Mercurial > hg > dmlib
changeset 131:df367404f2ad
Merged.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 04 Oct 2012 09:40:03 +0300 |
parents | 1d7dc7c8745c (current diff) ab4086db7dad (diff) |
children | b5569c84f00a |
files | |
diffstat | 3 files changed, 39 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/config.mak.in Thu Oct 04 09:39:37 2012 +0300 +++ b/config.mak.in Thu Oct 04 09:40:03 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 09:39:37 2012 +0300 +++ b/dmsimple.c Thu Oct 04 09:40:03 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, @@ -469,10 +469,14 @@ initSDL = TRUE; // Initialize audio parts - engine.optAfmt.freq = 44100; - engine.optAfmt.format = AUDIO_S16SYS; - engine.optAfmt.channels = 2; - engine.optAfmt.samples = 16*1024; + if (engine.optAfmt.freq == 0 && engine.optAfmt.channels == 0) + { + // Defaults, if none seem to be set + engine.optAfmt.freq = 44100; + engine.optAfmt.format = AUDIO_S16SYS; + engine.optAfmt.channels = 2; + engine.optAfmt.samples = 16*1024; + } #ifdef DM_USE_JSS jssInit(); @@ -519,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); @@ -532,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"); @@ -543,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) @@ -648,7 +665,7 @@ } // Call main tick - if ((err = demoMainTick()) != DMERR_OK) + if ((err = engine.demoRender()) != DMERR_OK) goto error_exit; // Flip screen @@ -690,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 09:39:37 2012 +0300 +++ b/dmsimple.h Thu Oct 04 09:40:03 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