56 lines
1.3 KiB
C
56 lines
1.3 KiB
C
#include <stdio.h>
|
|
|
|
#include "GL/gl.h"
|
|
|
|
#include "src/openwindow.h"
|
|
|
|
void handleInput(Window * window) {
|
|
if (windowKeyPressed(window, WINDOW_KEY_A) && !windowKeyShift(window))
|
|
printf("a is being pressed\n");
|
|
|
|
if (windowKeyHeld(window, WINDOW_KEY_A) && !windowKeyShift(window))
|
|
printf("a is being held\n");
|
|
|
|
if (windowKeyReleased(window, WINDOW_KEY_A) && !windowKeyShift(window))
|
|
printf("a is being released\n");
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
Window * w = openWindow("Window", 800, 600);
|
|
|
|
windowSetFps(w, 300);
|
|
|
|
while (!windowKeyPressed(w, WINDOW_KEY_ESC)) {
|
|
windowHandleEvents(w);
|
|
|
|
handleInput(w);
|
|
|
|
//printf("fps: %lf\n", 1 / windowGetDeltaTime(w));
|
|
|
|
int x = 0;
|
|
int y = 0;
|
|
windowGetMousePosition(w, &x, &y);
|
|
//printf("x: %d, y: %d\n", x, y);
|
|
|
|
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;
|
|
}
|