GLFWWindowOutput.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. // window should be visible
  14. driver.showWindow ();
  15. if (this->m_context.settings.render.mode == Application::ApplicationContext::EXPLICIT_WINDOW) {
  16. this->m_fullWidth = this->m_context.settings.render.window.geometry.z;
  17. this->m_fullHeight = this->m_context.settings.render.window.geometry.w;
  18. this->repositionWindow ();
  19. } else {
  20. // take the size from the driver (default window size)
  21. this->m_fullWidth = this->m_driver.getFramebufferSize ().x;
  22. this->m_fullHeight = this->m_driver.getFramebufferSize ().y;
  23. }
  24. // register the default viewport
  25. this->m_viewports["default"]
  26. = new GLFWOutputViewport { { 0, 0, this->m_fullWidth, this->m_fullHeight }, "default" };
  27. }
  28. void GLFWWindowOutput::repositionWindow () const {
  29. // reposition the window
  30. this->m_driver.resizeWindow (this->m_context.settings.render.window.geometry);
  31. }
  32. void GLFWWindowOutput::reset () {
  33. if (this->m_context.settings.render.mode == Application::ApplicationContext::EXPLICIT_WINDOW) {
  34. this->repositionWindow ();
  35. }
  36. }
  37. bool GLFWWindowOutput::renderVFlip () const { return true; }
  38. bool GLFWWindowOutput::renderMultiple () const { return false; }
  39. bool GLFWWindowOutput::haveImageBuffer () const { return false; }
  40. void* GLFWWindowOutput::getImageBuffer () const { return nullptr; }
  41. uint32_t GLFWWindowOutput::getImageBufferSize () const { return 0; }
  42. void GLFWWindowOutput::updateRender () const {
  43. if (this->m_context.settings.render.mode != Application::ApplicationContext::NORMAL_WINDOW) {
  44. return;
  45. }
  46. // take the size from the driver (default window size)
  47. this->m_fullWidth = this->m_driver.getFramebufferSize ().x;
  48. this->m_fullHeight = this->m_driver.getFramebufferSize ().y;
  49. // update the default viewport
  50. this->m_viewports["default"]->viewport = { 0, 0, this->m_fullWidth, this->m_fullHeight };
  51. }