如何在vc++6.0里面使用openGl.doc

如何在vc++6.0里面使用openGl.doc

ID:55281704

大小:34.50 KB

页数:10页

时间:2020-05-09

如何在vc++6.0里面使用openGl.doc_第1页
如何在vc++6.0里面使用openGl.doc_第2页
如何在vc++6.0里面使用openGl.doc_第3页
如何在vc++6.0里面使用openGl.doc_第4页
如何在vc++6.0里面使用openGl.doc_第5页
资源描述:

《如何在vc++6.0里面使用openGl.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、如何在vc++6.0里面使用openGl?你既可以建立Win32项目使用API,也可以建立MFC工程(一般不用MFC框架直接用API)我给你一个例子吧,建立Win32空项目,添加一个cpp文件,编译执行就行了(这是一个经典的opengl框架了)代码如下:#pragmacomment(lib,"opengl32.lib")#pragmacomment(lib,"glu32.lib")#pragmacomment(lib,"glaux.lib")#include#include#include#include

2、glaux.h>HDChDC=NULL;HGLRChRC=NULL;HWNDhWnd=NULL;HINSTANCEhInstance;BOOLkeys[256];BOOLactive=TRUE;BOOLfullscreen=TRUE;GLfloatrtri;GLfloatrquad;LRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM);GLvoidResizeGLScene(GLsizeiwidth,GLsizeiheight){if(height==0)height=1;glViewport(0,0,width,height);

3、glMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);glMatrixMode(GL_MODELVIEW);glLoadIdentity();}intInitGL(GLvoid){glShadeModel(GL_SMOOTH);glClearColor(0.0f,0.0f,0.0f,0.5f);glClearDepth(1.0f);glEnable(GL_DEPTH_TEST);glDepthFunc(GL_

4、LEQUAL);glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);returnTRUE;}intDrawGLScene(GLvoid){glClear(GL_COLOR_BUFFER_BIT

5、GL_DEPTH_BUFFER_BIT);glLoadIdentity();glTranslatef(-1.5f,0.0f,-6.0f);glRotatef(rtri,0.0f,1.0f,0.0f);glBegin(GL_TRIANGLES);glColor3f(1.0f,0.0f,0.0f);glVertex3f(0.0f,1.0f,

6、0.0f);glColor3f(0.0f,1.0f,0.0f);glVertex3f(-1.0f,-1.0f,1.0f);glColor3f(0.0f,0.0f,1.0f);glVertex3f(1.0f,-1.0f,1.0f);glColor3f(1.0f,0.0f,0.0f);glVertex3f(0.0f,1.0f,0.0f);glColor3f(0.0f,0.0f,1.0f);glVertex3f(1.0f,-1.0f,1.0f);glColor3f(0.0f,1.0f,0.0f);glVertex3f(1.0f,-1.0f,-1.0f);glColor3f(1.

7、0f,0.0f,0.0f);glVertex3f(0.0f,1.0f,0.0f);glColor3f(0.0f,1.0f,0.0f);glVertex3f(1.0f,-1.0f,-1.0f);glColor3f(0.0f,0.0f,1.0f);glVertex3f(-1.0f,-1.0f,-1.0f);glColor3f(1.0f,0.0f,0.0f);glVertex3f(0.0f,1.0f,0.0f);glColor3f(0.0f,0.0f,1.0f);glVertex3f(-1.0f,-1.0f,-1.0f);glColor3f(0.0f,1.0f,0.0f);gl

8、Vertex3f(-1.0f,-1.0f,1.0f);glEnd();glLoadIdentity();glTranslatef(1.5f,0.0f,-7.0f);glRotatef(rquad,1.0f,1.0f,1.0f);glBegin(GL_QUADS);glColor3f(0.0f,1.0f,0.0f);glVertex3f(1.0f,1.0f,-1.0f);glVertex3f(-1.0f,1.0f,-1.0f);glVertex3f(-1.0f,1.0f,1.0f);glVertex3f(1.0f,1.0f,1.

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

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

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