VTK  9.0.20201128
vtkSDL2OpenGLRenderWindow.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Visualization Toolkit
4 Module: vtkSDL2OpenGL2RenderWindow.h
5 
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
24 #ifndef vtkSDL2OpenGLRenderWindow_h
25 #define vtkSDL2OpenGLRenderWindow_h
26 
27 #include "vtkOpenGLRenderWindow.h"
28 #include "vtkRenderingOpenGL2Module.h" // For export macro
29 #include <SDL2/SDL.h> // for ivars
30 #include <stack> // for ivar
31 
32 class VTKRENDERINGOPENGL2_EXPORT vtkSDL2OpenGLRenderWindow : public vtkOpenGLRenderWindow
33 {
34 public:
37  void PrintSelf(ostream& os, vtkIndent indent) override;
38 
45  void Initialize(void) override;
46 
52  void Finalize(void) override;
53 
57  void SetFullScreen(vtkTypeBool) override;
58 
62  void SetShowWindow(bool val) override;
63 
65 
68  void SetSize(int, int) override;
69  void SetSize(int a[2]) override { vtkOpenGLRenderWindow::SetSize(a); }
71 
75  int* GetSize() VTK_SIZEHINT(2) override;
76 
78 
81  void SetPosition(int, int) override;
82  void SetPosition(int a[2]) override { vtkOpenGLRenderWindow::SetPosition(a); }
84 
88  int* GetScreenSize() VTK_SIZEHINT(2) override;
89 
93  int* GetPosition() VTK_SIZEHINT(2) override;
94 
99  void SetWindowName(const char*) override;
100 
101  void* GetGenericDisplayId() override { return (void*)this->ContextId; }
102  void* GetGenericWindowId() override { return (void*)this->WindowId; }
103  void* GetGenericDrawable() override { return (void*)this->WindowId; }
104 
108  void MakeCurrent() override;
109 
113  bool IsCurrent() override;
114 
118  void Clean();
119 
124  void Frame() override;
125 
127 
134  void PushContext() override;
135  void PopContext() override;
137 
147  bool SetSwapControl(int i) override;
148 
153  int GetColorBufferSizes(int* rgba) override;
154 
156 
160  void HideCursor() override;
161  void ShowCursor() override;
163 
164 protected:
166  ~vtkSDL2OpenGLRenderWindow() override;
167 
168  SDL_Window* WindowId;
169  SDL_GLContext ContextId;
170  std::stack<SDL_GLContext> ContextStack;
171  std::stack<SDL_Window*> WindowStack;
172  int ScreenSize[2];
174 
175  void CleanUpRenderers();
176  void CreateAWindow() override;
177  void DestroyWindow() override;
178 
179 private:
181  void operator=(const vtkSDL2OpenGLRenderWindow&) = delete;
182 };
183 
184 #endif
vtkOpenGLRenderWindow::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkOpenGLRenderWindow::GetColorBufferSizes
int GetColorBufferSizes(int *rgba) override
Get the size of the color buffer.
vtkSDL2OpenGLRenderWindow::GetGenericWindowId
void * GetGenericWindowId() override
Definition: vtkSDL2OpenGLRenderWindow.h:102
vtkOpenGLRenderWindow::SetSwapControl
virtual bool SetSwapControl(int)
Set the number of vertical syncs required between frames.
Definition: vtkOpenGLRenderWindow.h:356
vtkWindow::SetPosition
virtual void SetPosition(int x, int y)
Set the position (x and y) of the rendering window in screen coordinates (in pixels).
vtkWindow::GetSize
virtual int * GetSize()
Get the size (width and height) of the rendering window in screen coordinates (in pixels).
vtkSDL2OpenGLRenderWindow::WindowId
SDL_Window * WindowId
Definition: vtkSDL2OpenGLRenderWindow.h:168
vtkSDL2OpenGLRenderWindow::ContextId
SDL_GLContext ContextId
Definition: vtkSDL2OpenGLRenderWindow.h:169
vtkSDL2OpenGLRenderWindow::SetSize
void SetSize(int a[2]) override
Definition: vtkSDL2OpenGLRenderWindow.h:69
vtkOpenGLRenderWindow::PopContext
virtual void PopContext()
Definition: vtkOpenGLRenderWindow.h:339
vtkRenderWindow::ShowCursor
virtual void ShowCursor()
Definition: vtkRenderWindow.h:213
vtkRenderWindow::HideCursor
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...
Definition: vtkRenderWindow.h:212
vtkWindow::SetSize
virtual void SetSize(int width, int height)
Set the size (width and height) of the rendering window in screen coordinates (in pixels).
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkRenderWindow::Finalize
virtual void Finalize()
Finalize the rendering process.
Definition: vtkRenderWindow.h:178
vtkRenderWindow::MakeCurrent
void MakeCurrent() override
Attempt to make this window the current graphics context for the calling thread.
Definition: vtkRenderWindow.h:666
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkWindow::GetScreenSize
virtual int * GetScreenSize()
Get the current size of the screen in pixels.
Definition: vtkWindow.h:105
vtkSDL2OpenGLRenderWindow::ContextStack
std::stack< SDL_GLContext > ContextStack
Definition: vtkSDL2OpenGLRenderWindow.h:170
vtkX3D::string
Definition: vtkX3D.h:496
vtkSDL2OpenGLRenderWindow
Definition: vtkSDL2OpenGLRenderWindow.h:32
vtkOpenGLRenderWindow::Frame
void Frame() override
A termination method performed at the end of the rendering process to do things like swapping buffers...
vtkSDL2OpenGLRenderWindow::GetGenericDrawable
void * GetGenericDrawable() override
Definition: vtkSDL2OpenGLRenderWindow.h:103
vtkRenderWindow::SetFullScreen
virtual void SetFullScreen(vtkTypeBool)
Turn on/off rendering full screen window size.
Definition: vtkRenderWindow.h:238
vtkOpenGLRenderWindow::DestroyWindow
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
vtkWindow::SetShowWindow
virtual void SetShowWindow(bool)
vtkSDL2OpenGLRenderWindow::DEFAULT_BASE_WINDOW_NAME
static const std::string DEFAULT_BASE_WINDOW_NAME
Definition: vtkSDL2OpenGLRenderWindow.h:173
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:53
vtkRenderWindow::IsCurrent
virtual bool IsCurrent()
Tells if this window is the current graphics context for the calling thread.
Definition: vtkRenderWindow.h:672
vtkRenderWindow::New
static vtkRenderWindow * New()
Construct an instance of vtkRenderWindow with its screen size set to 300x300, borders turned on,...
vtkOpenGLRenderWindow::PushContext
virtual void PushContext()
Ability to push and pop this window's context as the current context.
Definition: vtkOpenGLRenderWindow.h:338
vtkSDL2OpenGLRenderWindow::WindowStack
std::stack< SDL_Window * > WindowStack
Definition: vtkSDL2OpenGLRenderWindow.h:171
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkOpenGLRenderWindow::Initialize
virtual void Initialize(void)
Initialize the rendering window.
Definition: vtkOpenGLRenderWindow.h:307
vtkOpenGLRenderWindow::CreateAWindow
virtual void CreateAWindow()=0
Create a not-off-screen window.
vtkOpenGLRenderWindow.h