Skip to content

Commit

Permalink
update gl linking
Browse files Browse the repository at this point in the history
  • Loading branch information
ColleagueRiley committed Jan 7, 2025
1 parent 0d275db commit c0e6e0b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions examples/gl33/gl33.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <GLES3/gl3.h>
#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
Expand Down

0 comments on commit c0e6e0b

Please sign in to comment.