OPENGL: Resolve OpenGL functions on run-time.
Formerly we relied on static linkage. However, in the presense of modern OpenGL (ES) implementations it is not easily identifable which library to link against. For example, on Linux amd64 with nVidia drivers and SDL2 setup to create a GLES 1.1 context one would need to link against libGL.so. However, traditionally GLES 1.1 required to link against libGLESv1_CM.so. To prevent a huge mess we simply resolve the OpenGL functions on run-time now and stop linking against a static library (in most cases). GLES support needs to be enabled manually on configure time for now. Tizen changes have NOT been tested.
This commit is contained in:
parent
b3b3d37e3b
commit
4a781737c1
13 changed files with 419 additions and 202 deletions
69
backends/graphics/opengl/context.cpp
Normal file
69
backends/graphics/opengl/context.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "backends/graphics/opengl/opengl-sys.h"
|
||||
#include "backends/graphics/opengl/opengl-graphics.h"
|
||||
|
||||
#include "common/tokenizer.h"
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
void Context::reset() {
|
||||
NPOTSupported = false;
|
||||
}
|
||||
|
||||
Context g_context;
|
||||
|
||||
void OpenGLGraphicsManager::initializeGLContext() {
|
||||
// Initialize default state.
|
||||
g_context.reset();
|
||||
|
||||
// Load all functions.
|
||||
// We use horrible trickery to silence C++ compilers.
|
||||
// See backends/plugins/sdl/sdl-provider.cpp for more information.
|
||||
assert(sizeof(void (*)()) == sizeof(void *));
|
||||
void *fn = nullptr;
|
||||
#define GL_EXT_FUNC_DEF(ret, name, param) \
|
||||
fn = getProcAddress(#name); \
|
||||
memcpy(&g_context.name, &fn, sizeof(fn))
|
||||
#ifdef USE_BUILTIN_OPENGL
|
||||
#define GL_FUNC_DEF(ret, name, param) g_context.name = &name
|
||||
#else
|
||||
#define GL_FUNC_DEF GL_EXT_FUNC_DEF
|
||||
#endif
|
||||
#include "backends/graphics/opengl/opengl-func.h"
|
||||
#undef GL_EXT_FUNC_DEF
|
||||
#undef GL_FUNC_DEF
|
||||
|
||||
const char *extString = (const char *)g_context.glGetString(GL_EXTENSIONS);
|
||||
|
||||
Common::StringTokenizer tokenizer(extString, " ");
|
||||
while (!tokenizer.empty()) {
|
||||
Common::String token = tokenizer.nextToken();
|
||||
|
||||
if (token == "GL_ARB_texture_non_power_of_two") {
|
||||
g_context.NPOTSupported = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace OpenGL
|
Loading…
Add table
Add a link
Reference in a new issue