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

Function vaoColorCreate

keyboard/src/graphics.cpp:56–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56GLuint vaoColorCreate(const VertexColorSolid* verticies, int size){
57 //create vertex buffer object
58 GLuint vao;
59 glGenVertexArrays(1, &vao);
60 glBindVertexArray(vao);
61
62 GLuint vbo;
63 glGenBuffers(1, &vbo);
64 glBindBuffer(GL_ARRAY_BUFFER, vbo);
65 //copy the vertex data to VRAM
66 glBufferData(GL_ARRAY_BUFFER, size, verticies, GL_STATIC_DRAW); //store in VRAM
67
68 //define position attribute location
69 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(VertexColorSolid), (void*)offsetof(VertexColorSolid, position));
70 glEnableVertexAttribArray(0);
71 //define texCoord attribute location
72 glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(VertexColorSolid), (void*)offsetof(VertexColorSolid, color));
73 glEnableVertexAttribArray(1);
74
75 //unbind
76 glBindVertexArray(0); //unbind VAO
77
78 //check for problems:
79 GLenum err = glGetError();
80 if (err != GL_NO_ERROR){
81 glDeleteBuffers(1, &vbo);
82 SDL_Log("Creating VBO failed: %u\n", err);
83 vbo = 0;
84 }
85 return vao;
86}
87
88GLuint vaoTextCreate(const VertexBasic* verticies, int size){
89 //create vertex buffer object

Callers 2

drawRectMethod · 0.70
drawCircleMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected