From c0e6e0bdee10bbfba46e03bd3dd66b97263e864a Mon Sep 17 00:00:00 2001 From: ColleagueRiley Date: Mon, 6 Jan 2025 22:17:21 -0500 Subject: [PATCH] update gl linking --- Makefile | 8 ++++++++ README.md | 19 ++++++++++++++++++- examples/gl33/gl33.c | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 96cec5ca..feb4fe3d 100644 --- a/Makefile +++ b/Makefile @@ -211,7 +211,15 @@ examples/first-person-camera/camera: examples/first-person-camera/camera.c RGFW. examples/gl33/gl33: examples/gl33/gl33.c RGFW.h +ifeq ($(detected_OS),Linux) + $(CC) $(CFLAGS) -I. $< -o $@$(EXT) +else ifeq ($(detected_OS),windows) + $(CC) $(CFLAGS) $(WARNINGS) -I. $< -lgdi32 -o $@$(EXT) +else ifeq ($(detected_OS),Darwin) + $(CC) $(CFLAGS) $(WARNINGS) -I. $< -framework Cocoa -o $@$(EXT) +else $(CC) $(CFLAGS) $(WARNINGS) -I. $< $(LIBS) $(LINK_GL3) -o $@$(EXT) +endif $(EXAMPLE_OUTPUTS): %: %.c RGFW.h $(CC) $(CFLAGS) $(WARNINGS) -I. $< $(LIBS) $(LINK_GL1) -o $@$(EXT) diff --git a/README.md b/README.md index 7c3f2926..159261e5 100755 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ This library 2) is very small compared to other libraries 3) only depends on system API libraries, Winapi, X11, Cocoa 4) lets you create a window with a graphics context (OpenGL, Vulkan or DirectX) and manage the window and its events only with a few function calls +5) is customizable, you enable or disable features This library does not @@ -91,6 +92,22 @@ windows : gcc main.c -lopengl32 -lgdi32 macos : gcc main.c -framework Cocoa -framework OpenGL -framework IOKit ``` +## Dynamic Linking with XDL.h +XDL can be used to dynamically link X11 functions to RGFW using `dl`. It allows X11 functions to loaded at runtime. + +To enable RGFW's use of XDL, add this line to your code: + +```c +#define RGFW_USE_XDL +``` + +## OpenGL Linking Considerations + This only applies to Windows, macOS and X11 (if you're using `XDL.h`): + + By default, OpenGL does not need to be explicitly linked unless you are directly using OpenGL functions in your code. If you rely on a OpenGL loader library, you don't need to explicitly link OpenGL at all! + + The examples/gl33/gl33 example demonstrates using OpenGL without explicitly linking it. + ## other examples ![examples](screenshot.PNG) @@ -99,7 +116,7 @@ You can find more examples [here](examples) or [run it in your browser](https:// # Officially tested Platforms - Windows (ReactOS, XP, Windows 10, 11) - Linux -- MacOS (10.13, 10.14, 14.5) (x86_64) +- MacOS (10.13, 10.14, 10.15) (x86_64) - HTML5 (webasm / Emscripten) - Raspberry PI OS diff --git a/examples/gl33/gl33.c b/examples/gl33/gl33.c index d55f27bb..55e1464a 100644 --- a/examples/gl33/gl33.c +++ b/examples/gl33/gl33.c @@ -15,6 +15,7 @@ #include #endif +#define RGFW_USE_XDL // feel free to remove this line if you don't want to use XDL (-lX11 -lXrandr -lGLX will be required) #define RGFW_ALLOC_DROPFILES #define RGFW_IMPLEMENTATION #define RGFW_PRINT_ERRORS