From fce88fc72ceaa2b52a020f254974d87af608c1eb Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 30 Aug 2019 11:33:43 +1000 Subject: [PATCH] [EGL] add debug printf helper --- VERSION | 2 +- client/renderers/EGL/CMakeLists.txt | 1 + client/renderers/EGL/debug.c | 58 +++++++++++++++++++++++++++++ client/renderers/EGL/debug.h | 27 ++++++++++++++ 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 client/renderers/EGL/debug.c create mode 100644 client/renderers/EGL/debug.h diff --git a/VERSION b/VERSION index f3120341..34a60bc9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-rc6-6-gb979752989+1 \ No newline at end of file +fetch-0-g163a2e5d0a+1 \ No newline at end of file diff --git a/client/renderers/EGL/CMakeLists.txt b/client/renderers/EGL/CMakeLists.txt index ce73f771..991c38b5 100644 --- a/client/renderers/EGL/CMakeLists.txt +++ b/client/renderers/EGL/CMakeLists.txt @@ -31,6 +31,7 @@ make_object( add_library(renderer_EGL STATIC egl.c + debug.c shader.c texture.c model.c diff --git a/client/renderers/EGL/debug.c b/client/renderers/EGL/debug.c new file mode 100644 index 00000000..5128fa20 --- /dev/null +++ b/client/renderers/EGL/debug.c @@ -0,0 +1,58 @@ +/* +Looking Glass - KVM FrameRelay (KVMFR) Client +Copyright (C) 2017-2019 Geoffrey McRae +https://looking-glass.hostfission.com + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include + +void egl_debug_printf(char * format, ...) +{ + va_list args; + va_start(args, format); + vfprintf(stderr, format, args); + va_end(args); + + GLenum error = glGetError(); + switch(error) + { + case GL_NO_ERROR: + fprintf(stderr, " (GL_NO_ERROR)\n"); + break; + + case GL_INVALID_ENUM: + fprintf(stderr, " (GL_INVALID_ENUM)\n"); + break; + + case GL_INVALID_VALUE: + fprintf(stderr, " (GL_INVALID_VALUE)\n"); + break; + + case GL_INVALID_OPERATION: + fprintf(stderr, " (GL_INVALID_OPERATION)\n"); + break; + + case GL_INVALID_FRAMEBUFFER_OPERATION: + fprintf(stderr, " (GL_INVALID_FRAMEBUFFER_OPERATION)\n"); + break; + + case GL_OUT_OF_MEMORY: + fprintf(stderr, " (GL_OUT_OF_MEMORY)\n"); + break; + } +} \ No newline at end of file diff --git a/client/renderers/EGL/debug.h b/client/renderers/EGL/debug.h new file mode 100644 index 00000000..47cf3106 --- /dev/null +++ b/client/renderers/EGL/debug.h @@ -0,0 +1,27 @@ +/* +Looking Glass - KVM FrameRelay (KVMFR) Client +Copyright (C) 2017-2019 Geoffrey McRae +https://looking-glass.hostfission.com + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#pragma once + +#include + +#define EGL_DEBUG_PRINT(type, fmt, ...) do {egl_debug_printf(type " %20s:%-4u | %-30s | " fmt, STRIPPATH(__FILE__), __LINE__, __FUNCTION__, ##__VA_ARGS__);} while (0) +#define EGL_ERROR(fmt, ...) EGL_DEBUG_PRINT("[E]", fmt, ##__VA_ARGS__) + +void egl_debug_printf(char * format, ...); \ No newline at end of file