From 82d64618f8e95d7248c4a31e9018619541b1c966 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 5 Oct 2024 06:49:04 +1000 Subject: [PATCH] Primitive modes sample should let you press START to exit, like other samples --- samples/primitive_modes/main.c | 43 ++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/samples/primitive_modes/main.c b/samples/primitive_modes/main.c index db793cc..f1fa78e 100644 --- a/samples/primitive_modes/main.c +++ b/samples/primitive_modes/main.c @@ -2,10 +2,11 @@ #include #include -#ifdef SDL2_BUILD +#ifndef __DREAMCAST__ #include static SDL_Window* win_handle; #else +#include #include #endif @@ -116,15 +117,36 @@ static void DrawTriFan(float y) { glEnd(); } -int main(int argc, char *argv[]) { -#ifdef SDL2_BUILD +static void sample_init() { +#ifndef __DREAMCAST__ SDL_Init(SDL_INIT_EVERYTHING); win_handle = SDL_CreateWindow("Shapes", 0, 0, 640, 480, SDL_WINDOW_OPENGL); SDL_GL_CreateContext(win_handle); #else glKosInit(); #endif +} +static int sample_should_exit() { +#ifndef __DREAMCAST__ + SDL_Event event; + while (SDL_PollEvent(&event)) { + if(event.type == SDL_QUIT) return 1; + } + return 0; +#else + maple_device_t *cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) return 0; + + cont_state_t *state = (cont_state_t *)maple_dev_status(cont); + if (!state) return 0; + + return state->buttons & CONT_START; +#endif +} + +int main(int argc, char *argv[]) { + sample_init(); glClearColor(0.5f, 0.5f, 0.5f, 1); glViewport(0, 0, 640, 480); @@ -139,18 +161,9 @@ int main(int argc, char *argv[]) { mat[3][3] = 1; glLoadMatrixf(mat); - int running = 1; - - while (running) { + while (!sample_should_exit()) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -#ifdef SDL2_BUILD - SDL_Event event; - while (SDL_PollEvent(&event)) { - if(event.type == SDL_QUIT) running = 0; - } -#endif - DrawTriStrip(300); DrawTriFan(300); DrawTriList(300); @@ -160,9 +173,9 @@ int main(int argc, char *argv[]) { glPointSize(5); DrawPoint(100); - glLineWidth(0.5f); - DrawLineLoop(100); glLineWidth(2); + DrawLineLoop(100); + glLineWidth(4); DrawLineStrip(100); glLineWidth(10); DrawLine(100);