/* Just for fun. Blocked my Ubuntu 15.10 with OpenGL 4.5.0 NVIDIA 352.63, but I was able to regain control with after a lot of Alt+F4 nd Ctrl+C TODO why does it block everything, if it's only in the GPU? */ #include #include #define GLEW_STATIC #include #include #include "common.h" static const GLuint WIDTH = 800; static const GLuint HEIGHT = 600; static const GLchar* vertex_shader_source = "#version 330 core\n" "layout (location = 0) in vec3 position;\n" "void main() {\n" " while(true);\n" " gl_Position = vec4(position, 1.0);\n" "}\n"; static const GLchar* fragment_shader_source = "#version 330 core\n" "out vec4 color;\n" "void main() {\n" " color = vec4(1.0f, 0.0f, 0.0f, 1.0f);\n" "}\n"; /* Passed as input to the vertex shader. */ static const GLfloat vertices[] = { 0.0f, 0.5f, 0.0f, 0.5f, -0.5f, 0.0f, -0.5f, -0.5f, 0.0f, }; int main(void) { GLint shader_program; glfwInit(); GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, __FILE__, NULL, NULL); glfwMakeContextCurrent(window); glewExperimental = GL_TRUE; glewInit(); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glViewport(0, 0, WIDTH, HEIGHT); shader_program = common_get_shader_program(vertex_shader_source, fragment_shader_source); GLuint vbo, vao; glGenVertexArrays(1, &vao); glGenBuffers(1, &vbo); glBindVertexArray(vao); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid*)0); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); while (!glfwWindowShouldClose(window)) { glfwPollEvents(); /* Render */ glClear(GL_COLOR_BUFFER_BIT); glUseProgram(shader_program); glBindVertexArray(vao); glDrawArrays(GL_TRIANGLES, 0, 3); /*glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, 0);*/ glBindVertexArray(0); glfwSwapBuffers(window); } glDeleteVertexArrays(1, &vao); glDeleteBuffers(1, &vbo); glfwTerminate(); return EXIT_SUCCESS; }