Gui::Gui(Nibbler &nibbler) : AGui(nibbler) { screen = NULL; if (SDL_Init(SDL_INIT_VIDEO) == -1) throw (NibError("SDL_init", "fail")); atexit(SDL_Quit); TTF_Init(); screen = SDL_SetVideoMode(nibbler.getWidth() * 25, nibbler.getHeight() * 25, 16, SDL_HWSURFACE | SDL_DOUBLEBUF); SDL_WM_SetCaption("NIBBLER", NULL); if (screen == NULL) throw (NibError("Video_mode", "fail")); }
Gui::Gui(Nibbler &nibbler) : AGui(nibbler) { size_t height = nibbler.getHeight(); size_t width = nibbler.getWidth(); height_base = static_cast<double>(2) / static_cast<double>(height); weight_base = static_cast<double>(2) / static_cast<double>(width); if (SDL_Init(SDL_INIT_VIDEO) == -1) throw (NibError("opengl_SDL_init", "fail")); if (atexit(SDL_Quit) != 0) throw (NibError("opengl_atexit", "fail")); TTF_Init(); if (SDL_SetVideoMode(width * 25, height * 25, 16, SDL_OPENGL | SDL_HWSURFACE | SDL_DOUBLEBUF) == NULL) throw (NibError("opengl_SDL_SetVideoMode", "fail")); SDL_WM_SetCaption("nibbler OpenGL", NULL); }