opengl编程指南程序

上传人:桔**** 文档编号:498910336 上传时间:2024-02-12 格式:DOC 页数:49 大小:575.53KB
返回 下载 相关 举报
opengl编程指南程序_第1页
第1页 / 共49页
opengl编程指南程序_第2页
第2页 / 共49页
opengl编程指南程序_第3页
第3页 / 共49页
opengl编程指南程序_第4页
第4页 / 共49页
opengl编程指南程序_第5页
第5页 / 共49页
点击查看更多>>
资源描述

《opengl编程指南程序》由会员分享,可在线阅读,更多相关《opengl编程指南程序(49页珍藏版)》请在金锄头文库上搜索。

1、#include stdafx.h#include #include void display() glClearColor(0.0,0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT); glColor4f(1.0,1.0,0.0,1.0); / set the point color glPointSize(10); glBegin(GL_POLYGON); glVertex2f(0.0,0.0); glVertex2f(0.0,3.0); glVertex2f(4.0,3.0); glVertex2f(6.0,1.5); glVertex2f(4.0,0.

2、0); glEnd(); glFlush();int main(int argc, char* argv) glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE); glutInitWindowPosition(100, 100); glutInitWindowSize(400, 400); glutCreateWindow(第一个OpenGL程序); glutDisplayFunc(display); glutMainLoop(); return 0;#include stdafx.h#include #inclu

3、de void display() glClearColor(0.0,0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT); glColor4f(1.0,0.0,0.0,1.0); / set the point color glPointSize(10); glBegin(GL_POINTS); glVertex3f(-0.5,-0.5,0.0); glVertex3f(0.5,-0.5,0.0); glVertex3f(0.5,0.5,0.0); glVertex3f(-0.5,0.5,0.0); glEnd(); glFlush();int main(in

4、t argc, char* argv) glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE); glutInitWindowPosition(100, 100); glutInitWindowSize(400, 400); glutCreateWindow(第一个OpenGL程序); glutDisplayFunc(display); glutMainLoop(); return 0;#include stdafx.h#include #include void display() glClearColor(0.0

5、,0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT); glColor4f(1.0,1.0,0.0,1.0); glPointSize(10); glBegin(GL_TRIANGLES); glVertex3f(0.25,0.25,0.0); glVertex3f(0.75,0.25,0.0); glVertex3f(0.75,0.75,0.0); glEnd(); glFlush();int main(int argc, char* argv) glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GL

6、UT_SINGLE); glutInitWindowPosition(100, 100); glutInitWindowSize(400, 400); glutCreateWindow(第台?一?个?OpenGL程序); glutDisplayFunc(display); glutMainLoop(); return 0;#include #include void display()/ 绘?制?函数簓 glClearColor(0.0,0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT); glColor4f(1.0,1.0,0.0,1.0); glPoint

7、Size(10);glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);glBegin(GL_POLYGON);glEdgeFlag(GL_TRUE);glVertex3f (0.25,0.25,0.0);glEdgeFlag(GL_FALSE);glVertex3f(0.75,0.25,0.0);glEdgeFlag(GL_TRUE);glVertex3f(0.75,0.75,0.0); glEnd(); glFlush();int main(int argc, char* argv) glutInit(&argc, argv); glutInitDisplayM

8、ode(GLUT_RGB | GLUT_SINGLE); glutInitWindowPosition(100, 100); glutInitWindowSize(400, 400); glutCreateWindow(标括?记?多变?形?边?界?边?); glutDisplayFunc(display); glutMainLoop(); return 0;#include stdafx.h#pragma comment( lib, opengl32.lib )#pragma comment( lib, glu32.lib )#pragma comment( lib, glut32.lib)#

9、include #include void background(void)glClearColor(0.0,0.0,0.0,0.0);/设?置?背?景颜?色?为a黑色?void myDisplay(void)glClear(GL_COLOR_BUFFER_BIT);/buffer设?置?为a颜?色?可写glBegin(GL_TRIANGLES);/开a始?画-三角?形?glShadeModel(GL_SMOOTH);/设?置?为a光a滑?明暗悝?模式?glColor3f(1.0,0.0,0.0);/设?置?第台?一?个?顶¥点?为a红色?glVertex2f(-1.0,-1.0);/设?置?

10、第台?一?个?顶¥点?的?坐?标括?为a(辍?1.0,?-1.0)?glColor3f(0.0,1.0,0.0);/设?置?第台?二t个?顶¥点?为a绿色?glVertex2f(0.0,-1.0);/设?置?第台?二t个?顶¥点?的?坐?标括?为a(辍?.0,?-1.0)?glColor3f(0.0,0.0,1.0);/设?置?第台?三个?顶¥点?为a蓝?色?glVertex2f(-0.5,1.0);/设?置?第台?三个?顶¥点?的?坐?标括?为a(辍?0.5,?1.0)?glEnd();/三角?形?结束?glFlush();/强?制?OpenGL函数簓在有瓺限T时骸?间?内运?行Dvoid

11、myReshape(GLsizei w,GLsizei h)glViewport(0,0,w,h);/设?置?视酣?口glMatrixMode(GL_PROJECTION);/指?明当獭?前矩?阵为aGL_PROJECTIONglLoadIdentity();/将?当獭?前矩?阵置?换?为a单蹋?位?阵if(w = h)gluOrtho2D(-1.0,1.5,-1.5,1.5*(GLfloat)h/(GLfloat)w);/定义?二t维?正y视酣?投?影?矩?阵elsegluOrtho2D(-1.0,1.5*(GLfloat)w/(GLfloat)h,-1.5,1.5);glMatrixMod

12、e(GL_MODELVIEW);/指?明当獭?前矩?阵为aGL_MODELVIEWint main(int argc,char * argv)/*初?始?化*/glutInit(&argc,argv);glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);glutInitWindowSize(400,400);glutInitWindowPosition(200,200);/*创洹?建窗洹?口*/glutCreateWindow(Triangle);/*绘?制?与?显?示?*/background();glutReshapeFunc(myReshape);glut

13、DisplayFunc(myDisplay);glutMainLoop();return(0);#include stdafx.h#pragma comment( lib, opengl32.lib )#pragma comment( lib, glu32.lib )#pragma comment( lib, glut32.lib)#include #include static int shoulder = 0, elbow = 0;/shoulder:肩部角度,elbow:肘部角度void init(void) glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glShadeModel(GL_FLAT);void display(void) glClear(G

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 幼儿/小学教育 > 小学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号