From 2957db19e5f2594417f8c92e47fcd42b009e9e33 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 25 Feb 2021 23:06:10 +1100 Subject: [PATCH] Simplify dynamic symbol stuff a little bit --- readme.md | 7 ++----- src/Audio.c | 27 ++++++++++++--------------- src/Graphics.c | 16 ++++++++-------- src/Http.c | 12 +++++------- src/Platform.h | 4 ++++ 5 files changed, 31 insertions(+), 35 deletions(-) diff --git a/readme.md b/readme.md index 903c4696c..d9924035c 100644 --- a/readme.md +++ b/readme.md @@ -32,12 +32,9 @@ Run ClassiCube.exe, then click Singleplayer at the main menu. Run ClassiCube.exe. You can connect to LAN/locally hosted servers, ~~minecraft.net servers,~~ and classicube.net servers through the launcher. ###### *Stuck with OpenGL 1.1 due to old graphics hardware?* -Compile the game yourself with the following flag described below. For compiling the game, see the corresponding command for BSD, macOS (32 bit or 64 bit), or Linux operating systems. +If you're on Windows, you should first try using the MESA software renderer from [here](http://download.qt.io/development_releases/prebuilt/llvmpipe/windows/). Typically though, this occurs because you have not installed GPU drivers. -*If you need to use the OpenGL 1.1 hardware renderer due to a non upgradable, older GPU, such as an ATI RAGE series card in an older laptop or PowerPC Mac with an integrated ATI or nVidia chip, add `-DCC_BUILD_GL11` as a compilation flag **before the optimize flag**. The game **will not run** without this flag on older GPUs under the above operating systems. - -###### *Windows specific* -*If you are stuck using the built-in OpenGL 1.1 software renderer, you can use the MESA software renderer from [here](http://download.qt.io/development_releases/prebuilt/llvmpipe/windows/) for slightly better performance. Typically though, this occurs because you have not installed GPU drivers.* +Otherwise, you will have to [compile the game yourself](#using-visual-studio-command-line). Don't forget to add `-DCC_BUILD_GL11` to the compilation command line so that the compiled game supports OpenGL 1.1. ### Compiling - Windows diff --git a/src/Audio.c b/src/Audio.c index 81b2d2ca0..c9fb96663 100644 --- a/src/Audio.c +++ b/src/Audio.c @@ -16,9 +16,6 @@ /* TODO: Refactor maybe to not rely on checking WinInfo.Handle != NULL */ #include "Window.h" #endif - -#define QUOTE(x) #x -#define DefineDynFunc(sym) { QUOTE(sym), (void**)&_ ## sym } int Audio_SoundsVolume, Audio_MusicVolume; #if defined CC_BUILD_NOAUDIO @@ -133,16 +130,16 @@ static const cc_string alLib = String_FromConst("libopenal.so.1"); static cc_bool LoadALFuncs(void) { static const struct DynamicLibSym funcs[18] = { - DefineDynFunc(alcCreateContext), DefineDynFunc(alcMakeContextCurrent), - DefineDynFunc(alcDestroyContext), DefineDynFunc(alcOpenDevice), - DefineDynFunc(alcCloseDevice), DefineDynFunc(alcGetError), + DynamicLib_Sym(alcCreateContext), DynamicLib_Sym(alcMakeContextCurrent), + DynamicLib_Sym(alcDestroyContext), DynamicLib_Sym(alcOpenDevice), + DynamicLib_Sym(alcCloseDevice), DynamicLib_Sym(alcGetError), - DefineDynFunc(alGetError), DefineDynFunc(alGenSources), - DefineDynFunc(alDeleteSources), DefineDynFunc(alGetSourcei), - DefineDynFunc(alSourcePlay), DefineDynFunc(alSourceStop), - DefineDynFunc(alSourceQueueBuffers), DefineDynFunc(alSourceUnqueueBuffers), - DefineDynFunc(alGenBuffers), DefineDynFunc(alDeleteBuffers), - DefineDynFunc(alBufferData), DefineDynFunc(alDistanceModel) + DynamicLib_Sym(alGetError), DynamicLib_Sym(alGenSources), + DynamicLib_Sym(alDeleteSources), DynamicLib_Sym(alGetSourcei), + DynamicLib_Sym(alSourcePlay), DynamicLib_Sym(alSourceStop), + DynamicLib_Sym(alSourceQueueBuffers), DynamicLib_Sym(alSourceUnqueueBuffers), + DynamicLib_Sym(alGenBuffers), DynamicLib_Sym(alDeleteBuffers), + DynamicLib_Sym(alBufferData), DynamicLib_Sym(alDistanceModel) }; void* lib = DynamicLib_Load2(&alLib); @@ -406,9 +403,9 @@ static const cc_string slLib = String_FromConst("libOpenSLES.so"); static cc_bool LoadSLFuncs(void) { static const struct DynamicLibSym funcs[5] = { - DefineDynFunc(slCreateEngine), DefineDynFunc(SL_IID_NULL), - DefineDynFunc(SL_IID_PLAY), DefineDynFunc(SL_IID_ENGINE), - DefineDynFunc(SL_IID_BUFFERQUEUE) + DynamicLib_Sym(slCreateEngine), DynamicLib_Sym(SL_IID_NULL), + DynamicLib_Sym(SL_IID_PLAY), DynamicLib_Sym(SL_IID_ENGINE), + DynamicLib_Sym(SL_IID_BUFFERQUEUE) }; void* lib = DynamicLib_Load2(&slLib); diff --git a/src/Graphics.c b/src/Graphics.c index 8e8acf001..cbae50271 100644 --- a/src/Graphics.c +++ b/src/Graphics.c @@ -2196,18 +2196,18 @@ void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) { static void GL_CheckSupport(void) { static const struct DynamicLibSym coreVboFuncs[5] = { - { "glBindBuffer", (void**)&_glBindBuffer }, { "glDeleteBuffers", (void**)&_glDeleteBuffers }, - { "glGenBuffers", (void**)&_glGenBuffers }, { "glBufferData", (void**)&_glBufferData }, - { "glBufferSubData", (void**)&_glBufferSubData } + DynamicLib_Sym2("glBindBuffer", glBindBuffer), DynamicLib_Sym2("glDeleteBuffers", glDeleteBuffers), + DynamicLib_Sym2("glGenBuffers", glGenBuffers), DynamicLib_Sym2("glBufferData", glBufferData), + DynamicLib_Sym2("glBufferSubData", glBufferSubData) }; static const struct DynamicLibSym arbVboFuncs[5] = { - { "glBindBufferARB", (void**)&_glBindBuffer }, { "glDeleteBuffersARB", (void**)&_glDeleteBuffers }, - { "glGenBuffersARB", (void**)&_glGenBuffers }, { "glBufferDataARB", (void**)&_glBufferData }, - { "glBufferSubDataARB", (void**)&_glBufferSubData } + DynamicLib_Sym2("glBindBufferARB", glBindBuffer), DynamicLib_Sym2("glDeleteBuffersARB", glDeleteBuffers), + DynamicLib_Sym2("glGenBuffersARB", glGenBuffers), DynamicLib_Sym2("glBufferDataARB", glBufferData), + DynamicLib_Sym2("glBufferSubDataARB", glBufferSubData) }; static const cc_string vboExt = String_FromConst("GL_ARB_vertex_buffer_object"); - cc_string extensions = String_FromReadonly((const char*)glGetString(GL_EXTENSIONS)); - const GLubyte* ver = glGetString(GL_VERSION); + cc_string extensions = String_FromReadonly((const char*)glGetString(GL_EXTENSIONS)); + const GLubyte* ver = glGetString(GL_VERSION); /* Version string is always: x.y. (and whatever afterwards) */ int major = ver[0] - '0', minor = ver[2] - '0'; diff --git a/src/Http.c b/src/Http.c index 4da837376..ea47f64a7 100644 --- a/src/Http.c +++ b/src/Http.c @@ -497,17 +497,15 @@ static const cc_string curlLib = String_FromConst("libcurl.so.4"); static const cc_string curlAlt = String_FromConst("libcurl.so.3"); #endif -#define QUOTE(x) #x -#define DefineCurlFunc(sym) { QUOTE(sym), (void**)&_ ## sym } static cc_bool LoadCurlFuncs(void) { static const struct DynamicLibSym funcs[8] = { - DefineCurlFunc(curl_global_init), DefineCurlFunc(curl_global_cleanup), - DefineCurlFunc(curl_easy_init), DefineCurlFunc(curl_easy_perform), - DefineCurlFunc(curl_easy_setopt), DefineCurlFunc(curl_easy_cleanup), - DefineCurlFunc(curl_slist_free_all), DefineCurlFunc(curl_slist_append) + DynamicLib_Sym(curl_global_init), DynamicLib_Sym(curl_global_cleanup), + DynamicLib_Sym(curl_easy_init), DynamicLib_Sym(curl_easy_perform), + DynamicLib_Sym(curl_easy_setopt), DynamicLib_Sym(curl_easy_cleanup), + DynamicLib_Sym(curl_slist_free_all), DynamicLib_Sym(curl_slist_append) }; /* Non-essential function missing in older curl versions */ - static const struct DynamicLibSym optFuncs[1] = { DefineCurlFunc(curl_easy_strerror) }; + static const struct DynamicLibSym optFuncs[1] = { DynamicLib_Sym(curl_easy_strerror) }; void* lib = DynamicLib_Load2(&curlLib); if (!lib) { diff --git a/src/Platform.h b/src/Platform.h index b3eedcc32..d754d5efa 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -96,6 +96,10 @@ CC_API cc_bool DynamicLib_DescribeError(cc_string* dst); /* The default file extension used for dynamic libraries on this platform. */ extern const cc_string DynamicLib_Ext; +#define DYNAMICLIB_QUOTE(x) #x +#define DynamicLib_Sym(sym) { DYNAMICLIB_QUOTE(sym), (void**)&_ ## sym } +#define DynamicLib_Sym2(name, sym) { name, (void**)&_ ## sym } + CC_API cc_result DynamicLib_Load(const cc_string* path, void** lib); /* OBSOLETE */ CC_API cc_result DynamicLib_Get(void* lib, const char* name, void** symbol); /* OBSOLETE */ /* Contains a name and a pointer to variable that will hold the loaded symbol */