Skip to content

Use BOZ literal constants for Integer(c_unsigned_char) #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/bunny.f90
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ program main
bunnies(nbunnies)%color = color_type(r = int(get_random_value( 50, 240), c_unsigned_char), &
g = int(get_random_value( 80, 240), c_unsigned_char), &
b = int(get_random_value(100, 240), c_unsigned_char), &
a = int(255, c_unsigned_char))
a = int(Z'FF', c_unsigned_char))
end do
end if

Expand Down
2 changes: 1 addition & 1 deletion examples/maze.f90
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ program main
! Converting 255 into an unsigned char requires the compiler
! flag `-fno-range-check`. Otherwise, we would have to convert
! via the intrinsic `transfer()`.
if (pixels(y * cubic%width + x)%r == int(255, c_unsigned_char) .and. &
if (pixels(y * cubic%width + x)%r == int(Z'FF', c_unsigned_char) .and. &
check_collision_circle_rec(player, radius, rectangle)) then
camera%position = old_camera
end if
Expand Down
78 changes: 49 additions & 29 deletions src/raylib.f90
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ module raylib

! Color
type, bind(c), public :: color_type
integer(kind=c_unsigned_char) :: r = 0_c_unsigned_char
integer(kind=c_unsigned_char) :: g = 0_c_unsigned_char
integer(kind=c_unsigned_char) :: b = 0_c_unsigned_char
integer(kind=c_unsigned_char) :: a = 255_c_unsigned_char
integer(kind=c_unsigned_char) :: r = Int(z'00',c_unsigned_char)
integer(kind=c_unsigned_char) :: g = Int(z'00',c_unsigned_char)
integer(kind=c_unsigned_char) :: b = Int(z'00',c_unsigned_char)
integer(kind=c_unsigned_char) :: a = Int(z'FF',c_unsigned_char)
end type color_type

! Rectangle
Expand Down Expand Up @@ -315,32 +315,52 @@ module raylib
type(c_ptr) :: paths = c_null_ptr !! char **
end type file_path_list_type

type(color_type), parameter, public :: LIGHTGRAY = color_type(200, 200, 200, 255)
type(color_type), parameter, public :: GRAY = color_type(130, 130, 130, 255)
type(color_type), parameter, public :: DARKGRAY = color_type( 80, 80, 80, 255)
type(color_type), parameter, public :: YELLOW = color_type(253, 249, 0, 255)
type(color_type), parameter, public :: GOLD = color_type(255, 203, 0, 255)
type(color_type), parameter, public :: ORANGE = color_type(255, 161, 0, 255)
type(color_type), parameter, public :: PINK = color_type(255, 109, 194, 255)
type(color_type), parameter, public :: RED = color_type(230, 41, 55, 255)
type(color_type), parameter, public :: MAROON = color_type(190, 33, 55, 255)
type(color_type), parameter, public :: GREEN = color_type( 0, 228, 48, 255)
type(color_type), parameter, public :: LIME = color_type( 0, 158, 47, 255)
type(color_type), parameter, public :: DARKGREEN = color_type( 0, 117, 44, 255)
type(color_type), parameter, public :: SKYBLUE = color_type(102, 191, 255, 255)
type(color_type), parameter, public :: BLUE = color_type( 0, 121, 241, 255)
type(color_type), parameter, public :: DARKBLUE = color_type( 0, 82, 172, 255)
type(color_type), parameter, public :: PURPLE = color_type(200, 122, 255, 255)
type(color_type), parameter, public :: VIOLET = color_type(135, 60, 190, 255)
type(color_type), parameter, public :: DARKPURPLE = color_type(112, 31, 126, 255)
type(color_type), parameter, public :: BEIGE = color_type(211, 176, 131, 255)
type(color_type), parameter, public :: BROWN = color_type(127, 106, 79, 255)
type(color_type), parameter, public :: DARKBROWN = color_type( 76, 63, 47, 255)
type(color_type), parameter, public :: WHITE = color_type(255, 255, 255, 255)
type(color_type), parameter, public :: BLACK = color_type( 0, 0, 0, 255)
integer(c_unsigned_char), parameter, private :: z130 = Int(Z'82',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z131 = Int(Z'83',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z135 = Int(Z'87',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z158 = Int(Z'9E',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z161 = Int(Z'A1',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z172 = Int(Z'AC',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z176 = Int(Z'B0',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z190 = Int(Z'BE',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z191 = Int(Z'BF',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z194 = Int(Z'C2',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z200 = Int(Z'C8',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z203 = Int(Z'CB',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z211 = Int(Z'D3',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z228 = Int(Z'E4',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z230 = Int(Z'E6',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z241 = Int(Z'F1',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z245 = Int(Z'F5',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z249 = Int(Z'F9',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z253 = Int(Z'FD',c_unsigned_char)
integer(c_unsigned_char), parameter, private :: z255 = Int(Z'FF',c_unsigned_char)
type(color_type), parameter, public :: LIGHTGRAY = color_type(z200, z200, z200, z255)
type(color_type), parameter, public :: GRAY = color_type(z130, z130, z130, z255)
type(color_type), parameter, public :: DARKGRAY = color_type( 80, 80, 80, z255)
type(color_type), parameter, public :: YELLOW = color_type(z253, z249, 0, z255)
type(color_type), parameter, public :: GOLD = color_type(z255, z203, 0, z255)
type(color_type), parameter, public :: ORANGE = color_type(z255, z161, 0, z255)
type(color_type), parameter, public :: PINK = color_type(z255, 109, z194, z255)
type(color_type), parameter, public :: RED = color_type(z230, 41, 55, z255)
type(color_type), parameter, public :: MAROON = color_type(z190, 33, 55, z255)
type(color_type), parameter, public :: GREEN = color_type( 0, z228, 48, z255)
type(color_type), parameter, public :: LIME = color_type( 0, z158, 47, z255)
type(color_type), parameter, public :: DARKGREEN = color_type( 0, 117, 44, z255)
type(color_type), parameter, public :: SKYBLUE = color_type(102, z191, z255, z255)
type(color_type), parameter, public :: BLUE = color_type( 0, 121, z241, z255)
type(color_type), parameter, public :: DARKBLUE = color_type( 0, 82, z172, z255)
type(color_type), parameter, public :: PURPLE = color_type(z200, 122, z255, z255)
type(color_type), parameter, public :: VIOLET = color_type(z135, 60, z190, z255)
type(color_type), parameter, public :: DARKPURPLE = color_type(112, 31, 126, z255)
type(color_type), parameter, public :: BEIGE = color_type(z211, z176, z131, z255)
type(color_type), parameter, public :: BROWN = color_type(127, 106, 79, z255)
type(color_type), parameter, public :: DARKBROWN = color_type( 76, 63, 47, z255)
type(color_type), parameter, public :: WHITE = color_type(z255, z255, z255, z255)
type(color_type), parameter, public :: BLACK = color_type( 0, 0, 0, z255)
type(color_type), parameter, public :: BLANK = color_type( 0, 0, 0, 0)
type(color_type), parameter, public :: MAGENTA = color_type(255, 0, 255, 255)
type(color_type), parameter, public :: RAYWHITE = color_type(245, 245, 245, 255)
type(color_type), parameter, public :: MAGENTA = color_type(z255, 0, z255, z255)
type(color_type), parameter, public :: RAYWHITE = color_type(z245, z245, z245, z255)

! ConfigFlags
integer(kind=c_int), parameter, public :: FLAG_VSYNC_HINT = int(z'00000040')
Expand Down