- replaced GLEW with GLLoadGen for GL access. This allows to have a header that only contains what's actually required, namely OpenGL 3.3 plus glBegin and glEnd which are the only compatibility functions needed for the fallback render path.

GLEW has two major problems:

- it always includes everything, there is no way to restrict the header to a specific GL version
- it is mostly broken with a core profile and only works if all sanity checks get switched off.
This commit is contained in:
Christoph Oelckers 2014-08-21 11:02:46 +02:00
parent 6f65bccf1c
commit e132fc5eed
7 changed files with 3156 additions and 43 deletions

View file

@ -239,33 +239,6 @@ set( ZDOOM_LIBS ${ZDOOM_LIBS} ${OPENGL_LIBRARIES} )
include_directories( ${OPENGL_INCLUDE_DIR} )
# check for GLEW
find_path( GLEW_INCLUDE_DIR GL/glew.h
PATHS "/usr/include"
"/usr/local/include" )
if( GLEW_INCLUDE_DIR )
message( STATUS "GLEW include files found at ${GLEW_INCLUDE_DIR}" )
else( GLEW_INCLUDE_DIR )
message( SEND_ERROR "Could not find GLEW include files" )
endif( GLEW_INCLUDE_DIR )
# GLEW include directory
include_directories( "${GLEW_INCLUDE_DIR}" )
if( NOT WIN32 OR APPLE )
find_library( GLEW_LIBRARY libGLEW.so )
else( NOT WIN32 OR APPLE )
find_library( GLEW_LIBRARY glew32 )
endif( NOT WIN32 OR APPLE )
if( NOT GLEW_LIBRARY )
message( SEND_ERROR "Could not find GLEW library files" )
endif( NOT GLEW_LIBRARY )
set( ZDOOM_LIBS ${ZDOOM_LIBS} ${GLEW_LIBRARY} )
# Decide on the name of the FMOD library we want to use.
if( NOT FMOD_LIB_NAME AND MSVC )
@ -1099,6 +1072,7 @@ add_executable( zdoom WIN32
gl/system/gl_framebuffer.cpp
gl/system/gl_menu.cpp
gl/system/gl_wipe.cpp
gl/system/gl_load.c
gl/models/gl_models_md3.cpp
gl/models/gl_models_md2.cpp
gl/models/gl_models.cpp

View file

@ -121,8 +121,7 @@ void OpenGLFrameBuffer::InitializeState()
if (first)
{
glewExperimental=true;
glewInit();
ogl_LoadFunctions();
}
gl_LoadExtensions();
@ -537,3 +536,4 @@ void OpenGLFrameBuffer::GameRestart()
LastCamera = NULL;
gl_GenerateGlobalBrightmapFromColormap();
}

1344
src/gl/system/gl_load.c Normal file

File diff suppressed because it is too large Load diff

1793
src/gl/system/gl_load.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -67,13 +67,10 @@
#include <fcntl.h>
//GL headers
#include <GL/glew.h>
#include "gl_load.h"
#if defined(__APPLE__)
#include <OpenGL/OpenGL.h>
#elif defined(__unix__)
//#include <GL/glxew.h>
#else // !__APPLE__ && !__unix__
#endif
#ifdef _WIN32

View file

@ -1,13 +1,15 @@
#include "gl/system/gl_system.h"
#define DWORD WINDOWS_DWORD
#include <GL/wglew.h>
#undef DWORD
//#include "gl/system/gl_system.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <GL/gl.h>
#include "wglext.h"
#define USE_WINDOWS_DWORD
#include "win32iface.h"
#include "win32gliface.h"
//#include "gl/gl_intern.h"
#include "x86.h"
#include "templates.h"
#include "version.h"
#include "c_console.h"
@ -22,8 +24,6 @@
#include "gl/renderer/gl_renderer.h"
#include "gl/system/gl_framebuffer.h"
#include "gl/shaders/gl_shader.h"
#include "gl/utility/gl_templates.h"
void gl_CalculateCPUSpeed();
extern int NewWidth, NewHeight, NewBits, DisplayBits;
@ -726,6 +726,12 @@ bool Win32GLVideo::SetupPixelFormat(int multisample)
//
//==========================================================================
// since we cannot use the extension loader here, before it gets initialized,
// we have to define the extended GL stuff we need, ourselves here.
// The headers generated by GLLoadGen only work if the loader gets initialized.
typedef const GLubyte * (APIENTRY *PFNGLGETSTRINGIPROC)(GLenum, GLuint);
#define GL_NUM_EXTENSIONS 0x821D
bool Win32GLVideo::checkCoreUsability()
{
// if we explicitly want to disable 4.x features this must fail.
@ -734,7 +740,7 @@ bool Win32GLVideo::checkCoreUsability()
// GL 4.4 implies GL_ARB_buffer_storage
if (strcmp((char*)glGetString(GL_VERSION), "4.4") >= 0) return true;
// at this point GLEW has not been initialized so we have to retrieve glGetStringi ourselves.
// at this point the extension loader has not been initialized so we have to retrieve glGetStringi ourselves.
PFNGLGETSTRINGIPROC myglGetStringi = (PFNGLGETSTRINGIPROC)wglGetProcAddress("glGetStringi");
if (!myglGetStringi) return false; // this should not happen.

View file

@ -1,7 +1,6 @@
#ifndef __WIN32GLIFACE_H__
#define __WIN32GLIFACE_H__
#include "gl/system/gl_system.h"
#include "hardware.h"
#include "win32iface.h"
#include "v_video.h"