Windows XP虚拟机绿色VC配置OpenGL开发环境

326 篇文章 2 订阅
20 篇文章 0 订阅

针对Oracle virtual box中windows XP(32位)虚拟机中,采用VC6绿色开发ide,配置OpenGL的步骤。


1 下载GLUT编译版

http://user.xmission.com/~nate/glut/glut-3.7.6-bin.zip

2 解压缩后的头文件、库文件设置

解压缩该文件,

把glut.h文件复制到绿色VC的include\GL下,例如:C:\VC6\VC98\Include\GL

把glut32.lib文件复制到绿色VC的lib下,例如:C:\VC6\VC98\Lib

把glut32.dll复制到c:\windows\system32下。

3 Demo项目

打开VC6 ide,新建Console工程,一路Next。

设置工程属性(Alt+F7),

在“设置(S)”下拉列表框中选择“所有配置”,

在对话框的“连接”页中的“对象/库模块”中添加以下连接库名

opengl32.lib Glut32.lib Glaux.lib glu32.lib

4 工程代码修改

打开工程的StdAfx.h文件

在#endif前添加头文件包含

#include <windows.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glaux.h>  

5 修改工程主程序,内容如下:

//opengl1.cpp

#include "stdafx.h"

#include <windows.h>
#include <gl\glut.h>

float points[] = {0.8, 0.8, 0.8, 0, 0.8, -0.8, -0.8, 0};

//Called to draw scene
void RenderSence(void)
{
	//Clear the window with current clearing color
	glClear(GL_COLOR_BUFFER_BIT);

	//绘制Demo点
	//设置点的颜色
    glColor3f(1.0, 0.0, 0);  
    glPointSize(15.0);  
    glBegin(GL_POINTS);  
	int i, j, cnt = sizeof(points)/sizeof(float)/ 2;
    for(i = 0; i < cnt; i++)    
        glVertex3f(points[i * 2], points[i * 2 + 1], 0);  
    glEnd();  

	//绘制Demo线
	glColor3f(0.0, 0.0, 1.0);  
    glBegin(GL_LINES);   
    for(i = 0; i < cnt; i++)    
    {    
		j = i + 1;
		if (j == cnt) j = 0;
        glVertex3f(points[2 * i], points[2 * i + 1], 0);  
        glVertex3f(points[2 * j], points[2 * j + 1], 0);  
    }  
    glEnd();  

	//Flush drawing commands
	glFlush();
}

//Set up the rendering state
void SetupRC(void)
{
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);      //此时背景色为蓝色
}

int main(int argc, char* argv[])
{
	//printf("Hello World!\n");
	glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
	glutInitWindowSize(600, 600);
	glutCreateWindow("Demo OpenGL应用");        //窗口名为“Simple”
	glutDisplayFunc(RenderSence);
	SetupRC();
	glutMainLoop();
	return 0;
}
6 按Ctrl+F5编译运行该项目



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值