Minor cleanup, improved OpenGL error reporting.

master
Martin Felis 2021-10-31 16:41:21 +01:00
parent 1848fd14cf
commit 133165ef9b
1 changed files with 49 additions and 15 deletions

View File

@ -86,11 +86,46 @@ static void opengl_error_callback(
GLsizei length,
const GLchar* message,
const void* userParam) {
const char* source_str;
switch (source)
{
case GL_DEBUG_SOURCE_API: source_str = "API"; break;
case GL_DEBUG_SOURCE_WINDOW_SYSTEM: source_str = "Window System"; break;
case GL_DEBUG_SOURCE_SHADER_COMPILER: source_str = "Shader Compiler"; break;
case GL_DEBUG_SOURCE_THIRD_PARTY: source_str = "3rd Party"; break;
case GL_DEBUG_SOURCE_APPLICATION: source_str = "Application"; break;
default: source_str = "Other"; break;
}
const char* type_str;
switch (type)
{
case GL_DEBUG_TYPE_ERROR: type_str = "Error"; break;
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: type_str = "Deprecated Behaviour"; break;
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: type_str = "Undefined Behaviour"; break;
case GL_DEBUG_TYPE_PORTABILITY: type_str = "Portability"; break;
case GL_DEBUG_TYPE_PERFORMANCE: type_str = "Performance"; break;
case GL_DEBUG_TYPE_MARKER: type_str = "Marker"; break;
case GL_DEBUG_TYPE_PUSH_GROUP: type_str = "Push Group"; break;
case GL_DEBUG_TYPE_POP_GROUP: type_str = "Pop Group"; break;
default: type_str = "Other"; break;
}
const char* severity_str;
switch (severity)
{
case GL_DEBUG_SEVERITY_HIGH: severity_str = "high"; break;
case GL_DEBUG_SEVERITY_MEDIUM: severity_str = "medium"; break;
case GL_DEBUG_SEVERITY_LOW: severity_str = "low"; break;
case GL_DEBUG_SEVERITY_NOTIFICATION: severity_str = "notification"; break;
default: severity_str = "unknown";
}
gLog(
"OpenGL Error: %s type %0x%x, severity = 0x%x, message = %s",
(type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""),
type,
severity,
"OpenGL Error (%s, type %s, severity = %s): %s",
source_str,
type_str,
severity_str,
message);
}
@ -116,15 +151,15 @@ void handle_mouse() {
glfwGetCursorPos(gWindow, &mouse_x, &mouse_y);
if (gGuiInputState->mouseButton) {
gGuiInputState->mousedX = mouse_x - gGuiInputState->mouseX;
gGuiInputState->mousedY = mouse_y - gGuiInputState->mouseY;
gGuiInputState->mousedX = int32_t (mouse_x) - gGuiInputState->mouseX;
gGuiInputState->mousedY = int32_t (mouse_y) - gGuiInputState->mouseY;
} else {
gGuiInputState->mousedX = 0;
gGuiInputState->mousedY = 0;
}
gGuiInputState->mouseX = mouse_x;
gGuiInputState->mouseY = mouse_y;
gGuiInputState->mouseScroll = mouse_scroll_y;
gGuiInputState->mouseX = int32_t(mouse_x);
gGuiInputState->mouseY = int32_t(mouse_y);
gGuiInputState->mouseScroll = int32_t(mouse_scroll_y);
gGuiInputState->mouseButton = glfwGetMouseButton(gWindow, 0)
+ (glfwGetMouseButton(gWindow, 1) << 1)
@ -186,8 +221,6 @@ void ShowDockspace(bool open) {
}
static ImGuizmo::OPERATION mCurrentGizmoOperation(ImGuizmo::TRANSLATE);
int gizmoCount = 1;
float camDistance = 8.f;
void RenderGuizmoTest(srcmdbuf* cmdbuf) {
srcmd rcmd;
@ -219,7 +252,7 @@ void ShowViewManip() {
windowHeight);
float viewManipulateRight = ImGui::GetWindowPos().x + windowWidth;
int title_height = ImGui::GetFontSize() + imgui_style.FramePadding.y * 2;
float title_height = ImGui::GetFontSize() + imgui_style.FramePadding.y * 2.f;
ImVec2 window_pos = ImGui::GetWindowPos();
ImVec2 view_manip_widget_size(128, 128);
@ -254,7 +287,7 @@ void ShowTransformManip(
ImVec2 window_pos = ImGui::GetWindowPos();
ImGuiStyle imgui_style = ImGui::GetStyle();
int title_height = ImGui::GetFontSize() + imgui_style.FramePadding.y * 2;
float title_height = ImGui::GetFontSize() + imgui_style.FramePadding.y * 2.f;
window_pos.x += imgui_style.WindowPadding.x;
window_pos.y += imgui_style.WindowPadding.y + title_height;
@ -324,6 +357,7 @@ void ShowTransformManip(
case ImGuizmo::SCALE:
ImGui::InputFloat("Scale Snap", &snap[0]);
break;
default: break;
}
ImGui::Checkbox("Bound Sizing", &boundSizing);
if (boundSizing) {
@ -386,7 +420,7 @@ void DoRender() {
// Update the gCameraState->mtxView
const ImVec2 content_avail = ImGui::GetContentRegionAvail();
srview_set_size(gView, content_avail.x, content_avail.y);
srview_set_size(gView, int(content_avail.x), int(content_avail.y));
float view_width = content_avail.x / 50.f;
float view_height = content_avail.y / 50.f;
@ -451,7 +485,7 @@ void DoRender() {
ImGui::End();
}
int main(void) {
int main() {
gTimerInit();
LoggingInit();