unsigned int resolutionDepths[8][2] = {0};
-bool selectDetail(int & width, int & height, int & bpp, int & detail);
int closestResolution(int width, int height);
int resolutionID(int width, int height);
void ReportError (char * strError);
-void SetupDSpFullScreen();
-void ShutdownDSp();
-
void DrawGL(Game & game);
void CreateGLWindow (void);
void sdlGetCursorPos(POINT *pt)
{
- int x, y;
- SDL_GetMouseState(&x, &y);
- pt->x = x;
- pt->y = y;
+ SDL_GetMouseState(&(pt->x), &(pt->y));
}
#define GetCursorPos(x) sdlGetCursorPos(x)
#define SetCursorPos(x, y) SDL_WarpMouse(x, y)
*/
}
-void SetupDSpFullScreen ()
-{
-}
-
-
-void ShutdownDSp ()
-{
-}
-
-
//-----------------------------------------------------------------------------------------------------------------------
// OpenGL Drawing
DefaultSettings(game);
- selectDetail(kContextWidth, kContextHeight, kBitsPerPixel, detail);
-
+ if (!SDL_WasInit(SDL_INIT_VIDEO))
+ if (SDL_Init(SDL_INIT_VIDEO) == -1)
+ {
+ fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
+ return false;
+ }
if(!LoadSettings(game)) {
fprintf(stderr, "Failed to load config, creating default\n");
SaveSettings(game);
}
-
if(kBitsPerPixel!=32&&kBitsPerPixel!=16){
kBitsPerPixel=16;
}
+ if (SDL_GL_LoadLibrary(NULL) == -1)
+ {
+ fprintf(stderr, "SDL_GL_LoadLibrary() failed: %s\n", SDL_GetError());
+ SDL_Quit();
+ return false;
+ }
- selectDetail(kContextWidth, kContextHeight, kBitsPerPixel, detail);
-
- SetupDSpFullScreen();
-
-
- if (!SDL_WasInit(SDL_INIT_VIDEO))
- {
- if (SDL_Init(SDL_INIT_VIDEO) == -1)
- {
- fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
- return false;
- }
-
- if (SDL_GL_LoadLibrary(NULL) == -1)
- {
- fprintf(stderr, "SDL_GL_LoadLibrary() failed: %s\n", SDL_GetError());
- SDL_Quit();
- return false;
- }
-
- SDL_Rect **res = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL);
- if ( (res == NULL) || (res == ((SDL_Rect **)-1)) || (res[0] == NULL) || (res[0]->w < 640) || (res[0]->h < 480) )
- res = hardcoded_resolutions;
+ SDL_Rect **res = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL);
+ if ( (res == NULL) || (res == ((SDL_Rect **)-1)) || (res[0] == NULL) || (res[0]->w < 640) || (res[0]->h < 480) )
+ res = hardcoded_resolutions;
- // reverse list (it was sorted biggest to smallest by SDL)...
- int count;
- for (count = 0; res[count]; count++)
- {
- if ((res[count]->w < 640) || (res[count]->h < 480))
- break; // sane lower limit.
- }
+ // reverse list (it was sorted biggest to smallest by SDL)...
+ int count;
+ for (count = 0; res[count]; count++)
+ {
+ if ((res[count]->w < 640) || (res[count]->h < 480))
+ break; // sane lower limit.
+ }
- static SDL_Rect *resolutions_block = NULL;
- resolutions_block = (SDL_Rect*) realloc(resolutions_block, sizeof (SDL_Rect) * count);
- resolutions = (SDL_Rect**) realloc(resolutions, sizeof (SDL_Rect *) * (count + 1));
- if ((resolutions_block == NULL) || (resolutions == NULL))
- {
- SDL_Quit();
- fprintf(stderr, "Out of memory!\n");
- return false;
- }
+ static SDL_Rect *resolutions_block = NULL;
+ resolutions_block = (SDL_Rect*) realloc(resolutions_block, sizeof (SDL_Rect) * count);
+ resolutions = (SDL_Rect**) realloc(resolutions, sizeof (SDL_Rect *) * (count + 1));
+ if ((resolutions_block == NULL) || (resolutions == NULL))
+ {
+ SDL_Quit();
+ fprintf(stderr, "Out of memory!\n");
+ return false;
+ }
- resolutions[count--] = NULL;
- for (int i = 0; count >= 0; i++, count--)
- {
- memcpy(&resolutions_block[count], res[i], sizeof (SDL_Rect));
- resolutions[count] = &resolutions_block[count];
- }
+ resolutions[count--] = NULL;
+ for (int i = 0; count >= 0; i++, count--)
+ {
+ memcpy(&resolutions_block[count], res[i], sizeof (SDL_Rect));
+ resolutions[count] = &resolutions_block[count];
+ }
- if (cmdline("showresolutions"))
- {
- printf("Resolutions we think are okay:\n");
- for (int i = 0; resolutions[i]; i++)
- printf(" %d x %d\n", (int) resolutions[i]->w, (int) resolutions[i]->h);
- }
- }
+ if (cmdline("showresolutions"))
+ {
+ printf("Resolutions we think are okay:\n");
+ for (int i = 0; resolutions[i]; i++)
+ printf(" %d x %d\n", (int) resolutions[i]->w, (int) resolutions[i]->h);
+ }
Uint32 sdlflags = SDL_OPENGL;
if (!cmdline("windowed"))
deltaTime /= 1000.0;
multiplier=deltaTime;
- if(multiplier<.001)multiplier=.001;
- if(multiplier>10)multiplier=10;
- if(update)frametime = currTime; // reset for next time interval
+ if(multiplier<.001) multiplier=.001;
+ if(multiplier>10) multiplier=10;
+ if(update) frametime = currTime; // reset for next time interval
deltaTime = (float) AbsoluteDeltaToDuration (currTime, time);
}
// game is not in focus, give CPU time to other apps by waiting for messages instead of 'peeking'
- STUBBED("give up CPU but sniff the event queue");
+ SDL_ActiveEvent evt;
+ SDL_WaitEvent((SDL_Event*)&evt);
+ if (evt.type == SDL_ACTIVEEVENT && evt.gain == 1)
+ gameFocused = true;
+ else if (evt.type == SDL_QUIT)
+ gDone = true;
}
}
// --------------------------------------------------------------------------
-
-
- bool selectDetail(int & width, int & height, int & bpp, int & detail)
- {
- bool res = true;
-
- // currently with SDL, we just use whatever is requested
- // and don't care. --ryan.
-
-
- return res;
- }
-
extern int channels[100];
extern OPENAL_SAMPLE * samp[100];
extern OPENAL_STREAM * strm[20];
bool LoadImage(const char * fname, TGAImageRec & tex)
{
- bool res = true;
-
if ( tex.data == NULL )
- {
return false;
- }
-
-
- res = load_image(fname, tex);
-
-
- return res;
+ else
+ return load_image(fname, tex);
}
void ScreenShot(const char * fname)
{
-
save_image(fname);
-
}