diff options
author | pk33 <pk33@pk33.space> | 2024-11-14 15:06:07 +0100 |
---|---|---|
committer | pk33 <pk33@pk33.space> | 2024-11-14 15:06:07 +0100 |
commit | ed2a4bc4400c38ecd11baccac5db328b797b5d68 (patch) | |
tree | b703749d0639f933edca4c3a78209159aa735c25 /src/main.c | |
parent | 5a54774474f43ae29716751d6415563a59b92c7d (diff) | |
download | engine33-ed2a4bc4400c38ecd11baccac5db328b797b5d68.tar.gz |
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 44 |
1 files changed, 35 insertions, 9 deletions
@@ -7,6 +7,7 @@ #include "strings33.h" #include "input33.h" #include "ui33.h" +#include "scene33.h" static void _term_sighandler( int sig ); @@ -20,7 +21,7 @@ int main(int argc, char *argv[]) if( e33_set_signal( SIGINT, _term_sighandler ) == -1 ) { LOGW( "SIGINT not handled"); } if( e33_set_signal( SIGTERM, _term_sighandler ) == -1 ) { LOGW( "SIGTERM not handled"); } - timeOld = clock_get_us(); + timeOld = clock33_get_us(); time = 0; fps = 0; FPS = 0; @@ -37,6 +38,15 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } + if( scene33_init() ) { + return EXIT_FAILURE; + } + + if( graphics33_init() ) { + return EXIT_FAILURE; + } + + while(1) { display33_vtswitcher_poll(1); @@ -46,9 +56,21 @@ int main(int argc, char *argv[]) { input33_poll(); - QPRINTF( 5, 5, "fps: %d", FPS-1 ); - if( KEYDOWN(KEY_K) ) { ui33_add_message("Pressed '%c'", 'K'); } + if( KEYDOWN(KEY_Q) ) { break; } + + if( KEYDOWN(KEY_W) ) { __scene.camera.t[2] += 0.1; } + else if( KEYDOWN(KEY_S) ) { __scene.camera.t[2] -= 0.1; } + if( KEYDOWN(KEY_A) ) { __scene.camera.t[0] -= 0.1; } + else if( KEYDOWN(KEY_D) ) { __scene.camera.t[0] += 0.1; } + if( KEYDOWN(KEY_SPACE) ) { __scene.camera.t[1] -= 0.1; } + else if( KEYDOWN(KEY_LEFTCTRL) ) { __scene.camera.t[1] += 0.1; } + + if( KEYDOWN(KEY_LEFT) ) { __scene.cube.r[1] -= 0.04; } + else if( KEYDOWN(KEY_RIGHT) ) { __scene.cube.r[1] += 0.04; } + if( KEYDOWN(KEY_UP) ) { __scene.cube.r[0] -= 0.04; } + else if( KEYDOWN(KEY_DOWN) ) { __scene.cube.r[0] += 0.04; } + if( MOUSEX ) { __mouse.x += MOUSEX; @@ -57,24 +79,26 @@ int main(int argc, char *argv[]) __mouse.y += MOUSEY; } - - if( __mouse.x < 0 ) __mouse.x = 0; if( __mouse.y < 0 ) __mouse.y = 0; if( __mouse.x >= __display.surface.w ) __mouse.x = __display.surface.w-1; if( __mouse.y >= __display.surface.h ) __mouse.y = __display.surface.h-1; - ui33_draw_mouse(); + graphics33_update(); + + graphics33_decompose_scene(); + QPRINTF( 5, 5, "fps: %d", FPS-1 ); QPRINTF( 100, 5, "M: x(%d), y(%d)", __mouse.x, __mouse.y ); + ui33_draw_mouse(); + ui33_draw_messages(); - ui33_draw_messages(); display33_flip(); } - time += clock_get_us() - timeOld; - timeOld = clock_get_us(); + time += clock33_get_us() - timeOld; + timeOld = clock33_get_us(); if(time >= 1000000) { @@ -89,6 +113,8 @@ int main(int argc, char *argv[]) display33_term(); logger33_term(); input33_term(); + graphics33_term(); + scene33_term(); return EXIT_SUCCESS; |