OpenGL學習筆記一——環境搭建

OpenGL的環境搭建還是蠻簡單的,自己的搭建環境是xp+vs2008,廢話不多了,直接看步驟吧:

一、搭建環境
1.下載glut,glut是OpenGL的一組擴展工具包,使用起來更方便http://www.opengl.org/resources/libraries/
2.下載glew,glew是什麼呢?http://glew.sourceforge.net/

關於glut和glew的安裝:
bin/glew32.dll        to     %SystemRoot%/system32
lib/glew32.lib        to     {VC Root}/Lib
include/GL/glew.h     to     {VC Root}/Include/GL
include/GL/wglew.h    to     {VC Root}/Include/GL

glut32.dll       to     %SystemRoot%/system32
glut.dll  to     %SystemRoot%/system32
glut32.lib       to     {VC Root}/Lib
glut.lib  to     {VC Root}/Lib

 

這樣拷貝文件之後,就省去了一系列不必要設置環境的麻煩。在代碼中如下使用:
#include <windows.h>  // Windows的頭文件
#include <GL/glew.h>  // 不需要包含gl.h,glu.h
#include <GL/wglew.h>
#include <GL/glut.h>  // 包含OpenGL實用庫, glut

#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib") 
#pragma comment(lib, "glew32.lib") 
#pragma comment(lib, "glew32s.lib") 
#pragma comment(lib, "glut32.lib")


二、簡單示例
注意順時針、逆時針畫法

先看看截圖

 


畫個三角形

 

畫個旋轉的正方形
  

 

畫個3D的三角形

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章