Update
This commit is contained in:
@@ -32,6 +32,10 @@ glm::vec3 g_viewOrient;
|
||||
#define GL_DEBUG_TYPE_ERROR_ARB 0x824C
|
||||
#endif // !GL_DEBUG_TYPE_ERROR_ARB
|
||||
|
||||
#ifndef GL_DEBUG_OUTPUT
|
||||
#define GL_DEBUG_OUTPUT 0x92E0
|
||||
#endif // !GL_DEBUG_OUTPUT
|
||||
|
||||
#ifndef GL_ARB_debug_output
|
||||
#define GL_ARB_debug_output 1
|
||||
typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled);
|
||||
@@ -52,7 +56,7 @@ void APIENTRY GL_DebugOutput(GLenum source,
|
||||
const char* message,
|
||||
const void* userParam)
|
||||
{
|
||||
// Nvidia spam too much about filenameBuffer mapping
|
||||
// Nvidia spam too much about buffer mapping
|
||||
if (type == 0x8251)
|
||||
return;
|
||||
|
||||
@@ -63,6 +67,7 @@ void APIENTRY GL_DebugOutput(GLenum source,
|
||||
if (type == GL_DEBUG_TYPE_ERROR_ARB)
|
||||
{
|
||||
bool debug = true;
|
||||
__debugbreak();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,25 +112,13 @@ void Render::Init(SDL_Window* pWindow)
|
||||
Msg("%s", (const char*)glGetString(GL_VENDOR));
|
||||
Msg("%s", (const char*)glGetString(GL_RENDERER));
|
||||
Msg("OpenGL ver. %s", (const char*)glGetString(GL_VERSION));
|
||||
Msg("Context created with OpenGL version %d.%d", GLVersion.major, GLVersion.minor);
|
||||
|
||||
Msg("Initializing OpenGL extensions...");
|
||||
InitGLExtensions();
|
||||
|
||||
// Reset OpenGL error stack
|
||||
glGetError();
|
||||
|
||||
// Load extension
|
||||
glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)SDL_GL_GetProcAddress("glDebugMessageCallbackARB");
|
||||
|
||||
// Enable debug output
|
||||
if (glDebugMessageCallbackARB)
|
||||
{
|
||||
Msg("...found GL_ARB_debug_output");
|
||||
|
||||
//glEnable(GL_DEBUG_OUTPUT);
|
||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
||||
glDebugMessageCallbackARB(GL_DebugOutput, NULL);
|
||||
}
|
||||
|
||||
|
||||
// Create render device
|
||||
g_renderDevice = new RenderDevice();
|
||||
|
||||
@@ -163,6 +156,75 @@ void Render::Init(SDL_Window* pWindow)
|
||||
}
|
||||
}
|
||||
|
||||
void Render::InitGLExtensions()
|
||||
{
|
||||
//// Load extension
|
||||
//glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)SDL_GL_GetProcAddress("glDebugMessageCallbackARB");
|
||||
|
||||
//// Enable debug output
|
||||
//if (glDebugMessageCallbackARB)
|
||||
//{
|
||||
// Msg("...found GL_ARB_debug_output");
|
||||
|
||||
// //glEnable(GL_DEBUG_OUTPUT);
|
||||
// glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
||||
// glDebugMessageCallbackARB(GL_DebugOutput, NULL);
|
||||
//}
|
||||
|
||||
//bool found_WGL_EXT_swap_control = false;
|
||||
bool found_GL_ARB_debug_output = false;
|
||||
|
||||
// Load extensions
|
||||
char* extensions = (char*)glGetString(GL_EXTENSIONS); // OpenGL Error: GL_INVALID_ENUM at D:\projects\old\pke\src\render\shadersystem.cpp:169
|
||||
if (extensions)
|
||||
{
|
||||
char* extension = strtok(extensions, " ");
|
||||
while (extension)
|
||||
{
|
||||
//if (strcmp(extension, "WGL_EXT_swap_control") == 0)
|
||||
// found_WGL_EXT_swap_control = true;
|
||||
|
||||
if (strcmp(extension, "GL_ARB_debug_output") == 0)
|
||||
found_GL_ARB_debug_output = true;
|
||||
|
||||
extension = strtok(NULL, " ");
|
||||
}
|
||||
}
|
||||
else // core profile
|
||||
{
|
||||
int NumberOfExtensions;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &NumberOfExtensions);
|
||||
|
||||
for (int i = 0; i < NumberOfExtensions; i++) {
|
||||
char* extension = (char*)glGetStringi(GL_EXTENSIONS, i);
|
||||
|
||||
//if (strcmp(extension, "WGL_EXT_swap_control") == 0)
|
||||
// found_WGL_EXT_swap_control = true;
|
||||
|
||||
if (strcmp(extension, "GL_ARB_debug_output") == 0)
|
||||
found_GL_ARB_debug_output = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Enable debug output
|
||||
if (found_GL_ARB_debug_output)
|
||||
{
|
||||
Msg("...found GL_ARB_debug_output");
|
||||
|
||||
glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)SDL_GL_GetProcAddress("glDebugMessageCallbackARB");
|
||||
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
||||
glDebugMessageCallbackARB(GL_DebugOutput, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
Msg("...not found GL_ARB_debug_output");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Render::Shutdown()
|
||||
{
|
||||
if (m_usingVAO)
|
||||
@@ -236,15 +298,20 @@ void Render::RenderStats()
|
||||
{
|
||||
char buffer[256];
|
||||
|
||||
snprintf(buffer, sizeof(buffer), "Scene: %s", g_sceneManager->getSceneName());
|
||||
snprintf(buffer, sizeof(buffer), "FPS: %.1f", ImGui::GetIO().Framerate);
|
||||
ImGui::GetForegroundDrawList()->AddText(ImVec2(0.0f, 0.0f), 0xffffffff, buffer);
|
||||
|
||||
snprintf(buffer, sizeof(buffer), "numModels: %d", g_NumModels);
|
||||
snprintf(buffer, sizeof(buffer), "Scene: %s", g_sceneManager->getSceneName());
|
||||
ImGui::GetForegroundDrawList()->AddText(ImVec2(0.0f, 15.0f), 0xffffffff, buffer);
|
||||
|
||||
snprintf(buffer, sizeof(buffer), "numModels: %d", g_NumModels);
|
||||
ImGui::GetForegroundDrawList()->AddText(ImVec2(0.0f, 30.0f), 0xffffffff, buffer);
|
||||
}
|
||||
|
||||
void Render::Present(bool vsync)
|
||||
{
|
||||
SDL_GL_SetSwapInterval(vsync);
|
||||
|
||||
SDL_GL_SwapWindow(m_pWindow);
|
||||
|
||||
// reset stats
|
||||
|
||||
@@ -16,6 +16,7 @@ public:
|
||||
~Render();
|
||||
|
||||
void Init(SDL_Window* pWindow);
|
||||
void InitGLExtensions();
|
||||
void Shutdown();
|
||||
|
||||
void RenderScene();
|
||||
|
||||
Reference in New Issue
Block a user