OpenGL基本图形的绘制

OpenGL基本图形的绘制

ID:40489655

大小:16.69 KB

页数:8页

时间:2019-08-03

OpenGL基本图形的绘制_第1页
OpenGL基本图形的绘制_第2页
OpenGL基本图形的绘制_第3页
OpenGL基本图形的绘制_第4页
OpenGL基本图形的绘制_第5页
资源描述:

《OpenGL基本图形的绘制》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、1.使用glColor,glPointSize函数绘制三个不同颜色和大小的点//T.cpp:Definestheentrypointfortheconsoleapplication.//#include"stdafx.h"#includevoidDisplay(void){glClear(GL_COLOR_BUFFER_BIT);glPointSize(5.0f);glBegin(GL_POINTS);glColor3f(1.0,0.0,0.0);glVertex2f(0.3f,0.5f);glEnd();glPointSize(

2、8.0f);glBegin(GL_POINTS);glColor3f(0.0,1.0,0.0);glVertex2f(0.0f,0.0f);glEnd();glPointSize(10.0f);glBegin(GL_POINTS);glColor3f(0.0,0.0,1.0);glVertex2f(-0.3f,-0.5f);glEnd();glFlush();}intmain(intargc,char*argv[]){glutInit(&argc,argv);glutInitDisplayMode(GLUT_RGB);glutInitWindowPos

3、ition(200,200);glutInitWindowSize(400,400);glutCreateWindow("ThreePoint");glutDisplayFunc(&Display);glutMainLoop();return0;}2.使用glColor,glLineWidth,glLineStripple函数绘制实心、虚线及渐变色线(1)实心线//T.cpp:Definestheentrypointfortheconsoleapplication.//#include"stdafx.h"#includevoidD

4、isplay(void){glClear(GL_COLOR_BUFFER_BIT);glColor3f(1.0,0.0,0.0);glEnable(GL_LINE_STIPPLE);glShadeModel(GL_SMOOTH);glLineStipple(2,0xFFFF);glLineWidth(2);glBegin(GL_LINES);glVertex2i(-100,0);glVertex2i(100,0);glEnd();glFlush();}intmain(intargc,char*argv[]){glutInit(&argc,argv);g

5、lutInitDisplayMode(GLUT_RGB);glutInitWindowPosition(200,200);glutInitWindowSize(400,400);glutCreateWindow("SolidLine");glutDisplayFunc(&Display);glutMainLoop();return0;}(2)虚线//T.cpp:Definestheentrypointfortheconsoleapplication.//#include"stdafx.h"#includevoidDisplay(v

6、oid){glClear(GL_COLOR_BUFFER_BIT);glColor3f(1.0,0.0,0.0);glEnable(GL_LINE_STIPPLE);glShadeModel(GL_SMOOTH);glLineStipple(4,0xAAAA);glLineWidth(2);glBegin(GL_LINES);glVertex2i(-100,0);glVertex2i(100,0);glEnd();glFlush();}intmain(intargc,char*argv[]){glutInit(&argc,argv);glutInitD

7、isplayMode(GLUT_RGB);glutInitWindowPosition(200,200);glutInitWindowSize(400,400);glutCreateWindow("DottedLine");glutDisplayFunc(&Display);glutMainLoop();return0;}(3)渐变线//T.cpp:Definestheentrypointfortheconsoleapplication.//#include"stdafx.h"#includeGLuintLine;voidInit

8、ial(void){glClearColor(0.0f,0.0f,0.0f,0.0f);Lin

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。