diff --git a/main.cpp b/main.cpp index 71785db..918db64 100644 --- a/main.cpp +++ b/main.cpp @@ -202,6 +202,8 @@ int main (int argc, char* argv[]) // get the real framebuffer size glfwGetFramebufferSize (window, &windowWidth, &windowHeight); + // set the default viewport + context->setDefaultViewport ({0, 0, windowWidth, windowHeight}); if (glewInit () != GLEW_OK) { @@ -210,6 +212,7 @@ int main (int argc, char* argv[]) return 3; } + if (project->getType () == "scene") { WallpaperEngine::Core::CScene* scene = project->getWallpaper ()->as (); @@ -264,6 +267,10 @@ int main (int argc, char* argv[]) while (glfwWindowShouldClose (window) == 0) { + // get the real framebuffer size + glfwGetFramebufferSize (window, &windowWidth, &windowHeight); + // set the default viewport + context->setDefaultViewport ({0, 0, windowWidth, windowHeight}); // calculate the current time value g_Time = (float) glfwGetTime (); // get the start time of the frame diff --git a/src/WallpaperEngine/Render/CContext.cpp b/src/WallpaperEngine/Render/CContext.cpp index 74e393a..9aaadb4 100644 --- a/src/WallpaperEngine/Render/CContext.cpp +++ b/src/WallpaperEngine/Render/CContext.cpp @@ -13,7 +13,8 @@ CContext::CContext (std::vector screens) : m_wallpaper (nullptr), m_screens (std::move (screens)), m_isRootWindow (m_screens.empty () == false), - m_window (0) + m_window (0), + m_defaultViewport ({0, 0, 1920, 1080}) { this->initializeViewports (); } @@ -99,10 +100,15 @@ void CContext::render () } } else - this->m_wallpaper->render ({0, 0, 1920, 1080}); + this->m_wallpaper->render (this->m_defaultViewport); } void CContext::setWallpaper (CWallpaper* wallpaper) { this->m_wallpaper = wallpaper; +} + +void CContext::setDefaultViewport (glm::vec4 defaultViewport) +{ + this->m_defaultViewport = defaultViewport; } \ No newline at end of file diff --git a/src/WallpaperEngine/Render/CContext.h b/src/WallpaperEngine/Render/CContext.h index dd2c9c0..c63ad49 100644 --- a/src/WallpaperEngine/Render/CContext.h +++ b/src/WallpaperEngine/Render/CContext.h @@ -15,11 +15,13 @@ namespace WallpaperEngine::Render void initializeViewports (); void render (); void setWallpaper (CWallpaper* wallpaper); + void setDefaultViewport (glm::vec4 defaultViewport); private: Window m_window; std::vector m_screens; std::vector m_viewports; + glm::vec4 m_defaultViewport; CWallpaper* m_wallpaper; bool m_isRootWindow; }; diff --git a/src/WallpaperEngine/Render/CWallpaper.cpp b/src/WallpaperEngine/Render/CWallpaper.cpp index 95d3924..a120a18 100644 --- a/src/WallpaperEngine/Render/CWallpaper.cpp +++ b/src/WallpaperEngine/Render/CWallpaper.cpp @@ -205,7 +205,7 @@ void CWallpaper::render (glm::vec4 viewport, bool newFrame) GLfloat position [] = { widthRatio * -1.0f, heightRatio * 1.0f, 0.0f, - widthRatio * 1.0, heightRatio * 1.0f, 0.0f, + widthRatio * 1.0f, heightRatio * 1.0f, 0.0f, widthRatio * -1.0f, heightRatio * -1.0f, 0.0f, widthRatio * -1.0f, heightRatio * -1.0f, 0.0f, widthRatio * 1.0f, heightRatio * 1.0f, 0.0f,