VTK  9.3.20240424
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#include "vtkRenderingOpenGL2Module.h" // For export macro
20#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
21// Ignore reserved-identifier warnings from
22// 1. SDL2/SDL_stdinc.h: warning: identifier '_SDL_size_mul_overflow_builtin'
23// 2. SDL2/SDL_stdinc.h: warning: identifier '_SDL_size_add_overflow_builtin'
24// 3. SDL2/SDL_audio.h: warning: identifier '_SDL_AudioStream'
25// 4. SDL2/SDL_joystick.h: warning: identifier '_SDL_Joystick'
26// 5. SDL2/SDL_sensor.h: warning: identifier '_SDL_Sensor'
27// 6. SDL2/SDL_gamecontroller.h: warning: identifier '_SDL_GameController'
28// 7. SDL2/SDL_haptic.h: warning: identifier '_SDL_Haptic'
29#ifdef __clang__
30#pragma clang diagnostic push
31#pragma clang diagnostic ignored "-Wreserved-identifier"
32#endif
33#include "SDL.h" // for ivar
34#ifdef __clang__
35#pragma clang diagnostic pop
36#endif
37#include <stack> // for ivar
38
39VTK_ABI_NAMESPACE_BEGIN
40class VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkSDL2OpenGLRenderWindow
42{
43public:
46 void PrintSelf(ostream& os, vtkIndent indent) override;
47
54 void Initialize() override;
55
61 void Finalize() override;
62
66 void SetFullScreen(vtkTypeBool) override;
67
71 void SetShowWindow(bool val) override;
72
74
77 void SetSize(int, int) override;
78 void SetSize(int a[2]) override { vtkOpenGLRenderWindow::SetSize(a); }
80
84 int* GetSize() VTK_SIZEHINT(2) override;
85
87
90 void SetPosition(int, int) override;
91 void SetPosition(int a[2]) override { vtkOpenGLRenderWindow::SetPosition(a); }
93
97 int* GetScreenSize() VTK_SIZEHINT(2) override;
98
102 int* GetPosition() VTK_SIZEHINT(2) override;
103
108 void SetWindowName(const char*) override;
109
110 void* GetGenericDisplayId() override { return (void*)this->ContextId; }
111 void* GetGenericWindowId() override { return (void*)this->WindowId; }
112 void* GetGenericDrawable() override { return (void*)this->WindowId; }
113
117 void MakeCurrent() override;
118
122 void ReleaseCurrent() override;
123
127 bool IsCurrent() override;
128
132 void Clean();
133
138 void Frame() override;
139
141
148 void PushContext() override;
149 void PopContext() override;
151
161 bool SetSwapControl(int i) override;
162
167 int GetColorBufferSizes(int* rgba) override;
168
170
174 void HideCursor() override;
175 void ShowCursor() override;
177
178protected:
181
182 SDL_Window* WindowId;
183 SDL_GLContext ContextId;
184 std::stack<SDL_GLContext> ContextStack;
185 std::stack<SDL_Window*> WindowStack;
186 static const std::string DEFAULT_BASE_WINDOW_NAME;
187
189 void CreateAWindow() override;
190 void DestroyWindow() override;
191
192private:
194 void operator=(const vtkSDL2OpenGLRenderWindow&) = delete;
195};
196
197VTK_ABI_NAMESPACE_END
198#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_SIZEHINT(...)
#define VTK_MARSHALAUTO