VC++2010是一个成熟稳定的版本,微软的编译工具Visual Studio系列从VC6到如今的VC2019,功能非常强大,我们在开始学习C++和计算机图形学的时候,一般入手<<C++Primer>><<OpenGL编程指南>>一般例子并不会详细讲解开发环境,这是因为C++和C语言还有OpenGL不是某一家公司的产物,而是开放标准,即成立标准委员会由多方协商参与制定,这样才有开源的实现,而在windows上研究相关技术开发商业产品,久而久之形成了惯例即采用微软出品的IDE,也的确很优秀,曾经宝兰也败下阵来,原因很多,但是我们觉得操作系统类似商城租房给商家销售差不多。当然在Linux环境下有它自身的一套C/C++编译器GCC/G++,相应的采用code::blocks或者Qt Creator或者KDeveloper等IDE。所以我们很多例子,笔记等不做特别说明都是在VC++2010或者其他版本上编译通过的。下面就是配置glut的步骤:

1.安装VS2010旗舰版,这个在百度下搜索VS2010旗舰版可以找到很多,还有安装步骤,安装完后记得填写KEY

2.glut还是<<配置code::blocks下glut>中下载的glut库,下面打开VC2010

粘屏幕其实不太必要,特别是多试几次后,步骤就几步,下面就文字罗列步骤

在菜单 文件->新建->项目

弹出的新建项目对话框中,模版选择Win32控制台应用程序

名称填 gluttest0

位置这里我填的是D:\codes\

按确定后,next,到 应用程序设置

附加选项 选 空项目,完成

这个时候创建了项目树,但是没有创建任何代码文件,包括头文件和CPP文件

来添加一个main.cpp文件

在源文件 右键菜单->添加->新建项

选中C++文件,名字填main

则在项目中添加了一个空的cpp文件main.cpp,下面的代码来自OpenGL红宝书(OpenGL编程指南)

#include <GL/glut.h>

/*
* Initialize depth buffer, projection matrix, light source, and lighting
* model. Do not specify a material property here.
*/
void myinit(void)
{
GLfloat ambient[] =
{0.0, 0.0, 0.0, 1.0};
GLfloat diffuse[] =
{1.0, 1.0, 1.0, 1.0};
GLfloat position[] =
{0.0, 3.0, 3.0, 0.0}; GLfloat lmodel_ambient[] =
{0.2, 0.2, 0.2, 1.0};
GLfloat local_view[] =
{0.0}; glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, position);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); glFrontFace(GL_CW);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
} /*
* Move object into position. Use 3rd through 12th parameters to specify the
* material property. Draw a teapot.
*/
void renderTeapot(GLfloat x, GLfloat y,
GLfloat ambr, GLfloat ambg, GLfloat ambb,
GLfloat difr, GLfloat difg, GLfloat difb,
GLfloat specr, GLfloat specg, GLfloat specb, GLfloat shine)
{
float mat[]; glPushMatrix();
glTranslatef(x, y, 0.0);
mat[] = ambr;
mat[] = ambg;
mat[] = ambb;
mat[] = 1.0;
glMaterialfv(GL_FRONT, GL_AMBIENT, mat);
mat[] = difr;
mat[] = difg;
mat[] = difb;
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat);
mat[] = specr;
mat[] = specg;
mat[] = specb;
glMaterialfv(GL_FRONT, GL_SPECULAR, mat);
glMaterialf(GL_FRONT, GL_SHININESS, shine * 128.0);
glutSolidTeapot(1.0);
glPopMatrix();
} /**
* First column: emerald, jade, obsidian, pearl, ruby, turquoise
* 2nd column: brass, bronze, chrome, copper, gold, silver
* 3rd column: black, cyan, green, red, white, yellow plastic
* 4th column: black, cyan, green, red, white, yellow rubber
*/
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderTeapot(2.0, 17.0, 0.0215, 0.1745, 0.0215,
0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6);
renderTeapot(2.0, 14.0, 0.135, 0.2225, 0.1575,
0.54, 0.89, 0.63, 0.316228, 0.316228, 0.316228, 0.1);
renderTeapot(2.0, 11.0, 0.05375, 0.05, 0.06625,
0.18275, 0.17, 0.22525, 0.332741, 0.328634, 0.346435, 0.3);
renderTeapot(2.0, 8.0, 0.25, 0.20725, 0.20725,
, 0.829, 0.829, 0.296648, 0.296648, 0.296648, 0.088);
renderTeapot(2.0, 5.0, 0.1745, 0.01175, 0.01175,
0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6);
renderTeapot(2.0, 2.0, 0.1, 0.18725, 0.1745,
0.396, 0.74151, 0.69102, 0.297254, 0.30829, 0.306678, 0.1);
renderTeapot(6.0, 17.0, 0.329412, 0.223529, 0.027451,
0.780392, 0.568627, 0.113725, 0.992157, 0.941176, 0.807843,
0.21794872);
renderTeapot(6.0, 14.0, 0.2125, 0.1275, 0.054,
0.714, 0.4284, 0.18144, 0.393548, 0.271906, 0.166721, 0.2);
renderTeapot(6.0, 11.0, 0.25, 0.25, 0.25,
0.4, 0.4, 0.4, 0.774597, 0.774597, 0.774597, 0.6);
renderTeapot(6.0, 8.0, 0.19125, 0.0735, 0.0225,
0.7038, 0.27048, 0.0828, 0.256777, 0.137622, 0.086014, 0.1);
renderTeapot(6.0, 5.0, 0.24725, 0.1995, 0.0745,
0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4);
renderTeapot(6.0, 2.0, 0.19225, 0.19225, 0.19225,
0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4);
renderTeapot(10.0, 17.0, 0.0, 0.0, 0.0, 0.01, 0.01, 0.01,
0.50, 0.50, 0.50, .);
renderTeapot(10.0, 14.0, 0.0, 0.1, 0.06, 0.0, 0.50980392, 0.50980392,
0.50196078, 0.50196078, 0.50196078, .);
renderTeapot(10.0, 11.0, 0.0, 0.0, 0.0,
0.1, 0.35, 0.1, 0.45, 0.55, 0.45, .);
renderTeapot(10.0, 8.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0,
0.7, 0.6, 0.6, .);
renderTeapot(10.0, 5.0, 0.0, 0.0, 0.0, 0.55, 0.55, 0.55,
0.70, 0.70, 0.70, .);
renderTeapot(10.0, 2.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0,
0.60, 0.60, 0.50, .);
renderTeapot(14.0, 17.0, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01,
0.4, 0.4, 0.4, .);
renderTeapot(14.0, 14.0, 0.0, 0.05, 0.05, 0.4, 0.5, 0.5,
0.04, 0.7, 0.7, .);
renderTeapot(14.0, 11.0, 0.0, 0.05, 0.0, 0.4, 0.5, 0.4,
0.04, 0.7, 0.04, .);
renderTeapot(14.0, 8.0, 0.05, 0.0, 0.0, 0.5, 0.4, 0.4,
0.7, 0.04, 0.04, .);
renderTeapot(14.0, 5.0, 0.05, 0.05, 0.05, 0.5, 0.5, 0.5,
0.7, 0.7, 0.7, .);
renderTeapot(14.0, 2.0, 0.05, 0.05, 0.0, 0.5, 0.5, 0.4,
0.7, 0.7, 0.04, .);
glFlush();
} void myReshape(int w, int h)
{
glViewport(, , w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
glOrtho(0.0, 16.0, 0.0, 16.0 * (GLfloat) h / (GLfloat) w,
-10.0, 10.0);
else
glOrtho(0.0, 16.0 * (GLfloat) w / (GLfloat) h, 0.0, 16.0,
-10.0, 10.0);
glMatrixMode(GL_MODELVIEW);
} /*
* Main Loop Open window with initial window size, title bar, RGBA display
* mode, and handle input events.
*/
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (, );
glutInitWindowPosition (, );
glutCreateWindow(argv[]);
myinit();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
glutMainLoop();
return ;
}

项目树在gluttest0上右键,弹出菜单找到属性,我们来设置依赖的glut库

首先是本地环境路径中加入glut32.dll

PATH=D:\mclib\glut376\lib;$(PATH)

然后设置include, C++->常规->附加包含目录,填D:\mclib\glut376\include

和其他include路径通过;号分割,指定glut.h在哪

最后设置lib,链接->常规->附加库目录设置d:\mclib\glut376\lib

链接->输入->附加依赖项 glut32.lib

然后主菜单下,生成(Build)->生成gluttest0,生成成功后,按绿色箭头,启动,则看到了熟悉的犹他茶壶

配置VC++2010的glut库的更多相关文章

  1. VS2010下配置使用OpenGL的glut库

    我已在我机上测试成功,机装VS2010! 在win7(windows7 ultimate SP1)下成功安装VS2010(Visual Studio 2010 ultimate x86). 下载glu ...

  2. VC++2010配置使用MySQL5.6

    0.前提 安装后的文件概览 编译器:  VC++2010 MySQL版本:MySQL5.6.19 for win64 Connector版本:connector  c++  1.1.3 在VS2010 ...

  3. 【转】Qt下使用glut库

    ps:这个说的很明白,尤其是win10环境下用mingw环境时编程时碰到的问题, 1.加 windows.h 2.在.pro 添加libs     博文地址:Qt下使用glut库   本人使用的环境 ...

  4. Editplus配置VC++(1) 及相关注意事项

    下篇文章:Editplus配置VC++(2) 与/d1reportSingleClassLayout 原本用的是VC++2010 现在换成了Visual Studio 2013,editplus相关配 ...

  5. Qt工程使用第三方库——Qt下使用glut库

    本人使用的环境 操作系统:windows10 Qt构建套件:qt-mingw4.8.5 + mingw4.4.0 Qt Creator版本:3.6.1   本教程配置针对工程而言,每个工程需要单独配置 ...

  6. VC++2010下编译STLport,Boost

    VC++2010下编译STLport,Boost 最近在想向Boost转移,努力掌握Boost代码的过程中, STLport版本:5.2.1 Boost版本:1.4.6.1 (1.4.7.0也OK) ...

  7. Editplus配置VC++(2) 与/d1reportSingleClassLayout

    前篇文章:Editplus配置VC++(1) 及相关注意事项 VC++有两个隐含编译选项/d1reportSingleClassLayout和/d1reportAllClassLayout   /d1 ...

  8. OpenGL学习之windows下安装opengl的glut库

    OpenGL学习之windows下安装opengl的glut库 GLUT不是OpenGL所必须的,但它会给我们的学习带来一定的方便,推荐安装.  Windows环境下的GLUT下载地址:(大小约为15 ...

  9. 配置code::blocks的glut环境

    code::blocks很小,特别适合小型项目及家用旧电脑上MingW下编程,当然windows还是安装的Visual Studio办公用的,现把配置过程记录一遍. 1.在百度搜code::block ...

随机推荐

  1. Java EE—最轻量级的企业框架?

    确保高效发展进程的建议 很久以前,J2EE,特别是应用程序服务器被认为过于臃肿和"重量级".对于开发人员来说,使用此技术开发应用程序会非常繁琐且令人沮丧.但是,由于 J2EE 框架 ...

  2. Apache JMeter (一)环境的配置和操作

    JMeter是Apache组织的开放源代码项目,是一款优秀的开源测试工具,可以做功能测试和性能测试.是每个资深的测试工程师必须掌握的测试工具,熟悉JMeter可以大大提高工作效率. 1.下载Jmete ...

  3. mysql之explain详解

    mysql之explain详解 mysql之explain各个字段的详细意思: 字段 含义 select_type 分为简单(simple)和复杂 type all : 即全表扫描 index : 按 ...

  4. SSM框架学习笔记(一)

    Spring框架 Spring :是一个开源框架,起初是为解决企业应用开发的复杂性而创建的,但是现在已经不止 企业级应用开发,Spring的核心就是提供了一个轻量级的控制反转和面向切面编程. SPri ...

  5. Hive中的数据库(Database)和表(Table)

    在前面的文章中,介绍了可以把Hive当成一个"数据库",它也具备传统数据库的数据单元,数据库(Database/Schema)和表(Table). 本文介绍一下Hive中的数据库( ...

  6. selenium-05-问题2

    现在的项目组用开源的Selenium做测试,但不得不说,这个东东bug奇多,下面是我遇到的一些问题,有些提供了解决方法,有些则需要继续研究,希望对各位看官有所帮助. 一.不能从命令行运行Seleniu ...

  7. Scala Data Structure

    Arrays Array 固定长度:ArrayBuffer 可变长度 arr.toBuffer, buf.toArray 初始化是不要使用 new 使用 () 访问元素 使用 for (elem &l ...

  8. 对Servlet执行流程的初步认识

    这里我们以Post方式请求Serclet为例 1.找到 中的URL地址 Form表单的Post请求HelloServlet(Action="HelloServlet")发起时, A ...

  9. js禁止刷新的简单方法

    //禁止用F5键  这个是键盘按下时触发document.onkeydown = function() { if ( event.keyCode==116) {event.keyCode = 0; e ...

  10. vue中关于滚动条的那点事

    vue中关于滚动条的那点事 不知道你有没有遇到过这种情况,有时当页面切换时,滚动条不在页面的顶端.最近半路加入一个项目,就遇到这种情况.(若只是为了解决此问题,可直接翻到最下方)下面谈谈解决此问题的过 ...