OpenGL: “?pixel”

该博客探讨了OpenGL中的像素概念,包括通过glGetIntegerv()获取的最大像素映射表和纹理尺寸,以及使用glutGet()查询屏幕和窗口的分辨率。博主详细解释了不同分辨率之间的比例关系,如xpixel、bpixel、wpixel和spixel,并讨论了窗口中视口的大小与实际窗口大小的区别。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

PART ONE

44ed7982164c4bb6ada449912d1b767a.png

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(地址分辨率)。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值