【问题标题】:Need the source code for glutSolidTeapot() API been used in opengl?需要在 opengl 中使用 glutSolidTeapot() API 的源代码吗?
【发布时间】:2015-05-16 22:46:16
【问题描述】:

谁能给我 glutSolidTeapot() API 在 opengl 中使用的 源代码 吗?
我的项目需要动画打开和关闭青色。
实现相同的相关代码会很棒。

【问题讨论】:

  • 这个论坛是针对技术问题的,而不是你可以找到实现 API 的代码的地方。
  • 这是一个 GLUT 函数,即不是 OpenGL 的一部分。 GLUT 有多种实现,其中两个是开源的,例如 FreeGLUT。因此您可以从那里获取代码。

标签: opengl glut opengl-4


【解决方案1】:
// Ghulam Mujtaba

#include <windows.h>
#include <GL/gl.h>    
#include <GL/glu.h>
#include <GL/glut.h>
static GLuint w=800,h=600;
void init( void)
{
glShadeModel (GL_SMOOTH);
glClearColor (1.0f, 1.0f, 1.0f, 1.0f);  
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);

}
void display(void){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//glPushMatrix();
glLoadIdentity();


glTranslatef(0.0,0.0,0.0);
// glRotatef(0.0,0.0,0.0,0.0);
//glScalef(0.0,0.0,0.0);
glColor3f (1.0f, 0.0f, 1.0f);
glutWireTeapot(1.0);//glutSolidTeapote(.25);
glFlush();
glutSwapBuffers();
}
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(90.0, (GLfloat) w/(GLfloat) h, 1.0, 50.0);
//glFrustum (-2.0, 2.0, -2.0, 2.0, 1.5, 20.0);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
//gluLookAt(0.0,0.0,15.0,0.0,-2.0,0.0,0.0,1.0,0.0);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize (w, h);
glutInitWindowPosition (100, 100);
glutCreateWindow ("TEAPOT");
init ();
//glutKeyboardFunc(key);
glutDisplayFunc(display);
glutIdleFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}

【讨论】:

  • op 要求提供glutSolidTeapot 的代码,而不是如何使用它的示例。
  • 没有解释的代码转储给出的答案很差。
猜你喜欢
  • 1970-01-01
  • 2020-05-31
  • 2012-12-07
  • 1970-01-01
  • 2011-09-05
  • 1970-01-01
  • 1970-01-01
  • 2023-01-08
  • 2014-04-09
相关资源
最近更新 更多