基本上,我想做的是,导入 3ds 对象(完成)并使其看起来“实心”,以便我可以对其应用闪电
这是我得到的一部分:
这是我加载对象并将其放在屏幕上的地方
void render()
{
int l_index;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW); // Modeling transformation
glLoadIdentity();
glTranslatef(0.0,0.0,-500.0);
glColor3d(1,1,0);
glBegin(GL_TRIANGLES);
for (l_index=0;l_index<object.polygons_qty;l_index++)
{
glVertex3f( object.vertex[ object.polygon[l_index].a ].x,
object.vertex[ object.polygon[l_index].a ].y,
object.vertex[ object.polygon[l_index].a ].z);
glVertex3f( object.vertex[ object.polygon[l_index].b ].x,
object.vertex[ object.polygon[l_index].b ].y,
object.vertex[ object.polygon[l_index].b ].z);
glVertex3f( object.vertex[ object.polygon[l_index].c ].x,
object.vertex[ object.polygon[l_index].c ].y,
object.vertex[ object.polygon[l_index].c ].z);
}
glEnd();
glutSwapBuffers();
}
初始化器
void init(){
angle=30;
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_SMOOTH);
// Projection transformation
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-100.0f,100.0f,-100.0f,100.0f,100.0f,-100.0f);
gluPerspective(30.0f,(GLfloat)screen_width/(GLfloat)screen_height,10.0f,10000.0f);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST); // We enable the depth test (also called z buffer)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
CThreeMaxLoader::Load3DS(&object,"chesspawn.3ds");
}