mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
[wpigui] Handle Direct3D framebuffer resize
This commit is contained in:
@@ -38,6 +38,10 @@ static void WindowSizeCallback(GLFWwindow* window, int width, int height) {
|
||||
}
|
||||
}
|
||||
|
||||
static void FramebufferSizeCallback(GLFWwindow* window, int width, int height) {
|
||||
PlatformFramebufferSizeChanged(width, height);
|
||||
}
|
||||
|
||||
static void WindowMaximizeCallback(GLFWwindow* window, int maximized) {
|
||||
gContext->maximized = maximized;
|
||||
}
|
||||
@@ -197,6 +201,7 @@ bool gui::Initialize(const char* title, int width, int height) {
|
||||
// Set window callbacks
|
||||
glfwGetWindowSize(gContext->window, &gContext->width, &gContext->height);
|
||||
glfwSetWindowSizeCallback(gContext->window, WindowSizeCallback);
|
||||
glfwSetFramebufferSizeCallback(gContext->window, FramebufferSizeCallback);
|
||||
glfwSetWindowMaximizeCallback(gContext->window, WindowMaximizeCallback);
|
||||
glfwSetWindowPosCallback(gContext->window, WindowPosCallback);
|
||||
|
||||
|
||||
@@ -152,6 +152,15 @@ void gui::PlatformShutdown() {
|
||||
ImGui_ImplDX11_Shutdown();
|
||||
}
|
||||
|
||||
void gui::PlatformFramebufferSizeChanged(int width, int height) {
|
||||
if (gPlatformContext && gPlatformContext->pd3dDevice) {
|
||||
CleanupRenderTarget();
|
||||
gPlatformContext->pSwapChain->ResizeBuffers(0, width, height,
|
||||
DXGI_FORMAT_UNKNOWN, 0);
|
||||
CreateRenderTarget();
|
||||
}
|
||||
}
|
||||
|
||||
static inline DXGI_FORMAT DXPixelFormat(PixelFormat format) {
|
||||
switch (format) {
|
||||
case kPixelRGBA:
|
||||
|
||||
@@ -67,6 +67,7 @@ void PlatformGlfwWindowHints();
|
||||
bool PlatformInitRenderer();
|
||||
void PlatformRenderFrame();
|
||||
void PlatformShutdown();
|
||||
void PlatformFramebufferSizeChanged(int width, int height);
|
||||
|
||||
void CommonRenderFrame();
|
||||
|
||||
|
||||
@@ -107,6 +107,8 @@ void gui::PlatformShutdown() {
|
||||
gPlatformValid = false;
|
||||
}
|
||||
|
||||
void gui::PlatformFramebufferSizeChanged(int, int) {}
|
||||
|
||||
static inline MTLPixelFormat MetalPixelFormat(PixelFormat format) {
|
||||
switch (format) {
|
||||
case kPixelRGBA:
|
||||
|
||||
@@ -99,6 +99,8 @@ void gui::PlatformShutdown() {
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
}
|
||||
|
||||
void gui::PlatformFramebufferSizeChanged(int width, int height) {}
|
||||
|
||||
static inline GLenum GLPixelFormat(PixelFormat format) {
|
||||
switch (format) {
|
||||
case kPixelRGBA:
|
||||
|
||||
Reference in New Issue
Block a user