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. Python作业本——前言

    大四毕业了,9月才开始研究生生涯,导师也没有严格要求我暑假留校做项目,也没提具体的学习要求.这两三个月比较闲,所以就打算学学Python.学习过程中肯定会有些心得体会,以及一些小练习.学习编程不同于传 ...

  2. IDEA中创建maven web项目

    本文将带你一路从IDEA中maven的配置到创建maven web项目,掌握IDEA中maven的使用. 一.IDEA中配置maven 开发中一般我们使用自己下载的maven,不使用IDEA工具自带的 ...

  3. 【原创】(四)Linux内存模型之Sparse Memory Model

    背景 Read the fucking source code! --By 鲁迅 A picture is worth a thousand words. --By 高尔基 说明: Kernel版本: ...

  4. 明明有class为什么还是报ClassNotFoundException?

    描述 我们修改接口时,习惯发布一个快照版本用于测试.我们的一个服务也是发布了快照版本,然后一个jar程序要依赖这个服务,修改pom文件打包部署后,通过 java -jar 命令执行这个jar程序,然后 ...

  5. .Net基础篇_学习笔记_第四天_if结构

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  6. Winform中跨窗体设置Zedgraph的属性并刷新曲线图

    场景 在使用ZedGraph时,经常有图形选项功能,设置曲线图相关属性后, 点击保存会设置另一个窗体的属性并刷新图. 效果 实现 在设置图形的选项的类中,声明委托和事件 //委托的定义 public ...

  7. C#基础知识总结(一)

    1.什么是匿名函数?匿名函数,就是没有名字的函数,或者说就是一组代码块,他的参数只有在方法块内有效,可以有效的减小创建方法事所需要的系统开销 2.lambda表达式是什么?lambda表达式 就是一个 ...

  8. Postman工具使用-接口测试(实战一)

    写在前面,本文首发[简书]https://www.jianshu.com/p/c188624c3580 作为一名测试人员,要去思考一下,如何能按需完成任务,又能轻松解决问题,这就很重要了!!! 凡事皆 ...

  9. JSR303 后端校验包的使用

    1.首先通过Maven导入JSR303架包. <!-- https://mvnrepository.com/artifact/org.hibernate.validator/hibernate- ...

  10. Github 入门1 (下载git , 连接本地库与github仓库)

    /* 本篇建立在以注册GitHub账号的前提下*/ (1)  下载 git  https://www.git-scm.com // win10 可以直接红色箭头标识的 Download 2.22.0 ...