Subclass Component::setBufferedToImage for openGL


#1

… i’ve subclassed the OpenGLComponent function to something like this ( and enable snapshots of opengl screens ). The only thing is (apart from the fact that the image is flipped vertically, but this is not the problem) if i compile and run this at work (win2k sp4) i get the image correctly, but if i recompile at home (on xp sp2) i get a black screen even if there are a lot of opengl stuff moving.
here is the code:

[code] if (makeCurrentContextActive())
{
int width = getWidth();
int height = getHeight();
int lineStride, pixelStride;

	shotImage = new Image(Image::RGB,width,height,true);

	uint8* data = shotImage->lockPixelDataReadWrite (0,0,width,height,lineStride,pixelStride);

	glReadPixels(0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE,data);

	shotImage->releasePixelDataReadWrite(data);
}[/code]

what could be ?


#2

Probably some opengl quirk. Try explicitly making the component do its rendering before you do the glReadPixels?


#3

you might also try putting a

prior to calling the read pixels command. this should ensure all drawing operations are finished before you attempt to read from the gl buffer.

btw what gfx cards do each of your machines have?


#4

[quote=“colinbear”]you might also try putting a

prior to calling the read pixels command. this should ensure all drawing operations are finished before you attempt to read from the gl buffer.

btw what gfx cards do each of your machines have?[/quote]

on win2k i have a 865g internal gpu (and it works correctly)
on wxp i have an ati 9600 pro (always black when reading)

i’m trying your suggestion right now…


#5

Hello

I am experiencing the same problem. I would like to read from the framebuffer in a separate function on demand, but obviously the context is not active so i dont get anything. Rendering is done all correct though. Have you solved your problem?

Thx in advance

Nina


#6

Ah was a quite old work. I have to see if i can find again the project. I remember i ended up stating my 9600pro card was fucked up cause on other nvidia and intel cards was working good (with a glFlush before calling glReadPixels).


#7