资源预览内容
第1页 / 共49页
第2页 / 共49页
第3页 / 共49页
第4页 / 共49页
第5页 / 共49页
第6页 / 共49页
第7页 / 共49页
第8页 / 共49页
第9页 / 共49页
第10页 / 共49页
亲,该文档总共49页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
#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.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 #include 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(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 #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); 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 | GLUT_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); glPointSize(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); glutInitDisplayMode(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)#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);/设?置?第台?一?个?顶¥点?的?坐?标括?为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 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);glMatrixMode(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);glutDisplayFunc(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
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号