Replace GLEW with a glLoadGen loader.

This should fix the GL loading errors that occur in some drivers due to
the use of deprecated functions by GLEW. Side benefits are more accurate
auto-completion (deprecated function and symbols don't exist) and faster
pointer loading (less entrypoints to load). In addition it removes an
external library depency, simplifying the build system a bit and
eliminating one set of binary libraries for Windows.
This commit is contained in:
Yuri Kunde Schlesner 2014-08-23 21:00:08 -03:00
parent 76372feb19
commit 478289140d
42 changed files with 2829 additions and 21329 deletions

View File

@ -6,7 +6,7 @@ set -e
if [ "$TRAVIS_OS_NAME" = linux -o -z "$TRAVIS_OS_NAME" ]; then
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get -qq update
sudo apt-get -qq install g++-4.8 xorg-dev libglu1-mesa-dev libglew-dev libxcursor-dev
sudo apt-get -qq install g++-4.8 xorg-dev libglu1-mesa-dev libxcursor-dev
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90
git clone https://github.com/glfw/glfw.git
mkdir glfw/build && cd glfw/build
@ -14,5 +14,5 @@ if [ "$TRAVIS_OS_NAME" = linux -o -z "$TRAVIS_OS_NAME" ]; then
cd -
elif [ "$TRAVIS_OS_NAME" = osx ]; then
brew tap homebrew/versions
brew install glew qt5 glfw3 pkgconfig
brew install qt5 glfw3 pkgconfig
fi

View File

@ -19,7 +19,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modul
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeTests)
include(FindX11 REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(GLEW REQUIRED)
find_package(OpenGL REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
@ -33,7 +32,6 @@ ENDIF (APPLE)
#external includes
include_directories(${GLFW_INCLUDE_DIRS})
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(${GLEW_INCLUDE_PATH})
# workaround for GLFW linking on OSX
link_directories(${GLFW_LIBRARY_DIRS})

View File

@ -1,47 +0,0 @@
#
# Try to find GLEW library and include path.
# Once done this will define
#
# GLEW_FOUND
# GLEW_INCLUDE_PATH
# GLEW_LIBRARY
#
IF (WIN32)
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
$ENV{PROGRAMFILES}/GLEW/include
${PROJECT_SOURCE_DIR}/src/nvgl/glew/include
DOC "The directory where GL/glew.h resides")
FIND_LIBRARY( GLEW_LIBRARY
NAMES glew GLEW glew32 glew32s
PATHS
$ENV{PROGRAMFILES}/GLEW/lib
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
DOC "The GLEW library")
ELSE (WIN32)
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
/usr/include
/usr/local/include
/sw/include
/opt/local/include
DOC "The directory where GL/glew.h resides")
FIND_LIBRARY( GLEW_LIBRARY
NAMES GLEW glew
PATHS
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
/sw/lib
/opt/local/lib
DOC "The GLEW library")
ENDIF (WIN32)
IF (GLEW_INCLUDE_PATH)
SET( GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise")
ELSE (GLEW_INCLUDE_PATH)
SET( GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise")
ENDIF (GLEW_INCLUDE_PATH)
MARK_AS_ADVANCED( GLEW_FOUND )

View File

@ -1,73 +0,0 @@
The OpenGL Extension Wrangler Library
Copyright (C) 2002-2007, Milan Ikits <milan ikits[]ieee org>
Copyright (C) 2002-2007, Marcelo E. Magallon <mmagallo[]debian org>
Copyright (C) 2002, Lev Povalahev
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the author may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
Mesa 3-D graphics library
Version: 7.0
Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2007 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and/or associated documentation files (the
"Materials"), to deal in the Materials without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Materials, and to
permit persons to whom the Materials are furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Materials.
THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.

View File

@ -1,18 +0,0 @@
See doc/index.html for more information.
If you downloaded the tarball from the GLEW website, you just need to:
Unix:
make
Windows:
use the project file in build/vc6/
If you wish to build GLEW from scratch (update the extension data from
the net or add your own extension information), you need a Unix
environment (including wget, perl, and GNU make). The extension data
is regenerated from the top level source directory with:
make extensions

View File

@ -1,12 +0,0 @@
Major:
- add support for windows mini-client drivers
- add windows installer (msi)
- separate build of static and shared object files (for mingw and
cygwin)
- start designing GLEW 2.0
Minor:
- make auto scripts work with text mode cygwin mounts
- add support for all SUN, MTX, and OML extensions
- make auto/Makefile more robust against auto/core/*~ mistakes
- web poll on separating glew, glxew and wglew

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -10,9 +10,9 @@ endif()
add_executable(citra ${SRCS} ${HEADERS})
if (APPLE)
target_link_libraries(citra core common video_core iconv pthread ${COREFOUNDATION_LIBRARY} ${OPENGL_LIBRARIES} ${GLEW_LIBRARY} ${GLFW_LIBRARIES})
target_link_libraries(citra core common video_core iconv pthread ${COREFOUNDATION_LIBRARY} ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES})
else()
target_link_libraries(citra core common video_core GLEW pthread X11 Xxf86vm Xi Xcursor ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} rt ${X11_Xrandr_LIB} ${X11_xv86vmode_LIB} ${PNG_LIBRARIES})
target_link_libraries(citra core common video_core pthread X11 Xxf86vm Xi Xcursor ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} rt ${X11_Xrandr_LIB} ${X11_xv86vmode_LIB} ${PNG_LIBRARIES})
endif()
#install(TARGETS citra RUNTIME DESTINATION ${bindir})

View File

@ -4,7 +4,6 @@
#pragma once
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include "common/emu_window.h"

View File

@ -47,7 +47,7 @@ else()
set(RT_LIBRARY rt)
endif()
target_link_libraries(citra-qt core common video_core qhexedit ${ICONV_LIBRARY} ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${RT_LIBRARY} ${GLEW_LIBRARY} ${PNG_LIBRARIES})
target_link_libraries(citra-qt core common video_core qhexedit ${ICONV_LIBRARY} ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${RT_LIBRARY} ${PNG_LIBRARIES})
if(USE_QT5)
target_link_libraries(citra-qt Qt5::Gui Qt5::Widgets Qt5::OpenGL)
endif()

View File

@ -5,6 +5,7 @@ set(SRCS clipper.cpp
utils.cpp
vertex_shader.cpp
video_core.cpp
renderer_opengl/generated/gl_3_2_core.c
renderer_opengl/renderer_opengl.cpp
renderer_opengl/gl_shader_util.cpp
debug_utils/debug_utils.cpp)
@ -19,6 +20,7 @@ set(HEADERS clipper.h
renderer_base.h
vertex_shader.h
video_core.h
renderer_opengl/generated/gl_3_2_core.h
renderer_opengl/renderer_opengl.h
renderer_opengl/gl_shader_util.h
renderer_opengl/gl_shaders.h

View File

@ -0,0 +1,5 @@
These file were generated by the [glLoadGen](https://bitbucket.org/alfonse/glloadgen/wiki/Home) OpenGL loader generator and have been checked in as-is. You can re-generate them using version 2.0.2 of glLoadGen and executing the following command:
```
lua LoadGen.lua -version 3.2 -profile core -indent space 3_2_core
```

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
#pragma once
#include <GL/glew.h>
#include "generated/gl_3_2_core.h"
namespace ShaderUtil {

View File

@ -247,10 +247,9 @@ void RendererOpenGL::SetWindow(EmuWindow* window) {
void RendererOpenGL::Init() {
render_window->MakeCurrent();
GLenum err = glewInit();
if (GLEW_OK != err) {
ERROR_LOG(RENDER, "Failed to initialize GLEW! Error message: \"%s\". Exiting...",
glewGetErrorString(err));
int err = ogl_LoadFunctions();
if (ogl_LOAD_SUCCEEDED != err) {
ERROR_LOG(RENDER, "Failed to initialize GL functions! Exiting...");
exit(-1);
}
@ -265,7 +264,6 @@ void RendererOpenGL::Init() {
// Initialize everything else
// --------------------------
InitFramebuffer();
NOTICE_LOG(RENDER, "GL_VERSION: %s\n", glGetString(GL_VERSION));

View File

@ -4,7 +4,7 @@
#pragma once
#include <GL/glew.h>
#include "generated/gl_3_2_core.h"
#include "common/common.h"
#include "common/emu_window.h"

View File

@ -30,11 +30,6 @@ void Start() {
/// Initialize the video core
void Init(EmuWindow* emu_window) {
// Required in order for GLFW to work on Linux,
// or for GL contexts above 2.x on OS X
glewExperimental = GL_TRUE;
g_emu_window = emu_window;
g_renderer = new RendererOpenGL();
g_renderer->SetWindow(g_emu_window);

View File

@ -20,6 +20,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="debug_utils\debug_utils.cpp" />
<ClCompile Include="renderer_opengl\generated\gl_3_2_core.c" />
<ClCompile Include="renderer_opengl\renderer_opengl.cpp" />
<ClCompile Include="renderer_opengl\gl_shader_util.cpp" />
<ClCompile Include="clipper.cpp" />
@ -39,6 +40,7 @@
<ClInclude Include="primitive_assembly.h" />
<ClInclude Include="rasterizer.h" />
<ClInclude Include="renderer_base.h" />
<ClInclude Include="renderer_opengl\generated\gl_3_2_core.h" />
<ClInclude Include="utils.h" />
<ClInclude Include="vertex_shader.h" />
<ClInclude Include="video_core.h" />

View File

@ -7,6 +7,9 @@
<Filter Include="debug_utils">
<UniqueIdentifier>{0ac498e6-bbd8-46e3-9d5f-e816546ab90e}</UniqueIdentifier>
</Filter>
<Filter Include="renderer_opengl\generated">
<UniqueIdentifier>{00301d57-24b3-4717-86a4-0073d131eb78}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="renderer_opengl\renderer_opengl.cpp">
@ -25,6 +28,9 @@
<ClCompile Include="debug_utils\debug_utils.cpp">
<Filter>debug_utils</Filter>
</ClCompile>
<ClCompile Include="renderer_opengl\generated\gl_3_2_core.c">
<Filter>renderer_opengl\generated</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="clipper.h" />
@ -50,8 +56,11 @@
<ClInclude Include="debug_utils\debug_utils.h">
<Filter>debug_utils</Filter>
</ClInclude>
<ClInclude Include="renderer_opengl\generated\gl_3_2_core.h">
<Filter>renderer_opengl\generated</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
</Project>
</Project>

View File

@ -11,7 +11,6 @@
<ItemDefinitionGroup>
<PostBuildEvent>
<Command>xcopy "$(SolutionDir)data" "$(EmuBinDir)" /Y /S /D
xcopy "$(ExternalsDir)glew-1.10.0\bin\Release\$(PlatformName)\glew32.dll" "$(EmuBinDir)" /Y /S /D
xcopy "$(ExternalsDir)glfw-3.0.2\lib-msvc100\glfw3.dll" "$(EmuBinDir)" /Y /S /D
%(Command)</Command>
</PostBuildEvent>

View File

@ -9,14 +9,14 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(ExternalsDir)glew-1.10.0\include;$(ExternalsDir)glfw-3.0.2\include;$(ExternalsDir)qhexedit;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ExternalsDir)glfw-3.0.2\include;$(ExternalsDir)qhexedit;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>
</PreprocessorDefinitions>
</ClCompile>
<Lib />
<Link>
<AdditionalLibraryDirectories>$(ExternalsDir)glew-1.10.0\lib\Release\$(PlatformName);$(ExternalsDir)glfw-3.0.2\lib-msvc100;$(ExternalsDir)libjpeg;$(ExternalsDir)sdl-2.0.0\lib\$(PlatformName);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>glfw3dll.lib;opengl32.lib;glew32.lib;glu32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ExternalsDir)glfw-3.0.2\lib-msvc100;$(ExternalsDir)libjpeg;$(ExternalsDir)sdl-2.0.0\lib\$(PlatformName);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>glfw3dll.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries>
</Link>

View File

@ -19,7 +19,7 @@
<QtUicExt>.h</QtUicExt>
</UIC>
<MOC>
<QtCommandLine>/I"$(SolutionDir)src" /I"$(ExternalsDir)glew-1.6.0\include" /I"$(ExternalsDir)sdl-1.2.15\include" /I"$(ExternalsDir)qhexedit"</QtCommandLine>
<QtCommandLine>/I"$(SolutionDir)src" /I"$(ExternalsDir)sdl-1.2.15\include" /I"$(ExternalsDir)qhexedit"</QtCommandLine>
<QtKeywords>false</QtKeywords>
</MOC>
<Link />

View File

@ -9,7 +9,7 @@
</Link>
<MOC>
<QtNoDebug>false</QtNoDebug>
<QtCommandLine>/I"$(SolutionDir)src" /I"$(ExternalsDir)glew-1.6.0\include" /I"$(ExternalsDir)sdl-1.2.15\include" /I"$(ExternalsDir)qhexedit" /D"_DEBUG"</QtCommandLine>
<QtCommandLine>/I"$(SolutionDir)src" /I"$(ExternalsDir)sdl-1.2.15\include" /I"$(ExternalsDir)qhexedit" /D"_DEBUG"</QtCommandLine>
</MOC>
<PostBuildEvent>
<Command>xcopy "$(QtBinaryDir)QtCored4.dll" "$(EmuBinDir)" /Y /S /D