1
0
forked from 0ad/0ad

Removes static linking of OpenGL library.

Tested By: Langbart, Stan
Differential Revision: https://code.wildfiregames.com/D4387
This was SVN commit r26104.
This commit is contained in:
Vladislav Belov 2021-12-24 08:02:27 +00:00
parent f9818b7f7a
commit 478164962f
5 changed files with 15 additions and 48 deletions

View File

@ -579,35 +579,6 @@ extern_lib_defs = {
end
end,
},
opengl = {
compile_settings = function()
if os.istarget("windows") then
add_default_include_paths("opengl")
elseif _OPTIONS["gles"] then
pkgconfig.add_includes("glesv2")
elseif not os.istarget("macosx") then
pkgconfig.add_includes("gl")
end
end,
link_settings = function()
if os.istarget("windows") then
add_default_lib_paths("opengl")
add_default_links({
win_names = { "opengl32", "gdi32" },
dbg_suffix = "",
no_delayload = 1, -- delayload seems to cause errors on startup
})
elseif os.istarget("macosx") then
add_default_links({
osx_frameworks = { "OpenGL" },
})
elseif _OPTIONS["gles"] then
pkgconfig.add_links("glesv2")
else
pkgconfig.add_links("gl")
end
end,
},
sdl = {
compile_settings = function()
if os.istarget("windows") then

View File

@ -706,7 +706,6 @@ function setup_all_libs ()
}
extern_libs = {
"boost",
"opengl",
"spidermonkey",
"fmt",
}
@ -747,7 +746,6 @@ function setup_all_libs ()
"spidermonkey",
"sdl", -- key definitions
"libxml2",
"opengl",
"zlib",
"boost",
"enet",
@ -779,7 +777,6 @@ function setup_all_libs ()
"third_party/ogre3d_preprocessor"
}
extern_libs = {
"opengl",
"sdl", -- key definitions
"spidermonkey", -- for graphics/scripting
"boost",
@ -800,7 +797,6 @@ function setup_all_libs ()
extern_libs = {
"boost",
"sdl", -- key definitions
"opengl",
"spidermonkey",
"fmt",
}
@ -818,7 +814,6 @@ function setup_all_libs ()
extern_libs = {
"spidermonkey",
"sdl", -- key definitions
"opengl",
"boost",
"enet",
"tinygettext",
@ -853,7 +848,6 @@ function setup_all_libs ()
"boost",
"sdl",
"openal",
"opengl",
"libpng",
"zlib",
"valgrind",
@ -917,7 +911,7 @@ function setup_all_libs ()
setup_static_lib_project("lowlevel", source_dirs, extern_libs, extra_params)
setup_static_lib_project("gladwrapper", {}, { "opengl", "glad" }, { no_pch = 1 })
setup_static_lib_project("gladwrapper", {}, { "glad" }, { no_pch = 1 })
glad_path = libraries_source_dir.."glad/"
sysincludedirs { glad_path.."include" }
if _OPTIONS["gles"] then
@ -964,7 +958,6 @@ end
-- used for main EXE as well as test
used_extern_libs = {
"opengl",
"sdl",
"libpng",

View File

@ -46,10 +46,6 @@
#include <string.h>
#include <stdarg.h>
#if MSC_VERSION
#pragma comment(lib, "opengl32.lib")
#endif
//----------------------------------------------------------------------------
// extensions

View File

@ -133,6 +133,9 @@ std::unique_ptr<CDevice> CDevice::Create(SDL_Window* window)
if (window)
{
// According to https://wiki.libsdl.org/SDL_CreateWindow we don't need to
// call SDL_GL_LoadLibrary if we have a window with SDL_WINDOW_OPENGL,
// because it'll be called internally for the first created window.
device->m_Window = window;
device->m_Context = SDL_GL_CreateContext(device->m_Window);
if (!device->m_Context)
@ -150,7 +153,6 @@ std::unique_ptr<CDevice> CDevice::Create(SDL_Window* window)
}
else
{
// SDL_GL_GetProcAddress is available because we called SDL_GL_LoadLibrary.
#if OS_WIN
ogl_Init(SDL_GL_GetProcAddress, wutil_GetAppHDC());
#elif defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES

View File

@ -32,6 +32,7 @@
#include "lib/timer.h"
#include "maths/MathUtil.h"
#include "ps/CConsole.h"
#include "ps/CLogger.h"
#include "ps/Filesystem.h"
#include "ps/Profile.h"
#include "ps/Profiler2.h"
@ -97,14 +98,18 @@ MESSAGEHANDLER(InitSDL)
// When running in Atlas, we skip the SDL video initialisation code
// which loads the library, and so SDL_GL_GetProcAddress fails (in
// ogl.cpp importExtensionFunctions).
// (TODO: I think this is meant to be context-independent, i.e. it
// doesn't matter that we're getting extensions from SDL-initialised
// GL stuff instead of from the wxWidgets-initialised GL stuff, but that
// should be checked.)
// So, make sure it's loaded:
SDL_InitSubSystem(SDL_INIT_VIDEO);
SDL_GL_LoadLibrary(NULL); // NULL = use default
// (it shouldn't hurt if this is called multiple times, I think)
// wxWidgets doesn't use a proper approach to dynamically load functions and
// doesn't provide GetProcAddr-like function. Technically we need to call
// SDL_GL_LoadLibrary inside GL device creation, but that might lead to a
// crash on Windows because of a wrong order of initialization between SDL
// and wxWidgets context management. So leave the call as is while it works.
// Refs:
// http://trac.wxwidgets.org/ticket/9213
// http://trac.wxwidgets.org/ticket/9215
if (SDL_GL_LoadLibrary(nullptr) && g_Logger)
LOGERROR("SDL failed to load GL library: '%s'", SDL_GetError());
}
MESSAGEHANDLER(InitGraphics)