MCPcopy Create free account
hub / github.com/InkboxSoftware/all-screen-keyboard / vaoTextCreate

Function vaoTextCreate

keyboard/src/graphics.cpp:88–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88GLuint vaoTextCreate(const VertexBasic* verticies, int size){
89 //create vertex buffer object
90 GLuint vao;
91 glGenVertexArrays(1, &vao);
92 glBindVertexArray(vao);
93
94 GLuint vbo;
95 glGenBuffers(1, &vbo);
96 glBindBuffer(GL_ARRAY_BUFFER, vbo);
97 //copy the vertex data to VRAM
98 glBufferData(GL_ARRAY_BUFFER, size, verticies, GL_STATIC_DRAW); //store in VRAM
99
100 //define position attribute location
101 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(VertexBasic), (void*)offsetof(VertexBasic, position));
102 glEnableVertexAttribArray(0);
103 //define texCoord attribute location
104 glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(VertexBasic), (void*)offsetof(VertexBasic, texCoord));
105 glEnableVertexAttribArray(1);
106
107 //unbind
108 glBindVertexArray(0); //unbind VAO
109
110 //check for problems:
111 GLenum err = glGetError();
112 if (err != GL_NO_ERROR){
113 glDeleteBuffers(1, &vbo);
114 SDL_Log("Creating VBO failed: %u\n", err);
115 vbo = 0;
116 }
117 return vao;
118}
119
120void vboFree(GLuint vbo){
121 glDeleteBuffers(1, &vbo);

Callers 1

initializeMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected