| 78 | }; |
| 79 | |
| 80 | int main(void) |
| 81 | { |
| 82 | glfwSetErrorCallback( |
| 83 | [](int error, const char* description) |
| 84 | { |
| 85 | fprintf(stderr, "Error: %s\n", description); |
| 86 | } |
| 87 | ); |
| 88 | |
| 89 | if (!glfwInit()) |
| 90 | exit(EXIT_FAILURE); |
| 91 | |
| 92 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); |
| 93 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6); |
| 94 | glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); |
| 95 | |
| 96 | GLFWwindow* window = glfwCreateWindow(1024, 768, "Simple example", nullptr, nullptr); |
| 97 | if (!window) |
| 98 | { |
| 99 | glfwTerminate(); |
| 100 | exit(EXIT_FAILURE); |
| 101 | } |
| 102 | |
| 103 | glfwSetKeyCallback( |
| 104 | window, |
| 105 | [](GLFWwindow* window, int key, int scancode, int action, int mods) |
| 106 | { |
| 107 | if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) |
| 108 | glfwSetWindowShouldClose(window, GLFW_TRUE); |
| 109 | } |
| 110 | ); |
| 111 | |
| 112 | glfwMakeContextCurrent(window); |
| 113 | gladLoadGL(glfwGetProcAddress); |
| 114 | glfwSwapInterval(1); |
| 115 | |
| 116 | const GLuint shaderVertex = glCreateShader(GL_VERTEX_SHADER); |
| 117 | glShaderSource(shaderVertex, 1, &shaderCodeVertex, nullptr); |
| 118 | glCompileShader(shaderVertex); |
| 119 | |
| 120 | const GLuint shaderFragment = glCreateShader(GL_FRAGMENT_SHADER); |
| 121 | glShaderSource(shaderFragment, 1, &shaderCodeFragment, nullptr); |
| 122 | glCompileShader(shaderFragment); |
| 123 | |
| 124 | const GLuint program = glCreateProgram(); |
| 125 | glAttachShader(program, shaderVertex); |
| 126 | glAttachShader(program, shaderFragment); |
| 127 | glLinkProgram(program); |
| 128 | glUseProgram(program); |
| 129 | |
| 130 | GLuint vao; |
| 131 | glCreateVertexArrays(1, &vao); |
| 132 | glBindVertexArray(vao); |
| 133 | |
| 134 | const GLsizeiptr kBufferSize = sizeof(PerFrameData); |
| 135 | |
| 136 | GLuint perFrameDataBuffer; |
| 137 | glCreateBuffers(1, &perFrameDataBuffer); |
nothing calls this directly
no test coverage detected