GLFWWindowOutput.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "GLFWWindowOutput.h"
  2. #include "GLFWOutputViewport.h"
  3. #include "WallpaperEngine/Logging/Log.h"
  4. #include <GL/glew.h>
  5. #include <GLFW/glfw3.h>
  6. #include <unistd.h>
  7. using namespace WallpaperEngine::Render::Drivers::Output;
  8. GLFWWindowOutput::GLFWWindowOutput (ApplicationContext& context, VideoDriver& driver) : Output (context, driver) {
  9. if (this->m_context.settings.render.mode != Application::ApplicationContext::NORMAL_WINDOW
  10. && this->m_context.settings.render.mode != Application::ApplicationContext::EXPLICIT_WINDOW) {
  11. sLog.exception ("Initializing window output when not in output mode, how did you get here?!");
  12. }
  13. driver.showWindow ();
  14. if (this->m_context.settings.render.mode == Application::ApplicationContext::EXPLICIT_WINDOW) {
  15. this->m_fullWidth = this->m_context.settings.render.window.geometry.z;
  16. this->m_fullHeight = this->m_context.settings.render.window.geometry.w;
  17. this->repositionWindow ();
  18. } else {
  19. this->m_fullWidth = this->m_driver.getFramebufferSize ().x;
  20. this->m_fullHeight = this->m_driver.getFramebufferSize ().y;
  21. }
  22. this->m_viewports["default"]
  23. = new GLFWOutputViewport { { 0, 0, this->m_fullWidth, this->m_fullHeight }, "default" };
  24. }
  25. void GLFWWindowOutput::repositionWindow () const {
  26. this->m_driver.resizeWindow (this->m_context.settings.render.window.geometry);
  27. }
  28. void GLFWWindowOutput::reset () {
  29. if (this->m_context.settings.render.mode == Application::ApplicationContext::EXPLICIT_WINDOW) {
  30. this->repositionWindow ();
  31. }
  32. }
  33. bool GLFWWindowOutput::renderVFlip () const { return true; }
  34. bool GLFWWindowOutput::renderMultiple () const { return false; }
  35. bool GLFWWindowOutput::haveImageBuffer () const { return false; }
  36. void* GLFWWindowOutput::getImageBuffer () const { return nullptr; }
  37. uint32_t GLFWWindowOutput::getImageBufferSize () const { return 0; }
  38. void GLFWWindowOutput::updateRender () const {
  39. // re-read every frame so window resizes re-stretch the scene instead of cropping it
  40. this->m_fullWidth = this->m_driver.getFramebufferSize ().x;
  41. this->m_fullHeight = this->m_driver.getFramebufferSize ().y;
  42. this->m_viewports["default"]->viewport = { 0, 0, this->m_fullWidth, this->m_fullHeight };
  43. }