mirror of
https://github.com/libretro/cpp-cheat.git
synced 2025-04-12 16:23:08 +00:00
83 lines
2.2 KiB
Plaintext
83 lines
2.2 KiB
Plaintext
/*
|
|
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 <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#define GLEW_STATIC
|
|
#include <GL/glew.h>
|
|
|
|
#include <GLFW/glfw3.h>
|
|
|
|
#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;
|
|
}
|