UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WindowsOpenGLPlatform.cpp File Reference
#include "WindowsOpenGLPlatform.h"
#include "Misc/ScopeLock.h"
#include "OpenGLDrvPrivate.h"
#include "OpenGLUtil.h"
#include "RHI.h"
#include "RHIUtilities.h"

Classes

struct  FPlatformOpenGLContext
 
class  FScopeContext
 
struct  FPlatformOpenGLDevice
 

Macros

#define GET_GL_ENTRYPOINTS_DLL(Type, Func)   Func = (Type)FPlatformProcess::GetDllExport(OpenGLDLL,TEXT(#Func));
 
#define GET_GL_ENTRYPOINTS(Type, Func)   Func = (Type)wglGetProcAddress(#Func);
 
#define CHECK_GL_ENTRYPOINTS(Type, Func)   if (Func == NULL) { bFoundAllEntryPoints = false; UE_LOG(LogRHI, Warning, TEXT("Failed to find entry point for %s"), TEXT(#Func)); }
 

Functions

void PlatformReleaseOpenGLContext (FPlatformOpenGLDevice *Device, FPlatformOpenGLContext *Context)
 
FPlatformOpenGLDevicePlatformCreateOpenGLDevice ()
 
bool PlatformCanEnableGPUCapture ()
 
void PlatformDestroyOpenGLDevice (FPlatformOpenGLDevice *Device)
 
FPlatformOpenGLContextPlatformCreateOpenGLContext (FPlatformOpenGLDevice *Device, void *InWindowHandle)
 
void PlatformDestroyOpenGLContext (FPlatformOpenGLDevice *Device, FPlatformOpenGLContext *Context)
 
bool PlatformBlitToViewport (IRHICommandContext &RHICmdContext, FPlatformOpenGLDevice *Device, const FOpenGLViewport &Viewport, uint32 BackbufferSizeX, uint32 BackbufferSizeY, bool bPresent, bool bLockToVsync)
 
void PlatformFlushIfNeeded ()
 
void PlatformRenderingContextSetup (FPlatformOpenGLDevice *Device)
 
void PlatformNULLContextSetup ()
 
void PlatformResizeGLContext (FPlatformOpenGLDevice *Device, FPlatformOpenGLContext *Context, uint32 SizeX, uint32 SizeY, bool bFullscreen, bool bWasFullscreen, GLenum BackBufferTarget, GLuint BackBufferResource)
 
void PlatformGetSupportedResolution (uint32 &Width, uint32 &Height)
 
bool PlatformGetAvailableResolutions (FScreenResolutionArray &Resolutions, bool bIgnoreRefreshRate)
 
void PlatformRestoreDesktopDisplayMode ()
 
bool PlatformInitOpenGL ()
 
int32 PlatformGlGetError ()
 
bool PlatformOpenGLThreadHasRenderingContext ()
 
FOpenGLTexturePlatformCreateBuiltinBackBuffer (FOpenGLDynamicRHI *OpenGLRHI, uint32 SizeX, uint32 SizeY)
 
voidPlatformGetWindow (FPlatformOpenGLContext *Context, void **AddParam)
 

Variables

bool GRunningUnderRenderDoc = false
 

Macro Definition Documentation

◆ CHECK_GL_ENTRYPOINTS

#define CHECK_GL_ENTRYPOINTS (   Type,
  Func 
)    if (Func == NULL) { bFoundAllEntryPoints = false; UE_LOG(LogRHI, Warning, TEXT("Failed to find entry point for %s"), TEXT(#Func)); }

◆ GET_GL_ENTRYPOINTS

#define GET_GL_ENTRYPOINTS (   Type,
  Func 
)    Func = (Type)wglGetProcAddress(#Func);

◆ GET_GL_ENTRYPOINTS_DLL

#define GET_GL_ENTRYPOINTS_DLL (   Type,
  Func 
)    Func = (Type)FPlatformProcess::GetDllExport(OpenGLDLL,TEXT(#Func));

Function Documentation

◆ PlatformBlitToViewport()

bool PlatformBlitToViewport ( IRHICommandContext RHICmdContext,
FPlatformOpenGLDevice Device,
const FOpenGLViewport Viewport,
uint32  BackbufferSizeX,
uint32  BackbufferSizeY,
bool  bPresent,
bool  bLockToVsync 
)

Main function for transferring data to on-screen buffers. On Windows it temporarily switches OpenGL context, on Mac only context's output view.

◆ PlatformCanEnableGPUCapture()

bool PlatformCanEnableGPUCapture ( )

Returns true if the platform supports a GPU capture tool (eg RenderDoc)

◆ PlatformCreateBuiltinBackBuffer()

FOpenGLTexture * PlatformCreateBuiltinBackBuffer ( FOpenGLDynamicRHI OpenGLRHI,
uint32  SizeX,
uint32  SizeY 
)

◆ PlatformCreateOpenGLContext()

FPlatformOpenGLContext * PlatformCreateOpenGLContext ( FPlatformOpenGLDevice Device,
void InWindowHandle 
)

Create an OpenGL context.

◆ PlatformCreateOpenGLDevice()

FPlatformOpenGLDevice * PlatformCreateOpenGLDevice ( )

Create the OpenGL device, encompassing all data needed to handle set of OpenGL contexts for a single OpenGL RHI. This contains shared context (to be used for resource loading), rendering context (to be used for rendering), and viewport contexts (to be used for blitting for various platform-specific viewports). On different platforms implementation details differ, by a lot. This should be called when creating the OpenGL RHI.

◆ PlatformDestroyOpenGLContext()

void PlatformDestroyOpenGLContext ( FPlatformOpenGLDevice Device,
FPlatformOpenGLContext Context 
)

Destroy an OpenGL context.

◆ PlatformDestroyOpenGLDevice()

void PlatformDestroyOpenGLDevice ( FPlatformOpenGLDevice Device)

Destroy the OpenGL device for single OpenGL RHI. This should happen when destroying the RHI.

◆ PlatformFlushIfNeeded()

void PlatformFlushIfNeeded ( )

◆ PlatformGetAvailableResolutions()

bool PlatformGetAvailableResolutions ( FScreenResolutionArray Resolutions,
bool  bIgnoreRefreshRate 
)

Retrieve available screen resolutions.

◆ PlatformGetSupportedResolution()

void PlatformGetSupportedResolution ( uint32 Width,
uint32 Height 
)

Returns a supported screen resolution that most closely matches input.

◆ PlatformGetWindow()

void * PlatformGetWindow ( FPlatformOpenGLContext Context,
void **  AddParam 
)

◆ PlatformGlGetError()

int32 PlatformGlGetError ( )

Just a glGetError() call. Added to make it possible to compile GL_VERIFY macros in other projects than OpenGLDrv.

◆ PlatformInitOpenGL()

bool PlatformInitOpenGL ( )

Initialize OpenGL on this platform. This must be called once before device contexts can be created.

Returns
true if initialization was successful.

◆ PlatformNULLContextSetup()

void PlatformNULLContextSetup ( )

This is used to detach an OpenGL context from current thread.

◆ PlatformOpenGLThreadHasRenderingContext()

bool PlatformOpenGLThreadHasRenderingContext ( )

Returns true when the calling thread owns the OpenGL rendering context.

◆ PlatformReleaseOpenGLContext()

void PlatformReleaseOpenGLContext ( FPlatformOpenGLDevice Device,
FPlatformOpenGLContext Context 
)

Release an OpenGL context.

◆ PlatformRenderingContextSetup()

void PlatformRenderingContextSetup ( FPlatformOpenGLDevice Device)

Set up rendering OpenGL context on current thread. This is the only context that can be used for rendering, and not only loading resources and framebuffer blitting (due to limitations of Windows OpenGL).

◆ PlatformResizeGLContext()

void PlatformResizeGLContext ( FPlatformOpenGLDevice Device,
FPlatformOpenGLContext Context,
uint32  SizeX,
uint32  SizeY,
bool  bFullscreen,
bool  bWasFullscreen,
GLenum  BackBufferTarget,
GLuint  BackBufferResource 
)

Resize the GL context.

◆ PlatformRestoreDesktopDisplayMode()

void PlatformRestoreDesktopDisplayMode ( )

Restore the original display mode

Variable Documentation

◆ GRunningUnderRenderDoc

bool GRunningUnderRenderDoc = false