先複製上週程式碼
-glBegin(GL_POLYGON);
glTexCoord2f(0,1);glVertex2f(-1,-1
glTexCoord2f(1,1);glVertex2f(+1,-1);
glTexCoord2f(1,0);glVertex2f(+1,+1);
glTexCoord2f(0,0);glVertex2f(-1,+1);
glEnd();
-GLUquadric * sphere=NULL;
gluQuadricTexture(sphere,1);
gluSphere(sphere,1,30,30);
sphere=gluNewQuadric();
-把球加入一起旋轉
float angle=0;
glRotatef(angle,0,-1,0);
angle++;//轉太快可以自己調
glutIdleFunc(display);
-增加程式碼
#include "glm.h"記得glm.cpp要add file加入
GLMmodel * pmodel=NULL;
glPushMatrix();
glRotatef(angle,0,1,0);
if(pmodel==NULL){
pmodel=glmReadOBJ("data/Gundam.obj");
glmUnitize(pmodel);
glmFacetNormals(pmodel);
glmVertexNormals(pmodel,90);
}
glmDraw(pmodel,GLM_MATERIAL|GLM_TEXTURE);
glPopMatrix();
myTexture("data/Diffuse.jpg");
glEnable(GL_DEPTH_TEST);
改data/Diffuse.jpg的 檔案使其圖片垂直反轉才能將正確貼圖貼上
沒有留言:
張貼留言