OpenGL函数理解
函数解析
Texture procedures
- glGenTexture
glGenTextures: generate texture names and returns n texture names in textures.
void glGenTextures(GLsizei n, GLuint * textures);
Parameters:
n: Specifies the number of texture names to be generated.
textures: Specifies an array in which the generated texture names are stored.
- glBindTexture
glBindTexture: bind a named texture to a texturing target, lets you create or use a named texture. When a texture is bound to a target, the previous binding for that target is automatically broken.
void glBindTexture(GLenum target, GLuint texture);
Parameters:
target: Specifies the target to which the texture is bound.
texture: Specifies the name of a texture.
- glTexParameteri
glTexParameteri sets texture parameters
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexImage2D
glTexImage2D: specify a two-dimensional texture image, to define texture images.
void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * data);
Parameters:
// too much parameters.
For more details please refer to GLAPI.
- glGenerateMipmap
glGenerateMipmap: generate mipmaps for a specified texture target.
void glGenerateMipmap(GLenum target);
- glUniform
Specify the value of a uniform variable for the current program object. Give some examples:
void glUniform1f( GLint location, GLfloat v0);
void glUniform2f( GLint location, GLfloat v0, GLfloat v1);
void glUniform4fv( GLint location, GLsizei count, const GLfloat *value);
void glUniform4iv( GLint location, GLsizei count, const GLint *value);
void glUniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
void glUniformMatrix2x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
Parameters:
location: Specifies the location of the uniform variable to be modified.
count:
- For the vector (glUniform*v) commands, specifies the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array.
- For the matrix (glUniformMatrix*) commands, specifies the number of matrices that are to be modified. This should be 1 if the targeted uniform variable is not an array of matrices, and 1 or more if it is an array of matrices.
transpose: For the matrix commands, specifies whether to transpose the matrix as the values are loaded into the uniform variable.
v0, v1, v2, v3: For the scalar commands, specifies the new values to be used for the specified uniform variable.
value: For the vector and matrix commands, specifies a pointer to an array of count values that will be used to update the specified uniform variable.
Understanding
glUniform1i(unf_texture, 0);
// Why do we pass a Zero value to unf_texture in glUniform1i?
The sampler2D is bound to a texture unit. The glUniform call binds it to texture unit zero.
- glActiveTexture
glActiveTexture: select active texture unit.
glActiveTexture(GL_TEXTURE0);
// Is glActiveTexture call really need?
The glActiveTexture call is only needed if you are going to use multiple texture units (because GL_TEXTURE0 is the default anyway).
VBO procedures
- glGenBuffers
glGenBuffers: generate buffer object names.
void glGenBuffers(GLsizei n, GLuint * buffers);
Parameters:
n: Specifies the number of buffer object names to be generated.
buffers: Specifies an array in which the generated buffer object names are stored.
- glBindBuffer
glBindBuffer binds a buffer object to the specified buffer binding point.
void glBindBuffer(GLenum target, GLuint buffer);
Parameters:
target: Specifies the target buffer object.
buffer: Specifies the name of a buffer object.
- glBufferData
glBufferData: creates and initializes a buffer object’s data store.
void glBufferData(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
Parameters:
target: Specifies the target buffer object.
size: Specifies the size in bytes of the buffer object's new data store.
data: Specifies a pointer to data that will be copied into the data store for initialization, or NULL if no data is to be copied.
usage: Specifies the expected usage pattern of the data store.
上一篇: Vue 页面传参以及 父子组件之间的传参
下一篇: java多线程之间通讯
推荐阅读
-
OpenGL函数理解
-
【OpenGL】OpenGL的窗口管理库
-
Kotlin中let的安全调用,非空断言,空合并操作符 ?:以及let函数与空合并操作符使用
-
《Linux命令行与shell脚本编程大全》 第二十一章 学习笔记 博客分类: Linux命令行与shell脚本编程大全 gawk变量数组内建函数自定义函数
-
对比mysql学习oracle函数(一):oracle单行函数—字符函数
-
Java系列笔记第八章:函数式编程
-
【读书笔记】细读《JavaScript权威指南》(第八章: 函数)
-
Python第八章函数笔记
-
JS权威指南(动物系列犀牛书)读书笔记——第八章 函数
-
自学Python笔记-第八章函数以及课后代码(上)