VTK  9.3.1
vtkSDL2OpenGLRenderWindow.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
12 #ifndef vtkSDL2OpenGLRenderWindow_h
13 #define vtkSDL2OpenGLRenderWindow_h
14 
15 #include "vtkOpenGLRenderWindow.h"
16 #include "vtkRenderingOpenGL2Module.h" // For export macro
17 // Ignore reserved-identifier warnings from
18 // 1. SDL2/SDL_stdinc.h: warning: identifier '_SDL_size_mul_overflow_builtin'
19 // 2. SDL2/SDL_stdinc.h: warning: identifier '_SDL_size_add_overflow_builtin'
20 // 3. SDL2/SDL_audio.h: warning: identifier '_SDL_AudioStream'
21 // 4. SDL2/SDL_joystick.h: warning: identifier '_SDL_Joystick'
22 // 5. SDL2/SDL_sensor.h: warning: identifier '_SDL_Sensor'
23 // 6. SDL2/SDL_gamecontroller.h: warning: identifier '_SDL_GameController'
24 // 7. SDL2/SDL_haptic.h: warning: identifier '_SDL_Haptic'
25 #ifdef __clang__
26 #pragma clang diagnostic push
27 #pragma clang diagnostic ignored "-Wreserved-identifier"
28 #endif
29 #include "SDL.h" // for ivar
30 #ifdef __clang__
31 #pragma clang diagnostic pop
32 #endif
33 #include <stack> // for ivar
34 
35 VTK_ABI_NAMESPACE_BEGIN
36 class VTKRENDERINGOPENGL2_EXPORT vtkSDL2OpenGLRenderWindow : public vtkOpenGLRenderWindow
37 {
38 public:
41  void PrintSelf(ostream& os, vtkIndent indent) override;
42 
49  void Initialize() override;
50 
56  void Finalize() override;
57 
61  void SetFullScreen(vtkTypeBool) override;
62 
66  void SetShowWindow(bool val) override;
67 
69 
72  void SetSize(int, int) override;
73  void SetSize(int a[2]) override { vtkOpenGLRenderWindow::SetSize(a); }
75 
79  int* GetSize() VTK_SIZEHINT(2) override;
80 
82 
85  void SetPosition(int, int) override;
86  void SetPosition(int a[2]) override { vtkOpenGLRenderWindow::SetPosition(a); }
88 
92  int* GetScreenSize() VTK_SIZEHINT(2) override;
93 
97  int* GetPosition() VTK_SIZEHINT(2) override;
98 
103  void SetWindowName(const char*) override;
104 
105  void* GetGenericDisplayId() override { return (void*)this->ContextId; }
106  void* GetGenericWindowId() override { return (void*)this->WindowId; }
107  void* GetGenericDrawable() override { return (void*)this->WindowId; }
108 
112  void MakeCurrent() override;
113 
117  void ReleaseCurrent() override;
118 
122  bool IsCurrent() override;
123 
127  void Clean();
128 
133  void Frame() override;
134 
136 
143  void PushContext() override;
144  void PopContext() override;
146 
156  bool SetSwapControl(int i) override;
157 
162  int GetColorBufferSizes(int* rgba) override;
163 
165 
169  void HideCursor() override;
170  void ShowCursor() override;
172 
173 protected:
175  ~vtkSDL2OpenGLRenderWindow() override;
176 
177  SDL_Window* WindowId;
178  SDL_GLContext ContextId;
179  std::stack<SDL_GLContext> ContextStack;
180  std::stack<SDL_Window*> WindowStack;
182 
183  void CleanUpRenderers();
184  void CreateAWindow() override;
185  void DestroyWindow() override;
186 
187 private:
189  void operator=(const vtkSDL2OpenGLRenderWindow&) = delete;
190 };
191 
192 VTK_ABI_NAMESPACE_END
193 #endif
OpenGL rendering window.
virtual void SetFullScreen(vtkTypeBool)
Turn on/off rendering full screen window size.
virtual void HideCursor()
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
std::stack< SDL_Window * > WindowStack
void SetSize(int a[2]) override
Set the size of the window in pixels.
static vtkRenderWindow * New()
Construct an instance of vtkRenderWindow with its screen size set to 300x300, borders turned on...
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
virtual void SetPosition(int x, int y)
Set the position (x and y) of the rendering window in screen coordinates (in pixels).
virtual bool IsCurrent()
Tells if this window is the current graphics context for the calling thread.
static const std::string DEFAULT_BASE_WINDOW_NAME
virtual void Finalize()
Finalize the rendering process.
virtual void SetShowWindow(bool)
Show or not Show the window.
int vtkTypeBool
Definition: vtkABI.h:64
virtual void SetSize(int width, int height)
Set the size (width and height) of the rendering window in screen coordinates (in pixels)...
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
virtual void ShowCursor()
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
virtual int * GetScreenSize()
Get the current size of the screen in pixels.
Definition: vtkWindow.h:94
std::stack< SDL_GLContext > ContextStack
virtual void Initialize()
Initialize the rendering window.
int GetColorBufferSizes(int *rgba) override
Get the size of the color buffer.
virtual void MakeCurrent()
Make the window current.
Definition: vtkWindow.h:235
virtual void PushContext()
Ability to push and pop this window's context as the current context.
#define VTK_SIZEHINT(...)
virtual bool SetSwapControl(int)
Set the number of vertical syncs required between frames.
void Frame() override
A termination method performed at the end of the rendering process to do things like swapping buffers...
void * GetGenericDrawable() override
Dummy stubs for vtkWindow API.
virtual int * GetSize()
Get the size (width and height) of the rendering window in screen coordinates (in pixels)...
virtual void ReleaseCurrent()
Release the current context.
Definition: vtkWindow.h:241
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void CreateAWindow()=0
Create a not-off-screen window.