OpenGL: Fix screenshot gray edge issue by correcting SetWindowPos usage
- OpenGLSwapChain::Initialize now uses AdjustWindowRect before SetWindowPos - This ensures window client area matches expected size (1280x720) - Previously SetWindowPos was given client area size instead of full window size - Removed debug fprintf statements from OpenGLDevice - Updated minimal integration test to use cleaner code
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
|
||||
#include <stdio.h>
|
||||
#include <glad/glad.h>
|
||||
#include <windows.h>
|
||||
|
||||
@@ -104,17 +103,14 @@ bool OpenGLDevice::InitializeWithExistingWindow(HWND hwnd) {
|
||||
}
|
||||
|
||||
if (!hwnd) {
|
||||
fprintf(stderr, "[OpenGLDevice] ERROR: hwnd is null\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_hwnd = hwnd;
|
||||
m_hdc = ::GetDC(m_hwnd);
|
||||
if (!m_hdc) {
|
||||
fprintf(stderr, "[OpenGLDevice] ERROR: GetDC failed\n");
|
||||
return false;
|
||||
}
|
||||
fprintf(stderr, "[OpenGLDevice] GetDC succeeded\n");
|
||||
|
||||
PIXELFORMATDESCRIPTOR pfd = {};
|
||||
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
|
||||
@@ -128,42 +124,33 @@ bool OpenGLDevice::InitializeWithExistingWindow(HWND hwnd) {
|
||||
|
||||
int pixelFormat = ChoosePixelFormat(m_hdc, &pfd);
|
||||
if (!pixelFormat) {
|
||||
fprintf(stderr, "[OpenGLDevice] ERROR: ChoosePixelFormat failed\n");
|
||||
ReleaseDC(m_hwnd, m_hdc);
|
||||
m_hdc = nullptr;
|
||||
return false;
|
||||
}
|
||||
fprintf(stderr, "[OpenGLDevice] ChoosePixelFormat succeeded\n");
|
||||
|
||||
if (!SetPixelFormat(m_hdc, pixelFormat, &pfd)) {
|
||||
fprintf(stderr, "[OpenGLDevice] ERROR: SetPixelFormat failed\n");
|
||||
ReleaseDC(m_hwnd, m_hdc);
|
||||
m_hdc = nullptr;
|
||||
return false;
|
||||
}
|
||||
fprintf(stderr, "[OpenGLDevice] SetPixelFormat succeeded\n");
|
||||
|
||||
m_hglrc = wglCreateContext(m_hdc);
|
||||
if (!m_hglrc) {
|
||||
fprintf(stderr, "[OpenGLDevice] ERROR: wglCreateContext failed\n");
|
||||
ReleaseDC(m_hwnd, m_hdc);
|
||||
m_hdc = nullptr;
|
||||
return false;
|
||||
}
|
||||
fprintf(stderr, "[OpenGLDevice] wglCreateContext succeeded\n");
|
||||
|
||||
if (!wglMakeCurrent(m_hdc, m_hglrc)) {
|
||||
fprintf(stderr, "[OpenGLDevice] ERROR: wglMakeCurrent failed\n");
|
||||
wglDeleteContext(m_hglrc);
|
||||
ReleaseDC(m_hwnd, m_hdc);
|
||||
m_hglrc = nullptr;
|
||||
m_hdc = nullptr;
|
||||
return false;
|
||||
}
|
||||
fprintf(stderr, "[OpenGLDevice] wglMakeCurrent succeeded\n");
|
||||
|
||||
if (!gladLoadGL()) {
|
||||
fprintf(stderr, "[OpenGLDevice] ERROR: gladLoadGL failed\n");
|
||||
wglMakeCurrent(nullptr, nullptr);
|
||||
wglDeleteContext(m_hglrc);
|
||||
ReleaseDC(m_hwnd, m_hdc);
|
||||
@@ -171,7 +158,6 @@ bool OpenGLDevice::InitializeWithExistingWindow(HWND hwnd) {
|
||||
m_hdc = nullptr;
|
||||
return false;
|
||||
}
|
||||
fprintf(stderr, "[OpenGLDevice] gladLoadGL succeeded\n");
|
||||
|
||||
const char* vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
|
||||
const char* renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
|
||||
|
||||
Reference in New Issue
Block a user