求助关于计算机图形学中关于贴图的操作
glBegin(GL_QUADS);glTexCoord2f(0.0f,0.0f);glVertex3f(-1.0f,-1.0f,0.0f);glTexCoord2f(0...
glBegin(GL_QUADS);
glTexCoord2f(0.0f,0.0f);glVertex3f(-1.0f,-1.0f,0.0f);
glTexCoord2f(0.0f,1.0f);glVertex3f(-1.0f,1.0f,0.0f);
glTexCoord2f(1.0f,1.0f);glVertex3f(1.0f,1.0f,0.0f);
glTexCoord2f(1.0f,0.0f);glVertex3f(1.0f,-1.0f,0.0f);
glEnd();
glDisable(GL_TEXTURE_2D);
这是对于纹理坐标的定义
要是我有这么一个四边形
glBegin(GL_POLYGON);
glVertex3f(-0.5f, 0.5f, 0.5f);
glVertex3f(-0.5f, -0.5f, 0.5f);
glVertex3f(0.5f, -0.5f, 0.5f);
glVertex3f(0.5f, 0.5f, 0.5f);
glEnd();
怎么给它贴上照片,
求详细代码
各位大哥帮帮忙
嗯 这个我已经知道了,谢谢各位 ,但是还有一个疑问,就是怎么给六面贴上不同的图片呢
在线等啊 展开
glTexCoord2f(0.0f,0.0f);glVertex3f(-1.0f,-1.0f,0.0f);
glTexCoord2f(0.0f,1.0f);glVertex3f(-1.0f,1.0f,0.0f);
glTexCoord2f(1.0f,1.0f);glVertex3f(1.0f,1.0f,0.0f);
glTexCoord2f(1.0f,0.0f);glVertex3f(1.0f,-1.0f,0.0f);
glEnd();
glDisable(GL_TEXTURE_2D);
这是对于纹理坐标的定义
要是我有这么一个四边形
glBegin(GL_POLYGON);
glVertex3f(-0.5f, 0.5f, 0.5f);
glVertex3f(-0.5f, -0.5f, 0.5f);
glVertex3f(0.5f, -0.5f, 0.5f);
glVertex3f(0.5f, 0.5f, 0.5f);
glEnd();
怎么给它贴上照片,
求详细代码
各位大哥帮帮忙
嗯 这个我已经知道了,谢谢各位 ,但是还有一个疑问,就是怎么给六面贴上不同的图片呢
在线等啊 展开
3个回答
展开全部
纹理贴图的步骤:创建纹理对象,指定一个纹理;确定纹理的使用方式;启用纹理;提供纹理坐标绘制几何图形。
你代码上面部分本身就是设置纹理坐标并且绘制了一个方形的。然后 glDisable(GL_TEXTURE_2D);这句话禁用了纹理。
至于绘制部分,比较简单,改成如下即可:
glBegin(GL_POLYGON);
glTexCoord2f(0.0f,0.0f);glVertex3f(-0.5f, 0.5f, 0.5f);
glTexCoord2f(1.0f,0.0f);glVertex3f(-0.5f, -0.5f, 0.5f);
glTexCoord2f(1.0f,1.0f);glVertex3f(0.5f, -0.5f, 0.5f);
glTexCoord2f(1.0f,0.0f);glVertex3f(0.5f, 0.5f, 0.5f);
glEnd();
你代码上面部分本身就是设置纹理坐标并且绘制了一个方形的。然后 glDisable(GL_TEXTURE_2D);这句话禁用了纹理。
至于绘制部分,比较简单,改成如下即可:
glBegin(GL_POLYGON);
glTexCoord2f(0.0f,0.0f);glVertex3f(-0.5f, 0.5f, 0.5f);
glTexCoord2f(1.0f,0.0f);glVertex3f(-0.5f, -0.5f, 0.5f);
glTexCoord2f(1.0f,1.0f);glVertex3f(0.5f, -0.5f, 0.5f);
glTexCoord2f(1.0f,0.0f);glVertex3f(0.5f, 0.5f, 0.5f);
glEnd();
展开全部
glBegin(GL_QUADS);
glTexCoord2f(0.0f,0.0f);glVertex3f(-0.5f, 0.5f, 0.5f);
glTexCoord2f(0.0f,1.0f);glVertex3f(-0.5f, -0.5f, 0.5f);
glTexCoord2f(1.0f,1.0f);glVertex3f(0.5f, -0.5f, 0.5f);
glTexCoord2f(1.0f,0.0f);glVertex3f(0.5f, 0.5f, 0.5f);
glEnd();
glDisable(GL_TEXTURE_2D);
纹理坐标不变的,只要把相应顶点的坐标改一下就可以了
glTexCoord2f(0.0f,0.0f);glVertex3f(-0.5f, 0.5f, 0.5f);
glTexCoord2f(0.0f,1.0f);glVertex3f(-0.5f, -0.5f, 0.5f);
glTexCoord2f(1.0f,1.0f);glVertex3f(0.5f, -0.5f, 0.5f);
glTexCoord2f(1.0f,0.0f);glVertex3f(0.5f, 0.5f, 0.5f);
glEnd();
glDisable(GL_TEXTURE_2D);
纹理坐标不变的,只要把相应顶点的坐标改一下就可以了
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1..定义纹理
void glTexImage1D/2D(
gL_TEXTURE_1D/2D,0,3,64,64,0,GL_RGB,GL_UNSIGNED_BYTE,checkImage[64][64][3]
);
括号中的都可以更改设置,其中,64是纹理图像的宽度和高度,checkImage[64][64][3]是纹理图像数据,这个要之前设置好.
2。纹理控制
glTexParameter(
GL_TEXTURE1D/2D,
GL_enum target,//纹理控制参数名,如GL_TEXTURE_MAG_FILTER/GL_TEXTURE_FILTER,
GL_enum param //纹理控制参数值,如GL_LINEAR_MIPMAP_NEAREST
)
3。映射方式
void glTexEnv(
GL_TEXTURE_ENV,
GL_TEXTURE_ENV_MODE,
GL_BLEND);
glEnable(GL_TEXTURE_2D);//启用纹理映射
4。创建纹理坐标与物体表面坐标之间的联系
之后就是楼上的回答的绘制部分了
void glTexImage1D/2D(
gL_TEXTURE_1D/2D,0,3,64,64,0,GL_RGB,GL_UNSIGNED_BYTE,checkImage[64][64][3]
);
括号中的都可以更改设置,其中,64是纹理图像的宽度和高度,checkImage[64][64][3]是纹理图像数据,这个要之前设置好.
2。纹理控制
glTexParameter(
GL_TEXTURE1D/2D,
GL_enum target,//纹理控制参数名,如GL_TEXTURE_MAG_FILTER/GL_TEXTURE_FILTER,
GL_enum param //纹理控制参数值,如GL_LINEAR_MIPMAP_NEAREST
)
3。映射方式
void glTexEnv(
GL_TEXTURE_ENV,
GL_TEXTURE_ENV_MODE,
GL_BLEND);
glEnable(GL_TEXTURE_2D);//启用纹理映射
4。创建纹理坐标与物体表面坐标之间的联系
之后就是楼上的回答的绘制部分了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询