VTK  9.3.0
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:
176 
177  SDL_Window* WindowId;
178  SDL_GLContext ContextId;
179  std::stack<SDL_GLContext> ContextStack;
180  std::stack<SDL_Window*> WindowStack;
182 
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
a simple class to control print indentation
Definition: vtkIndent.h:29
OpenGL rendering window.
void Frame() override
A termination method performed at the end of the rendering process to do things like swapping buffers...
void Finalize() override
Finalize the rendering window.
void MakeCurrent() override
Make this windows OpenGL context the current context.
void SetFullScreen(vtkTypeBool) override
Change the window to fill the entire screen.
void DestroyWindow() override
Destroy a not-off-screen window.
static const std::string DEFAULT_BASE_WINDOW_NAME
void PushContext() override
Ability to push and pop this window's context as the current context.
int * GetSize() override
Get the current size of the window in pixels.
void PopContext() override
Ability to push and pop this window's context as the current context.
void SetShowWindow(bool val) override
Show or not Show the window.
bool IsCurrent() override
Tells if this window is the current OpenGL context for the calling thread.
std::stack< SDL_Window * > WindowStack
void * GetGenericDrawable() override
Dummy stubs for vtkWindow API.
void SetSize(int a[2]) override
Set the size of the window in pixels.
void SetSize(int, int) override
Set the size of the window in pixels.
void ShowCursor() override
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
void Clean()
Clean up device contexts, rendering contexts, etc.
static vtkSDL2OpenGLRenderWindow * New()
void HideCursor() override
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
void ReleaseCurrent() override
Release the current context.
~vtkSDL2OpenGLRenderWindow() override
int * GetScreenSize() override
Get the current size of the screen in pixels.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Initialize() override
Initialize the rendering window.
std::stack< SDL_GLContext > ContextStack
void CreateAWindow() override
Create a not-off-screen window.
bool SetSwapControl(int i) override
Set the number of vertical syncs required between frames.
int GetColorBufferSizes(int *rgba) override
Get the size of the color buffer.
virtual void SetPosition(int x, int y)
Set the position (x and y) of the rendering window in screen coordinates (in pixels).
virtual void SetSize(int width, int height)
Set the size (width and height) of the rendering window in screen coordinates (in pixels).
@ string
Definition: vtkX3D.h:490
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_SIZEHINT(...)