执行渲染

执行渲染所需

C
glUseProgram(ShaderProgramID); // 使用着色器
glBindVertexArray(VAO); // 绑定VAO

/* --- 绘制函数 --- */
// 法一:基于顶点绘制
glDrawArrays(GL_TRIANGLES, 0, sizeof(vertex_array));
// 法二:使用EBO绘制
glDrawElements(GL_TRIANGLES, sizeof(indices_array), GL_UNSIGNED_INT, 0);
/* -------------- */

glBindVertexArray(0); //解绑VAO
点击展开查看更多

绘制函数

glDrawArrays

根据顶点数组绘制图元

C
void glDrawArrays(
	GLenum mode,
	GLint first,
	GLsizei count
)
点击展开查看更多

glDrawElements

根据索引数组来绘制图元

C
void glDrawElements(
    GLenum mode,
    GLsizei count,
    GLenum type,
    const void *indices
)
点击展开查看更多

版权声明

作者: Chaim

链接: https://chaim.eu.org/posts/%E6%89%A7%E8%A1%8C%E6%B8%B2%E6%9F%93/

许可证: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.

开始搜索

输入关键词搜索文章内容

↑↓
ESC
⌘K 快捷键