Created
February 19, 2018 07:17
-
-
Save chokomancarr/d0c9e25adefccc2a50d54ebfabf42dae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Start() { | |
Vec3 vertices[3] = { | |
Vec3(), | |
Vec3(1, 1, 0), | |
Vec3(1, -1, 0) }; | |
glGenVertexArrays(1, &_vao); | |
glGenBuffers(1, &_vboV); | |
glBindBuffer(GL_ARRAY_BUFFER, _vboV); | |
glBufferStorage(GL_ARRAY_BUFFER, _vboSz * sizeof(Vec3), vertices, GL_DYNAMIC_STORAGE_BIT); | |
glBindBuffer(GL_ARRAY_BUFFER, 0); | |
glBindVertexArray(_vao); | |
glEnableVertexAttribArray(0); | |
glBindBuffer(GL_ARRAY_BUFFER, _vboV); | |
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL); | |
glBindBuffer(GL_ARRAY_BUFFER, 0); | |
glBindVertexArray(0); | |
} | |
void Draw() { | |
glBindBuffer(GL_ARRAY_BUFFER, _vbo); | |
auto d = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); | |
*(Vec3*)d = Vec3(0, sinf(Time::time), 0); | |
glUnmapBuffer(GL_ARRAY_BUFFER); | |
glBindBuffer(GL_ARRAY_BUFFER, 0); | |
glUseProgram(defProgram); | |
glUniform4f(defColLoc, 1.0f, 0.0f, 0.0f, 1.0f); | |
glBindVertexArray(_vao); | |
glDrawArrays(GL_TRIANGLES, 0, 3); | |
glBindVertexArray(0); | |
glUseProgram(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment