Changeset 644a2e4 in opengl-game
- Timestamp:
- Jul 20, 2017, 2:36:56 AM (8 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 22b2c37
- Parents:
- 516668e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
new-game.cpp
r516668e r644a2e4 21 21 return 1; 22 22 } 23 glfwMakeContextCurrent 23 glfwMakeContextCurrent(window); 24 24 glewExperimental = GL_TRUE; 25 25 glewInit(); … … 43 43 glBufferData(GL_ARRAY_BUFFER, sizeof(points), points, GL_STATIC_DRAW); 44 44 45 GLuint vao =0;45 GLuint vao = 0; 46 46 glGenVertexArrays(1, &vao); 47 47 glBindVertexArray(vao); … … 50 50 glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL); 51 51 52 const char* vertex_shader = 53 "#version 410\n" 54 "in vec3 vp;" 55 "void main() {" 56 " gl_Position = vec4(vp, 1.0);" 57 "}"; 58 59 GLuint vs = glCreateShader(GL_VERTEX_SHADER); 60 glShaderSource(vs, 1, &vertex_shader, NULL); 61 glCompileShader(vs); 62 63 const char* fragment_shader = 64 "#version 410\n" 65 "out vec4 frag_color;" 66 "void main() {" 67 " frag_color = vec4(0.5, 0.0, 0.5, 1.0);" 68 "}"; 69 70 GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); 71 glShaderSource(fs, 1, &fragment_shader, NULL); 72 glCompileShader(fs); 73 74 GLuint shader_program = glCreateProgram(); 75 glAttachShader(shader_program, vs); 76 glAttachShader(shader_program, fs); 77 glLinkProgram(shader_program); 78 79 while (!glfwWindowShouldClose(window)) { 80 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 81 glUseProgram(shader_program); 82 glBindVertexArray(vao); 83 glDrawArrays(GL_TRIANGLES, 0, 3); 84 glfwPollEvents(); 85 glfwSwapBuffers(window); 86 } 87 52 88 glfwTerminate(); 53 89 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.