+ init();
+}
+
+Video::Attributes::Attributes(const Settings& settings)
+{
+ init();
+
+ std::vector<int> colors;
+ settings.get("colorbuffers", colors);
+ if (colors.size() > 0) colorBuffer[0] = colors[0];
+ if (colors.size() > 1) colorBuffer[1] = colors[1];
+ if (colors.size() > 2) colorBuffer[2] = colors[2];
+ if (colors.size() > 3) colorBuffer[3] = colors[3];
+
+ settings.get("framebuffer", frameBuffer);
+ settings.get("doublebuffer", doubleBuffer);
+ settings.get("depthbuffer", depthBuffer);
+ settings.get("stencilbuffer", stencilBuffer);
+
+ std::vector<int> accum;
+ settings.get("accumbuffers", accum);
+ if (accum.size() > 0) accumBuffer[0] = accum[0];
+ if (accum.size() > 1) accumBuffer[1] = accum[1];
+ if (accum.size() > 2) accumBuffer[2] = accum[2];
+ if (accum.size() > 3) accumBuffer[3] = accum[3];
+
+ settings.get("stereo", stereo);
+ settings.get("multiesamplebuffers", multisampleBuffers);
+ settings.get("multiesamplesamples", multisampleSamples);
+ settings.get("swapcontrol", swapControl);
+ settings.get("hardwareonly", hardwareOnly);
+
+ if (!settings.get("caption", caption))
+ {
+ caption = "Untitled";
+ }
+ settings.get("icon", icon);
+
+ settings.get("fullscreen", fullscreen);
+ settings.get("resizable", resizable);
+ settings.get("showcursor", cursorVisible);
+ settings.get("grab", cursorGrab);
+
+ std::vector<int> dimensions;
+ settings.get("videomode", dimensions);
+ if (dimensions.size() > 1)
+ {
+ mode[0] = dimensions[0];
+ mode[1] = dimensions[1];
+ }
+ else if (fullscreen && Backend::isInitialized())
+ {
+ SDL_Rect** modes = SDL_ListModes(NULL,
+ SDL_FULLSCREEN | SDL_HWSURFACE);
+
+ if (modes == (SDL_Rect**)0)
+ {
+ Mf::logError("no native video mode");
+ }
+ else if (modes == (SDL_Rect**)-1)
+ {
+ Mf::logWarning("any resolution allowed; "
+ "choosing default 800x600");
+ mode[0] = 800;
+ mode[1] = 600;
+ }
+ else
+ {
+ mode[0] = (*modes)->w;
+ mode[1] = (*modes)->h;
+ Mf::logInfo << "choosing native resolution "
+ << mode[0] << "x" << mode[1] << std::endl;
+ }
+ }
+ if (dimensions.size() > 2) mode[2] = dimensions[2];
+}
+
+void Video::Attributes::init()
+{
+ // set some sane GL and window defaults (see SDL_video.c:217)