Add version info to the log file

This commit is contained in:
Magnus Norddahl 2020-09-19 15:49:19 +02:00
parent df6ecb66df
commit e3208f989c
2 changed files with 18 additions and 9 deletions

View file

@ -30,17 +30,20 @@
#include <algorithm>
#include <cmath>
static bool GLLogStarted = false;
static void APIENTRY GLLogCallback(GLenum source, GLenum type, GLuint id,
GLenum severity, GLsizei length, const GLchar* message, const void* userParam)
{
FILE* f = fopen("OpenGLDebug.log", GLLogStarted ? "a" : "w");
FILE* f = fopen("OpenGLDebug.log", "ab");
if (!f) return;
GLLogStarted = true;
fprintf(f, "%s\r\n", message);
fclose(f);
}
static const char* GLLogCheckNull(const GLubyte* str)
{
return str ? (const char*)str : "null";
}
GLRenderDevice::GLRenderDevice(void* disp, void* window)
{
Context = IOpenGLContext::Create(disp, window);
@ -49,8 +52,18 @@ GLRenderDevice::GLRenderDevice(void* disp, void* window)
Context->MakeCurrent();
#ifdef _DEBUG
glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(&GLLogCallback, nullptr);
FILE* f = fopen("OpenGLDebug.log", "wb");
if (f)
{
fprintf(f, "GL_VENDOR = %s\r\n", GLLogCheckNull(glGetString(GL_VENDOR)));
fprintf(f, "GL_RENDERER = %s\r\n", GLLogCheckNull(glGetString(GL_RENDERER)));
fprintf(f, "GL_VERSION = %s\r\n", GLLogCheckNull(glGetString(GL_VERSION)));
fprintf(f, "GL_SHADING_LANGUAGE_VERSION = %s\r\n", GLLogCheckNull(glGetString(GL_SHADING_LANGUAGE_VERSION)));
fclose(f);
glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(&GLLogCallback, nullptr);
}
#endif
glGenVertexArrays(1, &mStreamVAO);

View file

@ -233,8 +233,6 @@ OpenGLCreationHelper::OpenGLCreationHelper(HWND window) : window(window)
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
//pfd.cDepthBits = 16;
//pfd.cStencilBits = 8;
int pixelformat = ChoosePixelFormat(query_dc, &pfd);
SetPixelFormat(query_dc, pixelformat, &pfd);
@ -268,8 +266,6 @@ HGLRC OpenGLCreationHelper::CreateContext(HDC hdc, HGLRC share_context)
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
//pfd.cDepthBits = 16;
//pfd.cStencilBits = 8;
int pixelformat = ChoosePixelFormat(hdc, &pfd);
SetPixelFormat(hdc, pixelformat, &pfd);