openGL的命令和语法:
openGL所有的命令都是以gl为前缀,然后是大写开始的单词构成,比如: glColor3f(),glVertex3f().后面的3f表示这个命令需要3个float-point(浮点数)作为参数。
openGL的常数都是以GL_为前缀,然后是下划线为分割符的大写字母,比如: GL_COLOR_BUFFER_BIT.
下面是openGL所用的前缀和相应的数据类型:
b 8-bit integer signed char GLbyte s 16-bit integer short GLshort i 32-bit integer long GLint, GLsizei f 32-bit floating-point float GLfloat, GLclampf d 64-bit floating-point double GLdouble, GLclampd ub 8-bit unsigned integer unsigned char GLubyte, GLboolean us 16-bit unsigned integer unsigned short GLushort ui 32-bit unsigned integer unsigned long GLuint, GLenum, GLbitfield
一些例子:
glVertex2i(1, 3);
glVertex2f(1.0, 3.0);
glColor3f(1.0, 0.0, 0.0);
float color_array[] = {1.0, 0.0, 0.0};
glColor3fv(color_array);
上面最后一个命令有个“v“,表示这个命令需要一个向量作为参数。
除了以上提到的数据类型,还有一个GLvoid,用来代替c中的void.