VTK  9.7.20260818
vtkEGLRenderWindowInternals.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
3
4#ifndef vtkEGLRenderWindowInternals_h
5#define vtkEGLRenderWindowInternals_h
6
8#include "vtkOpenGLRenderer.h"
9
10#include "vtk_glad.h" // OpenGL functions
11#include "vtkglad/include/glad/egl.h"
12
13VTK_ABI_NAMESPACE_BEGIN
14
15class vtkRecti;
17
23class VTKRENDERINGOPENGL2_EXPORT vtkEGLRenderWindowInternals
24{
25public:
29 [[nodiscard]] EGLDisplay GetDisplay() const { return this->Display; }
30
34 [[nodiscard]] EGLDisplay GetSurface() const { return this->Surface; }
35
37
40 [[nodiscard]] EGLContext GetContext() const { return this->Context; }
41 void SetContext(EGLContext context) { this->Context = context; }
43
47 void SetWindow(EGLNativeWindowType window) { this->Window = window; }
48
52 [[nodiscard]] int GetNumberOfDevices();
53
58 [[nodiscard]] bool SetDeviceAsDisplay(int deviceIndex);
59
64
69 void ConfigureWindow(int width, int height);
70
74 void SetDeviceIndex(int deviceIndex) { this->DeviceIndex = deviceIndex; };
75
80 void SetUseOnscreenRendering(bool useOnscreenRendering);
81
85 void GetSizeFromSurface(int* size);
86
91
97
100
106
107private:
112 bool TryInitializeMesaSoftware(EGLint& major, EGLint& minor);
113
117 bool TryInitializeHardware(int deviceIndex, EGLint& major, EGLint& minor);
118
122 bool FinalizeDisplaySetup(EGLint major, EGLint minor);
123
128 void InitializeOffscreenFramebuffer();
129
134 void DestroyOffscreenFramebuffer();
135
136 EGLNativeWindowType Window;
137 EGLDisplay Display;
138 EGLSurface Surface;
139 EGLContext Context;
140
141 int DeviceIndex = -1;
142 bool UseOnscreenRendering = false;
143
144 std::unique_ptr<vtkEGLConfig> Config;
145
146 unsigned int Height = 0;
147 unsigned int Width = 0;
148
149 unsigned int SurfacelessFBO = 0;
150 unsigned int ColorTexture = 0;
151 unsigned int DepthBuffer = 0;
152};
153
154VTK_ABI_NAMESPACE_END
155#endif
bool IsMesaSoftwareRenderer() const
Return true if the current build is using Mesa software rendering backend.
EGLDisplay GetDisplay() const
Return the EGLDisplay.
bool SetDeviceAsDisplay(int deviceIndex)
Set the wanted device for display if the device is available.
EGLDisplay GetSurface() const
Return the EGLSurface.
void SetUseOnscreenRendering(bool useOnscreenRendering)
Setter to handle onscreen rendering.
void ConfigureWindow(int width, int height)
Configure the current EGLWindow with the requested size.
~vtkEGLRenderWindowInternals()=default
bool MakeCurrent()
Try to attach the EGL rendering context to the EGL surface.
void SetContext(EGLContext context)
Get/Set the EGLContext.
EGLContext GetContext() const
Get/Set the EGLContext.
void SetDeviceIndex(int deviceIndex)
Setter used to store the device expected by the user.
void ReleaseCurrent()
Release the EGL state.
int GetNumberOfDevices()
Get the number of devices (graphic cards) from the system.
void SetWindow(EGLNativeWindowType window)
Set the EGLWindow.
void GetSizeFromSurface(int *size)
Get the current size of the EGLSurface.
void DestroyWindow()
Release EGL window.
an ordered list of renderers