Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2594360
  • 博文数量: 333
  • 博客积分: 4817
  • 博客等级: 上校
  • 技术积分: 4413
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-28 10:51
文章分类

全部博文(333)

文章存档

2017年(20)

2016年(57)

2015年(27)

2014年(20)

2013年(21)

2012年(164)

2011年(24)

分类: LINUX

2016-07-08 10:33:15

一、安装

 # yum list mesa*

 # yum install -y mesa*

 # yum install -y freeglut*
# yum install -y *glew*

二、验证

一个茶壶的例子:

#include 
#include 
void init();
void display();

int main(int argc, char* argv[])
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
	glutInitWindowPosition(0, 0);
	glutInitWindowSize(300, 300);
	
	glutCreateWindow("OpenGL 3D View");
	
	init();
	glutDisplayFunc(display);
	
	glutMainLoop();
	return 0;
}

void init()
{
	glClearColor(0.0, 0.0, 0.0, 0.0);
	glMatrixMode(GL_PROJECTION);
	glOrtho(-5, 5, -5, 5, 5, 15);
	glMatrixMode(GL_MODELVIEW);
	gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);
}

void display()
{
	glClear(GL_COLOR_BUFFER_BIT);
		
	glColor3f(1.0, 0, 0);
	glutWireTeapot(3);
	
	glFlush();
}

 $ gcc
-lglut -lGLU -lGL -o main.cpp main

 $ ./main

 

茶壶:

阅读(4637) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~