PDA

View Full Version : read back buffer



Selina
05-13-2010, 12:52 PM
Hi there;
I am a beginner. I need some help in OpenGl to achieve my graduation project at university.

I have a sequence of 3 images of the same scene, so how can I divide my image into 3 vertical strips and then take the first strip of the first image, the second strip of the second image, and the third strip of the third image and then add them together in one new image so that the first strip is at the left, the second in the middle and the third on the right of the new image and display the resulting image?
I used: glReadBuffer(GL_BACK), glReadPixels, glDrawBuffer,glCopyPixels, and other functtions but in vain. any ideas?

int main(int argc, char** argv) {
glutInit(&argc, argv);


glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(1020, 768);


glutCreateWindow("Selina Rio - UCL London");
initRendering();
glutKeyboardFunc(handleKeypress);
glutReshapeFunc(handleResize);

if (counter == 1)
{
glReadBuffer(GL_BACK);

glReadPixels(0,0,340,768,GLUT_RGB,GLUT_DOUBLE,data );
}
if (counter == 2)
{
glReadBuffer(GL_BACK);

glReadPixels(341,0,340,768,GLUT_RGB,GLUT_DOUBLE,da ta);
}
if (counter == 3)
{
glReadBuffer(GL_BACK);

glReadPixels(680,0,340,768,GLUT_RGB,GLUT_DOUBLE,da ta);
}
...
...

glutMainLoop();
return 0;
}

dorbie
05-13-2010, 02:40 PM
Load each image as a texture.

Draw the required portions of texture using a quad and selecting the image portion with texture coordinates.

Position the quads using vertex values or modelview matrix manipulations.

If you have one big image you're trying to move around then you can just read it all and use a single texture for it all.

You then select portions using texture coordinates.

Modern hardware lets you use any size texture image but earlier hardware requires 2^n dimensions on each edge.

Selina
05-13-2010, 07:11 PM
Load each image as a texture.

Draw the required portions of texture using a quad and selecting the image portion with texture coordinates.

Position the quads using vertex values or modelview matrix manipulations.

If you have one big image you're trying to move around then you can just read it all and use a single texture for it all.

You then select portions using texture coordinates.

Modern hardware lets you use any size texture image but earlier hardware requires 2^n dimensions on each edge.


Thanks
I will apply your method with external images but I wonder if I can use it for images coming from the same program, I mean I produced an image with opengl, the image is an animation imported from Blender throughMD2 file format. The program works and produces the image but I need to snapshot the image at 3 different moment s and integrate them so that each image contribute with one portion and I have to generalize this method later to have more than one portion from each image (say 4 portions from each one) and add them together in one image. sorry I forgot to mention this previously. If your method is valid for this purpose, how to snapshot an image and save it so that I can pick up parts of the image and render then within another image with other parts from different images at the same time. Many thanks for help so far

Selina
05-14-2010, 07:49 PM
Load each image as a texture.

Draw the required portions of texture using a quad and selecting the image portion with texture coordinates.

Position the quads using vertex values or modelview matrix manipulations.

If you have one big image you're trying to move around then you can just read it all and use a single texture for it all.

You then select portions using texture coordinates.

Modern hardware lets you use any size texture image but earlier hardware requires 2^n dimensions on each edge.


Thanks Dorbie again for the reply.
In order to load the image as a textre I am trying to capture the image rendered by OpenGL on the monitor screen. To let the program do that I found a fucntion called glgrab.c from Apple. This is the link to the program:

http://code.google.com/p/telekinesis/source/browse/trunk/Mac/Source/glgrab.c?r=140#

My questions are: is that what you mean with your suggestion? Do I need to save the images as textures in different files and the then add them in one image? If that is what i have to do so can I save the screen usng opengl functions (glgrab for example) ? is there any alternative way to do that with opengl?

I hope to find a solution for this urgent matter
Many thanks for help


.