Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image OpenGL标准单位度量_Image_Opengl_Import_Size_Textures - Fatal编程技术网

Image 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, -

我正在尝试导入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, -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)将映射到右上角。这叫做标准化设备坐标空间。谢谢你的回答