mirror of
https://github.com/ScrelliCopter/Lesson10-SDL3.git
synced 2025-02-21 07:19:26 +11:00
break out update
This commit is contained in:
92
Lesson10.c
92
Lesson10.c
@@ -17,7 +17,6 @@
|
||||
SDL_Window* win = NULL; // Holds Our Window Handle
|
||||
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 blend = false; // Blending ON/OFF
|
||||
|
||||
@@ -47,7 +46,7 @@ GLfloat z = 0.0f; // Depth Into The Screen
|
||||
|
||||
GLuint filter; // Which Filter To Use
|
||||
// Storage For 3 Textures
|
||||
GLuint texture[3] = { 0, 0, 0};
|
||||
GLuint texture[3] = { 0, 0, 0 };
|
||||
|
||||
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()
|
||||
if (active && !DrawGLScene()) // Active?
|
||||
if (!DrawGLScene())
|
||||
{
|
||||
done = true; // ESC or DrawGLScene Signalled A Quit
|
||||
break;
|
||||
done = true; // DrawGLScene Signalled A Quit
|
||||
return 1;
|
||||
}
|
||||
|
||||
SDL_GL_SwapWindow(win); // Swap Buffers (Double Buffering)
|
||||
|
||||
|
||||
// Handle keyboard input
|
||||
const Uint8* keys = SDL_GetKeyboardState(NULL);
|
||||
|
||||
@@ -592,8 +555,53 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
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
|
||||
FreeResources();
|
||||
KillGLWindow(); // Kill The Window
|
||||
|
||||
Reference in New Issue
Block a user