91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

基于opengl寫的一個小例程,繪制四面體,并且對其貼圖......程序比較簡單,適合入門

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?
#include?

static?GLuint?texName;

static?int?rtri?=0;
float?normal[4][3];
float?p1[3]={0.0?2.00.0};
float?p2[3]={-1.0?0.0-1.0};
float?p3[3]={1.0?0.0-1.0?};
float?p4[3]={0.0?0.01.0};

AUX_RGBImageRec?*LoadBMP(char?*Filename)
{
FILE?*File=NULL;
if(!Filename){
return?NULL;
}

File=fopen(Filename“r“);

if?(File){
fclose(File);
return?auxDIBImageLoad(Filename);
}
return?NULL;
}

int?LoadGLTextures()
{
int?Status?=?FALSE;
AUX_RGBImageRec?*Image[1];
memset(Image0sizeof(void?*)*1);???????????

if?(Image[0]=LoadBMP(“Data/box.bmp“))
{
Status=TRUE;
glGenTextures(1?&texName);
glBindTexture(GL_TEXTURE_2D?texName);

glTexParameteri(GL_TEXTURE_2D?GL_TEXTURE_WRAP_S?GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D?GL_TEXTURE_WRAP_T?GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D?GL_TEXTURE_MAG_FILTER?GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D?GL_TEXTURE_MIN_FILTER?GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D?0?GL_RGBA?Image[0]->sizeX?Image[0]->sizeY?0?GL_RGB?GL_UNSIGNED_BYTE?Image[0]->data);
}

if?(Image[0]){
if?(Image[0]->data){
free(Image[0]->data);
}
free(Image[0]);
}
return?Status;
}

void?ReduceToUnit(float?vector[3])
{
float?length;

length?=?(float)sqrt((vector[0]*vector[0])+(vector[1]*vector[1])+(vector[2]*vector[2]));

if(length?==?0.0f)
length?=?1.0f;

vector[0]?/=?length;
vector[1]?/=?length;
vector[2]?/=?length;
}

void?donomal(float?p11[3]?float?p22[3]?float?p33[3]?float?nor[3]){
float?v1[3]v2[3];

v1[0]?=?p11[0]?-?p22[0];
v1[1]?=?p11[1]?-?p22[1];
v1[2]?=?p11[2]?-?p22[2];

v2[0]?=?p22[0]?-?p33[0];
v2[1]?=?p22[1]?-?p33[1];
v2[2]?=?p22[2]?-?p33[2];

nor[0]?=?v1[1]*v2[2]?-?v1[2]*v2[1];
nor[1]?=?v1[2]*v2[0]?-?v1[0]*v2[2];
nor[2]?=?v1[0]*v2[1]?-?v1[1]*v2[0];
ReduceToUnit(nor);
}

void?display(void)
{

glClear?(GL_COLOR_BUFFER_BIT?|?GL_DEPTH_BUFFER_BIT);
// glEnable(GL_TEXTURE_2D);
// glTexEnvf(GL_TEXTURE_ENV?GL_TEXTURE_ENV_MODE?GL_REPLACE);

glLoadIdentity();
gluLookAt?(0.0?0.0?5.0?0.0?0.0?0.0?0.0?1.0?0.0);
glRotatef(rtri1.01.00.0);

donomal(p1?p3?p2?normal[0]);
donomal(p1?p4?p3?normal[1]);
donomal(p1?p2?p4?normal[2]);
donomal(p2?p3?p4?normal[3]);

glBindTexture(GL_TEXTURE_2D?texName);
????glBegin?(GL_TRIANGLES);
glNormal3fv(normal[0]);
????????glTexCoord2f(0.0?0.0); glVertex3f(0.0?2.0?0.0);
????????glTexCoord2f(0.0?1.0); glVertex3f(-1.0?0.0?-1.0);
????????glTexCoord2f(1.0?0.0); glVertex3f(?1.0?0.0?-1.0);

glNormal3fv(normal[1]);
????????glTexCoord2f(0.0?0.0); glVertex3f(0.0?2.0?0.0);
????????glTexCoord2f(1.0?0.0); glVertex3f(1.0?0.0?-1.0);
????????glTexCoord2f(1.0?1.0); glVertex3f(?0.0?0.0?1.0);

glNormal3fv(no

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????66614??1999-09-25?20:19??3D?rendering\Data\box.bmp

????..A.SH.??????9728??2009-04-29?20:28??3D?rendering\Data\Thumbs.db

?????文件????2016256??2009-04-29?20:39??3D?rendering\Debug\Simple.bsc

?????文件?????237654??2009-04-29?20:39??3D?rendering\Debug\Simple.exe

?????文件?????394580??2009-04-29?20:39??3D?rendering\Debug\Simple.ilk

?????文件??????25127??2009-04-29?20:39??3D?rendering\Debug\Simple.obj

?????文件??????43520??2009-04-29?20:11??3D?rendering\Debug\Simple.opt

?????文件?????346292??2009-04-29?18:58??3D?rendering\Debug\Simple.pch

?????文件?????656384??2009-04-29?20:39??3D?rendering\Debug\Simple.pdb

?????文件??????????0??2009-04-29?20:39??3D?rendering\Debug\Simple.sbr

?????文件?????140288??2009-05-07?14:32??3D?rendering\Debug\vc60.idb

?????文件??????77824??2009-04-29?20:39??3D?rendering\Debug\vc60.pdb

?????文件???????6071??2009-04-29?20:35??3D?rendering\Simple.cpp

?????文件???????3467??2009-04-29?20:35??3D?rendering\Simple.dsp

?????文件????????537??2008-10-06?22:37??3D?rendering\Simple.dsw

?????文件??????50176??2009-05-07?14:32??3D?rendering\Simple.ncb

?????文件??????53760??2009-05-07?14:32??3D?rendering\Simple.opt

?????文件????????246??2009-05-07?14:32??3D?rendering\Simple.plg

?????文件????????333??2009-05-07?14:32??3D?rendering\Simple.sln

????..A..H.??????6656??2009-05-07?14:32??3D?rendering\Simple.suo

?????目錄??????????0??2009-04-29?20:28??3D?rendering\Data

?????目錄??????????0??2009-04-29?20:39??3D?rendering\Debug

?????目錄??????????0??2009-05-07?14:32??3D?rendering

-----------?---------??----------?-----??----

??????????????4135513????????????????????23


評論

共有 條評論