PDA

View Full Version : Generating draw data



Stuart McDonald
01-24-2008, 11:22 PM
Hi,
I have a set of points which define connected lines making a 2D maze i.e. if you draw a line from one point to the next you end up back at the start and have drawn a maze.

I've created triangle strips from this and can draw a 3D view of maze fine. What I want to do now is create a large 2D array (of bytes) representing the maze. The resolution of the array maybe more or less than the size of the maze e.g. if the maze is 100 square then I may want a 2D array which is twice the "resolution" i.e. is 200x200. So the location [1][1] would correspond to the maze point 0.5,0.5 and [99][99] to the bottom corner 99,99.

Now I could do it all by hand i.e. "draw" the maze myself writing to the array, but what I'd like to do is set up my view and render to a texture which is the 2D array, or render to the screen and copy the pixels back to the array (if the array was bigger than the screen I would need multiple renders).

So can I set my view so that the drawn data correctly maps to the size of the array (above and looking down from some distance). Ten render to a texture using a shader to fill it? Is render to texture supported on older cards (I know I can't rely on NPOT textures). Would reading the screen be better? Any other approaches? General pointers?

Cheers,

Stuart.

ZbuffeR
01-25-2008, 01:25 AM
The simple method would be to render your tristrip with an ortho camera, from the the top, with correct scale to have correct pixel resolution.

http://www.opengl.org/wiki/index.php/Gen...3D_rendering.3F (http://www.opengl.org/wiki/index.php/General_OpenGL:_Transformations#How_do_I_draw_2D_c ontrols_over_my_3D_rendering.3F)

I am not sure if you want to really copy the render to texture (each time) or simply get it back once to use later multiple times.
For the latter : use glReadPixels to retrieve it, and you store the info to disk.
For the former : use either FBO (framebuffer object) or simply glCopyTexSubImage.

Stuart McDonald
01-27-2008, 11:53 PM
Worked a treat...Thanks!