Last active
May 7, 2018 16:41
-
-
Save dresswithpockets/d55f14ec7a0474225d170af5b40b6d00 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#version 330 core | |
out vec4 FragColor; | |
void main() | |
{ | |
FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f); | |
} |
This file contains hidden or 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
typedef float vec3[3]; | |
void loop() { | |
vec3 triangle_primitive[] = { | |
{ -0.5f, -0.5f, 0.0f }, | |
{ 0.5f, -0.5f, 0.0f }, | |
{ 0.0f, 0.5f, 0.0f } | |
}; | |
GLuint VAO; | |
GLuint VBO; | |
glGenVertexArrays(1, &VAO); | |
glGenBuffers(1, &VBO); | |
glBindVertexArray(VAO); | |
glBindBuffer(GL_ARRAY_BUFFER, VBO); | |
glBufferData(GL_ARRAY_BUFFER, sizeof(triangle_primitive), triangle_primitive, GL_STATIC_DRAW); | |
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(vec3), (void*)0); | |
glEnableVertexAttribArray(0); | |
glBindBuffer(GL_ARRAY_BUFFER, 0); | |
glBindVertexArray(0); | |
while(!glfwWindowShouldClose(window)) | |
{ | |
glClearColor(0.2f, 0.3f, 0.3f, 1.0f); | |
glClear(GL_COLOR_BUFFER_BIT); | |
glUseProgram(CD_Program_Basic); | |
glBindVertexArray(VAO); | |
glDrawArrays(GL_TRIANGLES, 0, 3); | |
glfwSwapBuffers(window); | |
glfwPollEvents(); | |
} | |
} |
This file contains hidden or 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
#version 330 core | |
layout (location = 0) in vec3 aPos; | |
void main() | |
{ | |
gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment