Learning OpenGL : (5) Using OpenGL

来源:互联网 发布:讲文明知礼仪主题文章 编辑:程序博客网 时间:2024/05/29 17:49

1. GLUT
OpenGL utility toolkit.
Because GLUT was originally not licensed as open source, a new GLUT implementation, freeglut, has sprung up to take its place.

 

 


2. GLEW
GLEW make an easy way to obtain full access to the OpenGl API.
GLEW library is prepackaged in the GLTools library.

 

 


3. GLTools
GLTools is a toolbox.

 

 


4. OpenGL DataType
1) Some DataType
OpenGL Data Type  Minimum Bit Width  Description
GLboolean    1
GLbyte     8
GLubyte     8
GLchar     8
GLshort     16
GLushort    16
GLhalf     16
...

 


2) These do not necessarily correspond directly to C data types.
Some descriptive name is given:
GLsizei is an OpenGL variable denoting a size parameter that si represented by an integer.
GLclampd is the value is expected to be clamped to the range 0.0 ~ 1.0.
...

 


3) Pointers and arrays are not given any special consideration.
Eg:
GLshort shorts[10];
GLdouble * doubles[10];

 

 


5. OpenGL Errors
1) OpenGL maintains a set of four error flags.
GL_INVALID_ENUM
GL_INVALID_VALUE
GL_INVALID_OPERATION
GL_OUT_OF_MEMORY
GL_NO_ERROR

 

 

2) To see whether any of these flag is set:
GLenum glGetError(void);

If more than one of these flag is set, glSetError stills returns only one value. Usually, you want to call glGetError in a loop until the return value is GL_NO_ERROR.

 

 


6. Identifying the Version
const GLubyte * glGetString(GLenum name);

 

 


7. glHint
1) The function glHint allows you to specify certain perferences of quality or speed for different types of operations.
void glHint(GLenum target, GLenum mode);

 

The target parameter allows you to specify types of behavior you want to modify.
The mode parameter tells OpenGL the mode.


however, implementations are not required to honor calls into glHint.

 

 

 


8. The OpenGL State Machine
1) To turn these type of state variable on and off:
void glEnable(GLenum capability);
void glDisable(Glenum capability);

 

 

Eg:
glEnable(GL_DEPTH_TEST);

 

 

2) Get whether it is enabled:
GLboolean glIsEnabled(GLenum capability);

 

 

3) Get other type of values:
void glGetBooleanv(GLenum pname, GLboolean * params);

 

 

原创粉丝点击