Introducing windowed fullscreen. Closes #9.

This commit is contained in:
Faerbit 2015-03-15 17:48:46 +01:00
parent 36173438cc
commit 40da86aad6
5 changed files with 36 additions and 6 deletions

View File

@ -3,6 +3,8 @@
<height>786</height>
</resolution>
<windowedFullscreen>true</windowedFullscreen>
<shadowCubeSize>1024</shadowCubeSize>
<farPlane>150.0</farPlane>

View File

@ -145,3 +145,11 @@ void Application::startGame() {
bool Application::isGameStarted() {
return gameStarted;
}
void Application::setFullscreen(bool state) {
this->fullscreen = state;
}
bool Application::makeFullscreen() {
return fullscreen;
}

View File

@ -35,7 +35,10 @@ class Application {
void setLoadingScreenContinuePath(std::string path);
bool isGameStarted();
void startGame();
void setFullscreen(bool state);
bool makeFullscreen();
private:
bool fullscreen;
bool gameStarted;
int ignoredMouseUpdates;
bool focused;

View File

@ -17,6 +17,7 @@ void Loader::loadConfig(Application* application) {
application->setWindowWidth(queryInt(resolution, "width"));
application->setWindowHeight(queryInt(resolution, "height"));
application->setFullscreen(queryBool(config, "windowedFullscreen"));
application->setShadowCubeSize(queryInt(config, "shadowCubeSize"));
application->setFarPlane(queryFloat(config, "farPlane"));
application->setMaxShadowRenderCount(queryInt(config, "maxShadowRenderCount"));

View File

@ -112,13 +112,29 @@ bool createWindow()
// define whether the window can get resized:
glfwWindowHint(GLFW_RESIZABLE, true);
// try to create an OpenGL context in a window and check the supported OpenGL version:
// R,G,B,A, Depth,Stencil
window = glfwCreateWindow(app.getGraphics()->getWindowSize().x, app.getGraphics()->getWindowSize().y, "SWP MarbleGame Group C", NULL, NULL);
if(app.makeFullscreen()) {
const GLFWvidmode* mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
glfwWindowHint(GLFW_RED_BITS, mode->redBits);
glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
window = glfwCreateWindow(mode->width, mode->height, "Saxum", glfwGetPrimaryMonitor(), NULL);
if (!window) {
ACGL::Utils::error() << "Failed to open a GLFW window - requested OpenGL: " << ACGL_OPENGL_VERSION << std::endl;
return false;
}
}
else {
// try to create an OpenGL context in a window and check the supported OpenGL version:
// R,G,B,A, Depth,Stencil
window = glfwCreateWindow(app.getGraphics()->getWindowSize().x, app.getGraphics()->getWindowSize().y, "Saxum", NULL, NULL);
if (!window) {
ACGL::Utils::error() << "Failed to open a GLFW window - requested OpenGL: " << ACGL_OPENGL_VERSION << std::endl;
return false;
}
}
glfwMakeContextCurrent(window);
#ifdef SAXUM_DEBUG
ACGL::init(true);