PART ONE
codes.cpp
#include <iostream>
#include <GL/freeglut.h>
using namespace std;
int main(int argc, char** argv)
{
glutInit(&argc, argv);
const char* name = "Default Framebuffer";
glutCreateWindow(name);
GLint xpixel;
glGetIntegerv(GL_MAX_PIXEL_MAP_TABLE, &xpixel);
cout << "Maxsize of xpixel is " << xpixel << endl;
GLint bpixel;
//GL_MAX_VIEWPORT_DIMS|GL_MAX_RENDERBUFFER_SIZE(RBO)
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &bpixel);
cout << "Maxsize of bpixel is " << bpixel << endl;
GLint screen_w = glutGet(GLUT_SCREEN_WIDTH);
GLint screen_h = glutGet(GLUT_SCREEN_HEIGHT);
cout << "Screen's width is " << screen_w << endl;
cout << "Screen's height is " << screen_h << endl;
GLint window_w = glutGet(GLUT_WINDOW_WIDTH);
GLint window_h = glutGet(GLUT_WINDOW_HEIGHT);
cout << "Window's width is " << window_w << endl;
cout << "Window's height is " << window_h << endl;
glutMainLoop();
return 0;
}
PART TWO
代码分析
1、通过glGetIntegerv()函数,查询GL_MAX_PIXEL_MAP_TABLE、GL_MAX_TEXTURE_SIZE,得到65536和16384。将65536的单位定义为xpixel,16384的单位定义为bpixel,则xpixel = 4*bpixel。
2、通过glutGet()函数,查询GLUT_SCREEN_WIDTH、GLUT_SCREEN_HEIGHT,得到屏幕的大小为1280*720,将单位定义为wpixel。
3、屏幕的分辨率实际为1920*1080,将单位定义为spixel。1280*720与1920*1080的映射关系为X~Y:1.5,即spixel = 1.5*wpixel。
4、通过glutGet()函数,查询GLUT_WINDOW_WIDTH、GLUT_WINDOW_HEIGHT,得到window中viewport的大小为300*300wpixel。注意:实际查询的是窗口中视口的大小,而非整个窗口的大小。
5、spixel = screen pixel(屏幕分辨率)、wpixel = window pixel(窗口分辨率)、bpixel = buffer pixel(缓冲分辨率)、xpixel = 01 pixel(地址分辨率)。