openGL 例子
2011-05-02 13:10
155 查看
用openGL画出的基本图形。
#include <GL/gl.h> #include <GL/glaux.h> #define PI 3.1415926535897 int main(int argc, char** argv){ auxInitDisplayMode (AUX_SINGLE | AUX_RGBA); auxInitPosition (0, 0, 300, 300); auxInitWindow(argv[0]); glClearColor(1.0,0.0,1.0,0.5);//magenta // glClearDepth(0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // specify the point size in pixel. // non-antialiasing defaultly. glPointSize(5.0); //paint a ploygon on the screen. glBegin(GL_POINTS); glColor3f(0.0,0.0,0.0); glVertex2f(0.0,0.0);//v0 glVertex2f(0.1,0.1);//v1 glVertex2f(0.2,0.1);//v2 glVertex2f(0.4,0.0);//v3 glVertex2f(0.5,-0.1);//v4 glEnd(); // draw a stipple lines. glEnable(GL_LINE_STIPPLE); glLineStipple(1,0xAAAA); glBegin(GL_LINES); glVertex2f(0.0,0.0); glVertex2f(0.0,0.5); //glDisable(GL_LINE_STIPPLE); glEnd(); glDisable(GL_LINE_STIPPLE); glBegin(GL_LINE_LOOP); //draw a circle with specific points. int circle_points = 100; float angle = 0; int i = 0; for(i = 0;i<circle_points;i++) { // draw with yellow and black in turn. if(i%2==0){ glColor3f(1.0,1.0,0.0); }else{ glColor3f(0.0,0.0,0.0); } angle = 2*i*PI/circle_points; //the cos and sin will occupy hole screen. glVertex2f(0.5*cos(angle),0.5*sin(angle)); } glEnd(); //must add this to flush the buffer, so we can see the new picture. glFlush(); Sleep(5000); }
相关文章推荐
- opengl 例子学习笔记
- opengl 关于 投影变换,模型视图变换,视口变换 和多视口 的综合例子
- JAVA的OPENGL,JOGL入门例子----碰撞移动的正方体
- Computer Graphic with opengl第一个例子
- VS下Qt的例子使用OpenGL遇到glGetIntegerv函数崩溃
- OpenGL “太阳、地球和月亮”天体运动动画 例子
- OPENGL入门——第一个例子的讲解
- OpenGL例子:机器人手臂
- 分析一个别人的qt+opengl例子
- openGL 小例子
- OpenGL编程轻松入门之一个简单的例子
- 基于MFC的OpenGL的一个简单例子
- 在MFC下使用OpenGL的一个简单的例子
- ubuntu12.04上Using cairo with OpenGL 例子编译
- Opengl第一个小例子
- Android OpenGL例子学习
- opengl 第一个例子
- opengl视图变化 非常清楚的一例子
- HTC VIVE SDK 中的例子 hellovr_opengl 程序流程分析
- 从今日起,我会把OpenGL红宝书上的例子用完整的代码形式写在我的博客中,