SVN commit 1010101 by rivol: Remove libglu dependancy M +0 -3 CMakeLists.txt M +1 -1 core/kgllib/CMakeLists.txt M +26 -4 core/kgllib/kgllib.cpp M +9 -2 core/kgllib/kgllib.h M +2 -1 extras/kgllib/hdrglwidget.cpp M +2 -1 extras/kgllib/widgetproxy.cpp --- trunk/playground/libs/kgllib/CMakeLists.txt #1010100:1010101 @@ -25,9 +25,6 @@ find_package(OpenGL REQUIRED) find_package(GLEW) find_package(Eigen2 REQUIRED) -if(NOT OPENGL_GLU_FOUND) - message(FATAL_ERROR "GLU was not found") -endif(NOT OPENGL_GLU_FOUND) # Taken from FindKDE4Internal.cmake set(INSTALL_TARGETS_DEFAULT_ARGS RUNTIME DESTINATION "${BIN_INSTALL_DIR}" --- trunk/playground/libs/kgllib/core/kgllib/CMakeLists.txt #1010100:1010101 @@ -34,7 +34,7 @@ add_library(kgllib SHARED ${kgllib_SRCS}) -target_link_libraries(kgllib ${OPENGL_gl_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} ${GLEW_GLEW_LIBRARY} ${OPENGL_glu_LIBRARY}) +target_link_libraries(kgllib ${OPENGL_gl_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} ${GLEW_GLEW_LIBRARY}) set_target_properties(kgllib PROPERTIES VERSION ${KGLLIB_LIB_VERSION} SOVERSION ${KGLLIB_LIB_SOVERSION} --- trunk/playground/libs/kgllib/core/kgllib/kgllib.cpp #1010100:1010101 @@ -3,7 +3,7 @@ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public + * You should have received a copy of the GNU Lesser General Public * License along with this program. If not, see . */ @@ -51,11 +51,33 @@ if (error == GL_NO_ERROR) { return true; } else { - const char* errString = (const char*)gluErrorString(error); - qCritical() << qPrintable(desc) << ":" << errString; + qCritical() << qPrintable(desc) << ":" << glErrorString(error); return false; } } +// This function has been taked (and somewhat adapted) from Mesa's libglu, which is licenced under LGPL2+ +const char* glErrorString(GLenum errorCode) +{ + /* GL Errors */ + if (errorCode == GL_NO_ERROR) { + return "no error"; + } else if (errorCode == GL_INVALID_VALUE) { + return "invalid value"; + } else if (errorCode == GL_INVALID_ENUM) { + return "invalid enum"; + } else if (errorCode == GL_INVALID_OPERATION) { + return "invalid operation"; + } else if (errorCode == GL_STACK_OVERFLOW) { + return "stack overflow"; + } else if (errorCode == GL_STACK_UNDERFLOW) { + return "stack underflow"; + } else if (errorCode == GL_OUT_OF_MEMORY) { + return "out of memory"; + } else { + return 0; + } } +} + --- trunk/playground/libs/kgllib/core/kgllib/kgllib.h #1010100:1010101 @@ -3,7 +3,7 @@ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either + * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, @@ -11,7 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public + * You should have received a copy of the GNU Lesser General Public * License along with this program. If not, see . */ @@ -54,6 +54,13 @@ **/ KGLLIB_EXPORT bool checkGLError(const QString& desc); +/** + * @return error string corresponding to the given OpenGL error code. + * + * This is similar to the gluErrorString() function, except that it does not handle GLU-specific + * error codes. The function is included in KGLLib to make it independant from libglu. + **/ +KGLLIB_EXPORT const char* glErrorString(GLenum errorCode); /** * Pointer to the global renderer object. --- trunk/playground/libs/kgllib/extras/kgllib/hdrglwidget.cpp #1010100:1010101 @@ -427,7 +427,8 @@ glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluOrtho2D(0, width, 0, height); + // This is same as gluOrtho2D(0, width, 0, height); + glOrtho(0, width, 0, height, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } --- trunk/playground/libs/kgllib/extras/kgllib/widgetproxy.cpp #1010100:1010101 @@ -62,7 +62,8 @@ // the OpenGL paintengine does glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluOrtho2D(0, width(), height(), 0); + // This is same as gluOrtho2D(0, width(), height(), 0); + glOrtho(0, width(), height(), 0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }