added -W, -w, -h command line options, retabbed a couple files

git-svn-id: svn://anubis/dwscr/trunk@91 5bef9df8-b654-44bb-925b-0ff18baa8f8c
This commit is contained in:
josh 2008-11-13 02:49:11 +00:00
parent 49d091deeb
commit 4ed97f09f6
4 changed files with 98 additions and 93 deletions

View File

@ -4,9 +4,6 @@
# set this to compile in "debug" mode # set this to compile in "debug" mode
#DEBUG := 1 #DEBUG := 1
# set this to be in "window mode" - i.e. do not hide mouse
# cursor and grab input
#WINDOW_MODE := 1
OBJS = dwscr.o wfobj/WFObj.o LoadFile/LoadFile.o ss/ss.a OBJS = dwscr.o wfobj/WFObj.o LoadFile/LoadFile.o ss/ss.a
TARGET = dwscr TARGET = dwscr
@ -15,9 +12,6 @@ export CPPFLAGS
ifdef DEBUG ifdef DEBUG
CPPFLAGS += -DDEBUG CPPFLAGS += -DDEBUG
endif endif
ifdef WINDOW_MODE
CPPFLAGS += -DWINDOW_MODE
endif
ifdef WITHOUT_ODE ifdef WITHOUT_ODE
CPPFLAGS += -DWITHOUT_ODE CPPFLAGS += -DWITHOUT_ODE
endif endif

View File

@ -23,7 +23,6 @@ using namespace std;
/* main function, called upon program invocation */ /* main function, called upon program invocation */
int main(int argc, char * argv[]) int main(int argc, char * argv[])
{ {
const string startString = "/s";
#ifdef WIN32 #ifdef WIN32
bool start = false; bool start = false;
#else #else
@ -32,6 +31,7 @@ int main(int argc, char * argv[])
SDL_Surface * sdlSurface; SDL_Surface * sdlSurface;
int width = DEFAULT_WIDTH; int width = DEFAULT_WIDTH;
int height = DEFAULT_HEIGHT; int height = DEFAULT_HEIGHT;
bool windowed = false;
#ifdef DEBUG #ifdef DEBUG
start = true; start = true;
@ -44,18 +44,32 @@ int main(int argc, char * argv[])
* to power off at the normally configured timeout) */ * to power off at the normally configured timeout) */
putenv("SDL_VIDEO_ALLOW_SCREENSAVER=1"); putenv("SDL_VIDEO_ALLOW_SCREENSAVER=1");
getDisplaySize(&width, &height);
/* extremely simple command-line argument handling */ /* extremely simple command-line argument handling */
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++)
{ {
if (startString == argv[i]) if (!strcmp("/s", argv[i]))
start = true; start = true;
else if (!strcmp("-W", argv[i]))
windowed = true;
else if (!strncmp("-w", argv[i], 2))
{
width = atoi( (strlen(argv[i]) > 2)
? argv[i] + 2
: argv[++i] );
}
else if (!strncmp("-h", argv[i], 2))
{
height = atoi( (strlen(argv[i]) > 2)
? argv[i] + 2
: argv[++i] );
}
} }
if (!start) if (!start)
return 0; return 0;
getDisplaySize(&width, &height);
/* initialize SDL library */ /* initialize SDL library */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER)) if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER))
{ {
@ -70,22 +84,21 @@ int main(int argc, char * argv[])
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
if ((sdlSurface = SDL_SetVideoMode(width, height, 0, int sdlMode = SDL_HWSURFACE | SDL_OPENGL;
SDL_HWSURFACE if (!windowed)
#ifndef WINDOW_MODE sdlMode |= SDL_NOFRAME;
| SDL_NOFRAME if ((sdlSurface = SDL_SetVideoMode(width, height, 0, sdlMode)) == NULL)
#endif
| SDL_OPENGL)) == NULL)
{ {
cerr << "Error setting video mode!" << endl; cerr << "Error setting video mode!" << endl;
return -2; return -2;
} }
SDL_WM_SetCaption("dwscr", "dwscr"); SDL_WM_SetCaption("dwscr", "dwscr");
#ifndef WINDOW_MODE if (!windowed)
{
SDL_WM_GrabInput(SDL_GRAB_ON); SDL_WM_GrabInput(SDL_GRAB_ON);
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
#endif }
/* after our window is created and SDL and OpenGL are initialized, /* after our window is created and SDL and OpenGL are initialized,
* start the main screensaver functionality */ * start the main screensaver functionality */

View File

@ -95,9 +95,7 @@ void SSMain::run()
switch (event.type) switch (event.type)
{ {
#ifndef WINDOW_MODE
case SDL_KEYDOWN: /* terminate screensaver upon */ case SDL_KEYDOWN: /* terminate screensaver upon */
#endif
case SDL_QUIT: /* key press or quit event */ case SDL_QUIT: /* key press or quit event */
goto RET; goto RET;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN: