mmo-project/fortran/client/raylib.f90

172 lines
5.8 KiB
Fortran
Raw Normal View History

2023-08-26 13:58:47 -04:00
module raylib
use iso_c_binding
implicit none
type, bind(c) :: vector2
real(c_float) :: x
real(c_float) :: y
end type
type, bind(c) :: vector3
real(c_float) :: x
real(c_float) :: y
real(c_float) :: z
end type
type, bind(c) :: color
integer(c_int8_t) :: r
integer(c_int8_t) :: g
integer(c_int8_t) :: b
integer(c_int8_t) :: a
end type
type(color) :: LIGHTGRAY = color(200, 200, 200, 255)
type(color) :: GRAY = color(130, 130, 130, 255)
type(color) :: DARKGRAY = color(80, 80, 80, 255)
type(color) :: YELLOW = color(253, 249, 0, 255)
type(color) :: GOLD = color(255, 203, 0, 255)
type(color) :: ORANGE = color(255, 161, 0, 255)
type(color) :: PINK = color(255, 109, 194, 255)
type(color) :: RED = color(230, 41, 55, 255)
type(color) :: MAROON = color(190, 33, 55, 255)
type(color) :: GREEN = color(0, 228, 48, 255)
type(color) :: LIME = color(0, 158, 47, 255)
type(color) :: DARKGREEN = color(0, 117, 44, 255)
type(color) :: SKYBLUE = color(102, 191, 255, 255)
type(color) :: BLUE = color(0, 121, 241, 255)
type(color) :: DARKBLUE = color(0, 82, 172, 255)
type(color) :: PURPLE = color(200, 122, 255, 255)
type(color) :: VIOLET = color(135, 60, 190, 255)
type(color) :: DARKPURPLE = color(112, 31, 126, 255)
type(color) :: BEIGE = color(211, 176, 131, 255)
type(color) :: BROWN = color(127, 106, 79, 255)
type(color) :: DARKBROWN = color(76, 63, 47, 255)
type(color) :: WHITE = color(255, 255, 255, 255)
type(color) :: BLACK = color(0, 0, 0, 255)
type(color) :: BLANK = color(0, 0, 0, 0)
type(color) :: MAGENTA = color(255, 0, 255, 255)
type(color) :: RAYWHITE = color(245, 245, 245, 255)
type, bind(c) :: camera3d
type(vector3) :: position
type(vector3) :: target
type(vector3) :: up
real(c_float) :: fovy
integer(c_int) :: projection
end type
!Camera system modes
integer(c_int) :: CAMERA_CUSTOM = 0
integer(c_int) :: CAMERA_FREE = 1
integer(c_int) :: CAMERA_ORBITAL = 2
integer(c_int) :: CAMERA_FIRST_PERSON = 3
integer(c_int) :: CAMERA_THIRD_PERSON = 4
!Camera projection
integer(c_int) :: CAMERA_PERSPECTIVE = 0
integer(c_int) :: CAMERA_ORTHOGRAPHIC = 1
interface
subroutine init_window(width, height, title) bind(c, name="InitWindow")
import :: c_char
import :: c_int
integer(c_int), intent(in), value :: width
integer(c_int), intent(in), value :: height
character(c_char), dimension(*), intent(in) :: title
end subroutine
function window_should_close() result(res) bind(c, name="WindowShouldClose")
import :: c_bool
logical(c_bool) :: res
end function
subroutine close_window() bind(c, name="CloseWindow")
end subroutine
subroutine clear_background(col) bind(c, name="ClearBackground")
import :: color
Type(color), intent(in), value :: col
end subroutine
subroutine begin_drawing() bind(c, name="BeginDrawing")
end subroutine
subroutine end_drawing() bind(c, name="EndDrawing")
end subroutine
subroutine begin_mode_3d(camera) bind(c, name="BeginMode3D")
import :: camera3d
type(camera3d), intent(in), value :: camera
end subroutine
subroutine end_mode_3d() bind(c, name="EndMode3D")
end subroutine
subroutine set_target_fps(fps) bind(c, name="SetTargetFPS")
import :: c_int
integer(c_int), intent(in), value :: fps
end subroutine
subroutine update_camera(camera_ptr, mode) bind(c, name="UpdateCamera")
import :: c_ptr, c_int
type(c_ptr) :: camera_ptr
integer(c_int):: mode
end subroutine update_camera
subroutine show_cursor() bind(c, name="ShowCursor")
end subroutine show_cursor
subroutine hide_cursor() bind(c, name="HideCursor")
end subroutine hide_cursor
subroutine EnableCursor() bind(c, name="EnableCursor")
end subroutine EnableCursor
subroutine disable_cursor() bind(c, name="DisableCursor")
end subroutine disable_cursor
subroutine draw_text(text, posX, posY, fontSize, col) bind(c, name="DrawText")
import :: c_int
import :: color
import :: c_char
character(c_char), dimension(*), intent(in) :: text
integer(c_int), intent(in), value :: posX
integer(c_int), intent(in), value :: posY
integer(c_int), intent(in), value :: fontSize
type(color), intent(in), value :: col
end subroutine draw_text
subroutine draw_cube(position, width, height, length, col) bind(c, name="DrawCube")
import :: vector3
import :: c_float
import :: color
type(vector3), intent(in), value :: position
real(c_float), intent(in), value :: width
real(c_float), intent(in), value :: height
real(c_float), intent(in), value :: length
type(color), intent(in), value :: col
end subroutine draw_cube
subroutine draw_cube_wires(position, width, height, length, col) bind(c, name="DrawCubeWires")
import :: vector3
import :: c_float
import :: color
type(vector3), intent(in), value :: position
real(c_float), intent(in), value :: width
real(c_float), intent(in), value :: height
real(c_float), intent(in), value :: length
type(color), intent(in), value :: col
end subroutine draw_cube_wires
subroutine draw_plane(centerPos, size, col) bind(c, name="DrawPlane")
import vector3
import vector2
import color
type(vector3), intent(in), value :: centerPos
type(vector2), intent(in), value :: size
type(color), intent(in), value :: col
end subroutine draw_plane
end interface
end module