gpt4 book ai didi

java - 纹理坐标不起作用?

转载 作者:行者123 更新时间:2023-11-29 03:54:47 25 4
gpt4 key购买 nike

说真的,我对这段代码很生气,因为它不起作用:

switch(particle) {
case 0:
glBegin(GL_TRIANGLE_STRIP); // STONE
glNormal3f(0.0f, 0.0f, 1.0f);
glTexCoord2d(1, 1); glVertex3f(x+size, y+size, 0.0f); // Top Right
glTexCoord2d(0.5, 1); glVertex3f(x-size, y+size, 0.0f); // Top Left
glTexCoord2d(1, 0.5); glVertex3f(x+size, y-size, 0.0f); // Bottom Right
glTexCoord2d(0.5, 0.5); glVertex3f(x-size, y-size, 0.0f); // Bottom Left
glEnd();
break;
case 1:
glBegin(GL_TRIANGLE_STRIP); // EARTH
glNormal3f(0.0f, 0.0f, 1.0f);
glTexCoord2d(0.5, 0.5); glVertex3f(x+size, y+size, 0.0f); // Top Right
glTexCoord2d(0, 0.5); glVertex3f(x-size, y+size, 0.0f); // Top Left
glTexCoord2d(0.5, 0); glVertex3f(x+size, y-size, 0.0f); // Bottom Right
glTexCoord2d(0, 0); glVertex3f(x-size, y-size, 0.0f); // Bottom Left
glEnd();
break;
}

情况 0 工作正常,但情况 1 没有,我不知道为什么......这是图像(32x32,带有两个 16x16 子纹理):

enter image description here

最佳答案

假设案例 0 显然工作正常,案例 1 的纹理坐标是错误的。它们应该是:

glBegin(GL_TRIANGLE_STRIP);         // EARTH
glNormal3f(0.0f, 0.0f, 1.0f);
glTexCoord2d(0.5, 1.0); glVertex3f(x+size, y+size, 0.0f); // Top Right
glTexCoord2d(0, 1.0); glVertex3f(x-size, y+size, 0.0f); // Top Left
glTexCoord2d(0.5, 0.5); glVertex3f(x+size, y-size, 0.0f); // Bottom Right
glTexCoord2d(0, 0.5); glVertex3f(x-size, y-size, 0.0f); // Bottom Left
glEnd();

关于java - 纹理坐标不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6962397/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com