/*
* FreeGLUT Shapes Demo
*
* Written by Nigel Stewart November 2003
*
* This program is test harness for the sphere, cone
* and torus shapes in FreeGLUT.
*
* Spinning wireframe and smooth shaded shapes are
* displayed until the ESC or q key is pressed. The
* number of geometry stacks and slices can be adjusted
* using the + and - keys.
*/
#include<GL/glut.h>
#include<stdlib.h>
void init()
{
glClearColor(1.0, 1.0, 1.0, 0.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0, 100.0, 0.0, 100.0);
}
void drawLine()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor4f(0.0, 0.5, 0.0, 0.5);
glBegin(GL_TRIANGLES);
glVertex2i(0, 0);
glColor4f(0.5, 0.0, 0.0, 0.5);
glVertex2i(50, 90);
glColor4f(0.0, 0.0, 0.5, 0.5);
glVertex2i(90, 50);
glEnd();
glFlush();
}
void main()
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(200, 200);
glutInitWindowSize(150, 500);
glutCreateWindow("an example opengl program");
init();
glutDisplayFunc(drawLine);
glutMainLoop();
}
* FreeGLUT Shapes Demo
*
* Written by Nigel Stewart November 2003
*
* This program is test harness for the sphere, cone
* and torus shapes in FreeGLUT.
*
* Spinning wireframe and smooth shaded shapes are
* displayed until the ESC or q key is pressed. The
* number of geometry stacks and slices can be adjusted
* using the + and - keys.
*/
#include<GL/glut.h>
#include<stdlib.h>
void init()
{
glClearColor(1.0, 1.0, 1.0, 0.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0, 100.0, 0.0, 100.0);
}
void drawLine()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor4f(0.0, 0.5, 0.0, 0.5);
glBegin(GL_TRIANGLES);
glVertex2i(0, 0);
glColor4f(0.5, 0.0, 0.0, 0.5);
glVertex2i(50, 90);
glColor4f(0.0, 0.0, 0.5, 0.5);
glVertex2i(90, 50);
glEnd();
glFlush();
}
void main()
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(200, 200);
glutInitWindowSize(150, 500);
glutCreateWindow("an example opengl program");
init();
glutDisplayFunc(drawLine);
glutMainLoop();
}
本文介绍了一个使用FreeGLUT库展示多种3D几何形状的简单程序实例。该程序能够显示旋转的线框和光滑着色的球体、圆锥及环面,用户可以通过按键调整几何体的堆叠和切片数量。

被折叠的 条评论
为什么被折叠?



