Skip to content

Commit

Permalink
[client] opengl: remove glu dependency
Browse files Browse the repository at this point in the history
We only use gluOrtho2D, which is trivially replaced with glOrtho, and
gluErrorString which can be replaced with a small lookup table.
  • Loading branch information
quantum5 authored and gnif committed Feb 20, 2021
1 parent ec921d7 commit 2973319
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
1 change: 0 additions & 1 deletion client/renderers/OpenGL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ project(renderer_Opengl LANGUAGES C)
find_package(PkgConfig)
pkg_check_modules(RENDERER_OPENGL_PKGCONFIG REQUIRED
gl
glu
)

add_library(renderer_OpenGL STATIC
Expand Down
40 changes: 36 additions & 4 deletions client/renderers/OpenGL/opengl.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <SDL2/SDL_ttf.h>

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>

#include "common/debug.h"
Expand Down Expand Up @@ -319,7 +318,7 @@ void opengl_on_resize(void * opaque, const int width, const int height,
glViewport(0, 0, this->window.x, this->window.y);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, this->window.x, this->window.y, 0);
glOrtho(0, this->window.x, this->window.y, 0, -1, 1);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
Expand Down Expand Up @@ -842,7 +841,40 @@ static bool _check_gl_error(unsigned int line, const char * name)
if (error == GL_NO_ERROR)
return false;

const GLubyte * errStr = gluErrorString(error);
const char * errStr;
switch (error)
{
case GL_INVALID_ENUM:
errStr = "GL_INVALID_ENUM";
break;

case GL_INVALID_VALUE:
errStr = "GL_INVALID_VALUE";
break;

case GL_INVALID_OPERATION:
errStr = "GL_INVALID_OPERATION";
break;

case GL_STACK_OVERFLOW:
errStr = "GL_STACK_OVERFLOW";
break;

case GL_STACK_UNDERFLOW:
errStr = "GL_STACK_UNDERFLOW";
break;

case GL_OUT_OF_MEMORY:
errStr = "GL_OUT_OF_MEMORY";
break;

case GL_TABLE_TOO_LARGE:
errStr = "GL_TABLE_TOO_LARGE";
break;

default:
errStr = "unknown error";
}
DEBUG_ERROR("%d: %s = %d (%s)", line, name, error, errStr);
return true;
}
Expand Down Expand Up @@ -1270,7 +1302,7 @@ static bool draw_frame(struct Inst * this)
break;

case GL_WAIT_FAILED:
DEBUG_ERROR("Wait failed %s", gluErrorString(glGetError()));
DEBUG_ERROR("Wait failed %d", glGetError());
break;
}

Expand Down

0 comments on commit 2973319

Please sign in to comment.