Hi,
I wrote a simple application that loads a 3d model.
I also would grab images from framebuffer, so I add this code:
glutPostRedisplay();
glutSwapBuffers();
.
.
glGetIntegerv(GL_VIEWPORT, geom);
width = geom[2];
height = geom[3];
input = (GLubyte *) malloc(width * height * 3 * sizeof(GLubyte));
if(!input){
perror("\nMalloc video buffer");
exit(0);
}
glReadBuffer(GL_BACK);
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, input);
Then I write input buffer in a file in ppm format.
I get good images, but if I resize manually app's window I only get
confused image files.
What is wrong in my code?
Thanks,
Alessandro Marino
|
|
0
|
|
|
|
Reply
|
a_marino
|
3/1/2004 8:26:30 AM |
|
Alex wrote:
>
> glGetIntegerv(GL_VIEWPORT, geom);
> width = geom[2];
> height = geom[3];
> I get good images, but if I resize manually app's window I only get
> confused image files.
> What is wrong in my code?
>
The viewport isn't the the same as the size
of the window.
--
<\___/> "To err is human, to moo bovine."
/ O O \
\_____/ FTB. For email, remove my socks.
|
|
0
|
|
|
|
Reply
|
fungus
|
3/1/2004 9:50:20 AM
|
|
Alex wrote:
> Hi,
> I wrote a simple application that loads a 3d model.
> I also would grab images from framebuffer, so I add this code:
>
> glutPostRedisplay();
> glutSwapBuffers();
> .
> .
> glGetIntegerv(GL_VIEWPORT, geom);
> width = geom[2];
> height = geom[3];
>
> input = (GLubyte *) malloc(width * height * 3 * sizeof(GLubyte));
> if(!input){
> perror("\nMalloc video buffer");
> exit(0);
> }
> glReadBuffer(GL_BACK);
> glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, input);
>
> Then I write input buffer in a file in ppm format.
> I get good images, but if I resize manually app's window I only get
> confused image files.
> What is wrong in my code?
>
>
> Thanks,
> Alessandro Marino
Hi,
have you tried to set glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ) ?
The error might occur when you write your ppm from your "input"
array. The default unpack-alignment is 4 bytes, so when you resize your
window to a non-multiple of 4 you might get into trouble.
Regards,
Toni
--
for mail, mirror: ed.lausivksa@elielb
|
|
0
|
|
|
|
Reply
|
Antonio
|
3/1/2004 11:13:01 AM
|
|
"Alex" <a_marino@libero.it> wrote in message
news:f51b1ea6.0403010009.17465faa@posting.google.com...
> Hi,
> I wrote a simple application that loads a 3d model.
> I also would grab images from framebuffer, so I add this code:
>
> glutPostRedisplay();
> glutSwapBuffers();
> .
> .
> glGetIntegerv(GL_VIEWPORT, geom);
> width = geom[2];
> height = geom[3];
>
> input = (GLubyte *) malloc(width * height * 3 * sizeof(GLubyte));
> if(!input){
> perror("\nMalloc video buffer");
> exit(0);
> }
> glReadBuffer(GL_BACK);
> glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, input);
>
> Then I write input buffer in a file in ppm format.
> I get good images, but if I resize manually app's window I only get
> confused image files.
> What is wrong in my code?
>
>
> Thanks,
> Alessandro Marino
You have to handle resize event and update viewport size.
After that your code will work...
yooyo
|
|
0
|
|
|
|
Reply
|
news
|
3/1/2004 11:14:48 AM
|
|
I already handle resize event with:
static void reshape ( int w, int h )
{
glViewport ( 0, 0, w, h ) ;
}
and glutReshapeFunc( reshape );
But the application doesn't work.
Alessandro
> > glutPostRedisplay();
> > glutSwapBuffers();
> > .
> > .
> > glGetIntegerv(GL_VIEWPORT, geom);
> > width = geom[2];
> > height = geom[3];
> >
> > input = (GLubyte *) malloc(width * height * 3 * sizeof(GLubyte));
> > if(!input){
> > perror("\nMalloc video buffer");
> > exit(0);
> > }
> > glReadBuffer(GL_BACK);
> > glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, input);
> >
> > Then I write input buffer in a file in ppm format.
> > I get good images, but if I resize manually app's window I only get
> > confused image files.
> > What is wrong in my code?
> >
> >
> > Thanks,
> > Alessandro Marino
>
> You have to handle resize event and update viewport size.
> After that your code will work...
>
> yooyo
|
|
0
|
|
|
|
Reply
|
a_marino
|
3/1/2004 4:44:42 PM
|
|
|
4 Replies
688 Views
(page loaded in 0.045 seconds)
Similiar Articles: Framebuffer readback, preferrable faster then glReadPixels - comp ...Framebuffer grab problem using glReadPixel() - comp.graphics.api ..... buffer"); exit(0); } glReadBuffer(GL_BACK); glReadPixels(0 ... Framebuffer readback, preferrable ... Grabbing float pixel values (from frame buffer)? - comp.graphics ...There are just color values representing the pixels you ... Framebuffer grab problem using glReadPixel() - comp ... is sometimes used to retain information about pixel ... Can i save an OpenGL scene as an image without showing it? - comp ...Framebuffer grab problem using glReadPixel() - comp.graphics.api ... Can i save an OpenGL scene as an image without showing it? - comp ..... scene on the screen and i can ... Redraw only some objects - comp.graphics.api.openglFramebuffer grab problem using glReadPixel() - comp.graphics.api ... Redraw only some objects - comp.graphics.api.opengl... objects as a simple polygon, there is no ... How to draw framebuffer to device context ? - comp.graphics.api ...Framebuffer grab problem using glReadPixel() - comp.graphics.api ..... objects as a simple polygon, there is no problem but when using ... how to use clipping or if ... glReadPixels question - comp.graphics.api.openglFramebuffer grab problem using glReadPixel() - comp.graphics.api ... glReadPixels question - comp.graphics.api.opengl... Image[700i*+j]); I am also using the GLUT library. Using glReadPixels to get a color - comp.graphics.api.opengl ...Framebuffer grab problem using glReadPixel() - comp.graphics.api ..... objects as a simple polygon, there is no problem but when using ... how to use ... with ... Simple polygon not working - comp.graphics.api.openglFramebuffer grab problem using glReadPixel() - comp.graphics.api ... Simple polygon not working - comp.graphics.api.opengl Framebuffer grab problem using ... OpenGL context across 3 monitors? - comp.graphics.api.opengl ...This is the problem, glut does not support muliview. ... Create the windows "by hand" using the pure API, this ... api.opengl... loop looks something like this: 1). grab ... Taking a frame from a live video - comp.soft-sys.matlab... Braille in an image") and now have a new problem to ... Framebuffer readback, preferrable faster then glReadPixels ... tip on how to take a snapshot or picture (or capture an ... Framebuffer grab problem using glReadPixel() - comp.graphics.api ...Hi, I wrote a simple application that loads a 3d model. I also would grab images from framebuffer, so I add this code: glutPostRedisplay(); glutS... android-ndk - Re: Problem with Framebuffer - msg#00171 - Recent ...Re: Problem with Framebuffer Hello Yog,I would not expect to be ... will be able to use glReadPixels to grab the ... Is there any opensource android APP using glReadPixel ... 7/21/2012 11:25:20 PM
|