2023-05-08 09:07:48 +02:00
|
|
|
#include "../includes/animations.h"
|
|
|
|
|
|
|
|
static GLuint _pId = 0;
|
2023-05-08 10:23:45 +02:00
|
|
|
static GLuint _planId = 0;
|
2023-05-08 09:07:48 +02:00
|
|
|
|
|
|
|
static void init(void);
|
|
|
|
static void draw(void);
|
|
|
|
|
|
|
|
void manif(int state) {
|
|
|
|
switch (state) {
|
|
|
|
case GL4DH_INIT:
|
|
|
|
init();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GL4DH_DRAW:
|
|
|
|
draw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void init(void) {
|
2023-05-08 10:23:45 +02:00
|
|
|
_planId = gl4dgGenQuadf();
|
2023-05-08 09:08:09 +02:00
|
|
|
_pId =
|
|
|
|
gl4duCreateProgram("<vs>shaders/manif.vs", "<fs>shaders/manif.fs", NULL);
|
2023-05-08 09:07:48 +02:00
|
|
|
|
|
|
|
gl4duGenMatrix(GL_FLOAT, "proj");
|
2023-05-08 10:23:45 +02:00
|
|
|
gl4duGenMatrix(GL_FLOAT, "model");
|
2023-05-08 09:07:48 +02:00
|
|
|
gl4duGenMatrix(GL_FLOAT, "view");
|
|
|
|
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw(void) {
|
2023-05-08 10:23:45 +02:00
|
|
|
glClearColor(0.2f, 0.2f, 0.8f, 1);
|
2023-05-08 09:07:48 +02:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
2023-05-08 10:23:45 +02:00
|
|
|
glUseProgram(_pId);
|
2023-05-08 09:07:48 +02:00
|
|
|
|
2023-05-08 10:23:45 +02:00
|
|
|
gl4duBindMatrix("proj");
|
|
|
|
gl4duLoadIdentityf();
|
|
|
|
GLfloat ratio = (GLfloat)_dims[0] / (GLfloat)_dims[1];
|
|
|
|
gl4duFrustumf(-1, 1, -ratio, ratio, 1, 1000);
|
|
|
|
|
|
|
|
gl4duBindMatrix("view");
|
|
|
|
gl4duLoadIdentityf();
|
|
|
|
const GLfloat distance = 2;
|
|
|
|
gl4duLookAtf(0, distance, distance, 0, 0, 0, 0, 1, 0);
|
|
|
|
|
|
|
|
gl4duBindMatrix("model");
|
|
|
|
gl4duLoadIdentityf();
|
|
|
|
gl4duRotatef(-90, 1, 0, 0);
|
|
|
|
gl4duScalef(4 * distance, 2 * distance, 1);
|
|
|
|
|
|
|
|
gl4duSendMatrices();
|
|
|
|
gl4dgDraw(_planId);
|
2023-05-08 09:07:48 +02:00
|
|
|
|
|
|
|
glUseProgram(0);
|
|
|
|
}
|