How big is my framebuffer ?

Hello !

I have a problem understanding something. I am using OpenGL under windows. I use wglCreateContext to create an OpenGL context and glViewport to set up the viewport. How do I know how much memory is allocated for the framebuffer ? If the memory depends on the window’s dimensions, who will increase the framebuffer’s size when I do a resize, 'cause I certainly am not. Does it mean that the framebuffer’s dimensions are the width and height of the wiewport ?

Thanks.

Come on, nobody knows ?

Expecting an answer in 17 minutes is a tad too optimistic, don’t ya think?

I’m not too sure of the answer myself, but I’d say multiply your resolution * depth + resolution * stencil + resolution * zbuffer.

So a 1600 x 1200, 32bit would be:
1920000 * 32 (4 byte) = 7680000
1920000 * 1 (8 bit stencil) = 1920000
1920000 * 2 (16 bit zbuffer) = 3840000
= 13,440,000

I hope…

Bode

[This message has been edited by Bode (edited 10-28-2003).]

I am in windowed mode. I don’t think that the framebuffer should be bound by my desktop resolution. It should depend on my window’s size or my viewport’s size. That’s logic. The problem is which one ? I find it more logic to depend on the viewport’s size, but this way a change in the wiewport’s width or height would change the framebuffer, which is odd…

The frame buffer should definitely not be limited by the viewport. The viewport just describes a viewport transform which is applied to a vertex after perspective division. But nothing stops you from drawing outside the viewport, assuming it’s still within the window area.

What determines the actual size of the frame buffer is, I assume, an implementation detail. Some implementations may have a set of buffers per window, other may have a single set of buffers shared by all windows. There is no way, using OpenGL, to get information on this.

I have tested my opengl implementration and I cannot draw outside the viewport…

The reason I have posted this question is whether glViewport is an expensive call or not. I don’t know what exactly is behind it, and the opengl documentation doesn’t specify that.

I have tested my opengl implementration and I cannot draw outside the viewport…

You cannot do it using primitives such as point, lines and triangles, beucase those are clipped to not intersect the view volume, and therefore will not intersect the viewport either. But it is possible using pixel transfers (glDrawPixels for example).

I don’t know what exactly is behind it, and the opengl documentation doesn’t specify that.

The viewport is just a viewport transform that maps the coordinates from normalized device coordinates to window coordinates. Just like the modelview matrix transform objects from local to world space, and the projection matrix transform objects from world to clip space.

Check out the API specification for more information. Section 2.10 in the 1.4 spec.