Skip to content

Commit aa35b56

Browse files
committed
Added utility functions.
1 parent f6ee269 commit aa35b56

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

examples/camera3d.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ program main
8181
camera%projection = CAMERA_ORTHOGRAPHIC
8282
camera%fov_y = 20.0 ! near plane width in CAMERA_ORTHOGRAPHIC
8383

84-
call camera_yaw(camera, -135 * (PI / 180.0), .true._c_bool)
85-
call camera_pitch(camera, -45 * (PI / 180.0), .true._c_bool, .true._c_bool, .false._c_bool)
84+
call camera_yaw(camera, deg2rad(-135.0), .true._c_bool)
85+
call camera_pitch(camera, deg2rad(-45.0), .true._c_bool, .true._c_bool, .false._c_bool)
8686
else if (camera%projection == CAMERA_ORTHOGRAPHIC) then
8787
! Reset to default view
8888
camera_mode = CAMERA_THIRD_PERSON

examples/plane.f90

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,7 @@ program main
9191
end if
9292
end if
9393

94-
rotation%x = pitch * (PI / 180.0)
95-
rotation%y = yaw * (PI / 180.0)
96-
rotation%z = roll * (PI / 180.0)
97-
94+
rotation = vector3_type(deg2rad(pitch), deg2rad(yaw), deg2rad(roll))
9895
model%transform = matrix_rotate_xyz(rotation)
9996

10097
call begin_drawing()

src/raylib.f90

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,9 @@ module raylib
11981198
public :: wave_format
11991199
public :: window_should_close
12001200

1201+
public :: deg2rad
1202+
public :: rad2deg
1203+
12011204
interface
12021205
! void AttachAudioMixedProcessor(AudioCallback processor)
12031206
subroutine attach_audio_mixed_processor(processor) bind(c, name='AttachAudioMixedProcessor')
@@ -5560,4 +5563,16 @@ function window_should_close() bind(c, name='WindowShouldClose')
55605563
logical(kind=c_bool) :: window_should_close
55615564
end function window_should_close
55625565
end interface
5566+
contains
5567+
elemental real function deg2rad(d) result(r)
5568+
real, intent(in) :: d
5569+
5570+
r = d * (PI / 180.0)
5571+
end function deg2rad
5572+
5573+
elemental real function rad2deg(r) result(d)
5574+
real, intent(in) :: r
5575+
5576+
d = r * (180.0 / PI)
5577+
end function rad2deg
55635578
end module raylib

0 commit comments

Comments
 (0)