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:
parent
49d091deeb
commit
4ed97f09f6
6
Makefile
6
Makefile
@ -4,9 +4,6 @@
|
||||
|
||||
# set this to compile in "debug" mode
|
||||
#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
|
||||
TARGET = dwscr
|
||||
@ -15,9 +12,6 @@ export CPPFLAGS
|
||||
ifdef DEBUG
|
||||
CPPFLAGS += -DDEBUG
|
||||
endif
|
||||
ifdef WINDOW_MODE
|
||||
CPPFLAGS += -DWINDOW_MODE
|
||||
endif
|
||||
ifdef WITHOUT_ODE
|
||||
CPPFLAGS += -DWITHOUT_ODE
|
||||
endif
|
||||
|
37
dwscr.cc
37
dwscr.cc
@ -23,7 +23,6 @@ using namespace std;
|
||||
/* main function, called upon program invocation */
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
const string startString = "/s";
|
||||
#ifdef WIN32
|
||||
bool start = false;
|
||||
#else
|
||||
@ -32,6 +31,7 @@ int main(int argc, char * argv[])
|
||||
SDL_Surface * sdlSurface;
|
||||
int width = DEFAULT_WIDTH;
|
||||
int height = DEFAULT_HEIGHT;
|
||||
bool windowed = false;
|
||||
|
||||
#ifdef DEBUG
|
||||
start = true;
|
||||
@ -44,18 +44,32 @@ int main(int argc, char * argv[])
|
||||
* to power off at the normally configured timeout) */
|
||||
putenv("SDL_VIDEO_ALLOW_SCREENSAVER=1");
|
||||
|
||||
getDisplaySize(&width, &height);
|
||||
|
||||
/* extremely simple command-line argument handling */
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
if (startString == argv[i])
|
||||
if (!strcmp("/s", argv[i]))
|
||||
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)
|
||||
return 0;
|
||||
|
||||
getDisplaySize(&width, &height);
|
||||
|
||||
/* initialize SDL library */
|
||||
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_MULTISAMPLESAMPLES, 4);
|
||||
|
||||
if ((sdlSurface = SDL_SetVideoMode(width, height, 0,
|
||||
SDL_HWSURFACE
|
||||
#ifndef WINDOW_MODE
|
||||
| SDL_NOFRAME
|
||||
#endif
|
||||
| SDL_OPENGL)) == NULL)
|
||||
int sdlMode = SDL_HWSURFACE | SDL_OPENGL;
|
||||
if (!windowed)
|
||||
sdlMode |= SDL_NOFRAME;
|
||||
if ((sdlSurface = SDL_SetVideoMode(width, height, 0, sdlMode)) == NULL)
|
||||
{
|
||||
cerr << "Error setting video mode!" << endl;
|
||||
return -2;
|
||||
}
|
||||
|
||||
SDL_WM_SetCaption("dwscr", "dwscr");
|
||||
#ifndef WINDOW_MODE
|
||||
if (!windowed)
|
||||
{
|
||||
SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* after our window is created and SDL and OpenGL are initialized,
|
||||
* start the main screensaver functionality */
|
||||
|
@ -95,9 +95,7 @@ void SSMain::run()
|
||||
|
||||
switch (event.type)
|
||||
{
|
||||
#ifndef WINDOW_MODE
|
||||
case SDL_KEYDOWN: /* terminate screensaver upon */
|
||||
#endif
|
||||
case SDL_QUIT: /* key press or quit event */
|
||||
goto RET;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
|
Loading…
x
Reference in New Issue
Block a user