Mercurial > hg > dmlib
changeset 127:ab4086db7dad
Various improvements in modularity.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 04 Oct 2012 06:23:13 +0300 |
parents | 97488948215c |
children | df367404f2ad |
files | config.mak.in dmsimple.c dmsimple.h |
diffstat | 3 files changed, 31 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/config.mak.in Thu Oct 04 06:04:43 2012 +0300 +++ b/config.mak.in Thu Oct 04 06:23:13 2012 +0300 @@ -3,6 +3,9 @@ DM_BUILD_TESTS=no DM_BUILD_TOOLS=yes +# Enable OpenGL specifics (does not mean that OpenGL is automatically used, tho) +DM_USE_OPENGL=no + # Build with runtime asserts? DM_USE_ASSERTS=yes
--- a/dmsimple.c Thu Oct 04 06:04:43 2012 +0300 +++ b/dmsimple.c Thu Oct 04 06:23:13 2012 +0300 @@ -426,7 +426,7 @@ memset(&engine, 0, sizeof(engine)); // Pre-initialization - if ((err = demoPreInit(argc, argv)) != DMERR_OK) + if ((err = demoPreInit()) != DMERR_OK) goto error_exit; if (!dmArgsProcess(argc, argv, optList, optListN, @@ -523,6 +523,13 @@ } // Initialize SDL video + if (engine.demoInitPreVideo != NULL && + (err = engine.demoInitPreVideo()) != DMERR_OK) + { + dmError("demoInitPreVideo() failed, %d: %s\n", err, dmErrorStr(err)); + goto error_exit; + } + dmPrint(1, "Initializing SDL video %d x %d x %dbpp, flags=0x%08x\n", engine.optScrWidth, engine.optScrHeight, engine.optBitDepth, engine.optVFlags); @@ -536,6 +543,12 @@ SDL_ShowCursor(SDL_DISABLE); SDL_WM_SetCaption(dmProgDesc, dmProgName); + if (engine.demoInitPostVideo != NULL && + (err = engine.demoInitPostVideo()) != DMERR_OK) + { + dmError("demoInitPostVideo() failed, %d: %s\n", err, dmErrorStr(err)); + goto error_exit; + } // Load resources dmPrint(1, "Loading resources, please wait...\n"); @@ -547,7 +560,7 @@ } // Final initializations - if ((err = demoInit()) != DMERR_OK) + if ((err = engine.demoInit()) != DMERR_OK) goto error_exit; #if defined(DM_DEBUG) && defined(DM_USE_JSS) @@ -652,7 +665,7 @@ } // Call main tick - if ((err = demoMainTick()) != DMERR_OK) + if ((err = engine.demoRender()) != DMERR_OK) goto error_exit; // Flip screen @@ -694,12 +707,14 @@ dmres_close(); - demoShutdown(); + if (engine.demoShutdown != NULL) + engine.demoShutdown(); if (initSDL) SDL_Quit(); - demoQuit(); + if (engine.demoQuit != NULL) + engine.demoQuit(); return 0; }
--- a/dmsimple.h Thu Oct 04 06:04:43 2012 +0300 +++ b/dmsimple.h Thu Oct 04 06:23:13 2012 +0300 @@ -45,6 +45,14 @@ int audioSamples; int demoDuration; #endif + + int (*demoInit)(); + int (*demoInitPreVideo)(); + int (*demoInitPostVideo)(); + int (*demoRender)(); + void (*demoShutdown)(); + void (*demoQuit)(); + } DMEngineData; @@ -77,10 +85,6 @@ int engineGetTick(); float engineGetTimeDT(); -int demoInit(); int demoPreInit(); -int demoMainTick(); -void demoShutdown(); -void demoQuit(); #endif // DMSIMPLE_H