Skip to content

Commit 6ae0ef9

Browse files
committed
cleanup
1 parent e49a5eb commit 6ae0ef9

7 files changed

Lines changed: 40 additions & 35 deletions

File tree

src/api/include/projectM-4/core.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ extern "C" {
3838
* If this function returns NULL, in most cases the OpenGL context is not initialized, not made
3939
* current or insufficient to render projectM visuals.
4040
*
41-
* Note: The OpenGL resolver is initialized on the first call to either projectm_create() or projectm_create_with_opengl_load_proc().
41+
* The OpenGL resolver is initialized on the first call to either projectm_create() or projectm_create_with_opengl_load_proc().
4242
* All projectM instances share the same resolver.
4343
*
4444
* @return A projectM handle for the newly created instance that must be used in subsequent API calls.
@@ -54,7 +54,7 @@ PROJECTM_EXPORT projectm_handle projectm_create();
5454
* If this function returns NULL, in most cases the OpenGL context is not initialized, not made
5555
* current or insufficient to render projectM visuals.
5656
*
57-
* Note: The OpenGL resolver is initialized on the first call to either projectm_create() or projectm_create_with_opengl_load_proc().
57+
* The OpenGL resolver is initialized on the first call to either projectm_create() or projectm_create_with_opengl_load_proc().
5858
* All projectM instances share the same resolver, and subsequent calls ignore the provided load_proc.
5959
*
6060
* @return A projectM handle for the newly created instance that must be used in subsequent API calls.

src/libprojectM/Renderer/Platform/DynamicLibrary.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ DynamicLibrary::~DynamicLibrary()
258258
}
259259

260260
// Absolute path heuristics for Win32:
261-
// - "C:\\..." (drive)
262-
// - "\\\\server\\share..." (UNC)
261+
// - "C:\\path\\to\\library.dll" (drive)
262+
// - "\\\\server\\share\\library.dll" (UNC)
263263
const bool isDriveAbs = (std::strlen(dllPath) > 2u) && (dllPath[1] == ':') &&
264264
(dllPath[2] == '\\' || dllPath[2] == '/');
265265
const bool isUncAbs = (dllPath[0] == '\\' && dllPath[1] == '\\');
@@ -380,9 +380,10 @@ DynamicLibrary::~DynamicLibrary()
380380
if (m_handle == nullptr)
381381
{
382382
const char* const extraDir = std::getenv("GLRESOLVER_DYLIB_DIR");
383-
if (extraDir != nullptr && extraDir[0] != '\00')
383+
if (extraDir != nullptr && extraDir[0] != '\0')
384384
{
385385
std::string full(extraDir);
386+
LOG_DEBUG(std::string("[DynamicLibrary] using ") + extraDirVar + " to locate: " + name);
386387
if (!full.empty() && full.back() != '/')
387388
{
388389
full.push_back('/');

src/libprojectM/Renderer/Platform/DynamicLibrary.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ class DynamicLibrary
378378

379379
private:
380380
LibHandle m_handle{}; //!< Library handle used to access the system library.
381-
std::string m_loadedName; //< Successfully opened library name.
381+
std::string m_loadedName; //!< Successfully opened library name.
382382
bool m_closeOnDestruct{false}; //!< If true, Close() is called from the destructor.
383383
};
384384

src/libprojectM/Renderer/Platform/GLResolver.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ auto GLResolver::Initialize(UserResolver resolver, void* userData) -> bool
318318

319319
diag += std::string(" glx_get_proc=\"") + (state.m_glxGetProcAddress != nullptr ? "yes" : "no") + "\"";
320320

321-
#if PLATFORM_GLX_ALLOW_CORE_GETPROCADDRESS_FALLBACK
321+
#if GLRESOLVER_GLX_ALLOW_CORE_GETPROCADDRESS_FALLBACK
322322

323323
diag += " glx_policy=\"ext+fallback\"";
324324

@@ -341,7 +341,7 @@ auto GLResolver::Initialize(UserResolver resolver, void* userData) -> bool
341341
m_loaded = false;
342342

343343
// Provide a concrete diagnostic to help debug "no backend" cases.
344-
LOG_ERROR(std::string("[GLResolver] No current GL backend detected. ")
344+
LOG_ERROR(std::string("[GLResolver] No current GL backend detected: ")
345345
+ "egl_current=\"" + (currentContext.eglCurrent ? "yes" : "no") + "\""
346346
+ " wgl_current=\"" + (currentContext.wglCurrent ? "yes" : "no") + "\""
347347
+ " glx_current=\"" + (currentContext.glxCurrent ? "yes" : "no") + "\""
@@ -351,7 +351,7 @@ auto GLResolver::Initialize(UserResolver resolver, void* userData) -> bool
351351
m_initializing = false;
352352
m_initCv.notify_all();
353353
lock.unlock();
354-
LOG_ERROR("[GLResolver] Failed to detect an active GL backend for the current context.");
354+
LOG_ERROR("[GLResolver] Failed to detect an active GL backend for the current context");
355355
return false;
356356
}
357357

@@ -436,13 +436,13 @@ auto GLResolver::GetProcAddress(const char* name) const -> void*
436436

437437
if (m_initializing)
438438
{
439-
LOG_DEBUG(std::string("[GLResolver] GetProcAddress called while initialization is in-flight; waiting."));
439+
LOG_DEBUG(std::string("[GLResolver] GetProcAddress called while initialization is in-flight; waiting"));
440440
m_initCv.wait(lock, [this]() { return !m_initializing; });
441441
}
442442

443443
if (!m_loaded)
444444
{
445-
LOG_ERROR(std::string("[GLResolver] GetProcAddress called without initialization."));
445+
LOG_ERROR(std::string("[GLResolver] GetProcAddress called without initialization"));
446446
return nullptr;
447447
}
448448

@@ -842,7 +842,7 @@ void GLResolver::ResolveProviderFunctions(ResolverState& state)
842842
}
843843
}
844844

845-
LOG_DEBUG(std::string("[GLResolver] EGL get_all_proc_addresses=") + (state.m_eglGetAllProcAddresses ? "yes" : "no"));
845+
LOG_DEBUG(std::string("[GLResolver] EGL get_all_proc_addresses=") + (state.m_eglGetAllProcAddresses ? "yes" : "no"));
846846
}
847847

848848
#ifdef _WIN32

src/libprojectM/Renderer/Platform/GLResolver.hpp

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
#include <mutex>
99
#include <string>
1010

11-
// Optional GLX fallback for resolving non-extension gl* names via glXGetProcAddress*.
11+
// GLX fallback for resolving non-extension gl* names via glXGetProcAddress*.
1212
//
1313
// Default behavior is conservative: only extension-style names are resolved via
1414
// glXGetProcAddress*, because some implementations return non-null for unknown
1515
// symbols which may crash when called.
1616
//
1717
// If support for legacy/non-GLVND stacks is required where some core entry points are not
1818
// exported from libGL/libOpenGL, you may enable this as a last-resort fallback.
19-
#ifndef PLATFORM_GLX_ALLOW_CORE_GETPROCADDRESS_FALLBACK
20-
#define PLATFORM_GLX_ALLOW_CORE_GETPROCADDRESS_FALLBACK 0
19+
#ifndef GLRESOLVER_GLX_ALLOW_CORE_GETPROCADDRESS_FALLBACK
20+
#define GLRESOLVER_GLX_ALLOW_CORE_GETPROCADDRESS_FALLBACK 0
2121
#endif
2222

2323
namespace libprojectM
@@ -111,9 +111,6 @@ using UserResolver = void* (*)(const char* name, void* userData);
111111
*
112112
* Compile-time switches:
113113
*
114-
* - GLRESOLVER_LOADER_DIAGNOSTICS=1
115-
* When enabled, the loader prints diagnostics for unusual ABI situations. Default is disabled.
116-
*
117114
* - GLRESOLVER_ALLOW_UNSAFE_DLL_SEARCH=1 (legacy Windows only)
118115
* If the OS loader does not support LOAD_LIBRARY_SEARCH_* flags (ERROR_INVALID_PARAMETER),
119116
* this loader tries to load from explicit safe locations (application directory and
@@ -122,6 +119,13 @@ using UserResolver = void* (*)(const char* name, void* userData);
122119
* (which can consult legacy search paths such as the process current working directory).
123120
* This is disabled by default for security hardening.
124121
*
122+
* - GLRESOLVER_GLX_ALLOW_CORE_GETPROCADDRESS_FALLBACK=1
123+
* Enable GLX fallback for resolving non-extension gl* names via glXGetProcAddress*.
124+
* Disabled by default.
125+
*
126+
* - GLRESOLVER_LOADER_DIAGNOSTICS=1
127+
* When enabled, the loader prints diagnostics for unusual ABI situations. Default is disabled.
128+
*
125129
* - USE_GLES
126130
* Switch for compile-time API selection:
127131
*
@@ -154,7 +158,7 @@ using UserResolver = void* (*)(const char* name, void* userData);
154158
* - EGL: Try to resolve function via eglGetProcAddress as fallback.
155159
* Always enabled.
156160
* - GLX: Try to resolve function via glXGetProcAddress as fallback.
157-
* Optional, enabled via PLATFORM_GLX_ALLOW_CORE_GETPROCADDRESS_FALLBACK.
161+
* Optional, enabled via GLRESOLVER_GLX_ALLOW_CORE_GETPROCADDRESS_FALLBACK.
158162
*
159163
* Resolution order (Emscripten/WebGL):
160164
*
@@ -345,24 +349,24 @@ class GLResolver
345349
*/
346350
struct CurrentContextProbe
347351
{
348-
bool eglLibOpened{false};
349-
bool eglAvailable{false};
350-
bool eglCurrent{false};
352+
bool eglLibOpened{false}; //!< True if an EGL library was opened.
353+
bool eglAvailable{false}; //!< True if EGL entry points were resolved.
354+
bool eglCurrent{false}; //!< True if an EGL context appears current.
351355

352-
bool glxLibOpened{false};
353-
bool glxAvailable{false};
354-
bool glxCurrent{false};
356+
bool glxLibOpened{false}; //!< True if a GLX library was opened.
357+
bool glxAvailable{false}; //!< True if GLX entry points were resolved.
358+
bool glxCurrent{false}; //!< True if a GLX context appears current.
355359

356-
bool wglLibOpened{false};
357-
bool wglAvailable{false};
358-
bool wglCurrent{false};
360+
bool wglLibOpened{false}; //!< True if a WGL library was opened.
361+
bool wglAvailable{false}; //!< True if WGL entry points were resolved.
362+
bool wglCurrent{false}; //!< True if a WGL context appears current.
359363

360364
bool cglLibOpened{false};
361-
bool cglAvailable{false};
362-
bool cglCurrent{false};
365+
bool cglAvailable{false}; //!< True if CGL entry points were resolved.
366+
bool cglCurrent{false}; //!< True if a CGL context appears current.
363367

364-
bool webglAvailable{false};
365-
bool webglCurrent{false};
368+
bool webglAvailable{false}; //!< True if WebGL entry points were resolved.
369+
bool webglCurrent{false}; //!< True if a WebGL context appears current.
366370
};
367371

368372
/**

src/libprojectM/Renderer/Platform/GladLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ auto GladLoader::LoadGlad() -> bool
9393

9494
if (!GLResolver::Instance().IsLoaded())
9595
{
96-
LOG_ERROR(std::string("[GladLoader] Cannot load GLAD, GLResolver is not initialized"));
96+
LOG_ERROR(std::string("[GladLoader] Cannot load GLAD: GLResolver is not initialized"));
9797
return false;
9898
}
9999

src/libprojectM/Renderer/Platform/GladLoader.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Renderer {
77
namespace Platform {
88

99
/**
10-
* @brief Helper for GLAD loading and GL projectM specific GL requirements checks.
10+
* @brief Helper for GLAD loading and projectM-specific GL requirements checks.
1111
*
1212
* @note This loader is a process-singleton.
1313
* @note The GLResolver needs to be initialized first, before using this loader.
@@ -44,7 +44,7 @@ class GladLoader
4444
auto CheckGLRequirements() -> bool;
4545

4646

47-
bool m_isLoaded{false}; //!< Flag to indicate is GLAD has been loaded.
47+
bool m_isLoaded{false}; //!< Flag indicating whether GLAD has been loaded.
4848
mutable std::mutex m_mutex; //!< Mutex to synchronize initialization.
4949
};
5050

0 commit comments

Comments
 (0)