我正在使用 GLUT 与 OpenGL 一起工作(如果可以的话,我会与 SDL 一起工作)。我需要画球体。我正在使用gluSphere
,但它根本不画任何东西。
这是我的 GLUT 初始化:
// Initializes display
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(600, 600);
// Window settings
glutCreateWindow("Collision detect");
glClearColor(0.0, 0.0, 0.0, 1.0);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glEnable(GL_TEXTURE_2D);
二次初始化:
quadratic = gluNewQuadric();
if( !quadratic){
throw new PROGRAM_EXCEPTION( "Cannot initialize quadartic", NULL);
}
gluQuadricNormals(quadratic, GLU_SMOOTH);
//gluQuadricDrawStyle( quadratic, GLU_FILL);
gluQuadricTexture(quadratic, GL_TRUE); // Tried both GL_TRUE and GL_FALSE
还有我的绘图功能:
glPushMatrix();
glTranslatef( position.getX(), position.getY(), position.getZ());
// This commented piece of code draws dot where I want it to,
// so coordinates and camera position are just fine
// glBegin(GL_POINTS);
// glVertex3f( 0,0,0);
// glEnd();
gluSphere( quadratic, 20.0f, 32, 32); // Tried r = 0.02f, 0.2f, 2.0f, 20.0f, none works
glPopMatrix();
问题:我错过了什么?是否有一些技巧可以让二次方程绘制?它与我的某些设置不兼容吗?
我花了几个小时试图解决这个问题,尝试了不同的东西......如果你需要一些其他的代码,只需说出哪个......我不想在这里粘贴 2000 行。还有一件事,我已经三重检查,我没有在里面使用它glBegin()
和glEnd()
. 我有几个三角形包围空间,它们画得很好。