project for a (works on my devices) demo

This commit is contained in:
beno
2026-03-13 16:48:03 +01:00
parent 0c0b42fbd0
commit 7ca7ec5d61
38 changed files with 4797 additions and 62 deletions

53
sources/glut_graphics.c Normal file
View File

@@ -0,0 +1,53 @@
#include <stddef.h> /* NULL */
#include "../headers/glut_graphics.h"
/* each request simply sets a flag to be consumed by the main loop, (no need for more than one redraw per cycle) */
int must_redraw = 0;
const int REDRAW_TIMER_INIT = 16;
int redraw_timer = 0;
void (*redraw_callback) (void) = NULL;
void assignRedrawCallback( void ( *callback) ( void)){
if( NULL != redraw_callback){
return;
}
redraw_callback = callback;
}
void issueRedraw(){
must_redraw = 1;
}
void consume_redraws(){
/* ensuring a minimum interval of 1/FPS secs between redraws
if the timer
*/
redraw_timer--;
if( redraw_timer < 0){
redraw_timer = 0;
}
else{
return;
}
if( 0 == must_redraw){
return;
}
must_redraw = 0;
/* what to do if the redraw callback is not set?
is not necessarily an error
*/
if( NULL == redraw_callback){
return;
}
redraw_timer = REDRAW_TIMER_INIT;
/* here the drawing implementation */
redraw_callback();
}