fixed client so that the user can update themselves!

This commit is contained in:
zongor 2023-10-13 00:45:46 -04:00
parent 0b09e0ab60
commit f323d09d9f
7 changed files with 502 additions and 470 deletions

Binary file not shown.

View File

@ -3,6 +3,7 @@ program main
use iso_c_binding use iso_c_binding
use raylib use raylib
use player_mod use player_mod
use json_module
implicit none implicit none
integer(c_int) :: screen_width = 800 integer(c_int) :: screen_width = 800
@ -11,10 +12,11 @@ program main
type(camera3d), target :: camera type(camera3d), target :: camera
type(player) :: me type(player) :: me
type(player), dimension(:), allocatable :: players type(player), dimension(:), allocatable :: players
character(len=24):: username character(len=24) :: username
character(len=24):: password character(len=24) :: password
integer :: i, status integer :: i, status
logical :: player_updated, exist logical :: player_updated, exist
real(c_double) :: time
inquire (file="debug.log", exist=exist) inquire (file="debug.log", exist=exist)
if (exist) then if (exist) then
@ -26,7 +28,7 @@ program main
call getarg(1, username) call getarg(1, username)
call getarg(2, password) call getarg(2, password)
me = player(username, vector3( 0.0_c_float, 1.0_c_float, 2.0_c_float ), PURPLE) me = player(username, vector3(0.0_c_float, 1.0_c_float, 2.0_c_float), PURPLE)
players = me%login(password) players = me%login(password)
camera%position = vector3(0.0_c_float, 10.0_c_float, 10.0_c_float) !Camera position camera%position = vector3(0.0_c_float, 10.0_c_float, 10.0_c_float) !Camera position
@ -57,33 +59,36 @@ program main
call me%sync_camera(camera) call me%sync_camera(camera)
if (player_updated) then time = get_time()
players = me%move() if (modulo(time, 1.0) .ge. 0.98_c_double) then
else if (player_updated) then
players = me%ping() players = me%move()
else
players = me%ping()
end if
end if end if
call begin_drawing() call begin_drawing()
call clear_background(RAYWHITE) call clear_background(RAYWHITE)
call begin_mode_3d(camera) call begin_mode_3d(camera)
! Draw floor ! Draw floor
call draw_grid(30_c_int, 1.0_c_float) call draw_grid(30_c_int, 1.0_c_float)
call draw_cube(me%position, 0.5_c_float, 0.5_c_float, 0.5_c_float, me%apperance) call draw_cube(me%position, 0.5_c_float, 0.5_c_float, 0.5_c_float, me%apperance)
do i=1,size(players) do i = 1, size(players)
call draw_cube(players(i)%position, 0.5_c_float, 0.5_c_float, 0.5_c_float, players(i)%apperance) call draw_cube(players(i)%position, 0.5_c_float, 0.5_c_float, 0.5_c_float, players(i)%apperance)
end do end do
call end_mode_3d() call end_mode_3d()
call end_drawing() call end_drawing()
end do end do
players = me%logout() players = me%logout()
if (allocated(players)) then if (allocated(players)) then
deallocate(players) deallocate (players)
end if end if
call close_window() !Close window and OpenGL context call close_window() !Close window and OpenGL context
close(12) close (12)
end program main end program main

View File

@ -1,118 +1,118 @@
module mod_dill module mod_dill
use iso_c_binding, only: c_char, c_int, c_int64_t, c_size_t use iso_c_binding, only: c_char, c_int, c_int64_t, c_size_t
implicit none implicit none
private private
public :: ipaddr, ipaddr_local, ipaddr_port, ipaddr_remote, ipaddr_str, & public :: ipaddr, ipaddr_local, ipaddr_port, ipaddr_remote, ipaddr_str, &
IPADDR_MAXSTRLEN, IPADDR_IPV4, IPADDR_IPV6, mrecv, msend, & IPADDR_MAXSTRLEN, IPADDR_IPV4, IPADDR_IPV6, mrecv, msend, &
suffix_attach, suffix_detach, tcp_accept, tcp_close, tcp_connect, & suffix_attach, suffix_detach, tcp_accept, tcp_close, tcp_connect, &
tcp_listen tcp_listen
integer(c_int), parameter :: IPADDR_IPV4 = 1 integer(c_int), parameter :: IPADDR_IPV4 = 1
integer(c_int), parameter :: IPADDR_IPV6 = 2 integer(c_int), parameter :: IPADDR_IPV6 = 2
integer(c_int), parameter :: IPADDR_MAXSTRLEN = 46 integer(c_int), parameter :: IPADDR_MAXSTRLEN = 46
type, bind(c) :: ipaddr type, bind(c) :: ipaddr
character(c_char) :: address(32) character(c_char) :: address(32)
end type ipaddr end type ipaddr
interface interface
integer(c_int) function ipaddr_local(addr, name, port, mode) & integer(c_int) function ipaddr_local(addr, name, port, mode) &
bind(c, name='dill_ipaddr_local') bind(c, name='dill_ipaddr_local')
import :: c_char, c_int, ipaddr import :: c_char, c_int, ipaddr
type(ipaddr), intent(out) :: addr type(ipaddr), intent(out) :: addr
character(c_char), intent(in) :: name(*) character(c_char), intent(in) :: name(*)
integer(c_int), value, intent(in) :: port integer(c_int), value, intent(in) :: port
integer(c_int), value, intent(in) :: mode integer(c_int), value, intent(in) :: mode
end function ipaddr_local end function ipaddr_local
integer(c_int) function ipaddr_port(addr) & integer(c_int) function ipaddr_port(addr) &
bind(c, name='dill_ipaddr_port') bind(c, name='dill_ipaddr_port')
import :: c_int, ipaddr import :: c_int, ipaddr
type(ipaddr), intent(in) :: addr type(ipaddr), intent(in) :: addr
end function ipaddr_port end function ipaddr_port
integer(c_int) function ipaddr_remote(addr, name, port, mode, deadline) & integer(c_int) function ipaddr_remote(addr, name, port, mode, deadline) &
bind(c, name='dill_ipaddr_remote') bind(c, name='dill_ipaddr_remote')
import :: c_char, c_int, c_int64_t, ipaddr import :: c_char, c_int, c_int64_t, ipaddr
type(ipaddr), intent(out) :: addr type(ipaddr), intent(out) :: addr
character(c_char), intent(in) :: name(*) character(c_char), intent(in) :: name(*)
integer(c_int), value, intent(in) :: port integer(c_int), value, intent(in) :: port
integer(c_int), value, intent(in) :: mode integer(c_int), value, intent(in) :: mode
integer(c_int64_t), value, intent(in) :: deadline integer(c_int64_t), value, intent(in) :: deadline
end function ipaddr_remote end function ipaddr_remote
subroutine ipaddr_str(addr, buf) & subroutine ipaddr_str(addr, buf) &
bind(c, name='dill_ipaddr_str') bind(c, name='dill_ipaddr_str')
import :: c_char, ipaddr import :: c_char, ipaddr
type(ipaddr), intent(in) :: addr type(ipaddr), intent(in) :: addr
character(c_char), intent(in out) :: buf(*) character(c_char), intent(in out) :: buf(*)
end subroutine ipaddr_str end subroutine ipaddr_str
integer(c_size_t) function mrecv(s, buf, len, deadline) & integer(c_size_t) function mrecv(s, buf, len, deadline) &
bind(c, name='dill_mrecv') bind(c, name='dill_mrecv')
import :: c_char, c_int, c_int64_t, c_size_t import :: c_char, c_int, c_int64_t, c_size_t
integer(c_int), value, intent(in) :: s integer(c_int), value, intent(in) :: s
character(c_char), intent(in out) :: buf(*) character(c_char), intent(in out) :: buf(*)
integer(c_size_t), value, intent(in) :: len integer(c_size_t), value, intent(in) :: len
integer(c_int64_t), value, intent(in) :: deadline integer(c_int64_t), value, intent(in) :: deadline
end function mrecv end function mrecv
integer(c_int) function msend(s, buf, len, deadline) & integer(c_int) function msend(s, buf, len, deadline) &
bind(c, name='dill_msend') bind(c, name='dill_msend')
import :: c_char, c_int, c_int64_t, c_size_t import :: c_char, c_int, c_int64_t, c_size_t
integer(c_int), value, intent(in) :: s integer(c_int), value, intent(in) :: s
character(c_char), intent(in) :: buf(*) character(c_char), intent(in) :: buf(*)
integer(c_size_t), value, intent(in) :: len integer(c_size_t), value, intent(in) :: len
integer(c_int64_t), value, intent(in) :: deadline integer(c_int64_t), value, intent(in) :: deadline
end function msend end function msend
integer(c_int) function suffix_attach(s, suffix, suffixlen) & integer(c_int) function suffix_attach(s, suffix, suffixlen) &
bind(c, name='dill_suffix_attach') bind(c, name='dill_suffix_attach')
import :: c_char, c_int, c_size_t import :: c_char, c_int, c_size_t
integer(c_int), value, intent(in) :: s integer(c_int), value, intent(in) :: s
character(c_char), intent(in) :: suffix(*) character(c_char), intent(in) :: suffix(*)
integer(c_size_t), value, intent(in) :: suffixlen integer(c_size_t), value, intent(in) :: suffixlen
end function suffix_attach end function suffix_attach
integer(c_int) function suffix_detach(s, deadline) & integer(c_int) function suffix_detach(s, deadline) &
bind(c, name='dill_suffix_detach') bind(c, name='dill_suffix_detach')
import :: c_int, c_int64_t import :: c_int, c_int64_t
integer(c_int), value, intent(in) :: s integer(c_int), value, intent(in) :: s
integer(c_int64_t), value, intent(in) :: deadline integer(c_int64_t), value, intent(in) :: deadline
end function suffix_detach end function suffix_detach
integer(c_int) function tcp_accept(s, addr, deadline) & integer(c_int) function tcp_accept(s, addr, deadline) &
bind(c, name='dill_tcp_accept') bind(c, name='dill_tcp_accept')
import :: c_int, c_int64_t, ipaddr import :: c_int, c_int64_t, ipaddr
integer(c_int), value, intent(in) :: s integer(c_int), value, intent(in) :: s
type(ipaddr), intent(out) :: addr type(ipaddr), intent(out) :: addr
integer(c_int64_t), value, intent(in) :: deadline integer(c_int64_t), value, intent(in) :: deadline
end function tcp_accept end function tcp_accept
integer(c_int) function tcp_close(s, deadline) & integer(c_int) function tcp_close(s, deadline) &
bind(c, name='dill_tcp_close') bind(c, name='dill_tcp_close')
import :: c_int, c_int64_t import :: c_int, c_int64_t
integer(c_int), value, intent(in) :: s integer(c_int), value, intent(in) :: s
integer(c_int64_t), value, intent(in) :: deadline integer(c_int64_t), value, intent(in) :: deadline
end function tcp_close end function tcp_close
integer(c_int) function tcp_connect(addr, deadline) & integer(c_int) function tcp_connect(addr, deadline) &
bind(c, name='dill_tcp_connect') bind(c, name='dill_tcp_connect')
import :: c_int, c_int64_t, ipaddr import :: c_int, c_int64_t, ipaddr
type(ipaddr), intent(in) :: addr type(ipaddr), intent(in) :: addr
integer(c_int64_t), value, intent(in) :: deadline integer(c_int64_t), value, intent(in) :: deadline
end function tcp_connect end function tcp_connect
integer(c_int) function tcp_listen(addr, backlog) & integer(c_int) function tcp_listen(addr, backlog) &
bind(c, name='dill_tcp_listen') bind(c, name='dill_tcp_listen')
import :: c_int, ipaddr import :: c_int, ipaddr
type(ipaddr), intent(in) :: addr type(ipaddr), intent(in) :: addr
integer(c_int), value, intent(in) :: backlog integer(c_int), value, intent(in) :: backlog
end function tcp_listen end function tcp_listen
end interface end interface
end module mod_dill end module mod_dill

View File

@ -4,11 +4,11 @@ module player_mod
use raylib use raylib
use json_module use json_module
use mod_dill, only: ipaddr, ipaddr_remote, IPADDR_IPV4, mrecv, msend, tcp_connect, & use mod_dill, only: ipaddr, ipaddr_remote, IPADDR_IPV4, mrecv, msend, tcp_connect, &
suffix_attach suffix_attach, tcp_close, suffix_detach
implicit none implicit none
type player type player
character(len=24):: username character(len=:), allocatable :: username
type(vector3) :: position type(vector3) :: position
type(color) :: apperance type(color) :: apperance
contains contains
@ -21,12 +21,10 @@ module player_mod
contains contains
type(player) function init_player(username, position, apperance, fifo_write, fifo_read) result(this) type(player) function init_player(username, position, apperance) result(this)
character(24) :: username character(24) :: username
type(vector3) :: position type(vector3) :: position
type(color) :: apperance type(color) :: apperance
integer :: fifo_write
integer :: fifo_read
this%username = username this%username = username
this%position = position this%position = position
@ -80,69 +78,83 @@ contains
class(player) :: this class(player) :: this
type(player), dimension(:), allocatable :: players type(player), dimension(:), allocatable :: players
integer :: request_type integer :: request_type
character(len=24) :: username character(len=:), allocatable :: username
character(len=:), allocatable :: local_username
integer :: apperance_r, apperance_g, apperance_b, i, count integer :: apperance_r, apperance_g, apperance_b, i, count
real(c_float) :: x_pos, y_pos real(real64) :: x_pos, y_pos
integer(c_size_t) :: message_size, msglen = 1024
character(c_char) :: message(1024) = ''
character(len=256) :: f_message
type(json_value), pointer :: root, user, recv_users
type(json_core) :: json
character(len=:), allocatable :: str
character(len=1024) :: jsn_string
character(len=10) :: istr
logical :: found
integer(c_int) :: rc, connection integer(c_int) :: rc, connection
integer(c_size_t) :: message_size, msglen = 256
type(ipaddr) :: addr type(ipaddr) :: addr
character(c_char) :: message(256) = ''
character(len=256) :: f_message
character(len=*), parameter :: TCP_SUFFIX = c_carriage_return//c_new_line//c_null_char character(len=*), parameter :: TCP_SUFFIX = c_carriage_return//c_new_line//c_null_char
type(json_value), pointer :: root, user
type(json_file) :: json
character(len=:), allocatable :: str
character(len=255) :: jsn_string
character(len=10) :: i_str
logical :: found
rc = ipaddr_remote(addr, '127.0.0.1'//c_null_char, 5555_c_int, IPADDR_IPV4, -1_c_int64_t) rc = ipaddr_remote(addr, '127.0.0.1'//c_null_char, 5555_c_int, IPADDR_IPV4, -1_c_int64_t)
connection = tcp_connect(addr, -1_c_int64_t) connection = tcp_connect(addr, -1_c_int64_t)
connection = suffix_attach(connection, TCP_SUFFIX, 2_c_size_t)
call json%initialize() call json%initialize(path_mode=2)
call json%create_object(root, '') call json%create_object(root, '')
call json%create_object(user, 'user') call json%create_object(user, 'user')
call json%add(user, 'username', this%username) local_username = this%username(:Len_Trim(this%username))
call json%add(user, 'username', local_username)
call json%add(user, 'x_pos', this%position%x) call json%add(user, 'x_pos', this%position%x)
call json%add(user, 'y_pos', this%position%y) call json%add(user, 'y_pos', this%position%z)
call json%add(user, 'command', request_type) call json%add(user, 'command', request_type)
call json%add(root, user) call json%add(root, user)
call json%serialize(root, str) call json%serialize(root, str)
call json%print(root)
connection = suffix_attach(connection, TCP_SUFFIX, 2_c_size_t)
rc = msend(connection, f_c_string(str, .true.), & rc = msend(connection, f_c_string(str, .true.), &
transfer(Len_Trim(f_c_string(str, .true.)), 0_c_size_t), -1_c_int64_t) transfer(Len_Trim(str) + 1, 0_c_size_t), -1_c_int64_t)
call json%destroy() connection = suffix_detach(connection, -1_c_size_t)
connection = suffix_attach(connection, TCP_SUFFIX, 2_c_size_t)
call json%initialize()
message_size = mrecv(connection, message, msglen, -1_c_int64_t) message_size = mrecv(connection, message, msglen, -1_c_int64_t)
print *, 'recv message: ', message
print *, 'message=', message
call c_f_string(message, jsn_string) call c_f_string(message, jsn_string)
call json%deserialize(jsn_string(:Len_Trim(jsn_string)))
call json%info('/users', n_children=count) call json%deserialize(recv_users, jsn_string(:Len_Trim(jsn_string)))
print *, count call json%info(recv_users, '/users', n_children=count)
if (allocated(players)) then
deallocate (players)
end if
if (count > 0) then
do i = 0, count - 1 do i = 0, count - 1
write (i_str, fmt='(I10)') i write (istr, fmt='(I10)') i
i_str = adjustl(i_str) istr = adjustl(istr)
call json%get("/users/"//istr//"/apperance_r", apperance_r, found) call json%get(recv_users, "/users/"//istr//"/apperance_r", apperance_r, found)
if (.not. found) stop 1 if (.not. found) stop 1
call json%get("/users/"//istr//"/apperance_g", apperance_g, found) call json%get(recv_users, "/users/"//istr//"/apperance_g", apperance_g, found)
if (.not. found) stop 1 if (.not. found) stop 1
call json%get("/users/"//istr//"/apperance_b", apperance_b, found) call json%get(recv_users, "/users/"//istr//"/apperance_b", apperance_b, found)
if (.not. found) stop 1 if (.not. found) stop 1
call json%get("/users/"//istr//"/x_pos", x_pos, found) call json%get(recv_users, "/users/"//istr//"/x_pos", x_pos, found)
if (.not. found) stop 1 if (.not. found) stop 1
call json%get("/users/"//istr//"/y_pos", y_pos, found) call json%get(recv_users, "/users/"//istr//"/y_pos", y_pos, found)
if (.not. found) stop 1 if (.not. found) stop 1
call json%get("/users/"//istr//"/username", username, found) call json%get(recv_users, "/users/"//istr//"/username", username, found)
if (.not. found) stop 1 if (.not. found) stop 1
if (allocated(players)) then if (allocated(players)) then
@ -153,8 +165,12 @@ contains
color(apperance_r, apperance_g, apperance_b, 255))] color(apperance_r, apperance_g, apperance_b, 255))]
end if end if
end do end do
end if
nullify (recv_users)
call json%destroy() call json%destroy()
rc = tcp_close(connection, -1_c_int64_t)
end function send_packet end function send_packet
! from ivanpribec `https://fortran-lang.discourse.group/t/best-practices-for-passing-c-strings/104/12` ! from ivanpribec `https://fortran-lang.discourse.group/t/best-practices-for-passing-c-strings/104/12`

View File

@ -55,286 +55,286 @@ module raylib
integer(c_int) :: projection integer(c_int) :: projection
end type end type
! Keyboard keys ! Keyboard keys
integer(c_int) :: KEY_NULL = 0 integer(c_int) :: KEY_NULL = 0
! Alphanumeric keys ! Alphanumeric keys
integer(c_int) :: KEY_APOSTROPHE = 39 integer(c_int) :: KEY_APOSTROPHE = 39
integer(c_int) :: KEY_COMMA = 44 integer(c_int) :: KEY_COMMA = 44
integer(c_int) :: KEY_MINUS = 45 integer(c_int) :: KEY_MINUS = 45
integer(c_int) :: KEY_PERIOD = 46 integer(c_int) :: KEY_PERIOD = 46
integer(c_int) :: KEY_SLASH = 47 integer(c_int) :: KEY_SLASH = 47
integer(c_int) :: KEY_ZERO = 48 integer(c_int) :: KEY_ZERO = 48
integer(c_int) :: KEY_ONE = 49 integer(c_int) :: KEY_ONE = 49
integer(c_int) :: KEY_TWO = 50 integer(c_int) :: KEY_TWO = 50
integer(c_int) :: KEY_THREE = 51 integer(c_int) :: KEY_THREE = 51
integer(c_int) :: KEY_FOUR = 52 integer(c_int) :: KEY_FOUR = 52
integer(c_int) :: KEY_FIVE = 53 integer(c_int) :: KEY_FIVE = 53
integer(c_int) :: KEY_SIX = 54 integer(c_int) :: KEY_SIX = 54
integer(c_int) :: KEY_SEVEN = 55 integer(c_int) :: KEY_SEVEN = 55
integer(c_int) :: KEY_EIGHT = 56 integer(c_int) :: KEY_EIGHT = 56
integer(c_int) :: KEY_NINE = 57 integer(c_int) :: KEY_NINE = 57
integer(c_int) :: KEY_SEMICOLON = 59 integer(c_int) :: KEY_SEMICOLON = 59
integer(c_int) :: KEY_EQUAL = 61 integer(c_int) :: KEY_EQUAL = 61
integer(c_int) :: KEY_A = 65 integer(c_int) :: KEY_A = 65
integer(c_int) :: KEY_B = 66 integer(c_int) :: KEY_B = 66
integer(c_int) :: KEY_C = 67 integer(c_int) :: KEY_C = 67
integer(c_int) :: KEY_D = 68 integer(c_int) :: KEY_D = 68
integer(c_int) :: KEY_E = 69 integer(c_int) :: KEY_E = 69
integer(c_int) :: KEY_F = 70 integer(c_int) :: KEY_F = 70
integer(c_int) :: KEY_G = 71 integer(c_int) :: KEY_G = 71
integer(c_int) :: KEY_H = 72 integer(c_int) :: KEY_H = 72
integer(c_int) :: KEY_I = 73 integer(c_int) :: KEY_I = 73
integer(c_int) :: KEY_J = 74 integer(c_int) :: KEY_J = 74
integer(c_int) :: KEY_K = 75 integer(c_int) :: KEY_K = 75
integer(c_int) :: KEY_L = 76 integer(c_int) :: KEY_L = 76
integer(c_int) :: KEY_M = 77 integer(c_int) :: KEY_M = 77
integer(c_int) :: KEY_N = 78 integer(c_int) :: KEY_N = 78
integer(c_int) :: KEY_O = 79 integer(c_int) :: KEY_O = 79
integer(c_int) :: KEY_P = 80 integer(c_int) :: KEY_P = 80
integer(c_int) :: KEY_Q = 81 integer(c_int) :: KEY_Q = 81
integer(c_int) :: KEY_R = 82 integer(c_int) :: KEY_R = 82
integer(c_int) :: KEY_S = 83 integer(c_int) :: KEY_S = 83
integer(c_int) :: KEY_T = 84 integer(c_int) :: KEY_T = 84
integer(c_int) :: KEY_U = 85 integer(c_int) :: KEY_U = 85
integer(c_int) :: KEY_V = 86 integer(c_int) :: KEY_V = 86
integer(c_int) :: KEY_W = 87 integer(c_int) :: KEY_W = 87
integer(c_int) :: KEY_X = 88 integer(c_int) :: KEY_X = 88
integer(c_int) :: KEY_Y = 89 integer(c_int) :: KEY_Y = 89
integer(c_int) :: KEY_Z = 90 integer(c_int) :: KEY_Z = 90
! Function keys ! Function keys
integer(c_int) :: KEY_SPACE = 32 integer(c_int) :: KEY_SPACE = 32
integer(c_int) :: KEY_ESCAPE = 256 integer(c_int) :: KEY_ESCAPE = 256
integer(c_int) :: KEY_ENTER = 257 integer(c_int) :: KEY_ENTER = 257
integer(c_int) :: KEY_TAB = 258 integer(c_int) :: KEY_TAB = 258
integer(c_int) :: KEY_BACKSPACE = 259 integer(c_int) :: KEY_BACKSPACE = 259
integer(c_int) :: KEY_INSERT = 260 integer(c_int) :: KEY_INSERT = 260
integer(c_int) :: KEY_DELETE = 261 integer(c_int) :: KEY_DELETE = 261
integer(c_int) :: KEY_RIGHT = 262 integer(c_int) :: KEY_RIGHT = 262
integer(c_int) :: KEY_LEFT = 263 integer(c_int) :: KEY_LEFT = 263
integer(c_int) :: KEY_DOWN = 264 integer(c_int) :: KEY_DOWN = 264
integer(c_int) :: KEY_UP = 265 integer(c_int) :: KEY_UP = 265
integer(c_int) :: KEY_PAGE_UP = 266 integer(c_int) :: KEY_PAGE_UP = 266
integer(c_int) :: KEY_PAGE_DOWN = 267 integer(c_int) :: KEY_PAGE_DOWN = 267
integer(c_int) :: KEY_HOME = 268 integer(c_int) :: KEY_HOME = 268
integer(c_int) :: KEY_END = 269 integer(c_int) :: KEY_END = 269
integer(c_int) :: KEY_CAPS_LOCK = 280 integer(c_int) :: KEY_CAPS_LOCK = 280
integer(c_int) :: KEY_SCROLL_LOCK = 281 integer(c_int) :: KEY_SCROLL_LOCK = 281
integer(c_int) :: KEY_NUM_LOCK = 282 integer(c_int) :: KEY_NUM_LOCK = 282
integer(c_int) :: KEY_PRINT_SCREEN = 283 integer(c_int) :: KEY_PRINT_SCREEN = 283
integer(c_int) :: KEY_PAUSE = 284 integer(c_int) :: KEY_PAUSE = 284
integer(c_int) :: KEY_F1 = 290 integer(c_int) :: KEY_F1 = 290
integer(c_int) :: KEY_F2 = 291 integer(c_int) :: KEY_F2 = 291
integer(c_int) :: KEY_F3 = 292 integer(c_int) :: KEY_F3 = 292
integer(c_int) :: KEY_F4 = 293 integer(c_int) :: KEY_F4 = 293
integer(c_int) :: KEY_F5 = 294 integer(c_int) :: KEY_F5 = 294
integer(c_int) :: KEY_F6 = 295 integer(c_int) :: KEY_F6 = 295
integer(c_int) :: KEY_F7 = 296 integer(c_int) :: KEY_F7 = 296
integer(c_int) :: KEY_F8 = 297 integer(c_int) :: KEY_F8 = 297
integer(c_int) :: KEY_F9 = 298 integer(c_int) :: KEY_F9 = 298
integer(c_int) :: KEY_F10 = 299 integer(c_int) :: KEY_F10 = 299
integer(c_int) :: KEY_F11 = 300 integer(c_int) :: KEY_F11 = 300
integer(c_int) :: KEY_F12 = 301 integer(c_int) :: KEY_F12 = 301
integer(c_int) :: KEY_LEFT_SHIFT = 340 integer(c_int) :: KEY_LEFT_SHIFT = 340
integer(c_int) :: KEY_LEFT_CONTROL = 341 integer(c_int) :: KEY_LEFT_CONTROL = 341
integer(c_int) :: KEY_LEFT_ALT = 342 integer(c_int) :: KEY_LEFT_ALT = 342
integer(c_int) :: KEY_LEFT_SUPER = 343 integer(c_int) :: KEY_LEFT_SUPER = 343
integer(c_int) :: KEY_RIGHT_SHIFT = 344 integer(c_int) :: KEY_RIGHT_SHIFT = 344
integer(c_int) :: KEY_RIGHT_CONTROL = 345 integer(c_int) :: KEY_RIGHT_CONTROL = 345
integer(c_int) :: KEY_RIGHT_ALT = 346 integer(c_int) :: KEY_RIGHT_ALT = 346
integer(c_int) :: KEY_RIGHT_SUPER = 347 integer(c_int) :: KEY_RIGHT_SUPER = 347
integer(c_int) :: KEY_KB_MENU = 348 integer(c_int) :: KEY_KB_MENU = 348
integer(c_int) :: KEY_LEFT_BRACKET = 91 integer(c_int) :: KEY_LEFT_BRACKET = 91
integer(c_int) :: KEY_BACKSLASH = 92 integer(c_int) :: KEY_BACKSLASH = 92
integer(c_int) :: KEY_RIGHT_BRACKET = 93 integer(c_int) :: KEY_RIGHT_BRACKET = 93
integer(c_int) :: KEY_GRAVE = 96 integer(c_int) :: KEY_GRAVE = 96
! Keypad keys ! Keypad keys
integer(c_int) :: KEY_KP_0 = 320 integer(c_int) :: KEY_KP_0 = 320
integer(c_int) :: KEY_KP_1 = 321 integer(c_int) :: KEY_KP_1 = 321
integer(c_int) :: KEY_KP_2 = 322 integer(c_int) :: KEY_KP_2 = 322
integer(c_int) :: KEY_KP_3 = 323 integer(c_int) :: KEY_KP_3 = 323
integer(c_int) :: KEY_KP_4 = 324 integer(c_int) :: KEY_KP_4 = 324
integer(c_int) :: KEY_KP_5 = 325 integer(c_int) :: KEY_KP_5 = 325
integer(c_int) :: KEY_KP_6 = 326 integer(c_int) :: KEY_KP_6 = 326
integer(c_int) :: KEY_KP_7 = 327 integer(c_int) :: KEY_KP_7 = 327
integer(c_int) :: KEY_KP_8 = 328 integer(c_int) :: KEY_KP_8 = 328
integer(c_int) :: KEY_KP_9 = 329 integer(c_int) :: KEY_KP_9 = 329
integer(c_int) :: KEY_KP_DECIMAL = 330 integer(c_int) :: KEY_KP_DECIMAL = 330
integer(c_int) :: KEY_KP_DIVIDE = 331 integer(c_int) :: KEY_KP_DIVIDE = 331
integer(c_int) :: KEY_KP_MULTIPLY = 332 integer(c_int) :: KEY_KP_MULTIPLY = 332
integer(c_int) :: KEY_KP_SUBTRACT = 333 integer(c_int) :: KEY_KP_SUBTRACT = 333
integer(c_int) :: KEY_KP_ADD = 334 integer(c_int) :: KEY_KP_ADD = 334
integer(c_int) :: KEY_KP_ENTER = 335 integer(c_int) :: KEY_KP_ENTER = 335
integer(c_int) :: KEY_KP_EQUAL = 336 integer(c_int) :: KEY_KP_EQUAL = 336
! Android key buttons ! Android key buttons
integer(c_int) :: KEY_BACK = 4 integer(c_int) :: KEY_BACK = 4
integer(c_int) :: KEY_MENU = 82 integer(c_int) :: KEY_MENU = 82
integer(c_int) :: KEY_VOLUME_UP = 24 integer(c_int) :: KEY_VOLUME_UP = 24
integer(c_int) :: KEY_VOLUME_DOWN = 25 integer(c_int) :: KEY_VOLUME_DOWN = 25
! Mouse buttons ! Mouse buttons
integer(c_int) :: MOUSE_LEFT_BUTTON = 0 integer(c_int) :: MOUSE_LEFT_BUTTON = 0
integer(c_int) :: MOUSE_RIGHT_BUTTON = 1 integer(c_int) :: MOUSE_RIGHT_BUTTON = 1
integer(c_int) :: MOUSE_MIDDLE_BUTTON = 2 integer(c_int) :: MOUSE_MIDDLE_BUTTON = 2
! Mouse cursor ! Mouse cursor
integer(c_int) :: MOUSE_CURSOR_DEFAULT = 0 integer(c_int) :: MOUSE_CURSOR_DEFAULT = 0
integer(c_int) :: MOUSE_CURSOR_ARROW = 1 integer(c_int) :: MOUSE_CURSOR_ARROW = 1
integer(c_int) :: MOUSE_CURSOR_IBEAM = 2 integer(c_int) :: MOUSE_CURSOR_IBEAM = 2
integer(c_int) :: MOUSE_CURSOR_CROSSHAIR = 3 integer(c_int) :: MOUSE_CURSOR_CROSSHAIR = 3
integer(c_int) :: MOUSE_CURSOR_POINTING_HAND = 4 integer(c_int) :: MOUSE_CURSOR_POINTING_HAND = 4
integer(c_int) :: MOUSE_CURSOR_RESIZE_EW = 5 integer(c_int) :: MOUSE_CURSOR_RESIZE_EW = 5
integer(c_int) :: MOUSE_CURSOR_RESIZE_NS = 6 integer(c_int) :: MOUSE_CURSOR_RESIZE_NS = 6
integer(c_int) :: MOUSE_CURSOR_RESIZE_NWSE = 7 integer(c_int) :: MOUSE_CURSOR_RESIZE_NWSE = 7
integer(c_int) :: MOUSE_CURSOR_RESIZE_NESW = 8 integer(c_int) :: MOUSE_CURSOR_RESIZE_NESW = 8
integer(c_int) :: MOUSE_CURSOR_RESIZE_ALL = 9 integer(c_int) :: MOUSE_CURSOR_RESIZE_ALL = 9
integer(c_int) :: MOUSE_CURSOR_NOT_ALLOWED = 10 integer(c_int) :: MOUSE_CURSOR_NOT_ALLOWED = 10
! Gamepad buttons ! Gamepad buttons
integer(c_int) :: GAMEPAD_BUTTON_UNKNOWN = 0 integer(c_int) :: GAMEPAD_BUTTON_UNKNOWN = 0
! This is normally a DPAD ! This is normally a DPAD
integer(c_int) :: GAMEPAD_BUTTON_LEFT_FACE_UP = 1 integer(c_int) :: GAMEPAD_BUTTON_LEFT_FACE_UP = 1
integer(c_int) :: GAMEPAD_BUTTON_LEFT_FACE_RIGHT = 2 integer(c_int) :: GAMEPAD_BUTTON_LEFT_FACE_RIGHT = 2
integer(c_int) :: GAMEPAD_BUTTON_LEFT_FACE_DOWN = 3 integer(c_int) :: GAMEPAD_BUTTON_LEFT_FACE_DOWN = 3
integer(c_int) :: GAMEPAD_BUTTON_LEFT_FACE_LEFT = 4 integer(c_int) :: GAMEPAD_BUTTON_LEFT_FACE_LEFT = 4
! This normally corresponds with PlayStation and Xbox controllers ! This normally corresponds with PlayStation and Xbox controllers
! XBOX: [Y,X,A,B] ! XBOX: [Y,X,A,B]
! PS3: [Triangle,Square,Cross,Circle] ! PS3: [Triangle,Square,Cross,Circle]
! No support for 6 button controllers though.. ! No support for 6 button controllers though..
integer(c_int) :: GAMEPAD_BUTTON_RIGHT_FACE_UP = 5 integer(c_int) :: GAMEPAD_BUTTON_RIGHT_FACE_UP = 5
integer(c_int) :: GAMEPAD_BUTTON_RIGHT_FACE_RIGHT = 6 integer(c_int) :: GAMEPAD_BUTTON_RIGHT_FACE_RIGHT = 6
integer(c_int) :: GAMEPAD_BUTTON_RIGHT_FACE_DOWN = 7 integer(c_int) :: GAMEPAD_BUTTON_RIGHT_FACE_DOWN = 7
integer(c_int) :: GAMEPAD_BUTTON_RIGHT_FACE_LEFT = 8 integer(c_int) :: GAMEPAD_BUTTON_RIGHT_FACE_LEFT = 8
integer(c_int) :: GAMEPAD_BUTTON_LEFT_TRIGGER_1 = 9 integer(c_int) :: GAMEPAD_BUTTON_LEFT_TRIGGER_1 = 9
integer(c_int) :: GAMEPAD_BUTTON_LEFT_TRIGGER_2 = 10 integer(c_int) :: GAMEPAD_BUTTON_LEFT_TRIGGER_2 = 10
integer(c_int) :: GAMEPAD_BUTTON_RIGHT_TRIGGER_1 = 11 integer(c_int) :: GAMEPAD_BUTTON_RIGHT_TRIGGER_1 = 11
integer(c_int) :: GAMEPAD_BUTTON_RIGHT_TRIGGER_2 = 12 integer(c_int) :: GAMEPAD_BUTTON_RIGHT_TRIGGER_2 = 12
integer(c_int) :: GAMEPAD_BUTTON_MIDDLE_LEFT = 13 ! PS3 Select integer(c_int) :: GAMEPAD_BUTTON_MIDDLE_LEFT = 13 ! PS3 Select
integer(c_int) :: GAMEPAD_BUTTON_MIDDLE = 14 ! PS Button/XBOX Button integer(c_int) :: GAMEPAD_BUTTON_MIDDLE = 14 ! PS Button/XBOX Button
integer(c_int) :: GAMEPAD_BUTTON_MIDDLE_RIGHT = 15 ! PS3 Start integer(c_int) :: GAMEPAD_BUTTON_MIDDLE_RIGHT = 15 ! PS3 Start
! These are the joystick press in buttons ! These are the joystick press in buttons
integer(c_int) :: GAMEPAD_BUTTON_LEFT_THUMB = 16 integer(c_int) :: GAMEPAD_BUTTON_LEFT_THUMB = 16
integer(c_int) :: GAMEPAD_BUTTON_RIGHT_THUMB = 17 integer(c_int) :: GAMEPAD_BUTTON_RIGHT_THUMB = 17
! Gamepad axis ! Gamepad axis
integer(c_int) :: GAMEPAD_AXIS_LEFT_X = 0 integer(c_int) :: GAMEPAD_AXIS_LEFT_X = 0
integer(c_int) :: GAMEPAD_AXIS_LEFT_Y = 1 integer(c_int) :: GAMEPAD_AXIS_LEFT_Y = 1
integer(c_int) :: GAMEPAD_AXIS_RIGHT_X = 2 integer(c_int) :: GAMEPAD_AXIS_RIGHT_X = 2
integer(c_int) :: GAMEPAD_AXIS_RIGHT_Y = 3 integer(c_int) :: GAMEPAD_AXIS_RIGHT_Y = 3
integer(c_int) :: GAMEPAD_AXIS_LEFT_TRIGGER = 4 ! [1..-1] (pressure-level) integer(c_int) :: GAMEPAD_AXIS_LEFT_TRIGGER = 4 ! [1..-1] (pressure-level)
integer(c_int) :: GAMEPAD_AXIS_RIGHT_TRIGGER = 5 ! [1..-1] (pressure-level) integer(c_int) :: GAMEPAD_AXIS_RIGHT_TRIGGER = 5 ! [1..-1] (pressure-level)
! Material map index ! Material map index
integer(c_int) :: MATERIAL_MAP_ALBEDO = 0 integer(c_int) :: MATERIAL_MAP_ALBEDO = 0
integer(c_int) :: MATERIAL_MAP_DIFFUSE = 0 ! same as MATERIAL_MAP_ALBEDO integer(c_int) :: MATERIAL_MAP_DIFFUSE = 0 ! same as MATERIAL_MAP_ALBEDO
integer(c_int) :: MATERIAL_MAP_METALNESS = 1 integer(c_int) :: MATERIAL_MAP_METALNESS = 1
integer(c_int) :: MATERIAL_MAP_SPECULAR = 1 ! same as MATERIAL_MAP_METALNESS integer(c_int) :: MATERIAL_MAP_SPECULAR = 1 ! same as MATERIAL_MAP_METALNESS
integer(c_int) :: MATERIAL_MAP_NORMAL = 2 integer(c_int) :: MATERIAL_MAP_NORMAL = 2
integer(c_int) :: MATERIAL_MAP_ROUGHNESS = 3 integer(c_int) :: MATERIAL_MAP_ROUGHNESS = 3
integer(c_int) :: MATERIAL_MAP_OCCLUSION = 4 integer(c_int) :: MATERIAL_MAP_OCCLUSION = 4
integer(c_int) :: MATERIAL_MAP_EMISSION = 5 integer(c_int) :: MATERIAL_MAP_EMISSION = 5
integer(c_int) :: MATERIAL_MAP_HEIGHT = 6 integer(c_int) :: MATERIAL_MAP_HEIGHT = 6
integer(c_int) :: MATERIAL_MAP_BRDG = 7 integer(c_int) :: MATERIAL_MAP_BRDG = 7
integer(c_int) :: MATERIAL_MAP_CUBEMAP = 8 ! NOTE: Uses GL_TEXTURE_CUBE_MAP integer(c_int) :: MATERIAL_MAP_CUBEMAP = 8 ! NOTE: Uses GL_TEXTURE_CUBE_MAP
integer(c_int) :: MATERIAL_MAP_IRRADIANCE = 9 ! NOTE: Uses GL_TEXTURE_CUBE_MAP integer(c_int) :: MATERIAL_MAP_IRRADIANCE = 9 ! NOTE: Uses GL_TEXTURE_CUBE_MAP
integer(c_int) :: MATERIAL_MAP_PREFILTER = 10 ! NOTE: Uses GL_TEXTURE_CUBE_MAP integer(c_int) :: MATERIAL_MAP_PREFILTER = 10 ! NOTE: Uses GL_TEXTURE_CUBE_MAP
! Shader location index ! Shader location index
integer(c_int) :: SHADER_LOC_VERTEX_POSITION = 0 integer(c_int) :: SHADER_LOC_VERTEX_POSITION = 0
integer(c_int) :: SHADER_LOC_VERTEX_TEXCOORD01 = 1 integer(c_int) :: SHADER_LOC_VERTEX_TEXCOORD01 = 1
integer(c_int) :: SHADER_LOC_VERTEX_TEXCOORD02 = 2 integer(c_int) :: SHADER_LOC_VERTEX_TEXCOORD02 = 2
integer(c_int) :: SHADER_LOC_VERTEX_NORMAL = 3 integer(c_int) :: SHADER_LOC_VERTEX_NORMAL = 3
integer(c_int) :: SHADER_LOC_VERTEX_TANGENT = 4 integer(c_int) :: SHADER_LOC_VERTEX_TANGENT = 4
integer(c_int) :: SHADER_LOC_VERTEX_COLOR = 5 integer(c_int) :: SHADER_LOC_VERTEX_COLOR = 5
integer(c_int) :: SHADER_LOC_MATRIX_MVP = 6 integer(c_int) :: SHADER_LOC_MATRIX_MVP = 6
integer(c_int) :: SHADER_LOC_MATRIX_VIEW = 7 integer(c_int) :: SHADER_LOC_MATRIX_VIEW = 7
integer(c_int) :: SHADER_LOC_MATRIX_PROJECTION = 8 integer(c_int) :: SHADER_LOC_MATRIX_PROJECTION = 8
integer(c_int) :: SHADER_LOC_MATRIX_MODEL = 9 integer(c_int) :: SHADER_LOC_MATRIX_MODEL = 9
integer(c_int) :: SHADER_LOC_MATRIX_NORMAL = 10 integer(c_int) :: SHADER_LOC_MATRIX_NORMAL = 10
integer(c_int) :: SHADER_LOC_VECTOR_VIEW = 11 integer(c_int) :: SHADER_LOC_VECTOR_VIEW = 11
integer(c_int) :: SHADER_LOC_COLOR_DIFFUSE = 12 integer(c_int) :: SHADER_LOC_COLOR_DIFFUSE = 12
integer(c_int) :: SHADER_LOC_COLOR_SPECULAR = 13 integer(c_int) :: SHADER_LOC_COLOR_SPECULAR = 13
integer(c_int) :: SHADER_LOC_COLOR_AMBIENT = 14 integer(c_int) :: SHADER_LOC_COLOR_AMBIENT = 14
integer(c_int) :: SHADER_LOC_MAP_ALBEDO = 15 integer(c_int) :: SHADER_LOC_MAP_ALBEDO = 15
integer(c_int) :: SHADER_LOC_MAP_DIFFUSE = 15 ! same as SHADER_LOC_MAP_ALBEDO integer(c_int) :: SHADER_LOC_MAP_DIFFUSE = 15 ! same as SHADER_LOC_MAP_ALBEDO
integer(c_int) :: SHADER_LOC_MAP_METALNESS = 16 integer(c_int) :: SHADER_LOC_MAP_METALNESS = 16
integer(c_int) :: SHADER_LOC_MAP_SPECULAR = 16 ! same as SHADER_LOC_MAP_METALNESS integer(c_int) :: SHADER_LOC_MAP_SPECULAR = 16 ! same as SHADER_LOC_MAP_METALNESS
integer(c_int) :: SHADER_LOC_MAP_NORMAL = 17 integer(c_int) :: SHADER_LOC_MAP_NORMAL = 17
integer(c_int) :: SHADER_LOC_MAP_ROUGHNESS = 18 integer(c_int) :: SHADER_LOC_MAP_ROUGHNESS = 18
integer(c_int) :: SHADER_LOC_MAP_OCCLUSION = 19 integer(c_int) :: SHADER_LOC_MAP_OCCLUSION = 19
integer(c_int) :: SHADER_LOC_MAP_EMISSION = 20 integer(c_int) :: SHADER_LOC_MAP_EMISSION = 20
integer(c_int) :: SHADER_LOC_MAP_HEIGHT = 21 integer(c_int) :: SHADER_LOC_MAP_HEIGHT = 21
integer(c_int) :: SHADER_LOC_MAP_CUBEMAP = 22 integer(c_int) :: SHADER_LOC_MAP_CUBEMAP = 22
integer(c_int) :: SHADER_LOC_MAP_IRRADIANCE = 23 integer(c_int) :: SHADER_LOC_MAP_IRRADIANCE = 23
integer(c_int) :: SHADER_LOC_MAP_PREFILTER = 24 integer(c_int) :: SHADER_LOC_MAP_PREFILTER = 24
integer(c_int) :: SHADER_LOC_MAP_BRDF = 25 integer(c_int) :: SHADER_LOC_MAP_BRDF = 25
! Shader uniform data type ! Shader uniform data type
integer(c_int) :: SHADER_UNIFORM_FLOAT = 0 integer(c_int) :: SHADER_UNIFORM_FLOAT = 0
integer(c_int) :: SHADER_UNIFORM_VEC2 = 1 integer(c_int) :: SHADER_UNIFORM_VEC2 = 1
integer(c_int) :: SHADER_UNIFORM_VEC3 = 2 integer(c_int) :: SHADER_UNIFORM_VEC3 = 2
integer(c_int) :: SHADER_UNIFORM_VEC4 = 3 integer(c_int) :: SHADER_UNIFORM_VEC4 = 3
integer(c_int) :: SHADER_UNIFORM_INT = 4 integer(c_int) :: SHADER_UNIFORM_INT = 4
integer(c_int) :: SHADER_UNIFORM_IVEC2 = 5 integer(c_int) :: SHADER_UNIFORM_IVEC2 = 5
integer(c_int) :: SHADER_UNIFORM_IVEC3 = 6 integer(c_int) :: SHADER_UNIFORM_IVEC3 = 6
integer(c_int) :: SHADER_UNIFORM_IVEC4 = 7 integer(c_int) :: SHADER_UNIFORM_IVEC4 = 7
integer(c_int) :: SHADER_UNIFORM_SAMPLER2D = 8 integer(c_int) :: SHADER_UNIFORM_SAMPLER2D = 8
! Pixel formats ! Pixel formats
integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1 ! 8 bit per pixel (no alpha) integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1 ! 8 bit per pixel (no alpha)
integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA = 2 ! 8*2 bpp (2 channels) integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA = 2 ! 8*2 bpp (2 channels)
integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R5G6B5 = 3 ! 16 bpp integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R5G6B5 = 3 ! 16 bpp
integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R8G8B8 = 4 ! 24 bpp integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R8G8B8 = 4 ! 24 bpp
integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R5G5B5A1 = 5 ! 16 bpp (1 bit alpha) integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R5G5B5A1 = 5 ! 16 bpp (1 bit alpha)
integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R4G4B4A4 = 6 ! 16 bpp (4 bit alpha) integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R4G4B4A4 = 6 ! 16 bpp (4 bit alpha)
integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 = 7 ! 32 bpp integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 = 7 ! 32 bpp
integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R32 = 8 ! 32 bpp (1 channel - float) integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R32 = 8 ! 32 bpp (1 channel - float)
integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R32G32B32 = 9 ! 32*3 bpp (3 channels - float) integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R32G32B32 = 9 ! 32*3 bpp (3 channels - float)
integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R32G32B32A32 = 10 ! 32*4 bpp (4 channels - float) integer(c_int) :: PIXELFORMAT_UNCOMPRESSED_R32G32B32A32 = 10 ! 32*4 bpp (4 channels - float)
integer(c_int) :: PIXELFORMAT_COMPRESSED_DXT1_RGB = 11 ! 4 bpp (no alpha) integer(c_int) :: PIXELFORMAT_COMPRESSED_DXT1_RGB = 11 ! 4 bpp (no alpha)
integer(c_int) :: PIXELFORMAT_COMPRESSED_DXT1_RGBA = 12 ! 4 bpp (1 bit alpha) integer(c_int) :: PIXELFORMAT_COMPRESSED_DXT1_RGBA = 12 ! 4 bpp (1 bit alpha)
integer(c_int) :: PIXELFORMAT_COMPRESSED_DXT3_RGBA = 13 ! 8 bpp integer(c_int) :: PIXELFORMAT_COMPRESSED_DXT3_RGBA = 13 ! 8 bpp
integer(c_int) :: PIXELFORMAT_COMPRESSED_DXT5_RGBA = 14 ! 8 bpp integer(c_int) :: PIXELFORMAT_COMPRESSED_DXT5_RGBA = 14 ! 8 bpp
integer(c_int) :: PIXELFORMAT_COMPRESSED_ETC1_RGB = 15 ! 4 bpp integer(c_int) :: PIXELFORMAT_COMPRESSED_ETC1_RGB = 15 ! 4 bpp
integer(c_int) :: PIXELFORMAT_COMPRESSED_ETC2_RGB = 16 ! 4 bpp integer(c_int) :: PIXELFORMAT_COMPRESSED_ETC2_RGB = 16 ! 4 bpp
integer(c_int) :: PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA = 17 ! 8 bpp integer(c_int) :: PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA = 17 ! 8 bpp
integer(c_int) :: PIXELFORMAT_COMPRESSED_PVRT_RGB = 18 ! 4 bpp integer(c_int) :: PIXELFORMAT_COMPRESSED_PVRT_RGB = 18 ! 4 bpp
integer(c_int) :: PIXELFORMAT_COMPRESSED_PVRT_RGBA = 19 ! 4 bpp integer(c_int) :: PIXELFORMAT_COMPRESSED_PVRT_RGBA = 19 ! 4 bpp
integer(c_int) :: PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA = 20 ! 8 bpp integer(c_int) :: PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA = 20 ! 8 bpp
integer(c_int) :: PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA = 21 ! 2 bpp integer(c_int) :: PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA = 21 ! 2 bpp
! Texture parameters: filter mode ! Texture parameters: filter mode
integer(c_int) :: TEXTURE_FILTER_POINT = 0 ! No filter, just pixel aproximation integer(c_int) :: TEXTURE_FILTER_POINT = 0 ! No filter, just pixel aproximation
integer(c_int) :: TEXTURE_FILTER_BILINEAR = 1 ! Linear filtering integer(c_int) :: TEXTURE_FILTER_BILINEAR = 1 ! Linear filtering
integer(c_int) :: TEXTURE_FILTER_TRILINEAR = 2 ! Trilinear filtering (linear with mipmaps) integer(c_int) :: TEXTURE_FILTER_TRILINEAR = 2 ! Trilinear filtering (linear with mipmaps)
integer(c_int) :: TEXTURE_FILTER_ANISOTROPIC_4X = 3 ! Anisotropic filtering 4x integer(c_int) :: TEXTURE_FILTER_ANISOTROPIC_4X = 3 ! Anisotropic filtering 4x
integer(c_int) :: TEXTURE_FILTER_ANISOTROPIC_8X = 4 ! Anisotropic filtering 8x integer(c_int) :: TEXTURE_FILTER_ANISOTROPIC_8X = 4 ! Anisotropic filtering 8x
integer(c_int) :: TEXTURE_FILTER_ANISOTROPIC_16X = 5 ! Anisotropic filtering 16x integer(c_int) :: TEXTURE_FILTER_ANISOTROPIC_16X = 5 ! Anisotropic filtering 16x
! Texture parameters: wrap mode ! Texture parameters: wrap mode
integer(c_int) :: TEXTURE_WRAP_REPEAT = 0 ! Repeats texture in tiled mode integer(c_int) :: TEXTURE_WRAP_REPEAT = 0 ! Repeats texture in tiled mode
integer(c_int) :: TEXTURE_WRAP_CLAMP = 1 ! Clamps texture to edge pixel in tiled mode integer(c_int) :: TEXTURE_WRAP_CLAMP = 1 ! Clamps texture to edge pixel in tiled mode
integer(c_int) :: TEXTURE_WRAP_MIRROR_REPEAT = 2 ! Mirrors and repeats the texture in tiled mode integer(c_int) :: TEXTURE_WRAP_MIRROR_REPEAT = 2 ! Mirrors and repeats the texture in tiled mode
integer(c_int) :: TEXTURE_WRAP_MIRROR_CLAMP = 3 ! Mirrors and clamps to border the texture in tiled mode integer(c_int) :: TEXTURE_WRAP_MIRROR_CLAMP = 3 ! Mirrors and clamps to border the texture in tiled mode
! Cubemap layouts ! Cubemap layouts
integer(c_int) :: CUBEMAP_LAYOUT_AUTO_DETECT = 0 ! Automatically detect layout type integer(c_int) :: CUBEMAP_LAYOUT_AUTO_DETECT = 0 ! Automatically detect layout type
integer(c_int) :: CUBEMAP_LAYOUT_LINE_VERTICAL = 1 ! Layout is defined by a vertical line with faces integer(c_int) :: CUBEMAP_LAYOUT_LINE_VERTICAL = 1 ! Layout is defined by a vertical line with faces
integer(c_int) :: CUBEMAP_LAYOUT_LINE_HORIZONTAL = 2 ! Layout is defined by an horizontal line with faces integer(c_int) :: CUBEMAP_LAYOUT_LINE_HORIZONTAL = 2 ! Layout is defined by an horizontal line with faces
integer(c_int) :: CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR = 3 ! Layout is defined by a 3x4 cross with cubemap faces integer(c_int) :: CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR = 3 ! Layout is defined by a 3x4 cross with cubemap faces
integer(c_int) :: CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE = 4 ! Layout is defined by a 4x3 cross with cubemap faces integer(c_int) :: CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE = 4 ! Layout is defined by a 4x3 cross with cubemap faces
integer(c_int) :: CUBEMAP_LAYOUT_PANORAMA = 5 ! Layout is defined by a panorama image (equirectangular map) integer(c_int) :: CUBEMAP_LAYOUT_PANORAMA = 5 ! Layout is defined by a panorama image (equirectangular map)
! Font type, defines generation method ! Font type, defines generation method
integer(c_int) :: FONT_DEFAULT = 0 ! Default font generation, anti-aliased integer(c_int) :: FONT_DEFAULT = 0 ! Default font generation, anti-aliased
integer(c_int) :: FONT_BITMAP = 1 ! Bitmap font generation, no anti-aliasing integer(c_int) :: FONT_BITMAP = 1 ! Bitmap font generation, no anti-aliasing
integer(c_int) :: FONT_SDF = 2 ! SDF font generation, requires external shader integer(c_int) :: FONT_SDF = 2 ! SDF font generation, requires external shader
! Color blending modes (pre-defined) ! Color blending modes (pre-defined)
integer(c_int) :: BLEND_ALPHA = 0 ! Blend textures considering alpha (default) integer(c_int) :: BLEND_ALPHA = 0 ! Blend textures considering alpha (default)
integer(c_int) :: BLEND_ADDITIVE = 1 ! Blend textures adding colors integer(c_int) :: BLEND_ADDITIVE = 1 ! Blend textures adding colors
integer(c_int) :: BLEND_MULTIPLIED = 2 ! Blend textures multiplying colors integer(c_int) :: BLEND_MULTIPLIED = 2 ! Blend textures multiplying colors
integer(c_int) :: BLEND_ADD_COLORS = 3 ! Blend textures adding colors (alternative) integer(c_int) :: BLEND_ADD_COLORS = 3 ! Blend textures adding colors (alternative)
integer(c_int) :: BLEND_SUBTRACT_COLORS = 4 ! Blend textures subtracting colors (alternative) integer(c_int) :: BLEND_SUBTRACT_COLORS = 4 ! Blend textures subtracting colors (alternative)
integer(c_int) :: BLEND_CUSTOM = 5 ! Belnd textures using custom src/dst factors (use rlSetBlendMode()) integer(c_int) :: BLEND_CUSTOM = 5 ! Belnd textures using custom src/dst factors (use rlSetBlendMode())
! Gestures ! Gestures
integer(c_int) :: GESTURE_NONE = 0 integer(c_int) :: GESTURE_NONE = 0
integer(c_int) :: GESTURE_TAP = 1 integer(c_int) :: GESTURE_TAP = 1
integer(c_int) :: GESTURE_DOUBLETAP = 2 integer(c_int) :: GESTURE_DOUBLETAP = 2
integer(c_int) :: GESTURE_HOLD = 4 integer(c_int) :: GESTURE_HOLD = 4
integer(c_int) :: GESTURE_DRAG = 8 integer(c_int) :: GESTURE_DRAG = 8
integer(c_int) :: GESTURE_SWIPE_RIGHT = 16 integer(c_int) :: GESTURE_SWIPE_RIGHT = 16
integer(c_int) :: GESTURE_SWIPE_LEFT = 32 integer(c_int) :: GESTURE_SWIPE_LEFT = 32
integer(c_int) :: GESTURE_SWIPE_UP = 64 integer(c_int) :: GESTURE_SWIPE_UP = 64
integer(c_int) :: GESTURE_SWIPE_DOWN = 128 integer(c_int) :: GESTURE_SWIPE_DOWN = 128
integer(c_int) :: GESTURE_PINCH_IN = 256 integer(c_int) :: GESTURE_PINCH_IN = 256
integer(c_int) :: GESTURE_PINCH_OUT = 512 integer(c_int) :: GESTURE_PINCH_OUT = 512
!Camera system modes !Camera system modes
integer(c_int) :: CAMERA_CUSTOM = 0 integer(c_int) :: CAMERA_CUSTOM = 0
@ -407,40 +407,40 @@ module raylib
subroutine disable_cursor() bind(c, name="DisableCursor") subroutine disable_cursor() bind(c, name="DisableCursor")
end subroutine disable_cursor end subroutine disable_cursor
function is_key_pressed(key) result (res) bind(c, name="IsKeyPressed") function is_key_pressed(key) result(res) bind(c, name="IsKeyPressed")
import :: c_int import :: c_int
import :: c_bool import :: c_bool
logical(c_bool) :: res logical(c_bool) :: res
integer(c_int), intent(in), value :: key integer(c_int), intent(in), value :: key
end function is_key_pressed end function is_key_pressed
function is_key_down(key) result (res) bind(c, name="IsKeyDown") function is_key_down(key) result(res) bind(c, name="IsKeyDown")
import :: c_int import :: c_int
import :: c_bool import :: c_bool
logical(c_bool) :: res logical(c_bool) :: res
integer(c_int), intent(in), value :: key integer(c_int), intent(in), value :: key
end function is_key_down end function is_key_down
function is_key_released(key) result (res) bind(c, name="IsKeyReleased") function is_key_released(key) result(res) bind(c, name="IsKeyReleased")
import :: c_int import :: c_int
import :: c_bool import :: c_bool
logical(c_bool) :: res logical(c_bool) :: res
integer(c_int), intent(in), value :: key integer(c_int), intent(in), value :: key
end function is_key_released end function is_key_released
function is_key_up(key) result (res) bind(c, name="IsKeyUp") function is_key_up(key) result(res) bind(c, name="IsKeyUp")
import :: c_int import :: c_int
import :: c_bool import :: c_bool
logical(c_bool) :: res logical(c_bool) :: res
integer(c_int), intent(in), value :: key integer(c_int), intent(in), value :: key
end function is_key_up end function is_key_up
subroutine draw_grid(slices, spacing) bind(c, name="DrawGrid") subroutine draw_grid(slices, spacing) bind(c, name="DrawGrid")
import :: c_int import :: c_int
import :: c_float import :: c_float
integer(c_int), intent(in), value :: slices integer(c_int), intent(in), value :: slices
real(c_float), intent(in), value :: spacing real(c_float), intent(in), value :: spacing
end subroutine draw_grid end subroutine draw_grid
subroutine draw_text(text, posX, posY, fontSize, col) bind(c, name="DrawText") subroutine draw_text(text, posX, posY, fontSize, col) bind(c, name="DrawText")
import :: c_int import :: c_int
@ -483,5 +483,10 @@ module raylib
type(vector2), intent(in), value :: size type(vector2), intent(in), value :: size
type(color), intent(in), value :: col type(color), intent(in), value :: col
end subroutine draw_plane end subroutine draw_plane
function get_time() result(res) bind(c, name="GetTime")
import :: c_double
real(c_double) :: res
end function get_time
end interface end interface
end module end module

View File

@ -54,7 +54,9 @@ program main
call ipaddr_str(addr, address_string) call ipaddr_str(addr, address_string)
print *, 'New connection from '//trim(address_string) print *, 'New connection from '//trim(address_string)
connection = suffix_attach(connection, TCP_SUFFIX, 2_c_size_t) connection = suffix_attach(connection, TCP_SUFFIX, 2_c_size_t)
print *, 'connected'
message_size = mrecv(connection, message, msglen, -1_c_int64_t) message_size = mrecv(connection, message, msglen, -1_c_int64_t)
print *, message_size
call c_f_string(message, jsn_string) call c_f_string(message, jsn_string)
@ -73,20 +75,20 @@ program main
call json%destroy() call json%destroy()
if (command .eq. 0) then ! get all logged in users and return their positions to client if (command .eq. 0) then ! get all logged in users and return their positions to client
rc = db_get_logged_in_users(db, connection)
else if (command .eq. 1) then else if (command .eq. 1) then
rc = db_login_user(db, username) rc = db_login_user(db, username)
rc = db_get_logged_in_users(db, connection)
else if (command .eq. 3) then ! update new pos to database else if (command .eq. 3) then ! update new pos to database
rc = db_move_user(db, username, x_pos, y_pos) rc = db_move_user(db, username, x_pos, y_pos)
rc = db_get_logged_in_users(db, connection)
else ! (2) if logout update logged_in to database else ! (2) if logout update logged_in to database
rc = db_logout_user(db, username) rc = db_logout_user(db, username)
rc = db_get_logged_in_users(db, connection)
exit server_loop exit server_loop
end if end if
rc = db_get_logged_in_users(db, connection)
rc = tcp_close(connection, -1_c_int64_t)
end do server_loop end do server_loop
rc = tcp_close(connection, -1_c_int64_t)
rc = db_close(db) rc = db_close(db)
contains contains

View File

@ -3,8 +3,7 @@ module db
use iso_fortran_env use iso_fortran_env
use iso_c_binding use iso_c_binding
use json_module use json_module
use mod_dill, only: ipaddr, ipaddr_remote, IPADDR_IPV4, mrecv, msend, tcp_connect, & use mod_dill, only: msend, suffix_attach, suffix_detach
suffix_attach
use :: sqlite3 use :: sqlite3
implicit none implicit none
private private
@ -145,6 +144,7 @@ contains
!! Prints number of courses per student to standard output. !! Prints number of courses per student to standard output.
type(db_type), intent(inout) :: db type(db_type), intent(inout) :: db
integer(c_int), intent(inout) :: connection integer(c_int), intent(inout) :: connection
character(len=*), parameter :: TCP_SUFFIX = c_carriage_return // c_new_line // c_null_char
character(len=:), allocatable :: str character(len=:), allocatable :: str
type(json_value), pointer :: root, users, user type(json_value), pointer :: root, users, user
@ -198,8 +198,12 @@ contains
call json%add(root, users) call json%add(root, users)
call json%serialize(root, str) call json%serialize(root, str)
print *, 'sending users'
call json%print(root)
rc = msend(connection, f_c_string(str, .true.), & rc = msend(connection, f_c_string(str, .true.), &
transfer(Len_Trim(f_c_string(str, .true.)), 0_c_size_t), -1_c_int64_t) transfer(Len_Trim(f_c_string(str, .true.)), 0_c_size_t), -1_c_int64_t)
call json%destroy() call json%destroy()
rc = sqlite3_finalize(stmt) rc = sqlite3_finalize(stmt)
@ -215,7 +219,7 @@ contains
"UPDATE users SET logged_in = 1 WHERE users.username = ?;", stmt) "UPDATE users SET logged_in = 1 WHERE users.username = ?;", stmt)
call db_error(rc, 'sqlite3_prepare_v2()') call db_error(rc, 'sqlite3_prepare_v2()')
rc = sqlite3_bind_text(stmt, 1, username) rc = sqlite3_bind_text(stmt, 1, username(:Len_Trim(username)))
call db_error(rc, 'sqlite3_bind_text()') call db_error(rc, 'sqlite3_bind_text()')
rc = sqlite3_step(stmt) rc = sqlite3_step(stmt)