Learning OpenGL : (5) Using OpenGL

來源:互聯網
上載者:User

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);

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.