VC++中OpenGL的配置

一、下载并安装glut
    opengl
glut GLUT不是OpenGL所必须的,但它会给学习带来一定的方便,推荐安装。
    Windows
环境下的GLUT下载地址:(大小约为150k
    http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
    Windows
环境下安装GLUT的步骤:
    1
、将下载的压缩包解开,将得到5个文件
    2
、在我的电脑中搜索“gl.h”,并找到其所在文件夹(Program Files\Microsoft Visual Studio\VC98\Include\GL文件夹)。把解压得到的glut.h放到这个文件夹。
    3
、把解压得到的glut.libglut32.lib放到静态函数库所在文件夹(Program Files\Microsoft Visual Studio\VC98\lib”文件夹)。
    4
、把解压得到的glut.dllglut32.dll放到操作系统目录下面的system32文件夹内。(典型的位置为:C:\Windows\System32

二、VC工程配置:
  1)创建一个Win32 Console Application
  2)链接OpenGL libraries。单击Project,再单击Settings,再找到Link单击,最后在Object/library modules 的最前面加上opengl32.lib glu32.lib glut.lib glaux.lib <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

     3)修改代码如下:

None.gif
None.gif#include 
" stdafx.h "
None.gif#include 
< GL / glut.h >
None.gif
None.gif
void  display( void )
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif   glClear (GL_COLOR_BUFFER_BIT);
/**//* clear all pixels  */
InBlock.gif   glColor3f (
1.01.01.0);
ExpandedSubBlockStart.gifContractedSubBlock.gif   glBegin(GL_POLYGON);
/**//* draw white polygon with corners at(0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)*/
InBlock.gif      glVertex3f (
0.250.250.0);
InBlock.gif      glVertex3f (
0.750.250.0);
InBlock.gif      glVertex3f (
0.750.750.0);
InBlock.gif      glVertex3f (
0.250.750.0);
InBlock.gif   glEnd();
ExpandedSubBlockStart.gifContractedSubBlock.gif   glFlush ();
/**//* start processing buffered OpenGL routines  */
ExpandedBlockEnd.gif}

None.gif
None.gif
void  init ( void
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif   glClearColor (
0.00.00.00.0);/**//* select clearing color  */
InBlock.gif   glMatrixMode(GL_PROJECTION);
InBlock.gif   glLoadIdentity();
ExpandedSubBlockStart.gifContractedSubBlock.gif   glOrtho(
0.01.00.01.0-1.01.0);/**//* initialize viewing values  */
ExpandedBlockEnd.gif}

None.gif
None.gif
int  main( int  argc,  char **  argv)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif   glutInit(
&argc, argv);
ExpandedSubBlockStart.gifContractedSubBlock.gif   glutInitDisplayMode (GLUT_SINGLE 
| GLUT_RGB);/**//*Declare initial display mode(single buffer and RGBA).*/
ExpandedSubBlockStart.gifContractedSubBlock.gif   glutInitWindowSize (
250250); /**//*Declare initial window size.*/
ExpandedSubBlockStart.gifContractedSubBlock.gif   glutInitWindowPosition (
100100);/**//*Declare initial window position.*/
ExpandedSubBlockStart.gifContractedSubBlock.gif   glutCreateWindow (
"hello");/**//*Open window with "hello"in its title bar.*/  
ExpandedSubBlockStart.gifContractedSubBlock.gif   init ();
/**//*Call initialization routines.*/
ExpandedSubBlockStart.gifContractedSubBlock.gif   glutDisplayFunc(display); 
/**//*Register callback function to display graphics.*/
ExpandedSubBlockStart.gifContractedSubBlock.gif   glutMainLoop();
/**//*Enter main loop and process events.*/
ExpandedSubBlockStart.gifContractedSubBlock.gif   
return 0;   /**//* ANSI C requires main to return int. */
ExpandedBlockEnd.gif}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值