VTK  9.5.2
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
11
12#ifndef vtkSDL2OpenGLRenderWindow_h
13#define vtkSDL2OpenGLRenderWindow_h
14
16
17#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_4_0
18#include "vtkRenderingOpenGL2Module.h" // For export macro
19#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
20// Ignore reserved-identifier warnings from
21// 1. SDL2/SDL_stdinc.h: warning: identifier '_SDL_size_mul_overflow_builtin'
22// 2. SDL2/SDL_stdinc.h: warning: identifier '_SDL_size_add_overflow_builtin'
23// 3. SDL2/SDL_audio.h: warning: identifier '_SDL_AudioStream'
24// 4. SDL2/SDL_joystick.h: warning: identifier '_SDL_Joystick'
25// 5. SDL2/SDL_sensor.h: warning: identifier '_SDL_Sensor'
26// 6. SDL2/SDL_gamecontroller.h: warning: identifier '_SDL_GameController'
27// 7. SDL2/SDL_haptic.h: warning: identifier '_SDL_Haptic'
28#ifdef __clang__
29#pragma clang diagnostic push
30#pragma clang diagnostic ignored "-Wreserved-identifier"
31#endif
32#include "SDL.h" // for ivar
33#ifdef __clang__
34#pragma clang diagnostic pop
35#endif
36#include <stack> // for ivar
37
38VTK_ABI_NAMESPACE_BEGIN
40 "Please use one of the dedicated platform render window or "
41 "vtkWebAssemblyOpenGLRenderWindow if your application targets WebAssembly.")
42 VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkSDL2OpenGLRenderWindow
44{
45public:
48 void PrintSelf(ostream& os, vtkIndent indent) override;
49
56 void Initialize() override;
57
63 void Finalize() override;
64
68 void SetFullScreen(vtkTypeBool) override;
69
73 void SetShowWindow(bool val) override;
74
76
79 void SetSize(int, int) override;
80 void SetSize(int a[2]) override { vtkOpenGLRenderWindow::SetSize(a); }
82
86 int* GetSize() VTK_SIZEHINT(2) override;
87
89
92 void SetPosition(int, int) override;
93 void SetPosition(int a[2]) override { vtkOpenGLRenderWindow::SetPosition(a); }
95
99 int* GetScreenSize() VTK_SIZEHINT(2) override;
100
104 int* GetPosition() VTK_SIZEHINT(2) override;
105
110 void SetWindowName(const char*) override;
111
112 void* GetGenericDisplayId() override { return (void*)this->ContextId; }
113 void* GetGenericWindowId() override { return (void*)this->WindowId; }
114 void* GetGenericDrawable() override { return (void*)this->WindowId; }
115
119 void MakeCurrent() override;
120
124 void ReleaseCurrent() override;
125
129 bool IsCurrent() override;
130
134 void Clean();
135
140 void Frame() override;
141
143
150 void PushContext() override;
151 void PopContext() override;
153
163 bool SetSwapControl(int i) override;
164
169 int GetColorBufferSizes(int* rgba) override;
170
172
176 void HideCursor() override;
177 void ShowCursor() override;
179
180protected:
183
184 SDL_Window* WindowId;
185 SDL_GLContext ContextId;
186 std::stack<SDL_GLContext> ContextStack;
187 std::stack<SDL_Window*> WindowStack;
188 static const std::string DEFAULT_BASE_WINDOW_NAME;
189
191 void CreateAWindow() override;
192 void DestroyWindow() override;
193
194private:
196 void operator=(const vtkSDL2OpenGLRenderWindow&) = delete;
197};
198
199VTK_ABI_NAMESPACE_END
200#endif
a simple class to control print indentation
Definition vtkIndent.h:29
void Frame() override
A termination method performed at the end of the rendering process to do things like swapping buffers...
void * GetGenericDisplayId() override
Dummy stubs for vtkWindow API.
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()
int * GetPosition() override
Get the position in screen coordinates of the window.
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 SetPosition(int, int) override
Set the position of the window.
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.
void SetWindowName(const char *) override
Set the name of the 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