Image OpenGL标准单位度量
我正在尝试导入OpenGl项目中的图像作为场景的背景Image OpenGL标准单位度量,image,opengl,import,size,textures,Image,Opengl,Import,Size,Textures,我正在尝试导入OpenGl项目中的图像作为场景的背景 loadTGA("Textures\\greenhill_positive_x.tga",skyboxTexture[1]); sizeX = 20.0; sizeY = 20.0; sizeZ = 3.0; glBindTexture(GL_TEXTURE_2D, skyboxTexture[1]); glBegin(GL_QUADS); glTexCoord2f(1, 1);glVertex3f(sizeX, -sizeY, -
loadTGA("Textures\\greenhill_positive_x.tga",skyboxTexture[1]);
sizeX = 20.0; sizeY = 20.0; sizeZ = 3.0;
glBindTexture(GL_TEXTURE_2D, skyboxTexture[1]);
glBegin(GL_QUADS);
glTexCoord2f(1, 1);glVertex3f(sizeX, -sizeY, -sizeZ);
glTexCoord2f(0, 1);glVertex3f(-sizeX, -sizeY, -sizeZ);
glTexCoord2f(0, 0);glVertex3f(-sizeX, -sizeY, sizeZ);
glTexCoord2f(1, 0);glVertex3f(sizeX, -sizeY, sizeZ);
glEnd();
代码运行良好,但纹理大小已调整为适合sizeX
、sizeY
、sizeZ
值。tga
文件的大小为250x250 px。我应该将哪些值传递给sizeX
,sizeY
,sizeZ
,以匹配图像大小 如果加载所有模式的标识矩阵,那么它只是:
glBegin(GL_QUADS);
glTexCoord2f(1, 1);glVertex3f(1, 1, 0);
glTexCoord2f(0, 1);glVertex3f(-1, 1, 0);
glTexCoord2f(0, 0);glVertex3f(-1, -1, 0);
glTexCoord2f(1, 0);glVertex3f(1, -1, 0);
glEnd();
您应该禁用深度写入和测试。这取决于您的投影和modelview矩阵。如果它们是相同的,则点(-1,-1,0)将映射到视口的左下角(最初与窗口的尺寸相同),而(1,1,0)将映射到右上角。这叫做标准化设备坐标空间。谢谢你的回答