visualiserWin::visualiserWin(int desiredFrameRate, bool vsync, int width, int height, Uint32 flags) { // Set the local members this->desiredFrameRate = desiredFrameRate; this->shouldVsync = vsync; this->currentVis = NULL; this->shouldCloseWindow = false; this->width = width; this->height = height; // Set the OpenGL attributes SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); if(vsync) SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); // Create the DSP manmager dspman = new DSPManager(); // Create the window drawContext = SDL_SetVideoMode(width, height, 0, flags | SDL_OPENGL); if(drawContext == NULL) throw(SDLException()); // also initialise the standard event handlers. initialiseStockEventHandlers(); }
visualiserWin::visualiserWin(int argc, char* argv[]) { // Set the local members to default values. this->desiredFrameRate = 0; this->shouldVsync = true; this->currentVis = NULL; this->shouldCloseWindow = false; this->width = 800; this->height = 600; bool fullscreen = false; MPDMode = false; mpdError = false; char opt; // Parse the options. Note, we don't check the default // case as there may be other options that are specified // for other parts of the program (such as visualisers). opterr = 0; while((opt = getopt(argc, argv, "s:fm:")) != -1) { switch(opt) { case 's': // Window Size. { char* tok = strtok(optarg, "x"); if(!tok) throw(argException("Window size not formatted properly.")); // TODO: Use strtol as it has error checking. width = atoi(tok); tok = strtok(NULL, "x"); if(!tok) throw(argException("Window size not formatted properly.")); height = atoi(tok); break; } case 'f': // Fullscreen. fullscreen = true; break; case 'm': MPDFile = optarg; MPDMode = true; break; } } // If fullscreen is set, detect the resolution. if(fullscreen) { const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo(); width = videoInfo->current_w; height = videoInfo->current_h; } // Set the OpenGL attributes SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); if(shouldVsync) SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); // Create the DSP manmager dspman = new DSPManager(); // Create the window if(fullscreen) drawContext = SDL_SetVideoMode(width, height, 0, SDL_FULLSCREEN | SDL_OPENGL); else drawContext = SDL_SetVideoMode(width, height, 0, SDL_OPENGL); if(drawContext == NULL) throw(SDLException()); // also initialise the standard event handlers. initialiseStockEventHandlers(); }