rendered paste body#include <GL/glfw.h>
#define PLAYER_SIZE 0.25
float player_x = 0;
float player_y = 0;
float player_angle = 0;
int main(void)
{
glfwInit();
if (!glfwOpenWindow(640, 480, 8, 8, 8, 8, 24, 0, GLFW_FULLSCREEN))
{
glfwTerminate();
return 0;
}
glfwSetWindowTitle("My OpenGL test");
while (1)
{
if (glfwGetKey(GLFW_KEY_UP))
player_y += 0.0001;
else if (glfwGetKey(GLFW_KEY_DOWN))
player_y -= 0.0001;
if (glfwGetKey(GLFW_KEY_LEFT))
player_x -= 0.0001;
else if (glfwGetKey(GLFW_KEY_RIGHT))
player_x += 0.0001;
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glBegin(GL_QUADS);
glVertex2f(player_x - PLAYER_SIZE / 2, player_y - PLAYER_SIZE / 2);
glVertex2f(player_x + PLAYER_SIZE / 2, player_y - PLAYER_SIZE / 2);
glVertex2f(player_x + PLAYER_SIZE / 2, player_y + PLAYER_SIZE / 2);
glVertex2f(player_x - PLAYER_SIZE / 2, player_y + PLAYER_SIZE / 2);
glEnd();
glfwSwapBuffers();
if (glfwGetKey(GLFW_KEY_ESC) || !glfwGetWindowParam(GLFW_OPENED))
break;
}
glfwTerminate();
return 0;
}