Got refactored raylib working in the vis_ast binary

Now to make that debugger...
This commit is contained in:
Edward R. Gonzalez 2023-11-19 00:01:35 -05:00
parent 053daaf877
commit 36ebbfe29b
19 changed files with 4581 additions and 4469 deletions

9
.vscode/launch.json vendored
View File

@ -49,6 +49,15 @@
"args": [], "args": [],
"cwd": "${workspaceFolder}/project/auxillary/vis_ast/dependencies/temp/raylib-master/src/", "cwd": "${workspaceFolder}/project/auxillary/vis_ast/dependencies/temp/raylib-master/src/",
"visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis" "visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis"
},
{
"type": "cppvsdbg",
"request": "launch",
"name": "Debug VIS AST",
"program": "${workspaceFolder}/project/auxillary/vis_ast/binaries/vis_ast.exe",
"args": [],
"cwd": "${workspaceFolder}/project/auxillary/vis_ast/binaries/",
"visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis"
} }
] ]
} }

View File

@ -15,6 +15,7 @@ $path_vis_root = Join-Path $path_aux 'vis_ast'
$path_binaries = Join-Path $path_vis_root 'binaries' $path_binaries = Join-Path $path_vis_root 'binaries'
$path_build = Join-Path $path_vis_root 'build' $path_build = Join-Path $path_vis_root 'build'
$path_code = Join-Path $path_vis_root 'code' $path_code = Join-Path $path_vis_root 'code'
$path_deps = Join-Path $path_vis_root 'dependencies'
$path_win32 = Join-Path $path_code 'win32' $path_win32 = Join-Path $path_code 'win32'
Import-Module $target_arch Import-Module $target_arch
@ -66,10 +67,26 @@ if ( (Test-Path $path_binaries) -eq $false ) {
New-Item $path_binaries -ItemType Directory New-Item $path_binaries -ItemType Directory
} }
$path_raylib = join-path $path_deps 'raylib'
$path_raylib_inc = join-path $path_raylib 'include'
$path_raylib_lib = join-path $path_raylib 'lib'
$path_raylib_dll = join-path $path_raylib_lib 'raylib.dll'
$path_raylib_dll_bin = join-path $path_binaries 'raylib.dll'
Copy-Item $path_raylib_dll $path_raylib_dll_bin -Force
$includes = @( $includes = @(
$paht_code $path_code,
$path_deps
) )
write-host $path_code
foreach ( $include in $includes ) {
Write-Host 'include: ' $include
}
# Microsoft # Microsoft
$lib_gdi32 = 'Gdi32.lib' $lib_gdi32 = 'Gdi32.lib'
$lib_xinput = 'Xinput.lib' $lib_xinput = 'Xinput.lib'
@ -82,6 +99,7 @@ $compiler_args = @(
($flag_define + 'UNICODE'), ($flag_define + 'UNICODE'),
($flag_define + '_UNICODE') ($flag_define + '_UNICODE')
( $flag_define + 'INTELLISENSE_DIRECTIVES=0'), ( $flag_define + 'INTELLISENSE_DIRECTIVES=0'),
( $flag_define + 'RL_USE_LIBTYPE_SHARED')
# ($flag_set_stack_size + $stack_size) # ($flag_set_stack_size + $stack_size)
$flag_wall $flag_wall
$flag_warnings_as_errors $flag_warnings_as_errors
@ -97,7 +115,9 @@ else {
$linker_args = @( $linker_args = @(
$flag_link_win_subsystem_windows, $flag_link_win_subsystem_windows,
$flag_link_optiiize_references $flag_link_optiiize_references,
( join-path $path_raylib_lib 'raylib.lib' )
) )
$unit = join-path $path_code 'vis_ast_windows.cpp' $unit = join-path $path_code 'vis_ast_windows.cpp'

View File

@ -0,0 +1,22 @@
$path_root = git rev-parse --show-toplevel
$path_scripts = Join-Path $path_root 'scripts'
$target_arch = Join-Path $path_scripts 'helpers/target_arch.psm1'
$devshell = Join-Path $path_scripts 'helpers/devshell.ps1'
$format_cpp = Join-Path $path_scripts 'helpers/format_cpp.psm1'
$incremental_checks = Join-Path $path_scripts 'helpers/incremental_checks.ps1'
$vendor_toolchain = Join-Path $path_scripts 'helpers/vendor_toolchain.ps1'
$path_project = Join-Path $path_root 'project'
$path_aux = Join-Path $path_project 'auxillary'
$path_vis_root = Join-Path $path_aux 'vis_ast'
$path_binaries = Join-Path $path_vis_root 'binaries'
$path_build = Join-Path $path_vis_root 'build'
if ( test-path $path_build ) {
remove-item $path_build -Recurse
}
if ( test-path $path_binaries ) {
remove-item $path_binaries -recurse
}

View File

@ -1,8 +1,45 @@
#if INTELLISENSE_DIRECTIVES #if INTELLISENSE_DIRECTIVES
#include "win32.hpp" #include "win32.hpp"
#include "raylib/include/raylib.h"
#endif #endif
int __stdcall WinMain( HINSTANCE instance, HINSTANCE prev_instance, char* commandline, int num_cmd_show) int __stdcall WinMain( HINSTANCE instance, HINSTANCE prev_instance, char* commandline, int num_cmd_show)
{ {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
rl::init_window(screenWidth, screenHeight, "raylib [core] example - basic window");
rl::set_target_fps(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!rl::window_should_close()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
rl::begin_drawing();
rl::clear_background(RL_RAYWHITE);
rl::draw_text("Congrats! You created your first window!", 190, 200, 20, RL_LIGHTGRAY);
rl::end_drawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
rl::close_window(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

@ -1,3 +1,5 @@
#include "platform/vendor/arch.hpp" #include "platform/vendor/arch.hpp"
#include "platform/vendor/compiler.hpp" #include "platform/vendor/compiler.hpp"
#include "platform/vendor/compiler_ignores.hpp" #include "platform/vendor/compiler_ignores.hpp"
@ -7,4 +9,6 @@
#include "platform/win32/types.hpp" #include "platform/win32/types.hpp"
#include "raylib/include/raylib.h"
#include "platform/win32/launch.cpp" #include "platform/win32/launch.cpp"

View File

@ -25,12 +25,12 @@
* *
**********************************************************************************************/ **********************************************************************************************/
#ifndef RL_CONFIG_H #ifndef CONFIG_H
#define RL_CONFIG_H #define CONFIG_H
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module selection - Some modules could be avoided // Module selection - Some modules could be avoided
// Mandatory modules: rcore, RLGL_, utils // Mandatory modules: rcore, rlgl, utils
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#define RL_SUPPORT_MODULE_RSHAPES 1 #define RL_SUPPORT_MODULE_RSHAPES 1
#define RL_SUPPORT_MODULE_RTEXTURES 1 #define RL_SUPPORT_MODULE_RTEXTURES 1
@ -41,12 +41,12 @@
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module: rcore - Configuration Flags // Module: rcore - Configuration Flags
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// RL_Camera module is included (rcamera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital // Camera module is included (rcamera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital
#define RL_SUPPORT_CAMERA_SYSTEM 1 #define RL_SUPPORT_CAMERA_SYSTEM 1
// Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag // Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag
#define RL_SUPPORT_GESTURES_SYSTEM 1 #define RL_SUPPORT_GESTURES_SYSTEM 1
// Include pseudo-random numbers generator (rprand.h), based on Xoshiro128** and SplitMix64 // Include pseudo-random numbers generator (rprand.h), based on Xoshiro128** and SplitMix64
#define SUPPORT_RPRAND_GENERATOR 1 #define RL_SUPPORT_RPRAND_GENERATOR 1
// Mouse gestures are directly mapped like touches and processed by gestures system // Mouse gestures are directly mapped like touches and processed by gestures system
#define RL_SUPPORT_MOUSE_GESTURES 1 #define RL_SUPPORT_MOUSE_GESTURES 1
// Reconfigure standard input to receive key inputs, works with SSH connection. // Reconfigure standard input to receive key inputs, works with SSH connection.
@ -55,21 +55,21 @@
// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often. // However, it can also reduce overall system performance, because the thread scheduler switches tasks more often.
#define RL_SUPPORT_WINMM_HIGHRES_TIMER 1 #define RL_SUPPORT_WINMM_HIGHRES_TIMER 1
// Use busy wait loop for timing sync, if not defined, a high-resolution timer is set up and used // Use busy wait loop for timing sync, if not defined, a high-resolution timer is set up and used
//#define SUPPORT_BUSY_WAIT_LOOP 1 //#define RL_SUPPORT_BUSY_WAIT_LOOP 1
// Use a partial-busy wait loop, in this case frame sleeps for most of the time, but then runs a busy loop at the end for accuracy // Use a partial-busy wait loop, in this case frame sleeps for most of the time, but then runs a busy loop at the end for accuracy
#define RL_SUPPORT_PARTIALBUSY_WAIT_LOOP 1 #define RL_SUPPORT_PARTIALBUSY_WAIT_LOOP 1
// Allow automatic screen capture of current screen pressing F12, defined in KeyCallback() // Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()
#define RL_SUPPORT_SCREEN_CAPTURE 1 #define RL_SUPPORT_SCREEN_CAPTURE 1
// Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback() // Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()
#define RL_SUPPORT_GIF_RECORDING 1 #define RL_SUPPORT_GIF_RECORDING 1
// Support RL_CompressData() and RL_DecompressData() functions // Support CompressData() and DecompressData() functions
#define RL_SUPPORT_COMPRESSION_API 1 #define RL_SUPPORT_COMPRESSION_API 1
// Support automatic generated events, loading and recording of those events when required // Support automatic generated events, loading and recording of those events when required
#define RL_SUPPORT_AUTOMATION_EVENTS 1 #define RL_SUPPORT_AUTOMATION_EVENTS 1
// Support custom frame control, only for advance users // Support custom frame control, only for advance users
// By default RL_EndDrawing() does this job: draws everything + RL_SwapScreenBuffer() + manage frame timing + RL_PollInputEvents() // By default end_drawing() does this job: draws everything + swap_screen_buffer() + manage frame timing + poll_input_events()
// Enabling this flag allows manual control of the frame processes, use at your own risk // Enabling this flag allows manual control of the frame processes, use at your own risk
//#define SUPPORT_CUSTOM_FRAME_CONTROL 1 //#define RL_SUPPORT_CUSTOM_FRAME_CONTROL 1
// rcore: Configuration values // rcore: Configuration values
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
@ -90,7 +90,7 @@
#define RL_MAX_AUTOMATION_EVENTS 16384 // Maximum number of automation events to record #define RL_MAX_AUTOMATION_EVENTS 16384 // Maximum number of automation events to record
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module: RLGL_ - Configuration values // Module: rlgl - Configuration values
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Enable OpenGL Debug Context (only available on OpenGL 4.3) // Enable OpenGL Debug Context (only available on OpenGL 4.3)
@ -102,9 +102,9 @@
//#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 4096 // Default internal render batch elements limits //#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 4096 // Default internal render batch elements limits
#define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering) #define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
#define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture) #define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
#define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (RL_SetShaderValueTexture()) #define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (set_shader_value_texture())
#define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal RL_Matrix stack #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
#define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
@ -168,7 +168,7 @@
// Support procedural image generation functionality (gradient, spot, perlin-noise, cellular) // Support procedural image generation functionality (gradient, spot, perlin-noise, cellular)
#define RL_SUPPORT_IMAGE_GENERATION 1 #define RL_SUPPORT_IMAGE_GENERATION 1
// Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop... // Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop...
// If not defined, still some functions are supported: RL_ImageFormat(), RL_ImageCrop(), RL_ImageToPOT() // If not defined, still some functions are supported: image_format(), image_crop(), image_to_pot()
#define RL_SUPPORT_IMAGE_MANIPULATION 1 #define RL_SUPPORT_IMAGE_MANIPULATION 1
@ -183,18 +183,18 @@
#define RL_SUPPORT_FILEFORMAT_TTF 1 #define RL_SUPPORT_FILEFORMAT_TTF 1
// Support text management functions // Support text management functions
// If not defined, still some functions are supported: RL_TextLength(), RL_TextFormat() // If not defined, still some functions are supported: text_length(), TextFormat()
#define RL_SUPPORT_TEXT_MANIPULATION 1 #define RL_SUPPORT_TEXT_MANIPULATION 1
// On font atlas image generation [RL_GenImageFontAtlas()], add a 3x3 pixels white rectangle // On font atlas image generation [gen_image_font_atlas()], add a 3x3 pixels white rectangle
// at the bottom-right corner of the atlas. It can be useful to for shapes drawing, to allow // at the bottom-right corner of the atlas. It can be useful to for shapes drawing, to allow
// drawing text and shapes with a single draw call [RL_SetShapesTexture()]. // drawing text and shapes with a single draw call [set_shapes_texture()].
#define RL_SUPPORT_FONT_ATLAS_WHITE_REC 1 #define RL_SUPPORT_FONT_ATLAS_WHITE_REC 1
// rtext: Configuration values // rtext: Configuration values
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#define RL_MAX_TEXT_BUFFER_LENGTH 1024 // RL_Size of internal static buffers used on some functions: #define RL_MAX_TEXT_BUFFER_LENGTH 1024 // Size of internal static buffers used on some functions:
// RL_TextFormat(), RL_TextSubtext(), RL_TextToUpper(), RL_TextToLower(), RL_TextToPascal(), TextSplit() // TextFormat(), TextSubtext(), TextToUpper(), TextToLower(), TextToPascal(), TextSplit()
#define RL_MAX_TEXTSPLIT_COUNT 128 // Maximum number of substrings to split: TextSplit() #define RL_MAX_TEXTSPLIT_COUNT 128 // Maximum number of substrings to split: TextSplit()
@ -243,7 +243,7 @@
// Standard file io library (stdio.h) included // Standard file io library (stdio.h) included
#define RL_SUPPORT_STANDARD_FILEIO 1 #define RL_SUPPORT_STANDARD_FILEIO 1
// Show RL_TRACELOG() output messages // Show RL_TRACELOG() output messages
// NOTE: By default RL_LOG_DEBUG traces not shown // NOTE: By default LOG_DEBUG traces not shown
#define RL_SUPPORT_TRACELOG 1 #define RL_SUPPORT_TRACELOG 1
//#define RL_SUPPORT_TRACELOG_DEBUG 1 //#define RL_SUPPORT_TRACELOG_DEBUG 1
@ -251,12 +251,35 @@
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#define RL_MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message #define RL_MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message
#endif // RL_CONFIG_H #endif // CONFIG_H
#if defined(__cplusplus) // Indicates of raylib has been refactored
#define RL_NS_BEGIN namespace raylib { #ifndef RL_REFACTORED_CPP
#define RL_REFACTORED_CPP
#endif
#define RL_USE_CPP_NAMESPACE 1
#define RL_USE_CPP_MANGLING 1
#if RL_USE_CPP_NAMESPACE && defined(__cplusplus)
#pragma message("USING CPP NAMESPACE")
#define RL_NS_BEGIN namespace rl {
#define RL_NS_END } #define RL_NS_END }
#else #else
#define RL_NS_BEGIN #define RL_NS_BEGIN
#define RL_NS_END #define RL_NS_END
#endif #endif
#if RL_USE_CPP_MANGLING && defined(__cplusplus)
#pragma message("USING CPP MANGLING")
#define RL_EXTERN_C_BEGIN
#define RL_EXTERN_C_END
#else
#ifdef __cplusplus
#define RL_EXTERN_C_BEGIN extern "C" {
#define RL_EXTERN_C_END }
#else
#define RL_EXTERN_C_BEGIN
#define RL_EXTERN_C_END
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -72,57 +72,59 @@
#define RL_CAMERA_CULL_DISTANCE_FAR RL_CULL_DISTANCE_FAR #define RL_CAMERA_CULL_DISTANCE_FAR RL_CULL_DISTANCE_FAR
#endif #endif
RL_NS_BEGIN
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
// NOTE: Below types are required for standalone usage // NOTE: Below types are required for standalone usage
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(RCAMERA_STANDALONE) #if defined(RCAMERA_STANDALONE)
// RL_Vector2, 2 components // Vector2, 2 components
typedef struct RL_Vector2 { typedef struct Vector2 {
float x; // Vector x component float x; // Vector x component
float y; // Vector y component float y; // Vector y component
} RL_Vector2; } Vector2;
// RL_Vector3, 3 components // Vector3, 3 components
typedef struct RL_Vector3 { typedef struct Vector3 {
float x; // Vector x component float x; // Vector x component
float y; // Vector y component float y; // Vector y component
float z; // Vector z component float z; // Vector z component
} RL_Vector3; } Vector3;
// RL_Matrix, 4x4 components, column major, OpenGL style, right-handed // Matrix, 4x4 components, column major, OpenGL style, right-handed
typedef struct RL_Matrix { typedef struct Matrix {
float m0, m4, m8, m12; // RL_Matrix first row (4 components) float m0, m4, m8, m12; // Matrix first row (4 components)
float m1, m5, m9, m13; // RL_Matrix second row (4 components) float m1, m5, m9, m13; // Matrix second row (4 components)
float m2, m6, m10, m14; // RL_Matrix third row (4 components) float m2, m6, m10, m14; // Matrix third row (4 components)
float m3, m7, m11, m15; // RL_Matrix fourth row (4 components) float m3, m7, m11, m15; // Matrix fourth row (4 components)
} RL_Matrix; } Matrix;
// RL_Camera type, defines a camera position/orientation in 3d space // Camera type, defines a camera position/orientation in 3d space
typedef struct RL_Camera3D { typedef struct Camera3D {
RL_Vector3 position; // RL_Camera position Vector3 position; // Camera position
RL_Vector3 target; // RL_Camera target it looks-at Vector3 target; // Camera target it looks-at
RL_Vector3 up; // RL_Camera up vector (rotation over its axis) Vector3 up; // Camera up vector (rotation over its axis)
float fovy; // RL_Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic float fovy; // Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic
int projection; // RL_Camera projection type: RL_CAMERA_PERSPECTIVE or RL_CAMERA_ORTHOGRAPHIC int projection; // Camera projection type: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC
} RL_Camera3D; } Camera3D;
typedef RL_Camera3D RL_Camera; // RL_Camera type fallback, defaults to RL_Camera3D typedef Camera3D Camera; // Camera type fallback, defaults to Camera3D
// RL_Camera projection // Camera projection
typedef enum { typedef enum {
RL_CAMERA_PERSPECTIVE = 0, // Perspective projection CAMERA_PERSPECTIVE = 0, // Perspective projection
RL_CAMERA_ORTHOGRAPHIC // Orthographic projection CAMERA_ORTHOGRAPHIC // Orthographic projection
} RL_CameraProjection; } CameraProjection;
// RL_Camera system modes // Camera system modes
typedef enum { typedef enum {
RL_CAMERA_CUSTOM = 0, // RL_Camera custom, controlled by user (RL_UpdateCamera() does nothing) CAMERA_CUSTOM = 0, // Camera custom, controlled by user (update_camera() does nothing)
RL_CAMERA_FREE, // RL_Camera free mode CAMERA_FREE, // Camera free mode
RL_CAMERA_ORBITAL, // RL_Camera orbital, around target, zoom supported CAMERA_ORBITAL, // Camera orbital, around target, zoom supported
RL_CAMERA_FIRST_PERSON, // RL_Camera first person CAMERA_FIRST_PERSON, // Camera first person
RL_CAMERA_THIRD_PERSON // RL_Camera third person CAMERA_THIRD_PERSON // Camera third person
} RL_CameraMode; } CameraMode;
#endif #endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -134,31 +136,29 @@
// Module Functions Declaration // Module Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(__cplusplus) RL_EXTERN_C_BEGIN
extern "C" { // Prevents name mangling of functions
#endif
RLAPI RL_Vector3 GetCameraForward(RL_Camera *camera); RLAPI Vector3 get_camera_forward(Camera *camera);
RLAPI RL_Vector3 GetCameraUp(RL_Camera *camera); RLAPI Vector3 get_camera_up(Camera *camera);
RLAPI RL_Vector3 GetCameraRight(RL_Camera *camera); RLAPI Vector3 get_camera_right(Camera *camera);
// RL_Camera movement // Camera movement
RLAPI void CameraMoveForward(RL_Camera *camera, float distance, bool moveInWorldPlane); RLAPI void camera_move_forward(Camera *camera, float distance, bool moveInWorldPlane);
RLAPI void CameraMoveUp(RL_Camera *camera, float distance); RLAPI void camera_move_up(Camera *camera, float distance);
RLAPI void CameraMoveRight(RL_Camera *camera, float distance, bool moveInWorldPlane); RLAPI void camera_move_right(Camera *camera, float distance, bool moveInWorldPlane);
RLAPI void CameraMoveToTarget(RL_Camera *camera, float delta); RLAPI void camera_move_to_target(Camera *camera, float delta);
// RL_Camera rotation // Camera rotation
RLAPI void CameraYaw(RL_Camera *camera, float angle, bool rotateAroundTarget); RLAPI void camera_yaw(Camera *camera, float angle, bool rotateAroundTarget);
RLAPI void CameraPitch(RL_Camera *camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp); RLAPI void camera_pitch(Camera *camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp);
RLAPI void CameraRoll(RL_Camera *camera, float angle); RLAPI void camera_roll(Camera *camera, float angle);
RLAPI RL_Matrix GetCameraViewMatrix(RL_Camera *camera); RLAPI Matrix get_camera_view_matrix(Camera *camera);
RLAPI RL_Matrix GetCameraProjectionMatrix(RL_Camera* camera, float aspect); RLAPI Matrix get_camera_projection_matrix(Camera* camera, float aspect);
#if defined(__cplusplus) RL_EXTERN_C_END
}
#endif RL_NS_END
#endif // RCAMERA_H #endif // RCAMERA_H
@ -172,47 +172,47 @@ RLAPI RL_Matrix GetCameraProjectionMatrix(RL_Camera* camera, float aspect);
#if defined(RCAMERA_IMPLEMENTATION) #if defined(RCAMERA_IMPLEMENTATION)
#include "raymath.h" // Required for vector maths: #include "raymath.h" // Required for vector maths:
// RL_Vector3Add() // vector3_add()
// RL_Vector3Subtract() // vector3_subtract()
// RL_Vector3Scale() // vector3_scale()
// RL_Vector3Normalize() // vector3_normalize()
// RL_Vector3Distance() // vector3_distance()
// RL_Vector3CrossProduct() // vector3_cross_product()
// RL_Vector3RotateByAxisAngle() // vector3_rotate_by_axis_angle()
// RL_Vector3Angle() // vector3_angle()
// RL_Vector3Negate() // vector3_negate()
// RL_MatrixLookAt() // matrix_look_at()
// RL_MatrixPerspective() // matrix_perspective()
// RL_MatrixOrtho() // matrix_ortho()
// RL_MatrixIdentity() // matrix_identity()
// raylib required functionality: // raylib required functionality:
// RL_GetMouseDelta() // get_mouse_delta()
// RL_GetMouseWheelMove() // get_mouse_wheel_move()
// RL_IsKeyDown() // is_key_down()
// RL_IsKeyPressed() // is_key_pressed()
// RL_GetFrameTime() // get_frame_time()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Defines and Macros // Defines and Macros
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#define RL_CAMERA_MOVE_SPEED 0.09f #define CAMERA_MOVE_SPEED 0.09f
#define RL_CAMERA_ROTATION_SPEED 0.03f #define CAMERA_ROTATION_SPEED 0.03f
#define RL_CAMERA_PAN_SPEED 0.2f #define CAMERA_PAN_SPEED 0.2f
// RL_Camera mouse movement sensitivity // Camera mouse movement sensitivity
#define RL_CAMERA_MOUSE_MOVE_SENSITIVITY 0.003f // TODO: it should be independant of framerate #define CAMERA_MOUSE_MOVE_SENSITIVITY 0.003f // TODO: it should be independant of framerate
#define RL_CAMERA_MOUSE_SCROLL_SENSITIVITY 1.5f #define CAMERA_MOUSE_SCROLL_SENSITIVITY 1.5f
#define RL_CAMERA_ORBITAL_SPEED 0.5f // Radians per second #define CAMERA_ORBITAL_SPEED 0.5f // Radians per second
#define RL_CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER 8.0f #define CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER 8.0f
#define RL_CAMERA_FIRST_PERSON_STEP_DIVIDER 30.0f #define CAMERA_FIRST_PERSON_STEP_DIVIDER 30.0f
#define RL_CAMERA_FIRST_PERSON_WAVING_DIVIDER 200.0f #define CAMERA_FIRST_PERSON_WAVING_DIVIDER 200.0f
// PLAYER (used by camera) // PLAYER (used by camera)
#define RL_PLAYER_MOVEMENT_SENSITIVITY 20.0f #define PLAYER_MOVEMENT_SENSITIVITY 20.0f
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
@ -229,88 +229,90 @@ RLAPI RL_Matrix GetCameraProjectionMatrix(RL_Camera* camera, float aspect);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
//... //...
RL_NS_BEGIN
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Definition // Module Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Returns the cameras forward vector (normalized) // Returns the cameras forward vector (normalized)
RL_Vector3 GetCameraForward(RL_Camera *camera) Vector3 get_camera_forward(Camera *camera)
{ {
return RL_Vector3Normalize(RL_Vector3Subtract(camera->target, camera->position)); return vector3_normalize(vector3_subtract(camera->target, camera->position));
} }
// Returns the cameras up vector (normalized) // Returns the cameras up vector (normalized)
// Note: The up vector might not be perpendicular to the forward vector // Note: The up vector might not be perpendicular to the forward vector
RL_Vector3 GetCameraUp(RL_Camera *camera) Vector3 get_camera_up(Camera *camera)
{ {
return RL_Vector3Normalize(camera->up); return vector3_normalize(camera->up);
} }
// Returns the cameras right vector (normalized) // Returns the cameras right vector (normalized)
RL_Vector3 GetCameraRight(RL_Camera *camera) Vector3 get_camera_right(Camera *camera)
{ {
RL_Vector3 forward = GetCameraForward(camera); Vector3 forward = get_camera_forward(camera);
RL_Vector3 up = GetCameraUp(camera); Vector3 up = get_camera_up(camera);
return RL_Vector3CrossProduct(forward, up); return vector3_cross_product(forward, up);
} }
// Moves the camera in its forward direction // Moves the camera in its forward direction
void CameraMoveForward(RL_Camera *camera, float distance, bool moveInWorldPlane) void camera_move_forward(Camera *camera, float distance, bool moveInWorldPlane)
{ {
RL_Vector3 forward = GetCameraForward(camera); Vector3 forward = get_camera_forward(camera);
if (moveInWorldPlane) if (moveInWorldPlane)
{ {
// Project vector onto world plane // Project vector onto world plane
forward.y = 0; forward.y = 0;
forward = RL_Vector3Normalize(forward); forward = vector3_normalize(forward);
} }
// Scale by distance // Scale by distance
forward = RL_Vector3Scale(forward, distance); forward = vector3_scale(forward, distance);
// Move position and target // Move position and target
camera->position = RL_Vector3Add(camera->position, forward); camera->position = vector3_add(camera->position, forward);
camera->target = RL_Vector3Add(camera->target, forward); camera->target = vector3_add(camera->target, forward);
} }
// Moves the camera in its up direction // Moves the camera in its up direction
void CameraMoveUp(RL_Camera *camera, float distance) void camera_move_up(Camera *camera, float distance)
{ {
RL_Vector3 up = GetCameraUp(camera); Vector3 up = get_camera_up(camera);
// Scale by distance // Scale by distance
up = RL_Vector3Scale(up, distance); up = vector3_scale(up, distance);
// Move position and target // Move position and target
camera->position = RL_Vector3Add(camera->position, up); camera->position = vector3_add(camera->position, up);
camera->target = RL_Vector3Add(camera->target, up); camera->target = vector3_add(camera->target, up);
} }
// Moves the camera target in its current right direction // Moves the camera target in its current right direction
void CameraMoveRight(RL_Camera *camera, float distance, bool moveInWorldPlane) void camera_move_right(Camera *camera, float distance, bool moveInWorldPlane)
{ {
RL_Vector3 right = GetCameraRight(camera); Vector3 right = get_camera_right(camera);
if (moveInWorldPlane) if (moveInWorldPlane)
{ {
// Project vector onto world plane // Project vector onto world plane
right.y = 0; right.y = 0;
right = RL_Vector3Normalize(right); right = vector3_normalize(right);
} }
// Scale by distance // Scale by distance
right = RL_Vector3Scale(right, distance); right = vector3_scale(right, distance);
// Move position and target // Move position and target
camera->position = RL_Vector3Add(camera->position, right); camera->position = vector3_add(camera->position, right);
camera->target = RL_Vector3Add(camera->target, right); camera->target = vector3_add(camera->target, right);
} }
// Moves the camera position closer/farther to/from the camera target // Moves the camera position closer/farther to/from the camera target
void CameraMoveToTarget(RL_Camera *camera, float delta) void camera_move_to_target(Camera *camera, float delta)
{ {
float distance = RL_Vector3Distance(camera->position, camera->target); float distance = vector3_distance(camera->position, camera->target);
// Apply delta // Apply delta
distance += delta; distance += delta;
@ -319,213 +321,213 @@ void CameraMoveToTarget(RL_Camera *camera, float delta)
if (distance <= 0) distance = 0.001f; if (distance <= 0) distance = 0.001f;
// Set new distance by moving the position along the forward vector // Set new distance by moving the position along the forward vector
RL_Vector3 forward = GetCameraForward(camera); Vector3 forward = get_camera_forward(camera);
camera->position = RL_Vector3Add(camera->target, RL_Vector3Scale(forward, -distance)); camera->position = vector3_add(camera->target, vector3_scale(forward, -distance));
} }
// Rotates the camera around its up vector // Rotates the camera around its up vector
// Yaw is "looking left and right" // Yaw is "looking left and right"
// If rotateAroundTarget is false, the camera rotates around its position // If rotateAroundTarget is false, the camera rotates around its position
// Note: angle must be provided in radians // Note: angle must be provided in radians
void CameraYaw(RL_Camera *camera, float angle, bool rotateAroundTarget) void camera_yaw(Camera *camera, float angle, bool rotateAroundTarget)
{ {
// Rotation axis // Rotation axis
RL_Vector3 up = GetCameraUp(camera); Vector3 up = get_camera_up(camera);
// View vector // View vector
RL_Vector3 targetPosition = RL_Vector3Subtract(camera->target, camera->position); Vector3 targetPosition = vector3_subtract(camera->target, camera->position);
// Rotate view vector around up axis // Rotate view vector around up axis
targetPosition = RL_Vector3RotateByAxisAngle(targetPosition, up, angle); targetPosition = vector3_rotate_by_axis_angle(targetPosition, up, angle);
if (rotateAroundTarget) if (rotateAroundTarget)
{ {
// Move position relative to target // Move position relative to target
camera->position = RL_Vector3Subtract(camera->target, targetPosition); camera->position = vector3_subtract(camera->target, targetPosition);
} }
else // rotate around camera.position else // rotate around camera.position
{ {
// Move target relative to position // Move target relative to position
camera->target = RL_Vector3Add(camera->position, targetPosition); camera->target = vector3_add(camera->position, targetPosition);
} }
} }
// Rotates the camera around its right vector, pitch is "looking up and down" // Rotates the camera around its right vector, pitch is "looking up and down"
// - lockView prevents camera overrotation (aka "somersaults") // - lockView prevents camera overrotation (aka "somersaults")
// - rotateAroundTarget defines if rotation is around target or around its position // - rotateAroundTarget defines if rotation is around target or around its position
// - rotateUp rotates the up direction as well (typically only usefull in RL_CAMERA_FREE) // - rotateUp rotates the up direction as well (typically only usefull in CAMERA_FREE)
// NOTE: angle must be provided in radians // NOTE: angle must be provided in radians
void CameraPitch(RL_Camera *camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp) void camera_pitch(Camera *camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp)
{ {
// Up direction // Up direction
RL_Vector3 up = GetCameraUp(camera); Vector3 up = get_camera_up(camera);
// View vector // View vector
RL_Vector3 targetPosition = RL_Vector3Subtract(camera->target, camera->position); Vector3 targetPosition = vector3_subtract(camera->target, camera->position);
if (lockView) if (lockView)
{ {
// In these camera modes we clamp the Pitch angle // In these camera modes we clamp the Pitch angle
// to allow only viewing straight up or down. // to allow only viewing straight up or down.
// RL_Clamp view up // clamp view up
float maxAngleUp = RL_Vector3Angle(up, targetPosition); float maxAngleUp = vector3_angle(up, targetPosition);
maxAngleUp -= 0.001f; // avoid numerical errors maxAngleUp -= 0.001f; // avoid numerical errors
if (angle > maxAngleUp) angle = maxAngleUp; if (angle > maxAngleUp) angle = maxAngleUp;
// RL_Clamp view down // clamp view down
float maxAngleDown = RL_Vector3Angle(RL_Vector3Negate(up), targetPosition); float maxAngleDown = vector3_angle(vector3_negate(up), targetPosition);
maxAngleDown *= -1.0f; // downwards angle is negative maxAngleDown *= -1.0f; // downwards angle is negative
maxAngleDown += 0.001f; // avoid numerical errors maxAngleDown += 0.001f; // avoid numerical errors
if (angle < maxAngleDown) angle = maxAngleDown; if (angle < maxAngleDown) angle = maxAngleDown;
} }
// Rotation axis // Rotation axis
RL_Vector3 right = GetCameraRight(camera); Vector3 right = get_camera_right(camera);
// Rotate view vector around right axis // Rotate view vector around right axis
targetPosition = RL_Vector3RotateByAxisAngle(targetPosition, right, angle); targetPosition = vector3_rotate_by_axis_angle(targetPosition, right, angle);
if (rotateAroundTarget) if (rotateAroundTarget)
{ {
// Move position relative to target // Move position relative to target
camera->position = RL_Vector3Subtract(camera->target, targetPosition); camera->position = vector3_subtract(camera->target, targetPosition);
} }
else // rotate around camera.position else // rotate around camera.position
{ {
// Move target relative to position // Move target relative to position
camera->target = RL_Vector3Add(camera->position, targetPosition); camera->target = vector3_add(camera->position, targetPosition);
} }
if (rotateUp) if (rotateUp)
{ {
// Rotate up direction around right axis // Rotate up direction around right axis
camera->up = RL_Vector3RotateByAxisAngle(camera->up, right, angle); camera->up = vector3_rotate_by_axis_angle(camera->up, right, angle);
} }
} }
// Rotates the camera around its forward vector // Rotates the camera around its forward vector
// Roll is "turning your head sideways to the left or right" // Roll is "turning your head sideways to the left or right"
// Note: angle must be provided in radians // Note: angle must be provided in radians
void CameraRoll(RL_Camera *camera, float angle) void camera_roll(Camera *camera, float angle)
{ {
// Rotation axis // Rotation axis
RL_Vector3 forward = GetCameraForward(camera); Vector3 forward = get_camera_forward(camera);
// Rotate up direction around forward axis // Rotate up direction around forward axis
camera->up = RL_Vector3RotateByAxisAngle(camera->up, forward, angle); camera->up = vector3_rotate_by_axis_angle(camera->up, forward, angle);
} }
// Returns the camera view matrix // Returns the camera view matrix
RL_Matrix GetCameraViewMatrix(RL_Camera *camera) Matrix get_camera_view_matrix(Camera *camera)
{ {
return RL_MatrixLookAt(camera->position, camera->target, camera->up); return matrix_look_at(camera->position, camera->target, camera->up);
} }
// Returns the camera projection matrix // Returns the camera projection matrix
RL_Matrix GetCameraProjectionMatrix(RL_Camera *camera, float aspect) Matrix get_camera_projection_matrix(Camera *camera, float aspect)
{ {
if (camera->projection == RL_CAMERA_PERSPECTIVE) if (camera->projection == CAMERA_PERSPECTIVE)
{ {
return RL_MatrixPerspective(camera->fovy*RL_DEG2RAD, aspect, RL_CAMERA_CULL_DISTANCE_NEAR, RL_CAMERA_CULL_DISTANCE_FAR); return matrix_perspective(camera->fovy*RL_DEG2RAD, aspect, RL_CAMERA_CULL_DISTANCE_NEAR, RL_CAMERA_CULL_DISTANCE_FAR);
} }
else if (camera->projection == RL_CAMERA_ORTHOGRAPHIC) else if (camera->projection == CAMERA_ORTHOGRAPHIC)
{ {
double top = camera->fovy/2.0; double top = camera->fovy/2.0;
double right = top*aspect; double right = top*aspect;
return RL_MatrixOrtho(-right, right, -top, top, RL_CAMERA_CULL_DISTANCE_NEAR, RL_CAMERA_CULL_DISTANCE_FAR); return matrix_ortho(-right, right, -top, top, RL_CAMERA_CULL_DISTANCE_NEAR, RL_CAMERA_CULL_DISTANCE_FAR);
} }
return RL_MatrixIdentity(); return matrix_identity();
} }
#if !defined(RCAMERA_STANDALONE) #if !defined(RCAMERA_STANDALONE)
// Update camera position for selected mode // Update camera position for selected mode
// RL_Camera mode: RL_CAMERA_FREE, RL_CAMERA_FIRST_PERSON, RL_CAMERA_THIRD_PERSON, RL_CAMERA_ORBITAL or CUSTOM // Camera mode: CAMERA_FREE, CAMERA_FIRST_PERSON, CAMERA_THIRD_PERSON, CAMERA_ORBITAL or CUSTOM
void RL_UpdateCamera(RL_Camera *camera, int mode) void update_camera(Camera *camera, int mode)
{ {
RL_Vector2 mousePositionDelta = RL_GetMouseDelta(); Vector2 mousePositionDelta = get_mouse_delta();
bool moveInWorldPlane = ((mode == RL_CAMERA_FIRST_PERSON) || (mode == RL_CAMERA_THIRD_PERSON)); bool moveInWorldPlane = ((mode == CAMERA_FIRST_PERSON) || (mode == CAMERA_THIRD_PERSON));
bool rotateAroundTarget = ((mode == RL_CAMERA_THIRD_PERSON) || (mode == RL_CAMERA_ORBITAL)); bool rotateAroundTarget = ((mode == CAMERA_THIRD_PERSON) || (mode == CAMERA_ORBITAL));
bool lockView = ((mode == RL_CAMERA_FIRST_PERSON) || (mode == RL_CAMERA_THIRD_PERSON) || (mode == RL_CAMERA_ORBITAL)); bool lockView = ((mode == CAMERA_FIRST_PERSON) || (mode == CAMERA_THIRD_PERSON) || (mode == CAMERA_ORBITAL));
bool rotateUp = false; bool rotateUp = false;
if (mode == RL_CAMERA_ORBITAL) if (mode == CAMERA_ORBITAL)
{ {
// Orbital can just orbit // Orbital can just orbit
RL_Matrix rotation = RL_MatrixRotate(GetCameraUp(camera), RL_CAMERA_ORBITAL_SPEED*RL_GetFrameTime()); Matrix rotation = matrix_rotate(get_camera_up(camera), CAMERA_ORBITAL_SPEED*get_frame_time());
RL_Vector3 view = RL_Vector3Subtract(camera->position, camera->target); Vector3 view = vector3_subtract(camera->position, camera->target);
view = RL_Vector3Transform(view, rotation); view = vector3_transform(view, rotation);
camera->position = RL_Vector3Add(camera->target, view); camera->position = vector3_add(camera->target, view);
} }
else else
{ {
// RL_Camera rotation // Camera rotation
if (RL_IsKeyDown(RL_KEY_DOWN)) CameraPitch(camera, -RL_CAMERA_ROTATION_SPEED, lockView, rotateAroundTarget, rotateUp); if (is_key_down(KEY_DOWN)) camera_pitch(camera, -CAMERA_ROTATION_SPEED, lockView, rotateAroundTarget, rotateUp);
if (RL_IsKeyDown(RL_KEY_UP)) CameraPitch(camera, RL_CAMERA_ROTATION_SPEED, lockView, rotateAroundTarget, rotateUp); if (is_key_down(KEY_UP)) camera_pitch(camera, CAMERA_ROTATION_SPEED, lockView, rotateAroundTarget, rotateUp);
if (RL_IsKeyDown(RL_KEY_RIGHT)) CameraYaw(camera, -RL_CAMERA_ROTATION_SPEED, rotateAroundTarget); if (is_key_down(KEY_RIGHT)) camera_yaw(camera, -CAMERA_ROTATION_SPEED, rotateAroundTarget);
if (RL_IsKeyDown(RL_KEY_LEFT)) CameraYaw(camera, RL_CAMERA_ROTATION_SPEED, rotateAroundTarget); if (is_key_down(KEY_LEFT)) camera_yaw(camera, CAMERA_ROTATION_SPEED, rotateAroundTarget);
if (RL_IsKeyDown(RL_KEY_Q)) CameraRoll(camera, -RL_CAMERA_ROTATION_SPEED); if (is_key_down(KEY_Q)) camera_roll(camera, -CAMERA_ROTATION_SPEED);
if (RL_IsKeyDown(RL_KEY_E)) CameraRoll(camera, RL_CAMERA_ROTATION_SPEED); if (is_key_down(KEY_E)) camera_roll(camera, CAMERA_ROTATION_SPEED);
// RL_Camera movement // Camera movement
if (!RL_IsGamepadAvailable(0)) if (!is_gamepad_available(0))
{ {
// RL_Camera pan (for RL_CAMERA_FREE) // Camera pan (for CAMERA_FREE)
if ((mode == RL_CAMERA_FREE) && (RL_IsMouseButtonDown(RL_MOUSE_BUTTON_MIDDLE))) if ((mode == CAMERA_FREE) && (is_mouse_button_down(MOUSE_BUTTON_MIDDLE)))
{ {
const RL_Vector2 mouseDelta = RL_GetMouseDelta(); const Vector2 mouseDelta = get_mouse_delta();
if (mouseDelta.x > 0.0f) CameraMoveRight(camera, RL_CAMERA_PAN_SPEED, moveInWorldPlane); if (mouseDelta.x > 0.0f) camera_move_right(camera, CAMERA_PAN_SPEED, moveInWorldPlane);
if (mouseDelta.x < 0.0f) CameraMoveRight(camera, -RL_CAMERA_PAN_SPEED, moveInWorldPlane); if (mouseDelta.x < 0.0f) camera_move_right(camera, -CAMERA_PAN_SPEED, moveInWorldPlane);
if (mouseDelta.y > 0.0f) CameraMoveUp(camera, -RL_CAMERA_PAN_SPEED); if (mouseDelta.y > 0.0f) camera_move_up(camera, -CAMERA_PAN_SPEED);
if (mouseDelta.y < 0.0f) CameraMoveUp(camera, RL_CAMERA_PAN_SPEED); if (mouseDelta.y < 0.0f) camera_move_up(camera, CAMERA_PAN_SPEED);
} }
else else
{ {
// Mouse support // Mouse support
CameraYaw(camera, -mousePositionDelta.x*RL_CAMERA_MOUSE_MOVE_SENSITIVITY, rotateAroundTarget); camera_yaw(camera, -mousePositionDelta.x*CAMERA_MOUSE_MOVE_SENSITIVITY, rotateAroundTarget);
CameraPitch(camera, -mousePositionDelta.y*RL_CAMERA_MOUSE_MOVE_SENSITIVITY, lockView, rotateAroundTarget, rotateUp); camera_pitch(camera, -mousePositionDelta.y*CAMERA_MOUSE_MOVE_SENSITIVITY, lockView, rotateAroundTarget, rotateUp);
} }
// Keyboard support // Keyboard support
if (RL_IsKeyDown(RL_KEY_W)) CameraMoveForward(camera, RL_CAMERA_MOVE_SPEED, moveInWorldPlane); if (is_key_down(KEY_W)) camera_move_forward(camera, CAMERA_MOVE_SPEED, moveInWorldPlane);
if (RL_IsKeyDown(RL_KEY_A)) CameraMoveRight(camera, -RL_CAMERA_MOVE_SPEED, moveInWorldPlane); if (is_key_down(KEY_A)) camera_move_right(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane);
if (RL_IsKeyDown(RL_KEY_S)) CameraMoveForward(camera, -RL_CAMERA_MOVE_SPEED, moveInWorldPlane); if (is_key_down(KEY_S)) camera_move_forward(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane);
if (RL_IsKeyDown(RL_KEY_D)) CameraMoveRight(camera, RL_CAMERA_MOVE_SPEED, moveInWorldPlane); if (is_key_down(KEY_D)) camera_move_right(camera, CAMERA_MOVE_SPEED, moveInWorldPlane);
} }
else else
{ {
// Gamepad controller support // Gamepad controller support
CameraYaw(camera, -(RL_GetGamepadAxisMovement(0, RL_GAMEPAD_AXIS_RIGHT_X) * 2)*RL_CAMERA_MOUSE_MOVE_SENSITIVITY, rotateAroundTarget); camera_yaw(camera, -(get_gamepad_axis_movement(0, GAMEPAD_AXIS_RIGHT_X) * 2)*CAMERA_MOUSE_MOVE_SENSITIVITY, rotateAroundTarget);
CameraPitch(camera, -(RL_GetGamepadAxisMovement(0, RL_GAMEPAD_AXIS_RIGHT_Y) * 2)*RL_CAMERA_MOUSE_MOVE_SENSITIVITY, lockView, rotateAroundTarget, rotateUp); camera_pitch(camera, -(get_gamepad_axis_movement(0, GAMEPAD_AXIS_RIGHT_Y) * 2)*CAMERA_MOUSE_MOVE_SENSITIVITY, lockView, rotateAroundTarget, rotateUp);
if (RL_GetGamepadAxisMovement(0, RL_GAMEPAD_AXIS_LEFT_Y) <= -0.25f) CameraMoveForward(camera, RL_CAMERA_MOVE_SPEED, moveInWorldPlane); if (get_gamepad_axis_movement(0, GAMEPAD_AXIS_LEFT_Y) <= -0.25f) camera_move_forward(camera, CAMERA_MOVE_SPEED, moveInWorldPlane);
if (RL_GetGamepadAxisMovement(0, RL_GAMEPAD_AXIS_LEFT_X) <= -0.25f) CameraMoveRight(camera, -RL_CAMERA_MOVE_SPEED, moveInWorldPlane); if (get_gamepad_axis_movement(0, GAMEPAD_AXIS_LEFT_X) <= -0.25f) camera_move_right(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane);
if (RL_GetGamepadAxisMovement(0, RL_GAMEPAD_AXIS_LEFT_Y) >= 0.25f) CameraMoveForward(camera, -RL_CAMERA_MOVE_SPEED, moveInWorldPlane); if (get_gamepad_axis_movement(0, GAMEPAD_AXIS_LEFT_Y) >= 0.25f) camera_move_forward(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane);
if (RL_GetGamepadAxisMovement(0, RL_GAMEPAD_AXIS_LEFT_X) >= 0.25f) CameraMoveRight(camera, RL_CAMERA_MOVE_SPEED, moveInWorldPlane); if (get_gamepad_axis_movement(0, GAMEPAD_AXIS_LEFT_X) >= 0.25f) camera_move_right(camera, CAMERA_MOVE_SPEED, moveInWorldPlane);
} }
if (mode == RL_CAMERA_FREE) if (mode == CAMERA_FREE)
{ {
if (RL_IsKeyDown(RL_KEY_SPACE)) CameraMoveUp(camera, RL_CAMERA_MOVE_SPEED); if (is_key_down(KEY_SPACE)) camera_move_up(camera, CAMERA_MOVE_SPEED);
if (RL_IsKeyDown(RL_KEY_LEFT_CONTROL)) CameraMoveUp(camera, -RL_CAMERA_MOVE_SPEED); if (is_key_down(KEY_LEFT_CONTROL)) camera_move_up(camera, -CAMERA_MOVE_SPEED);
} }
} }
if ((mode == RL_CAMERA_THIRD_PERSON) || (mode == RL_CAMERA_ORBITAL) || (mode == RL_CAMERA_FREE)) if ((mode == CAMERA_THIRD_PERSON) || (mode == CAMERA_ORBITAL) || (mode == CAMERA_FREE))
{ {
// Zoom target distance // Zoom target distance
CameraMoveToTarget(camera, -RL_GetMouseWheelMove()); camera_move_to_target(camera, -get_mouse_wheel_move());
if (RL_IsKeyPressed(RL_KEY_KP_SUBTRACT)) CameraMoveToTarget(camera, 2.0f); if (is_key_pressed(KEY_KP_SUBTRACT)) camera_move_to_target(camera, 2.0f);
if (RL_IsKeyPressed(RL_KEY_KP_ADD)) CameraMoveToTarget(camera, -2.0f); if (is_key_pressed(KEY_KP_ADD)) camera_move_to_target(camera, -2.0f);
} }
} }
#endif // !RCAMERA_STANDALONE #endif // !RCAMERA_STANDALONE
// Update camera movement, movement/rotation values should be provided by user // Update camera movement, movement/rotation values should be provided by user
void RL_UpdateCameraPro(RL_Camera *camera, RL_Vector3 movement, RL_Vector3 rotation, float zoom) void update_camera_pro(Camera *camera, Vector3 movement, Vector3 rotation, float zoom)
{ {
// Required values // Required values
// movement.x - Move forward/backward // movement.x - Move forward/backward
@ -541,18 +543,20 @@ void RL_UpdateCameraPro(RL_Camera *camera, RL_Vector3 movement, RL_Vector3 rotat
bool rotateUp = false; bool rotateUp = false;
bool moveInWorldPlane = true; bool moveInWorldPlane = true;
// RL_Camera rotation // Camera rotation
CameraPitch(camera, -rotation.y*RL_DEG2RAD, lockView, rotateAroundTarget, rotateUp); camera_pitch(camera, -rotation.y*RL_DEG2RAD, lockView, rotateAroundTarget, rotateUp);
CameraYaw(camera, -rotation.x*RL_DEG2RAD, rotateAroundTarget); camera_yaw(camera, -rotation.x*RL_DEG2RAD, rotateAroundTarget);
CameraRoll(camera, rotation.z*RL_DEG2RAD); camera_roll(camera, rotation.z*RL_DEG2RAD);
// RL_Camera movement // Camera movement
CameraMoveForward(camera, movement.x, moveInWorldPlane); camera_move_forward(camera, movement.x, moveInWorldPlane);
CameraMoveRight(camera, movement.y, moveInWorldPlane); camera_move_right(camera, movement.y, moveInWorldPlane);
CameraMoveUp(camera, movement.z); camera_move_up(camera, movement.z);
// Zoom target distance // Zoom target distance
CameraMoveToTarget(camera, zoom); camera_move_to_target(camera, zoom);
} }
RL_NS_END
#endif // RCAMERA_IMPLEMENTATION #endif // RCAMERA_IMPLEMENTATION

View File

@ -65,30 +65,34 @@
typedef enum bool { false = 0, true = !false } bool; typedef enum bool { false = 0, true = !false } bool;
#endif #endif
#include "config.h"
RL_NS_BEGIN
#if !defined(RL_VECTOR2_TYPE) #if !defined(RL_VECTOR2_TYPE)
// RL_Vector2 type // Vector2 type
typedef struct RL_Vector2 { typedef struct Vector2 {
float x; float x;
float y; float y;
} RL_Vector2; } Vector2;
#endif #endif
#if defined(RGESTURES_STANDALONE) #if defined(RGESTURES_STANDALONE)
// Gestures type // Gestures type
// NOTE: It could be used as flags to enable only some gestures // NOTE: It could be used as flags to enable only some gestures
typedef enum { typedef enum {
RL_GESTURE_NONE = 0, GESTURE_NONE = 0,
RL_GESTURE_TAP = 1, GESTURE_TAP = 1,
RL_GESTURE_DOUBLETAP = 2, GESTURE_DOUBLETAP = 2,
RL_GESTURE_HOLD = 4, GESTURE_HOLD = 4,
RL_GESTURE_DRAG = 8, GESTURE_DRAG = 8,
RL_GESTURE_SWIPE_RIGHT = 16, GESTURE_SWIPE_RIGHT = 16,
RL_GESTURE_SWIPE_LEFT = 32, GESTURE_SWIPE_LEFT = 32,
RL_GESTURE_SWIPE_UP = 64, GESTURE_SWIPE_UP = 64,
RL_GESTURE_SWIPE_DOWN = 128, GESTURE_SWIPE_DOWN = 128,
RL_GESTURE_PINCH_IN = 256, GESTURE_PINCH_IN = 256,
RL_GESTURE_PINCH_OUT = 512 GESTURE_PINCH_OUT = 512
} RL_Gesture; } Gesture;
#endif #endif
typedef enum { typedef enum {
@ -96,15 +100,15 @@ typedef enum {
TOUCH_ACTION_DOWN, TOUCH_ACTION_DOWN,
TOUCH_ACTION_MOVE, TOUCH_ACTION_MOVE,
TOUCH_ACTION_CANCEL TOUCH_ACTION_CANCEL
} RL_TouchAction; } TouchAction;
// RL_Gesture event // Gesture event
typedef struct { typedef struct {
int touchAction; int touchAction;
int pointCount; int pointCount;
int pointId[RL_MAX_TOUCH_POINTS]; int pointId[RL_MAX_TOUCH_POINTS];
RL_Vector2 position[RL_MAX_TOUCH_POINTS]; Vector2 position[RL_MAX_TOUCH_POINTS];
} RL_GestureEvent; } GestureEvent;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition // Global Variables Definition
@ -115,28 +119,26 @@ typedef struct {
// Module Functions Declaration // Module Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(__cplusplus) RL_EXTERN_C_BEGIN
extern "C" { // Prevents name mangling of functions
#endif
void RL_ProcessGestureEvent(RL_GestureEvent event); // Process gesture event and translate it into gestures void process_gesture_event(GestureEvent event); // Process gesture event and translate it into gestures
void RL_UpdateGestures(void); // Update gestures detected (must be called every frame) void update_gestures(void); // Update gestures detected (must be called every frame)
#if defined(RGESTURES_STANDALONE) #if defined(RGESTURES_STANDALONE)
void RL_SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags void set_gestures_enabled(unsigned int flags); // Enable a set of gestures using flags
bool RL_IsGestureDetected(int gesture); // Check if a gesture have been detected bool is_gesture_detected(int gesture); // Check if a gesture have been detected
int RL_GetGestureDetected(void); // Get latest detected gesture int get_gesture_detected(void); // Get latest detected gesture
float RL_GetGestureHoldDuration(void); // Get gesture hold time in seconds float get_gesture_hold_duration(void); // Get gesture hold time in seconds
RL_Vector2 RL_GetGestureDragVector(void); // Get gesture drag vector Vector2 get_gesture_drag_vector(void); // Get gesture drag vector
float RL_GetGestureDragAngle(void); // Get gesture drag angle float get_gesture_drag_angle(void); // Get gesture drag angle
RL_Vector2 RL_GetGesturePinchVector(void); // Get gesture pinch delta Vector2 get_gesture_pinch_vector(void); // Get gesture pinch delta
float RL_GetGesturePinchAngle(void); // Get gesture pinch angle float get_gesture_pinch_angle(void); // Get gesture pinch angle
#endif #endif
#if defined(__cplusplus) RL_EXTERN_C_END
}
#endif RL_NS_END
#endif // RGESTURES_H #endif // RGESTURES_H
@ -154,8 +156,8 @@ float RL_GetGesturePinchAngle(void); // Get gesture pinch
extern "C" { // Prevents name mangling of functions extern "C" { // Prevents name mangling of functions
#endif #endif
// Functions required to query time on Windows // Functions required to query time on Windows
int __stdcall RL_QueryPerformanceCounter(unsigned long long int *lpPerformanceCount); int __stdcall query_performance_counter(unsigned long long int *lpPerformanceCount);
int __stdcall RL_QueryPerformanceFrequency(unsigned long long int *lpFrequency); int __stdcall query_performance_frequency(unsigned long long int *lpFrequency);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
@ -186,6 +188,8 @@ float RL_GetGesturePinchAngle(void); // Get gesture pinch
#define RL_PINCH_TIMEOUT 0.3f // Pinch minimum time, measured in seconds #define RL_PINCH_TIMEOUT 0.3f // Pinch minimum time, measured in seconds
#define RL_DOUBLETAP_RANGE 0.03f // DoubleTap range, measured in normalized screen units (0.0f to 1.0f) #define RL_DOUBLETAP_RANGE 0.03f // DoubleTap range, measured in normalized screen units (0.0f to 1.0f)
RL_NS_BEGIN
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -198,14 +202,14 @@ typedef struct {
int firstId; // Touch id for first touch point int firstId; // Touch id for first touch point
int pointCount; // Touch points counter int pointCount; // Touch points counter
double eventTime; // Time stamp when an event happened double eventTime; // Time stamp when an event happened
RL_Vector2 upPosition; // Touch up position Vector2 upPosition; // Touch up position
RL_Vector2 downPositionA; // First touch down position Vector2 downPositionA; // First touch down position
RL_Vector2 downPositionB; // Second touch down position Vector2 downPositionB; // Second touch down position
RL_Vector2 downDragPosition; // Touch drag position Vector2 downDragPosition; // Touch drag position
RL_Vector2 moveDownPositionA; // First touch down position on move Vector2 moveDownPositionA; // First touch down position on move
RL_Vector2 moveDownPositionB; // Second touch down position on move Vector2 moveDownPositionB; // Second touch down position on move
RL_Vector2 previousPositionA; // Previous position A to compare for pinch gestures Vector2 previousPositionA; // Previous position A to compare for pinch gestures
RL_Vector2 previousPositionB; // Previous position B to compare for pinch gestures Vector2 previousPositionB; // Previous position B to compare for pinch gestures
int tapCounter; // TAP counter (one tap implies TOUCH_ACTION_DOWN and TOUCH_ACTION_UP actions) int tapCounter; // TAP counter (one tap implies TOUCH_ACTION_DOWN and TOUCH_ACTION_UP actions)
} Touch; } Touch;
struct { struct {
@ -213,7 +217,7 @@ typedef struct {
double timeDuration; // HOLD duration in seconds double timeDuration; // HOLD duration in seconds
} Hold; } Hold;
struct { struct {
RL_Vector2 vector; // DRAG vector (between initial and current position) Vector2 vector; // DRAG vector (between initial and current position)
float angle; // DRAG angle (relative to x-axis) float angle; // DRAG angle (relative to x-axis)
float distance; // DRAG distance (from initial touch point to final) (normalized [0..1]) float distance; // DRAG distance (from initial touch point to final) (normalized [0..1])
float intensity; // DRAG intensity, how far why did the DRAG (pixels per frame) float intensity; // DRAG intensity, how far why did the DRAG (pixels per frame)
@ -222,269 +226,287 @@ typedef struct {
double startTime; // SWIPE start time to calculate drag intensity double startTime; // SWIPE start time to calculate drag intensity
} Swipe; } Swipe;
struct { struct {
RL_Vector2 vector; // PINCH vector (between first and second touch points) Vector2 vector; // PINCH vector (between first and second touch points)
float angle; // PINCH angle (relative to x-axis) float angle; // PINCH angle (relative to x-axis)
float distance; // PINCH displacement distance (normalized [0..1]) float distance; // PINCH displacement distance (normalized [0..1])
} Pinch; } Pinch;
} RL_GesturesData; } GesturesData;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition // Global Variables Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
static RL_GesturesData RL_GESTURES = { static GesturesData GESTURES = {
#ifdef __cplusplus
(unsigned int)-1,
GESTURE_NONE,
0b0000001111111111
#else
.Touch.firstId = -1, .Touch.firstId = -1,
.current = RL_GESTURE_NONE, // No current gesture detected .current = GESTURE_NONE, // No current gesture detected
.enabledFlags = 0b0000001111111111 // All gestures supported by default .enabledFlags = 0b0000001111111111 // All gestures supported by default
#endif
}; };
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module specific Functions Declaration // Module specific Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
static float rgVector2Angle(RL_Vector2 initialPosition, RL_Vector2 finalPosition); static float rg_vector2_angle(Vector2 initialPosition, Vector2 finalPosition);
static float rgVector2Distance(RL_Vector2 v1, RL_Vector2 v2); static float rg_vector2_distance(Vector2 v1, Vector2 v2);
static double rgGetCurrentTime(void); static double rg_get_current_time(void);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Definition // Module Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Enable only desired gestures to be detected // Enable only desired gestures to be detected
void RL_SetGesturesEnabled(unsigned int flags) void set_gestures_enabled(unsigned int flags)
{ {
RL_GESTURES.enabledFlags = flags; GESTURES.enabledFlags = flags;
} }
// Check if a gesture have been detected // Check if a gesture have been detected
bool RL_IsGestureDetected(unsigned int gesture) bool is_gesture_detected(unsigned int gesture)
{ {
if ((RL_GESTURES.enabledFlags & RL_GESTURES.current) == gesture) return true; if ((GESTURES.enabledFlags & GESTURES.current) == gesture) return true;
else return false; else return false;
} }
// Process gesture event and translate it into gestures // Process gesture event and translate it into gestures
void RL_ProcessGestureEvent(RL_GestureEvent event) void process_gesture_event(GestureEvent event)
{ {
// Reset required variables // Reset required variables
RL_GESTURES.Touch.pointCount = event.pointCount; // Required on RL_UpdateGestures() GESTURES.Touch.pointCount = event.pointCount; // Required on update_gestures()
if (RL_GESTURES.Touch.pointCount == 1) // One touch point if (GESTURES.Touch.pointCount == 1) // One touch point
{ {
if (event.touchAction == TOUCH_ACTION_DOWN) if (event.touchAction == TOUCH_ACTION_DOWN)
{ {
RL_GESTURES.Touch.tapCounter++; // Tap counter GESTURES.Touch.tapCounter++; // Tap counter
// Detect GESTURE_DOUBLE_TAP // Detect GESTURE_DOUBLE_TAP
if ((RL_GESTURES.current == RL_GESTURE_NONE) && (RL_GESTURES.Touch.tapCounter >= 2) && ((rgGetCurrentTime() - RL_GESTURES.Touch.eventTime) < RL_TAP_TIMEOUT) && (rgVector2Distance(RL_GESTURES.Touch.downPositionA, event.position[0]) < RL_DOUBLETAP_RANGE)) if ((GESTURES.current == GESTURE_NONE) && (GESTURES.Touch.tapCounter >= 2) && ((rg_get_current_time() - GESTURES.Touch.eventTime) < RL_TAP_TIMEOUT) && (rg_vector2_distance(GESTURES.Touch.downPositionA, event.position[0]) < RL_DOUBLETAP_RANGE))
{ {
RL_GESTURES.current = RL_GESTURE_DOUBLETAP; GESTURES.current = GESTURE_DOUBLETAP;
RL_GESTURES.Touch.tapCounter = 0; GESTURES.Touch.tapCounter = 0;
} }
else // Detect RL_GESTURE_TAP else // Detect GESTURE_TAP
{ {
RL_GESTURES.Touch.tapCounter = 1; GESTURES.Touch.tapCounter = 1;
RL_GESTURES.current = RL_GESTURE_TAP; GESTURES.current = GESTURE_TAP;
} }
RL_GESTURES.Touch.downPositionA = event.position[0]; GESTURES.Touch.downPositionA = event.position[0];
RL_GESTURES.Touch.downDragPosition = event.position[0]; GESTURES.Touch.downDragPosition = event.position[0];
RL_GESTURES.Touch.upPosition = RL_GESTURES.Touch.downPositionA; GESTURES.Touch.upPosition = GESTURES.Touch.downPositionA;
RL_GESTURES.Touch.eventTime = rgGetCurrentTime(); GESTURES.Touch.eventTime = rg_get_current_time();
RL_GESTURES.Swipe.startTime = rgGetCurrentTime(); GESTURES.Swipe.startTime = rg_get_current_time();
RL_GESTURES.Drag.vector = (RL_Vector2){ 0.0f, 0.0f }; #ifdef __cplusplus
GESTURES.Drag.vector = Vector2{ 0.0f, 0.0f };
#else
GESTURES.Drag.vector = (Vector2){ 0.0f, 0.0f };
#endif
} }
else if (event.touchAction == TOUCH_ACTION_UP) else if (event.touchAction == TOUCH_ACTION_UP)
{ {
// A swipe can happen while the current gesture is drag, but (specially for web) also hold, so set upPosition for both cases // A swipe can happen while the current gesture is drag, but (specially for web) also hold, so set upPosition for both cases
if (RL_GESTURES.current == RL_GESTURE_DRAG || RL_GESTURES.current == RL_GESTURE_HOLD) RL_GESTURES.Touch.upPosition = event.position[0]; if (GESTURES.current == GESTURE_DRAG || GESTURES.current == GESTURE_HOLD) GESTURES.Touch.upPosition = event.position[0];
// NOTE: RL_GESTURES.Drag.intensity dependent on the resolution of the screen // NOTE: GESTURES.Drag.intensity dependent on the resolution of the screen
RL_GESTURES.Drag.distance = rgVector2Distance(RL_GESTURES.Touch.downPositionA, RL_GESTURES.Touch.upPosition); GESTURES.Drag.distance = rg_vector2_distance(GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition);
RL_GESTURES.Drag.intensity = RL_GESTURES.Drag.distance/(float)((rgGetCurrentTime() - RL_GESTURES.Swipe.startTime)); GESTURES.Drag.intensity = GESTURES.Drag.distance/(float)((rg_get_current_time() - GESTURES.Swipe.startTime));
// Detect GESTURE_SWIPE // Detect GESTURE_SWIPE
if ((RL_GESTURES.Drag.intensity > RL_FORCE_TO_SWIPE) && (RL_GESTURES.current != RL_GESTURE_DRAG)) if ((GESTURES.Drag.intensity > RL_FORCE_TO_SWIPE) && (GESTURES.current != GESTURE_DRAG))
{ {
// NOTE: Angle should be inverted in Y // NOTE: Angle should be inverted in Y
RL_GESTURES.Drag.angle = 360.0f - rgVector2Angle(RL_GESTURES.Touch.downPositionA, RL_GESTURES.Touch.upPosition); GESTURES.Drag.angle = 360.0f - rg_vector2_angle(GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition);
if ((RL_GESTURES.Drag.angle < 30) || (RL_GESTURES.Drag.angle > 330)) RL_GESTURES.current = RL_GESTURE_SWIPE_RIGHT; // Right if ((GESTURES.Drag.angle < 30) || (GESTURES.Drag.angle > 330)) GESTURES.current = GESTURE_SWIPE_RIGHT; // Right
else if ((RL_GESTURES.Drag.angle >= 30) && (RL_GESTURES.Drag.angle <= 150)) RL_GESTURES.current = RL_GESTURE_SWIPE_UP; // Up else if ((GESTURES.Drag.angle >= 30) && (GESTURES.Drag.angle <= 150)) GESTURES.current = GESTURE_SWIPE_UP; // Up
else if ((RL_GESTURES.Drag.angle > 150) && (RL_GESTURES.Drag.angle < 210)) RL_GESTURES.current = RL_GESTURE_SWIPE_LEFT; // Left else if ((GESTURES.Drag.angle > 150) && (GESTURES.Drag.angle < 210)) GESTURES.current = GESTURE_SWIPE_LEFT; // Left
else if ((RL_GESTURES.Drag.angle >= 210) && (RL_GESTURES.Drag.angle <= 330)) RL_GESTURES.current = RL_GESTURE_SWIPE_DOWN; // Down else if ((GESTURES.Drag.angle >= 210) && (GESTURES.Drag.angle <= 330)) GESTURES.current = GESTURE_SWIPE_DOWN; // Down
else RL_GESTURES.current = RL_GESTURE_NONE; else GESTURES.current = GESTURE_NONE;
} }
else else
{ {
RL_GESTURES.Drag.distance = 0.0f; GESTURES.Drag.distance = 0.0f;
RL_GESTURES.Drag.intensity = 0.0f; GESTURES.Drag.intensity = 0.0f;
RL_GESTURES.Drag.angle = 0.0f; GESTURES.Drag.angle = 0.0f;
RL_GESTURES.current = RL_GESTURE_NONE; GESTURES.current = GESTURE_NONE;
} }
RL_GESTURES.Touch.downDragPosition = (RL_Vector2){ 0.0f, 0.0f }; #if __cplusplus
RL_GESTURES.Touch.pointCount = 0; GESTURES.Touch.downDragPosition = Vector2{ 0.0f, 0.0f };
#else
GESTURES.Touch.downDragPosition = (Vector2){ 0.0f, 0.0f };
#endif
GESTURES.Touch.pointCount = 0;
} }
else if (event.touchAction == TOUCH_ACTION_MOVE) else if (event.touchAction == TOUCH_ACTION_MOVE)
{ {
RL_GESTURES.Touch.moveDownPositionA = event.position[0]; GESTURES.Touch.moveDownPositionA = event.position[0];
if (RL_GESTURES.current == RL_GESTURE_HOLD) if (GESTURES.current == GESTURE_HOLD)
{ {
if (RL_GESTURES.Hold.resetRequired) RL_GESTURES.Touch.downPositionA = event.position[0]; if (GESTURES.Hold.resetRequired) GESTURES.Touch.downPositionA = event.position[0];
RL_GESTURES.Hold.resetRequired = false; GESTURES.Hold.resetRequired = false;
// Detect RL_GESTURE_DRAG // Detect GESTURE_DRAG
if ((rgGetCurrentTime() - RL_GESTURES.Touch.eventTime) > RL_DRAG_TIMEOUT) if ((rg_get_current_time() - GESTURES.Touch.eventTime) > RL_DRAG_TIMEOUT)
{ {
RL_GESTURES.Touch.eventTime = rgGetCurrentTime(); GESTURES.Touch.eventTime = rg_get_current_time();
RL_GESTURES.current = RL_GESTURE_DRAG; GESTURES.current = GESTURE_DRAG;
} }
} }
RL_GESTURES.Drag.vector.x = RL_GESTURES.Touch.moveDownPositionA.x - RL_GESTURES.Touch.downDragPosition.x; GESTURES.Drag.vector.x = GESTURES.Touch.moveDownPositionA.x - GESTURES.Touch.downDragPosition.x;
RL_GESTURES.Drag.vector.y = RL_GESTURES.Touch.moveDownPositionA.y - RL_GESTURES.Touch.downDragPosition.y; GESTURES.Drag.vector.y = GESTURES.Touch.moveDownPositionA.y - GESTURES.Touch.downDragPosition.y;
} }
} }
else if (RL_GESTURES.Touch.pointCount == 2) // Two touch points else if (GESTURES.Touch.pointCount == 2) // Two touch points
{ {
if (event.touchAction == TOUCH_ACTION_DOWN) if (event.touchAction == TOUCH_ACTION_DOWN)
{ {
RL_GESTURES.Touch.downPositionA = event.position[0]; GESTURES.Touch.downPositionA = event.position[0];
RL_GESTURES.Touch.downPositionB = event.position[1]; GESTURES.Touch.downPositionB = event.position[1];
RL_GESTURES.Touch.previousPositionA = RL_GESTURES.Touch.downPositionA; GESTURES.Touch.previousPositionA = GESTURES.Touch.downPositionA;
RL_GESTURES.Touch.previousPositionB = RL_GESTURES.Touch.downPositionB; GESTURES.Touch.previousPositionB = GESTURES.Touch.downPositionB;
//RL_GESTURES.Pinch.distance = rgVector2Distance(RL_GESTURES.Touch.downPositionA, RL_GESTURES.Touch.downPositionB); //GESTURES.Pinch.distance = rg_vector2_distance(GESTURES.Touch.downPositionA, GESTURES.Touch.downPositionB);
RL_GESTURES.Pinch.vector.x = RL_GESTURES.Touch.downPositionB.x - RL_GESTURES.Touch.downPositionA.x; GESTURES.Pinch.vector.x = GESTURES.Touch.downPositionB.x - GESTURES.Touch.downPositionA.x;
RL_GESTURES.Pinch.vector.y = RL_GESTURES.Touch.downPositionB.y - RL_GESTURES.Touch.downPositionA.y; GESTURES.Pinch.vector.y = GESTURES.Touch.downPositionB.y - GESTURES.Touch.downPositionA.y;
RL_GESTURES.current = RL_GESTURE_HOLD; GESTURES.current = GESTURE_HOLD;
RL_GESTURES.Hold.timeDuration = rgGetCurrentTime(); GESTURES.Hold.timeDuration = rg_get_current_time();
} }
else if (event.touchAction == TOUCH_ACTION_MOVE) else if (event.touchAction == TOUCH_ACTION_MOVE)
{ {
RL_GESTURES.Pinch.distance = rgVector2Distance(RL_GESTURES.Touch.moveDownPositionA, RL_GESTURES.Touch.moveDownPositionB); GESTURES.Pinch.distance = rg_vector2_distance(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB);
RL_GESTURES.Touch.moveDownPositionA = event.position[0]; GESTURES.Touch.moveDownPositionA = event.position[0];
RL_GESTURES.Touch.moveDownPositionB = event.position[1]; GESTURES.Touch.moveDownPositionB = event.position[1];
RL_GESTURES.Pinch.vector.x = RL_GESTURES.Touch.moveDownPositionB.x - RL_GESTURES.Touch.moveDownPositionA.x; GESTURES.Pinch.vector.x = GESTURES.Touch.moveDownPositionB.x - GESTURES.Touch.moveDownPositionA.x;
RL_GESTURES.Pinch.vector.y = RL_GESTURES.Touch.moveDownPositionB.y - RL_GESTURES.Touch.moveDownPositionA.y; GESTURES.Pinch.vector.y = GESTURES.Touch.moveDownPositionB.y - GESTURES.Touch.moveDownPositionA.y;
if ((rgVector2Distance(RL_GESTURES.Touch.previousPositionA, RL_GESTURES.Touch.moveDownPositionA) >= RL_MINIMUM_PINCH) || (rgVector2Distance(RL_GESTURES.Touch.previousPositionB, RL_GESTURES.Touch.moveDownPositionB) >= RL_MINIMUM_PINCH)) if ((rg_vector2_distance(GESTURES.Touch.previousPositionA, GESTURES.Touch.moveDownPositionA) >= RL_MINIMUM_PINCH) || (rg_vector2_distance(GESTURES.Touch.previousPositionB, GESTURES.Touch.moveDownPositionB) >= RL_MINIMUM_PINCH))
{ {
if ( rgVector2Distance(RL_GESTURES.Touch.previousPositionA, RL_GESTURES.Touch.previousPositionB) > rgVector2Distance(RL_GESTURES.Touch.moveDownPositionA, RL_GESTURES.Touch.moveDownPositionB) ) RL_GESTURES.current = RL_GESTURE_PINCH_IN; if ( rg_vector2_distance(GESTURES.Touch.previousPositionA, GESTURES.Touch.previousPositionB) > rg_vector2_distance(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB) ) GESTURES.current = GESTURE_PINCH_IN;
else RL_GESTURES.current = RL_GESTURE_PINCH_OUT; else GESTURES.current = GESTURE_PINCH_OUT;
} }
else else
{ {
RL_GESTURES.current = RL_GESTURE_HOLD; GESTURES.current = GESTURE_HOLD;
RL_GESTURES.Hold.timeDuration = rgGetCurrentTime(); GESTURES.Hold.timeDuration = rg_get_current_time();
} }
// NOTE: Angle should be inverted in Y // NOTE: Angle should be inverted in Y
RL_GESTURES.Pinch.angle = 360.0f - rgVector2Angle(RL_GESTURES.Touch.moveDownPositionA, RL_GESTURES.Touch.moveDownPositionB); GESTURES.Pinch.angle = 360.0f - rg_vector2_angle(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB);
} }
else if (event.touchAction == TOUCH_ACTION_UP) else if (event.touchAction == TOUCH_ACTION_UP)
{ {
RL_GESTURES.Pinch.distance = 0.0f; GESTURES.Pinch.distance = 0.0f;
RL_GESTURES.Pinch.angle = 0.0f; GESTURES.Pinch.angle = 0.0f;
RL_GESTURES.Pinch.vector = (RL_Vector2){ 0.0f, 0.0f }; #if __cplusplus
RL_GESTURES.Touch.pointCount = 0; GESTURES.Pinch.vector = Vector2{ 0.0f, 0.0f };
#else
GESTURES.Pinch.vector = (Vector2){ 0.0f, 0.0f };
#endif
GESTURES.Touch.pointCount = 0;
RL_GESTURES.current = RL_GESTURE_NONE; GESTURES.current = GESTURE_NONE;
} }
} }
else if (RL_GESTURES.Touch.pointCount > 2) // More than two touch points else if (GESTURES.Touch.pointCount > 2) // More than two touch points
{ {
// TODO: Process gesture events for more than two points // TODO: Process gesture events for more than two points
} }
} }
// Update gestures detected (must be called every frame) // Update gestures detected (must be called every frame)
void RL_UpdateGestures(void) void update_gestures(void)
{ {
// NOTE: Gestures are processed through system callbacks on touch events // NOTE: Gestures are processed through system callbacks on touch events
// Detect RL_GESTURE_HOLD // Detect GESTURE_HOLD
if (((RL_GESTURES.current == RL_GESTURE_TAP) || (RL_GESTURES.current == RL_GESTURE_DOUBLETAP)) && (RL_GESTURES.Touch.pointCount < 2)) if (((GESTURES.current == GESTURE_TAP) || (GESTURES.current == GESTURE_DOUBLETAP)) && (GESTURES.Touch.pointCount < 2))
{ {
RL_GESTURES.current = RL_GESTURE_HOLD; GESTURES.current = GESTURE_HOLD;
RL_GESTURES.Hold.timeDuration = rgGetCurrentTime(); GESTURES.Hold.timeDuration = rg_get_current_time();
} }
// Detect RL_GESTURE_NONE // Detect GESTURE_NONE
if ((RL_GESTURES.current == RL_GESTURE_SWIPE_RIGHT) || (RL_GESTURES.current == RL_GESTURE_SWIPE_UP) || (RL_GESTURES.current == RL_GESTURE_SWIPE_LEFT) || (RL_GESTURES.current == RL_GESTURE_SWIPE_DOWN)) if ((GESTURES.current == GESTURE_SWIPE_RIGHT) || (GESTURES.current == GESTURE_SWIPE_UP) || (GESTURES.current == GESTURE_SWIPE_LEFT) || (GESTURES.current == GESTURE_SWIPE_DOWN))
{ {
RL_GESTURES.current = RL_GESTURE_NONE; GESTURES.current = GESTURE_NONE;
} }
} }
// Get latest detected gesture // Get latest detected gesture
int RL_GetGestureDetected(void) int get_gesture_detected(void)
{ {
// Get current gesture only if enabled // Get current gesture only if enabled
return (RL_GESTURES.enabledFlags & RL_GESTURES.current); return (GESTURES.enabledFlags & GESTURES.current);
} }
// Hold time measured in ms // Hold time measured in ms
float RL_GetGestureHoldDuration(void) float get_gesture_hold_duration(void)
{ {
// NOTE: time is calculated on current gesture HOLD // NOTE: time is calculated on current gesture HOLD
double time = 0.0; double time = 0.0;
if (RL_GESTURES.current == RL_GESTURE_HOLD) time = rgGetCurrentTime() - RL_GESTURES.Hold.timeDuration; if (GESTURES.current == GESTURE_HOLD) time = rg_get_current_time() - GESTURES.Hold.timeDuration;
return (float)time; return (float)time;
} }
// Get drag vector (between initial touch point to current) // Get drag vector (between initial touch point to current)
RL_Vector2 RL_GetGestureDragVector(void) Vector2 get_gesture_drag_vector(void)
{ {
// NOTE: drag vector is calculated on one touch points TOUCH_ACTION_MOVE // NOTE: drag vector is calculated on one touch points TOUCH_ACTION_MOVE
return RL_GESTURES.Drag.vector; return GESTURES.Drag.vector;
} }
// Get drag angle // Get drag angle
// NOTE: Angle in degrees, horizontal-right is 0, counterclockwise // NOTE: Angle in degrees, horizontal-right is 0, counterclockwise
float RL_GetGestureDragAngle(void) float get_gesture_drag_angle(void)
{ {
// NOTE: drag angle is calculated on one touch points TOUCH_ACTION_UP // NOTE: drag angle is calculated on one touch points TOUCH_ACTION_UP
return RL_GESTURES.Drag.angle; return GESTURES.Drag.angle;
} }
// Get distance between two pinch points // Get distance between two pinch points
RL_Vector2 RL_GetGesturePinchVector(void) Vector2 get_gesture_pinch_vector(void)
{ {
// NOTE: Pinch distance is calculated on two touch points TOUCH_ACTION_MOVE // NOTE: Pinch distance is calculated on two touch points TOUCH_ACTION_MOVE
return RL_GESTURES.Pinch.vector; return GESTURES.Pinch.vector;
} }
// Get angle between two pinch points // Get angle between two pinch points
// NOTE: Angle in degrees, horizontal-right is 0, counterclockwise // NOTE: Angle in degrees, horizontal-right is 0, counterclockwise
float RL_GetGesturePinchAngle(void) float get_gesture_pinch_angle(void)
{ {
// NOTE: pinch angle is calculated on two touch points TOUCH_ACTION_MOVE // NOTE: pinch angle is calculated on two touch points TOUCH_ACTION_MOVE
return RL_GESTURES.Pinch.angle; return GESTURES.Pinch.angle;
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module specific Functions Definition // Module specific Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Get angle from two-points vector with X-axis // Get angle from two-points vector with X-axis
static float rgVector2Angle(RL_Vector2 v1, RL_Vector2 v2) static float rg_vector2_angle(Vector2 v1, Vector2 v2)
{ {
float angle = atan2f(v2.y - v1.y, v2.x - v1.x)*(180.0f/RL_PI); float angle = atan2f(v2.y - v1.y, v2.x - v1.x)*(180.0f/RL_PI);
@ -493,8 +515,8 @@ static float rgVector2Angle(RL_Vector2 v1, RL_Vector2 v2)
return angle; return angle;
} }
// Calculate distance between two RL_Vector2 // Calculate distance between two Vector2
static float rgVector2Distance(RL_Vector2 v1, RL_Vector2 v2) static float rg_vector2_distance(Vector2 v1, Vector2 v2)
{ {
float result; float result;
@ -507,18 +529,18 @@ static float rgVector2Distance(RL_Vector2 v1, RL_Vector2 v2)
} }
// Time measure returned are seconds // Time measure returned are seconds
static double rgGetCurrentTime(void) static double rg_get_current_time(void)
{ {
double time = 0; double time = 0;
#if !defined(RGESTURES_STANDALONE) #if !defined(RGESTURES_STANDALONE)
time = RL_GetTime(); time = get_time();
#else #else
#if defined(_WIN32) #if defined(_WIN32)
unsigned long long int clockFrequency, currentTime; unsigned long long int clockFrequency, currentTime;
RL_QueryPerformanceFrequency(&clockFrequency); // BE CAREFUL: Costly operation! query_performance_frequency(&clockFrequency); // BE CAREFUL: Costly operation!
RL_QueryPerformanceCounter(&currentTime); query_performance_counter(&currentTime);
time = (double)currentTime/clockFrequency; // Time in seconds time = (double)currentTime/clockFrequency; // Time in seconds
#endif #endif
@ -552,4 +574,6 @@ static double rgGetCurrentTime(void)
return time; return time;
} }
RL_NS_END
#endif // RGESTURES_IMPLEMENTATION #endif // RGESTURES_IMPLEMENTATION

File diff suppressed because it is too large Load Diff

View File

@ -33,10 +33,10 @@
#endif #endif
#if defined(RL_SUPPORT_TRACELOG) #if defined(RL_SUPPORT_TRACELOG)
#define RL_TRACELOG(level, ...) RL_TraceLog(level, __VA_ARGS__) #define RL_TRACELOG(level, ...) RL_NS(trace_log)(level, __VA_ARGS__)
#if defined(RL_SUPPORT_TRACELOG_DEBUG) #if defined(RL_SUPPORT_TRACELOG_DEBUG)
#define TRACELOGD(...) RL_TraceLog(RL_LOG_DEBUG, __VA_ARGS__) #define TRACELOGD(...) RL_NS(trace_log)(LOG_DEBUG, __VA_ARGS__)
#else #else
#define TRACELOGD(...) (void)0 #define TRACELOGD(...) (void)0
#endif #endif
@ -70,7 +70,7 @@ extern "C" { // Prevents name mangling of functions
#endif #endif
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
void InitAssetManager(AAssetManager *manager, const char *dataPath); // Initialize asset manager from android app void init_asset_manager(AAssetManager *manager, const char *dataPath); // Initialize asset manager from android app
FILE *android_fopen(const char *fileName, const char *mode); // Replacement for fopen() -> Read-only! FILE *android_fopen(const char *fileName, const char *mode); // Replacement for fopen() -> Read-only!
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +0,0 @@
// rlgl.h
//namespace rlgl, RL_
namespace rl, RLGL_
//namespace RL_, RLGL_
namespace RL_OPENGL, RLGL_OPENGL
//word RLAPI, RLGLAPI
not include rlgl.h
word TRACELOG, RL_TRACELOG
not word RL_TEXTURE_MIN_FILTER
not word RL_TEXTURE_MAG_FILTER
not word RL_TEXTURE_FILTER_LINEAR
not word RL_PROJECTION
not word RL_MODELVIEW
not word RL_LINES
not word RL_TRIANGLES
not word RL_QUADS
not word RL_FLOAT
not word RL_UNSIGNED_BYTE
not word RL_MATRIX
word RLGL, RLGL_GLOBAL_DATA
word Matrix, RL_Matrix
word LOG_WARNING, RL_LOG_WARNING
word rlglInit, RLGL_Init
word rlglClose, RLGL_Close

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,242 @@
// rlgl.h
word RL_NOT_REFACTORED, RL_REFACTORED_CPP
namespace rl_,
namespace rl,
namespace rlgl,
not word rl
not word rlgl
namespace RL_LOG_, LOG_
namespace RL_PIXELFORMAT_, PIXELFORMAT_
namespace RL_TEXTURE_, TEXTURE_
namespace RL_SHADER_, SHADER_
namespace RL_BLEND_, BLEND_
namespace RL_ATTACHMENT_, ATTACHMENT_
namespace RL_CULL_, CULL_
not include rlgl.h
word TRACELOG, RL_TRACELOG
word RLGL, GLOBAL_DATA
word Vector2, Vector2
word Vector3, Vector3
word Vector4, Vector4
word Quaternion, Quaternion
word Matrix, Matrix
word Color, Color
word Rectangle, Rectangle
word Image, Image
word Texture, Texture
word Texture2D, Texture2d
word TextureCubemap, Texture_Cubemap
word RenderTexture, Render_Texture
word RenderTexture2D, Render_Texture2D
word NPatchInfo, N_Patch_Info
word GlyphInfo, Glyph_Info
word Font, Font
word Camera3D, Camera3D
word Camera, Camera
word Camera2D, Camera2D
word Mesh, Mesh
word Shader, Shader
word MaterialMap, Material_Map
word Material, Material
word Transform, Transform
word BoneInfo, Bone_Info
word Model, Model
word ModelAnimation, Model_Animation
word Ray, Ray
word RayCollision, Ray_Collision
word BoundingBox, Bounding_box
word Wave, Wave
word rAudioBuffer, Audio_Buffer
word rAudioProcessor, Audio_Processor
word AudioStream, Audio_Stream
word Sound, Sound
word Music, Music
word VrDeviceInfo, VR_Device_Info
word VrStereoConfig, VR_Stereo_Config
word FilePathList, File_Path_List
word AutomationEvent, Automation_Event
word AutomationEventList, Automation_Event_List
word Matrix, Matrix
word rlVertexBuffer, vertex_buffer
word rlDrawCall, draw_call
word rlRenderBatch, render_batch
word rlGlVersion, gl_version
word rlTraceLogLevel, trace_log_level
word rlPixelFormat, pixel_format
word rlTextureFilter, texture_filter
word rlShaderLocationIndex, shader_location_index
word rlShaderUniformDataType, shader_uniform_data_type
word rlShaderAttributeDataType, shader_attribute_data_type
word rlBlendMode, blend_mode
word rlFramebufferAttachType, framebuffer_attach_type
word rlFramebufferAttachTextureType, framebuffer_attach_texture_type
word rlCullMode, cull_mode
word get_pixel_data_size, gpu_get_pixel_data_size
word rlMatrixMode, matrix_mode
word rlPushMatrix, push_matrix
word rlPopMatrix, pop_matrix
word rlLoadIdentity, load_identity
word rlTranslatef, translatef
word rlRotatef, rotatef
word rlScalef, scalef
word rlMultMatrixf, mult_matrixf
word rlFrustum, frustum
word rlOrtho, ortho
word rlViewport, viewport
word rlBegin, begin
word rlEnd, end
word rlVertex2i, vertex2i
word rlVertex2f, vertex2f
word rlVertex3f, vertex3f
word rlTexCoord2f, tex_coord2f
word rlNormal3f, normal3f
word rlColor4ub, color4ub
word rlColor3f, color3f
word rlColor4f, color4f
word rlEnableVertexArray, enable_vertex_array
word rlDisableVertexArray, disable_vertex_array
word rlEnableVertexBuffer, enable_vertex_buffer
word rlDisableVertexBuffer, disable_vertex_buffer
word rlEnableVertexBufferElement, enable_vertex_buffer_element
word rlDisableVertexBufferElement, disable_vertex_buffer_element
word rlEnableVertexAttribute, enable_vertex_attribute
word rlDisableVertexAttribute, disable_vertex_attribute
word rlEnableStatePointer, enable_state_pointer
word rlDisableStatePointer, disable_state_pointer
word rlActiveTextureSlot, active_texture_slot
word rlEnableTexture, enable_texture
word rlDisableTexture, disable_texture
word rlEnableTextureCubemap, enable_texture_cubemap
word rlDisableTextureCubemap, disable_texture_cubemap
word rlTextureParameters, texture_parameters
word rlCubemapParameters, cubemap_parameters
word rlEnableShader, enable_shader
word rlDisableShader, disable_shader
word rlEnableFramebuffer, enable_framebuffer
word rlDisableFramebuffer, disable_framebuffer
word rlActiveDrawBuffers, active_draw_buffers
word rlBlitFramebuffer, blit_framebuffer
word rlEnableColorBlend, enable_color_blend
word rlDisableColorBlend, disable_color_blend
word rlEnableDepthTest, enable_depth_test
word rlDisableDepthTest, disable_depth_test
word rlEnableDepthMask, enable_depth_mask
word rlDisableDepthMask, disable_depth_mask
word rlEnableBackfaceCulling, enable_backface_culling
word rlDisableBackfaceCulling, disable_backface_culling
word rlSetCullFace, set_cull_face
word rlEnableScissorTest, enable_scissor_test
word rlDisableScissorTest, disable_scissor_test
word rlScissor, scissor
word rlEnableWireMode, enable_wire_mode
word rlEnablePointMode, enable_point_mode
word rlDisableWireMode, disable_wire_mode
word rlSetLineWidth, set_line_width
word rlGetLineWidth, get_line_width
word rlEnableSmoothLines, enable_smooth_lines
word rlDisableSmoothLines, disable_smooth_lines
word rlEnableStereoRender, enable_stereo_render
word rlDisableStereoRender, disable_stereo_render
word rlIsStereoRenderEnabled, is_stereo_render_enabled
word rlClearColor, clear_color
word rlClearScreenBuffers, clear_screen_buffers
word rlCheckErrors, check_errors
word rlSetBlendMode, set_blend_mode
word rlSetBlendFactors, set_blend_factors
word rlSetBlendFactorsSeparate, set_blend_factors_separate
word rlglInit, init
word rlglClose, close
word rlLoadExtensions, load_extensions
word rlGetVersion, get_version
word rlSetFramebufferWidth, set_framebuffer_width
word rlGetFramebufferWidth, get_framebuffer_width
word rlSetFramebufferHeight, set_framebuffer_height
word rlGetFramebufferHeight, get_framebuffer_height
word rlGetTextureIdDefault, get_texture_id_default
word rlGetShaderIdDefault, get_shader_id_default
word rlLoadRenderBatch, load_render_batch
word rlUnloadRenderBatch, unload_render_batch
word rlDrawRenderBatch, draw_render_batch
word rlSetRenderBatchActive, set_render_batch_active
word rlDrawRenderBatchActive, draw_render_batch_active
word rlCheckRenderBatchLimit, check_render_batch_limit
word rlSetTexture, set_texture
word rlLoadVertexArray, load_vertex_array
word rlLoadVertexBuffer, load_vertex_buffer
word rlLoadVertexBufferElement, load_vertex_buffer_element
word rlUpdateVertexBuffer, update_vertex_buffer
word rlUpdateVertexBufferElements, update_vertex_buffer_elements
word rlUnloadVertexArray, unload_vertex_array
word rlUnloadVertexBuffer, unload_vertex_buffer
word rlSetVertexAttribute, set_vertex_attribute
word rlSetVertexAttributeDivisor, set_vertex_attribute_divisor
word rlSetVertexAttributeDefault, set_vertex_attribute_default
word rlDrawVertexArray, draw_vertex_array
word rlDrawVertexArrayElements, draw_vertex_array_elements
word rlDrawVertexArrayInstanced, draw_vertex_array_instanced
word rlDrawVertexArrayElementsInstanced, draw_vertex_array_elements_instanced
word rlLoadTexture, load_texture
word rlLoadTextureDepth, load_texture_depth
word rlLoadTextureCubemap, load_texture_cubemap
word rlUpdateTexture, update_texture
word rlGetGlTextureFormats, get_gl_texture_formats
word rlUnloadTexture, unload_texture
word rlGenTextureMipmaps, gen_texture_mipmaps
word rlLoadFramebuffer, load_framebuffer
word rlFramebufferAttach, framebuffer_attach
word rlFramebufferComplete, framebuffer_complete
word rlUnloadFramebuffer, unload_framebuffer
word rlLoadShaderCode, load_shader_code
word rlCompileShader, compile_shader
word rlLoadShaderProgram, load_shader_program
word rlUnloadShaderProgram, unload_shader_program
word rlGetLocationUniform, get_location_uniform
word rlGetLocationAttrib, get_location_attrib
word rlSetUniform, set_uniform
word rlSetUniformMatrix, set_uniform_matrix
word rlSetUniformSampler, set_uniform_sampler
word rlSetShader, set_shader
word rlLoadComputeShaderProgram, load_compute_shader_program
word rlComputeShaderDispatch, compute_shader_dispatch
word rlLoadShaderBuffer, load_shader_buffer
word rlUnloadShaderBuffer, unload_shader_buffer
word rlUpdateShaderBuffer, update_shader_buffer
word rlBindShaderBuffer, bind_shader_buffer
word rlReadShaderBuffer, read_shader_buffer
word rlCopyShaderBuffer, copy_shader_buffer
word rlGetShaderBufferSize, get_shader_buffer_size
word rlBindImageTexture, bind_image_texture
word rlGetMatrixModelview, get_matrix_modelview
word rlGetMatrixProjection, get_matrix_projection
word rlGetMatrixTransform, get_matrix_transform
word rlGetMatrixProjectionStereo, get_matrix_projection_stereo
word rlGetMatrixViewOffsetStereo, get_matrix_view_offset_stereo
word rlSetMatrixProjection, set_matrix_projection
word rlSetMatrixModelview, set_matrix_modelview
word rlSetMatrixProjectionStereo, set_matrix_projection_stereo
word rlSetMatrixViewOffsetStereo, set_matrix_view_offset_stereo
word rlLoadDrawCube, load_draw_cube
word rlLoadDrawQuad, load_draw_quad
word rlLoadShaderDefault, load_shader_default
word rlUnloadShaderDefault, unload_shader_default
word rlGetPixelDataSize, internal_get_pixel_data_size
word rlMatrixIdentity, internal_matrix_identity
word rlMatrixMultiply, internal_matrix_multiply
word rlCheckRenderBatchLimit, check_render_batch_limit
word rlLoadShaderDefault, load_shader_default
word rlSetMatrixProjection, set_matrix_projection
word rlUnloadFramebuffer, unload_framebuffer
word rlReadScreenPixels, read_screen_pixels
word rlReadTexturePixels, read_texture_pixels
word rlGetShaderLocsDefault, get_shader_locs_default
word rlGetPixelFormatName, get_pixel_format_name

View File

@ -49,8 +49,10 @@ switch ($_){
. $incremental_checks . $incremental_checks
# Clear out the current content first # Clear out the current content first
# remove-item $path_temp -Recurse if ( test-path $path_temp) {
# New-Item -ItemType Directory -Path $path_temp remove-item $path_temp -Recurse
}
New-Item -ItemType Directory -Path $path_temp
if ( -not (Test-Path $path_binaries) ) { if ( -not (Test-Path $path_binaries) ) {
New-Item -ItemType Directory -Path $path_binaries New-Item -ItemType Directory -Path $path_binaries
@ -76,8 +78,10 @@ function setup-raylib {
$path_raylib_glfw_inc = join-path $path_raylib_src 'external/glfw/include' $path_raylib_glfw_inc = join-path $path_raylib_src 'external/glfw/include'
$path_raylib_gputex = join-path $path_raylib_src 'external/rl_gputex.h' $path_raylib_gputex = join-path $path_raylib_src 'external/rl_gputex.h'
remove-item $path_raylib_master -Recurse if ( test-path $path_raylib_master ) {
#invoke-webrequest -uri $url_raylib_zip -outfile $path_raylib_zip remove-item $path_raylib_master -Recurse
}
invoke-webrequest -uri $url_raylib_zip -outfile $path_raylib_zip
expand-archive -path $path_raylib_zip -destinationpath $path_temp expand-archive -path $path_raylib_zip -destinationpath $path_temp
write-host "Building raylib with $vendor" write-host "Building raylib with $vendor"
@ -87,27 +91,27 @@ function setup-raylib {
New-Item $path_build -ItemType Directory New-Item $path_build -ItemType Directory
} }
$raylib_headers = Get-ChildItem -Path $path_raylib_src -Filter '*.h' -File $raylib_headers = Get-ChildItem -Path $path_raylib_src -Filter '*.h' -File
$raylib_modules = get-childitem -path $path_raylib_src -filter '*.c' -file $raylib_modules = get-childitem -path $path_raylib_src -filter '*.c' -file
# Refactor with refactor.exe # Refactor with refactor.exe
if ( $true ) { if ( $true ) {
$path_refactor = join-path $path_raylib 'raylib_c.refactor' $path_refactor = join-path $path_raylib 'raylib_cpp.refactor'
$path_refactor_rlgl = join-path $path_raylib 'raylib_c_gl.refactor' $path_refactor_rlgl = join-path $path_raylib 'raylib_cpp_gl.refactor'
$fmt_includes = @() $files = @()
foreach ( $header in $raylib_headers ) { foreach ( $header in $raylib_headers ) {
$file_name = split-path $header -leaf $file_name = split-path $header -leaf
if ( -not $file_name.Equals('rlgl.h' ) ) { if ( -not $file_name.Equals('rlgl.h' ) ) {
$fmt_includes += "$header" $files += "$header"
} }
} }
foreach ( $module in $raylib_modules ) { foreach ( $module in $raylib_modules ) {
$fmt_includes += "$module" $files += "$module"
} }
$fmt_includes += "$path_raylib_gputex" $files += "$path_raylib_gputex"
$platform_modules = @() $platform_modules = @()
foreach ( $module in (get-childitem -path $path_raylib_platforms -filter '*.c' -file) ) { foreach ( $module in (get-childitem -path $path_raylib_platforms -filter '*.c' -file) ) {
@ -120,9 +124,9 @@ function setup-raylib {
write-host "Beginning refactor...`n" write-host "Beginning refactor...`n"
$refactors = @(@()) $refactors = @(@())
$refactorParams = @( $refactorParams = @(
"-debug", # "-debug",
"-num=$($fmt_includes.Count)" "-num=$($files.Count)"
"-src=$($fmt_includes)", "-src=$($files)",
"-spec=$($path_refactor)" "-spec=$($path_refactor)"
) )
& refactor $refactorParams & refactor $refactorParams
@ -133,7 +137,7 @@ function setup-raylib {
write-host "Beginning refactor...`n" write-host "Beginning refactor...`n"
$refactors = @(@()) $refactors = @(@())
$refactorParams = @( $refactorParams = @(
"-debug", # "-debug",
"-num=$($platform_modules.Count)" "-num=$($platform_modules.Count)"
"-src=$($platform_modules)", "-src=$($platform_modules)",
"-spec=$($path_refactor)" "-spec=$($path_refactor)"
@ -148,7 +152,7 @@ function setup-raylib {
write-host "Beginning refactor just for rlgl.h...`n" write-host "Beginning refactor just for rlgl.h...`n"
$refactors = @(@()) $refactors = @(@())
$refactorParams = @( $refactorParams = @(
"-debug", # "-debug",
"-num=$($gl_modules.Count)" "-num=$($gl_modules.Count)"
"-src=$($gl_modules)", "-src=$($gl_modules)",
"-spec=$($path_refactor_rlgl)" "-spec=$($path_refactor_rlgl)"
@ -221,7 +225,8 @@ function setup-raylib {
$compiler_args = @( $compiler_args = @(
($flag_define + 'PLATFORM_DESKTOP'), ($flag_define + 'PLATFORM_DESKTOP'),
($flag_define + 'BUILD_LIBTYPE_SHARED') ($flag_define + 'RL_BUILD_LIBTYPE_SHARED'),
$flag_all_cpp
) )
$linker_args = @( $linker_args = @(
$flag_link_dll, $flag_link_dll,
@ -244,5 +249,6 @@ function setup-raylib {
foreach ($header in $raylib_headers) { foreach ($header in $raylib_headers) {
Copy-Item -Path $header -Destination (join-path $path_raylib_inc (split-path $header -Leaf)) Copy-Item -Path $header -Destination (join-path $path_raylib_inc (split-path $header -Leaf))
} }
remove-item -path $path_temp -Recurse
} }
setup-raylib setup-raylib

View File

@ -92,8 +92,8 @@ function run-linker
if ( $vendor -match "clang" ) if ( $vendor -match "clang" )
{ {
# https://clang.llvm.org/docs/ClangCommandLineReference.html # https://clang.llvm.org/docs/ClangCommandLineReference.html
$flag_all_c = '/TC' $flag_all_c = '-x c'
$flag_all_cpp = '/TP' $flag_all_cpp = '-x c++'
$flag_compile = '-c' $flag_compile = '-c'
$flag_color_diagnostics = '-fcolor-diagnostics' $flag_color_diagnostics = '-fcolor-diagnostics'
$flag_no_color_diagnostics = '-fno-color-diagnostics' $flag_no_color_diagnostics = '-fno-color-diagnostics'