VTK  9.5.20250531
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
15#ifndef vtkSDL2OpenGLRenderWindow_h
16#define vtkSDL2OpenGLRenderWindow_h
17
19
20#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_4_0
21#include "vtkRenderingOpenGL2Module.h" // For export macro
22#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
23// Ignore reserved-identifier warnings from
24// 1. SDL2/SDL_stdinc.h: warning: identifier '_SDL_size_mul_overflow_builtin'
25// 2. SDL2/SDL_stdinc.h: warning: identifier '_SDL_size_add_overflow_builtin'
26// 3. SDL2/SDL_audio.h: warning: identifier '_SDL_AudioStream'
27// 4. SDL2/SDL_joystick.h: warning: identifier '_SDL_Joystick'
28// 5. SDL2/SDL_sensor.h: warning: identifier '_SDL_Sensor'
29// 6. SDL2/SDL_gamecontroller.h: warning: identifier '_SDL_GameController'
30// 7. SDL2/SDL_haptic.h: warning: identifier '_SDL_Haptic'
31#ifdef __clang__
32#pragma clang diagnostic push
33#pragma clang diagnostic ignored "-Wreserved-identifier"
34#endif
35#include "SDL.h" // for ivar
36#ifdef __clang__
37#pragma clang diagnostic pop
38#endif
39#include <stack> // for ivar
40
41VTK_ABI_NAMESPACE_BEGIN
43 "Please use one of the dedicated platform render window or "
44 "vtkWebAssemblyOpenGLRenderWindow if your application targets WebAssembly.")
45 VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkSDL2OpenGLRenderWindow
47{
48public:
51 void PrintSelf(ostream& os, vtkIndent indent) override;
52
59 void Initialize() override;
60
66 void Finalize() override;
67
71 void SetFullScreen(vtkTypeBool) override;
72
76 void SetShowWindow(bool val) override;
77
79
82 void SetSize(int, int) override;
83 void SetSize(int a[2]) override { vtkOpenGLRenderWindow::SetSize(a); }
85
89 int* GetSize() VTK_SIZEHINT(2) override;
90
92
95 void SetPosition(int, int) override;
96 void SetPosition(int a[2]) override { vtkOpenGLRenderWindow::SetPosition(a); }
98
102 int* GetScreenSize() VTK_SIZEHINT(2) override;
103
107 int* GetPosition() VTK_SIZEHINT(2) override;
108
113 void SetWindowName(const char*) override;
114
115 void* GetGenericDisplayId() override { return (void*)this->ContextId; }
116 void* GetGenericWindowId() override { return (void*)this->WindowId; }
117 void* GetGenericDrawable() override { return (void*)this->WindowId; }
118
122 void MakeCurrent() override;
123
127 void ReleaseCurrent() override;
128
132 bool IsCurrent() override;
133
137 void Clean();
138
143 void Frame() override;
144
146
153 void PushContext() override;
154 void PopContext() override;
156
166 bool SetSwapControl(int i) override;
167
172 int GetColorBufferSizes(int* rgba) override;
173
175
179 void HideCursor() override;
180 void ShowCursor() override;
182
183protected:
186
187 SDL_Window* WindowId;
188 SDL_GLContext ContextId;
189 std::stack<SDL_GLContext> ContextStack;
190 std::stack<SDL_Window*> WindowStack;
191 static const std::string DEFAULT_BASE_WINDOW_NAME;
192
194 void CreateAWindow() override;
195 void DestroyWindow() override;
196
197private:
199 void operator=(const vtkSDL2OpenGLRenderWindow&) = delete;
200};
201
202VTK_ABI_NAMESPACE_END
203#endif
a simple class to control print indentation
Definition vtkIndent.h:108
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.
int * GetScreenSize() override
Get the current size of the screen in pixels.
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.
void PopContext() override
Ability to push and pop this window's context as the current context.
void * GetGenericDrawable() override
Dummy stubs for vtkWindow API.
int * GetSize() override
Get the current size of the window in pixels.
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
static vtkSDL2OpenGLRenderWindow * New()
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.
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 ReleaseCurrent() override
Release the current context.
~vtkSDL2OpenGLRenderWindow() override
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 * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
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).
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DEPRECATED_IN_9_4_0(reason)
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO