break out update

This commit is contained in:
2024-03-12 21:34:00 +11:00
parent 05d2ac2d2a
commit 0c60210c45

View File

@@ -17,7 +17,6 @@
SDL_Window* win = NULL; // Holds Our Window Handle SDL_Window* win = NULL; // Holds Our Window Handle
SDL_GLContext ctx = NULL; // Permanent Rendering Context SDL_GLContext ctx = NULL; // Permanent Rendering Context
bool active = true; // Window Active Flag Set To TRUE By Default
bool fullscreen = true; // Fullscreen Flag Set To Fullscreen Mode By Default bool fullscreen = true; // Fullscreen Flag Set To Fullscreen Mode By Default
bool blend = false; // Blending ON/OFF bool blend = false; // Blending ON/OFF
@@ -47,7 +46,7 @@ GLfloat z = 0.0f; // Depth Into The Screen
GLuint filter; // Which Filter To Use GLuint filter; // Which Filter To Use
// Storage For 3 Textures // Storage For 3 Textures
GLuint texture[3] = { 0, 0, 0}; GLuint texture[3] = { 0, 0, 0 };
typedef struct tagVERTEX typedef struct tagVERTEX
{ {
@@ -480,53 +479,17 @@ void WndProc(SDL_Event *event)
} }
} }
int main(int argc, char *argv[]) int Update(void)
{ {
SDL_Init(SDL_INIT_VIDEO);
// Ask The User Which Screen Mode They Prefer
const SDL_MessageBoxData msgbox =
{
/* flags */ SDL_MESSAGEBOX_INFORMATION,
/* window */ win,
/* title */ "Start FullScreen?",
/* message */ "Would You Like To Run In Fullscreen Mode?",
/* numbuttons */ 2,
/* buttons */ yesnobttns,
/* colorScheme */ NULL
};
int bttnid = 1;
SDL_ShowMessageBox(&msgbox, &bttnid);
if (bttnid == 1)
{
fullscreen = false; // Windowed Mode
}
// Create Our OpenGL Window
if (!CreateGLWindow("Lionel Brits & NeHe's 3D World Tutorial", 640, 480, 16, fullscreen))
{
return 0; // Quit If Window Was Not Created
}
while (!done) // Loop That Runs While done=FALSE
{
SDL_Event event; // SDL Event Structure
while (SDL_PollEvent(&event) > 0) // Is There A Message Waiting?
{
WndProc(&event); // Deal with events
}
// Draw The Scene. Watch Quit Messages From DrawGLScene() // Draw The Scene. Watch Quit Messages From DrawGLScene()
if (active && !DrawGLScene()) // Active? if (!DrawGLScene())
{ {
done = true; // ESC or DrawGLScene Signalled A Quit done = true; // DrawGLScene Signalled A Quit
break; return 1;
} }
SDL_GL_SwapWindow(win); // Swap Buffers (Double Buffering) SDL_GL_SwapWindow(win); // Swap Buffers (Double Buffering)
// Handle keyboard input // Handle keyboard input
const Uint8* keys = SDL_GetKeyboardState(NULL); const Uint8* keys = SDL_GetKeyboardState(NULL);
@@ -592,8 +555,53 @@ int main(int argc, char *argv[])
{ {
lookupdown += 1.0f; lookupdown += 1.0f;
} }
return 0;
}
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_VIDEO);
// Ask The User Which Screen Mode They Prefer
const SDL_MessageBoxData msgbox =
{
/* flags */ SDL_MESSAGEBOX_INFORMATION,
/* window */ win,
/* title */ "Start FullScreen?",
/* message */ "Would You Like To Run In Fullscreen Mode?",
/* numbuttons */ 2,
/* buttons */ yesnobttns,
/* colorScheme */ NULL
};
int bttnid = 1;
SDL_ShowMessageBox(&msgbox, &bttnid);
if (bttnid == 1)
{
fullscreen = false; // Windowed Mode
} }
// Create Our OpenGL Window
if (!CreateGLWindow("Lionel Brits & NeHe's 3D World Tutorial", 640, 480, 16, fullscreen))
{
return 0; // Quit If Window Was Not Created
}
do
{
SDL_Event event; // SDL Event Structure
while (SDL_PollEvent(&event) > 0) // Is There A Message Waiting?
{
WndProc(&event); // Deal with events
}
if (Update())
{
done = true;
}
} while (!done);
// Shutdown // Shutdown
FreeResources(); FreeResources();
KillGLWindow(); // Kill The Window KillGLWindow(); // Kill The Window