openwindow/main.c

40 lines
882 B
C

#include <stdio.h>
#include "GL/gl.h"
#include "src/openwindow.h"
int main(void)
{
Window * w = openWindow("Window", 800, 600);
while (!windowKeyPressed(w, WINDOW_KEY_ESC)) {
windowHandleEvents(w);
if (windowKeyPressed(w, WINDOW_KEY_A))
printf("A is being pressed\n");
if (windowKeyReleased(w, WINDOW_KEY_A))
printf("A is being released\n");
glClearColor(0.1, 0.2, 0.3, 1);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, 800, 600);
glBegin(GL_TRIANGLES);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex2f(-0.5, -0.5);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex2f(0.5, -0.5);
glColor3f(0.0f, 0.0f, 1.0f);
glVertex2f(0.0, 0.5);
glEnd();
glFlush();
windowDraw(w);
}
closeWindow(w);
return 0;
}