View Full Version : The best methond of storing and scan-converting the graphic primitives

08-08-2004, 06:33 PM
My current project deals with huge amount of basic graphic primitives, such as small lines, triangles or polygons. All of them are smaller
than the size of 64*64. My task is to implement a method of fast retrieving and scan converting selected ones onto the display.

I know there are several ways to implement it. One way of doing it is to store all the primitives in one big texture map and cut out the
desired ones when needed. The other way is to use vertex buffer? (Can I?)

My question is which way is faster and easier to implement? Is there any other alternative ways? Can anyone point out a place where I can find some existing developing guide for any of these methods? Any help is appreciated.


08-09-2004, 12:37 AM
Difficult to tell what "selected ones" means in this context.
The easiest and probably fastest way to draw graphics primitives is to just let the graphics hardware draw them for you.
Storing them in a big texture will waste a huge amount of memory and drawing takes longer because you need to raster more pixels to get the rectangle with the data on screen.
To find the fastest way to draw these would take some experiments and depends on how many primitives are drawn.

08-09-2004, 08:32 AM
1. Fastest and easiest way to implement is to use the WGL_ARB_buffer_region extension where you call a save function and it will save the color and depth+stencil automatically, and then you can call restore.
You can save many screenshots this way.

2. The alternative ways are glReadPixels/glDrawPixels which is also easy to do.

3. With textures, it can get complicated if you want to restore the depth+stencil.

08-09-2004, 08:58 AM
This is kinda out of OpenGL's remit. If you're talking about drawing the pixels of primitives fast OpenGL does this in hardware and you don't worry about details like "scan conversion" algorithms, just send the primitives to the graphics system using OpenGL calls, even if you have them in screen space already you can set up the matrices appropriately. This is usually called pixel fill in OpenGl and it doesn't necessarily use a scan conversion algorithm.

If you want to scan convert them yourself with a specific algorithm then you're really talkling about software rendering and not OpenGL rendering. You would do this in memory and probably display the final pixels to the screen which would be a very uninteresting use of OpenGL and not particularly fast. Maybe you need a different forum for your question or you need to restate it with better understanding of how OpenGL is used.

08-10-2004, 01:36 PM
Sorry, I think I didn't make myself clear.
1. In this project, I can't draw those primitives with algorithm in my program, because that is too slow.
2. I can't use the opengl command like gl_triangle, gl_line or gl_polygon to draw those primitives directly.
3. I must prestore those primitives into a big texture or a matrix array (each matrix represents a primitive) or anything else(you tell me please). Before I draw anything, I need to load the texture or the matrix array into the video memory so that the scan-conversion can be speeded up. Those primitives are not drawn in one time. I'll only draw the one I need. So I have to fetch the primitive from the big texture or the matrix array and scan-convert it onto the screen. The number of the primitives is around few thousand.

Can anyone tell me how to satisfy the requirement in the fastest way? Any help is appreciated.



08-10-2004, 01:44 PM
What form are the primitives in? Screen space triangles? World space triangles? Edge lists? This is all still too vague. You haven't said why you can't transform with OpenGL. Let's say you can't you can still take eyespace primitives and send them to OpenGL with an identity matrix on the modelview for example.

So... there's still not enough specifics on your motivation.

08-10-2004, 02:47 PM
Thanks for your quick response, dorbie.
No transforming in this project. What I save in the texture or the matrix will be scan-converted to the screen without any change.
For example, I have a 10*10 polygon like this:

0 0 0 0 0 1 0 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 1 1 1 1 1 1 0 0
0 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1
0 1 1 1 1 1 1 1 1 0
0 0 1 1 1 1 1 1 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

It is saved as a small part of the texture (like how we implement the font) or a matrix array. It will be drawn onto the screen with 1(black) and 0(white).

For example, I may have 10,000 such primitives. All the primitives will be stored as the 10*10 polygon shown above. Each time I may choose to scan convert 300 from the 10,000. I donít know which 300 I will choose each time. So I will try to load all 10,000 primitives to the video memory to achieve the fastest scan conversion.

Iíd like to know if thereís a method or command I can load such huge amount of data, e.g., all 10,000 primitives, into the video memory at once. Or if there exists other better method to achieve fast scan-conversion of such primitives.



08-10-2004, 03:45 PM
Well you may be able to load them as texture glyphs and use quads to draw them on the screen much as you use a font texture to draw characters.

If that's really what you want to do, pack them into some textures and use texture coordinates and quads to display them on the screen.