2025-07-03 01:26:25 +02:00
/* C++ is picky about the linking of C
see
https : //stackoverflow.com/questions/38761620/undefined-reference-to-error-while-linking-object-files
*/
extern " C " {
2026-03-16 00:10:52 +01:00
# include <GL_STUFF/GLES_3_1_compatibility.h>
# include <glut.h>
# include <glut_extensions.h>
2025-07-03 01:26:25 +02:00
}
# include <glm/gtc/type_ptr.hpp>
# include <glm/gtc/matrix_transform.hpp>
# include <cmath>
# include <ctime>
# include <iostream>
# include <string>
2026-03-16 00:10:52 +01:00
# include <GL_STUFF/CURVES/CurvesLoader.hpp>
# include <GL_STUFF/SCENE/InstancesLoader.h>
# include <GL_STUFF/CURVES/CurveIterator.hpp>
# include <GL_STUFF/SCENE/Camera.hpp>
# include <GL_STUFF/SCENE/Instance3D.h>
# include <GL_STUFF/SCENE/ShadingHelper.h>
# include <GL_STUFF/UTILS/ResourceCache.h>
# include <GL_STUFF/UTILS/ShaderMaker.h>
# include <GL_STUFF/UTILS/ClockIterator.hpp>
2025-07-03 01:26:25 +02:00
/* EXCLUDED BC NO COMPUTE SHADERS IN GLES2
2026-03-16 00:10:52 +01:00
# include <GL_STUFF/EFFECTS/CRT_shader.h>
2025-07-03 01:26:25 +02:00
*/
2026-03-16 00:10:52 +01:00
# include <GL_STUFF/EFFECTS/ReelManager.h>
# include <GL_STUFF/EFFECTS/TexMerger.h>
# include <GL_STUFF/EFFECTS/Scene.h>
# include <GL_STUFF/EFFECTS/Screen.h>
2025-07-03 01:26:25 +02:00
using namespace glm ;
using namespace std ;
2026-03-16 00:10:52 +01:00
const char * RES_FOLDER = " /home/beno/Desktop/rg552_minimal_dev_env/WAYLAND/demos/rez_demo/resources/ " ; // "/CGI_DEMO/RESOURCES/";
2025-07-03 01:26:25 +02:00
2026-03-16 00:10:52 +01:00
const char * devPaths [ 2 ] = {
" /dev/input/event4 " ,
" /dev/input/event5 "
} ;
const int TARGET_FPS = 60 ;
2025-07-03 01:26:25 +02:00
static int ONE_TICK_MS = 1000 / TARGET_FPS ;
2026-03-16 00:10:52 +01:00
int scrWidth ;
int scrHeight ;
2025-07-03 01:26:25 +02:00
float viewSize = 2.0f ;
float aspect_ratio ;
int steps = 60 ;
GLuint linesShader ;
GLuint curveVAO ;
int nCurvePoints = 10000 ;
GLuint controlPointsVAO ;
int nControlPoints ;
GLuint curvePointsVBO ;
GLuint controlPointsVBO ;
mat4 projection ;
int baseClock = 8000 ;
ClockIterator cubesClock = ClockIterator ( baseClock ) ;
vector < Instance3D * > columns = vector < Instance3D * > ( ) ;
ShadingHelper * columnsShading ;
Instance3D * cube ;
ShadingHelper * cubeShading ;
vector < TextureHelper > cubeTextures ;
vector < Curve * > curves = vector < Curve * > ( ) ;
vector < CurveIterator * > iterators = vector < CurveIterator * > ( ) ;
CameraController * camera ;
Scene * sceneBuffer ;
ReelManager * reel ;
TexMerger * merger ;
Screen * canvas ;
/*was false and triggerable via keypress but i have no input capturing*/
bool runIterator = true ;
2026-03-16 00:10:52 +01:00
uint8_t previous_touches_count = 0 ;
uint8_t current_touches_count = 0 ;
2025-07-03 01:26:25 +02:00
2026-03-16 00:10:52 +01:00
touch_event * * previous_touches = NULL ;
touch_event * * current_touches = NULL ;
2025-07-03 01:26:25 +02:00
2026-03-16 00:10:52 +01:00
uint8_t touch_rotation = 3 ; /* it is not always possible to use a calibration matrix for rotating the touchscreen events, 0..3 rotations of 0, 90, 180, 270 */
2025-07-03 01:26:25 +02:00
/* don't want to implement */
/* also removed
glEnable ( GL_ALPHA_TEST ) ;
glDisable ( GL_ALPHA_TEST ) ;
*/
GLuint GLUT_COMPATIBILITY_PROFILE = 0 ;
GLuint GLUT_SINGLE = 0 ;
GLuint GLUT_RGBA = 0 ;
const GLuint GLUT_SCREEN_WIDTH = 0 ;
const GLuint GLUT_SCREEN_HEIGHT = 1 ;
void glutInitContextVersion ( int maj , int min ) { }
void glutInitContextProfile ( GLuint profile ) { }
void glutInitDisplayMode ( GLuint OR_ed_FLAGS ) { }
int glutGet ( GLuint dimension ) {
switch ( dimension ) {
case GLUT_SCREEN_WIDTH :
return 1920 ;
break ;
case GLUT_SCREEN_HEIGHT :
return 1156 ;
break ;
default :
exit ( 1 ) ;
}
}
vector < GLuint > antiLogSelect ( vector < GLuint > frames , float increment ) {
vector < int > indices = vector < int > ( ) ;
assert ( increment > 1 ) ;
float gap = 1 ;
for ( int index = 0 ; index < frames . size ( ) ; index + = gap ) {
gap * = increment ;
indices . push_back ( index ) ;
}
vector < GLuint > selected = vector < GLuint > ( ) ;
for ( int i = indices . size ( ) - 1 ; i > = 0 ; i - - ) {
selected . push_back ( frames [ frames . size ( ) - 1 - indices [ i ] ] ) ;
}
return selected ;
}
void drawAxis ( ) {
/*
glUseProgram ( linesShader ) ;
//AXIS
glUniform3f ( glGetUniformLocation ( linesShader , " baseColor " ) , 1 , 0 , 0 ) ;
glBegin ( GL_LINES ) ;
glVertex3f ( 0 , 0 , 0 ) ;
glVertex3f ( 5 , 0 , 0 ) ;
glEnd ( ) ;
glUniform3f ( glGetUniformLocation ( linesShader , " baseColor " ) , 0 , 0 , 1 ) ;
glBegin ( GL_LINES ) ;
glVertex3f ( 0 , 0 , 0 ) ;
glVertex3f ( 0 , 5 , 0 ) ;
glEnd ( ) ;
glUniform3f ( glGetUniformLocation ( linesShader , " baseColor " ) , 0 , 1 , 0 ) ;
glBegin ( GL_LINES ) ;
glVertex3f ( 0 , 0 , 0 ) ;
glVertex3f ( 0 , 0 , 5 ) ;
glEnd ( ) ;
*/
}
void drawCurve ( ) {
glUseProgram ( linesShader ) ;
//CURVE
glUniform3f ( glGetUniformLocation ( linesShader , " baseColor " ) , 0 , 1 , 0 ) ;
GLint localTransformUniform = glGetUniformLocation ( linesShader , " Model " ) ;
glUniformMatrix4fv ( localTransformUniform , 1 , GL_FALSE , value_ptr ( glm : : mat4 ( 1.0 ) ) ) ;
GLint projectionUniform = glGetUniformLocation ( linesShader , " Projection " ) ;
glUniformMatrix4fv ( projectionUniform , 1 , GL_FALSE , value_ptr ( projection ) ) ;
GLint viewUniform = glGetUniformLocation ( linesShader , " View " ) ;
glUniformMatrix4fv ( viewUniform , 1 , GL_FALSE , value_ptr ( camera - > getCamera ( ) - > getViewMat ( ) ) ) ;
glBindVertexArray ( curveVAO ) ;
glDrawArrays ( GL_POINTS , 0 , 2 * nCurvePoints ) ;
glBindVertexArray ( 0 ) ;
/* DISABLED
glUniform3f ( glGetUniformLocation ( linesShader , " baseColor " ) , 1 , 0 , 0 ) ;
glPointSize ( 10.0 ) ;
glBegin ( GL_POINTS ) ;
vec3 p = iterators [ 0 ] - > evaluation ( ) ;
glVertex3f ( p . x , p . y , p . z ) ;
glEnd ( ) ;
glPointSize ( 1.0 ) ;
glUniform3f ( glGetUniformLocation ( linesShader , " baseColor " ) , 0 , 0 , 1 ) ;
glBegin ( GL_LINES ) ;
vec3 d = p + iterators [ 0 ] - > derivation ( ) ;
glVertex3f ( p . x , p . y , p . z ) ;
glVertex3f ( d . x , d . y , d . z ) ;
glEnd ( ) ;
*/
glUniform3f ( glGetUniformLocation ( linesShader , " baseColor " ) , 1 , 0 , 0 ) ;
glBindVertexArray ( controlPointsVAO ) ;
glDrawArrays ( GL_LINES , 0 , 2 * nControlPoints ) ;
glBindVertexArray ( 0 ) ;
}
//funky stuff ahead
void renderLoop ( ) {
/* DISABLED
reel - > nextTexture ( ) ;
reel - > clearTexture ( ) ;
vector < GLuint > frames = reel - > getTextures ( ) ;
sceneBuffer - > setOutTexture ( frames . back ( ) ) ;
sceneBuffer - > draw ( ) ;
*/
glClearColor ( 0 , 0 , 0 , 0 ) ;
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
glEnable ( GL_CULL_FACE ) ;
glCullFace ( GL_BACK ) ;
glDepthFunc ( GL_LESS ) ;
//glEnable(GL_BLEND); //Attiva il blending
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
cubeShading - > useProgram ( ) ;
cubeShading - > bindTexture2D ( 1 , cubeTextures [ 0 ] . texture , cubeTextures [ 0 ] . uniformName ) ;
cubeShading - > bindTexture2D ( 2 , cubeTextures [ 1 ] . texture , cubeTextures [ 1 ] . uniformName ) ;
cubeShading - > bindViewUniforms ( projection , camera - > getCamera ( ) - > getViewMat ( ) ) ;
cubeShading - > bindLightUniforms ( vec3 ( 0 , 100 , 0 ) , vec3 ( 1.0f ) , camera - > getCamera ( ) - > getPosition ( ) ) ;
cubeShading - > bindModelUniforms ( cube - > getGlobalTransform ( ) , cube - > getLocalTransform ( ) ) ;
cube - > getModel ( ) - > draw ( ) ;
glDisable ( GL_CULL_FACE ) ;
glDisable ( GL_DEPTH_TEST ) ;
glEnable ( GL_DEPTH_TEST ) ;
glDepthFunc ( GL_ALWAYS ) ;
/*
glEnable ( GL_ALPHA_TEST ) ;
*/
glEnable ( GL_BLEND ) ; //Attiva il blending
glBlendFunc ( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA ) ;
glBlendEquation ( GL_MAX ) ; //evita i brutti artefatti
drawAxis ( ) ;
drawCurve ( ) ;
columnsShading - > useProgram ( ) ;
glUniform1f ( glGetUniformLocation ( columnsShading - > getProgram ( ) , " time " ) , cubesClock . getPercentage ( ) / 100.0f ) ;
columnsShading - > bindViewUniforms ( projection , camera - > getCamera ( ) - > getViewMat ( ) ) ;
columnsShading - > bindLightUniforms ( vec3 ( 0 , 100 , 0 ) , vec3 ( 1.0f ) , camera - > getCamera ( ) - > getPosition ( ) ) ;
vec3 LBN = vec3 ( 0 , 10000 , 0 ) ;
vec3 RTF = vec3 ( 0 , - 10000 , 0 ) ;
for ( Instance3D * inst : columns ) {
LBN = ( LBN . y < inst - > getModel ( ) - > getLBN ( ) . y ) ? LBN : inst - > getModel ( ) - > getLBN ( ) ;
RTF = ( RTF . y > inst - > getModel ( ) - > getRTF ( ) . y ) ? RTF : inst - > getModel ( ) - > getRTF ( ) ;
}
for ( Instance3D * inst : columns ) {
glUniform3fv ( glGetUniformLocation ( columnsShading - > getProgram ( ) , " boundingBoxLBN " ) , 1 , & LBN [ 0 ] ) ;
glUniform3fv ( glGetUniformLocation ( columnsShading - > getProgram ( ) , " boundingBoxRTF " ) , 1 , & RTF [ 0 ] ) ;
columnsShading - > bindModelUniforms ( inst - > getGlobalTransform ( ) , inst - > getLocalTransform ( ) ) ;
inst - > getModel ( ) - > draw ( ) ;
}
/*
glDisable ( GL_ALPHA_TEST ) ;
*/
glDisable ( GL_BLEND ) ;
/* DISABLED
vector < GLuint > selectedFrames = antiLogSelect ( frames , 1.01 + ( 1 - cubesClock . getPercentage ( ) / 100.0f ) * 5 ) ;
GLuint merged = merger - > merge ( selectedFrames , 0 , selectedFrames . size ( ) - 1 ) ;
*/
//GLuint merged = selectedFrames.back();
/*
canvas - > setInputTexture ( merged ) ;
canvas - > draw ( ) ;
*/
/* DISABLED
sceneBuffer - > setOutTexture ( merged ) ;
sceneBuffer - > draw ( ) ;
CRT_Shader : : get ( ) . loadColorFromFramebuffer ( sceneBuffer - > getFrameBuffer ( ) ) ;
glBindFramebuffer ( GL_FRAMEBUFFER , 0 ) ;
glClearColor ( 0 , 0 , 0 , 0 ) ;
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
CRT_Shader : : get ( ) . draw ( ONE_TICK_MS , 0 ) ;
*/
glutSwapBuffers ( ) ;
}
void timer ( int value ) {
2026-03-16 00:10:52 +01:00
//printf("begin timer buffers are old[%d] %p new[%d] %p\n", previous_touches_count, ( void*) previous_touches, current_touches_count, ( void*) current_touches);
//touch_events_array_copy( &previous_touches, current_touches, current_touches_count);
previous_touches = current_touches ;
previous_touches_count = current_touches_count ;
//printf("after copy buffers are old[%d] %p new[%d] %p\n", previous_touches_count, ( void*) previous_touches, current_touches_count, ( void*) current_touches);
glutGetTouchProxy ( ) . get_tracked_events ( & current_touches , & current_touches_count ) ;
//printf("after updating current buffers are old[%d] %p new[%d] %p\n", previous_touches_count, ( void*) previous_touches, current_touches_count, ( void*) current_touches);
2025-07-03 01:26:25 +02:00
cubesClock . step ( ONE_TICK_MS ) ;
cube - > rotate ( vec3 ( 0 , 1 , 0 ) , 1 ) ;
if ( runIterator ) {
//cube->setPosition(iterators[0]->evaluation());
//cube->alignTo(iterators[0]->derivation());
camera - > getCamera ( ) - > setPosition ( iterators [ 0 ] - > evaluation ( ) ) ;
camera - > getCamera ( ) - > alignTo ( iterators [ 0 ] - > derivation ( ) ) ;
for ( int i = 0 ; i < 10 ; i + + )
iterators [ 0 ] - > nextStep ( ) ;
/*
std : : cout < < " eval at " < < iterators [ 0 ] - > getStep ( ) < < " \n " ;
*/
}
2026-03-16 00:10:52 +01:00
else {
if ( previous_touches_count & & current_touches_count ) {
/*
printf ( " previous \n " ) ;
for ( uint8_t i = 0 ; i < previous_touches_count ; i + + ) {
printf ( " %ld \n " , previous_touches [ i ] - > tracking_id ) ;
}
printf ( " current \n " ) ;
for ( uint8_t i = 0 ; i < current_touches_count ; i + + ) {
printf ( " %ld \n " , previous_touches [ i ] - > tracking_id ) ;
}
*/
touch_coordinates * touch_pos_deltas ;
uint8_t touch_pos_deltas_count ;
//printf( "getting deltas\n");
glutGetTouchProxy ( ) . get_position_deltas (
previous_touches , previous_touches_count ,
current_touches , current_touches_count ,
& touch_pos_deltas , & touch_pos_deltas_count
) ;
//printf("got deltas\n");
if ( touch_pos_deltas_count ) {
int64_t x_offset = touch_pos_deltas [ 0 ] . x ;
int64_t y_offset = touch_pos_deltas [ 0 ] . y ;
int64_t buff_offset ;
switch ( touch_rotation % 4 ) {
case 0 :
break ;
case 1 :
buff_offset = x_offset ;
x_offset = - y_offset ;
y_offset = buff_offset ;
break ;
case 2 :
x_offset = - x_offset ;
y_offset = - y_offset ;
break ;
case 3 :
// was x_offset = y_offset, now it is negated and invalidates all the previous remappings
buff_offset = x_offset ;
x_offset = - y_offset ;
y_offset = - buff_offset ;
break ;
}
printf ( " this ass moved X of %ld \n " , x_offset ) ;
printf ( " this ass moved relX of %f \n " , ( float ) x_offset / scrWidth ) ;
camera - > panX ( 100 * ( ( float ) x_offset / scrWidth ) ) ;
camera - > panY ( 100 * ( ( float ) y_offset / scrHeight ) ) ;
free_touch_coordinates_buffer ( touch_pos_deltas ) ;
}
}
}
if ( previous_touches_count ) {
free_touch_events_array ( previous_touches , previous_touches_count ) ;
previous_touches = NULL ;
previous_touches_count = 0 ;
}
2025-07-03 01:26:25 +02:00
glutTimerFunc ( ONE_TICK_MS , timer , 0 ) ;
glutPostRedisplay ( ) ;
2026-03-16 00:10:52 +01:00
// printf("end of timer\n");
2025-07-03 01:26:25 +02:00
}
void keypressed ( unsigned char key , int x , int y ) {
if ( key > = ' 0 ' & & key < = ' 9 ' ) {
int prog = cubesClock . getPosition ( ) ;
cubesClock = ClockIterator ( baseClock / pow ( 3 , ( key - ' 0 ' ) / 2.0f ) ) ;
cubesClock . step ( prog ) ;
//for (CurveIterator* it : iterators)
// it->setProgress((key - '0')/ 10.0f);
}
else if ( key = = 32 ) {
runIterator = ! runIterator ;
} else if ( key = = 27 ) {
exit ( 0 ) ;
}
else {
camera - > keyPress ( key ) ;
}
}
void mousemoved ( int x , int y ) {
//camera.mouseMotion(x, y);
}
void emplaceModels ( ) {
char buf_1 [ 256 ] ;
char buf_2 [ 256 ] ;
snprintf ( buf_1 , sizeof ( buf_1 ) , " %s%s " , RES_FOLDER , " SCENE/scene.txt " ) ;
printf ( " would load %s \n " , buf_1 ) ;
loadInstances ( buf_1 , columns , false ) ;
snprintf ( buf_1 , sizeof ( buf_1 ) , " %s%s " , RES_FOLDER , " vertexShader_pulse.glsl " ) ;
snprintf ( buf_2 , sizeof ( buf_2 ) , " %s%s " , RES_FOLDER , " fragmentShader_pulse.glsl " ) ;
printf ( " would load %s | %s \n " , buf_1 , buf_2 ) ;
columnsShading = new ShadingHelper ( ResourceCache : : get ( ) . getShader ( & buf_1 [ 0 ] , & buf_2 [ 0 ] ) ) ;
snprintf ( buf_1 , sizeof ( buf_1 ) , " %s%s " , RES_FOLDER , " ico.obj " ) ;
printf ( " would load %s \n " , buf_1 ) ;
Model3D * cubeModel = new Model3D ( buf_1 , true ) ;
snprintf ( buf_1 , sizeof ( buf_1 ) , " %s%s " , RES_FOLDER , " vertexShader_gourard.glsl " ) ;
snprintf ( buf_2 , sizeof ( buf_2 ) , " %s%s " , RES_FOLDER , " fragmentShader_gourard.glsl " ) ;
cubeShading = new ShadingHelper ( ResourceCache : : get ( ) . getShader ( & buf_1 [ 0 ] , & buf_2 [ 0 ] ) ) ;
cube = new Instance3D ( cubeModel , vec3 ( 10 , 0 , 0 ) ) ;
TextureHelper col = TextureHelper ( ) ;
snprintf ( buf_1 , sizeof ( buf_1 ) , " %s%s " , RES_FOLDER , " waito.png " ) ;
printf ( " would load %s \n " , buf_1 ) ;
col . texture = ResourceCache : : get ( ) . getImage ( buf_1 ) ;
col . uniformName = " colorMap " ;
TextureHelper nor = TextureHelper ( ) ;
snprintf ( buf_1 , sizeof ( buf_1 ) , " %s%s " , RES_FOLDER , " cube3.png " ) ;
printf ( " would load %s \n " , buf_1 ) ;
nor . texture = ResourceCache : : get ( ) . getImage ( buf_1 ) ;
nor . uniformName = " normalMap " ;
cubeTextures . push_back ( col ) ;
cubeTextures . push_back ( nor ) ;
}
void curveSetup ( ) {
char buf_1 [ 256 ] ;
char buf_2 [ 256 ] ;
snprintf ( buf_1 , sizeof ( buf_1 ) , " %s%s " , RES_FOLDER , " curve5.txt " ) ;
printf ( " would load %s \n " , buf_1 ) ;
CurvesLoader : : loadCurves ( buf_1 , curves ) ;
//CurvesLoader::loadCurves("C:\\Users\\BoBoBoat\\Documents\\curve4cyclic.txt", curves);
for ( Curve * curve : curves )
iterators . push_back ( new CurveIterator ( curve , nCurvePoints , CurveIterationMode : : LENGTH ) ) ;
snprintf ( buf_1 , sizeof ( buf_1 ) , " %s%s " , RES_FOLDER , " vertexShader_lines.glsl " ) ;
snprintf ( buf_2 , sizeof ( buf_2 ) , " %s%s " , RES_FOLDER , " fragmentShader_lines.glsl " ) ;
printf ( " would load %s | %s \n " , buf_1 , buf_2 ) ;
linesShader = ShaderMaker : : createProgram ( & buf_1 [ 0 ] , & buf_2 [ 0 ] ) ;
glGenVertexArrays ( 1 , & curveVAO ) ;
glBindVertexArray ( curveVAO ) ;
vector < glm : : vec3 > curvePoints = vector < glm : : vec3 > ( ) ;
for ( int i = 0 ; i < nCurvePoints ; i + + ) {
curvePoints . push_back ( iterators [ 0 ] - > evaluation ( ) ) ;
iterators [ 0 ] - > nextStep ( ) ;
curvePoints . push_back ( iterators [ 0 ] - > evaluation ( ) ) ;
}
glGenBuffers ( 1 , & curvePointsVBO ) ;
glBindBuffer ( GL_ARRAY_BUFFER , curvePointsVBO ) ;
glBufferData ( GL_ARRAY_BUFFER , 2 * nCurvePoints * sizeof ( vec3 ) , & curvePoints [ 0 ] , GL_STATIC_DRAW ) ;
glEnableVertexAttribArray ( 0 ) ;
glVertexAttribPointer ( 0 , 3 , GL_FLOAT , GL_FALSE , 0 , 0 ) ;
glBindVertexArray ( 0 ) ;
glGenVertexArrays ( 1 , & controlPointsVAO ) ;
glBindVertexArray ( controlPointsVAO ) ;
vector < vec3 > controlPoints = vector < vec3 > ( ) ;
vector < vec3 > cp = * iterators [ 0 ] - > getCurve ( ) - > getControlPoints ( ) ;
controlPoints . push_back ( cp [ 0 ] ) ;
for ( int i = 1 ; i < cp . size ( ) - 1 ; i + + ) {
controlPoints . push_back ( cp [ i ] ) ;
controlPoints . push_back ( cp [ i ] ) ;
}
controlPoints . push_back ( cp [ cp . size ( ) - 1 ] ) ;
nControlPoints = controlPoints . size ( ) ;
glGenBuffers ( 1 , & controlPointsVBO ) ;
glBindBuffer ( GL_ARRAY_BUFFER , controlPointsVBO ) ;
glBufferData ( GL_ARRAY_BUFFER , nControlPoints * sizeof ( vec3 ) , & controlPoints [ 0 ] , GL_STATIC_DRAW ) ;
glEnableVertexAttribArray ( 0 ) ;
glVertexAttribPointer ( 0 , 3 , GL_FLOAT , GL_FALSE , 0 , 0 ) ;
glBindVertexArray ( 0 ) ;
}
int main ( int argc , char * argv [ ] ) {
2026-03-16 00:10:52 +01:00
glutInit ( ( char * * ) devPaths , 2 ) ;
2025-07-03 01:26:25 +02:00
glutInitContextVersion ( 4 , 0 ) ;
glutInitContextProfile ( GLUT_COMPATIBILITY_PROFILE ) ;
glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGBA ) ;
2026-03-16 00:10:52 +01:00
scrWidth = glutGet ( GLUT_SCREEN_WIDTH ) ; //* 5 / 6;
scrHeight = glutGet ( GLUT_SCREEN_HEIGHT ) ; //* 5 / 6;
2025-07-03 01:26:25 +02:00
//scrWidth = 640;
//scrHeight = 480;
aspect_ratio = ( ( float ) scrWidth ) / scrHeight ;
glutInitWindowSize ( scrWidth , scrHeight ) ;
glutInitWindowPosition ( 0 , 0 ) ;
glutCreateWindow ( " TriDi " ) ;
/*
glewExperimental = GL_TRUE ;
GLenum err = glewInit ( ) ;
if ( GLEW_OK ! = err )
std : : cout < < " Error " < < glewGetErrorString ( err ) < < " \n " ;
*/
//glutSetCursor(GLUT_CURSOR_NONE);
glutTimerFunc ( ONE_TICK_MS , timer , 0 ) ;
glutDisplayFunc ( renderLoop ) ;
glutKeyboardFunc ( keypressed ) ;
glutPassiveMotionFunc ( mousemoved ) ;
/*get the pointers to the missing functions*/
2026-03-16 00:10:52 +01:00
GLES_3_1_comp_init ( ) ;
2025-07-03 01:26:25 +02:00
printf (
" GL info : \n version : %s \n vendor: %s \n renderer : %s \n shading language version: %s \n " ,
glGetString ( GL_VERSION ) ,
glGetString ( GL_VENDOR ) ,
glGetString ( GL_RENDERER ) ,
glGetString ( GL_SHADING_LANGUAGE_VERSION )
) ;
projection = glm : : perspective ( glm : : radians ( 30.0f ) , aspect_ratio , 0.1f , 1000.0f ) ;
camera = new CameraController ( new Camera ( vec3 ( 0 , 0 , 2.0f ) , vec3 ( 0 , 0 , 1.0f ) , vec3 ( 0 , 1.0f , 0 ) ) ) ;
camera - > setWindowData ( 0 , scrWidth , 0 , scrHeight ) ;
camera - > getCamera ( ) - > setPosition ( vec3 ( 0 , 0 , 2 ) ) ;
curveSetup ( ) ;
emplaceModels ( ) ;
/*
printf ( " begin effects setup \n " ) ;
sceneBuffer = new Scene ( 0 , 0 , scrWidth , scrHeight ) ;
reel = new ReelManager ( 4 * TARGET_FPS , scrWidth , scrHeight ) ;
merger = new TexMerger ( 2 * TARGET_FPS , scrWidth , scrHeight ) ;
canvas = new Screen ( 0 , 0 , scrWidth , scrHeight ) ;
printf ( " end effects setup \n " ) ;
*/
/* DISABLED
CRT_Shader : : setup ( scrWidth , scrHeight , TRUE , SIM_PRECISION : : ROUGH ) ;
CRT_Shader : : get ( ) ;
*/
//glEnable(GL_CULL_FACE);
//glCullFace(GL_BACK);
glutMainLoop ( ) ;
}