Many textures on 1texture or rendering screenshots

Hey guys,I’d be so grateful for any help :O)

I have a few textured triangles which are mainly the copy of one but rotated and translated etc. I now need to render out every frame (using someone else’s frame saving library) but don’t know how to bind all of these to just one large texture. How do I create a large array of pixels to then load all of the images in order to put them all on one texture. Alternatively how do I render out every frame that can be seen on the screen with or without texture mapping in the displayfunc?

you have troubles rendering a frame? or you want to put the rendered frame inside a large texture??

I would like to render out every frame. I’m using someones library to render frames out. I have used it before (please see below ) but only when I had an array of pixels and then I could set every pixel array (r,g,b) to the r,g,b of the outputImage (which is of type SGI, as named in the library). But now I have a different problem as I don’t have an array of pixels, I have a bunch of textures triangles and I could render them out one by one (I guess)but not every frame that can be seen with displayfunc. this is how I used it before:

SGI *outputImage = new SGI(OUTPUT_WIDTH, OUTPUT_HEIGHT, OUTPUT_NUM_CHANNELS, OUTPUT_BYTES_PER_CHANNEL);

and then

struct Pixel
{
unsigned char r,g,b;
};

Pixel *pixel_array = NULL;

for (int y = 0; y < array_height; y++)
{
for (int x = 0; x < array_width; x++)
{
outputImage->set(x, y, 0, pixel_array[y * array_height + x].r);
outputImage->set(x, y, 1, pixel_array[y * array_height + x].g);
outputImage->set(x, y, 2, pixel_array[y * array_height + x].b);
}
}

finally:
char outFileName[1024] = “”;
outputImage->writeAsJPG(outFileName);

and this happens in displayfunc which is called in Idlefunc and gets rendered constantly.
Thank you for your help.

sorry still have troubles to understand you. you would like to render out every frame. ok. you use third party lib to do that so after the rendering the final scene image is in the backbuffer right? now you need to get that data and save it as an image?
if yes, then you should use glReadPixels() to read out the pixels from the backbuffer after you rendered successfully. then you will have a memory where the scene image is located and can save it to a file. you need to know the lib well to capture the screen in correct place.

Thank you. Ah I see so I have to use glReadPixels() to capture each frame.
so I just did this but it crashed:

glReadPixels( 0,0, OUTPUT_WIDTH, OUTPUT_HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, pixel_array);

Not sure about the 0,0 for x and y

and then have to do this I guess like before:
or (int y = 0; y < array_height; y++)
{
for (int x = 0; x < array_width; x++)
{
outputImage->set(x, y, 0, pixel_array[y * array_height + x].r);
outputImage->set(x, y, 1, pixel_array[y * array_height + x].g);
outputImage->set(x, y, 2, pixel_array[y * array_height + x].b);
}
}

Thank you soooo much NK47. I needed glReadPixels as you said. I managed to sort it out eventually. All the very best

:O)

this is wrong:
y * array_height + x

it should be:

y * array_width + x

Also:

The initial value of GL_PACK_ALIGNMENT is 4. This is not safe.
Try with 1 (call it before glReadPixel() ):
glPixelStorei( GL_PACK_ALIGNMENT, 1 );

As your format is RGB, unless your “OUTPUT_WIDTH” is divisible by 4, you will have a crash with GL_PACK_ALIGNMENT.

This link is really helpful:
http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/

you’re welcome! glad i could help.

Will do, many thanks overlay. :O)