OpenGL study

来源:互联网 发布:农村信用社软件下载 编辑:程序博客网 时间:2024/05/25 01:35
你可以在OpenGL的官方网站http://www.OpenGL.org的Documentation中下载到官方教程和例子程序:
The OpenGL Programming Guide,这就是著名的red book(“红皮书”)

如果你英语不好,那么推荐你阅读:
《OpenGL超级宝典》是一本相当不错的中文教程。可以在
http://www.vrforum.cn/forumdisplay.php?fid=29找到它的例子代码
《OpenGL编程权威指南》他是red book的中文译本,它的例子也就是red book的例子。

*Nate Robin的例子对你理解OpenGL很有帮助。http://www.gamedev.net/reference/articles/article839.asp

*The OpenGL Reference Manual(blue book)并不是一本入门教材,而是一本函数参考手册,可以从http://www.OpenGL.org的Documentation中下载下来,在实际学习中查询用

*NeHe的例子也是大家所喜爱的初学者例子。http://nehe.gamedev.net,在http://www.chinagamedev.net还有一部分的中文译文

***nehe的简单窗口例子(第二课)几乎含盖世界上的所有语言,如果想用自己喜欢的独特语言,可以参考http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=02最下方的联接,并结合C++的例子学习(大多数教材都是基于C++的,不过幸好我们真正关注的是OpenGL本身)

OpenGL的例子大都需要用到OpenGL应用工具包:GLUT库,下面讲讲怎样安装它

Visual C++ 6.0 HOWTO:
1。下载GLUT库:
http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
2。将压缩包内的glut.h放到.../Microsoft Visual Studio/VC98/Include/GL目录下
   将glut32.lib放到.../Microsoft Visual Studio/VC98/Lib目录下
   将glut32.dll放到X:/windows/systom32目录下(win98用户放到X:/windows/systom目录下)
3。建立一个控制台工程Win32 Console Application,加入hello.c并运行:
#include <GL/glut.h>

void display(void)
{
   glClear (GL_COLOR_BUFFER_BIT);/* clear all pixels  */
   glColor3f (1.0, 1.0, 1.0);
   glBegin(GL_POLYGON);/* draw white polygon with corners at(0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)*/
      glVertex3f (0.25, 0.25, 0.0);
      glVertex3f (0.75, 0.25, 0.0);
      glVertex3f (0.75, 0.75, 0.0);
      glVertex3f (0.25, 0.75, 0.0);
   glEnd();
   glFlush ();/* start processing buffered OpenGL routines  */
}

void init (void) 
{
   glClearColor (0.0, 0.0, 0.0, 0.0);/* select clearing color  */
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);/* initialize viewing values  */
}

int main(int argc, char** argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);/*Declare initial display mode(single buffer and RGBA).*/
   glutInitWindowSize (250, 250); /*Declare initial window size.*/
   glutInitWindowPosition (100, 100);/*Declare initial window position.*/
   glutCreateWindow ("hello");/*Open window with "hello"in its title bar.*/  
   init ();/*Call initialization routines.*/
   glutDisplayFunc(display); /*Register callback function to display graphics.*/
   glutMainLoop();/*Enter main loop and process events.*/
   return 0;   /* ANSI C requires main to return int. */
}

原创粉丝点击