View Full Version : glReadPixels doesnt work
i used glReadPixels to provide saving of frames in my CAD program.but iam getting nothing. more over i used glGetIntegerv(GL_VIEWPORT,array) but iam getting nothing in that array. i donno what is the problem .
glReadPixels(0,0,array,array,GL_BGR_EXT,GL_UNSIGNED_BYTE,buffer) is used in my rendering func but iam getting nothing in to that buffer. it is as same as before calling the glReadPixels() function.
is there is any thing that iam missing?
03-03-2004, 11:07 AM
Edit, OK I see what you're saying now.
Well it looks about right. Have you tried hardwiring the width & height instead of querrying just incase its a problem isolated to that call. It may also be that the viewport is set to some bogus value.
Also make sure your OpenGL context is current when you make the querry and perform the read. You could also try and use array  and  for the read if you get it working.
[This message has been edited by dorbie (edited 03-03-2004).]
yup dorbie, thanks for the answer . but i already did gave staticc values in height a nd width values in glReadPixels. moreover iam having only one rendering Context so there no more repeated making it current context i think. and get glGetIntegerv() does not work it gives a very large -ve value. anmd i forgot to tell iam Usin MFC. and also i just tried the code from the openGL superBible for that reading the frame buffer. but still there is no use.my disk saving routine is ok its working the only problem is glReadPixels doent do any thing at all!
here is the code that iam using
width=(width+3) & ~3;
bitsize = width*myviewport;
TRACE1("memrequired for BMP=%d",bitsize);
//ok lets initialize the bitmap header
plz i really want some help! iam waiting !
oh mighty OpenGl GOD , kindly send a angel to help me with my problem! a angel with answer to my question. http://www.opengl.org/discussion_boards/ubb/wink.gif
and forgot to tell ! my pixel format in the program is "6" . i donno what does it mean :[
03-04-2004, 12:48 PM
Please do us a favor
printf("Vendor is %s\n",vendor);
printf("Renderer is %s\n",renderer);
Please insert that into your routine and post the results.
My suspicion is that you might be in software mode ("Microsoft GDI generic"), and don't have support for the GL_BGR_EXT format.
Your code does a lot of stuff and it's hard to tell where it fails. Try something simpler, like
GLubyte* read_buffer=(GLubyte*)malloc(100*100*3*sizeof(GLub yte));
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.