emu_window_sdl2.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2016 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <memory>
  6. #include <utility>
  7. #include "core/frontend/emu_window.h"
  8. struct SDL_Window;
  9. class EmuWindow_SDL2 : public Core::Frontend::EmuWindow {
  10. public:
  11. explicit EmuWindow_SDL2(bool fullscreen);
  12. ~EmuWindow_SDL2();
  13. /// Swap buffers to display the next frame
  14. void SwapBuffers() override;
  15. /// Polls window events
  16. void PollEvents() override;
  17. /// Makes the graphics context current for the caller thread
  18. void MakeCurrent() override;
  19. /// Releases the GL context from the caller thread
  20. void DoneCurrent() override;
  21. /// Whether the window is still open, and a close request hasn't yet been sent
  22. bool IsOpen() const;
  23. private:
  24. /// Called by PollEvents when a key is pressed or released.
  25. void OnKeyEvent(int key, u8 state);
  26. /// Called by PollEvents when the mouse moves.
  27. void OnMouseMotion(s32 x, s32 y);
  28. /// Called by PollEvents when a mouse button is pressed or released
  29. void OnMouseButton(u32 button, u8 state, s32 x, s32 y);
  30. /// Called by PollEvents when any event that may cause the window to be resized occurs
  31. void OnResize();
  32. /// Called when user passes the fullscreen parameter flag
  33. void Fullscreen();
  34. /// Whether the GPU and driver supports the OpenGL extension required
  35. bool SupportsRequiredGLExtensions();
  36. /// Called when a configuration change affects the minimal size of the window
  37. void OnMinimalClientAreaChangeRequest(
  38. const std::pair<unsigned, unsigned>& minimal_size) override;
  39. /// Is the window still open?
  40. bool is_open = true;
  41. /// Internal SDL2 render window
  42. SDL_Window* render_window;
  43. using SDL_GLContext = void*;
  44. /// The OpenGL context associated with the window
  45. SDL_GLContext gl_context;
  46. };