opengl 渲染四边形的方式
GL_TRIANGLE_STRIP绘制三角形方式很多时候令人疑惑,在这里对其运作机理进行解释。
一般情况下有三种绘制一系列三角形的方式,分别是GL_TRIANGLES、GL_TRIANGLE_STRIP和GL_TRIANGLE_FAN。
如下图所示:
它的渲染根据顶点数据组成方式不同分为两种方式:
一、它的渲染可以通过glGenBuffers,glBindBuffer,glBufferData个来完成。当需要动态修改顶点数据时,通过调用glBufferSubData来完成。
#include "glew.h"
#include <glfw3.h>
#include "common/loadShader.h"
#include "glm.hpp"
#include "ext.hpp"
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(480, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}