• 大小: 7.44MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-03
  • 语言: 其他
  • 标签: OpenGL  纹理  

资源简介

计算机图形学 OpenGL 实验六 纹理贴图 包括二重纹理

资源截图

代码片段和文件信息

#include 
#include 
#include 

#include 
#include 
#include “texload.h“
#pragma comment(lib“glew32.lib“)

#define TEXW 512
#define TEXH 512
#define selfWidth 64
#define selfHeight 64

static GLubyte self[selfHeight][selfWidth][4];

float fTranslate;
float fRotate;
float fScale     = 1.0f; // set initial scale value to 1.0f

bool bPersp = false;
bool bAnim = false;
bool bWire = false;
bool change=false;         //茶壶纹理切换
bool light=false;      //茶壶高光
bool multiTexture=false;   //多重纹理叠合

int wHeight = 0;
int wWidth = 0;

static GLuint texture[4];

GLfloat mat_shininess[] = { 50.0 };
GLfloat mat_teapot_ambient[] = {0.2f 0.2f 0.2f 1.0f};
GLfloat mat_teapot_diffuse[] = {1.0f 1.0f 1.0f 1.0f};//白色漫射光
GLfloat mat_specular_teapot[] = {1.0f 1.0f 1.0f 1.0f};//白色高光

void makeselfImage()
{
int ijc;
for(i=0;i for(j=0;j c=(((i&0x8)==0)^((j&0x8)==0))*255;
self[i][j][0]=(GLubyte)c;
self[i][j][1]=(GLubyte)c;
self[i][j][2]=(GLubyte)c;
self[i][j][3]=(GLubyte)255;
}
}
}
//定义纹理的函数:
void init()
{            
glGenTextures(4 texture);                  //第一参数是需要生成标示符的个数 第二参数是返回标示符的数组
texload(0“monet.bmp“texture);
texload(1“Crack.bmp“texture);
texload(2“Spot.bmp“texture);

makeselfImage();//生成自定义纹理
glBindTexture(GL_TEXTURE_2Dtexture[3]);                             
glPixelStorei(GL_UNPACK_ALIGNMENT1); //设置像素存储模式所读取的图像数据的行对齐方式.
glTexImage2D(GL_TEXTURE_2D03selfWidthselfHeight0GL_RGBAGL_UNSIGNED_BYTEself);
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MAG_FILTERGL_LINEAR);
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MIN_FILTERGL_LINEAR);
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_WRAP_SGL_REPEAT);
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_WRAP_TGL_REPEAT);
}

void Draw_Leg(){
glScalef(1 1 3);
glBegin(GL_QUADS);
//front
glTexCoord2i(11); glVertex3f(0.50.50.5);//将当前(11)纹理坐标指定给 glVertex中的点
glTexCoord2i(10); glVertex3f(0.50.5-0.5);
glTexCoord2i(00); glVertex3f(0.5-0.5-0.5);
glTexCoord2i(01); glVertex3f(0.5-0.50.5);
//right
glTexCoord2i(11);glVertex3f(-0.50.50.5);//将当前(11)纹理坐标指定给 glVertex中的点
glTexCoord2i(10);glVertex3f(-0.50.5-0.5);
glTexCoord2i(00);glVertex3f(0.50.5-0.5);
glTexCoord2i(01);glVertex3f(0.50.50.5);

//back
glTexCoord2i(11);glVertex3f(-0.5-0.50.5);
glTexCoord2i(10);glVertex3f(-0.5-0.5-0.5);
glTexCoord2i(00);glVertex3f(-0.50.5-0.5);
glTexCoord2i(01);glVertex3f(-0.50.50.5);

//left
glTexCoord2i(11);glVertex3f(0.5-0.50.5);//将当前(11)纹理坐标指定给 glVertex中的点
glTexCoord2i(10);glVertex3f(0.5-0.5-0.5);
glTexCoord2i(00);glVertex3f(-0.5-0.5-0.5);
glTexCoord2i(01);glVertex3f(-0.5-0.50.5);
//up
glTexCoord2i(11);glVertex3f(-0.50.50.5);//将当前(11)纹理坐标指定给 glVertex中的点
glTexCoord2i(10); glVertex3f(0.50.50.5);
glTexCoord2i(00);glVertex3f(0.5-0.50.5);
glTexCoord2i(01); 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2011-11-30 18:57  exp6_Texture\
     目录           0  2011-11-30 18:58  exp6_Texture\exp6_Texture\
     文件         903  2011-05-02 21:10  exp6_Texture\exp6_Texture.sln
     文件       13312  2011-07-26 19:26  exp6_Texture\exp6_Texture.suo
     文件       49206  2007-07-06 08:24  exp6_Texture\exp6_Texture\Crack.bmp
     文件        3299  2011-07-26 16:52  exp6_Texture\exp6_Texture\exp6_Texture.vcxproj
     文件        1065  2011-07-26 16:52  exp6_Texture\exp6_Texture\exp6_Texture.vcxproj.filters
     文件      786488  2007-01-04 17:08  exp6_Texture\exp6_Texture\Monet.bmp
     文件       49206  2007-07-06 08:24  exp6_Texture\exp6_Texture\Spot.bmp
     文件        2869  2011-07-26 16:53  exp6_Texture\exp6_Texture\texload.h
     文件       11432  2011-07-26 16:54  exp6_Texture\exp6_Texture\Texture.cpp
     文件    12582966  2011-07-26 15:30  exp6_Texture\exp6_Texture\world.bmp

评论

共有 条评论