How do I get / set the default framebuffer width and height?

I want to know my default framebuffer size. I am reading the settings view port to a specific value, does not affect / set framebuffer sizes. Are there GL calls for this?

+3


source to share


1 answer


You cannot set the default framebuffer size using OpenGL calls. This is the size of the window, which is controlled by the interface of the windowing system (like EGL on Android). If you want to control it, this must happen as part of the initial window / surface / context setup, where the details are platform dependent.

I am not aware of a call that specifically specifies the default framebuffer size. But you can easily get it indirectly. The default values ​​for the viewport and the scissor rectangle correspond to the size of the window. So if you get them before resizing them, this will give you the window size.

From section 2.12.1 "Viewspace Management" in the spec:

Initially, w and h are set according to the width and height of the window that GL should render to.

From section 4.1.2 "Scissor test" in the spec:



Initially left = bottom = 0; the width and height are determined by the size of the GL window.

Thus, you can get the default framebuffer size with:

GLint dims[4] = {0};
glGetIntegerv(GL_VIEWPORT, dims);
GLint fbWidth = dims[2];
GLint fbHeight = dims[3];

      

or

GLint dims[4] = {0};
glGetIntegerv(GL_SCISSOR_BOX, dims);
GLint fbWidth = dims[2];
GLint fbHeight = dims[3];

      

+3


source







All Articles