#include <SDL/SDL_image.h>
#include "Dispatcher.hh"
-#include "Serializable.hh"
+#include "Log.hh"
#include "Settings.hh"
#include "Video.hh"
SDL_FreeSurface(context_);
context_ = 0;
setVideoMode(attribs_.mode);
- Mf::Dispatcher::getInstance().dispatch("video.context_recreated");
}
void Video::setOpenGLAttributes()
attribs_.mode[0] = mode[0];
attribs_.mode[1] = mode[1];
attribs_.mode[2] = mode[2];
+
+#if defined(_WIN32) || defined (_WIN64) || defined(__WIN32__)
+ // on win32, creating a new context via SDL_SetVideoMode will wipe
+ // out the GL state, so we gotta notify everyone to reload their
+ // state after the change
+ Mf::dispatcher::dispatch("video.context_recreated");
+ logInfo("video context recreated");
+#endif
}
- else throw Exception(SDL_GetError());
+ else throw Exception(Exception::SDL_ERROR);
}
}
}
+int Video::getWidth() const
+{
+ return context_->w;
+}
+
+int Video::getHeight() const
+{
+ return context_->h;
+}
+
+
Video::Attributes::Attributes()
{
// Set some sane GL and window defaults (see SDL_video.c:217)
Settings& settings = Settings::getInstance();
- std::vector<SerializablePtr> colors;
- settings.get("video.colorbuffers", colors);
- if (colors.size() > 0) colors[0]->get(colorBuffer[0]);
- if (colors.size() > 1) colors[1]->get(colorBuffer[1]);
- if (colors.size() > 2) colors[2]->get(colorBuffer[2]);
- if (colors.size() > 3) colors[3]->get(colorBuffer[3]);
-
- settings.get("video.framebuffer", frameBuffer);
- settings.get("video.doublebuffer", doubleBuffer);
- settings.get("video.depthbuffer", depthBuffer);
- settings.get("video.stencilbuffer", stencilBuffer);
-
- std::vector<SerializablePtr> accum;
- settings.get("video.accumbuffers", accum);
- if (accum.size() > 0) accum[0]->get(accumBuffer[0]);
- if (accum.size() > 1) accum[1]->get(accumBuffer[1]);
- if (accum.size() > 2) accum[2]->get(accumBuffer[2]);
- if (accum.size() > 3) accum[3]->get(accumBuffer[3]);
-
- settings.get("video.stereo", stereo);
- settings.get("video.multiesamplebuffers", multisampleBuffers);
- settings.get("video.multiesamplesamples", multisampleSamples);
- settings.get("video.swapcontrol", swapControl);
- settings.get("video.hardwareonly", hardwareonly);
-
- if (!settings.get("video.caption", caption))
+ std::vector<long> 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<long> 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("video.icon", icon);
-
- std::vector<SerializablePtr> dimensions;
- settings.get("video.mode", dimensions);
- if (dimensions.size() > 0) dimensions[0]->get(mode[0]);
- if (dimensions.size() > 1) dimensions[1]->get(mode[1]);
- if (dimensions.size() > 2) dimensions[2]->get(mode[2]);
-
- settings.get("video.fullscreen", fullscreen);
- settings.get("video.resizable", resizable);
- settings.get("video.showcursor", cursorVisible);
- settings.get("input.grab", cursorGrab);
+ settings.get("icon", icon);
+
+ std::vector<long> dimensions;
+ settings.get("videomode", dimensions);
+ if (dimensions.size() > 1)
+ {
+ mode[0] = dimensions[0];
+ mode[1] = dimensions[1];
+ }
+ if (dimensions.size() > 2) mode[2] = dimensions[2];
+
+ settings.get("fullscreen", fullscreen);
+ settings.get("resizable", resizable);
+ settings.get("showcursor", cursorVisible);
+ settings.get("grab", cursorGrab);
}