Skip to content

Commit deeaee4

Browse files
committed
Updated to raylib 5.5.
1 parent 143abd5 commit deeaee4

File tree

10 files changed

+341
-4177
lines changed

10 files changed

+341
-4177
lines changed

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
FC = gfortran
55
AR = ar
6-
FFLAGS = -g -std=f2018 -Wall -Wno-conversion -fmax-errors=1 -fno-range-check
6+
FFLAGS = -O2 -std=f2018 -Wall -Wno-conversion -fmax-errors=1 -fno-range-check
77
ARFLAGS = rcs
8-
LDFLAGS = -L/usr/local/lib/ -I./include/
8+
LDFLAGS = -L/usr/local/lib
99
RAYLIB = -lraylib
10-
LDLIBS = $(RAYLIB) -lGL -lpthread -lm
10+
LDLIBS = $(RAYLIB) -lglfw -lGL -lpthread -lm
1111
TARGET = libfortran-raylib.a
1212

1313
.PHONY: all clean examples
@@ -21,8 +21,8 @@ $(TARGET): src/raylib.f90 src/raylib_util.f90
2121
$(FC) $(FFLAGS) -c src/raylib_util.f90
2222
$(AR) $(ARFLAGS) $(TARGET) raylib.o raylib_camera.o raylib_math.o raylib_util.o
2323

24-
examples: bunny camera camera3d castle collision cubes explosion flags font geometric julia keys \
25-
log map maze plane shapes truck window
24+
examples: bunny camera camera3d castle collision cubes explosion flags font \
25+
geometric julia keys log map maze plane shapes ship window
2626

2727
bunny: $(TARGET) examples/bunny.f90
2828
$(FC) $(FFLAGS) $(LDFLAGS) -o bunny examples/bunny.f90 $(TARGET) $(LDLIBS)
@@ -75,8 +75,8 @@ plane: $(TARGET) examples/plane.f90
7575
shapes: $(TARGET) examples/shapes.f90
7676
$(FC) $(FFLAGS) $(LDFLAGS) -o shapes examples/shapes.f90 $(TARGET) $(LDLIBS)
7777

78-
truck: $(TARGET) examples/truck.f90
79-
$(FC) $(FFLAGS) $(LDFLAGS) -o truck examples/truck.f90 $(TARGET) $(LDLIBS)
78+
ship: $(TARGET) examples/ship.f90
79+
$(FC) $(FFLAGS) $(LDFLAGS) -o ship examples/ship.f90 $(TARGET) $(LDLIBS)
8080

8181
window: $(TARGET) examples/window.f90
8282
$(FC) $(FFLAGS) $(LDFLAGS) -o window examples/window.f90 $(TARGET) $(LDLIBS)
@@ -102,5 +102,5 @@ clean:
102102
if [ -e maze ]; then rm maze; fi
103103
if [ -e plane ]; then rm plane; fi
104104
if [ -e shapes ]; then rm shapes; fi
105-
if [ -e truck ]; then rm truck; fi
105+
if [ -e ship ]; then rm ship; fi
106106
if [ -e window ]; then rm window; fi

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
# fortran-raylib
22

33
A work-in-progress collection of interface bindings to
4-
[raylib](https://www.raylib.com/) 4.5/4.6/5.0/5.1, for 2-D and 3-D game
5-
programming in Fortran 2018.
4+
[raylib](https://www.raylib.com/) 5.5, for 2-D and 3-D game programming in
5+
Fortran 2018.
66

77
## Build Instructions
88

99
Install the raylib package suitable for your operating system, or build from
10-
[source](https://github.com/raysan5/raylib/releases/tag/5.0):
10+
[source](https://github.com/raysan5/raylib/releases/tag/5.5):
1111

1212
```
13-
$ cd raylib-5.0/
13+
$ cd raylib-5.5/
1414
$ mkdir build && cd build/
1515
$ cmake ..
1616
$ make PLATFORM=PLATFORM_DESKTOP
17+
$ make install
1718
```
18-
Select platform `PLATFORM_DESKTOP_SDL` for the SDL 2.0 backend instead:
19+
Select platform `PLATFORM_DESKTOP_SDL` for the SDL 2.0 back-end:
1920

2021
```
2122
$ make PLATFORM=PLATFORM_DESKTOP_SDL
@@ -64,7 +65,7 @@ additional platform-dependent libraries:
6465

6566
| System | Linker Libraries |
6667
|-----------------|----------------------------------------------------------------------------------------------------------|
67-
| FreeBSD | `-lraylib -lGL -lpthread -lm` |
68+
| FreeBSD | `-lraylib -lglfw -lGL -lpthread -lm` |
6869
| Linux | `-lraylib -lGL -lm -lpthread -ldl -lrt -lX11` |
6970
| Linux (Wayland) | `-lraylib -lGL -lm -lpthread -ldl -lrt -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon` |
7071
| macOS | `-lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo` |
@@ -102,11 +103,13 @@ end program main
102103
Compile and link the example program:
103104

104105
```
105-
$ gfortran -L/usr/local/lib -I/usr/local/include -o example example.f90 \
106-
libfortran-raylib.a -lraylib -lGL -lpthread -lm
106+
$ gfortran -L/usr/local/lib -o example example.f90 libfortran-raylib.a -lraylib -lGL -lpthread -lm
107107
$ ./example
108108
```
109109

110+
Depending on the build flags chosen for *raylib*, you may have to link with
111+
`-lglfw` additionally.
112+
110113
## Further Examples
111114

112115
More examples can be found in `examples/`:
@@ -128,7 +131,7 @@ More examples can be found in `examples/`:
128131
* **maze** renders a 3-D maze in first-person view.
129132
* **plane** demonstrates pitch/yaw/roll of a 3-D model.
130133
* **shapes** renders basic shapes.
131-
* **truck** rotates a 3-D model loaded from file.
134+
* **ship** rotates a 3-D model loaded from file.
132135
* **window** opens a window with raylib.
133136

134137
Build all examples with:
@@ -147,7 +150,7 @@ $ make examples RAYLIB=libraylib.a
147150

148151
Some issues have to be regarded when calling raylib from Fortran:
149152

150-
* Model loading is broken in raylib 5.0
153+
* Loading models in Wavefront OBJ format is broken since raylib 5.0
151154
([issue](https://github.com/raysan5/raylib/issues/3576)).
152155
* All procedure names and dummy arguments have been converted to snake case.
153156
* As Fortran does not feature unsigned data types, use the compiler flag
@@ -161,7 +164,7 @@ Some issues have to be regarded when calling raylib from Fortran:
161164
* If a function returns `type(c_ptr)`, the result has to be converted to a
162165
Fortran pointer with the intrinsic subroutine `c_f_pointer()` first. C char
163166
pointers may be converted with utility subroutine `c_f_str_ptr()` from module
164-
`raylib_util`.
167+
`raylib_util`, or the intrinsic `c_f_strpointer()` (Fortran 2023).
165168

166169
## Licence
167170

examples/castle.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ subroutine set_model_diffuse(model, texture)
6363
type(material_map_type), pointer :: material_map_ptrs(:)
6464

6565
! We have to add 1 to the array indices as a work-around, as we can't set
66-
! the lower bounds of the pointer arrays with `c_f_pointer()`.
66+
! the lower bounds of the pointer arrays with `c_f_pointer()` yet
67+
! (new Fortran 2023 feature).
6768
call c_f_pointer(model%materials, material_ptrs, [ model%material_count ])
6869
call c_f_pointer(material_ptrs(1)%maps, material_map_ptrs, [ MATERIAL_MAP_BRDF + 1 ])
6970
material_map_ptrs(MATERIAL_MAP_DIFFUSE + 1)%texture = texture

examples/map.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ subroutine set_model_diffuse(model, texture)
7272
type(material_map_type), pointer :: material_map_ptrs(:)
7373

7474
! We have to add 1 to the array indices as a work-around, as we can't set
75-
! the lower bounds of the pointer arrays with `c_f_pointer()`.
75+
! the lower bounds of the pointer arrays with `c_f_pointer()` yet
76+
! (new Fortran 2023 feature).
7677
call c_f_pointer(model%materials, material_ptrs, [ model%material_count ])
7778
call c_f_pointer(material_ptrs(1)%maps, material_map_ptrs, [ MATERIAL_MAP_BRDF + 1 ])
7879
material_map_ptrs(MATERIAL_MAP_DIFFUSE + 1)%texture = texture

examples/truck.f90 renamed to examples/ship.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
! truck.f90
1+
! ship.f90
22
!
33
! Example program that rotates a 3-D model loaded from file. Enables VSync and
44
! MSAA4.
55
!
6-
! Model (CC0) source: https://kenney.nl/assets/car-kit
6+
! Model (CC0) source: https://opengameart.org/content/lowpoly-ship-pack
77
!
88
! Author: Philipp Engel
99
! Licence: ISC
@@ -33,7 +33,7 @@ program main
3333
camera%fov_y = 45.0
3434
camera%projection = CAMERA_PERSPECTIVE
3535

36-
model = load_model('share/truck.obj' // c_null_char)
36+
model = load_model('share/ship.glb' // c_null_char)
3737

3838
angle = 0.0
3939
rotation = vector3_type(0.0, 1.0, 0.0)

fpm.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description = "Fortran 2018 ISO C binding interfaces to raylib"
88
keywords = [ "graphics", "raylib" ]
99

1010
[build]
11-
link = [ "raylib", "GL", "pthread", "m" ]
11+
link = [ "raylib", "glfw", "GL", "pthread", "m" ]
1212

1313
[library]
1414
source-dir = "src"
@@ -103,8 +103,8 @@ main = "shapes.f90"
103103

104104
[[executable]]
105105
source-dir = "examples"
106-
name = "truck"
107-
main = "truck.f90"
106+
name = "ship"
107+
main = "ship.f90"
108108

109109
[[executable]]
110110
source-dir = "examples"

share/ship.glb

177 KB
Binary file not shown.

share/truck.mtl

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)