Windows 8.1 Visual Studio 2013配置OpenGL开发环境

一,下载OpenGL代码——glut(The OpenGL Utility Toolkit)

glut下载地址: http://www.opengl.org/resources/libraries/glut/glut_downloads.php

for windows的code:

http://user.xmission.com/~nate/glut.html

其中:

Ø  glut-3.7.6-bin.zip : GLUT forWin32 dll, lib and header file (everything you need to get started programmingwith GLUT). 

Ø  glut-3.7.6-src.zip : GLUTsource code distribution (including a whole slew of great example programs +data).

现使用glut-3.7.6-bin.zip配置环境。

二,VS2013配置

1,Copy your glut.hto:<drive>:\<VC++ path>\include\GL\glut.h

*** put the drive where you installed VC++ instead of the<drive>

*** put the directory where you installed VC++ instead of the<VC++ path>

 

比如,glut.h---> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\GL\   (新建一个GL的文件夹)

 

2,Copy yourglut32.lib to:

<drive>:\<VC++path>\lib\glut32.lib

*** put the drive where youinstalled VC++ instead of the <drive> ***

*** put the directory whereyou installed VC++ instead of the <VC++ path>

比如,glut32.lib --->C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib

 

3,Copy glut32.dllinto your windows directory (windows or winnt, depends on if you are usingWindows95/98 or Windows NT)

注意:glut32.dll  ---> C:\Windows\SysWOW64 (windows8.1 64位操作系统)

                               ---> C:\Windows\System32 (windows8.1 32位操作系统)

比如,本人系统64位,因此glut32.dll ---> C:\Windows\SysWOW64

 

4,打开vs2013,随便打开或新建一个项目。选择 project->project property-> ConfigurationProperties->Linker->Input->Additional Dependencies 在其中添加opengl32.lib glu32.lib glut32.lib

注意:opengl32.lib glu32.lib glut32.lib之间不要用空格分隔,应该用换行键分隔!若用空格分隔会报错找不到.lib文件。

 

三,测试

 

在工程中添加如下代码编译(32位)即可。

注意:用x64编译不行,因为glut32.lib是给32位编译用的。

 

//glExampl01.cpp : Defines the entry point for the console application.

//

 

#include <Gl\glut.h>

void myDisplay(void)

 

{

 

    glClear(GL_COLOR_BUFFER_BIT);

 

    glColor3f(1.0, 0.0, 0.0);

    glBegin(GL_LINES);

    glVertex2i(180, 15);

    glVertex2i(10, 145);

    glEnd();

 

    glRectf(-0.5f, -0.5f, 0.5f, 0.5f);

 

    glFlush();

 

}

void init(void)

{

    glClearColor(1.0, 1.0, 1.0, 0.0);

 

    glMatrixMode(GL_PROJECTION);

    gluOrtho2D(0.0, 200.0, 0.0, 150.0);

 

}

 

int main(int argc, char * argv[])

{

 

    glutInit(&argc, argv);

 

    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);

 

    glutInitWindowPosition(50, 100);

 

    glutInitWindowSize(400, 300);

 

    glutCreateWindow("OpenGL");

 

    init();

 

    glutDisplayFunc(&myDisplay);

 

    glutMainLoop();

 

    return 0;

 

}

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值