/* Author: Josh Holtrop * DornerWorks screensaver * This was a for-fun project I started working on in November '07 * because I like 3D graphics. I modeled the DornerWorks logo in * blender, exported it to an Alias WaveFront object and material * file, wrote an Alias Wavefront object loader, and then wrapped * some OpenGL and ODE logic around it for various screensaver modes */ #include #include #include #include #include "displayinfo.h" #include "ss/SSMain.h" using namespace std; #define PROGNAME "dwscr" #define DEFAULT_WIDTH 1024 #define DEFAULT_HEIGHT 768 /* main function, called upon program invocation */ int main(int argc, char * argv[]) { const string startString = "/s"; #ifdef WIN32 bool start = false; #else bool start = true; #endif SDL_Surface * sdlSurface; int width = DEFAULT_WIDTH; int height = DEFAULT_HEIGHT; #ifdef DEBUG start = true; #endif /* make the SDL window appear in the top-left corner of the screen */ putenv("SDL_VIDEO_WINDOW_POS=0,0"); /* do not disable power management (this will allow monitors * to power off at the normally configured timeout) */ putenv("SDL_VIDEO_ALLOW_SCREENSAVER=1"); /* extremely simple command-line argument handling */ for (int i = 1; i < argc; i++) { if (startString == argv[i]) start = true; } if (!start) return 0; getDisplaySize(&width, &height); /* initialize SDL library */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER)) { cerr << "Error initializing video!" << endl; return -1; } SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); /* Enable multisampling */ 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) { cerr << "Error setting video mode!" << endl; return -2; } SDL_WM_SetCaption("dwscr", "dwscr"); #ifndef WINDOW_MODE 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 */ SSMain ss(width, height, getNumMonitors(), sdlSurface); ss.run(); SDL_Quit(); return 0; }