diff --git a/.gitignore b/.gitignore index 48d644c..9ef8613 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,7 @@ docs/vendor *.exe *.bak *.hbx +*.log lib tmp +.vscode diff --git a/README.md b/README.md index a126129..61cda90 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,20 @@ -# hb-raylib v3.5 +# hb-raylib v4.0.0 + +**Harbour** bindings for raylib 3.7.0, a simple and easy to use library to learn videogames programming [**raylib v3.7.0**](https://www.raylib.com). The project has an educational nature - the main goal is to expand knowledge in the field of creating the aplications with the usege of Harbour programing language. -**Harbour** bindings for raylib 3.5, a simple and easy to use library to learn videogames programming [**raylib v3.5**](https://www.raylib.com). The project has an educational nature - the main goal is to expand knowledge in the field of creating the aplications with the usege of Harbour programing language. ### Getting Started Installing **hb-raylib** requires **RayLib** including its headers. For more info see [**getting started**](examples/README.md). +### Platforms + +| OS | Supported | +|---------| ------------------ | +| Mac | :heavy_check_mark: | +| Linux | :heavy_check_mark: | +| Windows | :heavy_check_mark: | + ## License [![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](.git/LICENSE) diff --git a/docs/README.md b/docs/README.md index 0b8df78..bf3e3a1 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1 +1 @@ -# Website for hb-raylib v3.5 \ No newline at end of file +# Website for hb-raylib v3.7 \ No newline at end of file diff --git a/docs/assets/img/shapes/Colors_palette.gif b/docs/assets/img/shapes/Colors_palette.gif new file mode 100644 index 0000000..7a65659 Binary files /dev/null and b/docs/assets/img/shapes/Colors_palette.gif differ diff --git a/docs/assets/img/text/text_writing_anim.png b/docs/assets/img/text/text_writing_anim.png new file mode 100644 index 0000000..c34b655 Binary files /dev/null and b/docs/assets/img/text/text_writing_anim.png differ diff --git a/docs/audio.md b/docs/audio.md index d5c52a8..0ba8f44 100644 --- a/docs/audio.md +++ b/docs/audio.md @@ -362,6 +362,16 @@ Load music stream from file --- +#### LoadMusicStreamFromMemory() + +```c + +Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int dataSize); + +``` + +--- + #### UnloadMusicStream() ```c @@ -386,6 +396,18 @@ Start music playing --- +#### IsMusicPlaying() + +```c + +bool IsMusicPlaying(Music music); + +``` + +Check if music is playing + +--- + #### UpdateMusicStream() ```c @@ -434,27 +456,15 @@ Resume playing paused music --- -#### IsMusicPlaying() - -```c - -bool IsMusicPlaying( Music music ); - -``` - -Check if music is playing - ---- - -#### SetMusicVolume() + #### SetMusicVolume() ```c -void SetMusicVolume( Music music, float volume ); + void SetMusicVolume(Music music, float volume); ``` -Set volume for music ( 1.0 is max level ) +Set volume for music (1.0 is max level) --- diff --git a/docs/colors.md b/docs/colors.md index 8bc9fbd..5c92078 100644 --- a/docs/colors.md +++ b/docs/colors.md @@ -29,6 +29,7 @@ permalink: colors #define BEIGE (Color){ 211, 176, 131, 255 } // Beige #define BROWN (Color){ 127, 106, 79, 255 } // Brown #define DARKBROWN (Color){ 76, 63, 47, 255 } // Dark Brown + #define WHITE (Color){ 255, 255, 255, 255 } // White #define BLACK (Color){ 0, 0, 0, 255 } // Black #define BLANK (Color){ 0, 0, 0, 0 } // Transparent diff --git a/docs/core.md b/docs/core.md index 8948266..478cb4e 100644 --- a/docs/core.md +++ b/docs/core.md @@ -332,6 +332,18 @@ Get number of connected monitors --- +#### GetCurrentMonitor() + +```c + +int GetCurrentMonitor(void); + +``` + +Get specified monitor position + +--- + #### GetMonitorPosition() ```c @@ -428,7 +440,7 @@ Get window scale DPI factor --- -GetMonitorName() +## GetMonitorName() ```c @@ -648,6 +660,54 @@ Ends drawing to render texture --- +#### BeginShaderMode() + +```c + +void BeginShaderMode(Shader shader); + +``` + +Begin custom shader drawing + +--- + +#### EndShaderMode() + +```c + +void EndShaderMode(void); + +``` + +End custom shader drawing (use default shader) + +--- + +#### BeginBlendMode() + +```c + +void BeginBlendMode(int mode); + +``` + +Begin blending mode (alpha, additive, multiplied) + +--- + +#### EndBlendMode() + +```c + +void EndBlendMode(void); + +``` + +End blending mode (reset to default: alpha blending) + +--- + #### BeginScissorMode() ```c @@ -672,6 +732,167 @@ End scissor mode --- +#### BeginVrStereoMode() + +```c + +void BeginVrStereoMode(VrStereoConfig config); + +``` + +Begin stereo rendering + +--- + +#### EndVrStereoMode() + +```c + +void EndVrStereoMode(void); + +``` + +End stereo rendering + +--- + +## VR stereo config functions for VR simulator + +#### VrStereoConfig LoadVrStereoConfig() + +```c + +VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device); + +``` + +Load VR stereo config for VR simulator device parameters + +--- + +#### UnloadVrStereoConfig() + +```c + +void UnloadVrStereoConfig(VrStereoConfig config); + +``` + +Unload VR stereo config + + +## Shader management functions + +## NOTE: Shader functionality is not available on OpenGL 1.1 + +#### Shader LoadShader() + +```c + +Shader LoadShader(const char *vsFileName, const char *fsFileName); + +``` + +Load shader from files and bind default locations + +--- + +#### Shader LoadShaderFromMemory() + +```c + +Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode); + +``` + +Load shader from code strings and bind default locations + +--- + +#### GetShaderLocation() + +```c + +int GetShaderLocation(Shader shader, const char *uniformName); + +``` + +Get shader uniform location + +--- + +#### GetShaderLocationAttrib() + +```c + +int GetShaderLocationAttrib(Shader shader, const char *attribName); + +``` + +Get shader attribute location + +--- + +#### SetShaderValue() + +```c + +void SetShaderValue(Shader shader, int locIndex, const void *value, int uniformType); + +``` + +Set shader uniform value + +--- + +#### SetShaderValueV() + +```c + +void SetShaderValueV(Shader shader, int locIndex, const void *value, int uniformType, int count); + +``` + +Set shader uniform value vector + +--- + +#### SetShaderValueMatrix() + +```c + +void SetShaderValueMatrix(Shader shader, int locIndex, Matrix mat); + +``` + +Set shader uniform value (matrix 4x4) + +--- + +#### SetShaderValueTexture() + +```c + +void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture); + +``` + +Set shader uniform value for texture (sampler2d) + +--- + +#### UnloadShader() + +```c + +void UnloadShader(Shader shader); + +``` + +Unload shader from GPU memory (VRAM) + +--- + ## Screen-space-related functions #### GetMouseRay() @@ -810,6 +1031,30 @@ Returns elapsed time in seconds since InitWindow( ) ## Misc. functions +#### GetRandomValue() + +```c + +int GetRandomValue(int min, int max); + +``` + +Returns a random value between min and max (both included) + +--- + +#### TakeScreenshot() + +```c + +void TakeScreenshot(const char *fileName); + +``` + +Takes a screenshot of current screen (filename extension defines format) + +--- + #### SetConfigFlags() ```c @@ -822,6 +1067,18 @@ Setup init configuration flags ( view FLAGS ) --- +#### TraceLog() + +```c + +void TraceLog(int logType, const char *text, ...); + +``` + +Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR) + +--- + #### SetTraceLogLevel() ```c @@ -834,87 +1091,89 @@ Set the current threshold ( minimum ) log level --- -#### SetTraceLogExit() +#### MemAlloc() ```c -void SetTraceLogExit( int logType ); +void *MemAlloc(int size); ``` -Set the exit threshold ( minimum ) log level +Internal memory allocator --- -#### SetTraceLogCallback() +#### MemFree() ```c -void SetTraceLogCallback( TraceLogCallback callback ); +void MemFree(void *ptr); ``` -Set a trace log callback to enable custom logging +Internal memory free ---- +## Set custom callbacks -#### TraceLog() +## WARNING: Callbacks setup is intended for advance users + +#### SetTraceLogCallback() ```c -void TraceLog( int logType, const char *text, ... ); +void SetTraceLogCallback( TraceLogCallback callback ); ``` -Show trace log messages ( LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR ) +Set a trace log callback to enable custom logging --- -#### MemAlloc() +#### SetLoadFileDataCallback() ```c -void *MemAlloc( int size ); +void SetLoadFileDataCallback(LoadFileDataCallback callback); ``` -Internal memory allocator +Set custom file binary data loader --- -#### MemFree() +#### SetSaveFileDataCallback() ```c -void MemFree( void *ptr ); +void SetSaveFileDataCallback(SaveFileDataCallback callback); ``` -Internal memory free +Set custom file binary data saver --- -#### TakeScreenshot() +#### SetLoadFileTextCallback() ```c -void TakeScreenshot( const char *fileName ); +void SetLoadFileTextCallback(LoadFileTextCallback callback); ``` -Takes a screenshot of current screen ( saved a .png ) +Set custom file text data loader --- -#### GetRandomValue() +#### SetSaveFileTextCallback() ```c -int GetRandomValue( int min, int max ); +void SetSaveFileTextCallback(SaveFileTextCallback callback); ``` -Returns a random value between min and max ( both included ) +Set custom file text data saver --- @@ -1210,7 +1469,7 @@ Decompress data ( DEFLATE algorithm ) ## Persistent storage management -SaveStorageValue +#### SaveStorageValue ```c @@ -1590,18 +1849,6 @@ Returns mouse wheel movement Y --- -#### GetMouseCursor() - -```c - -int GetMouseCursor( void ); - -``` - -Returns mouse cursor if ( MouseCursor enum ) - ---- - #### SetMouseCursor() ```c diff --git a/docs/index.md b/docs/index.md index 06d2353..03c5ee8 100644 --- a/docs/index.md +++ b/docs/index.md @@ -7,16 +7,15 @@ title: "hb-raylib" ![Logo](assets/img/harbour_raylib.svg) -**hb-raylib v3.5** is a cross-platform open-source software development library. The library is meant to create graphical applications and games. The source code is written in C Language. It supports compilation to many target platforms, including Windows, GNU Linux, macOS, FreeBSD, Android. +**hb-raylib v3.7** is a cross-platform open-source software development library. The library is meant to create graphical applications and games. The source code is written in C Language. It supports compilation to many target platforms, including Windows, GNU Linux, macOS, FreeBSD, Android. View the project on [GitHub](https://github.com/rjopek/hb-raylib) -### Function reference v3.5 +### Function reference v3.7 > - [module: audio](audio "module: audio") > - [module: core](core "module: core") > - [module: models](models "module: models") -> - [module: shaders](shaders "module: shaders") > - [module: shapes](shapes "module: shapes") > - [module: text](text "module: text") > - [module: textures](textures "module: textures") @@ -62,7 +61,7 @@ PROCEDURE Main() [![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](LICENSE) -This site is based on the original [RayLib v3.5](https://www.raylib.com/cheatsheet/cheatsheet.html) documentation. +This site is based on the original [RayLib v3.7](https://www.raylib.com/cheatsheet/cheatsheet.html) documentation. License MIT is obviously applied only for this repository, not what it builds. diff --git a/docs/models.md b/docs/models.md index de53b25..2c7d374 100644 --- a/docs/models.md +++ b/docs/models.md @@ -224,18 +224,6 @@ Draw a grid ( centered at ( 0, 0, 0 ) ) --- -#### DrawGizmo() - -```c - -void DrawGizmo( Vector3 position ); - -``` - -Draw simple gizmo - ---- - ## Model loading/unloading functions #### LoadModel() @@ -288,27 +276,63 @@ Unload model ( but not meshes ) from memory ( RAM and/or VRAM ) ## Mesh loading/unloading functions -#### LoadMeshes() + +#### UnloadMesh() ```c -Mesh *LoadMeshes( const char *fileName, int *meshCount ); +void UnloadMesh( Mesh mesh ); ``` -Load meshes from model file +Unload mesh from memory ( RAM and/or VRAM ) --- -#### UnloadMesh() +#### UpdateMeshBuffer() ```c -void UnloadMesh( Mesh mesh ); +void UpdateMeshBuffer(Mesh mesh, int index, void *data, int dataSize, int offset); ``` -Unload mesh from memory ( RAM and/or VRAM ) +Update mesh vertex data in GPU for a specific buffer index + +--- + +#### DrawMesh() + +```c + +void DrawMesh(Mesh mesh, Material material, Matrix transform); + +``` +Draw a 3d mesh with material and transform + +--- + + ### DrawMeshInstanced() + +```c + + void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int instances); + +``` + +Draw multiple mesh instances with material and different transforms + +--- + +#### UnloadMesh() + +```c + +void UnloadMesh(Mesh mesh); + +``` + +Export mesh data to file, returns true on success --- @@ -768,11 +792,12 @@ Detect collision between ray and box --- -#### GetCollisionRayMesh() + +#### GetCollisionRayMesh(); ```c -RayHitInfo GetCollisionRayMesh( Ray ray, Mesh mesh, Matrix transform ); +RayHitInfo GetCollisionRayMesh(Ray ray, Mesh mesh, Matrix transform); ``` diff --git a/docs/shaders.md b/docs/shaders.md deleted file mode 100644 index bc6ef10..0000000 --- a/docs/shaders.md +++ /dev/null @@ -1,375 +0,0 @@ ---- -layout: default -title: module shaders -permalink: shaders ---- - -# **Function reference module: shaders** - -## Shader loading/unloading functions - -#### LoadShader() - -```c - -Shader LoadShader( const char *vsFileName, const char *fsFileName ); - -``` - -Load shader from files and bind default locations - ---- - -#### LoadShaderCode() - -```c - -Shader LoadShaderCode( const char *vsCode, const char *fsCode ); - -``` - -Load shader from code strings and bind default locations - ---- - -#### UnloadShader() - -```c - -void UnloadShader( Shader shader ); - -``` - -Unload shader from GPU memory ( VRAM ) - ---- - -#### GetShaderDefault() - -```c - -Shader GetShaderDefault( void ); - -``` - -Get default shader - ---- - -#### GetTextureDefault() - -```c - -Texture2D GetTextureDefault( void ); - -``` - -Get default texture - ---- - -#### GetShapesTexture() - -```c - -Texture2D GetShapesTexture( void ); - -``` - -Get texture to draw shapes - ---- - -#### GetShapesTextureRec() - -```c - -Rectangle GetShapesTextureRec( void ); - -``` - -Get texture rectangle to draw shapes - ---- - -#### SetShapesTexture() - -```c - -void SetShapesTexture( Texture2D texture, Rectangle source ); - -``` - -Define default texture used to draw shapes - ---- - -## Shader configuration functions - -#### GetShaderLocation() - -```c - -int GetShaderLocation( Shader shader, const char *uniformName ); - -``` - -Get shader uniform location - ---- - -#### GetShaderLocationAttrib() - -```c - -int GetShaderLocationAttrib( Shader shader, const char *attribName ); - -``` - -Get shader attribute location - ---- - -#### SetShaderValue() - -```c - -void SetShaderValue( Shader shader, int uniformLoc, const void *value, int uniformType ); - -``` - -Set shader uniform value - ---- - -#### SetShaderValueV() - -```c - -void SetShaderValueV( Shader shader, int uniformLoc, const void *value, int uniformType, int count ); - -``` - -Set shader uniform value vector - ---- - -#### SetShaderValueMatrix() - -```c - -void SetShaderValueMatrix( Shader shader, int uniformLoc, Matrix mat ); - -``` - -Set shader uniform value ( matrix 4x4 ) - ---- - -#### SetShaderValueTexture() - -```c - -void SetShaderValueTexture( Shader shader, int uniformLoc, Texture2D texture ); - -``` - -Set shader uniform value for texture - ---- - -#### SetMatrixProjection() - -```c - -void SetMatrixProjection( Matrix proj ); - -``` - -Set a custom projection matrix ( replaces internal projection matrix ) - ---- - -#### SetMatrixModelview() - -```c - -void SetMatrixModelview( Matrix view ); - -``` - -Set a custom modelview matrix ( replaces internal modelview matrix ) - ---- - -#### GetMatrixModelview() - -```c - -Matrix GetMatrixModelview( void ); - -``` - -Get internal modelview matrix - ---- - -#### GetMatrixProjection() - -```c - -Matrix GetMatrixProjection( void ); - -``` - -Get internal projection matrix - ---- - -## Shading begin/end functions - -#### BeginShaderMode() - -```c - -void BeginShaderMode( Shader shader ); - -``` - -Begin custom shader drawing - ---- - -#### EndShaderMode() - -```c - -void EndShaderMode( void ); - -``` - -End custom shader drawing ( use default shader ) - ---- - -#### BeginBlendMode() - -```c - -void BeginBlendMode( int mode ); - -``` - -Begin blending mode ( alpha, additive, multiplied ) - ---- - -#### EndBlendMode() - -```c - -void EndBlendMode( void ); - -``` - -End blending mode ( reset to default: alpha blending ) - ---- - -## VR control functions - -#### InitVrSimulator() - -```c - -void InitVrSimulator( void ); - -``` - -Init VR simulator for selected device parameters - ---- - -#### CloseVrSimulator() - -```c - -void CloseVrSimulator( void ); - -``` - -Close VR simulator for current device - ---- - -#### UpdateVrTracking() - -```c - -void UpdateVrTracking( Camera *camera ); - -``` - -Update VR tracking ( position and orientation ) and camera - ---- - -#### SetVrConfiguration() - -```c - -void SetVrConfiguration( VrDeviceInfo info, Shader distortion ); - -``` - -Set stereo rendering configuration parameters - ---- - -#### IsVrSimulatorReady() - -```c - -bool IsVrSimulatorReady( void ); - -``` - -Detect if VR simulator is ready - ---- - -#### ToggleVrMode() - -```c - -void ToggleVrMode( void ); - -``` - -Enable/Disable VR experience - ---- - -#### BeginVrDrawing() - -```c - -void BeginVrDrawing( void ); - -``` - -Begin VR simulator stereo rendering - ---- - -#### EndVrDrawing() - -```c - -void EndVrDrawing( void ); - -``` - -End VR simulator stereo rendering - ---- diff --git a/docs/shapes.md b/docs/shapes.md index 97bd72b..fd6b231 100644 --- a/docs/shapes.md +++ b/docs/shapes.md @@ -6,6 +6,19 @@ permalink: shapes # **Function reference module: shapes** +> Set texture and rectangle to be used on shapes drawing +> NOTE: It can be useful when using basic shapes and one single font, +> defining a font char white rectangle would allow drawing everything in a single draw call + +```c + +void SetShapesTexture(Texture2D texture, Rectangle source); + +``` + +#### SetShapesTexture() + + ## Basic shapes drawing functions #### DrawPixel() @@ -80,6 +93,18 @@ Draw a line using cubic-bezier curves in-out --- +#### DrawLineBezierQuad() + +```c + +void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thick, Color color); + +``` + +Draw line using quadratic bezier curves with a control point + +--- + #### DrawLineStrip() ```c @@ -108,7 +133,7 @@ Draw a color-filled circle ```c -void DrawCircleSector( Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color ); +void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); ``` @@ -120,7 +145,7 @@ Draw a piece of a circle ```c -void DrawCircleSectorLines( Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color ); +void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); ``` @@ -192,7 +217,7 @@ Draw ellipse outline ```c -void DrawRing( Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color ); +void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color); ``` @@ -204,7 +229,7 @@ Draw ring ```c -void DrawRingLines( Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color ); +void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color); ``` @@ -492,10 +517,12 @@ Check if point is inside a triangle #### CheckCollisionLines() -````c +```c bool CheckCollisionLines( Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2, Vector2 *collisionPoint); +``` + Check the collision between two lines --- @@ -506,8 +533,8 @@ Check the collision between two lines Rectangle GetCollisionRec( Rectangle rec1, Rectangle rec2 ); -```` +``` -## Get collision rectangle for two rectangles collision +Get collision rectangle for two rectangles collision --- diff --git a/docs/structs.md b/docs/structs.md index c1240c2..1fcfa4e 100644 --- a/docs/structs.md +++ b/docs/structs.md @@ -15,7 +15,7 @@ struct Color; // Color type, RGBA (32bit) struct Rectangle; // Rectangle type struct Image; // Image type (multiple pixel formats supported) - // NOTE: Data stored in CPU memory (RAM) + // NOTE: Data stored in CPU memory (RAM) struct Texture; // Texture type (multiple internal formats supported) // NOTE: Data stored in GPU memory (VRAM) struct RenderTexture; // RenderTexture type, for texture rendering @@ -43,6 +43,7 @@ struct Music; // Music type (file streaming from memory) struct AudioStream; // Raw audio stream type struct VrDeviceInfo; // VR device parameters +struct VrStereoConfig; // VR Stereo rendering configuration for simulator ``` diff --git a/docs/textures.md b/docs/textures.md index e536c92..3dc204a 100644 --- a/docs/textures.md +++ b/docs/textures.md @@ -10,7 +10,7 @@ permalink: textures #### LoadImage() -````c +```c Image LoadImage( const char *fileName ); @@ -996,6 +996,18 @@ Draws a texture ( or part of it ) that stretches or shrinks nicely --- +### DrawTexturePoly() + +```c + +void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointsCount, Color tint); + +``` + +Draw a textured polygon + +--- + ## Color/pixel related functions #### Fade() diff --git a/examples/README.md b/examples/README.md index c924dc9..0ac0b60 100644 --- a/examples/README.md +++ b/examples/README.md @@ -11,7 +11,7 @@ ### Install raylib -Download [raylib](https://github.com/raysan5/raylib/releases/tag/3.5.0) binary archive from this page and unpack in the directory: +Download [raylib](https://github.com/raysan5/raylib/releases/tag/3.7.0) binary archive from this page and unpack in the directory: ``` c:\raylib\bin *.dll @@ -42,6 +42,19 @@ To test it, type: hb-raylib\examples\harbour\tutorial>hbmk2 tutorial_01.prg ``` +# Installing and building raylib on multiple platforms + +raylib contains detailed instructions on building and usage on multiple platforms. + + - [Working on Windows](https://github.com/raysan5/raylib/wiki/Working-on-Windows) + - [Working on macOS](https://github.com/raysan5/raylib/wiki/Working-on-macOS) + - [Working on GNU Linux](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux) + - [Working on FreeBSD](https://github.com/raysan5/raylib/wiki/Working-on-FreeBSD) + - [Working on Raspberry Pi](https://github.com/raysan5/raylib/wiki/Working-on-Raspberry-Pi) + - [Working for Android](https://github.com/raysan5/raylib/wiki/Working-for-Android) + - [Working for Web (HTML5)](https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5)) + - [Working anywhere with CMake](https://github.com/raysan5/raylib/wiki/Working-with-CMake) + --- [Edit me](https://github.com/rjopek/hb-raylib/edit/main/docs/tutorial/README.md) diff --git a/examples/harbour/audio/audio_module_playing.prg b/examples/harbour/audio/audio_module_playing.prg new file mode 100644 index 0000000..0bfdab4 --- /dev/null +++ b/examples/harbour/audio/audio_module_playing.prg @@ -0,0 +1,111 @@ +#include "hbraylib.ch" + +#define LOOPING 3 + +#define MAX_CIRCLES 64 +#define ALPHA 1 +#define RADIUS 2 +#define POSITION 3 +#define SPEED 4 +#define ACOLOR 5 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aColors := { ORANGE, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE } + LOCAL aMusic + LOCAL aCircles[ MAX_CIRCLES, 5 ] + LOCAL nTimePlayed + LOCAL lPause := .F. + LOCAL nPitch := 1.0 + LOCAL i + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [audio] example - module playing (streaming)" ) + + InitAudioDevice() + + FOR i := MAX_CIRCLES TO 1 STEP -1 + aCircles[ i, ALPHA ] := 0 + aCircles[ i, RADIUS ] := GetRandomValue( 10, 40 ) + aCircles[ i, POSITION ] := { GetRandomValue( aCircles[ i, RADIUS ], nScreenWidth - aCircles[ i, RADIUS ] ), GetRandomValue( aCircles[ i, RADIUS ], nScreenHeight - aCircles[ i, RADIUS ] ) } + aCircles[ i, SPEED ] := GetRandomValue( 1, 100 ) / 2000 + aCircles[ i, ACOLOR ] := aColors[ GetRandomValue( 1, 14 ) ] + NEXT + + aMusic := LoadMusicStream( "resources/mini1111.xm" ) + aMusic[ LOOPING ] := .F. + + PlayMusicStream( aMusic ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + UpdateMusicStream( aMusic ) + + IF IsKeyPressed( KEY_SPACE ) + StopMusicStream( aMusic ) + PlayMusicStream( aMusic ) + ENDIF + + IF IsKeyPressed( KEY_P ) + lPause := !lPause + IF lPause + PauseMusicStream( aMusic ) + ELSE + ResumeMusicStream( aMusic ) + ENDIF + ENDIF + + IF IsKeyDown( KEY_DOWN ) + nPitch -= 0.01 + ELSEIF IsKeyDown( KEY_UP ) + nPitch += 0.01 + ENDIF + + SetMusicPitch( aMusic, nPitch ) + + nTimePlayed := GetMusicTimePlayed( aMusic ) / GetMusicTimeLength( aMusic ) * ( nScreenWidth - 40 ) + IF !lPause + FOR i := MAX_CIRCLES TO 1 STEP -1 + aCircles[ i, ALPHA ] += aCircles[ i, SPEED ] + aCircles[ i, RADIUS ] += aCircles[ i, SPEED ] * 10 + + IF aCircles[ i, ALPHA ] > 1 + aCircles[ i, SPEED ] *= -1 + ENDIF + + IF aCircles[ i, ALPHA ] <= 0 + aCircles[ i, ALPHA ] := 0 + aCircles[ i, RADIUS ] := GetRandomValue( 10, 40 ) + aCircles[ i, POSITION ] := { GetRandomValue( aCircles[ i, RADIUS ], nScreenWidth - aCircles[ i, RADIUS ] ), GetRandomValue( aCircles[ i, RADIUS ], nScreenHeight - aCircles[ i, RADIUS ] ) } + aCircles[ i, SPEED ] := GetRandomValue( 1, 100 ) / 2000 + aCircles[ i, ACOLOR ] := aColors[ GetRandomValue( 1, 14 ) ] + ENDIF + NEXT + ENDIF + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + FOR i := MAX_CIRCLES TO 1 STEP -1 + DrawCircleV( aCircles[ i, POSITION ], aCircles[ i, RADIUS ], Fade( aCircles[ i, ACOLOR ], aCircles[ i, ALPHA ] ) ) + NEXT + + DrawRectangle( 20, nScreenHeight - 20 - 12, nScreenWidth - 40, 12, LIGHTGRAY ) + DrawRectangle( 20, nScreenHeight - 20 - 12, Int( nTimePlayed ), 12, MAROON ) + DrawRectangleLines( 20, nScreenHeight - 20 - 12, nScreenWidth - 40, 12, GRAY ) + + EndDrawing() + + ENDDO + + UnloadMusicStream( aMusic ) + + CloseAudioDevice() + + CloseWindow() + + RETURN diff --git a/examples/harbour/audio/audio_multichannel_sound.prg b/examples/harbour/audio/audio_multichannel_sound.prg new file mode 100644 index 0000000..27ffa71 --- /dev/null +++ b/examples/harbour/audio/audio_multichannel_sound.prg @@ -0,0 +1,51 @@ +#include "hbraylib.ch" + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aFxWav + LOCAL aFxOgg + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [audio] example - Multichannel sound playing" ) + + InitAudioDevice() + + aFxWav := LoadSound( "resources/sound.wav" ) + aFxOgg := LoadSound( "resources/target.ogg" ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + IF IsKeyPressed( KEY_ENTER ) + PlaySound( aFxWav ) + ENDIF + IF IsKeyPressed( KEY_SPACE ) + PlaySoundMulti( aFxOgg ) + ENDIF + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawText( "MULTICHANNEL SOUND PLAYING", 20, 20, 20, GRAY ) + DrawText( "Press SPACE to play new ogg instance!", 200, 120, 20, LIGHTGRAY ) + DrawText( "Press ENTER to play new wav instance!", 200, 180, 20, LIGHTGRAY ) + + DrawText( TextFormat( "CONCURRENT SOUNDS PLAYING: %02i", GetSoundsPlaying() ), 220, 280, 20, RED ) + + EndDrawing() + + ENDDO + + StopSoundMulti() + + UnloadSound( aFxWav ) + UnloadSound( aFxOgg ) + + CloseAudioDevice() + + CloseWindow() + + RETURN diff --git a/examples/harbour/audio/audio_music_stream.prg b/examples/harbour/audio/audio_music_stream.prg new file mode 100644 index 0000000..a9c1f5e --- /dev/null +++ b/examples/harbour/audio/audio_music_stream.prg @@ -0,0 +1,70 @@ +#include "hbraylib.ch" + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aMusic + LOCAL nTimePlayed + LOCAL lPause := .F. + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [audio] example - music playing (streaming)" ) + + InitAudioDevice() + + aMusic := LoadMusicStream( "resources/country.mp3" ) + + PlayMusicStream( aMusic ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + UpdateMusicStream( aMusic ) + + IF IsKeyPressed( KEY_SPACE ) + StopMusicStream( aMusic ) + PlayMusicStream( aMusic ) + ENDIF + + IF IsKeyPressed( KEY_P ) + + lPause := ! lPause + + IF lPause + PauseMusicStream( aMusic ) + ELSE + ResumeMusicStream( aMusic ) + ENDIF + ENDIF + + nTimePlayed := GetMusicTimePlayed( aMusic ) / GetMusicTimeLength( aMusic ) * 400 + + IF nTimePlayed > 400 + StopMusicStream( aMusic ) + ENDIF + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawText( "MUSIC SHOULD BE PLAYING!", 255, 150, 20, LIGHTGRAY ) + + DrawRectangle( 200, 200, 400, 12, LIGHTGRAY ) + DrawRectangle( 200, 200, Int( nTimePlayed ), 12, MAROON ) + DrawRectangleLines( 200, 200, 400, 12, GRAY ) + + DrawText( "PRESS SPACE TO RESTART MUSIC", 215, 250, 20, LIGHTGRAY ) + DrawText( "PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, LIGHTGRAY ) + + EndDrawing() + + ENDDO + + UnloadMusicStream( aMusic ) + + CloseAudioDevice() + + CloseWindow() + + RETURN diff --git a/examples/harbour/audio/audio_raw_stream.prg b/examples/harbour/audio/audio_raw_stream.prg new file mode 100644 index 0000000..f54d20d --- /dev/null +++ b/examples/harbour/audio/audio_raw_stream.prg @@ -0,0 +1,157 @@ +/* +Exemplo não concluido! +Obs: Compilar junto com hbct +*/ + +#include "hbraylib.ch" + +#define MAX_SAMPLES 512 +#define MAX_SAMPLES_PER_UPDATE 4096 + +#define VECTOR2_X 1 +#define VECTOR2_Y 2 +#define PI 3.141592 + +PROCEDURE main + +// Initialization +// -------------------------------------------------------------------------------------- + LOCAL i + LOCAL fp + LOCAL screenWidth := 800 + LOCAL screenHeight := 450 + LOCAL stream + LOCAL DATA + LOCAL writeBuf + LOCAL mousePosition + LOCAL frequency + LOCAL oldFrequency + LOCAL readCursor + LOCAL waveLength + LOCAL position + LOCAL oldWavelength + LOCAL writeCursor + LOCAL writeLength + LOCAL readLength + + InitWindow( screenWidth, screenHeight, "raylib [audio] example - raw audio streaming" ); + + InitAudioDevice(); // Initialize audio device + + // Init raw audio stream (sample rate: 22050, sample size: 16bit-short, channels: 1-mono) + stream := LoadAudioStream( 22050, 16, 1 ) + +// Buffer for the single cycle waveform we are synthesizing + DATA := MAX_SAMPLES + +// Frame buffer, describing the waveform when repeated over the course of a frame + writeBuf := MAX_SAMPLES_PER_UPDATE + + PlayAudioStream( stream ) // Start processing stream buffer (no data loaded currently) + +// Cycles per second (hz) + frequency := 440.0 + +// Previous value, used to test if sine needs to be rewritten, and to smoothly modulate frequency + oldFrequency := 1.0 + +// Cursor to read and copy the samples of the sine wave buffer + readCursor := 0 + +// Computed size in samples of the sine wave + waveLength := 1 + + position := { 0, 0 } + + SetTargetFPS( 30 ) // Set our game to run at 30 frames-per-second +// -------------------------------------------------------------------------------------- + +// Main game loop + DO WHILE ( !WindowShouldClose() ) // Detect window close button or ESC key +// Update +// ---------------------------------------------------------------------------------- + + // Sample mouse input. + mousePosition := GetMousePosition() + + IF ( IsMouseButtonDown( MOUSE_BUTTON_LEFT ) ) + fp := mousePosition[ VECTOR2_Y ] + frequency = 40.0 + fp + ENDIF + + // Rewrite the sine wave. + // Compute two cycles to allow the buffer padding, simplifying any modulation, resampling, etc. + IF ( frequency != oldFrequency ) + // Compute wavelength. Limit size in both directions. + oldWavelength := waveLength + + waveLength := Int( 22050 / frequency ) + IF waveLength > ( MAX_SAMPLES / 2 ) + waveLength := ( MAX_SAMPLES / 2 ) + ENDIF + IF ( waveLength < 1 ) + waveLength := 1 + ENDIF + + // Write sine wave. + FOR i := 1 TO ( waveLength * 2 ) + 1 + DATA[ i ] := sin( ( ( 2 * PI * i / waveLength ) ) ) * 32000 + NEXT + + // Scale read cursor's position to minimize transition artifacts + readCursor := Int( readCursor * ( waveLength / oldWavelength ) ) + oldFrequency := frequency + ENDIF + + // Refill audio stream if required + IF IsAudioStreamProcessed( stream ) + // Synthesize a buffer that is exactly the requested size + writeCursor := 0 + DO WHILE ( writeCursor < MAX_SAMPLES_PER_UPDATE ) + // Start by trying to write the whole chunk at once + writeLength := MAX_SAMPLES_PER_UPDATE - writeCursor + + // Limit to the maximum readable size + readLength := waveLength - readCursor + IF ( writeLength > readLength ) + writeLength := readLength + ENDIF + + // Write the slice + // memcpy(writeBuf + writeCursor, data + readCursor, writeLength) + writeBuf := DATA + readCursor + + // Update cursors and loop audio + readCursor := ( readCursor + writeLength ) % waveLength + writeCursor += writeLength + ENDDO + // Copy finished frame to audio stream + UpdateAudioStream( stream, writeBuf, MAX_SAMPLES_PER_UPDATE ) + ENDIF + + // ---------------------------------------------------------------------------------- + // Draw + // ---------------------------------------------------------------------------------- + BeginDrawing() + ClearBackground( RAYWHITE ) + DrawText( TextFormat( "sine frequency: %i", Int( frequency ), GetScreenWidth() - 220, 10, 20, RED ) ) + DrawText( "click mouse button to change frequency", 10, 10, 20, DARKGRAY ) + // Draw the current buffer state proportionate to the screen + FOR i := 0 TO screenWidth + position[ VECTOR2_X ] := i + position[ VECTOR2_Y ] := 250 + 50 * DATA[ i * MAX_SAMPLES / screenWidth ] / 32000.0 + DrawPixelV( position, RED ) + NEXT + EndDrawing() + ENDDO +// ---------------------------------------------------------------------------------- +// De-Initialization +// -------------------------------------------------------------------------------------- +// free(data) // Unload sine wave data +// free(writeBuf) // Unload write buffer + UnloadAudioStream( stream ) // Close raw audio stream and delete buffers from RAM + CloseAudioDevice() // Close audio device (music streaming is automatically stopped) + CloseWindow() // Close window and OpenGL context +// -------------------------------------------------------------------------------------- + + RETURN diff --git a/examples/harbour/audio/audio_sound_loading.prg b/examples/harbour/audio/audio_sound_loading.prg new file mode 100644 index 0000000..c0b9a46 --- /dev/null +++ b/examples/harbour/audio/audio_sound_loading.prg @@ -0,0 +1,46 @@ +#include "hbraylib.ch" + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aFxWav + LOCAL aFxOgg + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [audio] example - sound loading and playing" ) + + InitAudioDevice() + + aFxWav := LoadSound( "resources/sound.wav" ) + aFxOgg := LoadSound( "resources/target.ogg" ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + IF IsKeyPressed( KEY_SPACE ) + PlaySound( aFxWav ) + ENDIF + IF IsKeyPressed( KEY_ENTER ) + PlaySound( aFxOgg ) + ENDIF + + BeginDrawing(); + + ClearBackground( RAYWHITE ) + + DrawText( "Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY ) + DrawText( "Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY ) + + EndDrawing() + + ENDDO + + UnloadSound( aFxWav ) + UnloadSound( aFxOgg ) + + CloseAudioDevice() + + CloseWindow() + + RETURN diff --git a/examples/harbour/audio/hbmk.hbm b/examples/harbour/audio/hbmk.hbm new file mode 100644 index 0000000..a5c4779 --- /dev/null +++ b/examples/harbour/audio/hbmk.hbm @@ -0,0 +1,2 @@ +hbraylib.hbc +-w3 -es2 \ No newline at end of file diff --git a/examples/harbour/audio/resources/LICENSE.md b/examples/harbour/audio/resources/LICENSE.md new file mode 100644 index 0000000..c94731c --- /dev/null +++ b/examples/harbour/audio/resources/LICENSE.md @@ -0,0 +1,10 @@ +| resource | author | licence | notes | +| :------------------- | :---------: | :------ | :---- | +| country.mp3 | [@emegeme](https://github.com/emegeme) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Originally created for "DART that TARGET" game | +| target.ogg | [@emegeme](https://github.com/emegeme) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Originally created for "DART that TARGET" game | +| target.flac | [@emegeme](https://github.com/emegeme) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Originally created for "DART that TARGET" game | +| coin.wav | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Created using [rFXGen](https://raylibtech.itch.io/rfxgen) | +| sound.wav | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Created using [rFXGen](https://raylibtech.itch.io/rfxgen) | +| spring.wav | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Created using [rFXGen](https://raylibtech.itch.io/rfxgen) | +| weird.wav | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Created using [rFXGen](https://raylibtech.itch.io/rfxgen) | +| mini1111.xm | [tPORt](https://modarchive.org/index.php?request=view_by_moduleid&query=51891) | [Mod Archive Distribution license](https://modarchive.org/index.php?terms-upload) | - | diff --git a/examples/harbour/audio/resources/country.mp3 b/examples/harbour/audio/resources/country.mp3 new file mode 100644 index 0000000..91066cc Binary files /dev/null and b/examples/harbour/audio/resources/country.mp3 differ diff --git a/examples/harbour/audio/resources/mini1111.xm b/examples/harbour/audio/resources/mini1111.xm new file mode 100644 index 0000000..a185c1a Binary files /dev/null and b/examples/harbour/audio/resources/mini1111.xm differ diff --git a/examples/harbour/audio/resources/sound.wav b/examples/harbour/audio/resources/sound.wav new file mode 100644 index 0000000..b5d01c9 Binary files /dev/null and b/examples/harbour/audio/resources/sound.wav differ diff --git a/examples/harbour/audio/resources/target.ogg b/examples/harbour/audio/resources/target.ogg new file mode 100644 index 0000000..2b73e1c Binary files /dev/null and b/examples/harbour/audio/resources/target.ogg differ diff --git a/examples/harbour/core/core_2d_camera.prg b/examples/harbour/core/core_2d_camera.prg new file mode 100644 index 0000000..0113f1c --- /dev/null +++ b/examples/harbour/core/core_2d_camera.prg @@ -0,0 +1,127 @@ +#include "hbraylib.ch" + +#define MAX_BUILDINGS 100 + +#define RECTANGLE_X 1 +#define RECTANGLE_Y 2 +#define RECTANGLE_WIDTH 3 +#define RECTANGLE_HEIGHT 4 + +#define CAMERA2D_TARGET 1 +#define CAMERA2D_OFFSET 2 +#define CAMERA2D_ROTATION 3 +#define CAMERA2D_ZOOM 4 + +#define VECTOR2_X 1 +#define VECTOR2_Y 2 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aPlayer := { 400, 280, 40, 40 } + LOCAL aBuildings[ MAX_BUILDINGS ][ 4 ] + LOCAL aBuildColors[ MAX_BUILDINGS ][ 4 ] + LOCAL nSpacing := 0 + LOCAL aCamera[ 4 ] + LOCAL i + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [core] example - 2d aCamera" ) + + FOR i := 1 TO MAX_BUILDINGS + + aBuildings[ i ][ RECTANGLE_WIDTH ] := GetRandomValue( 50, 200 ) + aBuildings[ i ][ RECTANGLE_HEIGHT ] := GetRandomValue( 100, 800 ) + aBuildings[ i ][ RECTANGLE_Y ] := nScreenHeight - 130.0 - aBuildings[ i ][ RECTANGLE_HEIGHT ] + aBuildings[ i ][ RECTANGLE_X ] := -6000.0 + nSpacing + + nSpacing += Int( aBuildings[ i ][ RECTANGLE_WIDTH ] ) + + aBuildColors[ i ] := { GetRandomValue( 200, 240 ), GetRandomValue( 200, 240 ), GetRandomValue( 200, 250 ), 255 } + + NEXT + + aCamera[ CAMERA2D_TARGET ] := { aPlayer[ RECTANGLE_X ] + 20.0, aPlayer[ RECTANGLE_Y ] + 20.0 } + aCamera[ CAMERA2D_OFFSET ] := { nScreenWidth / 2.0, nScreenHeight / 2.0 } + aCamera[ CAMERA2D_ROTATION ] := 0.0 + aCamera[ CAMERA2D_ZOOM ] := 1.0 + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + IF IsKeyDown( KEY_RIGHT ) + aPlayer[ RECTANGLE_X ] += 2 + ELSEIF IsKeyDown( KEY_LEFT ) + aPlayer[ RECTANGLE_X ] -= 2 + ENDIF + + aCamera[ CAMERA2D_TARGET ] := { aPlayer[ RECTANGLE_X ] + 20, aPlayer[ RECTANGLE_Y ] + 20 } + + IF IsKeyDown( KEY_A ) + aCamera[ CAMERA2D_ROTATION ]-- + ELSEIF IsKeyDown( KEY_S ) + aCamera[ CAMERA2D_ROTATION ]++ + ENDIF + + IF aCamera[ CAMERA2D_ROTATION ] > 40 + aCamera[ CAMERA2D_ROTATION ] := 40 + ELSEIF aCamera[ CAMERA2D_ROTATION ] < -40 + aCamera[ CAMERA2D_ROTATION ] := -40 + ENDIF + + aCamera[ CAMERA2D_ZOOM ] += GetMouseWheelMove() * 0.05 + + IF aCamera[ CAMERA2D_ZOOM ] > 3.0 + aCamera[ CAMERA2D_ZOOM ] := 3.0 + ELSEIF aCamera[ CAMERA2D_ZOOM ] < 0.1 + aCamera[ CAMERA2D_ZOOM ] := 0.1 + ENDIF + + IF IsKeyPressed( KEY_R ) + aCamera[ CAMERA2D_ZOOM ] := 1.0 + aCamera[ CAMERA2D_ROTATION ] := 0.0 + ENDIF + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + BeginMode2D( aCamera ) + + DrawRectangle( - 6000, 320, 13000, 8000, DARKGRAY ) + + FOR i := 1 TO MAX_BUILDINGS + DrawRectangleRec( aBuildings[ i ], aBuildColors[ i ] ) + NEXT + + DrawRectangleRec( aPlayer, RED ) + + DrawLine( Int( aCamera[ CAMERA2D_TARGET ][ VECTOR2_X ] ), - nScreenHeight * 10, Int( aCamera[ CAMERA2D_TARGET ][ VECTOR2_X ] ), nScreenHeight * 10, GREEN ) + DrawLine( - nScreenWidth * 10, Int( aCamera[ CAMERA2D_TARGET ][ VECTOR2_Y ] ), nScreenWidth * 10, Int( aCamera[ CAMERA2D_TARGET ][ VECTOR2_Y ] ), GREEN ) + + EndMode2D() + + DrawText( "SCREEN AREA", 640, 10, 20, RED ) + + DrawRectangle( 0, 0, nScreenWidth, 5, RED ) + DrawRectangle( 0, 5, 5, nScreenHeight - 10, RED ) + DrawRectangle( nScreenWidth - 5, 5, 5, nScreenHeight - 10, RED ) + DrawRectangle( 0, nScreenHeight - 5, nScreenWidth, 5, RED ) + + DrawRectangle( 10, 10, 250, 113, Fade( SKYBLUE, 0.5 ) ) + DrawRectangleLines( 10, 10, 250, 113, BLUE ) + + DrawText( "Free 2d aCamera controls:", 20, 20, 10, BLACK ) + DrawText( "- Right/Left to move Offset", 40, 40, 10, DARKGRAY ) + DrawText( "- Mouse Wheel to Zoom in-out", 40, 60, 10, DARKGRAY ) + DrawText( "- A / S to Rotate", 40, 80, 10, DARKGRAY ) + DrawText( "- R to reset Zoom and Rotation", 40, 100, 10, DARKGRAY ) + + EndDrawing() + + ENDDO + + CloseWindow() + + RETURN diff --git a/examples/harbour/core/core_3d_camera_first_person.prg b/examples/harbour/core/core_3d_camera_first_person.prg new file mode 100644 index 0000000..6d052e7 --- /dev/null +++ b/examples/harbour/core/core_3d_camera_first_person.prg @@ -0,0 +1,74 @@ +#include "hbraylib.ch" + +#define MAX_COLUMNS 20 + +#define CAMERA3D_POSITION 1 +#define CAMERA3D_TARGET 2 +#define CAMERA3D_UP 3 +#define CAMERA3D_FOVY 4 +#define CAMERA3D_PROJECTION 5 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aCamera[ 5 ] + LOCAL aHeights[ MAX_COLUMNS ] + LOCAL aPositions[ MAX_COLUMNS ] + LOCAL aColors[ MAX_COLUMNS ] + LOCAL i + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [core] example - 3d camera first person" ) + + aCamera[ CAMERA3D_POSITION ] := { 4.0, 2.0, 4.0 } + aCamera[ CAMERA3D_TARGET ] := { 0.0, 1.8, 0.0 } + aCamera[ CAMERA3D_UP ] := { 0.0, 1.0, 0.0 } + aCamera[ CAMERA3D_FOVY ] := 60.0 + aCamera[ CAMERA3D_PROJECTION ] := CAMERA_PERSPECTIVE + + FOR i := 1 TO MAX_COLUMNS + aHeights[ i ] := IntToF( GetRandomValue( 1, 12 ) ) + aPositions[ i ] := { IntToF( GetRandomValue( - 15, 15 ) ), aHeights[ i ] / 2.0, IntToF( GetRandomValue( - 15, 15 ) ) } + aColors[ i ] := { GetRandomValue( 20, 255 ), GetRandomValue( 10, 55 ), 30, 255 } + NEXT + + SetCameraMode( aCamera, CAMERA_FIRST_PERSON ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + UpdateCamera( aCamera ) + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + BeginMode3D( aCamera ) + + DrawPlane( { 0.0, 0.0, 0.0 }, { 32.0, 32.0 }, LIGHTGRAY ) + DrawCube( { - 16.0, 2.5, 0.0 }, 1.0, 5.0, 32.0, BLUE ) + DrawCube( { 16.0, 2.5, 0.0 }, 1.0, 5.0, 32.0, LIME ) + DrawCube( { 0.0, 2.5, 16.0 }, 32.0, 5.0, 1.0, GOLD ) + + FOR i := 1 TO MAX_COLUMNS + DrawCube( aPositions[ i ], 2.0, aHeights[ i ], 2.0, aColors[ i ] ) + DrawCubeWires( aPositions[ i ], 2.0, aHeights[ i ], 2.0, MAROON ) + NEXT + + EndMode3D() + + DrawRectangle( 10, 10, 220, 70, Fade( SKYBLUE, 0.5 ) ) + DrawRectangleLines( 10, 10, 220, 70, BLUE ) + + DrawText( "First person camera default controls:", 20, 20, 10, BLACK ) + DrawText( "- Move with keys: W, A, S, D", 40, 40, 10, DARKGRAY ) + DrawText( "- Mouse move to look around", 40, 60, 10, DARKGRAY ) + + EndDrawing() + + ENDDO + + CloseWindow() + + RETURN diff --git a/examples/harbour/core/core_3d_camera_free.prg b/examples/harbour/core/core_3d_camera_free.prg new file mode 100644 index 0000000..b2cd2fa --- /dev/null +++ b/examples/harbour/core/core_3d_camera_free.prg @@ -0,0 +1,65 @@ +#include "hbraylib.ch" + +#define CAMERA3D_POSITION 1 +#define CAMERA3D_TARGET 2 +#define CAMERA3D_UP 3 +#define CAMERA3D_FOVY 4 +#define CAMERA3D_PROJECTION 5 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aCamera[ 5 ] + LOCAL aCubePosition := { 0.0, 0.0, 0.0 } + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [core] example - 3d aCamera free" ) + + aCamera[ CAMERA3D_POSITION ] := { 10.0, 10.0, 10.0 } + aCamera[ CAMERA3D_TARGET ] := { 0.0, 0.0, 0.0 } + aCamera[ CAMERA3D_UP ] := { 0.0, 1.0, 0.0 } + aCamera[ CAMERA3D_FOVY ] := 45.0 + aCamera[ CAMERA3D_PROJECTION ] := CAMERA_PERSPECTIVE + + SetCameraMode( aCamera, CAMERA_FREE ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + UpdateCamera( aCamera ) + + IF IsKeyDown( Asc( "Z" ) ) + aCamera[ CAMERA3D_TARGET ] := { 0.0, 0.0, 0.0 } + ENDIF + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + BeginMode3D( aCamera ) + + DrawCube( aCubePosition, 2.0, 2.0, 2.0, RED ) + DrawCubeWires( aCubePosition, 2.0, 2.0, 2.0, MAROON ) + + DrawGrid( 10, 1.0 ) + + EndMode3D() + + DrawRectangle( 10, 10, 320, 133, Fade( SKYBLUE, 0.5 ) ) + DrawRectangleLines( 10, 10, 320, 133, BLUE ) + + DrawText( "Free aCamera default controls:", 20, 20, 10, BLACK ) + DrawText( "- Mouse Wheel to Zoom in-out", 40, 40, 10, DARKGRAY ) + DrawText( "- Mouse Wheel Pressed to Pan", 40, 60, 10, DARKGRAY ) + DrawText( "- Alt + Mouse Wheel Pressed to Rotate", 40, 80, 10, DARKGRAY ) + DrawText( "- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 100, 10, DARKGRAY ) + DrawText( "- Z to zoom to (0, 0, 0)", 40, 120, 10, DARKGRAY ) + + EndDrawing() + + ENDDO + + CloseWindow() + + RETURN diff --git a/examples/harbour/core/core_3d_camera_mode.prg b/examples/harbour/core/core_3d_camera_mode.prg new file mode 100644 index 0000000..dca9749 --- /dev/null +++ b/examples/harbour/core/core_3d_camera_mode.prg @@ -0,0 +1,39 @@ +#include "hbraylib.ch" + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aCamera := { { 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, 45.0, CAMERA_PERSPECTIVE } + LOCAL aCubePosition := { 0.0, 0.0, 0.0 } + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [core] example - 3d camera mode" ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + BeginMode3D( aCamera ) + + DrawCube( aCubePosition, 2.0, 2.0, 2.0, RED ) + DrawCubeWires( aCubePosition, 2.0, 2.0, 2.0, MAROON ) + + DrawGrid( 10, 1.0 ) + + EndMode3D() + + DrawText( "Welcome to the third dimension!", 10, 40, 20, DARKGRAY ) + + DrawFPS( 10, 10 ) + + EndDrawing() + + ENDDO + + CloseWindow() + + RETURN diff --git a/examples/harbour/core/core_basic_screen_manager.prg b/examples/harbour/core/core_basic_screen_manager.prg new file mode 100644 index 0000000..ca78b9f --- /dev/null +++ b/examples/harbour/core/core_basic_screen_manager.prg @@ -0,0 +1,96 @@ +#include "hbraylib.ch" + +#define LOGO 0 +#define TITLE 1 +#define GAMEPLAY 2 +#define ENDING 3 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL nCurrentScreen := LOGO + LOCAL nFramesCounter := 0 + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [core] example - basic screen manager" ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + SWITCH nCurrentScreen + + CASE LOGO + + nFramesCounter++ + IF nFramesCounter > 120 + nCurrentScreen := TITLE + ENDIF + EXIT + + CASE TITLE + + IF IsKeyPressed( KEY_ENTER ) .OR. IsGestureDetected( GESTURE_TAP ) + nCurrentScreen := GAMEPLAY + ENDIF + + EXIT + + CASE GAMEPLAY + + IF IsKeyPressed( KEY_ENTER ) .OR. IsGestureDetected( GESTURE_TAP ) + nCurrentScreen := ENDING + ENDIF + EXIT + + CASE ENDING + + IF IsKeyPressed( KEY_ENTER ) .OR. IsGestureDetected( GESTURE_TAP ) + nCurrentScreen := TITLE + ENDIF + EXIT + + ENDSWITCH + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + SWITCH nCurrentScreen + + CASE LOGO + + DrawText( "LOGO SCREEN", 20, 20, 40, LIGHTGRAY ) + DrawText( "WAIT for 2 SECONDS...", 290, 220, 20, GRAY ) + EXIT + + CASE TITLE + + DrawRectangle( 0, 0, nScreenWidth, nScreenHeight, GREEN ) + DrawText( "TITLE SCREEN", 20, 20, 40, DARKGREEN ) + DrawText( "PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, DARKGREEN ) + EXIT + + CASE GAMEPLAY + + DrawRectangle( 0, 0, nScreenWidth, nScreenHeight, PURPLE ) + DrawText( "GAMEPLAY SCREEN", 20, 20, 40, MAROON ) + DrawText( "PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, MAROON ) + EXIT + + CASE ENDING + + DrawRectangle( 0, 0, nScreenWidth, nScreenHeight, BLUE ) + DrawText( "ENDING SCREEN", 20, 20, 40, DARKBLUE ) + DrawText( "PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, DARKBLUE ) + EXIT + + ENDSWITCH + + EndDrawing() + + ENDDO + + CloseWindow() + + RETURN diff --git a/examples/harbour/core/core_basic_window.prg b/examples/harbour/core/core_basic_window.prg index 405757e..55ec466 100644 --- a/examples/harbour/core/core_basic_window.prg +++ b/examples/harbour/core/core_basic_window.prg @@ -1,4 +1,3 @@ - #include "hbraylib.ch" PROCEDURE Main() @@ -14,9 +13,9 @@ PROCEDURE Main() BeginDrawing() - ClearBackground( RAYWHITE ) + ClearBackground( RAYWHITE ) - DrawText( "Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY ) + DrawText( "Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY ) EndDrawing() diff --git a/examples/harbour/core/core_drop_files.prg b/examples/harbour/core/core_drop_files.prg new file mode 100644 index 0000000..c018c81 --- /dev/null +++ b/examples/harbour/core/core_drop_files.prg @@ -0,0 +1,51 @@ +#include "hbraylib.ch" + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL nCount := 0 + LOCAL aDroppedFiles + LOCAL i + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [core] example - drop files" ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + IF IsFileDropped() + aDroppedFiles := GetDroppedFiles( @nCount ) + ENDIF + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + IF nCount == 0 + DrawText( "Drop your files to this window!", 100, 40, 20, DARKGRAY ) + ELSE + DrawText( "Dropped files:", 100, 40, 20, DARKGRAY ) + + FOR i := 1 TO nCount + IF i % 2 == 0 + DrawRectangle( 0, 85 + 40 * i, nScreenWidth, 40, Fade( LIGHTGRAY, 0.5 ) ) + ELSE + DrawRectangle( 0, 85 + 40 * i, nScreenWidth, 40, Fade( LIGHTGRAY, 0.3 ) ) + ENDIF + DrawText( aDroppedFiles[ i ], 120, 100 + 40 * i, 10, GRAY ) + NEXT + + DrawText( "Drop new files...", 100, 110 + 40 * nCount, 20, DARKGRAY ) + + ENDIF + + EndDrawing() + + ENDDO + + ClearDroppedFiles() + + CloseWindow() + + RETURN diff --git a/examples/harbour/core/core_input_gamepad.prg b/examples/harbour/core/core_input_gamepad.prg new file mode 100644 index 0000000..6a34998 --- /dev/null +++ b/examples/harbour/core/core_input_gamepad.prg @@ -0,0 +1,214 @@ +#include "hbraylib.ch" + +#define XBOX360_LEGACY_NAME_ID "Xbox Controller" + +#ifdef PLATFORM_RPI +#define XBOX360_NAME_ID "Microsoft X-Box 360 pad" +#define PS3_NAME_ID "PLAYSTATION(R)3 Controller" +#else +#define XBOX360_NAME_ID "Xbox 360 Controller" +#define PS3_NAME_ID "PLAYSTATION(R)3 Controller" +#endif + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aTexPs3Pad + LOCAL aTexXboxPad + LOCAL i + + InitWindow( nScreenWidth, nScreenHeight, "Harbour and raylib [core] example - gamepad input" ) + + aTexPs3Pad := LoadTexture( "resources/ps3.png" ) + aTexXboxPad := LoadTexture( "resources/xbox.png" ) + + SetConfigFlags( FLAG_MSAA_4X_HINT ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + IF IsGamepadAvailable( 0 ) + + DrawText( TextFormatSI( "GP1: %s", GetGamepadName( 0 ) ), 10, 10, 10, BLACK ) + + IF IsGamepadName( 0, XBOX360_NAME_ID ) .OR. IsGamepadName( 0, XBOX360_LEGACY_NAME_ID ) + + DrawTexture( aTexXboxPad, 0, 0, DARKGRAY ) + + // Draw buttons: xbox home + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_MIDDLE ) + DrawCircle( 394, 89, 19, RED ) + ENDIF + + // Draw buttons: basic + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_MIDDLE_RIGHT ) + DrawCircle( 436, 150, 9, RED ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_MIDDLE_LEFT ) + DrawCircle( 352, 150, 9, RED ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_RIGHT_FACE_LEFT ) + DrawCircle( 501, 151, 15, BLUE ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_RIGHT_FACE_DOWN ) + DrawCircle( 536, 187, 15, LIME ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT ) + DrawCircle( 572, 151, 15, MAROON ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_RIGHT_FACE_UP ) + DrawCircle( 536, 115, 15, GOLD ) + ENDIF + + // Draw buttons: d-pad + DrawRectangle( 317, 202, 19, 71, BLACK ) + DrawRectangle( 293, 228, 69, 19, BLACK ) + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_LEFT_FACE_UP ) + DrawRectangle( 317, 202, 19, 26, RED ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_LEFT_FACE_DOWN ) + DrawRectangle( 317, 202 + 45, 19, 26, RED ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_LEFT_FACE_LEFT ) + DrawRectangle( 292, 228, 25, 19, RED ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_LEFT_FACE_RIGHT ) + DrawRectangle( 292 + 44, 228, 26, 19, RED ) + ENDIF + + // Draw buttons: left-right back + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_LEFT_TRIGGER_1 ) + DrawCircle( 259, 61, 20, RED ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_RIGHT_TRIGGER_1 ) + DrawCircle( 536, 61, 20, RED ) + ENDIF + + // Draw axis: left joystick + DrawCircle( 259, 152, 39, BLACK ) + DrawCircle( 259, 152, 34, LIGHTGRAY ) + DrawCircle( 259 + Int( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_LEFT_X ) * 20 ), ; + 152 + Int( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_LEFT_Y ) * 20 ), 25, BLACK ) + + // Draw axis: right joystick + DrawCircle( 461, 237, 38, BLACK ) + DrawCircle( 461, 237, 33, LIGHTGRAY ) + DrawCircle( 461 + Int( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_RIGHT_X ) * 20 ), ; + 237 + Int( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_RIGHT_Y ) * 20 ), 25, BLACK ) + + // Draw axis: left-right triggers + DrawRectangle( 170, 30, 15, 70, GRAY ) + DrawRectangle( 604, 30, 15, 70, GRAY ) + DrawRectangle( 170, 30, 15, 1 + Int( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_LEFT_TRIGGER ) / 2 * 70 ), RED ) + DrawRectangle( 604, 30, 15, 1 + Int( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_RIGHT_TRIGGER ) / 2 * 70 ), RED ) + + ELSEIF IsGamepadName( 0, PS3_NAME_ID ) + + DrawTexture( aTexPs3Pad, 0, 0, DARKGRAY ) + + // Draw buttons: ps + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_MIDDLE ) + DrawCircle( 396, 222, 13, RED ) + ENDIF + // draw buttons: basic + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_MIDDLE_LEFT ) + DrawRectangle( 328, 170, 32, 13, RED ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_MIDDLE_RIGHT ) + DrawTriangle( { 436, 168 }, { 436, 185 }, { 464, 177 }, RED ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_RIGHT_FACE_UP ) + DrawCircle( 557, 144, 13, LIME ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT ) + DrawCircle( 586, 173, 13, RED ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_RIGHT_FACE_DOWN ) + DrawCircle( 557, 203, 13, VIOLET ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_RIGHT_FACE_LEFT ) + DrawCircle( 527, 173, 13, PINK ) + ENDIF + + // Draw buttons: d-pad + DrawRectangle( 225, 132, 24, 84, BLACK ) + DrawRectangle( 195, 161, 84, 25, BLACK ) + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_LEFT_FACE_UP ) + DrawRectangle( 225, 132, 24, 29, RED ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_LEFT_FACE_DOWN ) + DrawRectangle( 225, 132 + 54, 24, 30, RED ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_LEFT_FACE_LEFT ) + DrawRectangle( 195, 161, 30, 25, RED ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_LEFT_FACE_RIGHT ) + DrawRectangle( 195 + 54, 161, 30, 25, RED ) + ENDIF + + // Draw buttons: left-right back buttons + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_LEFT_TRIGGER_1 ) + DrawCircle( 239, 82, 20, RED ) + ENDIF + IF IsGamepadButtonDown( 0, GAMEPAD_BUTTON_RIGHT_TRIGGER_1 ) + DrawCircle( 557, 82, 20, RED ) + ENDIF + + // Draw axis: left joystick + DrawCircle( 319, 255, 35, BLACK ) + DrawCircle( 319, 255, 31, LIGHTGRAY ) + DrawCircle( 319 + Int( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_LEFT_X ) * 20 ), ; + 255 + Int( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_LEFT_Y ) * 20 ), 25, BLACK ) + + // Draw axis: right joystick + DrawCircle( 475, 255, 35, BLACK ) + DrawCircle( 475, 255, 31, LIGHTGRAY ) + DrawCircle( 475 + Int( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_RIGHT_X ) * 20 ), ; + 255 + Int( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_RIGHT_Y ) * 20 ), 25, BLACK ) + + // Draw axis: left-right triggers + DrawRectangle( 169, 48, 15, 70, GRAY ) + DrawRectangle( 611, 48, 15, 70, GRAY ) + DrawRectangle( 169, 48, 15, 1 - Int( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_LEFT_TRIGGER ) / 2 * 70 ), RED ) + DrawRectangle( 611, 48, 15, 1 - Int( GetGamepadAxisMovement( 0, GAMEPAD_AXIS_RIGHT_TRIGGER ) / 2 * 70 ), RED ) + + ELSE + + DrawText( "- GENERIC GAMEPAD -", 280, 180, 20, GRAY ) + // TODO: Draw generic gamepad + ENDIF + + DrawText( TextFormat( "DETECTED AXIS [%i]:", GetGamepadAxisCount( 0 ) ), 10, 50, 10, MAROON ) + + FOR i := 0 TO GetGamepadAxisCount( 0 ) - 1 + DrawText( TextFormatIF( "AXIS %i: %.02f", i, GetGamepadAxisMovement( 0, i ) ), 20, 70 + 20 * i, 10, DARKGRAY ) + NEXT + + IF GetGamepadButtonPressed() != -1 + DrawText( TextFormat( "DETECTED BUTTON: %i", GetGamepadButtonPressed() ), 10, 430, 10, RED ) + ELSE + DrawText( "DETECTED BUTTON: NONE", 10, 430, 10, GRAY ) + ENDIF + + ELSE + DrawText( "GP1: NOT DETECTED", 10, 10, 10, GRAY ) + + DrawTexture( aTexXboxPad, 0, 0, LIGHTGRAY ) + ENDIF + + EndDrawing() + + ENDDO + + UnloadTexture( aTexPs3Pad ) + UnloadTexture( aTexXboxPad ) + + CloseWindow() + + RETURN diff --git a/examples/harbour/core/resources/LICENSE b/examples/harbour/core/resources/LICENSE new file mode 100644 index 0000000..d7d797a --- /dev/null +++ b/examples/harbour/core/resources/LICENSE @@ -0,0 +1,4 @@ +| resource | author | licence | notes | +| :------------ | :---------: | :------ | :---- | +| ps3.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - | +| xbox.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - | diff --git a/examples/harbour/core/resources/ps3.png b/examples/harbour/core/resources/ps3.png new file mode 100644 index 0000000..59c0b35 Binary files /dev/null and b/examples/harbour/core/resources/ps3.png differ diff --git a/examples/harbour/core/resources/xbox.png b/examples/harbour/core/resources/xbox.png new file mode 100644 index 0000000..1a57058 Binary files /dev/null and b/examples/harbour/core/resources/xbox.png differ diff --git a/examples/harbour/portable_window/hbmk.hbm b/examples/harbour/portable_window/hbmk.hbm new file mode 100644 index 0000000..a5c4779 --- /dev/null +++ b/examples/harbour/portable_window/hbmk.hbm @@ -0,0 +1,2 @@ +hbraylib.hbc +-w3 -es2 \ No newline at end of file diff --git a/examples/harbour/portable_window/portable_window.prg b/examples/harbour/portable_window/portable_window.prg new file mode 100644 index 0000000..e98d3ac --- /dev/null +++ b/examples/harbour/portable_window/portable_window.prg @@ -0,0 +1,61 @@ +#include "hbraylib.ch" + +#define VECTOR2_X 1 +#define VECTOR2_Y 2 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 600 + LOCAL aMousePosition + LOCAL aWindowPosition := { 500, 200 } + LOCAL aPanOffset + LOCAL lDragWindow := .F. + LOCAL lExitWindow := .F. + + SetConfigFlags( FLAG_WINDOW_UNDECORATED ) + InitWindow( nScreenWidth, nScreenHeight, "Harbour raygui - portable window" ) + + SetWindowPosition( aWindowPosition[ VECTOR2_X ], aWindowPosition[ VECTOR2_Y ] ) + + SetTargetFPS( 60 ) + + DO WHILE ! lExitWindow .AND. ! WindowShouldClose() + + aMousePosition := GetMousePosition() + + IF IsMouseButtonPressed( MOUSE_LEFT_BUTTON ) + + IF CheckCollisionPointRec( aMousePosition, { 0.0, 0.0, nScreenWidth + 0.5, 20.0 } ) + lDragWindow := .T. + aPanOffset := aMousePosition + ENDIF + ENDIF + + IF lDragWindow + + aWindowPosition[ VECTOR2_X ] += aMousePosition[ VECTOR2_X ] - aPanOffset[ VECTOR2_X ] + aWindowPosition[ VECTOR2_Y ] += aMousePosition[ VECTOR2_Y ] - aPanOffset[ VECTOR2_Y ] + + IF IsMouseButtonReleased( MOUSE_LEFT_BUTTON ) + lDragWindow := .F. + ENDIF + + SetWindowPosition( aWindowPosition[ VECTOR2_X ], aWindowPosition[ VECTOR2_Y ] ) + ENDIF + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + lExitWindow := GuiWindowBox( { 0.0, 0.0, nScreenWidth + 0.5, nScreenHeight + 0.5 }, "PORTABLE WINDOW" ) + + DrawText( TextFormat( "Mouse Position: [ %i, %i ]", aMousePosition[ VECTOR2_X ], aMousePosition[ VECTOR2_Y ] ), 10, 40, 10, DARKGRAY ) + + EndDrawing() + + ENDDO + + CloseWindow() + + RETURN diff --git a/examples/harbour/scroll_panel/gui_scroll_panel.prg b/examples/harbour/scroll_panel/gui_scroll_panel.prg new file mode 100644 index 0000000..4b8a4e2 --- /dev/null +++ b/examples/harbour/scroll_panel/gui_scroll_panel.prg @@ -0,0 +1,114 @@ +#include "hbraylib.ch" +#include "hbraygui.ch" + +#define RECTANGLE_X 1 +#define RECTANGLE_Y 2 +#define RECTANGLE_WIDTH 3 +#define RECTANGLE_HEIGHT 4 + +#define VECTOR2_X 1 +#define VECTOR2_Y 2 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aPanelRec := { 20, 40, 200, 150 } + LOCAL aPanelContentRec := { 0, 0, 340, 340 } + LOCAL aPanelScroll := { 99, - 20 } + LOCAL lShowContentArea := .T. + LOCAL aView + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raygui - GuiScrollPanel()" ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawText( TextFormat( "[ %i, %i ]", aPanelScroll[ VECTOR2_X ], aPanelScroll[ VECTOR2_X ] ), 4, 4, 20, RED ) + + aView := GuiScrollPanel( aPanelRec, aPanelContentRec, aPanelScroll ) + + BeginScissorMode( Int( aView[ RECTANGLE_X ] ), Int( aView[ RECTANGLE_Y ] ), Int( aView[ RECTANGLE_WIDTH ] ), Int( aView[ RECTANGLE_HEIGHT ] ) ) + GuiGrid( { aPanelRec[ RECTANGLE_X ] + aPanelScroll[ VECTOR2_X ], aPanelRec[ RECTANGLE_Y ] + aPanelScroll[ VECTOR2_Y ], ; + aPanelContentRec[ RECTANGLE_WIDTH ], aPanelContentRec[ RECTANGLE_HEIGHT ] }, 16, 3 ) + EndScissorMode() + + IF lShowContentArea + + DrawRectangle( Int( aPanelRec[ RECTANGLE_X ] + aPanelScroll[ VECTOR2_X ] ), Int( aPanelRec[ RECTANGLE_Y ] + aPanelScroll[ VECTOR2_Y ] ), ; + Int( aPanelContentRec[ RECTANGLE_WIDTH ] ), Int( aPanelContentRec[ RECTANGLE_HEIGHT ] ), Fade( RED, 0.1 ) ) + ENDIF + + DrawStyleEditControls() + + lShowContentArea := GuiCheckBox( { 565, 80, 20, 20 }, "SHOW CONTENT AREA", lShowContentArea ) + + aPanelContentRec[ RECTANGLE_WIDTH ] := GuiSliderBar( { 590, 385, 145, 15 }, "WIDTH", TextFormat( "%i", aPanelContentRec[ RECTANGLE_WIDTH ] ), aPanelContentRec[ RECTANGLE_WIDTH ], 1, 600 ) + aPanelContentRec[ RECTANGLE_HEIGHT ] := GuiSliderBar( { 590, 410, 145, 15 }, "HEIGHT", TextFormat( "%i", aPanelContentRec[ RECTANGLE_HEIGHT ] ), aPanelContentRec[ RECTANGLE_HEIGHT ], 1, 400 ) + + EndDrawing() + + ENDDO + + CloseWindow() + + RETURN + +STATIC PROCEDURE DrawStyleEditControls() + + LOCAL nStyle + LOCAL lStyle + LOCAL nText + + GuiGroupBox( { 550, 170, 220, 205 }, "SCROLLBAR STYLE" ) + + nStyle := GuiGetStyle( SCROLLBAR, BORDER_WIDTH ) + GuiLabel( { 555, 195, 110, 10 }, "BORDER_WIDTH" ) + GuiSpinner( { 670, 190, 90, 20 }, "", nStyle, 0, 6, .F. ) + GuiSetStyle( SCROLLBAR, BORDER_WIDTH, nStyle ) + + nStyle := GuiGetStyle( SCROLLBAR, ARROWS_SIZE ) + GuiLabel( { 555, 220, 110, 10 }, "ARROWS_SIZE" ) + GuiSpinner( { 670, 215, 90, 20 }, "", nStyle, 4, 14, .F. ) + GuiSetStyle( SCROLLBAR, ARROWS_SIZE, nStyle ) + + nStyle := GuiGetStyle( SCROLLBAR, TEXT_INNER_PADDING ) + GuiLabel( { 555, 245, 110, 10 }, "TEXT_INNER_PADDING" ) + GuiSpinner( { 670, 240, 90, 20 }, "", nStyle, 0, 14, .F. ) + GuiSetStyle( SCROLLBAR, TEXT_INNER_PADDING, nStyle ) + + lStyle := GuiCheckBox( { 565, 280, 20, 20 }, "ARROWS_VISIBLE", NToL( GuiGetStyle( SCROLLBAR, ARROWS_VISIBLE ) ) ) + GuiSetStyle( SCROLLBAR, ARROWS_VISIBLE, LToN( lStyle ) ) + + nStyle := GuiGetStyle( SCROLLBAR, SLIDER_PADDING ) + GuiLabel( { 555, 325, 110, 10 }, "SLIDER_PADDING" ) + GuiSpinner( { 670, 320, 90, 20 }, "", nStyle, 0, 14, .F. ) + GuiSetStyle( SCROLLBAR, SLIDER_PADDING, nStyle ) + + nStyle := GuiGetStyle( SCROLLBAR, SCROLL_SLIDER_SIZE ) + GuiLabel( { 555, 350, 110, 10 }, "SLIDER_SIZE" ) + GuiSpinner( { 670, 345, 90, 20 }, "", nStyle, 2, 100, .F. ) + GuiSetStyle( SCROLLBAR, SCROLL_SLIDER_SIZE, nStyle ) + + nText := GuiGetStyle( LISTVIEW, SCROLLBAR_SIDE ) + nStyle := GuiToggle( { 560, 110, 200, 35 }, hb_ntos( nText ), NToL( GuiGetStyle( LISTVIEW, SCROLLBAR_SIDE ) ) ) + GuiSetStyle( LISTVIEW, SCROLLBAR_SIDE, LToN( nStyle ) ) + + GuiGroupBox( { 550, 20, 220, 135 }, "SCROLLPANEL STYLE" ) + + nStyle := GuiGetStyle( LISTVIEW, SCROLLBAR_WIDTH ) + GuiLabel( { 555, 35, 110, 10 }, "SCROLLBAR_WIDTH" ) + GuiSpinner( { 670, 30, 90, 20 }, "", nStyle, 6, 30, .F. ) + GuiSetStyle( LISTVIEW, SCROLLBAR_WIDTH, nStyle ) + + nStyle := GuiGetStyle( DEFAULT, BORDER_WIDTH ) + GuiLabel( { 555, 60, 110, 10 }, "BORDER_WIDTH" ) + GuiSpinner( { 670, 55, 90, 20 }, "", nStyle, 0, 20, .F. ) + GuiSetStyle( DEFAULT, BORDER_WIDTH, nStyle ) + + RETURN diff --git a/examples/harbour/scroll_panel/hbmk.hbm b/examples/harbour/scroll_panel/hbmk.hbm new file mode 100644 index 0000000..a5c4779 --- /dev/null +++ b/examples/harbour/scroll_panel/hbmk.hbm @@ -0,0 +1,2 @@ +hbraylib.hbc +-w3 -es2 \ No newline at end of file diff --git a/examples/harbour/shaders/shaders_drawpixel.prg b/examples/harbour/shaders/shaders_drawpixel.prg index 659193d..641e990 100644 --- a/examples/harbour/shaders/shaders_drawpixel.prg +++ b/examples/harbour/shaders/shaders_drawpixel.prg @@ -1,4 +1,3 @@ - #include "hbraylib.ch" PROCEDURE Main() @@ -27,8 +26,6 @@ PROCEDURE Main() FOR x := 0 TO 800 FOR y := 0 TO 450 DrawPixel( x, y, { hb_RandomInt( 0, 255 ), hb_RandomInt( 0, 255 ), hb_RandomInt( 0, 255 ), 255 } ) - /* --- or --- */ - // DrawPixelV( { x, y }, { hb_RandomInt( 0, 255 ), hb_RandomInt( 0, 255 ), hb_RandomInt( 0, 255 ), 255 } ) NEXT NEXT diff --git a/examples/harbour/shapes/shapes_basic_shapes.prg b/examples/harbour/shapes/shapes_basic_shapes.prg index f32851d..ca2ecc2 100644 --- a/examples/harbour/shapes/shapes_basic_shapes.prg +++ b/examples/harbour/shapes/shapes_basic_shapes.prg @@ -2,11 +2,11 @@ PROCEDURE Main() - LOCAL screenWidth := 800 - LOCAL screenHeight := 450 + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 LOCAL lContinue := .T. - InitWindow( screenWidth, screenHeight, "Harbour raylib [shapes] example - basic shapes drawing" ) + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [shapes] example - basic shapes drawing" ) SetTargetFPS( 60 ) @@ -22,26 +22,26 @@ PROCEDURE Main() DrawText( "some basic shapes available on Harbour raylib", 20, 20, 20, DARKGRAY ) - DrawCircle( Int( screenHeight / 4 ), 120, 35, DARKBLUE ) + DrawCircle( Int( nScreenHeight / 4 ), 120, 35, DARKBLUE ) - DrawRectangle( Int( screenWidth / 4 ) * 2 - 60, 100, 120, 60, RED ) - DrawRectangleLines( Int( screenWidth / 4 ) * 2 - 40, 320, 80, 60, ORANGE ) - DrawRectangleGradientH( Int( screenWidth / 4 ) * 2 - 90, 170, 180, 130, MAROON, GOLD ) + DrawRectangle( Int( nScreenWidth / 4 ) * 2 - 60, 100, 120, 60, RED ) + DrawRectangleLines( Int( nScreenWidth / 4 ) * 2 - 40, 320, 80, 60, ORANGE ) + DrawRectangleGradientH( Int( nScreenWidth / 4 ) * 2 - 90, 170, 180, 130, MAROON, GOLD ) - DrawTriangle( { screenWidth / 4 * 3, 80 }, ; - { screenWidth / 4 * 3 - 60, 150 }, ; - { screenWidth / 4 * 3 + 60, 150 }, VIOLET ) + DrawTriangle( { nScreenWidth / 4 * 3, 80 }, ; + { nScreenWidth / 4 * 3 - 60, 150 }, ; + { nScreenWidth / 4 * 3 + 60, 150 }, VIOLET ) - DrawPoly( { screenWidth / 4 * 3, 320 }, 6, 80, 0, BROWN ) + DrawPoly( { nScreenWidth / 4 * 3, 320 }, 6, 80, 0, BROWN ) - DrawCircleGradient( Int( screenWidth / 4 ), 220, 60, GREEN, SKYBLUE ) + DrawCircleGradient( Int( nScreenWidth / 4 ), 220, 60, GREEN, SKYBLUE ) - DrawLine( 18, 42, screenWidth - 18, 42, BLACK ) - DrawCircleLines( Int( screenWidth / 4 ), 340, 80, DARKBLUE ) + DrawLine( 18, 42, nScreenWidth - 18, 42, BLACK ) + DrawCircleLines( Int( nScreenWidth / 4 ), 340, 80, DARKBLUE ) - DrawTriangleLines( { screenWidth / 4 * 3, 160 }, ; - { screenWidth / 4 * 3 - 20, 230 }, ; - { screenWidth / 4 * 3 + 20, 230 }, DARKBLUE ) + DrawTriangleLines( { nScreenWidth / 4 * 3, 160 }, ; + { nScreenWidth / 4 * 3 - 20, 230 }, ; + { nScreenWidth / 4 * 3 + 20, 230 }, DARKBLUE ) EndDrawing() diff --git a/examples/harbour/shapes/shapes_bouncing_ball.prg b/examples/harbour/shapes/shapes_bouncing_ball.prg index a0e4ac5..57b88fa 100644 --- a/examples/harbour/shapes/shapes_bouncing_ball.prg +++ b/examples/harbour/shapes/shapes_bouncing_ball.prg @@ -5,51 +5,51 @@ PROCEDURE Main() - LOCAL screenWidth := 800 - LOCAL screenHeight := 450 + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 LOCAL lContinue := .T. - LOCAL ballSpeed := { 5.0, 4.0 } - LOCAL ballRadius := 20 + LOCAL aBallSpeed := { 5.0, 4.0 } + LOCAL nBallRadius := 20 - LOCAL pause := .F. - LOCAL framesCounter := 0 - LOCAL ballPosition + LOCAL lPause := .F. + LOCAL nFramesCounter := 0 + LOCAL aBallPosition - InitWindow( screenWidth, screenHeight, "Harbour raylib [shapes] example - bouncing ball" ) + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [shapes] example - bouncing ball" ) - ballPosition := { GetScreenWidth() / 2, GetScreenHeight() / 2 } + aBallPosition := { GetScreenWidth() / 2, GetScreenHeight() / 2 } SetTargetFPS( 60 ) DO WHILE lContinue IF IsKeyPressed( KEY_SPACE ) - iif( pause == .T., pause := .F., pause := .T. ) + iif( lPause == .T., lPause := .F., lPause := .T. ) ENDIF - IF !pause - ballPosition[ VECTOR2_X ] += ballSpeed[ VECTOR2_X ] - ballPosition[ VECTOR2_Y ] += ballSpeed[ VECTOR2_Y ] + IF !lPause + aBallPosition[ VECTOR2_X ] += aBallSpeed[ VECTOR2_X ] + aBallPosition[ VECTOR2_Y ] += aBallSpeed[ VECTOR2_Y ] - IF ballPosition[ VECTOR2_X ] >= GetScreenWidth() - ballRadius .OR. ballPosition[ VECTOR2_X ] <= ballRadius - ballSpeed[ VECTOR2_X ] *= -1.0 + IF aBallPosition[ VECTOR2_X ] >= GetScreenWidth() - nBallRadius .OR. aBallPosition[ VECTOR2_X ] <= nBallRadius + aBallSpeed[ VECTOR2_X ] *= -1.0 ENDIF - IF ballPosition[ VECTOR2_Y ] >= GetScreenHeight() - ballRadius .OR. ballPosition[ VECTOR2_Y ] <= ballRadius - ballSpeed[ VECTOR2_Y ] *= -1.0 + IF aBallPosition[ VECTOR2_Y ] >= GetScreenHeight() - nBallRadius .OR. aBallPosition[ VECTOR2_Y ] <= nBallRadius + aBallSpeed[ VECTOR2_Y ] *= -1.0 ENDIF ELSE - framesCounter++ + nFramesCounter++ ENDIF BeginDrawing() ClearBackground( RAYWHITE ) - DrawCircleV( ballPosition, ballRadius, MAROON ) + DrawCircleV( aBallPosition, nBallRadius, MAROON ) DrawText( "PRESS SPACE to PAUSE BALL MOVEMENT", 10, GetScreenHeight() - 25, 20, LIGHTGRAY ) - IF pause .AND. framesCounter / 30 % 2 == 0 + IF lPause .AND. Int(nFramesCounter / 30) % 2 == 0 DrawText( "PAUSED", 350, 200, 30, GRAY ) ENDIF diff --git a/examples/harbour/shapes/shapes_collision_area.prg b/examples/harbour/shapes/shapes_collision_area.prg index 47f8cdb..c0e117e 100644 --- a/examples/harbour/shapes/shapes_collision_area.prg +++ b/examples/harbour/shapes/shapes_collision_area.prg @@ -50,10 +50,10 @@ PROCEDURE Main() boxB[ RECTANGLE_Y ] = screenUpperLimit ENDIF - collision := CheckCollisionRecs( boxA, boxB ) + collision := CheckCollisionRecs( boxB, boxA ) IF collision - boxCollision := GetCollisionRec( boxA, boxB ) + boxCollision := GetCollisionRec( boxB, boxA ) ENDIF IF IsKeyPressed( KEY_SPACE ) diff --git a/examples/harbour/shapes/shapes_colors_palette.prg b/examples/harbour/shapes/shapes_colors_palette.prg new file mode 100644 index 0000000..0740b3d --- /dev/null +++ b/examples/harbour/shapes/shapes_colors_palette.prg @@ -0,0 +1,77 @@ +#include "hbraylib.ch" + +#define MAX_COLORS_COUNT 21 + +#define RECTANGLE_X 1 +#define RECTANGLE_Y 2 +#define RECTANGLE_WIDTH 3 +#define RECTANGLE_HEIGHT 4 + +PROCEDURE Main() + + LOCAL screenWidth := 800 + LOCAL screenHeight := 450 + LOCAL aColors := { DARKGRAY, MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, DARKBROWN, GRAY, RED, GOLD, LIME, BLUE, VIOLET, BROWN, ; + LIGHTGRAY, PINK, YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE } + LOCAL aColorNames := { "DARKGRAY", "MAROON", "ORANGE", "DARKGREEN", "DARKBLUE", "DARKPURPLE", "DARKBROWN", "GRAY", "RED", "GOLD", "LIME", ; + "BLUE", "VIOLET", "BROWN", "LIGHTGRAY", "PINK", "YELLOW", "GREEN", "SKYBLUE", "PURPLE", "BEIGE" } + LOCAL aColorsRecs[ MAX_COLORS_COUNT, 4 ] + LOCAL aColorState[ MAX_COLORS_COUNT ] + LOCAL aMousePoint + LOCAL x := 0 + LOCAL i + + InitWindow( screenWidth, screenHeight, "Harbour raylib [shapes] example - colors palette" ) + + SetWindowIcon( LoadImage( "../../../docs/assets/img/LogoWindow16x16.png" ) ) + + FOR i := 1 TO MAX_COLORS_COUNT + aColorsRecs[ i, RECTANGLE_X ] := 20 + 100 * ( x % 7 ) + 10 * ( x % 7 ) + aColorsRecs[ i, RECTANGLE_Y ] := 80 + 100 * Int( x / 7 ) + 10 * Int( x / 7 ) + aColorsRecs[ i, RECTANGLE_WIDTH ] := 100 + aColorsRecs[ i, RECTANGLE_HEIGHT ] := 100 + x++ + NEXT + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + aMousePoint := GetMousePosition() + + FOR i := 1 TO MAX_COLORS_COUNT + IF CheckCollisionPointRec( aMousePoint, aColorsRecs[ i ] ) + aColorState[ i ] := 1 + ELSE + aColorState[ i ] := 0 + ENDIF + NEXT + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawText( "harbour raylib colors palette", 28, 42, 20, BLACK ) + DrawText( "press SPACE to see all colors", GetScreenWidth() - 180, GetScreenHeight() - 40, 10, GRAY ) + + FOR i := 1 TO MAX_COLORS_COUNT + + DrawRectangleRec( aColorsRecs[ i ], Fade( aColors[ i ], iif( aColorState[ i ] == 1, 0.6, 1.0 ) ) ) + + IF ( IsKeyDown( KEY_SPACE ) .OR. aColorState[ i ] == 1 ) + DrawRectangle( Int( aColorsRecs[ i, RECTANGLE_X ] ), Int( aColorsRecs[ i, RECTANGLE_Y ] + aColorsRecs[ i, RECTANGLE_HEIGHT ] - 26 ), ; + Int( aColorsRecs[ i, RECTANGLE_WIDTH ] ), 20, BLACK ) + DrawRectangleLinesEx( aColorsRecs[ i ], 6, Fade( BLACK, 0.3 ) ) + DrawText( aColorNames[ i ], Int( aColorsRecs[ i, RECTANGLE_X ] + aColorsRecs[ i, RECTANGLE_WIDTH ] - MeasureText( aColorNames[ i ], 10 ) - 12 ), ; + Int( aColorsRecs[ i, RECTANGLE_Y ] + aColorsRecs[ i, RECTANGLE_HEIGHT ] - 20 ), 10, aColors[ i ] ) + ENDIF + + NEXT + + EndDrawing() + + ENDDO + + CloseWindow() + + RETURN diff --git a/examples/harbour/shapes/shapes_lines_bezier.prg b/examples/harbour/shapes/shapes_lines_bezier.prg new file mode 100644 index 0000000..4457726 --- /dev/null +++ b/examples/harbour/shapes/shapes_lines_bezier.prg @@ -0,0 +1,37 @@ +#include "hbraylib.ch" + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aStart := { 0, 0 } + LOCAL aEnd := { nScreenWidth, nScreenHeight } + + SetConfigFlags( FLAG_MSAA_4X_HINT ) + InitWindow( nScreenWidth, nScreenHeight, "raylib [shapes] example - cubic-bezier lines" ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + IF IsMouseButtonDown( MOUSE_LEFT_BUTTON ) + aStart = GetMousePosition() + ELSEIF IsMouseButtonDown( MOUSE_RIGHT_BUTTON ) + aEnd = GetMousePosition() + ENDIF + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawText( "USE MOUSE LEFT-RIGHT CLICK to DEFINE LINE START and END POINTS", 15, 20, 20, GRAY ) + + DrawLineBezier( aStart, aEnd, 2.0, RED ) + + EndDrawing() + + ENDDO + + CloseWindow() + + RETURN diff --git a/examples/harbour/shapes/shapes_logo_raylib.prg b/examples/harbour/shapes/shapes_logo_raylib.prg index d56a306..003dedb 100644 --- a/examples/harbour/shapes/shapes_logo_raylib.prg +++ b/examples/harbour/shapes/shapes_logo_raylib.prg @@ -2,10 +2,10 @@ PROCEDURE Main() - LOCAL screenWidth := 800 - LOCAL screenHeight := 450 + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 - InitWindow( screenWidth, screenHeight, "Harbour raylib [shapes] example - raylib logo using shapes" ) + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [shapes] example - raylib logo using shapes" ) SetTargetFPS( 60 ) @@ -15,9 +15,9 @@ PROCEDURE Main() ClearBackground( RAYWHITE ) - DrawRectangle( Int( screenWidth / 2 ) - 128, Int( screenHeight / 2 ) - 128, 256, 256, BLACK ) - DrawRectangle( Int( screenWidth / 2 ) - 112, Int( screenHeight / 2 ) - 112, 224, 224, RAYWHITE ) - DrawText( "raylib", Int( screenWidth / 2 ) - 44, Int( screenHeight / 2 ) + 48, 50, BLACK ) + DrawRectangle( Int( nScreenWidth / 2 ) - 128, Int( nScreenHeight / 2 ) - 128, 256, 256, BLACK ) + DrawRectangle( Int( nScreenWidth / 2 ) - 112, Int( nScreenHeight / 2 ) - 112, 224, 224, RAYWHITE ) + DrawText( "raylib", Int( nScreenWidth / 2 ) - 44, Int( nScreenHeight / 2 ) + 48, 50, BLACK ) DrawText( "this is NOT a texture!", 350, 370, 10, GRAY ) diff --git a/examples/harbour/shapes/shapes_logo_raylib_anim.prg b/examples/harbour/shapes/shapes_logo_raylib_anim.prg index 194f6d0..23595c1 100644 --- a/examples/harbour/shapes/shapes_logo_raylib_anim.prg +++ b/examples/harbour/shapes/shapes_logo_raylib_anim.prg @@ -2,79 +2,79 @@ PROCEDURE Main() - LOCAL screenWidth := 800 - LOCAL screenHeight := 450 + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 LOCAL lContinue := .T. - LOCAL logoPositionX := Int( screenWidth / 2 - 128 ) - LOCAL logoPositionY := Int( screenHeight / 2 - 128 ) + LOCAL nLogoPositionX := Int( nScreenWidth / 2 - 128 ) + LOCAL nLogoPositionY := Int( nScreenHeight / 2 - 128 ) - LOCAL framesCounter := 0 - LOCAL lettersCount := 0 + LOCAL nFramesCounter := 0 + LOCAL nLettersCount := 0 - LOCAL topSideRecWidth := 16 - LOCAL leftSideRecHeight := 16 + LOCAL nTopSideRecWidth := 16 + LOCAL nLeftSideRecHeight := 16 - LOCAL bottomSideRecWidth := 16 - LOCAL rightSideRecHeight := 16 + LOCAL nBottomSideRecWidth := 16 + LOCAL nRightSideRecHeight := 16 - LOCAL STATE := 0 - LOCAL alpha := 1.0 + LOCAL nState := 0 + LOCAL nAlpha := 1.0 - InitWindow( screenWidth, screenHeight, "Harbour raylib [shapes] example - Harbour raylib logo animation" ) + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [shapes] example - Harbour raylib logo animation" ) SetTargetFPS( 60 ) DO WHILE lContinue - IF STATE == 0 - framesCounter++ - IF framesCounter == 120 - STATE := 1 - framesCounter := 0 + IF nState == 0 + nFramesCounter++ + IF nFramesCounter == 120 + nState := 1 + nFramesCounter := 0 ENDIF ELSE - IF STATE == 1 - topSideRecWidth += 4 - leftSideRecHeight += 4 - IF topSideRecWidth == 256 - STATE := 2 + IF nState == 1 + nTopSideRecWidth += 4 + nLeftSideRecHeight += 4 + IF nTopSideRecWidth == 256 + nState := 2 ENDIF ELSE - IF STATE == 2 - bottomSideRecWidth += 4 - rightSideRecHeight += 4 - IF bottomSideRecWidth == 256 - STATE := 3 + IF nState == 2 + nBottomSideRecWidth += 4 + nRightSideRecHeight += 4 + IF nBottomSideRecWidth == 256 + nState := 3 ENDIF ELSE - IF STATE == 3 - framesCounter++ - IF framesCounter = 12 - lettersCount++ - framesCounter := 0 + IF nState == 3 + nFramesCounter++ + IF nFramesCounter = 12 + nLettersCount++ + nFramesCounter := 0 ENDIF - IF lettersCount >= 10 - alpha -= 0.02 - IF alpha <= 0 - alpha := 0 - STATE := 4 + IF nLettersCount >= 18 + nAlpha -= 0.02 + IF nAlpha <= 0 + nAlpha := 0 + nState := 4 ENDIF ENDIF ELSE - IF STATE == 4 + IF nState == 4 IF IsKeyPressed( KEY_R ) - framesCounter := 0 - lettersCount := 0 + nFramesCounter := 0 + nLettersCount := 0 - topSideRecWidth := 16 - leftSideRecHeight := 16 + nTopSideRecWidth := 16 + nLeftSideRecHeight := 16 - bottomSideRecWidth := 16 - rightSideRecHeight := 16 + nBottomSideRecWidth := 16 + nRightSideRecHeight := 16 - alpha := 1.0 - STATE := 0 + nAlpha := 1.0 + nState := 0 ENDIF ENDIF ENDIF @@ -85,35 +85,34 @@ PROCEDURE Main() BeginDrawing() ClearBackground( RAYWHITE ) - IF STATE == 0 - IF ( framesCounter / 15 ) % 2 == 0 - DrawRectangle( logoPositionX, logoPositionY, 16, 16, BLACK ) + IF nState == 0 + IF Int( nFramesCounter / 15 ) % 2 == 0 + DrawRectangle( nLogoPositionX, nLogoPositionY, 16, 16, BLACK ) ENDIF ELSE - IF STATE == 1 - DrawRectangle( logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK ) - DrawRectangle( logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK ) + IF nState == 1 + DrawRectangle( nLogoPositionX, nLogoPositionY, nTopSideRecWidth, 16, BLACK ) + DrawRectangle( nLogoPositionX, nLogoPositionY, 16, nLeftSideRecHeight, BLACK ) ELSE - IF STATE == 2 - DrawRectangle( logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK ) - DrawRectangle( logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK ) + IF nState == 2 + DrawRectangle( nLogoPositionX, nLogoPositionY, nTopSideRecWidth, 16, BLACK ) + DrawRectangle( nLogoPositionX, nLogoPositionY, 16, nLeftSideRecHeight, BLACK ) - DrawRectangle( logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK ) - DrawRectangle( logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK ) + DrawRectangle( nLogoPositionX + 240, nLogoPositionY, 16, nRightSideRecHeight, BLACK ) + DrawRectangle( nLogoPositionX, nLogoPositionY + 240, nBottomSideRecWidth, 16, BLACK ) ELSE - IF STATE == 3 - DrawRectangle( logoPositionX, logoPositionY, topSideRecWidth, 16, Fade( BLACK, alpha ) ) - DrawRectangle( logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade( BLACK, alpha ) ) + IF nState == 3 + DrawRectangle( nLogoPositionX, nLogoPositionY, nTopSideRecWidth, 16, Fade( BLACK, nAlpha ) ) + DrawRectangle( nLogoPositionX, nLogoPositionY + 16, 16, nLeftSideRecHeight - 32, Fade( BLACK, nAlpha ) ) - DrawRectangle( logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade( BLACK, alpha ) ) - DrawRectangle( logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade( BLACK, alpha ) ) + DrawRectangle( nLogoPositionX + 240, nLogoPositionY + 16, 16, nRightSideRecHeight - 32, Fade( BLACK, nAlpha ) ) + DrawRectangle( nLogoPositionX, nLogoPositionY + 240, nBottomSideRecWidth, 16, Fade( BLACK, nAlpha ) ) - DrawRectangle( Int( screenWidth / 2 - 112 ), Int( screenHeight / 2 - 112 ), 224, 224, Fade( RAYWHITE, alpha ) ) + DrawRectangle( Int( nScreenWidth / 2 - 112 ), Int( nScreenHeight / 2 - 112 ), 224, 224, Fade( RAYWHITE, nAlpha ) ) - DrawText( TextSubtext( "Harbour", 0, lettersCount ), Int( screenWidth / 2 - 100 ), Int( screenHeight / 2 ), 50, Fade( BLACK, alpha ) ) - DrawText( TextSubtext( " raylib", 0, lettersCount ), Int( screenWidth / 2 - 30 ), Int( screenHeight / 2 + 48 ), 40, Fade( BLACK, alpha ) ) + DrawText( TextSubtext( e"Harbour\n raylib", 0, nLettersCount ), Int( nScreenWidth / 2 - 60 ), Int( nScreenHeight / 2 ), 40, Fade( BLACK, nAlpha ) ) ELSE - IF STATE == 4 + IF nState == 4 DrawText( "[R] REPLAY", 340, 200, 20, GRAY ) ENDIF ENDIF diff --git a/examples/harbour/shapes/shapes_rectangle_scaling.prg b/examples/harbour/shapes/shapes_rectangle_scaling.prg index 860d37c..bd552a9 100644 --- a/examples/harbour/shapes/shapes_rectangle_scaling.prg +++ b/examples/harbour/shapes/shapes_rectangle_scaling.prg @@ -31,7 +31,7 @@ PROCEDURE Main() CheckCollisionPointRec( mousePosition, { rec[ RECTANGLE_X ] + rec[ RECTANGLE_WIDTH ] - MOUSE_SCALE_MARK_SIZE, ; rec[ RECTANGLE_Y ] + rec[ RECTANGLE_HEIGHT ] - MOUSE_SCALE_MARK_SIZE, ; MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE } ) - + mouseScaleReady := .T. IF IsMouseButtonPressed( MOUSE_LEFT_BUTTON ) @@ -75,8 +75,8 @@ PROCEDURE Main() DrawRectangleLinesEx( rec, 1, RED ) DrawTriangle( { rec[ RECTANGLE_X ] + rec[ RECTANGLE_WIDTH ] - MOUSE_SCALE_MARK_SIZE, rec[ RECTANGLE_Y ] + rec[ RECTANGLE_HEIGHT ] }, ; - { rec[ RECTANGLE_X ] + rec[ RECTANGLE_WIDTH ], rec[ RECTANGLE_Y ] + rec[ RECTANGLE_HEIGHT ] }, ; - { rec[ RECTANGLE_X ] + rec[ RECTANGLE_WIDTH ], rec[ RECTANGLE_Y ] + rec[ RECTANGLE_HEIGHT ] - MOUSE_SCALE_MARK_SIZE }, RED ) + { rec[ RECTANGLE_X ] + rec[ RECTANGLE_WIDTH ], rec[ RECTANGLE_Y ] + rec[ RECTANGLE_HEIGHT ] }, ; + { rec[ RECTANGLE_X ] + rec[ RECTANGLE_WIDTH ], rec[ RECTANGLE_Y ] + rec[ RECTANGLE_HEIGHT ] - MOUSE_SCALE_MARK_SIZE }, RED ) ENDIF EndDrawing() diff --git a/examples/harbour/text/resources/KAISG.ttf b/examples/harbour/text/resources/KAISG.ttf new file mode 100644 index 0000000..04478b2 Binary files /dev/null and b/examples/harbour/text/resources/KAISG.ttf differ diff --git a/examples/harbour/text/resources/custom_alagard.png b/examples/harbour/text/resources/custom_alagard.png new file mode 100644 index 0000000..bbe688e Binary files /dev/null and b/examples/harbour/text/resources/custom_alagard.png differ diff --git a/examples/harbour/text/resources/custom_jupiter_crash.png b/examples/harbour/text/resources/custom_jupiter_crash.png new file mode 100644 index 0000000..c89572e Binary files /dev/null and b/examples/harbour/text/resources/custom_jupiter_crash.png differ diff --git a/examples/harbour/text/resources/custom_mecha.png b/examples/harbour/text/resources/custom_mecha.png new file mode 100644 index 0000000..5e20313 Binary files /dev/null and b/examples/harbour/text/resources/custom_mecha.png differ diff --git a/examples/harbour/text/resources/fonts/alagard.png b/examples/harbour/text/resources/fonts/alagard.png new file mode 100644 index 0000000..e8d15ee Binary files /dev/null and b/examples/harbour/text/resources/fonts/alagard.png differ diff --git a/examples/harbour/text/resources/fonts/alpha_beta.png b/examples/harbour/text/resources/fonts/alpha_beta.png new file mode 100644 index 0000000..6b880bd Binary files /dev/null and b/examples/harbour/text/resources/fonts/alpha_beta.png differ diff --git a/examples/harbour/text/resources/fonts/jupiter_crash.png b/examples/harbour/text/resources/fonts/jupiter_crash.png new file mode 100644 index 0000000..064df10 Binary files /dev/null and b/examples/harbour/text/resources/fonts/jupiter_crash.png differ diff --git a/examples/harbour/text/resources/fonts/mecha.png b/examples/harbour/text/resources/fonts/mecha.png new file mode 100644 index 0000000..88c2df7 Binary files /dev/null and b/examples/harbour/text/resources/fonts/mecha.png differ diff --git a/examples/harbour/text/resources/fonts/pixantiqua.png b/examples/harbour/text/resources/fonts/pixantiqua.png new file mode 100644 index 0000000..d9d3dfa Binary files /dev/null and b/examples/harbour/text/resources/fonts/pixantiqua.png differ diff --git a/examples/harbour/text/resources/fonts/pixelplay.png b/examples/harbour/text/resources/fonts/pixelplay.png new file mode 100644 index 0000000..5d5d563 Binary files /dev/null and b/examples/harbour/text/resources/fonts/pixelplay.png differ diff --git a/examples/harbour/text/resources/fonts/romulus.png b/examples/harbour/text/resources/fonts/romulus.png new file mode 100644 index 0000000..37b8f63 Binary files /dev/null and b/examples/harbour/text/resources/fonts/romulus.png differ diff --git a/examples/harbour/text/resources/fonts/setback.png b/examples/harbour/text/resources/fonts/setback.png new file mode 100644 index 0000000..7331c95 Binary files /dev/null and b/examples/harbour/text/resources/fonts/setback.png differ diff --git a/examples/harbour/text/resources/pixantiqua.ttf b/examples/harbour/text/resources/pixantiqua.ttf new file mode 100644 index 0000000..e012875 Binary files /dev/null and b/examples/harbour/text/resources/pixantiqua.ttf differ diff --git a/examples/harbour/text/text_font_filters.prg b/examples/harbour/text/text_font_filters.prg new file mode 100644 index 0000000..1c85c09 --- /dev/null +++ b/examples/harbour/text/text_font_filters.prg @@ -0,0 +1,105 @@ +#include "hbraylib.ch" + +#define FONT_BASESIZE 1 +#define FONT_TEXTURE 4 + +#define VECTOR2_X 1 +#define VECTOR2_Y 2 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL cMsg := "Loaded Font" + LOCAL aFont + LOCAL nFontSize + LOCAL aFontPosition := { 40, nScreenHeight / 2 - 80 } + LOCAL aTextSize + LOCAL nCurrentFontFilter := 0 + LOCAL nCount + LOCAL aDroppedFiles + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [text] example - Font filters" ) + + aFont := LoadFontEx( "resources/KAISG.ttf", 96, 0, 0 ) + + GenTextureMipmaps( aFont[ FONT_TEXTURE ] ) + + nFontSize := aFont[ FONT_BASESIZE ] + + SetTextureFilter( aFont[ FONT_TEXTURE ], FILTER_POINT ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + nFontSize += GetMouseWheelMove() * 4.0 + + IF IsKeyPressed( KEY_ONE ) + SetTextureFilter( aFont[ FONT_TEXTURE ], FILTER_POINT ) + nCurrentFontFilter := 0 + ELSEIF IsKeyPressed( KEY_TWO ) + SetTextureFilter( aFont[ FONT_TEXTURE ], FILTER_BILINEAR ) + nCurrentFontFilter := 1 + ELSEIF IsKeyPressed( KEY_THREE ) + SetTextureFilter( aFont[ FONT_TEXTURE ], FILTER_TRILINEAR ) + nCurrentFontFilter := 2 + ENDIF + + aTextSize := MeasureTextEx( aFont, cMsg, nFontSize, 0 ) + + IF IsKeyDown( KEY_LEFT ) + aFontPosition[ VECTOR2_X ] -= 10 + ELSEIF IsKeyDown( KEY_RIGHT ) + aFontPosition[ VECTOR2_X ] += 10 + ENDIF + + IF IsFileDropped() + + nCount := 1 + aDroppedFiles := GetDroppedFiles( nCount ) + + IF IsFileExtension( aDroppedFiles[ 1 ], ".ttf" ) + + UnloadFont( aFont ) + aFont := LoadFontEx( aDroppedFiles[ 1 ], Int( nFontSize ), 0, 0 ) + ClearDroppedFiles() + + ENDIF + ENDIF + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawText( "Use mouse wheel to change Font size", 20, 20, 10, GRAY ) + DrawText( "Use KEY_RIGHT and KEY_LEFT to move text", 20, 40, 10, GRAY ) + DrawText( "Use 1, 2, 3 to change texture filter", 20, 60, 10, GRAY ) + DrawText( "Drop a new TTF Font for dynamic loading", 20, 80, 10, DARKGRAY ) + + DrawTextEx( aFont, cMsg, aFontPosition, nFontSize, 0, BLACK ) + + DrawRectangle( 0, nScreenHeight - 80, nScreenWidth, 80, LIGHTGRAY ) + DrawText( TextFormat( "Font size: %02.02i", nFontSize ), 20, nScreenHeight - 50, 10, DARKGRAY ) + DrawText( TextFormat( "Text size: [%02.02i, %02.02i]", aTextSize[ VECTOR2_X ], aTextSize[ VECTOR2_Y ] ), 20, nScreenHeight - 30, 10, DARKGRAY ) + DrawText( "CURRENT TEXTURE FILTER:", 250, 400, 20, GRAY ) + + IF nCurrentFontFilter == 0 + DrawText( "POINT", 570, 400, 20, BLACK ) + ELSEIF nCurrentFontFilter == 1 + DrawText( "BILINEAR", 570, 400, 20, BLACK ) + ELSEIF nCurrentFontFilter == 2 + DrawText( "TRILINEAR", 570, 400, 20, BLACK ) + ENDIF + + EndDrawing() + + ENDDO + + ClearDroppedFiles() + + UnloadFont( aFont ) + + CloseWindow() + + RETURN diff --git a/examples/harbour/text/text_font_loading.prg b/examples/harbour/text/text_font_loading.prg new file mode 100644 index 0000000..33d6c0b --- /dev/null +++ b/examples/harbour/text/text_font_loading.prg @@ -0,0 +1,53 @@ +#include "hbraylib.ch" + +#define FONT_BASESIZE 1 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL cMsg := e"!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\n`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàąçêëèïîćÄĄĘęłôöĆûùŚÖܢťśƒ\nŹŻóÓńŃźż¿âŒÂ¬Â½Â¼Â¡Â«Â»â–‘▒▓│┤╡╢╖╕╣║╗â•╜╛â”└┴┬├─┼╞╟╚╔╩╦╠â•╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌â–â–€\nαßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√â¿Â²â– " + LOCAL aFontBm + LOCAL aFontTtf + LOCAL lUseTtf + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [text] example - font loading" ) + + aFontBm := LoadFont( "resources/pixantiqua.fnt" ) + + aFontTtf := LoadFontEx( "resources/pixantiqua.ttf", 32, 0, 250 ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + IF IsKeyDown( KEY_SPACE ) + lUseTtf := .T. + ELSE + lUseTtf := .F. + ENDIF + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawText( "Hold SPACE to use TTF generated font", 20, 20, 20, LIGHTGRAY ) + + IF ! lUseTtf + DrawTextEx( aFontBm, cMsg, { 20.0, 100.0 }, aFontBm[ FONT_BASESIZE ], 2, MAROON ) + DrawText( "Using BMFont (Angelcode) imported", 20, GetScreenHeight() - 30, 20, GRAY ) + ELSE + DrawTextEx( aFontTtf, cMsg, { 20.0, 100.0 }, aFontTtf[ FONT_BASESIZE ], 2, LIME ) + DrawText( "Using TTF font generated", 20, GetScreenHeight() - 30, 20, GRAY ) + ENDIF + + EndDrawing() + + ENDDO + + UnloadFont( aFontBm ) + UnloadFont( aFontTtf ) + + CloseWindow() + + RETURN diff --git a/examples/harbour/text/text_font_spritefont.prg b/examples/harbour/text/text_font_spritefont.prg new file mode 100644 index 0000000..bbf94ed --- /dev/null +++ b/examples/harbour/text/text_font_spritefont.prg @@ -0,0 +1,50 @@ +#include "hbraylib.ch" + +#define FONT_BASESIZE 1 +#define VECTOR2_X 1 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL cMsg1 := "THIS IS A custom SPRITE FONT..." + LOCAL cMsg2 := "...and this is ANOTHER CUSTOM font..." + LOCAL cMsg3 := "...and a THIRD one! GREAT! :D" + LOCAL aFont1, aFont2, aFont3 + LOCAL aFontPosition1, aFontPosition2, aFontPosition3 + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [text] example - sprite font loading" ) + + aFont1 := LoadFont( "resources/custom_mecha.png" ) + aFont2 := LoadFont( "resources/custom_alagard.png" ) + aFont3 := LoadFont( "resources/custom_jupiter_crash.png" ) + + aFontPosition1 := { nScreenWidth / 2 - MeasureTextEx( aFont1, cMsg1, aFont1[ FONT_BASESIZE ], -3 )[ VECTOR2_X ] / 2, nScreenHeight / 2 - aFont1[ FONT_BASESIZE ] / 2 - 80 } + + aFontPosition2 := { nScreenWidth / 2 - MeasureTextEx( aFont2, cMsg2, aFont2[ FONT_BASESIZE ], -2 )[ VECTOR2_X ] / 2, nScreenHeight / 2 - aFont2[ FONT_BASESIZE ] / 2 - 10 } + + aFontPosition3 := { nScreenWidth / 2 - MeasureTextEx( aFont3, cMsg3, aFont3[ FONT_BASESIZE ], 2 )[ VECTOR2_X ] / 2, nScreenHeight / 2 - aFont3[ FONT_BASESIZE ] / 2 + 50 } + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawTextEx( aFont1, cMsg1, aFontPosition1, aFont1[ FONT_BASESIZE ], -3, WHITE ) + DrawTextEx( aFont2, cMsg2, aFontPosition2, aFont2[ FONT_BASESIZE ], -2, WHITE ) + DrawTextEx( aFont3, cMsg3, aFontPosition3, aFont3[ FONT_BASESIZE ], 2, WHITE ) + + EndDrawing() + + ENDDO + + UnloadFont( aFont1 ) + UnloadFont( aFont2 ) + UnloadFont( aFont3 ) + + CloseWindow() + + RETURN diff --git a/examples/harbour/text/text_format_text.prg b/examples/harbour/text/text_format_text.prg new file mode 100644 index 0000000..534ca09 --- /dev/null +++ b/examples/harbour/text/text_format_text.prg @@ -0,0 +1,35 @@ +#include "hbraylib.ch" + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL nScore := 100020 + LOCAL nHiscore := 200450 + LOCAL nLives := 5 + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [text] example - text formatting" ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawText( TextFormat( "Score: %08i", nScore ), 200, 80, 20, RED ) + + DrawText( TextFormat( "HiScore: %08i", nHiscore ), 200, 120, 20, GREEN ) + + DrawText( TextFormat( "Lives: %02i", nLives ), 200, 160, 40, BLUE ) + + DrawText( TextFormat( "Elapsed Time: %02.02f ms", GetFrameTime() * 1000 ), 200, 220, 20, BLACK ) + + EndDrawing() + + ENDDO + + CloseWindow() + + RETURN diff --git a/examples/harbour/text/text_input_box.prg b/examples/harbour/text/text_input_box.prg new file mode 100644 index 0000000..7841541 --- /dev/null +++ b/examples/harbour/text/text_input_box.prg @@ -0,0 +1,91 @@ +#include "hbraylib.ch" + +#define MAX_INPUT_CHARS 9 + +#define RECTANGLE_X 1 +#define RECTANGLE_Y 2 +#define RECTANGLE_WIDTH 3 +#define RECTANGLE_HEIGHT 4 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL cName := "" + LOCAL nLetterCount := 0 + LOCAL aTextBox := { nScreenWidth / 2 - 100, 180, 225, 50 } + LOCAL lMouseOnText + LOCAL nFramesCounter := 0 + LOCAL nKey + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [text] example - input box" ) + + SetTargetFPS( 10 ) + + DO WHILE ! WindowShouldClose() + + IF CheckCollisionPointRec( GetMousePosition(), aTextBox ) + lMouseOnText := .T. + ELSE + lMouseOnText := .F. + ENDIF + + IF lMouseOnText + SetMouseCursor( MOUSE_CURSOR_IBEAM ) + nKey := GetCharPressed() + WHILE nKey > 0 + IF nKey >= 32 .AND. nKey <= 125 .AND. nLetterCount < MAX_INPUT_CHARS + cName += Chr( nKey ) + nLetterCount++ + ENDIF + nKey := GetCharPressed() + ENDDO + IF IsKeyPressed( KEY_BACKSPACE ) + nLetterCount-- + cName := SubStr( cName, 1, nLetterCount ) + IF nLetterCount < 0 + nLetterCount := 0 + ENDIF + ENDIF + ELSE + SetMouseCursor( MOUSE_CURSOR_DEFAULT ) + ENDIF + + IF lMouseOnText + nFramesCounter++ + ELSE + nFramesCounter := 0 + ENDIF + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawText( "PLACE MOUSE OVER INPUT BOX!", 240, 140, 20, GRAY ) + + DrawRectangleRec( aTextBox, LIGHTGRAY ) + + IF lMouseOnText + DrawRectangleLines( Int( aTextBox[ RECTANGLE_X ] ), Int( aTextBox[ RECTANGLE_Y ] ), Int( aTextBox[ RECTANGLE_WIDTH ] ), Int( aTextBox[ RECTANGLE_HEIGHT ] ), RED ) + ELSE + DrawRectangleLines( Int( aTextBox[ RECTANGLE_X ] ), Int( aTextBox[ RECTANGLE_Y ] ), Int( aTextBox[ RECTANGLE_WIDTH ] ), Int( aTextBox[ RECTANGLE_HEIGHT ] ), DARKGRAY ) + ENDIF + + DrawText( cName, Int( aTextBox[ RECTANGLE_X ] ) + 5, Int( aTextBox[ RECTANGLE_Y ] ) + 8, 40, MAROON ) + + DrawText( TextFormat( "INPUT CHARS: %i/%i", nLetterCount, MAX_INPUT_CHARS ), 315, 250, 20, DARKGRAY ) + + IF lMouseOnText + IF nLetterCount < MAX_INPUT_CHARS + IF ( nFramesCounter % 2 ) == 0 + DrawText( "_", Int( aTextBox[ RECTANGLE_X ] ) + 8 + MeasureText( cName, 40 ), Int( aTextBox[ RECTANGLE_Y ] ) + 12, 40, MAROON ) + ENDIF + ELSE + DrawText( "Press BACKSPACE to delete chars...", 230, 300, 20, GRAY ) + ENDIF + ENDIF + EndDrawing() + ENDDO + CloseWindow() + + RETURN diff --git a/examples/harbour/text/text_raylib_fonts.prg b/examples/harbour/text/text_raylib_fonts.prg new file mode 100644 index 0000000..2d3ab64 --- /dev/null +++ b/examples/harbour/text/text_raylib_fonts.prg @@ -0,0 +1,80 @@ +#include "hbraylib.ch" + +#define MAX_FONTS 8 + +#define VECTOR2_X 1 +#define VECTOR2_Y 2 + +#define FONT_BASESIZE 1 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aFonts[ MAX_FONTS ] + LOCAL aMessages + LOCAL aSpacings + LOCAL aPositions[ MAX_FONTS ][ 2 ] + LOCAL i + LOCAL aColors + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [text] example - raylib fonts" ) + + aFonts[ 1 ] := LoadFont( "resources/fonts/alagard.png" ) + aFonts[ 2 ] := LoadFont( "resources/fonts/pixelplay.png" ) + aFonts[ 3 ] := LoadFont( "resources/fonts/mecha.png" ) + aFonts[ 4 ] := LoadFont( "resources/fonts/setback.png" ) + aFonts[ 5 ] := LoadFont( "resources/fonts/romulus.png" ) + aFonts[ 6 ] := LoadFont( "resources/fonts/pixantiqua.png" ) + aFonts[ 7 ] := LoadFont( "resources/fonts/alpha_beta.png" ) + aFonts[ 8 ] := LoadFont( "resources/fonts/jupiter_crash.png" ) + + aMessages := { ; + "ALAGARD FONT designed by Hewett Tsoi", ; + "PIXELPLAY FONT designed by Aleksander Shevchuk", ; + "MECHA FONT designed by Captain Falcon", ; + "SETBACK FONT designed by Brian Kent (AEnigma)", ; + "ROMULUS FONT designed by Hewett Tsoi", ; + "PIXANTIQUA FONT designed by Gerhard Grossmann", ; + "ALPHA_BETA FONT designed by Brian Kent (AEnigma)", ; + "JUPITER_CRASH FONT designed by Brian Kent (AEnigma)" } + + aSpacings := { 2, 4, 8, 4, 3, 4, 4, 1 } + + FOR i := 1 TO MAX_FONTS + aPositions[ i ][ VECTOR2_X ] := nScreenWidth / 2 - MeasureTextEx( aFonts[ i ], aMessages[ i ], aFonts[ i ][ FONT_BASESIZE ] * 2, aSpacings[ i ] )[ VECTOR2_X ] / 2 + aPositions[ i ][ VECTOR2_Y ] := 60 + aFonts[ i ][ FONT_BASESIZE ] + 45 * i + NEXT + + aPositions[ 3 ][ VECTOR2_Y ] += 8 + aPositions[ 4 ][ VECTOR2_Y ] += 2 + aPositions[ 7 ][ VECTOR2_Y ] -= 8 + + aColors := { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED } + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawText( "free fonts included with raylib", 250, 20, 20, DARKGRAY ) + DrawLine( 220, 50, 590, 50, DARKGRAY ) + + FOR i := 1 TO MAX_FONTS + DrawTextEx( aFonts[ i ], aMessages[ i ], aPositions[ i ], aFonts[ i ][ FONT_BASESIZE ] * 2, aSpacings[ i ], aColors[ i ] ) + NEXT + + EndDrawing() + + ENDDO + + FOR i := 1 TO MAX_FONTS + UnloadFont( aFonts[ i ] ) + NEXT + + CloseWindow() + + RETURN diff --git a/examples/harbour/text/text_writing_anim.gif b/examples/harbour/text/text_writing_anim.gif deleted file mode 100644 index e8ff008..0000000 Binary files a/examples/harbour/text/text_writing_anim.gif and /dev/null differ diff --git a/examples/harbour/text/text_writing_anim.prg b/examples/harbour/text/text_writing_anim.prg index f32ac67..d4df7e6 100644 --- a/examples/harbour/text/text_writing_anim.prg +++ b/examples/harbour/text/text_writing_anim.prg @@ -4,9 +4,8 @@ PROCEDURE Main() LOCAL nScreenWidth := 800 LOCAL nScreenHeight := 450 - - LOCAL MESSAGE := "This sample illustrates a text writing" + Chr( 10 ) + "animation effect! take a look and you" + Chr( 10 ) + " will see that Harbor is great! ;)" - LOCAL framesCounter := 0 + LOCAL cMESSAGE := e"This sample illustrates a text writing\nanimation effect! Check it out! ;)" + LOCAL nframesCounter := 0 InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [text] example - text writing anim" ) @@ -15,20 +14,20 @@ PROCEDURE Main() DO WHILE ! WindowShouldClose() IF IsKeyDown( KEY_SPACE ) - framesCounter += 8 + nframesCounter += 8 ELSE - framesCounter++ + nframesCounter++ ENDIF IF IsKeyPressed( KEY_ENTER ) - framesCounter := 0 + nframesCounter := 0 ENDIF BeginDrawing() ClearBackground( RAYWHITE ) - DrawText( TextSubtext( MESSAGE, 0, framesCounter / 10 ), 210, 130, 20, MAROON ) + DrawText( TextSubtext( cMESSAGE, 0, nframesCounter / 10 ), 210, 130, 20, MAROON ) DrawText( "PRESS [ENTER] to RESTART!", 240, 260, 20, LIGHTGRAY ) DrawText( "PRESS [SPACE] to SPEED UP!", 239, 300, 20, LIGHTGRAY ) diff --git a/examples/harbour/textures/hbmk.hbm b/examples/harbour/textures/hbmk.hbm new file mode 100644 index 0000000..a5c4779 --- /dev/null +++ b/examples/harbour/textures/hbmk.hbm @@ -0,0 +1,2 @@ +hbraylib.hbc +-w3 -es2 \ No newline at end of file diff --git a/examples/harbour/textures/resources/boom.wav b/examples/harbour/textures/resources/boom.wav new file mode 100644 index 0000000..fd18137 Binary files /dev/null and b/examples/harbour/textures/resources/boom.wav differ diff --git a/examples/harbour/textures/resources/cat.png b/examples/harbour/textures/resources/cat.png new file mode 100644 index 0000000..db56b9e Binary files /dev/null and b/examples/harbour/textures/resources/cat.png differ diff --git a/examples/harbour/textures/resources/custom_jupiter_crash.png b/examples/harbour/textures/resources/custom_jupiter_crash.png new file mode 100644 index 0000000..c89572e Binary files /dev/null and b/examples/harbour/textures/resources/custom_jupiter_crash.png differ diff --git a/examples/harbour/textures/resources/cyberpunk_street_background.png b/examples/harbour/textures/resources/cyberpunk_street_background.png new file mode 100644 index 0000000..838d08a Binary files /dev/null and b/examples/harbour/textures/resources/cyberpunk_street_background.png differ diff --git a/examples/harbour/textures/resources/cyberpunk_street_foreground.png b/examples/harbour/textures/resources/cyberpunk_street_foreground.png new file mode 100644 index 0000000..528b4ae Binary files /dev/null and b/examples/harbour/textures/resources/cyberpunk_street_foreground.png differ diff --git a/examples/harbour/textures/resources/cyberpunk_street_midground.png b/examples/harbour/textures/resources/cyberpunk_street_midground.png new file mode 100644 index 0000000..73f24fe Binary files /dev/null and b/examples/harbour/textures/resources/cyberpunk_street_midground.png differ diff --git a/examples/harbour/textures/resources/explosion.png b/examples/harbour/textures/resources/explosion.png new file mode 100644 index 0000000..6df1cf3 Binary files /dev/null and b/examples/harbour/textures/resources/explosion.png differ diff --git a/examples/harbour/textures/resources/parrots.png b/examples/harbour/textures/resources/parrots.png new file mode 100644 index 0000000..9a0e7f8 Binary files /dev/null and b/examples/harbour/textures/resources/parrots.png differ diff --git a/examples/harbour/textures/resources/raylib_logo.png b/examples/harbour/textures/resources/raylib_logo.png new file mode 100644 index 0000000..eb25185 Binary files /dev/null and b/examples/harbour/textures/resources/raylib_logo.png differ diff --git a/examples/harbour/textures/resources/scarfy.png b/examples/harbour/textures/resources/scarfy.png new file mode 100644 index 0000000..be3b83d Binary files /dev/null and b/examples/harbour/textures/resources/scarfy.png differ diff --git a/examples/harbour/textures/resources/spark_flame.png b/examples/harbour/textures/resources/spark_flame.png new file mode 100644 index 0000000..72cea2e Binary files /dev/null and b/examples/harbour/textures/resources/spark_flame.png differ diff --git a/examples/harbour/textures/resources/wabbit_alpha.png b/examples/harbour/textures/resources/wabbit_alpha.png new file mode 100644 index 0000000..db4081f Binary files /dev/null and b/examples/harbour/textures/resources/wabbit_alpha.png differ diff --git a/examples/harbour/textures/textures_background_scrolling.prg b/examples/harbour/textures/textures_background_scrolling.prg new file mode 100644 index 0000000..51bf291 --- /dev/null +++ b/examples/harbour/textures/textures_background_scrolling.prg @@ -0,0 +1,74 @@ +#include "hbraylib.ch" + +#define TEXTURE2D_WIDTH 2 +#define TEXTURE2D_HEIGHT 3 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + + LOCAL aBackground + LOCAL aMidground + LOCAL aForeground + + LOCAL nScrollingBack := 0.0 + LOCAL nScrollingMid := 0.0 + LOCAL nScrollingFore := 0.0 + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [textures] example - background scrolling" ) + + aBackground := LoadTexture( "resources/cyberpunk_street_background.png" ) + aMidground := LoadTexture( "resources/cyberpunk_street_midground.png" ) + aForeground := LoadTexture( "resources/cyberpunk_street_foreground.png" ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + nScrollingBack -= 0.1 + nScrollingMid -= 0.5 + nScrollingFore -= 1.0 + + IF ( nScrollingBack <= -aBackground[ TEXTURE2D_WIDTH ] * 2 ) + nScrollingBack := 0 + ENDIF + + IF ( nScrollingMid <= -aMidground[ TEXTURE2D_WIDTH ] * 2 ) + nScrollingMid := 0 + ENDIF + + IF ( nScrollingFore <= -aForeground[ TEXTURE2D_WIDTH ] * 2 ) + nScrollingFore := 0 + ENDIF + + BeginDrawing() + + ClearBackground( GetColor( 0x052c46ff ) ) + + DrawTextureEx( aBackground, { nScrollingBack, 20 }, 0.0, 2.0, WHITE ) + + DrawTextureEx( aBackground, { aBackground[ TEXTURE2D_WIDTH ] * 2 + nScrollingBack, 20 }, 0.0, 2.0, WHITE ) + + DrawTextureEx( aMidground, { nScrollingMid, 20 }, 0.0, 2.0, WHITE ) + + DrawTextureEx( aMidground, { aMidground[ TEXTURE2D_WIDTH ] * 2 + nScrollingMid, 20 }, 0.0, 2.0, WHITE ) + + DrawTextureEx( aForeground, { nScrollingFore, 70 }, 0.0, 2.0, WHITE ) + + DrawTextureEx( aForeground, { aForeground[ TEXTURE2D_WIDTH ] * 2 + nScrollingFore, 70 }, 0.0, 2.0, WHITE ) + + DrawText( "BACKGROUND SCROLLING & PARALLAX", 10, 10, 20, RED ) + DrawText( "(c) Cyberpunk Street Environment by Luis Zuno (@ansimuz)", nScreenWidth - 330, nScreenHeight - 20, 10, RAYWHITE ) + + EndDrawing() + + ENDDO + + UnloadTexture( aBackground ) + UnloadTexture( aMidground ) + UnloadTexture( aForeground ) + + CloseWindow() + + RETURN diff --git a/examples/harbour/textures/textures_blend_modes.prg b/examples/harbour/textures/textures_blend_modes.prg new file mode 100644 index 0000000..7103f04 --- /dev/null +++ b/examples/harbour/textures/textures_blend_modes.prg @@ -0,0 +1,76 @@ +#include "hbraylib.ch" + +#define TEXTURE2D_WIDTH 2 +#define TEXTURE2D_HEIGHT 3 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + + LOCAL aBgImage + LOCAL aBgTexture + + LOCAL aFgImage + LOCAL aFgTexture + + LOCAL nBlendCountMax := 4 + LOCAL nBlendMode := 0 + + SetTargetFPS( 60 ) + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [textures] example - blend modes" ) + + aBgImage := LoadImage( "resources/cyberpunk_street_background.png" ) + aBgTexture := LoadTextureFromImage( aBgImage ) + + aFgImage := LoadImage( "resources/cyberpunk_street_foreground.png" ) + aFgTexture := LoadTextureFromImage( aFgImage ) + + UnloadImage( aBgImage ) + UnloadImage( aFgImage ) + + DO WHILE ! WindowShouldClose() + IF IsKeyPressed( KEY_SPACE ) + IF nBlendMode >= nBlendCountMax - 1 + nBlendMode := 0 + ELSE + nBlendMode++ + ENDIF + ENDIF + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawTexture( aBgTexture, Int( nScreenWidth / 2 - aBgTexture[ TEXTURE2D_WIDTH ] / 2 ), Int( nScreenHeight / 2 - aBgTexture[ TEXTURE2D_HEIGHT ] / 2 ), WHITE ) + + BeginBlendMode( nBlendMode ) + DrawTexture( aFgTexture, Int( nScreenWidth / 2 - afgTexture[ TEXTURE2D_WIDTH ] / 2 ), Int( nScreenHeight / 2 - afgTexture[ TEXTURE2D_HEIGHT ] / 2 ), WHITE ) + EndBlendMode() + + DrawText( "Press SPACE to change blend modes.", 310, 350, 10, GRAY ) + + DO CASE + CASE nBlendMode = BLEND_ALPHA + DrawText( "Current: BLEND_ALPHA", Int( nScreenWidth / 2 - 60 ), 370, 10, GRAY ) + CASE nBlendMode = BLEND_ADDITIVE + DrawText( "Current: BLEND_ADDITIVE", Int( nScreenWidth / 2 - 60 ), 370, 10, GRAY ) + CASE nBlendMode = BLEND_MULTIPLIED + DrawText( "Current: BLEND_MULTIPLIED", Int( nScreenWidth / 2 - 60 ), 370, 10, GRAY ) + CASE nBlendMode = BLEND_ADD_COLORS + DrawText( "Current: BLEND_ADD_COLORS", Int( nScreenWidth / 2 - 60 ), 370, 10, GRAY ) + ENDCASE + + DrawText( "(c) Cyberpunk Street Environment by Luis Zuno (@ansimuz)", Int( nScreenWidth - 330 ), Int( nScreenHeight - 20 ), 10, GRAY ) + + EndDrawing() + + ENDDO + + UnloadTexture( aBgTexture ) + UnloadTexture( afgTexture ) + + CloseWindow() + + RETURN diff --git a/examples/harbour/textures/textures_bunnymark.prg b/examples/harbour/textures/textures_bunnymark.prg new file mode 100644 index 0000000..9648dcf --- /dev/null +++ b/examples/harbour/textures/textures_bunnymark.prg @@ -0,0 +1,80 @@ +#include "hbraylib.ch" + +#define MAX_BUNNIES 50000 +#define MAX_BATCH_ELEMENTS 8192 + +#define POSITION 1 +#define SPEED 2 +#define ACOLOR 3 + +#define VECTOR2_X 1 +#define VECTOR2_Y 2 + +#define TEXTURE2D_WIDTH 2 +#define TEXTURE2D_HEIGHT 3 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + + LOCAL aTexBunny + LOCAL nBunniesCount := 0 + LOCAL aBunnies[ 3, MAX_BUNNIES ] + LOCAL i + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [textures] example - bunnymark" ) + + aTexBunny := LoadTexture( "resources/wabbit_alpha.png" ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + IF IsMouseButtonDown( MOUSE_LEFT_BUTTON ) + FOR i := 0 TO 100 + IF nBunniesCount < MAX_BUNNIES + nBunniesCount++ + aBunnies[ POSITION, nBunniesCount ] := GetMousePosition() + aBunnies[ SPEED, nBunniesCount ] := { GetRandomValue( - 250, 250 ) / 60.0, GetRandomValue( - 250, 250 ) / 60.0 } + aBunnies[ ACOLOR, nBunniesCount ] := { GetRandomValue( 50, 240 ), GetRandomValue( 80, 240 ), GetRandomValue( 100, 240 ), 255 } + ENDIF + NEXT + ENDIF + + FOR i := 1 TO nBunniesCount + aBunnies[ POSITION, i, VECTOR2_X ] += aBunnies[ SPEED, i, VECTOR2_X ] + aBunnies[ POSITION, i, VECTOR2_Y ] += aBunnies[ SPEED, i, VECTOR2_Y ] + IF aBunnies[ POSITION, i, VECTOR2_X ] + aTexBunny[ TEXTURE2D_WIDTH ] / 2 > GetScreenWidth() .OR. ; + aBunnies[ POSITION, i, VECTOR2_X ] + aTexBunny[ TEXTURE2D_WIDTH ] / 2 < 0 + aBunnies[ SPEED, i, VECTOR2_X ] *= -1 + ENDIF + IF aBunnies[ POSITION, i, VECTOR2_Y ] + aTexBunny[ TEXTURE2D_HEIGHT ] / 2 > GetScreenHeight() .OR. ; + aBunnies[ POSITION, i, VECTOR2_Y ] + aTexBunny[ TEXTURE2D_HEIGHT ] / 2 - 40 < 0 + aBunnies[ SPEED, i, VECTOR2_Y ] *= -1 + ENDIF + NEXT + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + FOR i := 1 TO nBunniesCount + DrawTexture( aTexBunny, Int( aBunnies[ POSITION, i, VECTOR2_X ] ), Int( aBunnies[ POSITION, i, VECTOR2_Y ] ), aBunnies[ ACOLOR, i ] ) + NEXT + + DrawRectangle( 0, 0, nScreenWidth, 40, BLACK ) + DrawText( TextFormat( "bunnies: %i", nBunniesCount ), 120, 10, 20, GREEN ) + DrawText( TextFormat( "batched draw calls: %i", 1 + nBunniesCount / MAX_BATCH_ELEMENTS ), 320, 10, 20, MAROON ) + + DrawFPS( 10, 10 ) + + EndDrawing() + + ENDDO + + UnloadTexture( aTexBunny ) + + CloseWindow() + + RETURN diff --git a/examples/harbour/textures/textures_image_drawing.prg b/examples/harbour/textures/textures_image_drawing.prg new file mode 100644 index 0000000..2391626 --- /dev/null +++ b/examples/harbour/textures/textures_image_drawing.prg @@ -0,0 +1,68 @@ +#include "hbraylib.ch" + +#define TEXTURE2D_WIDTH 2 +#define TEXTURE2D_HEIGHT 3 + +#define VECTOR2_X 1 +#define VECTOR2_Y 2 + +#define FONT_BASESIZE 1 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aCat + LOCAL aParrots + LOCAL aTexture + LOCAL aFont + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [textures] example - image drawing" ) + + aCat := LoadImage( "resources/cat.png" ) + // ImageCrop( aCat, { 100, 10, 280, 380 } ) + // ImageFlipHorizontal( aCat ) + // ImageResize( aCat, 150, 200 ) + aParrots := LoadImage( "resources/parrots.png" ) + + ImageDraw( aParrots, aCat, { 0, 0, aCat[ TEXTURE2D_WIDTH ], aCat[ TEXTURE2D_HEIGHT ] }, { 30, 40, aCat[ TEXTURE2D_WIDTH ] * 1.5, aCat[ TEXTURE2D_HEIGHT ] * 1.5 }, WHITE ) + // ImageCrop( aParrots, { 0, 50, aParrots[ TEXTURE2D_WIDTH ], aParrots[ TEXTURE2D_HEIGHT ] - 100 } ) + ImageDrawPixel( aParrots, 10, 10, RAYWHITE ) + ImageDrawCircle( aParrots, 10, 10, 5, RAYWHITE ) + ImageDrawRectangle( aParrots, 5, 20, 10, 10, RAYWHITE ) + + UnloadImage( aCat ) + + aFont := LoadFont( "resources/custom_jupiter_crash.png" ) + + ImageDrawTextEx( aParrots, aFont, "PARROTS & CAT", { 300, 230 }, aFont[ FONT_BASESIZE ], - 2, WHITE ) + + UnloadFont( aFont ) + + aTexture := LoadTextureFromImage( aParrots ) + UnloadImage( aParrots ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawTexture( aTexture, Int( nScreenWidth / 2 - aTexture[ TEXTURE2D_WIDTH ] / 2 ), Int( nScreenHeight / 2 - aTexture[ TEXTURE2D_HEIGHT ] / 2 - 40 ), WHITE ) + DrawRectangleLines( Int( nScreenWidth / 2 - aTexture[ TEXTURE2D_WIDTH ] / 2 ), Int( nScreenHeight / 2 - aTexture[ TEXTURE2D_HEIGHT ] / 2 - 40 ), ; + Int( aTexture[ TEXTURE2D_WIDTH ] ), Int( aTexture[ TEXTURE2D_HEIGHT ] ), DARKGRAY ) + + DrawText( "We are drawing only one texture from various images composed!", 240, 350, 10, DARKGRAY ) + DrawText( "Source images have been cropped, scaled, flipped and copied one over the other.", 190, 370, 10, DARKGRAY ) + + EndDrawing() + + ENDDO + + UnloadTexture( aTexture ) + + CloseWindow() + + RETURN diff --git a/examples/harbour/textures/textures_image_generation.prg b/examples/harbour/textures/textures_image_generation.prg new file mode 100644 index 0000000..cbb3eca --- /dev/null +++ b/examples/harbour/textures/textures_image_generation.prg @@ -0,0 +1,81 @@ +#include "hbraylib.ch" + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + + LOCAL aVerticalGradient := GenImageGradientV( nScreenWidth, nScreenHeight, RED, BLUE ) + LOCAL aHorizontalGradient := GenImageGradientH( nScreenWidth, nScreenHeight, RED, BLUE ) + LOCAL aRadialGradient := GenImageGradientRadial( nScreenWidth, nScreenHeight, 0.0, WHITE, BLACK ) + LOCAL aChecked := GenImageChecked( nScreenWidth, nScreenHeight, 32, 32, RED, BLUE ) + LOCAL aWhiteNoise := GenImageWhiteNoise( nScreenWidth, nScreenHeight, 0.5 ) + LOCAL aPerlinNoise := GenImagePerlinNoise( nScreenWidth, nScreenHeight, 50, 50, 4.0 ) + LOCAL aCellular := GenImageCellular( nScreenWidth, nScreenHeight, 32 ) + LOCAL aTextures[ 7 ] + LOCAL nCurrentTexture := 1 + LOCAL i + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [Textures] example - procedural images generation" ) + + aTextures[ 1 ] := LoadTextureFromImage( aVerticalGradient ) + aTextures[ 2 ] := LoadTextureFromImage( aHorizontalGradient ) + aTextures[ 3 ] := LoadTextureFromImage( aRadialGradient ) + aTextures[ 4 ] := LoadTextureFromImage( aChecked ) + aTextures[ 5 ] := LoadTextureFromImage( aWhiteNoise ) + aTextures[ 6 ] := LoadTextureFromImage( aPerlinNoise ) + aTextures[ 7 ] := LoadTextureFromImage( aCellular ) + + UnloadImage( aVerticalGradient ) + UnloadImage( aHorizontalGradient ) + UnloadImage( aRadialGradient ) + UnloadImage( aChecked ) + UnloadImage( aWhiteNoise ) + UnloadImage( aPerlinNoise ) + UnloadImage( aCellular ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + IF IsMouseButtonPressed( MOUSE_LEFT_BUTTON ) .OR. IsKeyPressed( KEY_RIGHT ) + iif( nCurrentTexture < Len( aTextures ), nCurrentTexture++, nCurrentTexture := 1 ) + ENDIF + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawTexture( aTextures[ nCurrentTexture ], 0, 0, WHITE ) + + DrawRectangle( 30, 400, 325, 30, Fade( SKYBLUE, 0.5 ) ) + DrawRectangleLines( 30, 400, 325, 30, Fade( WHITE, 0.5 ) ) + DrawText( "MOUSE LEFT BUTTON to CYCLE PROCEDURAL TEXTURES", 40, 410, 10, WHITE ) + + DO CASE + CASE nCurrentTexture = 1 + DrawText( "VERTICAL GRADIENT", 560, 10, 20, RAYWHITE ) + CASE nCurrentTexture = 2 + DrawText( "HORIZONTAL GRADIENT", 540, 10, 20, RAYWHITE ) + CASE nCurrentTexture = 3 + DrawText( "RADIAL GRADIENT", 580, 10, 20, LIGHTGRAY ) + CASE nCurrentTexture = 4 + DrawText( "CHECKED", 680, 10, 20, RAYWHITE ) + CASE nCurrentTexture = 5 + DrawText( "WHITE NOISE", 640, 10, 20, RED ) + CASE nCurrentTexture = 6 + DrawText( "PERLIN NOISE", 630, 10, 20, RAYWHITE ) + CASE nCurrentTexture = 7 + DrawText( "CELLULAR", 670, 10, 20, RAYWHITE ) + ENDCASE + EndDrawing() + + ENDDO + + FOR i := 1 TO Len( aTextures ) + UnloadTexture( aTextures[ i ] ) + NEXT + + CloseWindow() + + RETURN diff --git a/examples/harbour/textures/textures_image_loading.prg b/examples/harbour/textures/textures_image_loading.prg new file mode 100644 index 0000000..d6729b4 --- /dev/null +++ b/examples/harbour/textures/textures_image_loading.prg @@ -0,0 +1,42 @@ +#include "hbraylib.ch" + +#define TEXTURE2D_WIDTH 2 +#define TEXTURE2D_HEIGHT 3 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + + LOCAL aImage + LOCAL aTexture + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [textures] example - image loading" ) + + aImage := LoadImage( "resources/raylib_logo.png" ) + + aTexture := LoadTextureFromImage( aImage ) + + UnloadImage( aImage ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawTexture( aTexture, Int( nScreenWidth / 2 - aTexture[ TEXTURE2D_WIDTH ] / 2 ), Int( nScreenHeight / 2 - aTexture[ TEXTURE2D_HEIGHT ] / 2 ), WHITE ) + + DrawText( "this IS a texture loaded from an image!", 300, 370, 10, GRAY ) + + EndDrawing() + + ENDDO + + UnloadTexture( aTexture ) + + CloseWindow() + + RETURN diff --git a/examples/harbour/textures/textures_logo_raylib.prg b/examples/harbour/textures/textures_logo_raylib.prg new file mode 100644 index 0000000..aecdb46 --- /dev/null +++ b/examples/harbour/textures/textures_logo_raylib.prg @@ -0,0 +1,37 @@ +#include "hbraylib.ch" + +#define TEXTURE2D_WIDTH 2 +#define TEXTURE2D_HEIGHT 3 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + + LOCAL aTexture + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [aTextures] example - Texture loading and drawing" ) + + aTexture := LoadTexture( "resources/raylib_logo.png" ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawTexture( aTexture, Int( nScreenWidth / 2 - aTexture[ TEXTURE2D_WIDTH ] / 2 ), Int( nScreenHeight / 2 - aTexture[ TEXTURE2D_HEIGHT ] / 2 ), WHITE ) + + DrawText( "this IS a aTexture!", 360, 370, 10, GRAY ) + + EndDrawing() + + ENDDO + + UnloadTexture( aTexture ) + + CloseWindow() + + RETURN diff --git a/examples/harbour/textures/textures_particles_blending.prg b/examples/harbour/textures/textures_particles_blending.prg new file mode 100644 index 0000000..7d013a0 --- /dev/null +++ b/examples/harbour/textures/textures_particles_blending.prg @@ -0,0 +1,110 @@ +#include "hbraylib.ch" + +#define MAX_PARTICLES 200 +#define POSITION 1 +#define ACOLOR 2 +#define ALPHA 3 +#define SIZE 4 +#define ROTATION 5 +#define ACTIVE 6 + +#define TEXTURE2D_WIDTH 2 +#define TEXTURE2D_HEIGHT 3 + +#define VECTOR2_X 1 +#define VECTOR2_Y 2 + +#define RECTANGLE_X 1 +#define RECTANGLE_Y 2 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aMouseTail[ 6, MAX_PARTICLES ] + LOCAL aSmoke + LOCAL nBlending := BLEND_ALPHA + LOCAL nGravity := 3.0 + LOCAL aSourceRec := { 0.0, 0.0 } + LOCAL i + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [textures] example - particles blending" ) + + FOR i := 1 TO MAX_PARTICLES + aMouseTail[ POSITION, i ] := { 3, 4 } + aMouseTail[ ACOLOR, i ] := { GetRandomValue( 0, 255 ), GetRandomValue( 0, 255 ), GetRandomValue( 0, 255 ), 255 } + aMouseTail[ ALPHA, i ] := 1 + aMouseTail[ SIZE, i ] := GetRandomValue( 1, 30 ) / 20.0 + aMouseTail[ ROTATION, i ] := GetRandomValue( 0, 360 ) + aMouseTail[ ACTIVE, i ] := .F. + NEXT + + aSmoke = LoadTexture( "resources/spark_flame.png" ) + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + FOR i := 1 TO MAX_PARTICLES + IF !aMouseTail[ ACTIVE, i ] + aMouseTail[ ACTIVE, i ] := .T. + aMouseTail[ ALPHA, i ] := 1 + aMouseTail[ POSITION, i ] := GetMousePOSITION() + i := MAX_PARTICLES + ENDIF + NEXT + + FOR i := 1 TO MAX_PARTICLES + IF aMouseTail[ ACTIVE, i ] + aMouseTail[ POSITION, i, VECTOR2_Y ] += nGravity / 2 + aMouseTail[ ALPHA, i ] -= 0.005 + ENDIF + + IF aMouseTail[ ALPHA, i ] <= 0 + aMouseTail[ ACTIVE, i ] := .F. + ENDIF + aMouseTail[ ROTATION, i ] += 2.0 + NEXT + + IF IsKeyPressed( KEY_SPACE ) + IF nBlending == BLEND_ALPHA + nBlending := BLEND_ADDITIVE + ELSE + nBlending := BLEND_ALPHA + ENDIF + ENDIF + + BeginDrawing() + + ClearBackground( DARKGRAY ) + + BeginBlendMode( nBlending ) + + FOR i := 1 TO MAX_PARTICLES + IF aMouseTail[ ACTIVE, i ] + DrawTexturePro( aSmoke, { aSourceRec[ RECTANGLE_X ], aSourceRec[ RECTANGLE_Y ], aSmoke[ TEXTURE2D_WIDTH ], aSmoke[ TEXTURE2D_HEIGHT ] }, ; + { aMouseTail[ POSITION, i, VECTOR2_X ], aMouseTail[ POSITION, i, VECTOR2_Y ], aSmoke[ TEXTURE2D_WIDTH ] * aMouseTail[ SIZE, i ], aSmoke[ TEXTURE2D_HEIGHT ] * aMouseTail[ SIZE, i ] }, ; + { ( aSmoke[ TEXTURE2D_WIDTH ] * aMouseTail[ SIZE, i ] / 2.0 ), ( aSmoke[ TEXTURE2D_HEIGHT ] * aMouseTail[ SIZE, i ] / 2.0 ) }, ; + aMouseTail[ ROTATION, i ], Fade( aMouseTail[ ACOLOR, i ], aMouseTail[ ALPHA, i ] ) ) + ENDIF + NEXT + + EndBlendMode() + + DrawText( "PRESS SPACE to CHANGE BLENDING MODE", 180, 20, 20, BLACK ) + + IF nBlending == BLEND_ALPHA + DrawText( "ALPHA BLENDING", 290, nScreenHeight - 40, 20, BLACK ) + ELSE + DrawText( "ADDITIVE BLENDING", 280, nScreenHeight - 40, 20, RAYWHITE ) + ENDIF + + EndDrawing() + + ENDDO + + UnloadTexture( aSmoke ) + + CloseWindow() + + RETURN diff --git a/examples/harbour/textures/textures_rectangle.prg b/examples/harbour/textures/textures_rectangle.prg new file mode 100644 index 0000000..974ca22 --- /dev/null +++ b/examples/harbour/textures/textures_rectangle.prg @@ -0,0 +1,98 @@ +#include "hbraylib.ch" + +#define MAX_FRAME_SPEED 15 +#define MIN_FRAME_SPEED 1 + +#define TEXTURE2D_WIDTH 2 +#define TEXTURE2D_HEIGHT 3 + +#define RECTANGLE_X 1 +#define RECTANGLE_Y 2 +#define RECTANGLE_WIDTH 3 +#define RECTANGLE_HEIGHT 4 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aScarfy + LOCAL aPosition + LOCAL aFrameRec + LOCAL nCurrentFrame := 0 + LOCAL nFramesCounter := 0 + LOCAL nFramesSpeed := 8 + LOCAL i + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [texture] example - texture rectangle" ) + + aScarfy := LoadTexture( "resources/scarfy.png" ) + + aPosition := { 350.0, 280.0 } + aFrameRec := { 0.0, 0.0, aScarfy[ TEXTURE2D_WIDTH ] / 6, aScarfy[ TEXTURE2D_HEIGHT ] } + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + nFramesCounter++ + + IF nFramesCounter >= ( 60 / nFramesSpeed ) + + nFramesCounter := 0 + nCurrentFrame++ + + IF nCurrentFrame > 5 + nCurrentFrame := 0 + ENDIF + + aFrameRec[ RECTANGLE_X ] := nCurrentFrame * aScarfy[ TEXTURE2D_WIDTH ] / 6 + + ENDIF + + IF IsKeyPressed( KEY_RIGHT ) + nFramesSpeed++ + ELSEIF IsKeyPressed( KEY_LEFT ) + nFramesSpeed-- + ENDIF + + IF nFramesSpeed > MAX_FRAME_SPEED + nFramesSpeed := MAX_FRAME_SPEED + ELSEIF nFramesSpeed < MIN_FRAME_SPEED + nFramesSpeed := MIN_FRAME_SPEED + ENDIF + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawTexture( aScarfy, 15, 40, WHITE ) + DrawRectangleLines( 15, 40, aScarfy[ TEXTURE2D_WIDTH ], aScarfy[ TEXTURE2D_HEIGHT ], LIME ) + DrawRectangleLines( 15 + Int( aFrameRec[ RECTANGLE_X ] ), 40 + Int( aFrameRec[ RECTANGLE_Y ] ), Int( aFrameRec[ RECTANGLE_WIDTH ] ), Int( aFrameRec[ RECTANGLE_HEIGHT ] ), RED ) + + DrawText( "FRAME SPEED: ", 165, 210, 10, DARKGRAY ) + DrawText( TextFormat( "%02i FPS", nFramesSpeed ), 575, 210, 10, DARKGRAY ) + DrawText( "PRESS RIGHT/LEFT KEYS to CHANGE SPEED!", 290, 240, 10, DARKGRAY ) + + FOR i := 0 TO MAX_FRAME_SPEED - 1 + + IF i < nFramesSpeed + DrawRectangle( 250 + 21 * i, 205, 20, 20, RED ) + ENDIF + + DrawRectangleLines( 250 + 21 * i, 205, 20, 20, MAROON ) + + NEXT + + DrawTextureRec( aScarfy, aFrameRec, aPosition, WHITE ) + + DrawText( "(c) Scarfy sprite by Eiden Marsal", nScreenWidth - 200, nScreenHeight - 20, 10, GRAY ) + + EndDrawing() + + ENDDO + + UnloadTexture( aScarfy ) + + CloseWindow() + + RETURN diff --git a/examples/harbour/textures/textures_sprite_explosion.prg b/examples/harbour/textures/textures_sprite_explosion.prg new file mode 100644 index 0000000..62a6edd --- /dev/null +++ b/examples/harbour/textures/textures_sprite_explosion.prg @@ -0,0 +1,104 @@ +#include "hbraylib.ch" + +#define NUM_FRAMES_PER_LINE 5 +#define NUM_LINES 5 + +#define TEXTURE2D_WIDTH 2 +#define TEXTURE2D_HEIGHT 3 + +#define VECTOR2_X 1 +#define VECTOR2_Y 2 + +#define RECTANGLE_X 1 +#define RECTANGLE_Y 2 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aFxBoom + LOCAL aExplosion + LOCAL nFrameWidth + LOCAL nFrameHeight + LOCAL nCurrentFrame := 0 + LOCAL nCurrentLine := 0 + LOCAL aFrameRec + LOCAL aPosition := { 0.0, 0.0 } + LOCAL lActive := .F. + LOCAL nFramesCounter := 0 + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [textures] example - sprite explosion" ) + + InitAudioDevice() + + aFxBoom := LoadSound( "resources/boom.wav" ) + + aExplosion := LoadTexture( "resources/explosion.png" ) + + nFrameWidth := aExplosion[ TEXTURE2D_WIDTH ] / NUM_FRAMES_PER_LINE + nFrameHeight := aExplosion[ TEXTURE2D_HEIGHT ] / NUM_LINES + + aFrameRec := { 0, 0, nFrameWidth, nFrameHeight } + + SetTargetFPS( 120 ) + + DO WHILE ! WindowShouldClose() + + IF IsMouseButtonPressed( MOUSE_LEFT_BUTTON ) .AND. ! lActive + + aPosition := GetMousePosition() + lActive := .T. + + aPosition[ VECTOR2_X ] -= nFrameWidth / 2 + aPosition[ VECTOR2_Y ] -= nFrameHeight / 2 + + PlaySound( aFxBoom ) + + ENDIF + + IF ( lActive ) + + nFramesCounter++ + + IF nFramesCounter > 2 + + nCurrentFrame++ + + IF nCurrentFrame >= NUM_FRAMES_PER_LINE + + nCurrentFrame = 0 + nCurrentLine++ + + IF nCurrentLine >= NUM_LINES + nCurrentLine := 0 + lActive := .F. + ENDIF + ENDIF + + nFramesCounter = 0 + ENDIF + ENDIF + + aFrameRec[ RECTANGLE_X ] := nFrameWidth * nCurrentFrame + aFrameRec[ RECTANGLE_Y ] := nFrameHeight * nCurrentLine + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + IF lActive + DrawTextureRec( aExplosion, aFrameRec, aPosition, WHITE ) + ENDIF + + EndDrawing() + + ENDDO + + UnloadTexture( aExplosion ) + UnloadSound( aFxBoom ) + + CloseAudioDevice() + + CloseWindow() + + RETURN diff --git a/examples/harbour/textures/textures_srcrec_dstrec.prg b/examples/harbour/textures/textures_srcrec_dstrec.prg new file mode 100644 index 0000000..c73a011 --- /dev/null +++ b/examples/harbour/textures/textures_srcrec_dstrec.prg @@ -0,0 +1,60 @@ +#include "hbraylib.ch" + +#define TEXTURE2D_WIDTH 2 +#define TEXTURE2D_HEIGHT 3 + +#define VECTOR2_X 1 +#define VECTOR2_Y 2 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + + LOCAL aScarfy + + LOCAL aFrameWidth + LOCAL aFrameHeight + + LOCAL aOrigin + LOCAL aSourceRec + LOCAL aDestRec + LOCAL nRotation := 0 + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [textures] examples - texture source and destination rectangles" ) + + aScarfy := LoadTexture( "resources/Scarfy.png" ) + + aFrameWidth := aScarfy[ TEXTURE2D_WIDTH ] / 6 + aFrameHeight := aScarfy[ TEXTURE2D_HEIGHT ] + + aSourceRec := { 0.0, 0.0, aFrameWidth, aFrameHeight } + aDestRec := { nScreenWidth / 2, nScreenHeight / 2, aFrameWidth * 2, aFrameHeight * 2 } + aOrigin := { aFrameWidth, aFrameHeight } + + SetTargetFPS( 60 ) + + DO WHILE ! WindowShouldClose() + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + nRotation++ + + DrawTexturePro( aScarfy, aSourceRec, aDestRec, aOrigin, nRotation, WHITE ) + + DrawLine( Int( aDestRec[ VECTOR2_X ] ), 0, Int( aDestRec[ VECTOR2_X ] ), nScreenHeight, GRAY ) + DrawLine( 0, Int( aDestRec[ VECTOR2_Y ] ), nScreenWidth, Int( aDestRec[ VECTOR2_Y ] ), GRAY ) + + DrawText( "(c) Scarfy sprite by Eiden Marsal", nScreenWidth - 200, nScreenHeight - 20, 10, GRAY ) + + EndDrawing() + + ENDDO + + UnloadTexture( aScarfy ) + + CloseWindow() + + RETURN diff --git a/examples/harbour/textures/textures_to_image.prg b/examples/harbour/textures/textures_to_image.prg new file mode 100644 index 0000000..dffe3ab --- /dev/null +++ b/examples/harbour/textures/textures_to_image.prg @@ -0,0 +1,43 @@ +#include "hbraylib.ch" + +#define TEXTURE2D_WIDTH 2 +#define TEXTURE2D_HEIGHT 3 + +PROCEDURE Main() + + LOCAL nScreenWidth := 800 + LOCAL nScreenHeight := 450 + LOCAL aImage + LOCAL aTexture + + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [textures] example - texture to image" ) + + aImage := LoadImage( "resources/raylib_logo.png" ) + aTexture := LoadTextureFromImage( aImage ) + UnloadImage( aImage ) + + aImage := GetTextureData( aTexture ) + UnloadTexture( aTexture ) + + aTexture := LoadTextureFromImage( aImage ) + UnloadImage( aImage ) + + DO WHILE ! WindowShouldClose() + + BeginDrawing() + + ClearBackground( RAYWHITE ) + + DrawTexture( aTexture, Int( nScreenWidth / 2 - aTexture[ TEXTURE2D_WIDTH ] / 2 ), Int( nScreenHeight / 2 - aTexture[ TEXTURE2D_HEIGHT ] / 2 ), WHITE ) + + DrawText( "this IS a texture loaded from an image!", 300, 370, 10, GRAY ) + + EndDrawing() + + ENDDO + + UnloadTexture( aTexture ) + + CloseWindow() + + RETURN diff --git a/examples/harbour/tutorial/tutorial_01.prg b/examples/harbour/tutorial/tutorial_01.prg index 45f521c..8bd078e 100644 --- a/examples/harbour/tutorial/tutorial_01.prg +++ b/examples/harbour/tutorial/tutorial_01.prg @@ -1,4 +1,3 @@ - #include "hbraylib.ch" PROCEDURE Main() diff --git a/examples/harbour/tutorial/tutorial_08.prg b/examples/harbour/tutorial/tutorial_08.prg index 2320313..247c3a7 100644 --- a/examples/harbour/tutorial/tutorial_08.prg +++ b/examples/harbour/tutorial/tutorial_08.prg @@ -1,41 +1,32 @@ - #include "hbraylib.ch" PROCEDURE Main() LOCAL nScreenWidth := 800 LOCAL nScreenHeight := 450 - LOCAL lContinue := .T. + LOCAL nKeyPressed + LOCAL nKey := 0 SetConfigFlags( FLAG_WINDOW_RESIZABLE + FLAG_VSYNC_HINT ) - InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [ tutorial_08 ] shapes" ) + InitWindow( nScreenWidth, nScreenHeight, "Harbour raylib [ tutorial_08 ] keycode" ) - SetTargetFPS( 60 ) + SetTargetFPS( 10 ) - DO WHILE lContinue + DO WHILE ! WindowShouldClose() BeginDrawing() ClearBackground( { 32, 32, 32, 255 } ) - IF WindowShouldClose() - lContinue := .F. //WindowShouldClose() - ENDIF - - DrawText( hb_ntos( GetKeyPressed() ), 190, 200, 20, LIGHTGRAY ) - -// GetKeyPressed() + nKeyPressed := GetKeyPressed() -// SWITCH nKey - -// CASE K_ESC -// lContinue := .F. -// EXIT - -// OTHERWISE + IF nKeyPressed != 0 + nKey := nKeyPressed + ENDIF -// ENDSWITCH + DrawText( hb_ntos( nKey ), 310, 200, 20, LIGHTGRAY ) + DrawText( "Get key pressed keycode", 30, 200, 20, LIGHTGRAY ) EndDrawing() diff --git a/include/hbraygui.ch b/include/hbraygui.ch new file mode 100644 index 0000000..778954c --- /dev/null +++ b/include/hbraygui.ch @@ -0,0 +1,122 @@ + +#ifndef HBRAYGUI_CH_ +#define HBRAYGUI_CH_ + +// Gui control state +#define GUI_STATE_NORMAL 0 +#define GUI_STATE_FOCUSED 1 +#define GUI_STATE_PRESSED 2 +#define GUI_STATE_DISABLED 3 + +// Gui control text alignment +#define GUI_TEXT_ALIGN_LEFT 0 +#define GUI_TEXT_ALIGN_CENTER 1 +#define GUI_TEXT_ALIGN_RIGHT 2 + +// Gui controls +#define DEFAULT 0 +#define LABEL 1 // LABELBUTTON +#define BUTTON 2 // IMAGEBUTTON +#define TOGGLE 3 // TOGGLEGROUP +#define SLIDER 4 // SLIDERBAR +#define PROGRESSBAR 5 +#define CHECKBOX 6 +#define COMBOBOX 7 +#define DROPDOWNBOX 8 +#define TEXTBOX 9 // TEXTBOXMULTI +#define VALUEBOX 10 +#define SPINNER 11 +#define LISTVIEW 12 +#define COLORPICKER 13 +#define SCROLLBAR 14 +#define STATUSBAR 15 + +// Gui base properties for every control +#define BORDER_COLOR_NORMAL 0 +#define BASE_COLOR_NORMAL 1 +#define TEXT_COLOR_NORMAL 2 +#define BORDER_COLOR_FOCUSED 3 +#define BASE_COLOR_FOCUSED 4 +#define TEXT_COLOR_FOCUSED 5 +#define BORDER_COLOR_PRESSED 6 +#define BASE_COLOR_PRESSED 7 +#define TEXT_COLOR_PRESSED 8 +#define BORDER_COLOR_DISABLED 9 +#define BASE_COLOR_DISABLED 10 +#define TEXT_COLOR_DISABLED 11 +#define BORDER_WIDTH 12 +#define TEXT_PADDING 13 +#define TEXT_ALIGNMENT 14 +#define RESERVED 15 + +// Gui extended properties depend on control +// NOTE: We reserve a fixed size of additional properties per control + +// DEFAULT properties +#define TEXT_SIZE 16 +#define TEXT_SPACING 17 +#define LINE_COLOR 18 +#define BACKGROUND_COLOR 19 + +// Label +//typedef enum { } GuiLabelProperty; + +// Button +//typedef enum { } GuiButtonProperty; + +// Toggle / ToggleGroup +#define GROUP_PADDING 16 + +// Slider / SliderBar +#define SLIDER_WIDTH 16 +#define SLIDER_PADDING 17 + +// ProgressBar +#define PROGRESS_PADDING 16 + +// CheckBox +#define CHECK_PADDING 16 + +// ComboBox +#define COMBO_BUTTON_WIDTH 16 +#define COMBO_BUTTON_PADDING 17 + +// DropdownBox +#define ARROW_PADDING 16 +#define DROPDOWN_ITEMS_PADDING 17 + +// TextBox / TextBoxMulti / ValueBox / Spinner +#define TEXT_INNER_PADDING 16 +#define TEXT_LINES_PADDING 17 +#define COLOR_SELECTED_FG 18 +#define COLOR_SELECTED_BG 19 + +// Spinner +#define SPIN_BUTTON_WIDTH 16 +#define SPIN_BUTTON_PADDING 17 + +// ScrollBar +#define ARROWS_SIZE 16 +#define ARROWS_VISIBLE 17 +#define SCROLL_SLIDER_PADDING 18 +#define SCROLL_SLIDER_SIZE 19 +#define SCROLL_PADDING 20 +#define SCROLL_SPEED 21 + +// ScrollBar side +#define SCROLLBAR_LEFT_SIDE 0 +#define SCROLLBAR_RIGHT_SIDE 1 + +#define LIST_ITEMS_HEIGHT 16 +#define LIST_ITEMS_PADDING 17 +#define SCROLLBAR_WIDTH 18 +#define SCROLLBAR_SIDE 19 + +// ColorPicker +#define COLOR_SELECTOR_SIZE 16 +#define HUEBAR_WIDTH 17 // Right hue bar width +#define HUEBAR_PADDING 18 // Right hue bar separation from panel +#define HUEBAR_SELECTOR_HEIGHT 19 // Right hue bar selector height +#define HUEBAR_SELECTOR_OVERFLOW 20 // Right hue bar selector overflow + +#endif /* HBRAYGUI_CH_ */ \ No newline at end of file diff --git a/include/hbraylib.ch b/include/hbraylib.ch index f34232f..45b7d84 100644 --- a/include/hbraylib.ch +++ b/include/hbraylib.ch @@ -35,349 +35,377 @@ //---------------------------------------------------------------------------------- // Enumerators Definition //---------------------------------------------------------------------------------- -/* --- System config flags --- */ -/* --- NOTE: Used for bit masks --- */ -#define FLAG_RESERVED 1 // Reserved -#define FLAG_FULLSCREEN_MODE 2 // Set to run program in fullscreen -#define FLAG_WINDOW_RESIZABLE 4 // Set to allow resizable window -#define FLAG_WINDOW_UNDECORATED 8 // Set to disable window decoration (frame and buttons) -#define FLAG_WINDOW_TRANSPARENT 16 // Set to allow transparent window -#define FLAG_WINDOW_HIDDEN 128 // Set to create the window initially hidden -#define FLAG_WINDOW_ALWAYS_RUN 256 // Set to allow windows running while minimized -#define FLAG_MSAA_4X_HINT 32 // Set to try enabling MSAA 4X -#define FLAG_VSYNC_HINT 64 // Set to try enabling V-Sync on GPU - -/* --- Trace log type --- */ -#define LOG_ALL 0 // Display all logs -#define LOG_TRACE 1 -#define LOG_DEBUG 2 -#define LOG_INFO 3 -#define LOG_WARNING 4 -#define LOG_ERROR 5 -#define LOG_FATAL 6 -#define LOG_NONE 7 // Disable logging - -/* --- Keyboard keys --- */ -/* --- Alphanumeric keys --- */ -#define KEY_APOSTROPHE 39 -#define KEY_COMMA 44 -#define KEY_MINUS 45 -#define KEY_PERIOD 46 -#define KEY_SLASH 47 -#define KEY_ZERO 48 -#define KEY_ONE 49 -#define KEY_TWO 50 -#define KEY_THREE 51 -#define KEY_FOUR 52 -#define KEY_FIVE 53 -#define KEY_SIX 54 -#define KEY_SEVEN 55 -#define KEY_EIGHT 56 -#define KEY_NINE 57 -#define KEY_SEMICOLON 59 -#define KEY_EQUAL 61 -#define KEY_A 65 -#define KEY_B 66 -#define KEY_C 67 -#define KEY_D 68 -#define KEY_E 69 -#define KEY_F 70 -#define KEY_G 71 -#define KEY_H 72 -#define KEY_I 73 -#define KEY_J 74 -#define KEY_K 75 -#define KEY_L 76 -#define KEY_M 77 -#define KEY_N 78 -#define KEY_O 79 -#define KEY_P 80 -#define KEY_Q 81 -#define KEY_R 82 -#define KEY_S 83 -#define KEY_T 84 -#define KEY_U 85 -#define KEY_V 86 -#define KEY_W 87 -#define KEY_X 88 -#define KEY_Y 89 -#define KEY_Z 90 - -/* --- Function keys --- */ -#define KEY_SPACE 32 -#define KEY_ESCAPE 256 -#define KEY_ENTER 257 -#define KEY_TAB 258 -#define KEY_BACKSPACE 259 -#define KEY_INSERT 260 -#define KEY_DELETE 261 -#define KEY_RIGHT 262 -#define KEY_LEFT 263 -#define KEY_DOWN 264 -#define KEY_UP 265 -#define KEY_PAGE_UP 266 -#define KEY_PAGE_DOWN 267 -#define KEY_HOME 268 -#define KEY_END 269 -#define KEY_CAPS_LOCK 280 -#define KEY_SCROLL_LOCK 281 -#define KEY_NUM_LOCK 282 -#define KEY_PRINT_SCREEN 283 -#define KEY_PAUSE 284 -#define KEY_F1 290 -#define KEY_F2 291 -#define KEY_F3 292 -#define KEY_F4 293 -#define KEY_F5 294 -#define KEY_F6 295 -#define KEY_F7 296 -#define KEY_F8 297 -#define KEY_F9 298 -#define KEY_F10 299 -#define KEY_F11 300 -#define KEY_F12 301 -#define KEY_LEFT_SHIFT 340 -#define KEY_LEFT_CONTROL 341 -#define KEY_LEFT_ALT 342 -#define KEY_LEFT_SUPER 343 -#define KEY_RIGHT_SHIFT 344 -#define KEY_RIGHT_CONTROL 345 -#define KEY_RIGHT_ALT 346 -#define KEY_RIGHT_SUPER 347 -#define KEY_KB_MENU 348 -#define KEY_LEFT_BRACKET 91 -#define KEY_BACKSLASH 92 -#define KEY_RIGHT_BRACKET 93 -#define KEY_GRAVE 96 - -/* --- Keypad keys --- */ -#define KEY_KP_0 320 -#define KEY_KP_1 321 -#define KEY_KP_2 322 -#define KEY_KP_3 323 -#define KEY_KP_4 324 -#define KEY_KP_5 325 -#define KEY_KP_6 326 -#define KEY_KP_7 327 -#define KEY_KP_8 328 -#define KEY_KP_9 329 -#define KEY_KP_DECIMAL 330 -#define KEY_KP_DIVIDE 331 -#define KEY_KP_MULTIPLY 332 -#define KEY_KP_SUBTRACT 333 -#define KEY_KP_ADD 334 -#define KEY_KP_ENTER 335 -#define KEY_KP_EQUAL 336 - -/* --- Android buttons --- */ -#define KEY_BACK 4 -#define KEY_MENU 82 -#define KEY_VOLUME_UP 24 -#define KEY_VOLUME_DOWN 25 - -/* --- Mouse buttons --- */ -#define MOUSE_LEFT_BUTTON 0 -#define MOUSE_RIGHT_BUTTON 1 -#define MOUSE_MIDDLE_BUTTON 2 - -/* --- Gamepad number --- */ -#define GAMEPAD_PLAYER1 0 -#define GAMEPAD_PLAYER2 1 -#define GAMEPAD_PLAYER3 2 -#define GAMEPAD_PLAYER4 3 - -/* --- Gamepad Buttons --- */ -/* --- This is here just for error checking -#define GAMEPAD_BUTTON_UNKNOWN 0 - -/* --- This is normally a DPAD --- */ -#define GAMEPAD_BUTTON_LEFT_FACE_UP 1 -#define GAMEPAD_BUTTON_LEFT_FACE_RIGHT 2 -#define GAMEPAD_BUTTON_LEFT_FACE_DOWN 3 -#define GAMEPAD_BUTTON_LEFT_FACE_LEFT 5 - -/* --- This normally corresponds with PlayStation and Xbox controllers --- */ -/* --- XBOX: [YXAB] --- */ -/* --- PS3: [TriangleSquareCrossCircle] --- */ -/* --- No support for 6 button controllers though.. --- */ -#define GAMEPAD_BUTTON_RIGHT_FACE_UP 6 -#define GAMEPAD_BUTTON_RIGHT_FACE_RIGHT 7 -#define GAMEPAD_BUTTON_RIGHT_FACE_DOWN 8 -#define GAMEPAD_BUTTON_RIGHT_FACE_LEFT 9 - -/* --- Triggers --- */ -#define GAMEPAD_BUTTON_LEFT_TRIGGER_1 10 -#define GAMEPAD_BUTTON_LEFT_TRIGGER_2 11 -#define GAMEPAD_BUTTON_RIGHT_TRIGGER_1 12 -#define GAMEPAD_BUTTON_RIGHT_TRIGGER_2 13 - -/* --- These are buttons in the center of the gamepad --- */ -#define GAMEPAD_BUTTON_MIDDLE_LEFT 14 //PS3 Select -#define GAMEPAD_BUTTON_MIDDLE 15 //PS Button/XBOX Button -#define GAMEPAD_BUTTON_MIDDLE_RIGHT 16 //PS3 Start - -/* --- These are the joystick press in buttons --- */ -#define GAMEPAD_BUTTON_LEFT_THUMB 17 -#define GAMEPAD_BUTTON_RIGHT_THUMB 18 - -/* --- This is here just for error checking --- */ -#define GAMEPAD_AXIS_UNKNOWN 1 - -/* --- Left stick --- */ -#define GAMEPAD_AXIS_LEFT_X 2 -#define GAMEPAD_AXIS_LEFT_Y 3 - -/* --- Right stick --- */ -#define GAMEPAD_AXIS_RIGHT_X 4 -#define GAMEPAD_AXIS_RIGHT_Y 5 - -/* --- Pressure levels for the back triggers --- */ -#define GAMEPAD_AXIS_LEFT_TRIGGER 6 // [1..-1] (pressure-level) -#define GAMEPAD_AXIS_RIGHT_TRIGGER 7 // [1..-1] (pressure-level) - -/* --- Shader location point type --- */ -#define LOC_VERTEX_POSITION 0 -#define LOC_VERTEX_TEXCOORD01 1 -#define LOC_VERTEX_TEXCOORD02 2 -#define LOC_VERTEX_NORMAL 3 -#define LOC_VERTEX_TANGENT 4 -#define LOC_VERTEX_COLOR 5 -#define LOC_MATRIX_MVP 6 -#define LOC_MATRIX_MODEL 7 -#define LOC_MATRIX_VIEW 8 -#define LOC_MATRIX_PROJECTION 9 -#define LOC_VECTOR_VIEW 10 -#define LOC_COLOR_DIFFUSE 11 -#define LOC_COLOR_SPECULAR 12 -#define LOC_COLOR_AMBIENT 13 -#define LOC_MAP_ALBEDO 14 // LOC_MAP_DIFFUSE -#define LOC_MAP_METALNESS 15 // LOC_MAP_SPECULAR -#define LOC_MAP_NORMAL 16 -#define LOC_MAP_ROUGHNESS 17 -#define LOC_MAP_OCCLUSION 18 -#define LOC_MAP_EMISSION 19 -#define LOC_MAP_HEIGHT 20 -#define LOC_MAP_CUBEMAP 21 -#define LOC_MAP_IRRADIANCE 22 -#define LOC_MAP_PREFILTER 23 -#define LOC_MAP_BRDF 24 - -#define LOC_MAP_DIFFUSE LOC_MAP_ALBEDO -#define LOC_MAP_SPECULAR LOC_MAP_METALNESS - -/* --- Shader uniform data types --- */ -#define UNIFORM_FLOAT 0 -#define UNIFORM_VEC2 1 -#define UNIFORM_VEC3 2 -#define UNIFORM_VEC4 3 -#define UNIFORM_INT 4 -#define UNIFORM_IVEC2 5 -#define UNIFORM_IVEC3 6 -#define UNIFORM_IVEC4 7 -#define UNIFORM_SAMPLER2D 8 - -/* --- Material map type --- */ -#define MAP_ALBEDO 0 // MAP_DIFFUSE -#define MAP_METALNESS 1 // MAP_SPECULAR -#define MAP_NORMAL 2 -#define MAP_ROUGHNESS 3 -#define MAP_OCCLUSION 4 -#define MAP_EMISSION 5 -#define MAP_HEIGHT 6 -#define MAP_CUBEMAP 7 // NOTE: Uses GL_TEXTURE_CUBE_MAP -#define MAP_IRRADIANCE 8 // NOTE: Uses GL_TEXTURE_CUBE_MAP -#define MAP_PREFILTER 9 // NOTE: Uses GL_TEXTURE_CUBE_MAP -#define MAP_BRDF 10 - -#define MAP_DIFFUSE MAP_ALBEDO -#define MAP_SPECULAR MAP_METALNESS - -/* --- Pixel formats --- */ -/* --- NOTE: Support depends on OpenGL version and platform --- */ -#define UNCOMPRESSED_GRAYSCALE 1 // 8 bit per pixel (no alpha) -#define UNCOMPRESSED_GRAY_ALPHA 2 // 8*2 bpp (2 channels) -#define UNCOMPRESSED_R5G6B5 3 // 16 bpp -#define UNCOMPRESSED_R8G8B8 4 // 24 bpp -#define UNCOMPRESSED_R5G5B5A1 5 // 16 bpp (1 bit alpha) -#define UNCOMPRESSED_R4G4B4A4 6 // 16 bpp (4 bit alpha) -#define UNCOMPRESSED_R8G8B8A8 7 // 32 bpp -#define UNCOMPRESSED_R32 8 // 32 bpp (1 channel - float) -#define UNCOMPRESSED_R32G32B32 9 // 32*3 bpp (3 channels - float) -#define UNCOMPRESSED_R32G32B32A32 10 // 32*4 bpp (4 channels - float) -#define COMPRESSED_DXT1_RGB 11 // 4 bpp (no alpha) -#define COMPRESSED_DXT1_RGBA 12 // 4 bpp (1 bit alpha) -#define COMPRESSED_DXT3_RGBA 13 // 8 bpp -#define COMPRESSED_DXT5_RGBA 14 // 8 bpp -#define COMPRESSED_ETC1_RGB 15 // 4 bpp -#define COMPRESSED_ETC2_RGB 16 // 4 bpp -#define COMPRESSED_ETC2_EAC_RGBA 17 // 8 bpp -#define COMPRESSED_PVRT_RGB 18 // 4 bpp -#define COMPRESSED_PVRT_RGBA 19 // 4 bpp -#define COMPRESSED_ASTC_4x4_RGBA 20 // 8 bpp -#define COMPRESSED_ASTC_8x8_RGBA 21 // 2 bpp - -/* --- Texture parameters: filter mode --- */ -/* --- NOTE 1: Filtering considers mipmaps if available in the texture --- */ -/* --- NOTE 2: Filter is accordingly set for minification and magnification --- */ -#define FILTER_POINT 0 // No filter just pixel aproximation -#define FILTER_BILINEAR 1 // Linear filtering -#define FILTER_TRILINEAR 2 // Trilinear filtering (linear with mipmaps) -#define FILTER_ANISOTROPIC_4X 3 // Anisotropic filtering 4x -#define FILTER_ANISOTROPIC_8X 4 // Anisotropic filtering 8x -#define FILTER_ANISOTROPIC_16X 5 // Anisotropic filtering 16x - -/* --- Cubemap layout type --- */ -#define CUBEMAP_AUTO_DETECT 0 // Automatically detect layout type -#define CUBEMAP_LINE_VERTICAL 1 // Layout is defined by a vertical line with faces -#define CUBEMAP_LINE_HORIZONTAL 2 // Layout is defined by an horizontal line with faces -#define CUBEMAP_CROSS_THREE_BY_FOUR 3 // Layout is defined by a 3x4 cross with cubemap faces -#define CUBEMAP_CROSS_FOUR_BY_THREE 4 // Layout is defined by a 4x3 cross with cubemap faces -#define CUBEMAP_PANORAMA 5 // Layout is defined by a panorama image (equirectangular map) - -/* --- Texture parameters: wrap mode --- */ -#define WRAP_REPEAT 0 // Repeats texture in tiled mode -#define WRAP_CLAMP 1 // Clamps texture to edge pixel in tiled mode -#define WRAP_MIRROR_REPEAT 2 // Mirrors and repeats the texture in tiled mode -#define WRAP_MIRROR_CLAMP 3 // Mirrors and clamps to border the texture in tiled mode - -/* --- Font type defines generation method --- */ -#define FONT_DEFAULT 0 // Default font generation anti-aliased -#define FONT_BITMAP 1 // Bitmap font generation no anti-aliasing -#define FONT_SDF 2 // SDF font generation requires external shader - -/* --- Color blending modes (pre-defined) --- */ -#define BLEND_ALPHA 0 // Blend textures considering alpha (default) -#define BLEND_ADDITIVE 1 // Blend textures adding colors -#define BLEND_MULTIPLIED 2 // Blend textures multiplying colors - -/* --- Gestures type --- */ -/* --- NOTE: It could be used as flags to enable only some gestures --- */ -#define GESTURE_NONE 0 -#define GESTURE_TAP 1 -#define GESTURE_DOUBLETAP 2 -#define GESTURE_HOLD 4 -#define GESTURE_DRAG 8 -#define GESTURE_SWIPE_RIGHT 16 -#define GESTURE_SWIPE_LEFT 32 -#define GESTURE_SWIPE_UP 64 -#define GESTURE_SWIPE_DOWN 128 -#define GESTURE_PINCH_IN 256 -#define GESTURE_PINCH_OUT 512 - -/* --- Camera system modes --- */ -#define CAMERA_CUSTOM 0 -#define CAMERA_FREE 1 -#define CAMERA_ORBITAL 2 -#define CAMERA_FIRST_PERSON 3 -#define CAMERA_THIRD_PERSON 4 - -/* --- Camera projection modes --- */ -#define CAMERA_PERSPECTIVE 0 -#define CAMERA_ORTHOGRAPHIC 1 - -/* --- Type of n-patch --- */ -#define NPT_9PATCH 0 // Npatch defined by 3x3 tiles -#define NPT_3PATCH_VERTICAL 1 // Npatch defined by 1x3 tiles -#define NPT_3PATCH_HORIZONTAL 2 // Npatch defined by 3x1 tiles +// System/Window config flags +// NOTE: Every bit registers one state (use it with bit masks) +// By default all flags are set to 0 +#define FLAG_VSYNC_HINT 0x00000040 // Set to try enabling V-Sync on GPU +#define FLAG_FULLSCREEN_MODE 0x00000002 // Set to run program in fullscreen +#define FLAG_WINDOW_RESIZABLE 0x00000004 // Set to allow resizable window +#define FLAG_WINDOW_UNDECORATED 0x00000008 // Set to disable window decoration (frame and buttons) +#define FLAG_WINDOW_HIDDEN 0x00000080 // Set to hide window +#define FLAG_WINDOW_MINIMIZED 0x00000200 // Set to minimize window (iconify) +#define FLAG_WINDOW_MAXIMIZED 0x00000400 // Set to maximize window (expanded to monitor) +#define FLAG_WINDOW_UNFOCUSED 0x00000800 // Set to window non focused +#define FLAG_WINDOW_TOPMOST 0x00001000 // Set to window always on top +#define FLAG_WINDOW_ALWAYS_RUN 0x00000100 // Set to allow windows running while minimized +#define FLAG_WINDOW_TRANSPARENT 0x00000010 // Set to allow transparent framebuffer +#define FLAG_WINDOW_HIGHDPI 0x00002000 // Set to support HighDPI +#define FLAG_MSAA_4X_HINT 0x00000020 // Set to try enabling MSAA 4X +#define FLAG_INTERLACED_HINT 0x00010000 // Set to try enabling interlaced video format (for V3D) + +// Trace log type +#define LOG_ALL 0 // Display all logs +#define LOG_TRACE 1 +#define LOG_DEBUG 2 +#define LOG_INFO 3 +#define LOG_WARNING 4 +#define LOG_ERROR 5 +#define LOG_FATAL 6 +#define LOG_NONE 7 // Disable logging#define + +// Keyboard keys (US keyboard layout) +// NOTE: Use GetKeyPressed() to allow redefining +// required keys for alternative layouts + +// Alphanumeric keys +#define KEY_NULL 0 +#define KEY_APOSTROPHE 39 +#define KEY_COMMA 44 +#define KEY_MINUS 45 +#define KEY_PERIOD 46 +#define KEY_SLASH 47 +#define KEY_ZERO 48 +#define KEY_ONE 49 +#define KEY_TWO 50 +#define KEY_THREE 51 +#define KEY_FOUR 52 +#define KEY_FIVE 53 +#define KEY_SIX 54 +#define KEY_SEVEN 55 +#define KEY_EIGHT 56 +#define KEY_NINE 57 +#define KEY_SEMICOLON 59 +#define KEY_EQUAL 61 +#define KEY_A 65 +#define KEY_B 66 +#define KEY_C 67 +#define KEY_D 68 +#define KEY_E 69 +#define KEY_F 70 +#define KEY_G 71 +#define KEY_H 72 +#define KEY_I 73 +#define KEY_J 74 +#define KEY_K 75 +#define KEY_L 76 +#define KEY_M 77 +#define KEY_N 78 +#define KEY_O 79 +#define KEY_P 80 +#define KEY_Q 81 +#define KEY_R 82 +#define KEY_S 83 +#define KEY_T 84 +#define KEY_U 85 +#define KEY_V 86 +#define KEY_W 87 +#define KEY_X 88 +#define KEY_Y 89 +#define KEY_Z 90 + +// Function keys +#define KEY_SPACE 32 +#define KEY_ESCAPE 256 +#define KEY_ENTER 257 +#define KEY_TAB 258 +#define KEY_BACKSPACE 259 +#define KEY_INSERT 260 +#define KEY_DELETE 261 +#define KEY_RIGHT 262 +#define KEY_LEFT 263 +#define KEY_DOWN 264 +#define KEY_UP 265 +#define KEY_PAGE_UP 266 +#define KEY_PAGE_DOWN 267 +#define KEY_HOME 268 +#define KEY_END 269 +#define KEY_CAPS_LOCK 280 +#define KEY_SCROLL_LOCK 281 +#define KEY_NUM_LOCK 282 +#define KEY_PRINT_SCREEN 283 +#define KEY_PAUSE 284 +#define KEY_F1 290 +#define KEY_F2 291 +#define KEY_F3 292 +#define KEY_F4 293 +#define KEY_F5 294 +#define KEY_F6 295 +#define KEY_F7 296 +#define KEY_F8 297 +#define KEY_F9 298 +#define KEY_F10 299 +#define KEY_F11 300 +#define KEY_F12 301 +#define KEY_LEFT_SHIFT 340 +#define KEY_LEFT_CONTROL 341 +#define KEY_LEFT_ALT 342 +#define KEY_LEFT_SUPER 343 +#define KEY_RIGHT_SHIFT 344 +#define KEY_RIGHT_CONTROL 345 +#define KEY_RIGHT_ALT 346 +#define KEY_RIGHT_SUPER 347 +#define KEY_KB_MENU 348 +#define KEY_LEFT_BRACKET 91 +#define KEY_BACKSLASH 92 +#define KEY_RIGHT_BRACKET 93 +#define KEY_GRAVE 96 + +// Keypad keys +#define KEY_KP_0 320 +#define KEY_KP_1 321 +#define KEY_KP_2 322 +#define KEY_KP_3 323 +#define KEY_KP_4 324 +#define KEY_KP_5 325 +#define KEY_KP_6 326 +#define KEY_KP_7 327 +#define KEY_KP_8 328 +#define KEY_KP_9 329 +#define KEY_KP_DECIMAL 330 +#define KEY_KP_DIVIDE 331 +#define KEY_KP_MULTIPLY 332 +#define KEY_KP_SUBTRACT 333 +#define KEY_KP_ADD 334 +#define KEY_KP_ENTER 335 +#define KEY_KP_EQUAL 336 + +// Android buttons +#define KEY_BACK 4 +#define KEY_MENU 82 +#define KEY_VOLUME_UP 24 +#define KEY_VOLUME_DOWN 25 + +// Mouse buttons +#define MOUSE_LEFT_BUTTON 0 +#define MOUSE_RIGHT_BUTTON 1 +#define MOUSE_MIDDLE_BUTTON 2 + +// Mouse cursor types +#define MOUSE_CURSOR_DEFAULT 0 +#define MOUSE_CURSOR_ARROW 1 +#define MOUSE_CURSOR_IBEAM 2 +#define MOUSE_CURSOR_CROSSHAIR 3 +#define MOUSE_CURSOR_POINTING_HAND 4 +#define MOUSE_CURSOR_RESIZE_EW 5 // The horizontal resize/move arrow shape +#define MOUSE_CURSOR_RESIZE_NS 6 // The vertical resize/move arrow shape +#define MOUSE_CURSOR_RESIZE_NWSE 7 // The top-left to bottom-right diagonal resize/move arrow shape +#define MOUSE_CURSOR_RESIZE_NESW 8 // The top-right to bottom-left diagonal resize/move arrow shape +#define MOUSE_CURSOR_RESIZE_ALL 9 // The omni-directional resize/move cursor shape +#define MOUSE_CURSOR_NOT_ALLOWED 10 // The operation-not-allowed shape#define + +// Mouse buttons +#define MOUSE_BUTTON_LEFT 0 +#define MOUSE_BUTTON_RIGHT 1 +#define MOUSE_BUTTON_MIDDLE 2 +#define MOUSE_BUTTON_SIDE 3 +#define MOUSE_BUTTON_EXTRA 4 +#define MOUSE_BUTTON_FORWARD 5 +#define MOUSE_BUTTON_BACK 6 + +// Gamepad buttons +// This is here just for error checking +#define GAMEPAD_BUTTON_UNKNOWN 0 + +// This is normally a DPAD +#define GAMEPAD_BUTTON_LEFT_FACE_UP 1 +#define GAMEPAD_BUTTON_LEFT_FACE_RIGHT 2 +#define GAMEPAD_BUTTON_LEFT_FACE_DOWN 3 +#define GAMEPAD_BUTTON_LEFT_FACE_LEFT 4 + +// This normally corresponds with PlayStation and Xbox controllers +// XBOX: [YXAB] +// PS3: [TriangleSquareCrossCircle] +// No support for 6 button controllers though.. +#define GAMEPAD_BUTTON_RIGHT_FACE_UP 5 +#define GAMEPAD_BUTTON_RIGHT_FACE_RIGHT 6 +#define GAMEPAD_BUTTON_RIGHT_FACE_DOWN 7 +#define GAMEPAD_BUTTON_RIGHT_FACE_LEFT 8 + +// Triggers +#define GAMEPAD_BUTTON_LEFT_TRIGGER_1 9 +#define GAMEPAD_BUTTON_LEFT_TRIGGER_2 10 +#define GAMEPAD_BUTTON_RIGHT_TRIGGER_1 11 +#define GAMEPAD_BUTTON_RIGHT_TRIGGER_2 12 + +// These are buttons in the center of the gamepad +#define GAMEPAD_BUTTON_MIDDLE_LEFT 13 //PS3 Select +#define GAMEPAD_BUTTON_MIDDLE 14 //PS Button/XBOX Button +#define GAMEPAD_BUTTON_MIDDLE_RIGHT 15 //PS3 Start + +// These are the joystick press in buttons +#define GAMEPAD_BUTTON_LEFT_THUMB 16 +#define GAMEPAD_BUTTON_RIGHT_THUMB 17 + +// Gamepad axis +// Left stick +#define GAMEPAD_AXIS_LEFT_X 0 +#define GAMEPAD_AXIS_LEFT_Y 1 + +// Right stick +#define GAMEPAD_AXIS_RIGHT_X 2 +#define GAMEPAD_AXIS_RIGHT_Y 3 + +// Pressure levels for the back triggers +#define GAMEPAD_AXIS_LEFT_TRIGGER 4 // [1..-1] (pressure-level) +#define GAMEPAD_AXIS_RIGHT_TRIGGER 5 // [1..-1] (pressure-level) + +// Material map index +#define MATERIAL_MAP_ALBEDO 0 // MATERIAL_MAP_DIFFUSE +#define MATERIAL_MAP_METALNESS 1 // MATERIAL_MAP_SPECULAR +#define MATERIAL_MAP_NORMAL 2 +#define MATERIAL_MAP_ROUGHNESS 3 +#define MATERIAL_MAP_OCCLUSION 4 +#define MATERIAL_MAP_EMISSION 5 +#define MATERIAL_MAP_HEIGHT 6 +#define MATERIAL_MAP_BRDG 7 +#define MATERIAL_MAP_CUBEMAP 8 // NOTE: Uses GL_TEXTURE_CUBE_MAP +#define MATERIAL_MAP_IRRADIANCE 9 // NOTE: Uses GL_TEXTURE_CUBE_MAP +#define MATERIAL_MAP_PREFILTER 10 // NOTE: Uses GL_TEXTURE_CUBE_MAP + +#define MATERIAL_MAP_DIFFUSE MATERIAL_MAP_ALBEDO +#define MATERIAL_MAP_SPECULAR MATERIAL_MAP_METALNESS + +// Shader location index +#define SHADER_LOC_VERTEX_POSITION 0 +#define SHADER_LOC_VERTEX_TEXCOORD01 1 +#define SHADER_LOC_VERTEX_TEXCOORD02 2 +#define SHADER_LOC_VERTEX_NORMAL 3 +#define SHADER_LOC_VERTEX_TANGENT 4 +#define SHADER_LOC_VERTEX_COLOR 5 +#define SHADER_LOC_MATRIX_MVP 6 +#define SHADER_LOC_MATRIX_VIEW 7 +#define SHADER_LOC_MATRIX_PROJECTION 8 +#define SHADER_LOC_MATRIX_MODEL 9 +#define SHADER_LOC_MATRIX_NORMAL 10 +#define SHADER_LOC_VECTOR_VIEW 11 +#define SHADER_LOC_COLOR_DIFFUSE 12 +#define SHADER_LOC_COLOR_SPECULAR 13 +#define SHADER_LOC_COLOR_AMBIENT 14 +#define SHADER_LOC_MAP_ALBEDO 15 // SHADER_LOC_MAP_DIFFUSE +#define SHADER_LOC_MAP_METALNESS 16 // SHADER_LOC_MAP_SPECULAR +#define SHADER_LOC_MAP_NORMAL 17 +#define SHADER_LOC_MAP_ROUGHNESS 18 +#define SHADER_LOC_MAP_OCCLUSION 19 +#define SHADER_LOC_MAP_EMISSION 20 +#define SHADER_LOC_MAP_HEIGHT 21 +#define SHADER_LOC_MAP_CUBEMAP 22 +#define SHADER_LOC_MAP_IRRADIANCE 23 +#define SHADER_LOC_MAP_PREFILTER 24 +#define SHADER_LOC_MAP_BRDF 25 + +#define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO +#define SHADER_LOC_MAP_SPECULAR SHADER_LOC_MAP_METALNESS + +// Shader uniform data types +#define UNIFORM_FLOAT 0 +#define UNIFORM_VEC2 1 +#define UNIFORM_VEC3 2 +#define UNIFORM_VEC4 3 +#define UNIFORM_INT 4 +#define UNIFORM_IVEC2 5 +#define UNIFORM_IVEC3 6 +#define UNIFORM_IVEC4 7 +#define UNIFORM_SAMPLER2D 8 + +// Pixel formats +// NOTE: Support depends on OpenGL version and platform +#define PIXELFORMAT_UNCOMPRESSED_GRAYSCALE 1 // 8 bit per pixel (no alpha) +#define PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA 2 // 8*2 bpp (2 channels) +#define PIXELFORMAT_UNCOMPRESSED_R5G6B5 3 // 16 bpp +#define PIXELFORMAT_UNCOMPRESSED_R8G8B8 4 // 24 bpp +#define PIXELFORMAT_UNCOMPRESSED_R5G5B5A1 5 // 16 bpp (1 bit alpha) +#define PIXELFORMAT_UNCOMPRESSED_R4G4B4A4 6 // 16 bpp (4 bit alpha) +#define PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 7 // 32 bpp +#define PIXELFORMAT_UNCOMPRESSED_R32 8 // 32 bpp (1 channel - float) +#define PIXELFORMAT_UNCOMPRESSED_R32G32B32 9 // 32*3 bpp (3 channels - float) +#define PIXELFORMAT_UNCOMPRESSED_R32G32B32A32 10 // 32*4 bpp (4 channels - float) +#define PIXELFORMAT_COMPRESSED_DXT1_RGB 11 // 4 bpp (no alpha) +#define PIXELFORMAT_COMPRESSED_DXT1_RGBA 12 // 4 bpp (1 bit alpha) +#define PIXELFORMAT_COMPRESSED_DXT3_RGBA 13 // 8 bpp +#define PIXELFORMAT_COMPRESSED_DXT5_RGBA 14 // 8 bpp +#define PIXELFORMAT_COMPRESSED_ETC1_RGB 15 // 4 bpp +#define PIXELFORMAT_COMPRESSED_ETC2_RGB 16 // 4 bpp +#define PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA 17 // 8 bpp +#define PIXELFORMAT_COMPRESSED_PVRT_RGB 18 // 4 bpp +#define PIXELFORMAT_COMPRESSED_PVRT_RGBA 19 // 4 bpp +#define PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA 20 // 8 bpp +#define PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA 21 // 2 bpp + +// Texture parameters: filter mode +// NOTE 1: Filtering considers mipmaps if available in the texture +// NOTE 2: Filter is accordingly set for minification and magnification +#define TEXTURE_FILTER_POINT 0 // No filter, just pixel aproximation +#define TEXTURE_FILTER_BILINEAR 1 // Linear filtering +#define TEXTURE_FILTER_TRILINEAR 2 // Trilinear filtering (linear with mipmaps) +#define TEXTURE_FILTER_ANISOTROPIC_4X 3 // Anisotropic filtering 4x +#define TEXTURE_FILTER_ANISOTROPIC_8X 4 // Anisotropic filtering 8x +#define TEXTURE_FILTER_ANISOTROPIC_16X 5 // Anisotropic filtering 16x + +// Texture parameters: wrap mode +#define TEXTURE_WRAP_REPEAT 0 // Repeats texture in tiled mode +#define TEXTURE_WRAP_CLAMP 1 // Clamps texture to edge pixel in tiled mode +#define TEXTURE_WRAP_MIRROR_REPEAT 2 // Mirrors and repeats the texture in tiled mode +#define TEXTURE_WRAP_MIRROR_CLAMP 3 // Mirrors and clamps to border the texture in tiled mode + +// Cubemap layouts +#define CUBEMAP_LAYOUT_AUTO_DETECT 0 // Automatically detect layout type +#define CUBEMAP_LAYOUT_LINE_VERTICAL 1 // Layout is defined by a vertical line with faces +#define CUBEMAP_LAYOUT_LINE_HORIZONTAL 2 // Layout is defined by an horizontal line with faces +#define CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR 3 // Layout is defined by a 3x4 cross with cubemap faces +#define CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE 4 // Layout is defined by a 4x3 cross with cubemap faces +#define CUBEMAP_LAYOUT_PANORAMA 5 // Layout is defined by a panorama image (equirectangular map) + +// Font type defines generation method +#define FONT_DEFAULT 0 // Default font generation anti-aliased +#define FONT_BITMAP 1 // Bitmap font generation no anti-aliasing +#define FONT_SDF 2 // SDF font generation requires external shader + +// Color blending modes (pre-defined) +#define BLEND_ALPHA 0 // Blend textures considering alpha (default) +#define BLEND_ADDITIVE 1 // Blend textures adding colors +#define BLEND_MULTIPLIED 2 // Blend textures multiplying colors +#define BLEND_ADD_COLORS 3 // Blend textures adding colors (alternative) +#define BLEND_SUBTRACT_COLORS 4 // Blend textures subtracting colors (alternative) +#define BLEND_CUSTOM 5 // Belnd textures using custom src/dst factors (use SetBlendModeCustom()) + +// Gestures type +// NOTE: It could be used as flags to enable only some gestures +#define GESTURE_NONE 0 +#define GESTURE_TAP 1 +#define GESTURE_DOUBLETAP 2 +#define GESTURE_HOLD 4 +#define GESTURE_DRAG 8 +#define GESTURE_SWIPE_RIGHT 16 +#define GESTURE_SWIPE_LEFT 32 +#define GESTURE_SWIPE_UP 64 +#define GESTURE_SWIPE_DOWN 128 +#define GESTURE_PINCH_IN 256 +#define GESTURE_PINCH_OUT 512 + +// Camera system modes +#define CAMERA_CUSTOM 0 +#define CAMERA_FREE 1 +#define CAMERA_ORBITAL 2 +#define CAMERA_FIRST_PERSON 3 +#define CAMERA_THIRD_PERSON 4 + +// Camera projection modes +#define CAMERA_PERSPECTIVE 0 +#define CAMERA_ORTHOGRAPHIC 1 + +// N-patch layout +#define NPATCH_NINE_PATCH 0 // Npatch layout: 3x3 tiles +#define NPATCH_THREE_PATCH_VERTICAL 1 // Npatch layout: 1x3 tiles +#define NPATCH_THREE_PATCH_HORIZONTAL 2 // Npatch layout: 3x1 tiles #endif /* HBRAYLIB_CH_ */ diff --git a/include/hbraylib.h b/include/hbraylib.h index 7f1054c..f5f2058 100644 --- a/include/hbraylib.h +++ b/include/hbraylib.h @@ -7,11 +7,14 @@ #include "hbapiitm.h" #include "hbstack.h" +#define RAYGUI_IMPLEMENTATION +#define RAYGUI_SUPPORT_ICONS + #include HB_EXTERN_BEGIN -extern HB_EXPORT Image* hb_raylib_param( int iParam ); +extern HB_EXPORT Image* hb_image_param( int iParam ); HB_EXTERN_END diff --git a/include/ricons.h b/include/ricons.h new file mode 100644 index 0000000..6befa36 --- /dev/null +++ b/include/ricons.h @@ -0,0 +1,556 @@ +/********************************************************************************************** +* +* rIcons - Icons pack intended for tools development with raygui +* +* LICENSE: zlib/libpng +* +* Copyright (c) 2019-2020 Ramon Santamaria (@raysan5) +* +**********************************************************************************************/ + +#ifndef RICONS_H +#define RICONS_H + +//---------------------------------------------------------------------------------- +// Defines and Macros +//---------------------------------------------------------------------------------- +#define RICON_MAX_ICONS 256 // Maximum number of icons +#define RICON_SIZE 16 // Size of icons (squared) + +#define RICON_MAX_NAME_LENGTH 32 // Maximum length of icon name id + +// Icons data is defined by bit array (every bit represents one pixel) +// Those arrays are stored as unsigned int data arrays, so every array +// element defines 32 pixels (bits) of information +// Number of elemens depend on RICON_SIZE (by default 16x16 pixels) +#define RICON_DATA_ELEMENTS (RICON_SIZE*RICON_SIZE/32) + +//---------------------------------------------------------------------------------- +// Icons enumeration +//---------------------------------------------------------------------------------- +typedef enum { + RICON_NONE = 0, + RICON_FOLDER_FILE_OPEN = 1, + RICON_FILE_SAVE_CLASSIC = 2, + RICON_FOLDER_OPEN = 3, + RICON_FOLDER_SAVE = 4, + RICON_FILE_OPEN = 5, + RICON_FILE_SAVE = 6, + RICON_FILE_EXPORT = 7, + RICON_FILE_NEW = 8, + RICON_FILE_DELETE = 9, + RICON_FILETYPE_TEXT = 10, + RICON_FILETYPE_AUDIO = 11, + RICON_FILETYPE_IMAGE = 12, + RICON_FILETYPE_PLAY = 13, + RICON_FILETYPE_VIDEO = 14, + RICON_FILETYPE_INFO = 15, + RICON_FILE_COPY = 16, + RICON_FILE_CUT = 17, + RICON_FILE_PASTE = 18, + RICON_CURSOR_HAND = 19, + RICON_CURSOR_POINTER = 20, + RICON_CURSOR_CLASSIC = 21, + RICON_PENCIL = 22, + RICON_PENCIL_BIG = 23, + RICON_BRUSH_CLASSIC = 24, + RICON_BRUSH_PAINTER = 25, + RICON_WATER_DROP = 26, + RICON_COLOR_PICKER = 27, + RICON_RUBBER = 28, + RICON_COLOR_BUCKET = 29, + RICON_TEXT_T = 30, + RICON_TEXT_A = 31, + RICON_SCALE = 32, + RICON_RESIZE = 33, + RICON_FILTER_POINT = 34, + RICON_FILTER_BILINEAR = 35, + RICON_CROP = 36, + RICON_CROP_ALPHA = 37, + RICON_SQUARE_TOGGLE = 38, + RICON_SYMMETRY = 39, + RICON_SYMMETRY_HORIZONTAL = 40, + RICON_SYMMETRY_VERTICAL = 41, + RICON_LENS = 42, + RICON_LENS_BIG = 43, + RICON_EYE_ON = 44, + RICON_EYE_OFF = 45, + RICON_FILTER_TOP = 46, + RICON_FILTER = 47, + RICON_TARGET_POINT = 48, + RICON_TARGET_SMALL = 49, + RICON_TARGET_BIG = 50, + RICON_TARGET_MOVE = 51, + RICON_CURSOR_MOVE = 52, + RICON_CURSOR_SCALE = 53, + RICON_CURSOR_SCALE_RIGHT = 54, + RICON_CURSOR_SCALE_LEFT = 55, + RICON_UNDO = 56, + RICON_REDO = 57, + RICON_REREDO = 58, + RICON_MUTATE = 59, + RICON_ROTATE = 60, + RICON_REPEAT = 61, + RICON_SHUFFLE = 62, + RICON_EMPTYBOX = 63, + RICON_TARGET = 64, + RICON_TARGET_SMALL_FILL = 65, + RICON_TARGET_BIG_FILL = 66, + RICON_TARGET_MOVE_FILL = 67, + RICON_CURSOR_MOVE_FILL = 68, + RICON_CURSOR_SCALE_FILL = 69, + RICON_CURSOR_SCALE_RIGHT_FILL = 70, + RICON_CURSOR_SCALE_LEFT_FILL = 71, + RICON_UNDO_FILL = 72, + RICON_REDO_FILL = 73, + RICON_REREDO_FILL = 74, + RICON_MUTATE_FILL = 75, + RICON_ROTATE_FILL = 76, + RICON_REPEAT_FILL = 77, + RICON_SHUFFLE_FILL = 78, + RICON_EMPTYBOX_SMALL = 79, + RICON_BOX = 80, + RICON_BOX_TOP = 81, + RICON_BOX_TOP_RIGHT = 82, + RICON_BOX_RIGHT = 83, + RICON_BOX_BOTTOM_RIGHT = 84, + RICON_BOX_BOTTOM = 85, + RICON_BOX_BOTTOM_LEFT = 86, + RICON_BOX_LEFT = 87, + RICON_BOX_TOP_LEFT = 88, + RICON_BOX_CENTER = 89, + RICON_BOX_CIRCLE_MASK = 90, + RICON_POT = 91, + RICON_ALPHA_MULTIPLY = 92, + RICON_ALPHA_CLEAR = 93, + RICON_DITHERING = 94, + RICON_MIPMAPS = 95, + RICON_BOX_GRID = 96, + RICON_GRID = 97, + RICON_BOX_CORNERS_SMALL = 98, + RICON_BOX_CORNERS_BIG = 99, + RICON_FOUR_BOXES = 100, + RICON_GRID_FILL = 101, + RICON_BOX_MULTISIZE = 102, + RICON_ZOOM_SMALL = 103, + RICON_ZOOM_MEDIUM = 104, + RICON_ZOOM_BIG = 105, + RICON_ZOOM_ALL = 106, + RICON_ZOOM_CENTER = 107, + RICON_BOX_DOTS_SMALL = 108, + RICON_BOX_DOTS_BIG = 109, + RICON_BOX_CONCENTRIC = 110, + RICON_BOX_GRID_BIG = 111, + RICON_OK_TICK = 112, + RICON_CROSS = 113, + RICON_ARROW_LEFT = 114, + RICON_ARROW_RIGHT = 115, + RICON_ARROW_BOTTOM = 116, + RICON_ARROW_TOP = 117, + RICON_ARROW_LEFT_FILL = 118, + RICON_ARROW_RIGHT_FILL = 119, + RICON_ARROW_BOTTOM_FILL = 120, + RICON_ARROW_TOP_FILL = 121, + RICON_AUDIO = 122, + RICON_FX = 123, + RICON_WAVE = 124, + RICON_WAVE_SINUS = 125, + RICON_WAVE_SQUARE = 126, + RICON_WAVE_TRIANGULAR = 127, + RICON_CROSS_SMALL = 128, + RICON_PLAYER_PREVIOUS = 129, + RICON_PLAYER_PLAY_BACK = 130, + RICON_PLAYER_PLAY = 131, + RICON_PLAYER_PAUSE = 132, + RICON_PLAYER_STOP = 133, + RICON_PLAYER_NEXT = 134, + RICON_PLAYER_RECORD = 135, + RICON_MAGNET = 136, + RICON_LOCK_CLOSE = 137, + RICON_LOCK_OPEN = 138, + RICON_CLOCK = 139, + RICON_TOOLS = 140, + RICON_GEAR = 141, + RICON_GEAR_BIG = 142, + RICON_BIN = 143, + RICON_HAND_POINTER = 144, + RICON_LASER = 145, + RICON_COIN = 146, + RICON_EXPLOSION = 147, + RICON_1UP = 148, + RICON_PLAYER = 149, + RICON_PLAYER_JUMP = 150, + RICON_KEY = 151, + RICON_DEMON = 152, + RICON_TEXT_POPUP = 153, + RICON_GEAR_EX = 154, + RICON_CRACK = 155, + RICON_CRACK_POINTS = 156, + RICON_STAR = 157, + RICON_DOOR = 158, + RICON_EXIT = 159, + RICON_MODE_2D = 160, + RICON_MODE_3D = 161, + RICON_CUBE = 162, + RICON_CUBE_FACE_TOP = 163, + RICON_CUBE_FACE_LEFT = 164, + RICON_CUBE_FACE_FRONT = 165, + RICON_CUBE_FACE_BOTTOM = 166, + RICON_CUBE_FACE_RIGHT = 167, + RICON_CUBE_FACE_BACK = 168, + RICON_CAMERA = 169, + RICON_SPECIAL = 170, + RICON_LINK_NET = 171, + RICON_LINK_BOXES = 172, + RICON_LINK_MULTI = 173, + RICON_LINK = 174, + RICON_LINK_BROKE = 175, + RICON_TEXT_NOTES = 176, + RICON_NOTEBOOK = 177, + RICON_SUITCASE = 178, + RICON_SUITCASE_ZIP = 179, + RICON_MAILBOX = 180, + RICON_MONITOR = 181, + RICON_PRINTER = 182, + RICON_PHOTO_CAMERA = 183, + RICON_PHOTO_CAMERA_FLASH = 184, + RICON_HOUSE = 185, + RICON_HEART = 186, + RICON_CORNER = 187, + RICON_VERTICAL_BARS = 188, + RICON_VERTICAL_BARS_FILL = 189, + RICON_LIFE_BARS = 190, + RICON_INFO = 191, + RICON_CROSSLINE = 192, + RICON_HELP = 193, + RICON_FILETYPE_ALPHA = 194, + RICON_FILETYPE_HOME = 195, + RICON_LAYERS_VISIBLE = 196, + RICON_LAYERS = 197, + RICON_WINDOW = 198, + RICON_HIDPI = 199, + RICON_200 = 200, + RICON_201 = 201, + RICON_202 = 202, + RICON_203 = 203, + RICON_204 = 204, + RICON_205 = 205, + RICON_206 = 206, + RICON_207 = 207, + RICON_208 = 208, + RICON_209 = 209, + RICON_210 = 210, + RICON_211 = 211, + RICON_212 = 212, + RICON_213 = 213, + RICON_214 = 214, + RICON_215 = 215, + RICON_216 = 216, + RICON_217 = 217, + RICON_218 = 218, + RICON_219 = 219, + RICON_220 = 220, + RICON_221 = 221, + RICON_222 = 222, + RICON_223 = 223, + RICON_224 = 224, + RICON_225 = 225, + RICON_226 = 226, + RICON_227 = 227, + RICON_228 = 228, + RICON_229 = 229, + RICON_230 = 230, + RICON_231 = 231, + RICON_232 = 232, + RICON_233 = 233, + RICON_234 = 234, + RICON_235 = 235, + RICON_236 = 236, + RICON_237 = 237, + RICON_238 = 238, + RICON_239 = 239, + RICON_240 = 240, + RICON_241 = 241, + RICON_242 = 242, + RICON_243 = 243, + RICON_244 = 244, + RICON_245 = 245, + RICON_246 = 246, + RICON_247 = 247, + RICON_248 = 248, + RICON_249 = 249, + RICON_250 = 250, + RICON_251 = 251, + RICON_252 = 252, + RICON_253 = 253, + RICON_254 = 254, + RICON_255 = 255, +} guiIconName; + +#endif // RICONS_H + +#if defined(RICONS_IMPLEMENTATION) +//---------------------------------------------------------------------------------- +// Icons data (allocated on memory data section by default) +// NOTE: A new icon set could be loaded over this array using GuiLoadIcons(), +// just note that loaded icons set must be same RICON_SIZE +//---------------------------------------------------------------------------------- +static unsigned int guiIcons[RICON_MAX_ICONS*RICON_DATA_ELEMENTS] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_NONE + 0x3ff80000, 0x2f082008, 0x2042207e, 0x40027fc2, 0x40024002, 0x40024002, 0x40024002, 0x00007ffe, // RICON_FOLDER_FILE_OPEN + 0x3ffe0000, 0x44226422, 0x400247e2, 0x5ffa4002, 0x57ea500a, 0x500a500a, 0x40025ffa, 0x00007ffe, // RICON_FILE_SAVE_CLASSIC + 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024002, 0x44424282, 0x793e4102, 0x00000100, // RICON_FOLDER_OPEN + 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024102, 0x44424102, 0x793e4282, 0x00000000, // RICON_FOLDER_SAVE + 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x24442284, 0x21042104, 0x20042104, 0x00003ffc, // RICON_FILE_OPEN + 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x21042104, 0x22842444, 0x20042104, 0x00003ffc, // RICON_FILE_SAVE + 0x3ff00000, 0x201c2010, 0x00042004, 0x20041004, 0x20844784, 0x00841384, 0x20042784, 0x00003ffc, // RICON_FILE_EXPORT + 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x22042204, 0x22042f84, 0x20042204, 0x00003ffc, // RICON_FILE_NEW + 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x25042884, 0x25042204, 0x20042884, 0x00003ffc, // RICON_FILE_DELETE + 0x3ff00000, 0x201c2010, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // RICON_FILETYPE_TEXT + 0x3ff00000, 0x201c2010, 0x27042004, 0x244424c4, 0x26442444, 0x20642664, 0x20042004, 0x00003ffc, // RICON_FILETYPE_AUDIO + 0x3ff00000, 0x201c2010, 0x26042604, 0x20042004, 0x35442884, 0x2414222c, 0x20042004, 0x00003ffc, // RICON_FILETYPE_IMAGE + 0x3ff00000, 0x201c2010, 0x20c42004, 0x22442144, 0x22442444, 0x20c42144, 0x20042004, 0x00003ffc, // RICON_FILETYPE_PLAY + 0x3ff00000, 0x3ffc2ff0, 0x3f3c2ff4, 0x3dbc2eb4, 0x3dbc2bb4, 0x3f3c2eb4, 0x3ffc2ff4, 0x00002ff4, // RICON_FILETYPE_VIDEO + 0x3ff00000, 0x201c2010, 0x21842184, 0x21842004, 0x21842184, 0x21842184, 0x20042184, 0x00003ffc, // RICON_FILETYPE_INFO + 0x0ff00000, 0x381c0810, 0x28042804, 0x28042804, 0x28042804, 0x28042804, 0x20102ffc, 0x00003ff0, // RICON_FILE_COPY + 0x00000000, 0x701c0000, 0x079c1e14, 0x55a000f0, 0x079c00f0, 0x701c1e14, 0x00000000, 0x00000000, // RICON_FILE_CUT + 0x01c00000, 0x13e41bec, 0x3f841004, 0x204420c4, 0x20442044, 0x20442044, 0x207c2044, 0x00003fc0, // RICON_FILE_PASTE + 0x00000000, 0x3aa00fe0, 0x2abc2aa0, 0x2aa42aa4, 0x20042aa4, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_CURSOR_HAND + 0x00000000, 0x003c000c, 0x030800c8, 0x30100c10, 0x10202020, 0x04400840, 0x01800280, 0x00000000, // RICON_CURSOR_POINTER + 0x00000000, 0x00180000, 0x01f00078, 0x03e007f0, 0x07c003e0, 0x04000e40, 0x00000000, 0x00000000, // RICON_CURSOR_CLASSIC + 0x00000000, 0x04000000, 0x11000a00, 0x04400a80, 0x01100220, 0x00580088, 0x00000038, 0x00000000, // RICON_PENCIL + 0x04000000, 0x15000a00, 0x50402880, 0x14102820, 0x05040a08, 0x015c028c, 0x007c00bc, 0x00000000, // RICON_PENCIL_BIG + 0x01c00000, 0x01400140, 0x01400140, 0x0ff80140, 0x0ff80808, 0x0aa80808, 0x0aa80aa8, 0x00000ff8, // RICON_BRUSH_CLASSIC + 0x1ffc0000, 0x5ffc7ffe, 0x40004000, 0x00807f80, 0x01c001c0, 0x01c001c0, 0x01c001c0, 0x00000080, // RICON_BRUSH_PAINTER + 0x00000000, 0x00800000, 0x01c00080, 0x03e001c0, 0x07f003e0, 0x036006f0, 0x000001c0, 0x00000000, // RICON_WATER_DROP + 0x00000000, 0x3e003800, 0x1f803f80, 0x0c201e40, 0x02080c10, 0x00840104, 0x00380044, 0x00000000, // RICON_COLOR_PICKER + 0x00000000, 0x07800300, 0x1fe00fc0, 0x3f883fd0, 0x0e021f04, 0x02040402, 0x00f00108, 0x00000000, // RICON_RUBBER + 0x00c00000, 0x02800140, 0x08200440, 0x20081010, 0x2ffe3004, 0x03f807fc, 0x00e001f0, 0x00000040, // RICON_COLOR_BUCKET + 0x00000000, 0x21843ffc, 0x01800180, 0x01800180, 0x01800180, 0x01800180, 0x03c00180, 0x00000000, // RICON_TEXT_T + 0x00800000, 0x01400180, 0x06200340, 0x0c100620, 0x1ff80c10, 0x380c1808, 0x70067004, 0x0000f80f, // RICON_TEXT_A + 0x78000000, 0x50004000, 0x00004800, 0x03c003c0, 0x03c003c0, 0x00100000, 0x0002000a, 0x0000000e, // RICON_SCALE + 0x75560000, 0x5e004002, 0x54001002, 0x41001202, 0x408200fe, 0x40820082, 0x40820082, 0x00006afe, // RICON_RESIZE + 0x00000000, 0x3f003f00, 0x3f003f00, 0x3f003f00, 0x00400080, 0x001c0020, 0x001c001c, 0x00000000, // RICON_FILTER_POINT + 0x6d800000, 0x00004080, 0x40804080, 0x40800000, 0x00406d80, 0x001c0020, 0x001c001c, 0x00000000, // RICON_FILTER_BILINEAR + 0x40080000, 0x1ffe2008, 0x14081008, 0x11081208, 0x10481088, 0x10081028, 0x10047ff8, 0x00001002, // RICON_CROP + 0x00100000, 0x3ffc0010, 0x2ab03550, 0x22b02550, 0x20b02150, 0x20302050, 0x2000fff0, 0x00002000, // RICON_CROP_ALPHA + 0x40000000, 0x1ff82000, 0x04082808, 0x01082208, 0x00482088, 0x00182028, 0x35542008, 0x00000002, // RICON_SQUARE_TOGGLE + 0x00000000, 0x02800280, 0x06c006c0, 0x0ea00ee0, 0x1e901eb0, 0x3e883e98, 0x7efc7e8c, 0x00000000, // RICON_SIMMETRY + 0x01000000, 0x05600100, 0x1d480d50, 0x7d423d44, 0x3d447d42, 0x0d501d48, 0x01000560, 0x00000100, // RICON_SIMMETRY_HORIZONTAL + 0x01800000, 0x04200240, 0x10080810, 0x00001ff8, 0x00007ffe, 0x0ff01ff8, 0x03c007e0, 0x00000180, // RICON_SIMMETRY_VERTICAL + 0x00000000, 0x010800f0, 0x02040204, 0x02040204, 0x07f00308, 0x1c000e00, 0x30003800, 0x00000000, // RICON_LENS + 0x00000000, 0x061803f0, 0x08240c0c, 0x08040814, 0x0c0c0804, 0x23f01618, 0x18002400, 0x00000000, // RICON_LENS_BIG + 0x00000000, 0x00000000, 0x1c7007c0, 0x638e3398, 0x1c703398, 0x000007c0, 0x00000000, 0x00000000, // RICON_EYE_ON + 0x00000000, 0x10002000, 0x04700fc0, 0x610e3218, 0x1c703098, 0x001007a0, 0x00000008, 0x00000000, // RICON_EYE_OFF + 0x00000000, 0x00007ffc, 0x40047ffc, 0x10102008, 0x04400820, 0x02800280, 0x02800280, 0x00000100, // RICON_FILTER_TOP + 0x00000000, 0x40027ffe, 0x10082004, 0x04200810, 0x02400240, 0x02400240, 0x01400240, 0x000000c0, // RICON_FILTER + 0x00800000, 0x00800080, 0x00000080, 0x3c9e0000, 0x00000000, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_POINT + 0x00800000, 0x00800080, 0x00800080, 0x3f7e01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_SMALL + 0x00800000, 0x00800080, 0x03e00080, 0x3e3e0220, 0x03e00220, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_BIG + 0x01000000, 0x04400280, 0x01000100, 0x43842008, 0x43849ab2, 0x01002008, 0x04400100, 0x01000280, // RICON_TARGET_MOVE + 0x01000000, 0x04400280, 0x01000100, 0x41042108, 0x41049ff2, 0x01002108, 0x04400100, 0x01000280, // RICON_CURSOR_MOVE + 0x781e0000, 0x500a4002, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x4002500a, 0x0000781e, // RICON_CURSOR_SCALE + 0x00000000, 0x20003c00, 0x24002800, 0x01000200, 0x00400080, 0x00140024, 0x003c0004, 0x00000000, // RICON_CURSOR_SCALE_RIGHT + 0x00000000, 0x0004003c, 0x00240014, 0x00800040, 0x02000100, 0x28002400, 0x3c002000, 0x00000000, // RICON_CURSOR_SCALE_LEFT + 0x00000000, 0x00100020, 0x10101fc8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // RICON_UNDO + 0x00000000, 0x08000400, 0x080813f8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // RICON_REDO + 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3f902020, 0x00400020, 0x00000000, // RICON_REREDO + 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3fc82010, 0x00200010, 0x00000000, // RICON_MUTATE + 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18101020, 0x00100fc8, 0x00000020, // RICON_ROTATE + 0x00000000, 0x04000200, 0x240429fc, 0x20042204, 0x20442004, 0x3f942024, 0x00400020, 0x00000000, // RICON_REPEAT + 0x00000000, 0x20001000, 0x22104c0e, 0x00801120, 0x11200040, 0x4c0e2210, 0x10002000, 0x00000000, // RICON_SHUFFLE + 0x7ffe0000, 0x50024002, 0x44024802, 0x41024202, 0x40424082, 0x40124022, 0x4002400a, 0x00007ffe, // RICON_EMPTYBOX + 0x00800000, 0x03e00080, 0x08080490, 0x3c9e0808, 0x08080808, 0x03e00490, 0x00800080, 0x00000000, // RICON_TARGET + 0x00800000, 0x00800080, 0x00800080, 0x3ffe01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_SMALL_FILL + 0x00800000, 0x00800080, 0x03e00080, 0x3ffe03e0, 0x03e003e0, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_BIG_FILL + 0x01000000, 0x07c00380, 0x01000100, 0x638c2008, 0x638cfbbe, 0x01002008, 0x07c00100, 0x01000380, // RICON_TARGET_MOVE_FILL + 0x01000000, 0x07c00380, 0x01000100, 0x610c2108, 0x610cfffe, 0x01002108, 0x07c00100, 0x01000380, // RICON_CURSOR_MOVE_FILL + 0x781e0000, 0x6006700e, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x700e6006, 0x0000781e, // RICON_CURSOR_SCALE_FILL + 0x00000000, 0x38003c00, 0x24003000, 0x01000200, 0x00400080, 0x000c0024, 0x003c001c, 0x00000000, // RICON_CURSOR_SCALE_RIGHT + 0x00000000, 0x001c003c, 0x0024000c, 0x00800040, 0x02000100, 0x30002400, 0x3c003800, 0x00000000, // RICON_CURSOR_SCALE_LEFT + 0x00000000, 0x00300020, 0x10301ff8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // RICON_UNDO_FILL + 0x00000000, 0x0c000400, 0x0c081ff8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // RICON_REDO_FILL + 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3ff02060, 0x00400060, 0x00000000, // RICON_REREDO_FILL + 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3ff82030, 0x00200030, 0x00000000, // RICON_MUTATE_FILL + 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18301020, 0x00300ff8, 0x00000020, // RICON_ROTATE_FILL + 0x00000000, 0x06000200, 0x26042ffc, 0x20042204, 0x20442004, 0x3ff42064, 0x00400060, 0x00000000, // RICON_REPEAT_FILL + 0x00000000, 0x30001000, 0x32107c0e, 0x00801120, 0x11200040, 0x7c0e3210, 0x10003000, 0x00000000, // RICON_SHUFFLE_FILL + 0x00000000, 0x30043ffc, 0x24042804, 0x21042204, 0x20442084, 0x20142024, 0x3ffc200c, 0x00000000, // RICON_EMPTYBOX_SMALL + 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX + 0x00000000, 0x23c43ffc, 0x23c423c4, 0x200423c4, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_TOP + 0x00000000, 0x3e043ffc, 0x3e043e04, 0x20043e04, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_TOP_RIGHT + 0x00000000, 0x20043ffc, 0x20042004, 0x3e043e04, 0x3e043e04, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_RIGHT + 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x3e042004, 0x3e043e04, 0x3ffc3e04, 0x00000000, // RICON_BOX_BOTTOM_RIGHT + 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x23c42004, 0x23c423c4, 0x3ffc23c4, 0x00000000, // RICON_BOX_BOTTOM + 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x207c2004, 0x207c207c, 0x3ffc207c, 0x00000000, // RICON_BOX_BOTTOM_LEFT + 0x00000000, 0x20043ffc, 0x20042004, 0x207c207c, 0x207c207c, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_LEFT + 0x00000000, 0x207c3ffc, 0x207c207c, 0x2004207c, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_TOP_LEFT + 0x00000000, 0x20043ffc, 0x20042004, 0x23c423c4, 0x23c423c4, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_CIRCLE_MASK + 0x7ffe0000, 0x40024002, 0x47e24182, 0x4ff247e2, 0x47e24ff2, 0x418247e2, 0x40024002, 0x00007ffe, // RICON_BOX_CENTER + 0x7fff0000, 0x40014001, 0x40014001, 0x49555ddd, 0x4945495d, 0x400149c5, 0x40014001, 0x00007fff, // RICON_POT + 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x404e40ce, 0x48125432, 0x4006540e, 0x00007ffe, // RICON_ALPHA_MULTIPLY + 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x5c4e40ce, 0x44124432, 0x40065c0e, 0x00007ffe, // RICON_ALPHA_CLEAR + 0x7ffe0000, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x00007ffe, // RICON_DITHERING + 0x07fe0000, 0x1ffa0002, 0x7fea000a, 0x402a402a, 0x5b2a512a, 0x5128552a, 0x40205128, 0x00007fe0, // RICON_MIPMAPS + 0x00000000, 0x1ff80000, 0x12481248, 0x12481ff8, 0x1ff81248, 0x12481248, 0x00001ff8, 0x00000000, // RICON_BOX_GRID + 0x12480000, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x00001248, // RICON_GRID + 0x00000000, 0x1c380000, 0x1c3817e8, 0x08100810, 0x08100810, 0x17e81c38, 0x00001c38, 0x00000000, // RICON_BOX_CORNERS_SMALL + 0x700e0000, 0x700e5ffa, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x5ffa700e, 0x0000700e, // RICON_BOX_CORNERS_BIG + 0x3f7e0000, 0x21422142, 0x21422142, 0x00003f7e, 0x21423f7e, 0x21422142, 0x3f7e2142, 0x00000000, // RICON_FOUR_BOXES + 0x00000000, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x00000000, // RICON_GRID_FILL + 0x7ffe0000, 0x7ffe7ffe, 0x77fe7000, 0x77fe77fe, 0x777e7700, 0x777e777e, 0x777e777e, 0x0000777e, // RICON_BOX_MULTISIZE + 0x781e0000, 0x40024002, 0x00004002, 0x01800000, 0x00000180, 0x40020000, 0x40024002, 0x0000781e, // RICON_ZOOM_SMALL + 0x781e0000, 0x40024002, 0x00004002, 0x03c003c0, 0x03c003c0, 0x40020000, 0x40024002, 0x0000781e, // RICON_ZOOM_MEDIUM + 0x781e0000, 0x40024002, 0x07e04002, 0x07e007e0, 0x07e007e0, 0x400207e0, 0x40024002, 0x0000781e, // RICON_ZOOM_BIG + 0x781e0000, 0x5ffa4002, 0x1ff85ffa, 0x1ff81ff8, 0x1ff81ff8, 0x5ffa1ff8, 0x40025ffa, 0x0000781e, // RICON_ZOOM_ALL + 0x00000000, 0x2004381c, 0x00002004, 0x00000000, 0x00000000, 0x20040000, 0x381c2004, 0x00000000, // RICON_ZOOM_CENTER + 0x00000000, 0x1db80000, 0x10081008, 0x10080000, 0x00001008, 0x10081008, 0x00001db8, 0x00000000, // RICON_BOX_DOTS_SMALL + 0x35560000, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x35562002, 0x00000000, // RICON_BOX_DOTS_BIG + 0x7ffe0000, 0x40024002, 0x48124ff2, 0x49924812, 0x48124992, 0x4ff24812, 0x40024002, 0x00007ffe, // RICON_BOX_CONCENTRIC + 0x00000000, 0x10841ffc, 0x10841084, 0x1ffc1084, 0x10841084, 0x10841084, 0x00001ffc, 0x00000000, // RICON_BOX_GRID_BIG + 0x00000000, 0x00000000, 0x10000000, 0x04000800, 0x01040200, 0x00500088, 0x00000020, 0x00000000, // RICON_OK_TICK + 0x00000000, 0x10080000, 0x04200810, 0x01800240, 0x02400180, 0x08100420, 0x00001008, 0x00000000, // RICON_CROSS + 0x00000000, 0x02000000, 0x00800100, 0x00200040, 0x00200010, 0x00800040, 0x02000100, 0x00000000, // RICON_ARROW_LEFT + 0x00000000, 0x00400000, 0x01000080, 0x04000200, 0x04000800, 0x01000200, 0x00400080, 0x00000000, // RICON_ARROW_RIGHT + 0x00000000, 0x00000000, 0x00000000, 0x08081004, 0x02200410, 0x00800140, 0x00000000, 0x00000000, // RICON_ARROW_BOTTOM + 0x00000000, 0x00000000, 0x01400080, 0x04100220, 0x10040808, 0x00000000, 0x00000000, 0x00000000, // RICON_ARROW_TOP + 0x00000000, 0x02000000, 0x03800300, 0x03e003c0, 0x03e003f0, 0x038003c0, 0x02000300, 0x00000000, // RICON_ARROW_LEFT_FILL + 0x00000000, 0x00400000, 0x01c000c0, 0x07c003c0, 0x07c00fc0, 0x01c003c0, 0x004000c0, 0x00000000, // RICON_ARROW_RIGHT_FILL + 0x00000000, 0x00000000, 0x00000000, 0x0ff81ffc, 0x03e007f0, 0x008001c0, 0x00000000, 0x00000000, // RICON_ARROW_BOTTOM_FILL + 0x00000000, 0x00000000, 0x01c00080, 0x07f003e0, 0x1ffc0ff8, 0x00000000, 0x00000000, 0x00000000, // RICON_ARROW_TOP_FILL + 0x00000000, 0x18a008c0, 0x32881290, 0x24822686, 0x26862482, 0x12903288, 0x08c018a0, 0x00000000, // RICON_AUDIO + 0x00000000, 0x04800780, 0x004000c0, 0x662000f0, 0x08103c30, 0x130a0e18, 0x0000318e, 0x00000000, // RICON_FX + 0x00000000, 0x00800000, 0x08880888, 0x2aaa0a8a, 0x0a8a2aaa, 0x08880888, 0x00000080, 0x00000000, // RICON_WAVE + 0x00000000, 0x00600000, 0x01080090, 0x02040108, 0x42044204, 0x24022402, 0x00001800, 0x00000000, // RICON_WAVE_SINUS + 0x00000000, 0x07f80000, 0x04080408, 0x04080408, 0x04080408, 0x7c0e0408, 0x00000000, 0x00000000, // RICON_WAVE_SQUARE + 0x00000000, 0x00000000, 0x00a00040, 0x22084110, 0x08021404, 0x00000000, 0x00000000, 0x00000000, // RICON_WAVE_TRIANGULAR + 0x00000000, 0x00000000, 0x04200000, 0x01800240, 0x02400180, 0x00000420, 0x00000000, 0x00000000, // RICON_CROSS_SMALL + 0x00000000, 0x18380000, 0x12281428, 0x10a81128, 0x112810a8, 0x14281228, 0x00001838, 0x00000000, // RICON_PLAYER_PREVIOUS + 0x00000000, 0x18000000, 0x11801600, 0x10181060, 0x10601018, 0x16001180, 0x00001800, 0x00000000, // RICON_PLAYER_PLAY_BACK + 0x00000000, 0x00180000, 0x01880068, 0x18080608, 0x06081808, 0x00680188, 0x00000018, 0x00000000, // RICON_PLAYER_PLAY + 0x00000000, 0x1e780000, 0x12481248, 0x12481248, 0x12481248, 0x12481248, 0x00001e78, 0x00000000, // RICON_PLAYER_PAUSE + 0x00000000, 0x1ff80000, 0x10081008, 0x10081008, 0x10081008, 0x10081008, 0x00001ff8, 0x00000000, // RICON_PLAYER_STOP + 0x00000000, 0x1c180000, 0x14481428, 0x15081488, 0x14881508, 0x14281448, 0x00001c18, 0x00000000, // RICON_PLAYER_NEXT + 0x00000000, 0x03c00000, 0x08100420, 0x10081008, 0x10081008, 0x04200810, 0x000003c0, 0x00000000, // RICON_PLAYER_RECORD + 0x00000000, 0x0c3007e0, 0x13c81818, 0x14281668, 0x14281428, 0x1c381c38, 0x08102244, 0x00000000, // RICON_MAGNET + 0x07c00000, 0x08200820, 0x3ff80820, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // RICON_LOCK_CLOSE + 0x07c00000, 0x08000800, 0x3ff80800, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // RICON_LOCK_OPEN + 0x01c00000, 0x0c180770, 0x3086188c, 0x60832082, 0x60034781, 0x30062002, 0x0c18180c, 0x01c00770, // RICON_CLOCK + 0x0a200000, 0x1b201b20, 0x04200e20, 0x04200420, 0x04700420, 0x0e700e70, 0x0e700e70, 0x04200e70, // RICON_TOOLS + 0x01800000, 0x3bdc318c, 0x0ff01ff8, 0x7c3e1e78, 0x1e787c3e, 0x1ff80ff0, 0x318c3bdc, 0x00000180, // RICON_GEAR + 0x01800000, 0x3ffc318c, 0x1c381ff8, 0x781e1818, 0x1818781e, 0x1ff81c38, 0x318c3ffc, 0x00000180, // RICON_GEAR_BIG + 0x00000000, 0x08080ff8, 0x08081ffc, 0x0aa80aa8, 0x0aa80aa8, 0x0aa80aa8, 0x08080aa8, 0x00000ff8, // RICON_BIN + 0x00000000, 0x00000000, 0x20043ffc, 0x08043f84, 0x04040f84, 0x04040784, 0x000007fc, 0x00000000, // RICON_HAND_POINTER + 0x00000000, 0x24400400, 0x00001480, 0x6efe0e00, 0x00000e00, 0x24401480, 0x00000400, 0x00000000, // RICON_LASER + 0x00000000, 0x03c00000, 0x08300460, 0x11181118, 0x11181118, 0x04600830, 0x000003c0, 0x00000000, // RICON_COIN + 0x00000000, 0x10880080, 0x06c00810, 0x366c07e0, 0x07e00240, 0x00001768, 0x04200240, 0x00000000, // RICON_EXPLOSION + 0x00000000, 0x3d280000, 0x2528252c, 0x3d282528, 0x05280528, 0x05e80528, 0x00000000, 0x00000000, // RICON_1UP + 0x01800000, 0x03c003c0, 0x018003c0, 0x0ff007e0, 0x0bd00bd0, 0x0a500bd0, 0x02400240, 0x02400240, // RICON_PLAYER + 0x01800000, 0x03c003c0, 0x118013c0, 0x03c81ff8, 0x07c003c8, 0x04400440, 0x0c080478, 0x00000000, // RICON_PLAYER_JUMP + 0x3ff80000, 0x30183ff8, 0x30183018, 0x3ff83ff8, 0x03000300, 0x03c003c0, 0x03e00300, 0x000003e0, // RICON_KEY + 0x3ff80000, 0x3ff83ff8, 0x33983ff8, 0x3ff83398, 0x3ff83ff8, 0x00000540, 0x0fe00aa0, 0x00000fe0, // RICON_DEMON + 0x00000000, 0x0ff00000, 0x20041008, 0x25442004, 0x10082004, 0x06000bf0, 0x00000300, 0x00000000, // RICON_TEXT_POPUP + 0x00000000, 0x11440000, 0x07f00be8, 0x1c1c0e38, 0x1c1c0c18, 0x07f00e38, 0x11440be8, 0x00000000, // RICON_GEAR_EX + 0x00000000, 0x20080000, 0x0c601010, 0x07c00fe0, 0x07c007c0, 0x0c600fe0, 0x20081010, 0x00000000, // RICON_CRACK + 0x00000000, 0x20080000, 0x0c601010, 0x04400fe0, 0x04405554, 0x0c600fe0, 0x20081010, 0x00000000, // RICON_CRACK_POINTS + 0x00000000, 0x00800080, 0x01c001c0, 0x1ffc3ffe, 0x03e007f0, 0x07f003e0, 0x0c180770, 0x00000808, // RICON_STAR + 0x0ff00000, 0x08180810, 0x08100818, 0x0a100810, 0x08180810, 0x08100818, 0x08100810, 0x00001ff8, // RICON_DOOR + 0x0ff00000, 0x08100810, 0x08100810, 0x10100010, 0x4f902010, 0x10102010, 0x08100010, 0x00000ff0, // RICON_EXIT + 0x00040000, 0x001f000e, 0x0ef40004, 0x12f41284, 0x0ef41214, 0x10040004, 0x7ffc3004, 0x10003000, // RICON_MODE_2D + 0x78040000, 0x501f600e, 0x0ef44004, 0x12f41284, 0x0ef41284, 0x10140004, 0x7ffc300c, 0x10003000, // RICON_MODE_3D + 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // RICON_CUBE + 0x7fe00000, 0x5ff87ff0, 0x47fe4ffc, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // RICON_CUBE_FACE_TOP + 0x7fe00000, 0x50386030, 0x47fe483c, 0x443e443e, 0x443e443e, 0x241e75fe, 0x0c06140e, 0x000007fe, // RICON_CUBE_FACE_LEFT + 0x7fe00000, 0x50286030, 0x47fe4804, 0x47fe47fe, 0x47fe47fe, 0x27fe77fe, 0x0ffe17fe, 0x000007fe, // RICON_CUBE_FACE_FRONT + 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x3ff27fe2, 0x0ffe1ffa, 0x000007fe, // RICON_CUBE_FACE_BOTTOM + 0x7fe00000, 0x70286030, 0x7ffe7804, 0x7c227c02, 0x7c227c22, 0x3c127de2, 0x0c061c0a, 0x000007fe, // RICON_CUBE_FACE_RIGHT + 0x7fe00000, 0x7fe87ff0, 0x7ffe7fe4, 0x7fe27fe2, 0x7fe27fe2, 0x24127fe2, 0x0c06140a, 0x000007fe, // RICON_CUBE_FACE_BACK + 0x00000000, 0x2a0233fe, 0x22022602, 0x22022202, 0x2a022602, 0x00a033fe, 0x02080110, 0x00000000, // RICON_CAMERA + 0x00000000, 0x200c3ffc, 0x000c000c, 0x3ffc000c, 0x30003000, 0x30003000, 0x3ffc3004, 0x00000000, // RICON_SPECIAL + 0x00000000, 0x0022003e, 0x012201e2, 0x0100013e, 0x01000100, 0x79000100, 0x4f004900, 0x00007800, // RICON_LINK_NET + 0x00000000, 0x44007c00, 0x45004600, 0x00627cbe, 0x00620022, 0x45007cbe, 0x44004600, 0x00007c00, // RICON_LINK_BOXES + 0x00000000, 0x0044007c, 0x0010007c, 0x3f100010, 0x3f1021f0, 0x3f100010, 0x3f0021f0, 0x00000000, // RICON_LINK_MULTI + 0x00000000, 0x0044007c, 0x00440044, 0x0010007c, 0x00100010, 0x44107c10, 0x440047f0, 0x00007c00, // RICON_LINK + 0x00000000, 0x0044007c, 0x00440044, 0x0000007c, 0x00000010, 0x44007c10, 0x44004550, 0x00007c00, // RICON_LINK_BROKE + 0x02a00000, 0x22a43ffc, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // RICON_TEXT_NOTES + 0x3ffc0000, 0x20042004, 0x245e27c4, 0x27c42444, 0x2004201e, 0x201e2004, 0x20042004, 0x00003ffc, // RICON_NOTEBOOK + 0x00000000, 0x07e00000, 0x04200420, 0x24243ffc, 0x24242424, 0x24242424, 0x3ffc2424, 0x00000000, // RICON_SUITCASE + 0x00000000, 0x0fe00000, 0x08200820, 0x40047ffc, 0x7ffc5554, 0x40045554, 0x7ffc4004, 0x00000000, // RICON_SUITCASE_ZIP + 0x00000000, 0x20043ffc, 0x3ffc2004, 0x13c81008, 0x100813c8, 0x10081008, 0x1ff81008, 0x00000000, // RICON_MAILBOX + 0x00000000, 0x40027ffe, 0x5ffa5ffa, 0x5ffa5ffa, 0x40025ffa, 0x03c07ffe, 0x1ff81ff8, 0x00000000, // RICON_MONITOR + 0x0ff00000, 0x6bfe7ffe, 0x7ffe7ffe, 0x68167ffe, 0x08106816, 0x08100810, 0x0ff00810, 0x00000000, // RICON_PRINTER + 0x3ff80000, 0xfffe2008, 0x870a8002, 0x904a888a, 0x904a904a, 0x870a888a, 0xfffe8002, 0x00000000, // RICON_PHOTO_CAMERA + 0x0fc00000, 0xfcfe0cd8, 0x8002fffe, 0x84428382, 0x84428442, 0x80028382, 0xfffe8002, 0x00000000, // RICON_PHOTO_CAMERA_FLASH + 0x00000000, 0x02400180, 0x08100420, 0x20041008, 0x23c42004, 0x22442244, 0x3ffc2244, 0x00000000, // RICON_HOUSE + 0x00000000, 0x1c700000, 0x3ff83ef8, 0x3ff83ff8, 0x0fe01ff0, 0x038007c0, 0x00000100, 0x00000000, // RICON_HEART + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x80000000, 0xe000c000, // RICON_CORNER + 0x00000000, 0x14001c00, 0x15c01400, 0x15401540, 0x155c1540, 0x15541554, 0x1ddc1554, 0x00000000, // RICON_VERTICAL_BARS + 0x00000000, 0x03000300, 0x1b001b00, 0x1b601b60, 0x1b6c1b60, 0x1b6c1b6c, 0x1b6c1b6c, 0x00000000, // RICON_VERTICAL_BARS_FILL + 0x00000000, 0x00000000, 0x403e7ffe, 0x7ffe403e, 0x7ffe0000, 0x43fe43fe, 0x00007ffe, 0x00000000, // RICON_LIFE_BARS + 0x7ffc0000, 0x43844004, 0x43844284, 0x43844004, 0x42844284, 0x42844284, 0x40044384, 0x00007ffc, // RICON_INFO + 0x40008000, 0x10002000, 0x04000800, 0x01000200, 0x00400080, 0x00100020, 0x00040008, 0x00010002, // RICON_CROSSLINE + 0x00000000, 0x1ff01ff0, 0x18301830, 0x1f001830, 0x03001f00, 0x00000300, 0x03000300, 0x00000000, // RICON_HELP + 0x3ff00000, 0x2abc3550, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x00003ffc, // RICON_FILETYPE_ALPHA + 0x3ff00000, 0x201c2010, 0x22442184, 0x28142424, 0x29942814, 0x2ff42994, 0x20042004, 0x00003ffc, // RICON_FILETYPE_HOME + 0x07fe0000, 0x04020402, 0x7fe20402, 0x44224422, 0x44224422, 0x402047fe, 0x40204020, 0x00007fe0, // RICON_LAYERS_VISIBLE + 0x07fe0000, 0x04020402, 0x7c020402, 0x44024402, 0x44024402, 0x402047fe, 0x40204020, 0x00007fe0, // RICON_LAYERS + 0x00000000, 0x40027ffe, 0x7ffe4002, 0x40024002, 0x40024002, 0x40024002, 0x7ffe4002, 0x00000000, // RICON_WINDOW + 0x09100000, 0x09f00910, 0x09100910, 0x00000910, 0x24a2779e, 0x27a224a2, 0x709e20a2, 0x00000000, // RICON_HIDPI + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_200 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_201 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_202 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_203 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_204 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_205 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_206 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_207 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_208 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_209 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_210 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_211 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_212 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_213 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_214 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_215 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_216 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_217 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_218 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_219 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_220 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_221 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_222 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_223 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_224 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_225 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_226 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_227 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_228 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_229 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_230 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_231 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_232 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_233 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_234 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_235 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_236 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_237 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_238 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_239 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_240 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_241 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_242 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_243 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_244 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_245 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_246 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_247 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_248 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_249 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_250 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_251 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_252 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_253 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_254 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_255 +}; +#endif // RICONS_IMPLEMENTATION diff --git a/src/audio.c b/src/audio.c index 592e25b..d90e61b 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1,7 +1,9 @@ /* * RayLib library: audio.c - * version 3.5 + * version 3.7 * + * Copyright 2021 Leonardo Mendez ( mlmgerencir at gmail com ) + * Copyright 2021 Maurizio la Cecilia ( m.lacecilia at gmail com ) * Copyright 2020 - 2021 RafaÅ‚ Jopek ( rafaljopek at hotmail com ) * */ @@ -14,62 +16,1263 @@ // Audio device management functions // void InitAudioDevice(void); // Initialize audio device and context +HB_FUNC( INITAUDIODEVICE ) +{ + InitAudioDevice(); +} + // void CloseAudioDevice(void); // Close the audio device and context +HB_FUNC( CLOSEAUDIODEVICE ) +{ + CloseAudioDevice(); +} + // bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully +HB_FUNC( ISAUDIODEVICEREADY ) +{ + hb_retl( IsAudioDeviceReady() ); +} + // void SetMasterVolume(float volume); // Set master volume (listener) +HB_FUNC( SETMASTERVOLUME ) +{ + if( hb_param( 1, HB_IT_NUMERIC ) != NULL ) + { + SetMasterVolume( ( float ) hb_parnd( 1 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} // Wave/Sound loading/unloading functions + // Wave LoadWave(const char *fileName); // Load wave data from file +HB_FUNC( LOADWAVE ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL ) + { + Wave wave = LoadWave( hb_parc( 1 ) ); + + PHB_ITEM pWaveArray = hb_itemArrayNew( 5 ); + + hb_arraySetNI( pWaveArray, 1, ( unsigned int ) wave.frameCount ); + hb_arraySetNI( pWaveArray, 2, ( unsigned int ) wave.sampleRate ); + hb_arraySetNI( pWaveArray, 3, ( unsigned int ) wave.sampleSize ); + hb_arraySetNI( pWaveArray, 4, ( unsigned int ) wave.channels ); + hb_arraySetPtr( pWaveArray, 5, wave.data ); + + hb_itemReturnRelease( pWaveArray ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); // Load wave from memory buffer, fileType refers to extension: i.e. "wav" +HB_FUNC( LOADWAVEFROMMEMORY ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL && + hb_param( 2, HB_IT_STRING ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL ) + { + Wave wave = LoadWaveFromMemory( hb_parc( 1 ), ( const unsigned char * ) hb_parptr( 2 ), hb_parni( 3 ) ); + + PHB_ITEM pWaveArray = hb_itemArrayNew( 5 ); + + hb_arraySetNI( pWaveArray, 1, ( unsigned int ) wave.frameCount ); + hb_arraySetNI( pWaveArray, 2, ( unsigned int ) wave.sampleRate ); + hb_arraySetNI( pWaveArray, 3, ( unsigned int ) wave.sampleSize ); + hb_arraySetNI( pWaveArray, 4, ( unsigned int ) wave.channels ); + hb_arraySetPtr( pWaveArray, 5, wave.data ); + + hb_itemReturnRelease( pWaveArray ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // Sound LoadSound(const char *fileName); // Load sound from file +HB_FUNC( LOADSOUND ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL ) + { + Sound sound = LoadSound( hb_parc( 1 ) ); + + PHB_ITEM pSoundArray = hb_itemArrayNew( 2 ); + + // AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pSoundArray, 1 ); + + hb_arrayNew( pSubarrayAudioStream, 4 ); + hb_arraySetPtr( pSubarrayAudioStream, 1, sound.stream.buffer ); + hb_arraySetNI( pSubarrayAudioStream, 2, ( unsigned int ) sound.stream.sampleRate ); + hb_arraySetNI( pSubarrayAudioStream, 3, ( unsigned int ) sound.stream.sampleSize ); + hb_arraySetNI( pSubarrayAudioStream, 4, ( unsigned int ) sound.stream.channels ); + + hb_arraySetNI( pSoundArray, 2, ( unsigned int ) sound.frameCount ); + + hb_itemReturnRelease( pSoundArray ); + hb_itemRelease( pSubarrayAudioStream ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // Sound LoadSoundFromWave(Wave wave); // Load sound from wave data +HB_FUNC( LOADSOUNDFROMWAVE ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 ) + { + Wave wave; + + wave.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 1 ); + wave.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + wave.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + wave.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + wave.data = hb_arrayGetPtr( pItem, 5 ); + + Sound sound = LoadSoundFromWave( wave ); + + PHB_ITEM pSoundArray = hb_itemArrayNew( 2 ); + + // AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pSoundArray, 1 ); + + hb_arrayNew( pSubarrayAudioStream, 4 ); + hb_arraySetPtr( pSubarrayAudioStream, 1, sound.stream.buffer ); + hb_arraySetNI( pSubarrayAudioStream, 2, ( unsigned int ) sound.stream.sampleRate ); + hb_arraySetNI( pSubarrayAudioStream, 3, ( unsigned int ) sound.stream.sampleSize ); + hb_arraySetNI( pSubarrayAudioStream, 4, ( unsigned int ) sound.stream.channels ); + + hb_arraySetNI( pSoundArray, 2, ( unsigned int ) sound.frameCount ); + + hb_itemReturnRelease( pSoundArray ); + hb_itemRelease( pSubarrayAudioStream ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data +HB_FUNC( UPDATESOUND ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 2 && + hb_param( 2, HB_IT_POINTER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) + { + Sound sound; + + // AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + sound.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + sound.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + sound.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + sound.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + sound.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + + UpdateSound( sound, hb_parptr( 2 ), hb_parni( 3 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void UnloadWave(Wave wave); // Unload wave data +HB_FUNC( UNLOADWAVE ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 ) + { + Wave wave; + + wave.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 1 ); + wave.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + wave.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + wave.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + wave.data = hb_arrayGetPtr( pItem, 5 ); + + UnloadWave( wave ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void UnloadSound(Sound sound); // Unload sound +HB_FUNC( UNLOADSOUND ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 2 ) + { + Sound sound; + + // AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + sound.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + sound.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + sound.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + sound.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + sound.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + + UnloadSound( sound ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // bool ExportWave(Wave wave, const char *fileName); // Export wave data to file, returns true on success +HB_FUNC( EXPORTWAVE ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 && + hb_param( 2, HB_IT_STRING ) != NULL ) + { + Wave wave; + + wave.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 1 ); + wave.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + wave.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + wave.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + wave.data = hb_arrayGetPtr( pItem, 5 ); + + hb_retl( ExportWave( wave, hb_parc( 2 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // bool ExportWaveAsCode(Wave wave, const char *fileName); // Export wave sample data to code (.h), returns true on success +HB_FUNC( EXPORTWAVEASCODE ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 && + hb_param( 2, HB_IT_STRING ) != NULL ) + { + Wave wave; + + wave.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 1 ); + wave.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + wave.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + wave.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + wave.data = hb_arrayGetPtr( pItem, 5 ); + + hb_retl( ExportWaveAsCode( wave, hb_parc( 2 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} // Wave/Sound management functions + // void PlaySound(Sound sound); // Play a sound +HB_FUNC( PLAYSOUND ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 2 ) + { + Sound sound; + + // AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + sound.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + sound.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + sound.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + sound.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + sound.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + + PlaySound( sound ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void StopSound(Sound sound); // Stop playing a sound +HB_FUNC( STOPSOUND ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 2 ) + { + Sound sound; + + // AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + sound.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + sound.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + sound.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + sound.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + sound.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + + StopSound( sound ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void PauseSound(Sound sound); // Pause a sound +HB_FUNC( PAUSESOUND ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 2 ) + { + Sound sound; + + // AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + sound.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + sound.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + sound.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + sound.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + sound.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + + PauseSound( sound ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void ResumeSound(Sound sound); // Resume a paused sound +HB_FUNC( RESUMESOUND ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 2 ) + { + Sound sound; + + // AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + sound.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + sound.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + sound.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + sound.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + sound.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + + ResumeSound( sound ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void PlaySoundMulti(Sound sound); // Play a sound (using multichannel buffer pool) +HB_FUNC( PLAYSOUNDMULTI ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 2 ) + { + Sound sound; + + // AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + sound.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + sound.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + sound.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + sound.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + sound.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + + PlaySoundMulti( sound ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void StopSoundMulti(void); // Stop any sound playing (using multichannel buffer pool) +HB_FUNC(STOPSOUNDMULTI) +{ + StopSoundMulti(); +} + // int GetSoundsPlaying(void); // Get number of sounds playing in the multichannel +HB_FUNC(GETSOUNDSPLAYING) +{ + hb_retni( GetSoundsPlaying() ); +} + // bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing +HB_FUNC( ISSOUNDPLAYING ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 2 ) + { + Sound sound; + + // AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + sound.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + sound.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + sound.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + sound.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + sound.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + + hb_retl( IsSoundPlaying( sound )); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level) +HB_FUNC( SETSOUNDVOLUME ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 2 && hb_param( 2, HB_IT_NUMERIC ) != NULL) + { + Sound sound; + + // AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + sound.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + sound.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + sound.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + sound.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + sound.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + + SetSoundVolume( sound, ( float ) hb_parnd( 2 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level) +HB_FUNC( SETSOUNDPITCH ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 2 && + hb_param( 2, HB_IT_NUMERIC ) != NULL) + { + Sound sound; + + // AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + sound.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + sound.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + sound.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + sound.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + sound.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + + SetSoundPitch( sound, ( float ) hb_parnd( 2 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format +HB_FUNC( WAVEFORMAT ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 && + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL && + hb_param( 4, HB_IT_INTEGER ) != NULL ) + { + Wave wave; + + wave.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 1 ); + wave.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + wave.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + wave.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + wave.data = hb_arrayGetPtr( pItem, 5 ); + + WaveFormat( &wave, hb_parni( 2 ), hb_parni( 3 ), hb_parni( 4 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // Wave WaveCopy(Wave wave); // Copy a wave to a new wave +HB_FUNC( WAVECOPY ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 ) + { + Wave wave; + + wave.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 1 ); + wave.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + wave.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + wave.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + wave.data = hb_arrayGetPtr( pItem, 5 ); + + Wave waveret = WaveCopy( wave ); + + PHB_ITEM info = hb_itemArrayNew( 5 ); + + hb_arraySetNI( info, 1, ( unsigned int ) waveret.frameCount ); + hb_arraySetNI( info, 2, ( unsigned int ) waveret.sampleRate ); + hb_arraySetNI( info, 3, ( unsigned int ) waveret.sampleSize ); + hb_arraySetNI( info, 4, ( unsigned int ) waveret.channels ); + hb_arraySetPtr( info, 5, waveret.data ); + + hb_itemReturnRelease( info ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range +HB_FUNC( WAVECROP ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 && + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL ) + { + Wave wave; + + wave.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 1 ); + wave.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + wave.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + wave.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + wave.data = hb_arrayGetPtr( pItem, 5 ); + + WaveCrop( &wave, hb_parni( 2 ), hb_parni( 3 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // float *LoadWaveSamples(Wave wave); // Load samples data from wave as a floats array +HB_FUNC( LOADWAVESAMPLES ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 ) + { + Wave wave; + + wave.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 1 ); + wave.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + wave.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + wave.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + wave.data = hb_arrayGetPtr( pItem, 5 ); + + hb_retptr( LoadWaveSamples( wave ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void UnloadWaveSamples(float *samples); // Unload samples data loaded with LoadWaveSamples() +HB_FUNC( UNLOADWAVESAMPLES ) +{ + if( hb_param( 1, HB_IT_NUMERIC ) != NULL ) + { + float samples; + UnloadWaveSamples( &samples ); + hb_storni( ( float ) samples, 1 ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} // Music management functions + // Music LoadMusicStream(const char *fileName); // Load music stream from file +HB_FUNC( LOADMUSICSTREAM ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL ) + { + Music music = LoadMusicStream( hb_parc( 1 ) ); + + PHB_ITEM pMusicArray = hb_itemArrayNew( 5 ); + + //AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pMusicArray, 1 ); + + hb_arrayNew( pSubarrayAudioStream, 4 ); + hb_arraySetPtr( pSubarrayAudioStream, 1, ( rAudioBuffer * ) music.stream.buffer ); + hb_arraySetNI( pSubarrayAudioStream, 2, ( unsigned int ) music.stream.sampleRate ); + hb_arraySetNI( pSubarrayAudioStream, 3, ( unsigned int ) music.stream.sampleSize ); + hb_arraySetNI( pSubarrayAudioStream, 4, ( unsigned int ) music.stream.channels ); + + hb_arraySetNI( pMusicArray, 2, ( unsigned int ) music.frameCount ); + hb_arraySetL( pMusicArray, 3, music.looping ); + hb_arraySetNI( pMusicArray, 4, music.ctxType ); + hb_arraySetPtr( pMusicArray, 5, music.ctxData ); + + hb_itemReturnRelease( pMusicArray ); + hb_itemRelease( pSubarrayAudioStream ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +//Music LoadMusicStreamFromMemory(const char *fileType, unsigned char* data, int dataSize); // Load music stream from data + // void UnloadMusicStream(Music music); // Unload music stream +HB_FUNC( UNLOADMUSICSTREAM ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 ) + { + Music music; + + //AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + music.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + music.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + music.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + music.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + music.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + music.looping = hb_arrayGetL( pItem, 3 ); + music.ctxType = hb_arrayGetNI( pItem, 4 ); + music.ctxData = hb_arrayGetPtr( pItem, 5 ); + + UnloadMusicStream( music ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void PlayMusicStream(Music music); // Start music playing +HB_FUNC( PLAYMUSICSTREAM ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 ) + { + Music music; + + //AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + music.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + music.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + music.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + music.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + music.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + music.looping = hb_arrayGetL( pItem, 3 ); + music.ctxType = hb_arrayGetNI( pItem, 4 ); + music.ctxData = hb_arrayGetPtr( pItem, 5 ); + + PlayMusicStream( music ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +//bool IsMusicStreamPlaying(Music music); // Check if music is playing +HB_FUNC( ISMUSICSTREAMPLAYING ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 ) + { + Music music; + + //AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + music.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + music.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + music.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + music.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + music.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + music.looping = hb_arrayGetL( pItem, 3 ); + music.ctxType = hb_arrayGetNI( pItem, 4 ); + music.ctxData = hb_arrayGetPtr( pItem, 5 ); + + hb_retl( IsMusicStreamPlaying( music ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void UpdateMusicStream(Music music); // Updates buffers for music streaming +HB_FUNC( UPDATEMUSICSTREAM ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 ) + { + Music music; + + //AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + music.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + music.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + music.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + music.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + music.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + music.looping = hb_arrayGetL( pItem, 3 ); + music.ctxType = hb_arrayGetNI( pItem, 4 ); + music.ctxData = hb_arrayGetPtr( pItem, 5 ); + + UpdateMusicStream( music ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void StopMusicStream(Music music); // Stop music playing +HB_FUNC( STOPMUSICSTREAM ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 ) + { + Music music; + + //AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + music.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + music.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + music.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + music.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + music.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + music.looping = hb_arrayGetL( pItem, 3 ); + music.ctxType = hb_arrayGetNI( pItem, 4 ); + music.ctxData = hb_arrayGetPtr( pItem, 5 ); + + StopMusicStream( music ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void PauseMusicStream(Music music); // Pause music playing +HB_FUNC( PAUSEMUSICSTREAM ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 ) + { + Music music; + + //AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + music.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + music.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + music.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + music.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + music.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + music.looping = hb_arrayGetL( pItem, 3 ); + music.ctxType = hb_arrayGetNI( pItem, 4 ); + music.ctxData = hb_arrayGetPtr( pItem, 5 ); + + PauseMusicStream( music ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void ResumeMusicStream(Music music); // Resume playing paused music -// bool IsMusicPlaying(Music music); // Check if music is playing +HB_FUNC( RESUMEMUSICSTREAM ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 ) + { + Music music; + + //AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + music.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + music.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + music.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + music.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + music.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + music.looping = hb_arrayGetL( pItem, 3 ); + music.ctxType = hb_arrayGetNI( pItem, 4 ); + music.ctxData = hb_arrayGetPtr( pItem, 5 ); + + ResumeMusicStream( music ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + + // void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level) +HB_FUNC( SETMUSICVOLUME ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 && + hb_param( 2, HB_IT_NUMERIC ) != NULL ) + { + Music music; + + //AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + music.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + music.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + music.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + music.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + music.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + music.looping = hb_arrayGetL( pItem, 3 ); + music.ctxType = hb_arrayGetNI( pItem, 4 ); + music.ctxData = hb_arrayGetPtr( pItem, 5 ); + + SetMusicVolume( music, ( float ) hb_parnd( 2 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level) +HB_FUNC( SETMUSICPITCH ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 && + hb_param( 2, HB_IT_NUMERIC ) != NULL ) + { + Music music; + + //AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + music.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + music.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + music.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + music.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + music.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + music.looping = hb_arrayGetL( pItem, 3 ); + music.ctxType = hb_arrayGetNI( pItem, 4 ); + music.ctxData = hb_arrayGetPtr( pItem, 5 ); + + SetMusicPitch( music, ( float ) hb_parnd( 2 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // float GetMusicTimeLength(Music music); // Get music time length (in seconds) +HB_FUNC( GETMUSICTIMELENGTH ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 ) + { + Music music; + + //AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + music.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + music.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + music.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + music.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + music.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + music.looping = hb_arrayGetL( pItem, 3 ); + music.ctxType = hb_arrayGetNI( pItem, 4 ); + music.ctxData = hb_arrayGetPtr( pItem, 5 ); + + hb_retnd( ( float ) GetMusicTimeLength( music ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // float GetMusicTimePlayed(Music music); // Get current music time played (in seconds) +HB_FUNC( GETMUSICTIMEPLAYED ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 ) + { + Music music; + + //AudioStream stream + PHB_ITEM pSubarrayAudioStream = hb_arrayGetItemPtr( pItem, 1 ); + + music.stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pSubarrayAudioStream, 1 ); + music.stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 2 ); + music.stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 3 ); + music.stream.channels = ( unsigned int ) hb_arrayGetNI( pSubarrayAudioStream, 4 ); + + music.frameCount = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + music.looping = hb_arrayGetL( pItem, 3 ); + music.ctxType = hb_arrayGetNI( pItem, 4 ); + music.ctxData = hb_arrayGetPtr( pItem, 5 ); + + hb_retnd( ( float ) GetMusicTimePlayed( music ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} // AudioStream management functions -// AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Init audio stream (to stream raw audio pcm data) -// void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data -// void CloseAudioStream(AudioStream stream); // Close audio stream and free memory + +// AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels); // Load audio stream (to stream raw audio pcm data) +HB_FUNC( LOADAUDIOSTREAM ) +{ + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL ) + { + AudioStream stream = LoadAudioStream( ( unsigned int ) hb_parni( 1 ), ( unsigned int ) hb_parni( 2 ), ( unsigned int ) hb_parni( 3 ) ); + + PHB_ITEM pInitAudioStreamArray = hb_itemArrayNew( 4 ); + + hb_arraySetPtr( pInitAudioStreamArray, 1, ( rAudioBuffer * ) stream.buffer ); + hb_arraySetNI( pInitAudioStreamArray, 2, ( unsigned int ) stream.sampleRate ); + hb_arraySetNI( pInitAudioStreamArray, 3, ( unsigned int ) stream.sampleSize ); + hb_arraySetNI( pInitAudioStreamArray, 4, ( unsigned int ) stream.channels ); + + hb_itemReturnRelease( pInitAudioStreamArray ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void UnloadAudioStream(AudioStream stream); // Unload audio stream and free memory +HB_FUNC( UNLOADAUDIOSTREAM ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 ) + { + AudioStream stream; + + stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pItem, 1 ); + stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + stream.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + + UnloadAudioStream( stream ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + + +// void UpdateAudioStream(AudioStream stream, const void *data, int frameCount); // Update audio stream buffers with data +HB_FUNC( UPDATEAUDIOSTREAM ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 && + hb_param( 2, HB_IT_POINTER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL ) + { + AudioStream stream; + + stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pItem, 1 ); + stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + stream.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + + UpdateAudioStream( stream, hb_parptr( 2 ), hb_parni( 3 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // bool IsAudioStreamProcessed(AudioStream stream); // Check if any audio stream buffers requires refill +HB_FUNC( ISAUDIOSTREAMPROCESSED ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 ) + { + AudioStream stream; + + stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pItem, 1 ); + stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + stream.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + + hb_retl( IsAudioStreamProcessed( stream ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void PlayAudioStream(AudioStream stream); // Play audio stream +HB_FUNC( PLAYAUDIOSTREAM ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 ) + { + AudioStream stream; + + stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pItem, 1 ); + stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + stream.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + + PlayAudioStream( stream ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void PauseAudioStream(AudioStream stream); // Pause audio stream +HB_FUNC( PAUSEAUDIOSTREAM ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 ) + { + AudioStream stream; + + stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pItem, 1 ); + stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + stream.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + + PauseAudioStream( stream ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void ResumeAudioStream(AudioStream stream); // Resume audio stream +HB_FUNC( RESUMEAUDIOSTREAM ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 ) + { + AudioStream stream; + + stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pItem, 1 ); + stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + stream.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + + ResumeAudioStream( stream ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // bool IsAudioStreamPlaying(AudioStream stream); // Check if audio stream is playing +HB_FUNC( ISAUDIOSTREAMPLAYING ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 ) + { + AudioStream stream; + + stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pItem, 1 ); + stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + stream.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + + hb_retl( IsAudioStreamPlaying( stream ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void StopAudioStream(AudioStream stream); // Stop audio stream +HB_FUNC( STOPAUDIOSTREAM ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 ) + { + AudioStream stream; + + stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pItem, 1 ); + stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + stream.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + + StopAudioStream( stream ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void SetAudioStreamVolume(AudioStream stream, float volume); // Set volume for audio stream (1.0 is max level) +HB_FUNC( SETAUDIOSTREAMVOLUME ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 && + hb_param( 2, HB_IT_NUMERIC ) != NULL ) + { + AudioStream stream; + + stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pItem, 1 ); + stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + stream.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + + SetAudioStreamVolume( stream, ( float ) hb_parnd( 2 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void SetAudioStreamPitch(AudioStream stream, float pitch); // Set pitch for audio stream (1.0 is base level) +HB_FUNC( SetAudioStreamPitch ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 && + hb_param( 2, HB_IT_NUMERIC ) != NULL ) + { + AudioStream stream; + + stream.buffer = ( rAudioBuffer * ) hb_arrayGetPtr( pItem, 1 ); + stream.sampleRate = ( unsigned int ) hb_arrayGetNI( pItem, 2 ); + stream.sampleSize = ( unsigned int ) hb_arrayGetNI( pItem, 3 ); + stream.channels = ( unsigned int ) hb_arrayGetNI( pItem, 4 ); + + SetAudioStreamPitch( stream, ( float ) hb_parnd( 2 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams +HB_FUNC( SETAUDIOSTREAMBUFFERSIZEDEFAULT ) +{ + if( hb_param( 1, HB_IT_INTEGER ) != NULL ) + { + SetAudioStreamBufferSizeDefault( hb_parni( 1 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} diff --git a/src/core.c b/src/core.c index f163419..20373c2 100644 --- a/src/core.c +++ b/src/core.c @@ -1,6 +1,6 @@ /* * RayLib library: core.c - * version 3.5 + * version 3.7 * * Copyright 2020 - 2021 RafaÅ‚ Jopek ( rafaljopek at hotmail com ) * @@ -9,7 +9,7 @@ #include "hbraylib.h" /* --- Image* support --- */ -static HB_GARBAGE_FUNC( hb_raylib_destructor ) +static HB_GARBAGE_FUNC( hb_image_destructor ) { Image ** ppImage = ( Image ** ) Cargo; @@ -19,15 +19,15 @@ static HB_GARBAGE_FUNC( hb_raylib_destructor ) } } -static const HB_GC_FUNCS s_gcRaylibFuncs = +static const HB_GC_FUNCS s_gcImageFuncs = { - hb_raylib_destructor, + hb_image_destructor, hb_gcDummyMark }; -Image * hb_raylib_param( int iParam ) +Image * hb_image_param( int iParam ) { - Image ** ppImage = ( Image ** ) hb_parptrGC( &s_gcRaylibFuncs, iParam ); + Image ** ppImage = ( Image ** ) hb_parptrGC( &s_gcImageFuncs, iParam ); if( ppImage && *ppImage ) { diff --git a/src/hb.c b/src/hb.c new file mode 100644 index 0000000..e1537a8 --- /dev/null +++ b/src/hb.c @@ -0,0 +1,24 @@ +/* + * RayLib library: hb.c + * version 3.7 + * + * Copyright 2020 - 2021 RafaÅ‚ Jopek ( rafaljopek at hotmail com ) + * + */ + +#include "hbraylib.h" + +HB_FUNC( LTON ) +{ + hb_retni( hb_parl( 1 ) ); +} + +HB_FUNC( NTOL ) +{ + hb_retl( hb_parni( 1 ) ); +} + +HB_FUNC( INTTOF ) +{ + hb_retnd( ( float ) hb_parni( 1 ) ); +} diff --git a/src/hbraygui.c b/src/hbraygui.c new file mode 100644 index 0000000..b8c9cbc --- /dev/null +++ b/src/hbraygui.c @@ -0,0 +1,366 @@ +/* + * RayLib library: hbraylib.c + * version 3.7 + * + * Copyright 2020 - 2021 RafaÅ‚ Jopek ( rafaljopek at hotmail com ) + * + */ + +#include "hbraylib.h" + +// Global gui modification functions +// void GuiEnable(void); // Enable gui controls (global state) +// void GuiDisable(void); // Disable gui controls (global state) +// void GuiLock(void); // Lock gui controls (global state) +// void GuiUnlock(void); // Unlock gui controls (global state) +// void GuiFade(float alpha); // Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f + +// void GuiSetState(int state); // Set gui state (global state) +// int GuiGetState(void); // Get gui state (global state) + +// void GuiSetFont(Font font); // Set gui custom font (global state) +// Font GuiGetFont(void); // Get gui custom font (global state) + +// Style set/get functions + +void GuiSetStyle( int control, int property, int value ); // Set one style property +HB_FUNC( GUISETSTYLE ) +{ + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL ) + { + GuiSetStyle( hb_parni( 1 ), hb_parni( 2 ), hb_parni( 3 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +int GuiGetStyle( int control, int property ); // Get one style property +HB_FUNC( GUIGETSTYLE ) +{ + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) + { + hb_retni( GuiGetStyle( hb_parni( 1 ), hb_parni( 2 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// #if defined(RAYGUI_TEXTBOX_EXTENDED) +// GuiTextBox() extended functions +// void GuiTextBoxSetActive(Rectangle bounds); // Sets the active textbox +// Rectangle GuiTextBoxGetActive(void); // Get bounds of active textbox +// void GuiTextBoxSetCursor(int cursor); // Set cursor position of active textbox +// int GuiTextBoxGetCursor(void); // Get cursor position of active textbox +// void GuiTextBoxSetSelection(int start, int length); // Set selection of active textbox +// Vector2 GuiTextBoxGetSelection(void); // Get selection of active textbox (x - selection start y - selection length) +// bool GuiTextBoxIsActive(Rectangle bounds); // Returns true if a textbox control with specified `bounds` is the active textbox +// GuiTextBoxState GuiTextBoxGetState(void); // Get state for the active textbox +// void GuiTextBoxSetState(GuiTextBoxState state); // Set state for the active textbox (state must be valid else things will break) +// void GuiTextBoxSelectAll(const char *text); // Select all characters in the active textbox (same as pressing `CTRL` + `A`) +// void GuiTextBoxCopy(const char *text); // Copy selected text to clipboard from the active textbox (same as pressing `CTRL` + `C`) +// void GuiTextBoxPaste(char *text, int textSize); // Paste text from clipboard into the textbox (same as pressing `CTRL` + `V`) +// void GuiTextBoxCut(char *text); // Cut selected text in the active textbox and copy it to clipboard (same as pressing `CTRL` + `X`) +// int GuiTextBoxDelete(char *text, int length, bool before); // Deletes a character or selection before from the active textbox (depending on `before`). Returns bytes deleted. +// int GuiTextBoxGetByteIndex(const char *text, int start, int from, int to); // Get the byte index for a character starting at position `from` with index `start` until position `to`. +// #endif + +// Container/separator controls, useful for controls organization + +bool GuiWindowBox( Rectangle bounds, const char *title ); // Window Box control, shows a window that can be closed +HB_FUNC( GUIWINDOWBOX ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 && hb_param( 2, HB_IT_STRING ) != NULL ) + { + Rectangle bounds; + + bounds.x = ( float ) hb_arrayGetND( pItem, 1 ); + bounds.y = ( float ) hb_arrayGetND( pItem, 2 ); + bounds.width = ( float ) hb_arrayGetND( pItem, 3 ); + bounds.height = ( float ) hb_arrayGetND( pItem, 4 ); + + hb_retl( GuiWindowBox( bounds, hb_parc( 2 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +void GuiGroupBox( Rectangle bounds, const char *text ); // Group Box control with text name +HB_FUNC( GUIGROUPBOX ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 && hb_param( 2, HB_IT_STRING ) != NULL ) + { + Rectangle bounds; + + bounds.x = ( float ) hb_arrayGetND( pItem, 1 ); + bounds.y = ( float ) hb_arrayGetND( pItem, 2 ); + bounds.width = ( float ) hb_arrayGetND( pItem, 3 ); + bounds.height = ( float ) hb_arrayGetND( pItem, 4 ); + + GuiGroupBox( bounds, hb_parc( 2 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void GuiLine(Rectangle bounds, const char *text); // Line separator control, could contain text +// void GuiPanel(Rectangle bounds); // Panel control, useful to group controls + +Rectangle GuiScrollPanel( Rectangle bounds, Rectangle content, Vector2 *scroll ); // Scroll Panel control +HB_FUNC( GUISCROLLPANEL ) +{ + PHB_ITEM pItem1, pItem2, pItem3 ; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 4 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 && + ( pItem3 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 2 ) + { + Rectangle bounds; + + bounds.x = ( float ) hb_arrayGetND( pItem1, 1 ); + bounds.y = ( float ) hb_arrayGetND( pItem1, 2 ); + bounds.width = ( float ) hb_arrayGetND( pItem1, 3 ); + bounds.height = ( float ) hb_arrayGetND( pItem1, 4 ); + + Rectangle content; + + content.x = ( float ) hb_arrayGetND( pItem2, 1 ); + content.y = ( float ) hb_arrayGetND( pItem2, 2 ); + content.width = ( float ) hb_arrayGetND( pItem2, 3 ); + content.height = ( float ) hb_arrayGetND( pItem2, 4 ); + + Vector2 scroll; + + scroll.x = ( float ) hb_arrayGetND( pItem3, 1 ); + scroll.y = ( float ) hb_arrayGetND( pItem3, 2 ); + + Rectangle rec = GuiScrollPanel( bounds, content, &scroll ); + + PHB_ITEM info = hb_itemArrayNew( 4 ); + + hb_arraySetND( info, 1, ( float ) rec.x ); + hb_arraySetND( info, 2, ( float ) rec.y ); + hb_arraySetND( info, 3, ( float ) rec.width ); + hb_arraySetND( info, 4, ( float ) rec.height ); + + hb_itemReturnRelease( info ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// Basic controls set + +void GuiLabel( Rectangle bounds, const char *text ); // Label control, shows text +HB_FUNC( GUILABEL ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 && hb_param( 2, HB_IT_STRING ) != NULL ) + { + Rectangle bounds; + + bounds.x = ( float ) hb_arrayGetND( pItem, 1 ); + bounds.y = ( float ) hb_arrayGetND( pItem, 2 ); + bounds.width = ( float ) hb_arrayGetND( pItem, 3 ); + bounds.height = ( float ) hb_arrayGetND( pItem, 4 ); + + GuiLabel( bounds, hb_parc( 2 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// bool GuiButton(Rectangle bounds, const char *text); // Button control, returns true when clicked +// bool GuiLabelButton(Rectangle bounds, const char *text); // Label button control, show true when clicked +// bool GuiImageButton(Rectangle bounds, const char *text, Texture2D texture); // Image button control, returns true when clicked +// bool GuiImageButtonEx(Rectangle bounds, const char *text, Texture2D texture, Rectangle texSource); // Image button extended control, returns true when clicked + +bool GuiToggle( Rectangle bounds, const char *text, bool active ); // Toggle Button control, returns true when active +HB_FUNC( GUITOGGLE ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 && + hb_param( 2, HB_IT_STRING ) != NULL && + hb_param( 3, HB_IT_LOGICAL ) != NULL ) + { + Rectangle bounds; + + bounds.x = ( float ) hb_arrayGetND( pItem, 1 ); + bounds.y = ( float ) hb_arrayGetND( pItem, 2 ); + bounds.width = ( float ) hb_arrayGetND( pItem, 3 ); + bounds.height = ( float ) hb_arrayGetND( pItem, 4 ); + + hb_retl( GuiToggle( bounds, hb_parc( 2 ), hb_parl( 3 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// int GuiToggleGroup(Rectangle bounds, const char *text, int active); // Toggle Group control, returns active toggle index + +bool GuiCheckBox( Rectangle bounds, const char *text, bool checked ); // Check Box control, returns true when active +HB_FUNC( GUICHECKBOX ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 && + hb_param( 2, HB_IT_STRING ) != NULL && + hb_param( 3, HB_IT_LOGICAL ) != NULL ) + { + Rectangle bounds; + + bounds.x = ( float ) hb_arrayGetND( pItem, 1 ); + bounds.y = ( float ) hb_arrayGetND( pItem, 2 ); + bounds.width = ( float ) hb_arrayGetND( pItem, 3 ); + bounds.height = ( float ) hb_arrayGetND( pItem, 4 ); + + hb_retl( GuiCheckBox( bounds, hb_parc( 2 ), hb_parl( 3 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// int GuiComboBox(Rectangle bounds, const char *text, int active); // Combo Box control, returns selected item index +// bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMode); // Dropdown Box control, returns selected item + +bool GuiSpinner( Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode ); // Spinner control, returns selected value +HB_FUNC( GUISPINNER ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 && + hb_param( 2, HB_IT_STRING ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL && + hb_param( 4, HB_IT_INTEGER ) != NULL && + hb_param( 5, HB_IT_INTEGER ) != NULL && + hb_param( 6, HB_IT_LOGICAL ) != NULL ) + { + Rectangle bounds; + + bounds.x = ( float ) hb_arrayGetND( pItem, 1 ); + bounds.y = ( float ) hb_arrayGetND( pItem, 2 ); + bounds.width = ( float ) hb_arrayGetND( pItem, 3 ); + bounds.height = ( float ) hb_arrayGetND( pItem, 4 ); + + int value; + hb_retl( GuiSpinner( bounds, hb_parc( 2 ), &value, hb_parni( 4 ), hb_parni( 5 ), hb_parl( 6 ) ) ); + hb_storni( value, 3 ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode); // Value Box control, updates input text with numbers +// bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode); // Text Box control, updates input text +// bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode); // Text Box control with multiple lines +// float GuiSlider(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue); // Slider control, returns selected value + +float GuiSliderBar( Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue ); // Slider Bar control, returns selected value +HB_FUNC( GUISLIDERBAR ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 && + hb_param( 2, HB_IT_STRING ) != NULL && + hb_param( 2, HB_IT_STRING ) != NULL && + hb_param( 4, HB_IT_NUMERIC ) != NULL && + hb_param( 5, HB_IT_NUMERIC ) != NULL && + hb_param( 6, HB_IT_NUMERIC ) != NULL ) + { + Rectangle bounds; + + bounds.x = ( float ) hb_arrayGetND( pItem, 1 ); + bounds.y = ( float ) hb_arrayGetND( pItem, 2 ); + bounds.width = ( float ) hb_arrayGetND( pItem, 3 ); + bounds.height = ( float ) hb_arrayGetND( pItem, 4 ); + + hb_retnd( ( float ) GuiSliderBar( bounds, hb_parc( 2 ), hb_parc( 3 ), ( float ) hb_parnd( 4 ), ( float ) hb_parnd( 5 ), ( float ) hb_parnd( 6 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue); // Progress Bar control, shows current progress value +// void GuiStatusBar(Rectangle bounds, const char *text); // Status Bar control, shows info text +// void GuiDummyRec(Rectangle bounds, const char *text); // Dummy control for placeholders +// int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue); // Scroll Bar control + +Vector2 GuiGrid( Rectangle bounds, float spacing, int subdivs ); // Grid control +HB_FUNC( GUIGRID ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 && + hb_param( 2, HB_IT_NUMERIC ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL ) + { + Rectangle bounds; + + bounds.x = ( float ) hb_arrayGetND( pItem, 1 ); + bounds.y = ( float ) hb_arrayGetND( pItem, 2 ); + bounds.width = ( float ) hb_arrayGetND( pItem, 3 ); + bounds.height = ( float ) hb_arrayGetND( pItem, 4 ); + + Vector2 vector2 = GuiGrid( bounds, ( float ) hb_parnd( 2 ), hb_parni( 3 ) ); + + PHB_ITEM info = hb_itemArrayNew( 2 ); + + hb_arraySetNI( info, 1, ( float ) vector2.x ); + hb_arraySetNI( info, 2, ( float ) vector2.y ); + + hb_itemReturnRelease( info ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// Advance controls set +// int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int active); // List View control, returns selected list item index +// int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, int *scrollIndex, int active); // List View with extended parameters +// int GuiMessageBox(Rectangle bounds, const char *title, const char *message, const char *buttons); // Message Box control, displays a message +// int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text); // Text Input Box control, ask for text +// Color GuiColorPicker(Rectangle bounds, Color color); // Color Picker control + +// Styles loading functions +// void GuiLoadStyle(const char *fileName); // Load style file (.rgs) +// void GuiLoadStyleProps(const int *props, int count); // Load style properties from array +// void GuiLoadStyleDefault(void); // Load style default over global style +// void GuiUpdateStyleComplete(void); // Updates full style properties set with default values + +/* +typedef GuiStyle (unsigned int *) +// GuiStyle LoadGuiStyle(const char *fileName); // Load style from file (.rgs) +// void UnloadGuiStyle(GuiStyle style); // Unload style +*/ + +// const char *GuiIconText(int iconId, const char *text); // Get text with icon id prepended diff --git a/src/hbraylib.c b/src/hbraylib.c index 3f67e4c..af93534 100644 --- a/src/hbraylib.c +++ b/src/hbraylib.c @@ -1,6 +1,6 @@ /* * RayLib library: hbraylib.c - * version 3.5 + * version 3.7 * * Copyright 2020 - 2021 RafaÅ‚ Jopek ( rafaljopek at hotmail com ) * diff --git a/src/hbraylib.prg b/src/hbraylib.prg index 05f4516..f032d9f 100644 --- a/src/hbraylib.prg +++ b/src/hbraylib.prg @@ -1,8 +1,8 @@ /* * RayLib library: hbraylib.prg - * version 3.5 + * version 3.7 * - * Copyright 2020 RafaÅ‚ Jopek ( rafaljopek at hotmail com ) + * Copyright 2021 RafaÅ‚ Jopek ( rafaljopek at hotmail com ) * */ diff --git a/src/models.c b/src/models.c index 5fd79dc..b7eeaec 100644 --- a/src/models.c +++ b/src/models.c @@ -1,6 +1,6 @@ /* * RayLib library: models.c - * version 3.5 + * version 3.7 * * Copyright 2020 -2021 RafaÅ‚ Jopek ( rafaljopek at hotmail com ) * @@ -9,50 +9,619 @@ #include "hbraylib.h" //------------------------------------------------------------------------------------ -// Model 3d Loading and Drawing Functions (Module: models) +// Basic 3d Shapes Drawing Functions (Module: models) //------------------------------------------------------------------------------------ -// Model loading/unloading functions -// Model LoadModel(const char *fileName); // Load model from files (meshes and materials) -// Model LoadModelFromMesh(Mesh mesh); // Load model from generated mesh (default material) -// void UnloadModel(Model model); // Unload model (including meshes) from memory (RAM and/or VRAM) -// void UnloadModelKeepMeshes(Model model); // Unload model (but not meshes) from memory (RAM and/or VRAM) +// Basic geometric 3D shapes drawing functions -// Mesh loading/unloading functions -// Mesh *LoadMeshes(const char *fileName, int *meshCount); // Load meshes from model file -// void UnloadMesh(Mesh mesh); // Unload mesh from memory (RAM and/or VRAM) -// bool ExportMesh(Mesh mesh, const char *fileName); // Export mesh data to file, returns true on success +// void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space +HB_FUNC( DRAWLINE3D ) +{ + PHB_ITEM pItem1, pItem2, pItem3; -// Material loading/unloading functions -// Material *LoadMaterials(const char *fileName, int *materialCount); // Load materials from model file -// Material LoadMaterialDefault(void); // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) -// void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM) -// void SetMaterialTexture(Material *material, int mapType, Texture2D texture); // Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...) -// void SetModelMeshMaterial(Model *model, int meshId, int materialId); // Set material for a mesh + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 3 && + ( pItem3 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 4 ) + { + Vector3 startPos; -// Model animations loading/unloading functions -// ModelAnimation *LoadModelAnimations(const char *fileName, int *animsCount); // Load model animations from file -// void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); // Update model animation pose -// void UnloadModelAnimation(ModelAnimation anim); // Unload animation data -// bool IsModelAnimationValid(Model model, ModelAnimation anim); // Check model animation skeleton match + startPos.x = ( float ) hb_arrayGetND( pItem1, 1 ); + startPos.y = ( float ) hb_arrayGetND( pItem1, 2 ); + startPos.z = ( float ) hb_arrayGetND( pItem1, 3 ); -// Mesh generation functions -// Mesh GenMeshPoly(int sides, float radius); // Generate polygonal mesh -// Mesh GenMeshPlane(float width, float length, int resX, int resZ); // Generate plane mesh (with subdivisions) -// Mesh GenMeshCube(float width, float height, float length); // Generate cuboid mesh -// Mesh GenMeshSphere(float radius, int rings, int slices); // Generate sphere mesh (standard sphere) -// Mesh GenMeshHemiSphere(float radius, int rings, int slices); // Generate half-sphere mesh (no bottom cap) -// Mesh GenMeshCylinder(float radius, float height, int slices); // Generate cylinder mesh -// Mesh GenMeshTorus(float radius, float size, int radSeg, int sides); // Generate torus mesh -// Mesh GenMeshKnot(float radius, float size, int radSeg, int sides); // Generate trefoil knot mesh -// Mesh GenMeshHeightmap(Image heightmap, Vector3 size); // Generate heightmap mesh from image data -// Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); // Generate cubes-based map mesh from image data - -// Mesh manipulation functions -// BoundingBox MeshBoundingBox(Mesh mesh); // Compute mesh bounding box limits -// void MeshTangents(Mesh *mesh); // Compute mesh tangents -// void MeshBinormals(Mesh *mesh); // Compute mesh binormals -// void MeshNormalsSmooth(Mesh *mesh); // Smooth (average) vertex normals + Vector3 endPos; + + endPos.x = ( float ) hb_arrayGetND( pItem2, 1 ); + endPos.y = ( float ) hb_arrayGetND( pItem2, 2 ); + endPos.z = ( float ) hb_arrayGetND( pItem2, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem3, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem3, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem3, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem3, 4 ); + + DrawLine3D( startPos, endPos, color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawPoint3D(Vector3 position, Color color); // Draw a point in 3D space, actually a small line +HB_FUNC( DRAWPOINT3D ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + { + Vector3 position; + + position.x = ( float ) hb_arrayGetND( pItem1, 1 ); + position.y = ( float ) hb_arrayGetND( pItem1, 2 ); + position.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem2, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem2, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); + + DrawPoint3D( position, color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space +HB_FUNC( DRAWCIRCLE3D ) +{ + PHB_ITEM pItem1, pItem2, pItem3; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + hb_param( 2, HB_IT_NUMERIC ) != NULL && + ( pItem2 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 3 && + hb_param( 4, HB_IT_NUMERIC ) != NULL && + ( pItem3 = hb_param( 5, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 4 ) + { + Vector3 center; + + center.x = ( float ) hb_arrayGetND( pItem1, 1 ); + center.y = ( float ) hb_arrayGetND( pItem1, 2 ); + center.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Vector3 rotationAxis; + + rotationAxis.x = ( float ) hb_arrayGetND( pItem2, 1 ); + rotationAxis.y = ( float ) hb_arrayGetND( pItem2, 2 ); + rotationAxis.z = ( float ) hb_arrayGetND( pItem2, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem3, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem3, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem3, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem3, 4 ); + + DrawCircle3D( center, ( float ) hb_parnd( 2 ), rotationAxis, ( float ) hb_parnd( 4 ), color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color); // Draw a color-filled triangle (vertex in counter-clockwise order!) +HB_FUNC( DRAWTRIANGLE3D ) +{ + PHB_ITEM pItem1, pItem2, pItem3, pItem4; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 3 && + ( pItem3 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 3 && + ( pItem4 = hb_param( 4, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem4 ) == 4 ) + { + Vector3 v1; + + v1.x = ( float ) hb_arrayGetND( pItem1, 1 ); + v1.y = ( float ) hb_arrayGetND( pItem1, 2 ); + v1.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Vector3 v2; + + v2.x = ( float ) hb_arrayGetND( pItem2, 1 ); + v2.y = ( float ) hb_arrayGetND( pItem2, 2 ); + v2.z = ( float ) hb_arrayGetND( pItem2, 3 ); + + Vector3 v3; + + v3.x = ( float ) hb_arrayGetND( pItem3, 1 ); + v3.y = ( float ) hb_arrayGetND( pItem3, 2 ); + v3.z = ( float ) hb_arrayGetND( pItem3, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem4, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem4, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem4, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem4, 4 ); + + DrawTriangle3D( v1, v2, v3, color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawTriangleStrip3D(Vector3 *points, int pointsCount, Color color); // Draw a triangle strip defined by points +HB_FUNC( DRAWTRIANGLESTRIP3D ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + hb_param( 2, HB_IT_INTEGER ) != NULL && + ( pItem2 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + { + Vector3 points; + + points.x = ( float ) hb_arrayGetND( pItem1, 1 ); + points.y = ( float ) hb_arrayGetND( pItem1, 2 ); + points.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem2, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem2, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); + + DrawTriangleStrip3D( &points, hb_parni( 2 ), color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube +HB_FUNC( DRAWCUBE ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + hb_param( 2, HB_IT_NUMERIC ) != NULL && + hb_param( 3, HB_IT_NUMERIC ) != NULL && + hb_param( 4, HB_IT_NUMERIC ) != NULL && + ( pItem2 = hb_param( 5, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + { + Vector3 position; + + position.x = ( float ) hb_arrayGetND( pItem1, 1 ); + position.y = ( float ) hb_arrayGetND( pItem1, 2 ); + position.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem2, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem2, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); + + DrawCube( position, ( float ) hb_parnd( 2 ), ( float ) hb_parnd( 3 ), ( float ) hb_parnd( 4 ), color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version) +HB_FUNC( DRAWCUBEV ) +{ + PHB_ITEM pItem1, pItem2, pItem3; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 3 && + ( pItem3 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 4 ) + { + Vector3 position; + + position.x = ( float ) hb_arrayGetND( pItem1, 1 ); + position.y = ( float ) hb_arrayGetND( pItem1, 2 ); + position.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Vector3 size; + + size.x = ( float ) hb_arrayGetND( pItem2, 1 ); + size.y = ( float ) hb_arrayGetND( pItem2, 2 ); + size.z = ( float ) hb_arrayGetND( pItem2, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem3, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem3, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem3, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem3, 4 ); + + DrawCubeV( position, size, color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires +HB_FUNC( DRAWCUBEWIRES ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + hb_param( 2, HB_IT_NUMERIC ) != NULL && + hb_param( 3, HB_IT_NUMERIC ) != NULL && + hb_param( 4, HB_IT_NUMERIC ) != NULL && + ( pItem2 = hb_param( 5, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + { + Vector3 position; + + position.x = ( float ) hb_arrayGetND( pItem1, 1 ); + position.y = ( float ) hb_arrayGetND( pItem1, 2 ); + position.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem2, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem2, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); + + DrawCubeWires( position, ( float ) hb_parnd( 2 ), ( float ) hb_parnd( 3 ), ( float ) hb_parnd( 4 ), color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawCubeWiresV(Vector3 position, Vector3 size, Color color); // Draw cube wires (Vector version) +HB_FUNC( DRAWCUBEWIRESV ) +{ + PHB_ITEM pItem1, pItem2, pItem3; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 3 && + ( pItem3 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 4 ) + { + Vector3 position; + + position.x = ( float ) hb_arrayGetND( pItem1, 1 ); + position.y = ( float ) hb_arrayGetND( pItem1, 2 ); + position.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Vector3 size; + + size.x = ( float ) hb_arrayGetND( pItem2, 1 ); + size.y = ( float ) hb_arrayGetND( pItem2, 2 ); + size.z = ( float ) hb_arrayGetND( pItem2, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem3, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem3, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem3, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem3, 4 ); + + DrawCubeWiresV( position, size, color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color); // Draw cube textured +HB_FUNC( DRAWCUBETEXTURE ) +{ + PHB_ITEM pItem1, pItem2, pItem3; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 5 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 3 && + hb_param( 3, HB_IT_NUMERIC ) != NULL && + hb_param( 4, HB_IT_NUMERIC ) != NULL && + hb_param( 5, HB_IT_NUMERIC ) != NULL && + ( pItem3 = hb_param( 6, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 4 ) + { + Texture2D texture; + + texture.id = ( unsigned int ) hb_arrayGetNI( pItem1, 1 ); + texture.width = hb_arrayGetNI( pItem1, 2 ); + texture.height = hb_arrayGetNI( pItem1, 3 ); + texture.mipmaps = hb_arrayGetNI( pItem1, 4 ); + texture.format = hb_arrayGetNI( pItem1, 5 ); + + Vector3 position; + + position.x = ( float ) hb_arrayGetND( pItem2, 1 ); + position.y = ( float ) hb_arrayGetND( pItem2, 2 ); + position.z = ( float ) hb_arrayGetND( pItem2, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem3, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem3, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem3, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem3, 4 ); + + DrawCubeTexture( texture, position, ( float ) hb_parnd( 3 ), ( float ) hb_parnd( 4 ), ( float ) hb_parnd( 5 ), color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawSphere(Vector3 centerPos, float radius, Color color); // Draw sphere +HB_FUNC( DRAWSPHERE ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + hb_param( 2, HB_IT_NUMERIC ) != NULL && + ( pItem2 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + { + Vector3 centerPos; + + centerPos.x = ( float ) hb_arrayGetND( pItem1, 1 ); + centerPos.y = ( float ) hb_arrayGetND( pItem1, 2 ); + centerPos.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem2, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem2, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); + + DrawSphere( centerPos, ( float ) hb_parnd( 2 ), color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere with extended parameters +HB_FUNC( DRAWSPHEREEX ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + hb_param( 2, HB_IT_NUMERIC ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL && + hb_param( 4, HB_IT_INTEGER ) != NULL && + ( pItem2 = hb_param( 5, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + { + Vector3 centerPos; + + centerPos.x = ( float ) hb_arrayGetND( pItem1, 1 ); + centerPos.y = ( float ) hb_arrayGetND( pItem1, 2 ); + centerPos.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem2, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem2, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); + + DrawSphereEx( centerPos, ( float ) hb_parnd( 2 ), hb_parni( 3 ), hb_parni( 4 ), color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere wires +HB_FUNC( DRAWSPHEREWIRES ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + hb_param( 2, HB_IT_NUMERIC ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL && + hb_param( 4, HB_IT_INTEGER ) != NULL && + ( pItem2 = hb_param( 5, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + { + Vector3 centerPos; + + centerPos.x = ( float ) hb_arrayGetND( pItem1, 1 ); + centerPos.y = ( float ) hb_arrayGetND( pItem1, 2 ); + centerPos.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem2, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem2, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); + + DrawSphereWires( centerPos, ( float ) hb_parnd( 2 ), hb_parni( 3 ), hb_parni( 4 ), color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone +HB_FUNC( DRAWCYLINDER ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + hb_param( 2, HB_IT_NUMERIC ) != NULL && + hb_param( 3, HB_IT_NUMERIC ) != NULL && + hb_param( 4, HB_IT_NUMERIC ) != NULL && + hb_param( 5, HB_IT_INTEGER ) != NULL && + ( pItem2 = hb_param( 6, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + { + Vector3 position; + + position.x = ( float ) hb_arrayGetND( pItem1, 1 ); + position.y = ( float ) hb_arrayGetND( pItem1, 2 ); + position.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem2, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem2, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); + + DrawCylinder( position, ( float ) hb_parnd( 2 ), ( float ) hb_parnd( 3 ), ( float ) hb_parnd( 4 ), hb_parni( 5 ), color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color); // Draw a cylinder/cone wires +HB_FUNC( DRAWCYLINDERWIRES ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + hb_param( 2, HB_IT_NUMERIC ) != NULL && + hb_param( 3, HB_IT_NUMERIC ) != NULL && + hb_param( 4, HB_IT_NUMERIC ) != NULL && + hb_param( 5, HB_IT_INTEGER ) != NULL && + ( pItem2 = hb_param( 6, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + { + Vector3 position; + + position.x = ( float ) hb_arrayGetND( pItem1, 1 ); + position.y = ( float ) hb_arrayGetND( pItem1, 2 ); + position.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem2, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem2, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); + + DrawCylinderWires( position, ( float ) hb_parnd( 2 ), ( float ) hb_parnd( 3 ), ( float ) hb_parnd( 4 ), hb_parni( 5 ), color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawPlane(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XZ +HB_FUNC( DRAWPLANE ) +{ + PHB_ITEM pItem1, pItem2, pItem3; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 2 && + ( pItem3 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 4 ) + { + Vector3 centerPos; + + centerPos.x = ( float ) hb_arrayGetND( pItem1, 1 ); + centerPos.y = ( float ) hb_arrayGetND( pItem1, 2 ); + centerPos.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Vector2 size; + + size.x = ( float ) hb_arrayGetND( pItem2, 1 ); + size.y = ( float ) hb_arrayGetND( pItem2, 2 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem3, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem3, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem3, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem3, 4 ); + + DrawPlane( centerPos, size, color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawRay(Ray ray, Color color); // Draw a ray line +HB_FUNC( DRAWRAY ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 2 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + { + Ray ray; + + // Vector3 position + PHB_ITEM pSubarray1Vector3 = hb_arrayGetItemPtr( pItem1, 1 ); + + ray.position.x = ( float ) hb_arrayGetND( pSubarray1Vector3, 1 ); + ray.position.y = ( float ) hb_arrayGetND( pSubarray1Vector3, 2 ); + ray.position.z = ( float ) hb_arrayGetND( pSubarray1Vector3, 3 ); + + // Vector3 direction + PHB_ITEM pSubarray2Vector3 = hb_arrayGetItemPtr( pItem1, 2 ); + + ray.direction.x = ( float ) hb_arrayGetND( pSubarray2Vector3, 1 ); + ray.direction.y = ( float ) hb_arrayGetND( pSubarray2Vector3, 2 ); + ray.direction.z = ( float ) hb_arrayGetND( pSubarray2Vector3, 3 ); + + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem2, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem2, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); + + DrawRay( ray, color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0)) +HB_FUNC( DRAWGRID ) +{ + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_NUMERIC ) != NULL ) + { + DrawGrid( hb_parni( 1 ), ( float ) hb_parnd( 2 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +//Model loading/unloading functions + +// Model LoadModel(const char *fileName); // Load model from files (meshes and materials) +// Model LoadModelFromMesh(Mesh mesh); // Load model from generated mesh (default material) +// void UnloadModel(Model model); // Unload model (including meshes) from memory (RAM and/or VRAM) +// void UnloadModelKeepMeshes(Model model); // Unload model (but not meshes) from memory (RAM and/or VRAM) +// BoundingBox GetModelBoundingBox(Model model); // Compute model bounding box limits (considers all meshes) // Model drawing functions // void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set) @@ -60,17 +629,55 @@ // void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set) // void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters // void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires) -// void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture -// void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector3 center, float size, Color tint); // Draw a billboard texture defined by source +// void DrawBillboard(Camera camera, Texture2D texture, Vector3 position, float size, Color tint); // Draw a billboard texture +// void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Color tint); // Draw a billboard texture defined by source +// void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Vector2 origin, float rotation, Color tint); // Draw a billboard texture defined by source and rotation + +// Mesh management functions +// void UploadMesh(Mesh *mesh, bool dynamic); // Upload mesh vertex data in GPU and provide VAO/VBO ids +// void UpdateMeshBuffer(Mesh mesh, int index, void *data, int dataSize, int offset); // Update mesh vertex data in GPU for a specific buffer index +// void UnloadMesh(Mesh mesh); // Unload mesh data from CPU and GPU +// void DrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform +// void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int instances); // Draw multiple mesh instances with material and different transforms +// bool ExportMesh(Mesh mesh, const char *fileName); // Export mesh data to file, returns true on success +// BoundingBox GetMeshBoundingBox(Mesh mesh); // Compute mesh bounding box limits +// void GenMeshTangents(Mesh *mesh); // Compute mesh tangents +// void GenMeshBinormals(Mesh *mesh); // Compute mesh binormals + +// Mesh generation functions +// Mesh GenMeshPoly(int sides, float radius); // Generate polygonal mesh +// Mesh GenMeshPlane(float width, float length, int resX, int resZ); // Generate plane mesh (with subdivisions) +// Mesh GenMeshCube(float width, float height, float length); // Generate cuboid mesh +// Mesh GenMeshSphere(float radius, int rings, int slices); // Generate sphere mesh (standard sphere) +// Mesh GenMeshHemiSphere(float radius, int rings, int slices); // Generate half-sphere mesh (no bottom cap) +// Mesh GenMeshCylinder(float radius, float height, int slices); // Generate cylinder mesh +// Mesh GenMeshCone(float radius, float height, int slices); // Generate cone/pyramid mesh +// Mesh GenMeshTorus(float radius, float size, int radSeg, int sides); // Generate torus mesh +// Mesh GenMeshKnot(float radius, float size, int radSeg, int sides); // Generate trefoil knot mesh +// Mesh GenMeshHeightmap(Image heightmap, Vector3 size); // Generate heightmap mesh from image data +// Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); // Generate cubes-based map mesh from image data + +// Material loading/unloading functions +// Material *LoadMaterials(const char *fileName, int *materialCount); // Load materials from model file +// Material LoadMaterialDefault(void); // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) +// void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM) +// void SetMaterialTexture(Material *material, int mapType, Texture2D texture); // Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...) +// void SetModelMeshMaterial(Model *model, int meshId, int materialId); // Set material for a mesh + +// Model animations loading/unloading functions +// ModelAnimation *LoadModelAnimations(const char *fileName, int *animCount); // Load model animations from file +// void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); // Update model animation pose +// void UnloadModelAnimation(ModelAnimation anim); // Unload animation data +// void UnloadModelAnimations(ModelAnimation* animations, unsigned int count); // Unload animation array data +// bool IsModelAnimationValid(Model model, ModelAnimation anim); // Check model animation skeleton match // Collision detection functions -// bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2); // Detect collision between two spheres -// bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes -// bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Detect collision between box and sphere -// bool CheckCollisionRaySphere(Ray ray, Vector3 center, float radius); // Detect collision between ray and sphere -// bool CheckCollisionRaySphereEx(Ray ray, Vector3 center, float radius, Vector3 *collisionPoint); // Detect collision between ray and sphere, returns collision point -// bool CheckCollisionRayBox(Ray ray, BoundingBox box); // Detect collision between ray and box -// RayHitInfo GetCollisionRayMesh(Ray ray, Mesh mesh, Matrix transform); // Get collision info between ray and mesh -// RayHitInfo GetCollisionRayModel(Ray ray, Model model); // Get collision info between ray and model -// RayHitInfo GetCollisionRayTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); // Get collision info between ray and triangle -// RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight); // Get collision info between ray and ground plane (Y-normal plane) +// bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2); // Check collision between two spheres +// bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Check collision between two bounding boxes +// bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Check collision between box and sphere +// RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius); // Get collision info between ray and sphere +// RayCollision GetRayCollisionBox(Ray ray, BoundingBox box); // Get collision info between ray and box +// RayCollision GetRayCollisionModel(Ray ray, Model model); // Get collision info between ray and model +// RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform); // Get collision info between ray and mesh +// RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); // Get collision info between ray and triangle +// RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4); // Get collision info between ray and quad diff --git a/src/raylib-core.c b/src/raylib-core.c index d2e4544..a48a869 100644 --- a/src/raylib-core.c +++ b/src/raylib-core.c @@ -1,7 +1,8 @@ /* * RayLib library: raylib-core.c - * version 3.5 + * version 3.7 * + * Copyright 2021 Leonardo Mendez ( mlmgerencir at gmail com ) * Copyright 2020 - 2021 RafaÅ‚ Jopek ( rafaljopek at hotmail com ) * */ @@ -17,7 +18,9 @@ // void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context HB_FUNC( INITWINDOW ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL && hb_param( 3, HB_IT_STRING ) != NULL ) + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_STRING ) != NULL ) { InitWindow( hb_parni( 1 ), hb_parni( 2 ), hb_parc( 3 ) ); } @@ -83,19 +86,40 @@ HB_FUNC( ISWINDOWRESIZED ) // bool IsWindowState(unsigned int flag); // Check if one specific window flag is enabled HB_FUNC( ISWINDOWSTATE ) { - hb_retl( IsWindowState( ( unsigned int ) hb_parni( 1 ) ) ); + if( hb_param( 1, HB_IT_INTEGER ) != NULL ) + { + hb_retl( IsWindowState( ( unsigned int ) hb_parni( 1 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } } // void SetWindowState(unsigned int flags); // Set window configuration state using flags HB_FUNC( SETWINDOWSTATE ) { - SetWindowState( ( unsigned int ) hb_parni( 1 ) ); + if( hb_param( 1, HB_IT_INTEGER ) != NULL ) + { + SetWindowState( ( unsigned int ) hb_parni( 1 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } } // void ClearWindowState(unsigned int flags); // Clear window configuration state flags HB_FUNC( CLEARWINDOWSTATE ) { - ClearWindowState( ( unsigned int ) hb_parni( 1 ) ); + if( hb_param( 1, HB_IT_INTEGER ) != NULL ) + { + ClearWindowState( ( unsigned int ) hb_parni( 1 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } } // void ToggleFullscreen(void); // Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP) @@ -161,7 +185,8 @@ HB_FUNC( SETWINDOWTITLE ) // void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP) HB_FUNC( SETWINDOWPOSITION ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) { SetWindowPosition( hb_parni( 1 ), hb_parni( 2 ) ); } @@ -187,7 +212,8 @@ HB_FUNC( SETWINDOWMONITOR ) // void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) HB_FUNC( SETWINDOWMINSIZE ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) { SetWindowMinSize( hb_parni( 1 ), hb_parni( 2 ) ); } @@ -200,7 +226,8 @@ HB_FUNC( SETWINDOWMINSIZE ) // void SetWindowSize(int width, int height); // Set window dimensions HB_FUNC( SETWINDOWSIZE ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) { SetWindowSize( hb_parni( 1 ), hb_parni( 2 ) ); } @@ -234,6 +261,12 @@ HB_FUNC( GETMONITORCOUNT ) hb_retni( GetMonitorCount() ); } +// int GetCurrentMonitor(void); // Get current connected monitor +HB_FUNC( GETCURRENTMONITOR ) +{ + hb_retni( GetCurrentMonitor() ); +} + // Vector2 GetMonitorPosition(int monitor); // Get specified monitor position HB_FUNC( GETMONITORPOSITION ) { @@ -241,13 +274,12 @@ HB_FUNC( GETMONITORPOSITION ) { Vector2 vector2 = GetMonitorPosition( hb_parni( 1 ) ); - PHB_ITEM info = hb_itemArrayNew( 2 ); - - hb_arraySetNI( info, 1, ( float ) vector2.x ); - hb_arraySetNI( info, 2, ( float ) vector2.y ); + PHB_ITEM pVector2Array = hb_itemArrayNew( 2 ); - hb_itemReturnRelease( info ); + hb_arraySetNI( pVector2Array, 1, ( float ) vector2.x ); + hb_arraySetNI( pVector2Array, 2, ( float ) vector2.y ); + hb_itemReturnRelease( pVector2Array ); } else { @@ -320,31 +352,30 @@ HB_FUNC( GETMONITORREFRESHRATE ) } } - // Vector2 GetWindowPosition(void); // Get window position XY on monitor HB_FUNC( GETWINDOWPOSITION ) { - PHB_ITEM info = hb_itemArrayNew( 2 ); - Vector2 vector2 = GetWindowPosition(); - hb_arraySetNI( info, 1, ( float ) vector2.x ); - hb_arraySetNI( info, 2, ( float ) vector2.y ); + PHB_ITEM pVector2Array = hb_itemArrayNew( 2 ); - hb_itemReturnRelease( info ); + hb_arraySetNI( pVector2Array, 1, ( float ) vector2.x ); + hb_arraySetNI( pVector2Array, 2, ( float ) vector2.y ); + + hb_itemReturnRelease( pVector2Array ); } // Vector2 GetWindowScaleDPI(void); // Get window scale DPI factor -HB_FUNC( GetWindowScaleDPI ) +HB_FUNC( GETWINDOWSCALEDPI ) { - PHB_ITEM info = hb_itemArrayNew( 2 ); - Vector2 vector2 = GetWindowScaleDPI(); - hb_arraySetNI( info, 1, ( float ) vector2.x ); - hb_arraySetNI( info, 2, ( float ) vector2.y ); + PHB_ITEM pVector2Array = hb_itemArrayNew( 2 ); - hb_itemReturnRelease( info ); + hb_arraySetNI( pVector2Array, 1, ( float ) vector2.x ); + hb_arraySetNI( pVector2Array, 2, ( float ) vector2.y ); + + hb_itemReturnRelease( pVector2Array ); } // const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor @@ -386,6 +417,33 @@ HB_FUNC( GETCLIPBOARDTEXT ) } } +// Custom frame control functions + +// void SwapScreenBuffer(void); // Swap back buffer with front buffer (screen drawing) +HB_FUNC( SWAPSCREENBUFFER ) +{ + SwapScreenBuffer(); +} + +// void PollInputEvents(void); // Register all input events +HB_FUNC( POLLINPUTEVENTS ) +{ + PollInputEvents(); +} + +// void WaitTime(float ms); // Wait for some milliseconds (halt program execution) +HB_FUNC( WAITTIME ) +{ + if( hb_param( 1, HB_IT_NUMERIC ) != NULL ) + { + WaitTime( ( float ) hb_parnd( 1 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // Cursor-related functions // void ShowCursor(void); // Shows cursor @@ -418,75 +476,825 @@ HB_FUNC( DISABLECURSOR ) DisableCursor(); } -// bool IsCursorOnScreen(void); // Check if cursor is on the current screen. -HB_FUNC( ISCURSORONSCREEN ) +// bool IsCursorOnScreen(void); // Check if cursor is on the current screen. +HB_FUNC( ISCURSORONSCREEN ) +{ + hb_retl( IsCursorOnScreen() ); +} + +// Drawing-related functions + +// void ClearBackground(Color color); // Set background color (framebuffer clear color) +HB_FUNC( CLEARBACKGROUND ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 ) + { + Color color; + + color.r = ( unsigned char ) hb_arrayGetNI( pItem, 1 ); + color.g = ( unsigned char ) hb_arrayGetNI( pItem, 2 ); + color.b = ( unsigned char ) hb_arrayGetNI( pItem, 3 ); + color.a = ( unsigned char ) hb_arrayGetNI( pItem, 4 ); + + ClearBackground( color ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing +HB_FUNC( BEGINDRAWING ) +{ + BeginDrawing(); +} + +// void EndDrawing(void); // End canvas drawing and swap buffers (double buffering) +HB_FUNC( ENDDRAWING ) +{ + EndDrawing(); +} + +// void BeginMode2D(Camera2D camera); // Initialize 2D mode with custom camera (2D) +HB_FUNC( BEGINMODE2D ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 ) + { + Camera2D camera; + + //Vector2 offset + PHB_ITEM pSubarray1 = hb_arrayGetItemPtr( pItem, 1 ); + + camera.offset.x = ( float ) hb_arrayGetND( pSubarray1, 1 ); + camera.offset.y = ( float ) hb_arrayGetND( pSubarray1, 2 ); + + //Vector2 target + PHB_ITEM pSubarray2 = hb_arrayGetItemPtr( pItem, 2 ); + + camera.target.x = ( float ) hb_arrayGetND( pSubarray2, 1 ); + camera.target.y = ( float ) hb_arrayGetND( pSubarray2, 2 ); + + camera.rotation = ( float ) hb_arrayGetND( pItem, 3 ); + camera.zoom = ( float ) hb_arrayGetND( pItem, 4 ); + + BeginMode2D( camera ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void EndMode2D(void); // Ends 2D mode with custom camera +HB_FUNC( ENDMODE2D ) +{ + EndMode2D(); +} + + +// void BeginMode3D(Camera3D camera); // Initializes 3D mode with custom camera (3D) +HB_FUNC( BEGINMODE3D ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 ) + { + Camera3D camera; + + // Vector3 position + PHB_ITEM pSubarray1 = hb_arrayGetItemPtr( pItem, 1 ); + + camera.position.x = ( float ) hb_arrayGetND( pSubarray1, 1 ); + camera.position.y = ( float ) hb_arrayGetND( pSubarray1, 2 ); + camera.position.z = ( float ) hb_arrayGetND( pSubarray1, 3 ); + + // Vector3 target + PHB_ITEM pSubarray2 = hb_arrayGetItemPtr( pItem, 2 ); + + camera.target.x = ( float ) hb_arrayGetND( pSubarray2, 1 ); + camera.target.y = ( float ) hb_arrayGetND( pSubarray2, 2 ); + camera.target.z = ( float ) hb_arrayGetND( pSubarray2, 3 ); + + // Vector3 up + PHB_ITEM pSubarray3 = hb_arrayGetItemPtr( pItem, 3 ); + + camera.up.x = ( float ) hb_arrayGetND( pSubarray3, 1 ); + camera.up.y = ( float ) hb_arrayGetND( pSubarray3, 2 ); + camera.up.z = ( float ) hb_arrayGetND( pSubarray3, 3 ); + + camera.fovy = ( float ) hb_arrayGetND( pItem, 4 ); + camera.projection = hb_arrayGetNI( pItem, 5 ); + + BeginMode3D( camera ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void EndMode3D(void); // Ends 3D mode and returns to default 2D orthographic mode +HB_FUNC( ENDMODE3D ) +{ + EndMode3D(); +} + +// void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing +HB_FUNC( BEGINTEXTUREMODE ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 3 ) + { + RenderTexture2D target; + + target.id = ( unsigned int ) hb_arrayGetNI( pItem, 1 ); + + // Texture texture + PHB_ITEM pSubarray1 = hb_arrayGetItemPtr( pItem, 2 ); + + target.texture.id = ( unsigned int ) hb_arrayGetNI( pSubarray1, 1 ); + target.texture.width = hb_arrayGetNI( pSubarray1, 2 ); + target.texture.height = hb_arrayGetNI( pSubarray1, 3 ); + target.texture.mipmaps = hb_arrayGetNI( pSubarray1, 4 ); + target.texture.format = hb_arrayGetNI( pSubarray1, 5 ); + + // Texture depth + PHB_ITEM pSubarray2 = hb_arrayGetItemPtr( pItem, 3 ); + + target.depth.id = ( unsigned int ) hb_arrayGetNI( pSubarray2, 1 ); + target.depth.width = hb_arrayGetNI( pSubarray2, 2 ); + target.depth.height = hb_arrayGetNI( pSubarray2, 3 ); + target.depth.mipmaps = hb_arrayGetNI( pSubarray2, 4 ); + target.depth.format = hb_arrayGetNI( pSubarray2, 5 ); + + BeginTextureMode( target ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void EndTextureMode(void); // Ends drawing to render texture +HB_FUNC( ENDTEXTUREMODE ) +{ + EndTextureMode(); +} + +//void BeginShaderMode(Shader shader); // Begin custom shader drawing +//void EndShaderMode(void); // End custom shader drawing (use default shader) + +//void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied) +HB_FUNC( BEGINBLENDMODE ) +{ + if( hb_param( 1, HB_IT_INTEGER ) != NULL ) + { + BeginBlendMode( hb_parni( 1 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void EndBlendMode(void); // End blending mode (reset to default: alpha blending) +HB_FUNC( ENDBLENDMODE ) +{ + EndBlendMode(); +} + +// void BeginScissorMode(int x, int y, int width, int height); // Begin scissor mode (define screen area for following drawing) +HB_FUNC( BEGINSCISSORMODE ) +{ + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL && + hb_param( 4, HB_IT_INTEGER ) != NULL ) + { + BeginScissorMode( hb_parni( 1 ), hb_parni( 2 ), hb_parni( 3 ), hb_parni( 4 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void EndScissorMode(void); // End scissor mode +HB_FUNC( ENDSCISSORMODE ) +{ + EndScissorMode(); +} + +//void BeginVrStereoMode(VrStereoConfig config); // Begin stereo rendering +//void EndVrStereoMode(void); // End stereo rendering + +//VR stereo config functions for VR simulator + +//VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device); // Load VR stereo config for VR simulator device parameters +//void UnloadVrStereoConfig(VrStereoConfig config); // Unload VR stereo config + +//Shader management functions +//NOTE: Shader functionality is not available on OpenGL 1.1 + +//Shader LoadShader(const char *vsFileName, const char *fsFileName); // Load shader from files and bind default locations +//Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode); // Load shader from code strings and bind default locations +//int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location +//int GetShaderLocationAttrib(Shader shader, const char *attribName); // Get shader attribute location +//void SetShaderValue(Shader shader, int locIndex, const void *value, int uniformType); // Set shader uniform value +//void SetShaderValueV(Shader shader, int locIndex, const void *value, int uniformType, int count); // Set shader uniform value vector +//void SetShaderValueMatrix(Shader shader, int locIndex, Matrix mat); // Set shader uniform value (matrix 4x4) +//void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture); // Set shader uniform value for texture (sampler2d) +//void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM) + +// Screen-space-related functions + +// Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position +HB_FUNC( GETMOUSERAY ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 2 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 5 ) + { + Vector2 mousePosition; + + mousePosition.x = ( float ) hb_arrayGetND( pItem1, 1 ); + mousePosition.y = ( float ) hb_arrayGetND( pItem1, 2 ); + + Camera camera; + + // Vector3 position + PHB_ITEM pSubarray1 = hb_arrayGetItemPtr( pItem2, 1 ); + + camera.position.x = ( float ) hb_arrayGetND( pSubarray1, 1 ); + camera.position.y = ( float ) hb_arrayGetND( pSubarray1, 2 ); + camera.position.z = ( float ) hb_arrayGetND( pSubarray1, 3 ); + + // Vector3 target + PHB_ITEM pSubarray2 = hb_arrayGetItemPtr( pItem2, 2 ); + + camera.target.x = ( float ) hb_arrayGetND( pSubarray2, 1 ); + camera.target.y = ( float ) hb_arrayGetND( pSubarray2, 2 ); + camera.target.z = ( float ) hb_arrayGetND( pSubarray2, 3 ); + + // Vector3 up + PHB_ITEM pSubarray3 = hb_arrayGetItemPtr( pItem2, 3 ); + + camera.up.x = ( float ) hb_arrayGetND( pSubarray3, 1 ); + camera.up.y = ( float ) hb_arrayGetND( pSubarray3, 2 ); + camera.up.z = ( float ) hb_arrayGetND( pSubarray3, 3 ); + + camera.fovy = ( float ) hb_arrayGetND( pItem2, 4 ); + camera.projection = hb_arrayGetNI( pItem2, 5 ); + + Ray ray = GetMouseRay( mousePosition, camera ); + + PHB_ITEM pRayArray = hb_itemArrayNew( 2 ); + + // Vector3 position + PHB_ITEM pSubarray1Vector3 = hb_arrayGetItemPtr( pRayArray, 1 ); + + hb_arrayNew( pSubarray1Vector3, 3 ); + hb_arraySetND( pSubarray1Vector3, 1, ( float ) ray.position.x ); + hb_arraySetND( pSubarray1Vector3, 2, ( float ) ray.position.y ); + hb_arraySetND( pSubarray1Vector3, 3, ( float ) ray.position.z ); + + // VectVector3or3 direction + PHB_ITEM pSubarray2Vector3 = hb_arrayGetItemPtr( pRayArray, 2 ); + + hb_arrayNew( pSubarray2Vector3, 3 ); + hb_arraySetND( pSubarray2Vector3, 1, ( float ) ray.direction.x ); + hb_arraySetND( pSubarray2Vector3, 2, ( float ) ray.direction.y ); + hb_arraySetND( pSubarray2Vector3, 3, ( float ) ray.direction.z ); + + hb_itemReturnRelease( pRayArray ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix) +// Matrix GetCameraMatrix2D(Camera2D camera); // Returns camera 2d transform matrix + +// Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position +HB_FUNC( GETWORLDTOSCREEN ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 5 ) + { + Vector3 position; + + position.x = ( float ) hb_arrayGetND( pItem1, 1 ); + position.y = ( float ) hb_arrayGetND( pItem1, 2 ); + position.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Camera camera; + + // Vector3 position + PHB_ITEM pSubarray1 = hb_arrayGetItemPtr( pItem2, 1 ); + + camera.position.x = ( float ) hb_arrayGetND( pSubarray1, 1 ); + camera.position.y = ( float ) hb_arrayGetND( pSubarray1, 2 ); + camera.position.z = ( float ) hb_arrayGetND( pSubarray1, 3 ); + + // Vector3 target + PHB_ITEM pSubarray2 = hb_arrayGetItemPtr( pItem2, 2 ); + + camera.target.x = ( float ) hb_arrayGetND( pSubarray2, 1 ); + camera.target.y = ( float ) hb_arrayGetND( pSubarray2, 2 ); + camera.target.z = ( float ) hb_arrayGetND( pSubarray2, 3 ); + + // Vector3 up + PHB_ITEM pSubarray3 = hb_arrayGetItemPtr( pItem2, 3 ); + + camera.up.x = ( float ) hb_arrayGetND( pSubarray3, 1 ); + camera.up.y = ( float ) hb_arrayGetND( pSubarray3, 2 ); + camera.up.z = ( float ) hb_arrayGetND( pSubarray3, 3 ); + + camera.fovy = ( float ) hb_arrayGetND( pItem2, 4 ); + camera.projection = hb_arrayGetNI( pItem2, 5 ); + + Vector2 vector2 = GetWorldToScreen( position, camera ); + + PHB_ITEM pVector2Array = hb_itemArrayNew( 2 ); + + hb_arraySetNI( pVector2Array, 1, ( float ) vector2.x ); + hb_arraySetNI( pVector2Array, 2, ( float ) vector2.y ); + + hb_itemReturnRelease( pVector2Array ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height); // Returns size position for a 3d world space position +HB_FUNC( GETWORLDTOSCREENEX ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 3 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 5 && + hb_param( 3, HB_IT_INTEGER ) != NULL && + hb_param( 4, HB_IT_INTEGER ) != NULL) + { + Vector3 position; + + position.x = ( float ) hb_arrayGetND( pItem1, 1 ); + position.y = ( float ) hb_arrayGetND( pItem1, 2 ); + position.z = ( float ) hb_arrayGetND( pItem1, 3 ); + + Camera camera; + + // Vector3 position + PHB_ITEM pSubarray1 = hb_arrayGetItemPtr( pItem2, 1 ); + + camera.position.x = ( float ) hb_arrayGetND( pSubarray1, 1 ); + camera.position.y = ( float ) hb_arrayGetND( pSubarray1, 2 ); + camera.position.z = ( float ) hb_arrayGetND( pSubarray1, 3 ); + + // Vector3 target + PHB_ITEM pSubarray2 = hb_arrayGetItemPtr( pItem2, 2 ); + + camera.target.x = ( float ) hb_arrayGetND( pSubarray2, 1 ); + camera.target.y = ( float ) hb_arrayGetND( pSubarray2, 2 ); + camera.target.z = ( float ) hb_arrayGetND( pSubarray2, 3 ); + + // Vector3 up + PHB_ITEM pSubarray3 = hb_arrayGetItemPtr( pItem2, 3 ); + + camera.up.x = ( float ) hb_arrayGetND( pSubarray3, 1 ); + camera.up.y = ( float ) hb_arrayGetND( pSubarray3, 2 ); + camera.up.z = ( float ) hb_arrayGetND( pSubarray3, 3 ); + + camera.fovy = ( float ) hb_arrayGetND( pItem2, 4 ); + camera.projection = hb_arrayGetNI( pItem2, 5 ); + + Vector2 vector2 = GetWorldToScreenEx( position, camera, hb_parni( 3 ), hb_parni( 4 ) ); + + PHB_ITEM pVector2Array = hb_itemArrayNew( 2 ); + + hb_arraySetNI( pVector2Array, 1, ( float ) vector2.x ); + hb_arraySetNI( pVector2Array, 2, ( float ) vector2.y ); + + hb_itemReturnRelease( pVector2Array ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + + +// Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Returns the screen space position for a 2d camera world space position +HB_FUNC( GETWORLDTOSCREEN2D ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 2 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + { + Vector2 position; + + position.x = ( float ) hb_arrayGetND( pItem1, 1 ); + position.y = ( float ) hb_arrayGetND( pItem1, 2 ); + + Camera2D camera; + + //Vector2 offset + PHB_ITEM pSubarray1 = hb_arrayGetItemPtr( pItem1, 1 ); + + camera.offset.x = ( float ) hb_arrayGetND( pSubarray1, 1 ); + camera.offset.y = ( float ) hb_arrayGetND( pSubarray1, 2 ); + + //Vector2 target + PHB_ITEM pSubarray2 = hb_arrayGetItemPtr( pItem1, 2 ); + + camera.target.x = ( float ) hb_arrayGetND( pSubarray2, 1 ); + camera.target.y = ( float ) hb_arrayGetND( pSubarray2, 2 ); + + camera.rotation = ( float ) hb_arrayGetND( pItem1, 3 ); + camera.zoom = ( float ) hb_arrayGetND( pItem1, 3 ); + + Vector2 vector2 = GetWorldToScreen2D( position, camera ); + + PHB_ITEM pVector2Array = hb_itemArrayNew( 2 ); + + hb_arraySetNI( pVector2Array, 1, ( float ) vector2.x ); + hb_arraySetNI( pVector2Array, 2, ( float ) vector2.y ); + + hb_itemReturnRelease( pVector2Array ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Returns the world space position for a 2d camera screen space position +HB_FUNC( GETSCREENTOWORLD2D ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 2 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + { + Vector2 position; + + position.x = ( float ) hb_arrayGetND( pItem1, 1 ); + position.y = ( float ) hb_arrayGetND( pItem1, 2 ); + + Camera2D camera; + + //Vector2 offset + PHB_ITEM pSubarray1 = hb_arrayGetItemPtr( pItem1, 1 ); + + camera.offset.x = ( float ) hb_arrayGetND( pSubarray1, 1 ); + camera.offset.y = ( float ) hb_arrayGetND( pSubarray1, 2 ); + + //Vector2 target + PHB_ITEM pSubarray2 = hb_arrayGetItemPtr( pItem1, 2 ); + + camera.target.x = ( float ) hb_arrayGetND( pSubarray2, 1 ); + camera.target.y = ( float ) hb_arrayGetND( pSubarray2, 2 ); + + camera.rotation = ( float ) hb_arrayGetND( pItem1, 3 ); + camera.zoom = ( float ) hb_arrayGetND( pItem1, 3 ); + + Vector2 vector2 = GetScreenToWorld2D( position, camera ); + + PHB_ITEM pVector2Array = hb_itemArrayNew( 2 ); + + hb_arraySetNI( pVector2Array, 1, ( float ) vector2.x ); + hb_arraySetNI( pVector2Array, 2, ( float ) vector2.y ); + + hb_itemReturnRelease( pVector2Array ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// Timing-related functions + +// void SetTargetFPS(int fps); // Set target FPS (maximum) +HB_FUNC( SETTARGETFPS ) +{ + if( hb_param( 1, HB_IT_INTEGER ) != NULL ) + { + SetTargetFPS( hb_parni( 1 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// int GetFPS(void); // Returns current FPS +HB_FUNC( GETFPS ) +{ + hb_retni( GetFPS() ); +} + +// float GetFrameTime(void); // Returns time in seconds for last frame drawn +HB_FUNC( GETFRAMETIME ) +{ + hb_retnd( ( float ) GetFrameTime() ); +} + +// double GetTime(void); // Returns elapsed time in seconds since InitWindow() +HB_FUNC( GetTime ) +{ + hb_retnd( GetTime() ); +} + +// Misc. functions + +// int GetRandomValue(int min, int max); // Returns a random value between min and max (both included) +HB_FUNC( GETRANDOMVALUE ) +{ + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) + { + hb_retni( GetRandomValue( hb_parni( 1 ), hb_parni( 2 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (filename extension defines format) +HB_FUNC( TAKESCREENSHOT ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL ) + { + TakeScreenshot( hb_parc( 1 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void SetConfigFlags(unsigned int flags); // Setup init configuration flags (view FLAGS) +HB_FUNC( SETCONFIGFLAGS ) +{ + if( hb_param( 1, HB_IT_INTEGER ) != NULL ) + { + SetConfigFlags( ( unsigned int ) hb_parni( 1 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void TraceLog(int logType, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR) +HB_FUNC( TRACELOG ) +{ + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_STRING ) != NULL ) + { + TraceLog( hb_parni( 1 ), hb_parc( 2 ), hb_parni( 3 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void SetTraceLogLevel(int logType); // Set the current threshold (minimum) log level +HB_FUNC( SETTRACELOGLEVEL ) +{ + if( hb_param( 1, HB_IT_INTEGER ) != NULL ) + { + SetTraceLogLevel( hb_parni( 1 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void *MemAlloc(int size); // Internal memory allocator +HB_FUNC( MEMALLOC ) +{ + if( hb_param( 1, HB_IT_INTEGER ) != NULL ) + { + hb_retptr( MemAlloc( hb_parni( 1 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +//void *MemRealloc(void *ptr, int size); // Internal memory reallocator + +//void MemFree(void *ptr); // Internal memory free +HB_FUNC( MEMFREE ) +{ + if( hb_param( 1, HB_IT_POINTER ) != NULL ) + { + MemFree( hb_parptr( 1 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// Set custom callbacks +// WARNING: Callbacks setup is intended for advance users + +// void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log +// void SetLoadFileDataCallback(LoadFileDataCallback callback); // Set custom file binary data loader +// void SetSaveFileDataCallback(SaveFileDataCallback callback); // Set custom file binary data saver +// void SetLoadFileTextCallback(LoadFileTextCallback callback); // Set custom file text data loader +// void SetSaveFileTextCallback(SaveFileTextCallback callback); // Set custom file text data saver + +// Files management functions + +// unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read) +HB_FUNC( LOADFILEDATA ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL ) + { + unsigned int bytesRead; + hb_retptr( ( unsigned char * ) LoadFileData( hb_parc( 1 ), &bytesRead ) ); + hb_storni( bytesRead, 1 ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData() +HB_FUNC( UNLOADFILEDATA ) +{ + if( hb_param( 1, HB_IT_POINTER ) != NULL ) + { + UnloadFileData( ( unsigned char * ) hb_parptr( 1 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write), returns true on success +HB_FUNC( SAVEFILEDATA ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL && hb_param( 2, HB_IT_POINTER ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) + { + hb_retl( SaveFileData( hb_parc( 1 ), hb_parptr( 2 ), hb_parni( 3 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string +HB_FUNC( LOADFILETEXT ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL ) + { + hb_retc( LoadFileText( hb_parc( 1 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void UnloadFileText(char *text); // Unload file text data allocated by LoadFileText() +HB_FUNC( UNLOADFILETEXT ) +{ + if( hb_param( 1, HB_IT_POINTER ) != NULL ) + { + UnloadFileText( ( char * ) hb_parptr( 1 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success +HB_FUNC( SAVEFILETEXT ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL && + hb_param( 2, HB_IT_STRING ) != NULL ) + { + char text = ( char ) hb_parni( 2 ); + hb_retl( SaveFileText( hb_parc( 1 ), &text ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// bool FileExists(const char *fileName); // Check if file exists +HB_FUNC( FILEEXISTS ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL ) + { + hb_retl( FileExists( hb_parc( 1 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// bool DirectoryExists(const char *dirPath); // Check if a directory path exists +HB_FUNC( DIRECTORYEXISTS ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL ) + { + hb_retl( DirectoryExists( hb_parc( 1 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// bool IsFileExtension(const char *fileName, const char *ext);// Check file extension (including point: .png, .wav) +HB_FUNC( ISFILEEXTENSION ) { - hb_retl( IsCursorOnScreen() ); + if( hb_param( 1, HB_IT_STRING ) != NULL && + hb_param( 2, HB_IT_STRING ) != NULL ) + { + hb_retl( IsFileExtension( hb_parc( 1 ), hb_parc( 2 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } } -// Drawing-related functions - -// void ClearBackground(Color color); // Set background color (framebuffer clear color) -HB_FUNC( CLEARBACKGROUND ) +// const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (including point: ".png") +HB_FUNC( GETFILEEXTENSION ) { - PHB_ITEM pItem; - - if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 ) + if( hb_param( 1, HB_IT_STRING ) != NULL ) { - Color color; - - color.r = ( unsigned char ) hb_arrayGetNI( pItem, 1 ); - color.g = ( unsigned char ) hb_arrayGetNI( pItem, 2 ); - color.b = ( unsigned char ) hb_arrayGetNI( pItem, 3 ); - color.a = ( unsigned char ) hb_arrayGetNI( pItem, 4 ); - - ClearBackground( color ); + hb_retc( GetFileExtension( hb_parc( 1 ) ) ); } else { - hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } } -// void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing -HB_FUNC( BEGINDRAWING ) +// const char *GetFileName(const char *filePath); // Get pointer to filename for a path string +HB_FUNC( GETFILENAME ) { - BeginDrawing(); + if( hb_param( 1, HB_IT_STRING ) != NULL ) + { + hb_retc( GetFileName( hb_parc( 1 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } } -// void EndDrawing(void); // End canvas drawing and swap buffers (double buffering) -HB_FUNC( ENDDRAWING ) +// const char *GetFileNameWithoutExt(const char *filePath); // Get filename string without extension (uses static string) +HB_FUNC( GETFILENAMEWITHOUTEXT ) { - EndDrawing(); + if( hb_param( 1, HB_IT_STRING ) != NULL ) + { + hb_retc( GetFileNameWithoutExt( hb_parc( 1 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } } -// void BeginMode2D(Camera2D camera); // Initialize 2D mode with custom camera (2D) -// void EndMode2D(void); // Ends 2D mode with custom camera -// void BeginMode3D(Camera3D camera); // Initializes 3D mode with custom camera (3D) -// void EndMode3D(void); // Ends 3D mode and returns to default 2D orthographic mode -// void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing -// void EndTextureMode(void); // Ends drawing to render texture -// void BeginScissorMode(int x, int y, int width, int height); // Begin scissor mode (define screen area for following drawing) -// void EndScissorMode(void); // End scissor mode - -// Screen-space-related functions - -// Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position -// Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix) -// Matrix GetCameraMatrix2D(Camera2D camera); // Returns camera 2d transform matrix -// Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position -// Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height); // Returns size position for a 3d world space position -// Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Returns the screen space position for a 2d camera world space position -// Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Returns the world space position for a 2d camera screen space position - -// Timing-related functions - -// void SetTargetFPS(int fps); // Set target FPS (maximum) -HB_FUNC( SETTARGETFPS ) +// const char *GetDirectoryPath(const char *filePath); // Get full path for a given fileName with path (uses static string) +HB_FUNC( GETDIRECTORYPATH ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_STRING ) != NULL ) { - SetTargetFPS( hb_parni( 1 ) ); + hb_retc( GetDirectoryPath( hb_parc( 1 ) ) ); } else { @@ -494,32 +1302,43 @@ HB_FUNC( SETTARGETFPS ) } } -// int GetFPS(void); // Returns current FPS -HB_FUNC( GETFPS ) +// const char *GetPrevDirectoryPath(const char *dirPath); // Get previous directory path for a given path (uses static string) +HB_FUNC( GETPREVDIRECTORYPATH ) { - hb_retni( GetFPS() ); + if( hb_param( 1, HB_IT_STRING ) != NULL ) + { + hb_retc( GetPrevDirectoryPath( hb_parc( 1 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } } -// float GetFrameTime(void); // Returns time in seconds for last frame drawn -HB_FUNC( GETFRAMETIME ) +// const char *GetWorkingDirectory(void); // Get current working directory (uses static string) +HB_FUNC( GETWORKINGDIRECTORY ) { - hb_retnd( ( float ) GetFrameTime() ); + hb_retc( GetWorkingDirectory() ); } -// double GetTime(void); // Returns elapsed time in seconds since InitWindow() -HB_FUNC( GetTime ) +// char **GetDirectoryFiles(const char *dirPath, int *count); // Get filenames in a directory path (memory should be freed) +HB_FUNC( GETDIRECTORYFILES ) { - hb_retnd( GetTime() ); -} + if( hb_param( 1, HB_IT_STRING ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) + { + int count; + char ** files = GetDirectoryFiles( hb_parc( 1 ), &count ); + hb_storni( count, 1 ); -// Misc. functions + PHB_ITEM pFilesArray = hb_itemArrayNew( count ); -// void SetConfigFlags(unsigned int flags); // Setup init configuration flags (view FLAGS) -HB_FUNC( SETCONFIGFLAGS ) -{ - if( hb_param( 1, HB_IT_INTEGER ) != NULL ) - { - SetConfigFlags( ( unsigned int ) hb_parni( 1 ) ); + for( int i = 0; i < count; i++ ) + { + hb_arraySetC( pFilesArray, i + 1, files[ i ] ); + } + + hb_itemReturnRelease( pFilesArray ); } else { @@ -527,12 +1346,18 @@ HB_FUNC( SETCONFIGFLAGS ) } } -// void SetTraceLogLevel(int logType); // Set the current threshold (minimum) log level -HB_FUNC( SETTRACELOGLEVEL ) +// void ClearDirectoryFiles(void); // Clear directory files paths buffers (free memory) +HB_FUNC( CLEARDIRECTORYFILES ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL ) + ClearDirectoryFiles(); +} + +// bool ChangeDirectory(const char *dir); // Change working directory, return true on success +HB_FUNC( CHANGEDIRECTORY ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL ) { - SetTraceLogLevel( hb_parni( 1 ) ); + hb_retnl( ChangeDirectory( hb_parc( 1 ) ) ); } else { @@ -540,12 +1365,29 @@ HB_FUNC( SETTRACELOGLEVEL ) } } -// void SetTraceLogExit(int logType); // Set the exit threshold (minimum) log level -HB_FUNC( SETTRACELOGEXIT ) +// bool IsFileDropped(void); // Check if a file has been dropped into window +HB_FUNC( ISFILEDROPPED ) +{ + hb_retl( IsFileDropped() ); +} + +// char **GetDroppedFiles(int *count); // Get dropped files names (memory should be freed) +HB_FUNC( GETDROPPEDFILES ) { if( hb_param( 1, HB_IT_INTEGER ) != NULL ) { - SetTraceLogExit( hb_parni( 1 ) ); + int count; + char ** files = GetDroppedFiles( &count ); + hb_storni( count, 1 ); + + PHB_ITEM pFilesArray = hb_itemArrayNew( count ); + + for( int i = 0; i < count; i++ ) + { + hb_arraySetC( pFilesArray, i + 1, files[ i ] ); + } + + hb_itemReturnRelease( pFilesArray ); } else { @@ -553,27 +1395,18 @@ HB_FUNC( SETTRACELOGEXIT ) } } -// void SetTraceLogCallback(TraceLogCallback callback); // Set a trace log callback to enable custom logging -// void TraceLog(int logType, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR) - -// void *MemAlloc(int size); // Internal memory allocator -HB_FUNC( MEMALLOC ) -{ - hb_retptr( MemAlloc( hb_parni( 1 ) ) ); -} - -// void MemFree(void *ptr); // Internal memory free -HB_FUNC( MEMFREE ) +// void ClearDroppedFiles(void); // Clear dropped files paths buffer (free memory) +HB_FUNC( CLEARDROPPEDFILES ) { - MemFree( hb_parptr( 1 ) ); + ClearDroppedFiles(); } -// void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png) -HB_FUNC( TAKESCREENSHOT ) +// long GetFileModTime(const char *fileName); // Get file modification time (last write time) +HB_FUNC( GETFILEMODTIME ) { if( hb_param( 1, HB_IT_STRING ) != NULL ) { - TakeScreenshot( hb_parc( 1 ) ); + hb_retnl( GetFileModTime( hb_parc( 1 ) ) ); } else { @@ -581,12 +1414,16 @@ HB_FUNC( TAKESCREENSHOT ) } } -// int GetRandomValue(int min, int max); // Returns a random value between min and max (both included) -HB_FUNC( GETRANDOMVALUE ) +// unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLength); // Compress data (DEFLATE algorithm) +HB_FUNC( COMPRESSDATA ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_POINTER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL ) { - hb_retni( GetRandomValue( hb_parni( 1 ), hb_parni( 2 ) ) ); + int compDataLength; + hb_retptr( ( unsigned char * ) CompressData( ( unsigned char * ) hb_parptr( 1 ), hb_parni( 2 ), &compDataLength ) ); + hb_storni( compDataLength, 3 ); } else { @@ -594,43 +1431,32 @@ HB_FUNC( GETRANDOMVALUE ) } } -// Files management functions - -// unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read) - -// void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData() -// bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write), returns true on success -// char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string -// void UnloadFileText(unsigned char *text); // Unload file text data allocated by LoadFileText() -// bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success -// bool FileExists(const char *fileName); // Check if file exists -// bool DirectoryExists(const char *dirPath); // Check if a directory path exists -// bool IsFileExtension(const char *fileName, const char *ext);// Check file extension (including point: .png, .wav) -// const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (including point: ".png") -// const char *GetFileName(const char *filePath); // Get pointer to filename for a path string -// const char *GetFileNameWithoutExt(const char *filePath); // Get filename string without extension (uses static string) -// const char *GetDirectoryPath(const char *filePath); // Get full path for a given fileName with path (uses static string) -// const char *GetPrevDirectoryPath(const char *dirPath); // Get previous directory path for a given path (uses static string) -// const char *GetWorkingDirectory(void); // Get current working directory (uses static string) -// char **GetDirectoryFiles(const char *dirPath, int *count); // Get filenames in a directory path (memory should be freed) -// void ClearDirectoryFiles(void); // Clear directory files paths buffers (free memory) -// bool ChangeDirectory(const char *dir); // Change working directory, return true on success -// bool IsFileDropped(void); // Check if a file has been dropped into window -// char **GetDroppedFiles(int *count); // Get dropped files names (memory should be freed) -// void ClearDroppedFiles(void); // Clear dropped files paths buffer (free memory) -// long GetFileModTime(const char *fileName); // Get file modification time (last write time) - -// unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLength); // Compress data (DEFLATE algorithm) // unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *dataLength); // Decompress data (DEFLATE algorithm) +HB_FUNC( DECOMPRESSDATA ) +{ + if( hb_param( 1, HB_IT_POINTER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL ) + { + int dataLength; + hb_retptr( ( unsigned char * ) DecompressData( ( unsigned char * ) hb_parptr( 1 ), hb_parni( 2 ), &dataLength ) ); + hb_storni( dataLength, 3 ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} // Persistent storage management // bool SaveStorageValue(unsigned int position, int value); // Save integer value to storage file (to defined position), returns true on success HB_FUNC( SAVESTORAGEVALUE ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) { - SaveStorageValue( hb_parni( 1 ), hb_parni( 2 ) ); + SaveStorageValue( ( unsigned int) hb_parni( 1 ), hb_parni( 2 ) ); } else { @@ -643,7 +1469,7 @@ HB_FUNC( LOADSTORAGEVALUE ) { if( hb_param( 1, HB_IT_INTEGER ) != NULL ) { - hb_retni( LoadStorageValue( hb_parni( 1 ) ) ); + hb_retni( LoadStorageValue( ( unsigned int ) hb_parni( 1 ) ) ); } else { @@ -765,7 +1591,8 @@ HB_FUNC( ISGAMEPADAVAILABLE ) // bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available) HB_FUNC( ISGAMEPADNAME ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 1, HB_IT_STRING ) != NULL ) + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_STRING ) != NULL ) { hb_retl( IsGamepadName( hb_parni( 1 ), hb_parc( 2 ) ) ); } @@ -791,7 +1618,8 @@ HB_FUNC( GETGAMEPADNAME ) // bool IsGamepadButtonPressed(int gamepad, int button); // Detect if a gamepad button has been pressed once HB_FUNC( ISGAMEPADBUTTONPRESSED ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 1, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) { hb_retl( IsGamepadButtonPressed( hb_parni( 1 ), hb_parni( 2 ) ) ); } @@ -804,7 +1632,8 @@ HB_FUNC( ISGAMEPADBUTTONPRESSED ) // bool IsGamepadButtonDown(int gamepad, int button); // Detect if a gamepad button is being pressed HB_FUNC( ISGAMEPADBUTTONDOWN ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 1, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) { hb_retl( IsGamepadButtonDown( hb_parni( 1 ), hb_parni( 2 ) ) ); } @@ -817,7 +1646,8 @@ HB_FUNC( ISGAMEPADBUTTONDOWN ) // bool IsGamepadButtonReleased(int gamepad, int button); // Detect if a gamepad button has been released once HB_FUNC( ISGAMEPADBUTTONRELEASED ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 1, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) { hb_retl( IsGamepadButtonReleased( hb_parni( 1 ), hb_parni( 2 ) ) ); } @@ -830,7 +1660,8 @@ HB_FUNC( ISGAMEPADBUTTONRELEASED ) // bool IsGamepadButtonUp(int gamepad, int button); // Detect if a gamepad button is NOT being pressed HB_FUNC( ISGAMEPADBUTTONUP ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 1, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) { hb_retl( IsGamepadButtonUp( hb_parni( 1 ), hb_parni( 2 ) ) ); } @@ -862,7 +1693,8 @@ HB_FUNC( GETGAMEPADAXISCOUNT ) // float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis HB_FUNC( GETGAMEPADAXISMOVEMENT ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 1, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) { hb_retnd( ( float ) GetGamepadAxisMovement( hb_parni( 1 ), hb_parni( 2 ) ) ); } @@ -872,6 +1704,19 @@ HB_FUNC( GETGAMEPADAXISMOVEMENT ) } } +// int SetGamepadMappings(const char *mappings); // Set internal gamepad mappings (SDL_GameControllerDB) +HB_FUNC( SETGAMEPADMAPPINGS ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL ) + { + hb_retni( SetGamepadMappings( hb_parc( 1 ) ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // Input-related functions: mouse // bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once @@ -941,20 +1786,23 @@ HB_FUNC( GETMOUSEY ) // Vector2 GetMousePosition(void); // Returns mouse position XY HB_FUNC( GETMOUSEPOSITION ) { - PHB_ITEM info = hb_itemArrayNew( 2 ); - Vector2 vector2 = GetMousePosition(); - hb_arraySetNI( info, 1, ( float ) vector2.x ); - hb_arraySetNI( info, 2, ( float ) vector2.y ); + PHB_ITEM pVector2Array = hb_itemArrayNew( 2 ); + + hb_arraySetNI( pVector2Array, 1, ( float ) vector2.x ); + hb_arraySetNI( pVector2Array, 2, ( float ) vector2.y ); - hb_itemReturnRelease( info ); + hb_itemReturnRelease( pVector2Array ); } +// Vector2 GetMouseDelta(void); // Get mouse delta between frames + // void SetMousePosition(int x, int y); // Set mouse position XY HB_FUNC( SETMOUSEPOSITION ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) { SetMousePosition( hb_parni( 1 ), hb_parni( 2 ) ); } @@ -967,7 +1815,8 @@ HB_FUNC( SETMOUSEPOSITION ) // void SetMouseOffset(int offsetX, int offsetY); // Set mouse offset HB_FUNC( SETMOUSEOFFSET ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) { SetMouseOffset( hb_parni( 1 ), hb_parni( 2 ) ); } @@ -980,7 +1829,8 @@ HB_FUNC( SETMOUSEOFFSET ) // void SetMouseScale(float scaleX, float scaleY); // Set mouse scaling HB_FUNC( SETMOUSESCALE ) { - if( hb_param( 1, HB_IT_NUMERIC ) != NULL && hb_param( 2, HB_IT_NUMERIC ) != NULL ) + if( hb_param( 1, HB_IT_NUMERIC ) != NULL && + hb_param( 2, HB_IT_NUMERIC ) != NULL ) { SetMouseScale( ( float ) hb_parnd( 1 ), ( float ) hb_parnd( 2 ) ); } @@ -996,16 +1846,17 @@ HB_FUNC( GETMOUSEWHEELMOVE ) hb_retni( GetMouseWheelMove() ); } -// int GetMouseCursor(void); // Returns mouse cursor if (MouseCursor enum) -HB_FUNC( GetMouseCursor ) -{ - hb_retni( GetMouseCursor() ); -} - // void SetMouseCursor(int cursor); // Set mouse cursor HB_FUNC( SETMOUSECURSOR ) { - SetMouseCursor( hb_parni( 1 ) ); + if( hb_param( 1, HB_IT_INTEGER ) != NULL ) + { + SetMouseCursor( hb_parni( 1 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } } // Input-related functions: touch @@ -1029,12 +1880,12 @@ HB_FUNC( GETTOUCHPOSITION ) { Vector2 vector2 = GetTouchPosition( hb_parni( 1 ) ); - PHB_ITEM info = hb_itemArrayNew( 2 ); + PHB_ITEM pVector2Array = hb_itemArrayNew( 2 ); - hb_arraySetNI( info, 1, ( float ) vector2.x ); - hb_arraySetNI( info, 2, ( float ) vector2.y ); + hb_arraySetNI( pVector2Array, 1, ( float ) vector2.x ); + hb_arraySetNI( pVector2Array, 2, ( float ) vector2.y ); - hb_itemReturnRelease( info ); + hb_itemReturnRelease( pVector2Array ); } else { @@ -1042,6 +1893,12 @@ HB_FUNC( GETTOUCHPOSITION ) } } +// int GetTouchPointCount(void); // Get number of touch points +HB_FUNC( GETTOUCHPOINTCOUNT ) +{ + hb_retni( GetTouchPointCount() ); +} + //------------------------------------------------------------------------------------ // Gestures and Touch Handling Functions (Module: gestures) //------------------------------------------------------------------------------------ @@ -1060,7 +1917,7 @@ HB_FUNC( SETGESTURESENABLED ) } // bool IsGestureDetected(int gesture); // Check if a gesture have been detected -HB_FUNC( IsGestureDetected ) +HB_FUNC( ISGESTUREDETECTED ) { if( hb_param( 1, HB_IT_INTEGER ) != NULL ) { @@ -1073,34 +1930,28 @@ HB_FUNC( IsGestureDetected ) } // int GetGestureDetected(void); // Get latest detected gesture -HB_FUNC( GetGestureDetected ) +HB_FUNC( GETGESTUREDETECTED ) { hb_retni( GetGestureDetected() ); } -// int GetTouchPointsCount(void); // Get touch points count -HB_FUNC( GetTouchPointsCount ) -{ - hb_retni( GetTouchPointsCount() ); -} - // float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds -HB_FUNC( GetGestureHoldDuration ) +HB_FUNC( GETGESTUREHOLDDURATION ) { hb_retnd( ( float ) GetGestureHoldDuration() ); } // Vector2 GetGestureDragVector(void); // Get gesture drag vector -HB_FUNC( GetGestureDragVector ) +HB_FUNC( GETGESTUREDRAGVECTOR ) { - PHB_ITEM info = hb_itemArrayNew( 2 ); - Vector2 vector2 = GetGestureDragVector(); - hb_arraySetNI( info, 1, ( float ) vector2.x ); - hb_arraySetNI( info, 2, ( float ) vector2.y ); + PHB_ITEM pVector2Array = hb_itemArrayNew( 2 ); - hb_itemReturnRelease( info ); + hb_arraySetNI( pVector2Array, 1, ( float ) vector2.x ); + hb_arraySetNI( pVector2Array, 2, ( float ) vector2.y ); + + hb_itemReturnRelease( pVector2Array ); } // float GetGestureDragAngle(void); // Get gesture drag angle @@ -1112,14 +1963,14 @@ HB_FUNC( GETGESTUREDRAGANGLE ) // Vector2 GetGesturePinchVector(void); // Get gesture pinch delta HB_FUNC( GETGESTUREPINCHVECTOR ) { - PHB_ITEM info = hb_itemArrayNew( 2 ); - Vector2 vector2 = GetGesturePinchVector(); - hb_arraySetNI( info, 1, ( float ) vector2.x ); - hb_arraySetNI( info, 2, ( float ) vector2.y ); + PHB_ITEM pVector2Array = hb_itemArrayNew( 2 ); - hb_itemReturnRelease( info ); + hb_arraySetNI( pVector2Array, 1, ( float ) vector2.x ); + hb_arraySetNI( pVector2Array, 2, ( float ) vector2.y ); + + hb_itemReturnRelease( pVector2Array ); } // float GetGesturePinchAngle(void); // Get gesture pinch angle @@ -1133,7 +1984,88 @@ HB_FUNC( GETGESTUREPINCHANGLE ) //------------------------------------------------------------------------------------ // void SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available) + +HB_FUNC( SETCAMERAMODE ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 && + hb_param( 2, HB_IT_INTEGER ) != NULL ) + { + Camera camera; + + // Vector3 position + PHB_ITEM pSubarray1 = hb_arrayGetItemPtr( pItem, 1 ); + + camera.position.x = ( float ) hb_arrayGetND( pSubarray1, 1 ); + camera.position.y = ( float ) hb_arrayGetND( pSubarray1, 2 ); + camera.position.z = ( float ) hb_arrayGetND( pSubarray1, 3 ); + + // Vector3 target + PHB_ITEM pSubarray2 = hb_arrayGetItemPtr( pItem, 2 ); + + camera.target.x = ( float ) hb_arrayGetND( pSubarray2, 1 ); + camera.target.y = ( float ) hb_arrayGetND( pSubarray2, 2 ); + camera.target.z = ( float ) hb_arrayGetND( pSubarray2, 3 ); + + // Vector3 up + PHB_ITEM pSubarray3 = hb_arrayGetItemPtr( pItem, 3 ); + + camera.up.x = ( float ) hb_arrayGetND( pSubarray3, 1 ); + camera.up.y = ( float ) hb_arrayGetND( pSubarray3, 2 ); + camera.up.z = ( float ) hb_arrayGetND( pSubarray3, 3 ); + + camera.fovy = ( float ) hb_arrayGetND( pItem, 4 ); + camera.projection = hb_arrayGetNI( pItem, 5 ); + + SetCameraMode( camera, hb_parni( 2 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void UpdateCamera(Camera *camera); // Update camera position for selected mode +HB_FUNC( UPDATECAMERA ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 ) + { + Camera camera; + + // Vector3 position + PHB_ITEM pSubarray1 = hb_arrayGetItemPtr( pItem, 1 ); + + camera.position.x = ( float ) hb_arrayGetND( pSubarray1, 1 ); + camera.position.y = ( float ) hb_arrayGetND( pSubarray1, 2 ); + camera.position.z = ( float ) hb_arrayGetND( pSubarray1, 3 ); + + // Vector3 target + PHB_ITEM pSubarray2 = hb_arrayGetItemPtr( pItem, 2 ); + + camera.target.x = ( float ) hb_arrayGetND( pSubarray2, 1 ); + camera.target.y = ( float ) hb_arrayGetND( pSubarray2, 2 ); + camera.target.z = ( float ) hb_arrayGetND( pSubarray2, 3 ); + + // Vector3 up + PHB_ITEM pSubarray3 = hb_arrayGetItemPtr( pItem, 3 ); + + camera.up.x = ( float ) hb_arrayGetND( pSubarray3, 1 ); + camera.up.y = ( float ) hb_arrayGetND( pSubarray3, 2 ); + camera.up.z = ( float ) hb_arrayGetND( pSubarray3, 3 ); + + camera.fovy = ( float ) hb_arrayGetND( pItem, 4 ); + camera.projection = hb_arrayGetNI( pItem, 5 ); + + UpdateCamera( &camera ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} // void SetCameraPanControl(int keyPan); // Set camera pan key to combine with mouse movement (free camera) HB_FUNC( SETCAMERAPANCONTROL ) diff --git a/src/rlgl.c b/src/rlgl.c deleted file mode 100644 index d66bd28..0000000 --- a/src/rlgl.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * RayLib library: rlgl.c - * version 3.5 - * - * Copyright 2020 RafaÅ‚ Jopek ( rafaljopek at hotmail com ) - * - */ - -#include "hbraylib.h" - -//------------------------------------------------------------------------------------ -// Shaders System Functions (Module: rlgl) -// NOTE: This functions are useless when using OpenGL 1.1 -//------------------------------------------------------------------------------------ - -// Shader loading/unloading functions -// Shader LoadShader(const char *vsFileName, const char *fsFileName); // Load shader from files and bind default locations -// Shader LoadShaderCode(const char *vsCode, const char *fsCode); // Load shader from code strings and bind default locations -// void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM) - -// Shader GetShaderDefault(void); // Get default shader -// Texture2D GetTextureDefault(void); // Get default texture -// Texture2D GetShapesTexture(void); // Get texture to draw shapes -// Rectangle GetShapesTextureRec(void); // Get texture rectangle to draw shapes -// void SetShapesTexture(Texture2D texture, Rectangle source); // Define default texture used to draw shapes - -// Shader configuration functions -// int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location -// int GetShaderLocationAttrib(Shader shader, const char *attribName); // Get shader attribute location -// void SetShaderValue(Shader shader, int uniformLoc, const void *value, int uniformType); // Set shader uniform value -// void SetShaderValueV(Shader shader, int uniformLoc, const void *value, int uniformType, int count); // Set shader uniform value vector -// void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4) -// void SetShaderValueTexture(Shader shader, int uniformLoc, Texture2D texture); // Set shader uniform value for texture -// void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix) -// void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix) -// Matrix GetMatrixModelview(void); // Get internal modelview matrix -// Matrix GetMatrixProjection(void); // Get internal projection matrix - -// Texture maps generation (PBR) -// NOTE: Required shaders should be provided -// TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int size, int format); // Generate cubemap texture from 2D panorama texture -// TextureCubemap GenTextureIrradiance(Shader shader, TextureCubemap cubemap, int size); // Generate irradiance texture using cubemap data -// TextureCubemap GenTexturePrefilter(Shader shader, TextureCubemap cubemap, int size); // Generate prefilter texture using cubemap data -// Texture2D GenTextureBRDF(Shader shader, int size); // Generate BRDF texture - -// Shading begin/end functions -// void BeginShaderMode(Shader shader); // Begin custom shader drawing -// void EndShaderMode(void); // End custom shader drawing (use default shader) -// void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied) -// void EndBlendMode(void); // End blending mode (reset to default: alpha blending) - -// VR control functions -// void InitVrSimulator(void); // Init VR simulator for selected device parameters -// void CloseVrSimulator(void); // Close VR simulator for current device -// void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera -// void SetVrConfiguration(VrDeviceInfo info, Shader distortion); // Set stereo rendering configuration parameters -// bool IsVrSimulatorReady(void); // Detect if VR simulator is ready -// void ToggleVrMode(void); // Enable/Disable VR experience -// void BeginVrDrawing(void); // Begin VR simulator stereo rendering -// void EndVrDrawing(void); // End VR simulator stereo rendering diff --git a/src/shapes.c b/src/shapes.c index 07c6d60..c55f230 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -1,13 +1,20 @@ /* * RayLib library: shapes.c - * version 3.5 + * version 3.7 * + * Copyright 2021 Leonardo Mendez ( mlmgerencir at gmail com ) * Copyright 2020 - 2021 RafaÅ‚ Jopek ( rafaljopek at hotmail com ) * */ #include "hbraylib.h" + +// Set texture and rectangle to be used on shapes drawing +// NOTE: It can be useful when using basic shapes and one single font, +// defining a font char white rectangle would allow drawing everything in a single draw call +//void SetShapesTexture(Texture2D texture, Rectangle source); + /* --- Basic shapes drawing functions --- */ // void DrawPixel( int posX, int posY, Color color ); @@ -192,6 +199,8 @@ HB_FUNC( DRAWLINEBEZIER ) } } +//void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thick, Color color); //Draw line using quadratic bezier curves with a control point + // void DrawLineStrip( Vector2 *points, int pointsCount, Color color); HB_FUNC( DRAWLINESTRIP ) { @@ -246,15 +255,16 @@ HB_FUNC( DRAWCIRCLE ) } } -// void DrawCircleSector( Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color ); + +//void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); HB_FUNC( DRAWCIRCLESECTOR ) { PHB_ITEM pItem1, pItem2; if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 2 && hb_param( 2, HB_IT_NUMERIC ) != NULL && - hb_param( 3, HB_IT_INTEGER ) != NULL && - hb_param( 4, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_NUMERIC ) != NULL && + hb_param( 4, HB_IT_NUMERIC ) != NULL && hb_param( 5, HB_IT_INTEGER ) != NULL && ( pItem2 = hb_param( 6, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) { @@ -270,7 +280,7 @@ HB_FUNC( DRAWCIRCLESECTOR ) color.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); color.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); - DrawCircleSector( center, ( float ) hb_parnd( 2 ), hb_parni( 3 ), hb_parni( 4 ), hb_parni( 5 ), color ); + DrawCircleSector( center, ( float ) hb_parnd( 2 ), ( float ) hb_parnd( 3 ), ( float ) hb_parnd( 4 ), hb_parni( 5 ), color ); } else { @@ -278,15 +288,15 @@ HB_FUNC( DRAWCIRCLESECTOR ) } } -// void DrawCircleSectorLines( Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color ); + //void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); HB_FUNC( DRAWCIRCLESECTORLINES ) { PHB_ITEM pItem1, pItem2; if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 2 && hb_param( 2, HB_IT_NUMERIC ) != NULL && - hb_param( 3, HB_IT_INTEGER ) != NULL && - hb_param( 4, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_NUMERIC ) != NULL && + hb_param( 4, HB_IT_NUMERIC ) != NULL && hb_param( 5, HB_IT_INTEGER ) != NULL && ( pItem2 = hb_param( 6, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) { @@ -302,7 +312,7 @@ HB_FUNC( DRAWCIRCLESECTORLINES ) color.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); color.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); - DrawCircleSectorLines( center, ( float ) hb_parnd( 2 ), hb_parni( 3 ), hb_parni( 4 ), hb_parni( 5 ), color ); + DrawCircleSectorLines( center, ( float ) hb_parnd( 2 ), ( float ) hb_parnd( 3 ), ( float ) hb_parnd( 4 ), hb_parni( 5 ), color ); } else { @@ -448,8 +458,7 @@ HB_FUNC( DRAWELLIPSELINES ) hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } } - -// void DrawRing( Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color ); +//void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color); // Draw ring HB_FUNC( DRAWRING ) { PHB_ITEM pItem1, pItem2; @@ -457,8 +466,8 @@ HB_FUNC( DRAWRING ) if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 2 && hb_param( 2, HB_IT_NUMERIC ) != NULL && hb_param( 3, HB_IT_NUMERIC ) != NULL && - hb_param( 4, HB_IT_INTEGER ) != NULL && - hb_param( 5, HB_IT_INTEGER ) != NULL && + hb_param( 4, HB_IT_NUMERIC ) != NULL && + hb_param( 5, HB_IT_NUMERIC ) != NULL && hb_param( 6, HB_IT_INTEGER ) != NULL && ( pItem2 = hb_param( 7, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) { @@ -474,7 +483,7 @@ HB_FUNC( DRAWRING ) color.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); color.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); - DrawRing( center, ( float ) hb_parnd( 2 ), ( float ) hb_parnd( 3 ), hb_parni( 4 ), hb_parni( 5 ), hb_parni( 6 ), color ); + DrawRing( center, ( float ) hb_parnd( 2 ), ( float ) hb_parnd( 3 ), ( float ) hb_parnd( 4 ), hb_parnd( 5 ), hb_parni( 6 ), color ); } else { @@ -482,7 +491,7 @@ HB_FUNC( DRAWRING ) } } -// void DrawRingLines( Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color ); +//void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color); // Draw ring outline HB_FUNC( DRAWRINGLINES ) { PHB_ITEM pItem1, pItem2; @@ -490,8 +499,8 @@ HB_FUNC( DRAWRINGLINES ) if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 2 && hb_param( 2, HB_IT_NUMERIC ) != NULL && hb_param( 3, HB_IT_NUMERIC ) != NULL && - hb_param( 4, HB_IT_INTEGER ) != NULL && - hb_param( 5, HB_IT_INTEGER ) != NULL && + hb_param( 4, HB_IT_NUMERIC ) != NULL && + hb_param( 5, HB_IT_NUMERIC ) != NULL && hb_param( 6, HB_IT_INTEGER ) != NULL && ( pItem2 = hb_param( 7, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) { @@ -507,7 +516,7 @@ HB_FUNC( DRAWRINGLINES ) color.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); color.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); - DrawRingLines( center, ( float ) hb_parnd( 2 ), ( float ) hb_parnd( 3 ), hb_parni( 4 ), hb_parni( 5 ), hb_parni( 6 ), color ); + DrawRingLines( center, ( float ) hb_parnd( 2 ), ( float ) hb_parnd( 3 ), ( float ) hb_parnd( 4 ), ( float ) hb_parnd( 5 ), hb_parni( 6 ), color ); } else { diff --git a/src/text.c b/src/text.c index 7c46636..fc52530 100644 --- a/src/text.c +++ b/src/text.c @@ -1,7 +1,9 @@ /* * RayLib library: text.c - * version 3.5 + * version 3.7 * + * Copyright 2021 Leonardo Mendez ( mlmgerencir at gmail com ) + * Copyright 2021 Maurizio la Cecilia ( m.lacecilia at gmail com ) * Copyright 2020 - 2021 RafaÅ‚ Jopek ( rafaljopek at hotmail com ) * */ @@ -13,21 +15,242 @@ //------------------------------------------------------------------------------------ // Font loading/unloading functions + // Font GetFontDefault(void); // Get the default Font +HB_FUNC( GETFONTDEFAULT ) +{ + Font font = GetFontDefault(); + + PHB_ITEM pFontArray = hb_itemArrayNew( 6 ); + + hb_arraySetNI( pFontArray, 1, font.baseSize ); + hb_arraySetNI( pFontArray, 2, font.glyphCount ); + hb_arraySetNI( pFontArray, 3, font.glyphPadding ); + + // Texture2D texture + PHB_ITEM pSubarrayTexture2D = hb_arrayGetItemPtr( pFontArray, 4 ); + + hb_arrayNew( pSubarrayTexture2D, 5 ); + hb_arraySetNI( pSubarrayTexture2D, 1, ( unsigned int ) font.texture.id ); + hb_arraySetNI( pSubarrayTexture2D, 2, font.texture.width ); + hb_arraySetNI( pSubarrayTexture2D, 3, font.texture.height ); + hb_arraySetNI( pSubarrayTexture2D, 4, font.texture.mipmaps ); + hb_arraySetNI( pSubarrayTexture2D, 5, font.texture.format ); + + hb_arraySetPtr( pFontArray, 5, font.recs ); + hb_arraySetPtr( pFontArray, 6, font.glyphs ); + + hb_itemReturnRelease( pFontArray ); +} + // Font LoadFont(const char *fileName); // Load font from file into GPU memory (VRAM) +HB_FUNC( LOADFONT ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL ) + { + Font font = LoadFont( hb_parc( 1 ) ); + + PHB_ITEM pFontArray = hb_itemArrayNew( 6 ); + + hb_arraySetNI( pFontArray, 1, font.baseSize ); + hb_arraySetNI( pFontArray, 2, font.glyphCount ); + hb_arraySetNI( pFontArray, 3, font.glyphPadding ); + + // Texture2D texture + PHB_ITEM pSubarrayTexture2D = hb_arrayGetItemPtr( pFontArray, 4 ); + + hb_arrayNew( pSubarrayTexture2D, 5 ); + hb_arraySetNI( pSubarrayTexture2D, 1, ( unsigned int ) font.texture.id ); + hb_arraySetNI( pSubarrayTexture2D, 2, font.texture.width ); + hb_arraySetNI( pSubarrayTexture2D, 3, font.texture.height ); + hb_arraySetNI( pSubarrayTexture2D, 4, font.texture.mipmaps ); + hb_arraySetNI( pSubarrayTexture2D, 5, font.texture.format ); + + hb_arraySetPtr( pFontArray, 5, font.recs ); + hb_arraySetPtr( pFontArray, 6, font.glyphs ); + + hb_itemReturnRelease( pFontArray ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCount); // Load font from file with extended parameters +HB_FUNC( LOADFONTEX ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL && + hb_param( 4, HB_IT_INTEGER ) != NULL ) + { + Font font = LoadFontEx( hb_parc( 1 ), hb_parni( 2 ), ( int * ) hb_parptr( 3 ), hb_parni( 4 ) ); + + PHB_ITEM pFontArray = hb_itemArrayNew( 6 ); + + hb_arraySetNI( pFontArray, 1, font.baseSize ); + hb_arraySetNI( pFontArray, 2, font.glyphCount ); + hb_arraySetNI( pFontArray, 3, font.glyphPadding ); + + // Texture2D texture + PHB_ITEM pSubarrayTexture2D = hb_arrayGetItemPtr( pFontArray, 4 ); + + hb_arrayNew( pSubarrayTexture2D, 5 ); + hb_arraySetNI( pSubarrayTexture2D, 1, ( unsigned int ) font.texture.id ); + hb_arraySetNI( pSubarrayTexture2D, 2, font.texture.width ); + hb_arraySetNI( pSubarrayTexture2D, 3, font.texture.height ); + hb_arraySetNI( pSubarrayTexture2D, 4, font.texture.mipmaps ); + hb_arraySetNI( pSubarrayTexture2D, 5, font.texture.format ); + + hb_arraySetPtr( pFontArray, 5, font.recs ); + hb_arraySetPtr( pFontArray, 6, font.glyphs ); + + hb_itemReturnRelease( pFontArray ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style) +HB_FUNC( LOADFONTFROMIMAGE ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 5 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 && + hb_param( 3, HB_IT_INTEGER ) != NULL ) + { + Image image; + + image.data = hb_arrayGetPtr( pItem1, 1 ); + image.width = hb_arrayGetNI( pItem1, 2 ); + image.height = hb_arrayGetNI( pItem1, 3 ); + image.mipmaps = hb_arrayGetNI( pItem1, 4 ); + image.format = hb_arrayGetNI( pItem1, 5 ); + + Color key; + + key.r = ( unsigned char ) hb_arrayGetNI( pItem2, 1 ); + key.g = ( unsigned char ) hb_arrayGetNI( pItem2, 2 ); + key.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); + key.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); + + Font font = LoadFontFromImage( image, key, hb_parni( 3 ) ); + + PHB_ITEM pFontArray = hb_itemArrayNew( 6 ); + + hb_arraySetNI( pFontArray, 1, font.baseSize ); + hb_arraySetNI( pFontArray, 2, font.glyphCount ); + hb_arraySetNI( pFontArray, 3, font.glyphPadding ); + + // Texture2D texture + PHB_ITEM pSubarrayTexture2D = hb_arrayGetItemPtr( pFontArray, 4 ); + + hb_arrayNew( pSubarrayTexture2D, 5 ); + hb_arraySetNI( pSubarrayTexture2D, 1, ( unsigned int ) font.texture.id ); + hb_arraySetNI( pSubarrayTexture2D, 2, font.texture.width ); + hb_arraySetNI( pSubarrayTexture2D, 3, font.texture.height ); + hb_arraySetNI( pSubarrayTexture2D, 4, font.texture.mipmaps ); + hb_arraySetNI( pSubarrayTexture2D, 5, font.texture.format ); + + hb_arraySetPtr( pFontArray, 5, font.recs ); + hb_arraySetPtr( pFontArray, 6, font.glyphs ); + + hb_itemReturnRelease( pFontArray ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount); // Load font from memory buffer, fileType refers to extension: i.e. "ttf" +HB_FUNC( LoadFontFromMemory ) +{ + if( hb_param( 1, HB_IT_STRING ) != NULL && + hb_param( 2, HB_IT_POINTER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL && + hb_param( 4, HB_IT_INTEGER ) != NULL && + hb_param( 5, HB_IT_INTEGER ) != NULL && + hb_param( 6, HB_IT_INTEGER ) != NULL ) + { + int fontChars; + Font font = LoadFontFromMemory( hb_parc( 1 ), ( const unsigned char * ) hb_parptr( 2 ), hb_parni( 3 ), hb_parni( 4 ), &fontChars, hb_parni( 6 ) ); + hb_storni( fontChars, 5 ); + + PHB_ITEM pFontArray = hb_itemArrayNew( 6 ); + + hb_arraySetNI( pFontArray, 1, font.baseSize ); + hb_arraySetNI( pFontArray, 2, font.glyphCount ); + hb_arraySetNI( pFontArray, 3, font.glyphPadding ); + + // Texture2D texture + PHB_ITEM pSubarrayTexture2D = hb_arrayGetItemPtr( pFontArray, 4 ); + + hb_arrayNew( pSubarrayTexture2D, 5 ); + hb_arraySetNI( pSubarrayTexture2D, 1, ( unsigned int ) font.texture.id ); + hb_arraySetNI( pSubarrayTexture2D, 2, font.texture.width ); + hb_arraySetNI( pSubarrayTexture2D, 3, font.texture.height ); + hb_arraySetNI( pSubarrayTexture2D, 4, font.texture.mipmaps ); + hb_arraySetNI( pSubarrayTexture2D, 5, font.texture.format ); + + hb_arraySetPtr( pFontArray, 5, font.recs ); + hb_arraySetPtr( pFontArray, 6, font.glyphs ); + + hb_itemReturnRelease( pFontArray ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // CharInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount, int type); // Load font data for further use // Image GenImageFontAtlas(const CharInfo *chars, Rectangle **recs, int charsCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info // void UnloadFontData(CharInfo *chars, int charsCount); // Unload font chars info data (RAM) + // void UnloadFont(Font font); // Unload Font from GPU memory (VRAM) +HB_FUNC( UNLOADFONT ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 6 ) + { + Font font; + + font.baseSize = hb_arrayGetNI( pItem, 1 ); + font.glyphCount = hb_arrayGetNI( pItem, 2 ); + font.glyphPadding = hb_arrayGetNI( pItem, 3 ); + + // Texture2D texture + PHB_ITEM pSubarrayTexture2D = hb_arrayGetItemPtr( pItem, 4 ); + + font.texture.id = ( unsigned int ) hb_arrayGetNI( pSubarrayTexture2D, 1 ); + font.texture.width = hb_arrayGetNI( pSubarrayTexture2D, 2 ); + font.texture.height = hb_arrayGetNI( pSubarrayTexture2D, 3 ); + font.texture.mipmaps = hb_arrayGetNI( pSubarrayTexture2D, 4 ); + font.texture.format = hb_arrayGetNI( pSubarrayTexture2D, 5 ); + + font.recs = ( Rectangle * ) hb_arrayGetPtr( pItem, 5 ); + font.glyphs = ( GlyphInfo * ) hb_arrayGetPtr( pItem, 6 ); + + UnloadFont( font ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} // Text drawing functions // void DrawFPS(int posX, int posY); // Shows current FPS HB_FUNC( DRAWFPS ) { - if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_INTEGER ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) { DrawFPS( hb_parni( 1 ), hb_parni( 2 ) ); } @@ -42,10 +265,10 @@ HB_FUNC( DRAWTEXT ) { PHB_ITEM pItem; - if( hb_param( 1, HB_IT_STRING ) != NULL && - hb_param( 2, HB_IT_INTEGER ) != NULL && - hb_param( 3, HB_IT_INTEGER ) != NULL && - hb_param( 4, HB_IT_INTEGER ) != NULL && + if( hb_param( 1, HB_IT_STRING ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL && + hb_param( 4, HB_IT_INTEGER ) != NULL && ( pItem = hb_param( 5, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 4 ) { @@ -65,15 +288,167 @@ HB_FUNC( DRAWTEXT ) } // void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text using font and additional parameters -// void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits -// void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint); // Draw text using font inside rectangle limits with support for text selection +HB_FUNC( DRAWTEXTEX ) +{ + PHB_ITEM pItem1, pItem2, pItem3; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 6 && + hb_param( 2, HB_IT_STRING ) != NULL && + ( pItem2 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 2 && + hb_param( 4, HB_IT_NUMERIC ) != NULL && + hb_param( 5, HB_IT_NUMERIC ) != NULL && + ( pItem3 = hb_param( 6, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 4 ) + { + Font font; + + font.baseSize = hb_arrayGetNI( pItem1, 1 ); + font.glyphCount = hb_arrayGetNI( pItem1, 2 ); + font.glyphPadding = hb_arrayGetNI( pItem1, 3 ); + + // Texture2D texture + PHB_ITEM pSubarrayTexture2D = hb_arrayGetItemPtr( pItem1, 4 ); + + font.texture.id = ( unsigned int ) hb_arrayGetNI( pSubarrayTexture2D, 1 ); + font.texture.width = hb_arrayGetNI( pSubarrayTexture2D, 2 ); + font.texture.height = hb_arrayGetNI( pSubarrayTexture2D, 3 ); + font.texture.mipmaps = hb_arrayGetNI( pSubarrayTexture2D, 4 ); + font.texture.format = hb_arrayGetNI( pSubarrayTexture2D, 5 ); + + font.recs = hb_arrayGetPtr( pItem1, 5 ); + font.glyphs = hb_arrayGetPtr( pItem1, 6 ); + + Vector2 position; + + position.x = ( float ) hb_arrayGetND( pItem2, 1 ); + position.y = ( float ) hb_arrayGetND( pItem2, 2 ); + + Color tint; + + tint.r = ( unsigned char ) hb_arrayGetNI( pItem3, 1 ); + tint.g = ( unsigned char ) hb_arrayGetNI( pItem3, 2 ); + tint.b = ( unsigned char ) hb_arrayGetNI( pItem3, 3 ); + tint.a = ( unsigned char ) hb_arrayGetNI( pItem3, 4 ); + + DrawTextEx( font, hb_parc( 2 ), position, ( float ) hb_parnd( 4 ), ( float ) hb_parnd( 5 ), tint ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// void DrawTextPro(Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint); // Draw text using Font and pro parameters (rotation) +HB_FUNC( DRAWTEXTPRO ) +{ + PHB_ITEM pItem1, pItem2, pItem3, pItem4; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 6 && + hb_param( 2, HB_IT_STRING ) != NULL && + ( pItem2 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 2 && + ( pItem3 = hb_param( 4, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 2 && + hb_param( 5, HB_IT_NUMERIC ) != NULL && + hb_param( 6, HB_IT_NUMERIC ) != NULL && + hb_param( 7, HB_IT_NUMERIC ) != NULL && + ( pItem4 = hb_param( 8, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem4 ) == 4 ) + { + Font font; + + font.baseSize = hb_arrayGetNI( pItem1, 1 ); + font.glyphCount = hb_arrayGetNI( pItem1, 2 ); + font.glyphPadding = hb_arrayGetNI( pItem1, 3 ); + + // Texture2D texture + PHB_ITEM pSubarrayTexture2D = hb_arrayGetItemPtr( pItem1, 4 ); + + font.texture.id = ( unsigned int ) hb_arrayGetNI( pSubarrayTexture2D, 1 ); + font.texture.width = hb_arrayGetNI( pSubarrayTexture2D, 2 ); + font.texture.height = hb_arrayGetNI( pSubarrayTexture2D, 3 ); + font.texture.mipmaps = hb_arrayGetNI( pSubarrayTexture2D, 4 ); + font.texture.format = hb_arrayGetNI( pSubarrayTexture2D, 5 ); + + font.recs = hb_arrayGetPtr( pItem1, 5 ); + font.glyphs = hb_arrayGetPtr( pItem1, 6 ); + + Vector2 position; + + position.x = ( float ) hb_arrayGetND( pItem2, 1 ); + position.y = ( float ) hb_arrayGetND( pItem2, 2 ); + + Vector2 origin; + + origin.x = ( float ) hb_arrayGetND( pItem3, 1 ); + origin.y = ( float ) hb_arrayGetND( pItem3, 2 ); + + Color tint; + + tint.r = ( unsigned char ) hb_arrayGetNI( pItem4, 1 ); + tint.g = ( unsigned char ) hb_arrayGetNI( pItem4, 2 ); + tint.b = ( unsigned char ) hb_arrayGetNI( pItem4, 3 ); + tint.a = ( unsigned char ) hb_arrayGetNI( pItem4, 4 ); + + DrawTextPro( font, hb_parc( 2 ), position, origin, ( float ) hb_parnd( 5 ), ( float ) hb_parnd( 6 ), ( float ) hb_parnd( 7 ), tint ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSize, Color tint); // Draw one character (codepoint) +HB_FUNC( DRAWTEXTCODEPOINT ) +{ + PHB_ITEM pItem1, pItem2, pItem3; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 6 && + hb_param( 2, HB_IT_INTEGER ) != NULL && + ( pItem2 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 2 && + hb_param( 4, HB_IT_NUMERIC ) != NULL && + ( pItem3 = hb_param( 5, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 4 ) + { + Font font; + + font.baseSize = hb_arrayGetNI( pItem1, 1 ); + font.glyphCount = hb_arrayGetNI( pItem1, 2 ); + font.glyphPadding = hb_arrayGetNI( pItem1, 3 ); + + // Texture2D texture + PHB_ITEM pSubarrayTexture2D = hb_arrayGetItemPtr( pItem1, 4 ); + + font.texture.id = ( unsigned int ) hb_arrayGetNI( pSubarrayTexture2D, 1 ); + font.texture.width = hb_arrayGetNI( pSubarrayTexture2D, 2 ); + font.texture.height = hb_arrayGetNI( pSubarrayTexture2D, 3 ); + font.texture.mipmaps = hb_arrayGetNI( pSubarrayTexture2D, 4 ); + font.texture.format = hb_arrayGetNI( pSubarrayTexture2D, 5 ); + + font.recs = hb_arrayGetPtr( pItem1, 5 ); + font.glyphs = hb_arrayGetPtr( pItem1, 6 ); + + Vector2 position; + + position.x = ( float ) hb_arrayGetND( pItem2, 1 ); + position.y = ( float ) hb_arrayGetND( pItem2, 2 ); + + Color tint; + + tint.r = ( unsigned char ) hb_arrayGetNI( pItem3, 1 ); + tint.g = ( unsigned char ) hb_arrayGetNI( pItem3, 2 ); + tint.b = ( unsigned char ) hb_arrayGetNI( pItem3, 3 ); + tint.a = ( unsigned char ) hb_arrayGetNI( pItem3, 4 ); + + DrawTextCodepoint( font, hb_parni( 2 ), position, ( float ) hb_parnd( 4 ), tint ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} // Text misc. functions // int MeasureText(const char *text, int fontSize); // Measure string width for default font HB_FUNC( MEASURETEXT ) { - if( hb_param( 1, HB_IT_STRING ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_STRING ) != NULL && + hb_param( 2, HB_IT_INTEGER ) != NULL ) { hb_retni( MeasureText( hb_parc( 1 ), hb_parni( 2 ) ) ); } @@ -84,17 +459,100 @@ HB_FUNC( MEASURETEXT ) } // Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing); // Measure string size for Font +HB_FUNC( MEASURETEXTEX ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 6 && + hb_param( 2, HB_IT_STRING ) != NULL && + hb_param( 3, HB_IT_NUMERIC ) != NULL && + hb_param( 4, HB_IT_NUMERIC ) != NULL ) + { + Font font; + + font.baseSize = hb_arrayGetNI( pItem, 1 ); + font.glyphCount = hb_arrayGetNI( pItem, 2 ); + font.glyphPadding = hb_arrayGetNI( pItem, 3 ); + + // Texture2D texture + PHB_ITEM pSubarrayTexture2D = hb_arrayGetItemPtr( pItem, 4 ); + + font.texture.id = ( unsigned int ) hb_arrayGetNI( pSubarrayTexture2D, 1 ); + font.texture.width = hb_arrayGetNI( pSubarrayTexture2D, 2 ); + font.texture.height = hb_arrayGetNI( pSubarrayTexture2D, 3 ); + font.texture.mipmaps = hb_arrayGetNI( pSubarrayTexture2D, 4 ); + font.texture.format = hb_arrayGetNI( pSubarrayTexture2D, 5 ); + + font.recs = hb_arrayGetPtr( pItem, 5 ); + font.glyphs = hb_arrayGetPtr( pItem, 6 ); + + Vector2 vector2 = MeasureTextEx( font, hb_parc( 2 ), ( float ) hb_parnd( 3 ), ( float ) hb_parnd( 4 ) ); + + PHB_ITEM pVector2Array = hb_itemArrayNew( 2 ); + + hb_arraySetNI( pVector2Array, 1, ( float ) vector2.x ); + hb_arraySetNI( pVector2Array, 2, ( float ) vector2.y ); + + hb_itemReturnRelease( pVector2Array ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // int GetGlyphIndex(Font font, int codepoint); // Get index position for a unicode character on font +HB_FUNC( GETGLYPHINDEX ) +{ + PHB_ITEM pItem; + + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 6 && + hb_param( 2, HB_IT_INTEGER ) != NULL ) + { + Font font; + + font.baseSize = hb_arrayGetNI( pItem, 1 ); + font.glyphCount = hb_arrayGetNI( pItem, 2 ); + font.glyphPadding = hb_arrayGetNI( pItem, 3 ); + + // Texture2D texture + PHB_ITEM pSubarrayTexture2D = hb_arrayGetItemPtr( pItem, 4 ); + + font.texture.id = ( unsigned int ) hb_arrayGetNI( pSubarrayTexture2D, 1 ); + font.texture.width = hb_arrayGetNI( pSubarrayTexture2D, 2 ); + font.texture.height = hb_arrayGetNI( pSubarrayTexture2D, 3 ); + font.texture.mipmaps = hb_arrayGetNI( pSubarrayTexture2D, 4 ); + font.texture.format = hb_arrayGetNI( pSubarrayTexture2D, 5 ); + + font.recs = hb_arrayGetPtr( pItem, 5 ); + font.glyphs = hb_arrayGetPtr( pItem, 6 ); + + GetGlyphIndex( font, hb_parni( 2 ) ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +// Text codepoints management functions (unicode characters) + +// int *LoadCodepoints(const char *text, int *count); // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter +// void UnloadCodepoints(int *codepoints); // Unload codepoints data from memory +// int GetCodepointCount(const char *text); // Get total number of codepoints in a UTF-8 encoded string +// int GetCodepoint(const char *text, int *bytesProcessed); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure +// const char *CodepointToUTF8(int codepoint, int *byteSize); // Encode one codepoint into UTF-8 byte array (array length returned as parameter) +// char *TextCodepointsToUTF8(int *codepoints, int length); // Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!) // Text strings management functions (no utf8 strings, only byte chars) // NOTE: Some strings allocate memory internally for returned strings, just be careful! +// int TextCopy(char *dst, const char *src); // Copy one string to another, returns bytes copied -// int TextCopy(char *dst, const char *src); // Copy one string to another, returns bytes copied - -// bool TextIsEqual(const char *text1, const char *text2); // Check if two text string are equal +// bool TextIsEqual(const char *text1, const char *text2); // Check if two text string are equal HB_FUNC( TEXTISEQUAL ) { - if( hb_param( 1, HB_IT_STRING ) != NULL && hb_param( 2, HB_IT_STRING ) != NULL ) + if( hb_param( 1, HB_IT_STRING ) != NULL && + hb_param( 2, HB_IT_STRING ) != NULL ) { hb_retl( TextIsEqual( hb_parc( 1 ), hb_parc( 2 ) ) ); } @@ -120,9 +578,9 @@ HB_FUNC( TEXTLENGTH ) // const char *TextFormat(const char *text, ...); // Text formatting with variables (sprintf style) HB_FUNC( TEXTFORMAT ) { - if( hb_param( 1, HB_IT_STRING ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_STRING ) != NULL ) { - hb_retc( TextFormat( hb_parc( 1 ), hb_parni( 2 ) ) ); + hb_retc( TextFormat( hb_parc( 1 ), hb_parni( 2 ), hb_parni( 3 ) ) ); } else { @@ -130,12 +588,11 @@ HB_FUNC( TEXTFORMAT ) } } -// const char *TextSubtext(const char *text, int position, int length); // Get a piece of a text string -HB_FUNC( TEXTSUBTEXT ) +HB_FUNC( TEXTFORMATIF ) { - if( hb_param( 1, HB_IT_STRING ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_STRING ) != NULL ) { - hb_retc( TextSubtext( hb_parc( 1 ), hb_parni( 2 ), hb_parni( 3 ) ) ); + hb_retc( TextFormat( hb_parc( 1 ), hb_parni( 2 ), ( float ) hb_parnd( 3 ) ) ); } else { @@ -143,18 +600,11 @@ HB_FUNC( TEXTSUBTEXT ) } } -// char *TextReplace(char *text, const char *replace, const char *by); // Replace text string (memory must be freed!) -// char *TextInsert(const char *text, const char *insert, int position); // Insert text in a position (memory must be freed!) -// const char *TextJoin(const char **textList, int count, const char *delimiter); // Join text strings with delimiter -// const char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings -// void TextAppend(char *text, const char *append, int *position); // Append text at specific position and move cursor! - -// int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string -HB_FUNC( TEXTFINDINDEX ) +HB_FUNC( TEXTFORMATII ) { - if( hb_param( 1, HB_IT_STRING ) != NULL && hb_param( 2, HB_IT_STRING ) != NULL ) + if( hb_param( 1, HB_IT_STRING ) != NULL ) { - hb_retni( TextFindIndex( hb_parc( 1 ), hb_parc( 2 ) ) ); + hb_retc( TextFormat( hb_parc( 1 ), hb_parni( 2 ), hb_parni( 3 ) ) ); } else { @@ -162,12 +612,11 @@ HB_FUNC( TEXTFINDINDEX ) } } -// const char *TextToUpper(const char *text); // Get upper case version of provided string -HB_FUNC( TEXTTOUPPER ) +HB_FUNC( TEXTFORMATSI ) { if( hb_param( 1, HB_IT_STRING ) != NULL ) { - hb_retc( TextToUpper( hb_parc( 1 ) ) ); + hb_retc( TextFormat( hb_parc( 1 ), hb_parc( 2 ), hb_parni( 3 ) ) ); } else { @@ -175,12 +624,12 @@ HB_FUNC( TEXTTOUPPER ) } } -// const char *TextToLower(const char *text); // Get lower case version of provided string -HB_FUNC( TEXTTOLOWER ) +// const char *TextSubtext(const char *text, int position, int length); // Get a piece of a text string +HB_FUNC( TEXTSUBTEXT ) { - if( hb_param( 1, HB_IT_STRING ) != NULL ) + if( hb_param( 1, HB_IT_STRING ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) { - hb_retc( TextToLower( hb_parc( 1 ) ) ); + hb_retc( TextSubtext( hb_parc( 1 ), hb_parni( 2 ), hb_parni( 3 ) ) ); } else { @@ -188,12 +637,19 @@ HB_FUNC( TEXTTOLOWER ) } } -// const char *TextToPascal(const char *text); // Get Pascal case notation version of provided string -HB_FUNC( TEXTTOPASCAL ) +// char *TextReplace(char *text, const char *replace, const char *by); // Replace text string (memory must be freed!) +// char *TextInsert(const char *text, const char *insert, int position); // Insert text in a position (memory must be freed!) +// const char *TextJoin(const char **textList, int count, const char *delimiter); // Join text strings with delimiter +// const char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings +// void TextAppend(char *text, const char *append, int *position); // Append text at specific position and move cursor! + +// int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string +HB_FUNC( TEXTFINDINDEX ) { - if( hb_param( 1, HB_IT_STRING ) != NULL ) + if( hb_param( 1, HB_IT_STRING ) != NULL && + hb_param( 2, HB_IT_STRING ) != NULL ) { - hb_retc( TextToPascal( hb_parc( 1 ) ) ); + hb_retni( TextFindIndex( hb_parc( 1 ), hb_parc( 2 ) ) ); } else { @@ -201,12 +657,12 @@ HB_FUNC( TEXTTOPASCAL ) } } -// int TextToInteger(const char *text); // Get integer value from text (negative values not supported) -HB_FUNC( TEXTTOINTEGER ) +// const char *TextToUpper(const char *text); // Get upper case version of provided string +HB_FUNC( TEXTTOUPPER ) { if( hb_param( 1, HB_IT_STRING ) != NULL ) { - hb_retni( TextToInteger( hb_parc( 1 ) ) ); + hb_retc( TextToUpper( hb_parc( 1 ) ) ); } else { @@ -214,18 +670,12 @@ HB_FUNC( TEXTTOINTEGER ) } } -// char *TextToUtf8(int *codepoints, int length); // Encode text codepoint into utf8 text (memory must be freed!) - -// UTF8 text strings management functions - -// int *GetCodepoints(const char *text, int *count); // Get all codepoints in a string, codepoints count returned by parameters - -// int GetCodepointsCount(const char *text); // Get total number of characters (codepoints) in a UTF8 encoded string -HB_FUNC( GETCODEPOINTSCOUNT ) +// const char *TextToLower(const char *text); // Get lower case version of provided string +HB_FUNC( TEXTTOLOWER ) { if( hb_param( 1, HB_IT_STRING ) != NULL ) { - hb_retni( GetCodepointsCount( hb_parc( 1 ) ) ); + hb_retc( TextToLower( hb_parc( 1 ) ) ); } else { @@ -233,14 +683,12 @@ HB_FUNC( GETCODEPOINTSCOUNT ) } } -// int GetNextCodepoint(const char *text, int *bytesProcessed); // Returns next codepoint in a UTF8 encoded string; 0x3f('?') is returned on failure -HB_FUNC( GETNEXTCODEPOINT ) +// const char *TextToPascal(const char *text); // Get Pascal case notation version of provided string +HB_FUNC( TEXTTOPASCAL ) { - if( hb_param( 1, HB_IT_STRING ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_STRING ) != NULL ) { - int bytesProcessed; - hb_retni( GetNextCodepoint( hb_parc( 1 ), &bytesProcessed ) ); - hb_storni( bytesProcessed, 2 ); + hb_retc( TextToPascal( hb_parc( 1 ) ) ); } else { @@ -248,17 +696,15 @@ HB_FUNC( GETNEXTCODEPOINT ) } } -// const char *CodepointToUtf8(int codepoint, int *byteLength); // Encode codepoint into utf8 text (char array length returned as parameter) -HB_FUNC( CODEPOINTTOUTF8 ) +// int TextToInteger(const char *text); // Get integer value from text (negative values not supported) +HB_FUNC( TEXTTOINTEGER ) { - if( hb_param( 1, HB_IT_STRING ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) + if( hb_param( 1, HB_IT_STRING ) != NULL ) { - int byteLength; - hb_retc( CodepointToUtf8( hb_parni( 1 ), &byteLength ) ); - hb_storni( byteLength, 2 ); + hb_retni( TextToInteger( hb_parc( 1 ) ) ); } else { hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } -} +} \ No newline at end of file diff --git a/src/textures.c b/src/textures.c index 7c0086c..1aa43f0 100644 --- a/src/textures.c +++ b/src/textures.c @@ -1,7 +1,9 @@ /* * RayLib library: textures.c - * version 3.5 + * version 3.7 * + * Copyright 2021 Leonardo Mendez ( mlmgerencir at gmail com ) + * Copyright 2021 Maurizio la Cecilia ( m.lacecilia at gmail com ) * Copyright 2020 - 2021 RafaÅ‚ Jopek ( rafaljopek at hotmail com ) * */ @@ -98,8 +100,7 @@ HB_FUNC( LOADIMAGEFROMMEMORY ) hb_param( 2, HB_IT_INTEGER ) != NULL && hb_param( 3, HB_IT_INTEGER ) != NULL ) { - const unsigned char fileData = ( const unsigned char ) hb_parni( 2 ); - Image image = LoadImageFromMemory( hb_parc( 1 ), &fileData, hb_parni( 3 ) ); + Image image = LoadImageFromMemory( hb_parc( 1 ), ( const unsigned char *) hb_parptr( 2 ), hb_parni( 3 ) ); PHB_ITEM info = hb_itemArrayNew( 5 ); @@ -307,7 +308,7 @@ HB_FUNC( GENIMAGEGRADIENTH ) } // Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer); // Generate image: radial gradient -HB_FUNC( GenImageGradientRadial ) +HB_FUNC( GENIMAGEGRADIENTRADIAL ) { PHB_ITEM pItem1, pItem2; @@ -581,6 +582,58 @@ HB_FUNC( IMAGETEXT ) } // Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font) +HB_FUNC( IMAGETEXTEX ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 6 && + hb_param( 2, HB_IT_STRING ) != NULL && + hb_param( 3, HB_IT_NUMERIC ) != NULL && + hb_param( 4, HB_IT_NUMERIC ) != NULL && + ( pItem2 = hb_param( 5, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + { + Font font; + + font.baseSize = hb_arrayGetNI( pItem1, 1 ); + font.glyphCount = hb_arrayGetNI( pItem1, 2 ); + font.glyphPadding = hb_arrayGetNI( pItem1, 3 ); + + // Texture2D texture + PHB_ITEM pSubarrayTexture2D = hb_arrayGetItemPtr( pItem1, 4 ); + + font.texture.id = ( unsigned int ) hb_arrayGetNI( pSubarrayTexture2D, 1 ); + font.texture.width = hb_arrayGetNI( pSubarrayTexture2D, 2 ); + font.texture.height = hb_arrayGetNI( pSubarrayTexture2D, 3 ); + font.texture.mipmaps = hb_arrayGetNI( pSubarrayTexture2D, 4 ); + font.texture.format = hb_arrayGetNI( pSubarrayTexture2D, 5 ); + + font.recs = hb_arrayGetPtr( pItem2, 5 ); + font.glyphs = hb_arrayGetPtr( pItem2, 6 ); + + Color tint; + + tint.r = ( unsigned char ) hb_arrayGetNI( pItem2, 1 ); + tint.g = ( unsigned char ) hb_arrayGetNI( pItem2, 2 ); + tint.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); + tint.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); + + Image imageret = ImageTextEx( font, hb_parc( 2 ), ( float ) hb_parnd( 3 ), ( float ) hb_parnd( 4 ), tint ); + + PHB_ITEM pImageTextExArray = hb_itemArrayNew( 5 ); + + hb_arraySetPtr( pImageTextExArray, 1, imageret.data ); + hb_arraySetNI( pImageTextExArray, 2, imageret.width ); + hb_arraySetNI( pImageTextExArray, 3, imageret.height ); + hb_arraySetNI( pImageTextExArray, 4, imageret.mipmaps ); + hb_arraySetNI( pImageTextExArray, 5, imageret.format ); + + hb_itemReturnRelease( pImageTextExArray ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} // void ImageFormat(Image *image, int newFormat); // Convert image data to desired format HB_FUNC( IMAGEFORMAT ) @@ -588,7 +641,7 @@ HB_FUNC( IMAGEFORMAT ) PHB_ITEM pItem; if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 && - hb_param( 2, HB_IT_INTEGER ) != NULL ) + hb_param( 2, HB_IT_INTEGER ) != NULL ) { Image image; @@ -723,7 +776,7 @@ HB_FUNC( IMAGEALPHACLEAR ) } // void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image -HB_FUNC( ImageAlphaMask ) +HB_FUNC( IMAGEALPHAMASK ) { PHB_ITEM pItem1, pItem2; @@ -783,8 +836,8 @@ HB_FUNC( IMAGERESIZE ) PHB_ITEM pItem; if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 && - hb_param( 2, HB_IT_INTEGER ) != NULL && - hb_param( 3, HB_IT_INTEGER ) != NULL ) + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL ) { Image image; @@ -808,8 +861,8 @@ HB_FUNC( IMAGERESIZENN ) PHB_ITEM pItem; if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 && - hb_param( 2, HB_IT_INTEGER ) != NULL && - hb_param( 3, HB_IT_INTEGER ) != NULL ) + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL ) { Image image; @@ -833,11 +886,11 @@ HB_FUNC( IMAGERESIZECANVAS ) PHB_ITEM pItem1, pItem2; if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 5 && - hb_param( 2, HB_IT_INTEGER ) != NULL && - hb_param( 3, HB_IT_INTEGER ) != NULL && - hb_param( 4, HB_IT_INTEGER ) != NULL && - hb_param( 5, HB_IT_INTEGER ) != NULL && - ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL && + hb_param( 4, HB_IT_INTEGER ) != NULL && + hb_param( 5, HB_IT_INTEGER ) != NULL && + ( pItem2 = hb_param( 6, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) { Image image; @@ -891,10 +944,10 @@ HB_FUNC( IMAGEDITHER ) PHB_ITEM pItem; if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 && - hb_param( 2, HB_IT_INTEGER ) != NULL && - hb_param( 3, HB_IT_INTEGER ) != NULL && - hb_param( 4, HB_IT_INTEGER ) != NULL && - hb_param( 5, HB_IT_INTEGER ) != NULL ) + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL && + hb_param( 4, HB_IT_INTEGER ) != NULL && + hb_param( 5, HB_IT_INTEGER ) != NULL ) { Image image; @@ -1285,9 +1338,9 @@ HB_FUNC( IMAGEDRAWPIXEL ) PHB_ITEM pItem1, pItem2; if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 5 && - hb_param( 2, HB_IT_INTEGER ) != NULL && - hb_param( 3, HB_IT_INTEGER ) != NULL && - ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL && + ( pItem2 = hb_param( 4, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) { Image dst; @@ -1318,8 +1371,8 @@ HB_FUNC( IMAGEDRAWPIXELV ) PHB_ITEM pItem1, pItem2, pItem3; if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 5 && - ( pItem2 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 2 && - ( pItem3 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 4 ) + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 2 && + ( pItem3 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 4 ) { Image dst; @@ -1678,32 +1731,32 @@ HB_FUNC( IMAGEDRAW ) Image src; - src.data = hb_arrayGetPtr( pItem1, 1 ); - src.width = hb_arrayGetNI( pItem1, 2 ); - src.height = hb_arrayGetNI( pItem1, 3 ); - src.mipmaps = hb_arrayGetNI( pItem1, 4 ); - src.format = hb_arrayGetNI( pItem1, 5 ); + src.data = hb_arrayGetPtr( pItem2, 1 ); + src.width = hb_arrayGetNI( pItem2, 2 ); + src.height = hb_arrayGetNI( pItem2, 3 ); + src.mipmaps = hb_arrayGetNI( pItem2, 4 ); + src.format = hb_arrayGetNI( pItem2, 5 ); Rectangle srcRec; - srcRec.x = ( float ) hb_arrayGetND( pItem2, 1 ); - srcRec.y = ( float ) hb_arrayGetND( pItem2, 2 ); - srcRec.width = ( float ) hb_arrayGetND( pItem2, 3 ); - srcRec.height = ( float ) hb_arrayGetND( pItem2, 4 ); + srcRec.x = ( float ) hb_arrayGetND( pItem3, 1 ); + srcRec.y = ( float ) hb_arrayGetND( pItem3, 2 ); + srcRec.width = ( float ) hb_arrayGetND( pItem3, 3 ); + srcRec.height = ( float ) hb_arrayGetND( pItem3, 4 ); Rectangle dstRec; - dstRec.x = ( float ) hb_arrayGetND( pItem2, 1 ); - dstRec.y = ( float ) hb_arrayGetND( pItem2, 2 ); - dstRec.width = ( float ) hb_arrayGetND( pItem2, 3 ); - dstRec.height = ( float ) hb_arrayGetND( pItem2, 4 ); + dstRec.x = ( float ) hb_arrayGetND( pItem4, 1 ); + dstRec.y = ( float ) hb_arrayGetND( pItem4, 2 ); + dstRec.width = ( float ) hb_arrayGetND( pItem4, 3 ); + dstRec.height = ( float ) hb_arrayGetND( pItem4, 4 ); Color tint; - tint.r = ( unsigned char ) hb_arrayGetNI( pItem3, 1 ); - tint.g = ( unsigned char ) hb_arrayGetNI( pItem3, 2 ); - tint.b = ( unsigned char ) hb_arrayGetNI( pItem3, 3 ); - tint.a = ( unsigned char ) hb_arrayGetNI( pItem3, 4 ); + tint.r = ( unsigned char ) hb_arrayGetNI( pItem5, 1 ); + tint.g = ( unsigned char ) hb_arrayGetNI( pItem5, 2 ); + tint.b = ( unsigned char ) hb_arrayGetNI( pItem5, 3 ); + tint.a = ( unsigned char ) hb_arrayGetNI( pItem5, 4 ); ImageDraw( &dst, src, srcRec, dstRec, tint ); } @@ -1749,6 +1802,63 @@ HB_FUNC( IMAGEDRAWTEXT ) } // void ImageDrawTextEx(Image *dst, Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text (custom sprite font) within an image (destination) +HB_FUNC( IMAGEDRAWTEXTEX ) +{ + PHB_ITEM pItem1, pItem2, pItem3, pItem4; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 5 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 6 && + hb_param( 3, HB_IT_STRING ) != NULL && + ( pItem3 = hb_param( 4, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 2 && + hb_param( 5, HB_IT_NUMERIC ) != NULL && + hb_param( 6, HB_IT_NUMERIC ) != NULL && + ( pItem4 = hb_param( 7, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem4 ) == 4 ) + { + Image dst; + + dst.data = hb_arrayGetPtr( pItem1, 1 ); + dst.width = hb_arrayGetNI( pItem1, 2 ); + dst.height = hb_arrayGetNI( pItem1, 3 ); + dst.mipmaps = hb_arrayGetNI( pItem1, 4 ); + dst.format = hb_arrayGetNI( pItem1, 5 ); + + Font font; + + font.baseSize = hb_arrayGetNI( pItem2, 1 ); + font.glyphCount = hb_arrayGetNI( pItem2, 2 ); + font.glyphPadding = hb_arrayGetNI( pItem2, 3 ); + + //Texture2D texture + PHB_ITEM pSubarrayTexture2D = hb_arrayGetItemPtr( pItem2, 4 ); + + font.texture.id = ( unsigned int ) hb_arrayGetNI( pSubarrayTexture2D, 1 ); + font.texture.width = hb_arrayGetNI( pSubarrayTexture2D, 2 ); + font.texture.height = hb_arrayGetNI( pSubarrayTexture2D, 3 ); + font.texture.mipmaps = hb_arrayGetNI( pSubarrayTexture2D, 4 ); + font.texture.format = hb_arrayGetNI( pSubarrayTexture2D, 5 ); + + font.recs = hb_arrayGetPtr( pItem2, 5 ); + font.glyphs = hb_arrayGetPtr( pItem2, 6 ); + + Vector2 position; + + position.x = ( float ) hb_arrayGetND( pItem3, 1 ); + position.y = ( float ) hb_arrayGetND( pItem3, 2 ); + + Color tint; + + tint.r = ( unsigned char ) hb_arrayGetNI( pItem4, 1 ); + tint.g = ( unsigned char ) hb_arrayGetNI( pItem4, 2 ); + tint.b = ( unsigned char ) hb_arrayGetNI( pItem4, 3 ); + tint.a = ( unsigned char ) hb_arrayGetNI( pItem4, 4 ); + + ImageDrawTextEx( &dst, font, hb_parc( 3 ), position, ( float ) hb_parnd( 5 ), ( float ) hb_parnd( 6 ), tint ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} // Texture loading functions // NOTE: These functions require GPU access @@ -1785,7 +1895,7 @@ HB_FUNC( LOADTEXTUREFROMIMAGE ) { Image image; - image.data = hb_arrayGetPtr( pItem, 1 ); + image.data = ( void * )hb_arrayGetPtr( pItem, 1 ); image.width = hb_arrayGetNI( pItem, 2 ); image.height = hb_arrayGetNI( pItem, 3 ); image.mipmaps = hb_arrayGetNI( pItem, 4 ); @@ -1824,7 +1934,7 @@ HB_FUNC( LOADTEXTURECUBEMAP ) image.mipmaps = hb_arrayGetNI( pItem, 4 ); image.format = hb_arrayGetNI( pItem, 5 ); - TextureCubemap texturecubemap = LoadTextureCubemap( image, hb_parni( 1 ) ); + TextureCubemap texturecubemap = LoadTextureCubemap( image, hb_parni( 2 ) ); PHB_ITEM info = hb_itemArrayNew( 5 ); @@ -1843,6 +1953,41 @@ HB_FUNC( LOADTEXTURECUBEMAP ) } // RenderTexture2D LoadRenderTexture(int width, int height); // Load texture for rendering (framebuffer) +HB_FUNC( LOADRENDERTEXTURE ) +{ + if( hb_param( 1, HB_IT_INTEGER ) != NULL && hb_param( 2, HB_IT_INTEGER ) != NULL ) + { + RenderTexture2D rendertexture2d = LoadRenderTexture( hb_parni( 1 ), hb_parni( 2 ) ); + + PHB_ITEM pRenderTextureArray = hb_itemArrayNew( 3 ); + + hb_arraySetNI( pRenderTextureArray, 1, rendertexture2d.id ); + + PHB_ITEM pSubarray = hb_arrayGetItemPtr( pRenderTextureArray, 2 ); + + hb_arrayNew( pSubarray, 5 ); + hb_arraySetNI( pSubarray, 1, rendertexture2d.texture.id ); + hb_arraySetNI( pSubarray, 2, rendertexture2d.texture.width ); + hb_arraySetNI( pSubarray, 3, rendertexture2d.texture.height ); + hb_arraySetNI( pSubarray, 4, rendertexture2d.texture.mipmaps ); + hb_arraySetNI( pSubarray, 5, rendertexture2d.texture.format ); + + pSubarray = hb_arrayGetItemPtr( pRenderTextureArray, 3 ); + hb_arrayNew( pSubarray, 5 ); + hb_arraySetNI( pSubarray, 1, rendertexture2d.depth.id ); + hb_arraySetNI( pSubarray, 2, rendertexture2d.depth.width ); + hb_arraySetNI( pSubarray, 3, rendertexture2d.depth.height ); + hb_arraySetNI( pSubarray, 4, rendertexture2d.depth.mipmaps ); + hb_arraySetNI( pSubarray, 5, rendertexture2d.depth.format ); + + hb_itemReturnRelease( pRenderTextureArray ); + hb_itemRelease( pSubarray ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} // void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM) HB_FUNC( UNLOADTEXTURE ) @@ -1923,9 +2068,10 @@ HB_FUNC( UPDATETEXTUREREC ) hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } } +// Texture configuration functions -// Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image -HB_FUNC( GETTEXTUREDATA ) +// void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture +HB_FUNC( GENTEXTUREMIPMAPS ) { PHB_ITEM pItem; @@ -1939,17 +2085,30 @@ HB_FUNC( GETTEXTUREDATA ) texture.mipmaps = hb_arrayGetNI( pItem, 4 ); texture.format = hb_arrayGetNI( pItem, 5 ); - Image image = GetTextureData( texture ); + GenTextureMipmaps( &texture ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} - PHB_ITEM info = hb_itemArrayNew( 5 ); +// void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode +HB_FUNC( SETTEXTUREFILTER ) +{ + PHB_ITEM pItem; - hb_arraySetPtr( info, 1, image.data ); - hb_arraySetNI( info, 2, image.width ); - hb_arraySetNI( info, 3, image.height ); - hb_arraySetNI( info, 4, image.mipmaps ); - hb_arraySetNI( info, 5, image.format ); + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 && hb_param( 2, HB_IT_INTEGER ) != NULL ) + { + Texture2D texture; - hb_itemReturnRelease( info ); + texture.id = ( unsigned int ) hb_arrayGetNI( pItem, 1 ); + texture.width = hb_arrayGetNI( pItem, 2 ); + texture.height = hb_arrayGetNI( pItem, 3 ); + texture.mipmaps = hb_arrayGetNI( pItem, 4 ); + texture.format = hb_arrayGetNI( pItem, 5 ); + + SetTextureFilter( texture, hb_parni( 2 ) ); } else { @@ -1957,37 +2116,396 @@ HB_FUNC( GETTEXTUREDATA ) } } -// Image GetScreenData(void); // Get pixel data from screen buffer and return an Image (screenshot) -HB_FUNC( GETSCREENDATA ) +// void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode +HB_FUNC( SetTextureWrap ) { - Image image = GetScreenData(); + PHB_ITEM pItem; - PHB_ITEM info = hb_itemArrayNew( 5 ); + if( ( pItem = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem ) == 5 && hb_param( 2, HB_IT_INTEGER ) != NULL ) + { + Texture2D texture; - hb_arraySetPtr( info, 1, image.data ); - hb_arraySetNI( info, 2, image.width ); - hb_arraySetNI( info, 3, image.height ); - hb_arraySetNI( info, 4, image.mipmaps ); - hb_arraySetNI( info, 5, image.format ); + texture.id = ( unsigned int ) hb_arrayGetNI( pItem, 1 ); + texture.width = hb_arrayGetNI( pItem, 2 ); + texture.height = hb_arrayGetNI( pItem, 3 ); + texture.mipmaps = hb_arrayGetNI( pItem, 4 ); + texture.format = hb_arrayGetNI( pItem, 5 ); - hb_itemReturnRelease( info ); + SetTextureWrap( texture, hb_parni( 2 ) ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } } -// Texture configuration functions -// void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture - -// void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode -// void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode - // Texture drawing functions + // void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D +HB_FUNC( DRAWTEXTURE ) +{ + PHB_ITEM pItem1, pItem2; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 5 && + hb_param( 2, HB_IT_INTEGER ) != NULL && + hb_param( 3, HB_IT_INTEGER ) != NULL && + ( pItem2 = hb_param( 4, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 ) + { + Texture2D texture; + + texture.id = ( unsigned int ) hb_arrayGetNI( pItem1, 1 ); + texture.width = hb_arrayGetNI( pItem1, 2 ); + texture.height = hb_arrayGetNI( pItem1, 3 ); + texture.mipmaps = hb_arrayGetNI( pItem1, 4 ); + texture.format = hb_arrayGetNI( pItem1, 5 ); + + Color tint; + + tint.r = ( unsigned char ) hb_arrayGetNI( pItem2, 1 ); + tint.g = ( unsigned char ) hb_arrayGetNI( pItem2, 2 ); + tint.b = ( unsigned char ) hb_arrayGetNI( pItem2, 3 ); + tint.a = ( unsigned char ) hb_arrayGetNI( pItem2, 4 ); + + DrawTexture( texture, hb_parni( 2 ), hb_parni( 3 ), tint ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2 +HB_FUNC( DRAWTEXTUREV ) +{ + PHB_ITEM pItem1, pItem2, pItem3; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 5 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 2 && + ( pItem3 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 4 ) + { + Texture2D texture; + + texture.id = ( unsigned int ) hb_arrayGetNI( pItem1, 1 ); + texture.width = hb_arrayGetNI( pItem1, 2 ); + texture.height = hb_arrayGetNI( pItem1, 3 ); + texture.mipmaps = hb_arrayGetNI( pItem1, 4 ); + texture.format = hb_arrayGetNI( pItem1, 5 ); + + Vector2 position; + + position.x = ( float ) hb_arrayGetND( pItem2, 1 ); + position.y = ( float ) hb_arrayGetND( pItem2, 2 ); + + Color tint; + + tint.r = ( unsigned char ) hb_arrayGetNI( pItem3, 1 ); + tint.g = ( unsigned char ) hb_arrayGetNI( pItem3, 2 ); + tint.b = ( unsigned char ) hb_arrayGetNI( pItem3, 3 ); + tint.a = ( unsigned char ) hb_arrayGetNI( pItem3, 4 ); + + DrawTextureV( texture, position, tint ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters +HB_FUNC( DRAWTEXTUREEX ) +{ + PHB_ITEM pItem1, pItem2, pItem3; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 5 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 2 && + hb_param( 3, HB_IT_NUMERIC ) != NULL && + hb_param( 4, HB_IT_NUMERIC ) != NULL && + ( pItem3 = hb_param( 5, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 4 ) + { + Texture2D texture; + + texture.id = ( unsigned int ) hb_arrayGetNI( pItem1, 1 ); + texture.width = hb_arrayGetNI( pItem1, 2 ); + texture.height = hb_arrayGetNI( pItem1, 3 ); + texture.mipmaps = hb_arrayGetNI( pItem1, 4 ); + texture.format = hb_arrayGetNI( pItem1, 5 ); + + Vector2 position; + + position.x = ( float ) hb_arrayGetND( pItem2, 1 ); + position.y = ( float ) hb_arrayGetND( pItem2, 2 ); + + Color tint; + + tint.r = ( unsigned char ) hb_arrayGetNI( pItem3, 1 ); + tint.g = ( unsigned char ) hb_arrayGetNI( pItem3, 2 ); + tint.b = ( unsigned char ) hb_arrayGetNI( pItem3, 3 ); + tint.a = ( unsigned char ) hb_arrayGetNI( pItem3, 4 ); + + DrawTextureEx( texture, position, ( float ) hb_parnd( 3 ), ( float ) hb_parnd( 4 ), tint ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint); // Draw a part of a texture defined by a rectangle +HB_FUNC( DRAWTEXTUREREC ) +{ + PHB_ITEM pItem1, pItem2, pItem3, pItem4; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 5 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 && + ( pItem3 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 2 && + ( pItem4 = hb_param( 4, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem4 ) == 4 ) + { + Texture2D texture; + + texture.id = ( unsigned int ) hb_arrayGetNI( pItem1, 1 ); + texture.width = hb_arrayGetNI( pItem1, 2 ); + texture.height = hb_arrayGetNI( pItem1, 3 ); + texture.mipmaps = hb_arrayGetNI( pItem1, 4 ); + texture.format = hb_arrayGetNI( pItem1, 5 ); + + Rectangle source; + + source.x = ( float ) hb_arrayGetND( pItem2, 1 ); + source.y = ( float ) hb_arrayGetND( pItem2, 2 ); + source.width = ( float ) hb_arrayGetND( pItem2, 3 ); + source.height = ( float ) hb_arrayGetND( pItem2, 4 ); + + Vector2 position; + + position.x = ( float ) hb_arrayGetND( pItem3, 1 ); + position.y = ( float ) hb_arrayGetND( pItem3, 2 ); + + Color tint; + + tint.r = ( unsigned char ) hb_arrayGetNI( pItem4, 1 ); + tint.g = ( unsigned char ) hb_arrayGetNI( pItem4, 2 ); + tint.b = ( unsigned char ) hb_arrayGetNI( pItem4, 3 ); + tint.a = ( unsigned char ) hb_arrayGetNI( pItem4, 4 ); + + DrawTextureRec( texture, source, position, tint ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void DrawTextureQuad(Texture2D texture, Vector2 tiling, Vector2 offset, Rectangle quad, Color tint); // Draw texture quad with tiling and offset parameters +HB_FUNC( DRAWTEXTUREQUAD ) +{ + PHB_ITEM pItem1, pItem2, pItem3, pItem4, pItem5; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 5 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 2 && + ( pItem3 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 2 && + ( pItem4 = hb_param( 4, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem4 ) == 4 && + ( pItem5 = hb_param( 5, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem5 ) == 4 ) + { + Texture2D texture; + + texture.id = ( unsigned int ) hb_arrayGetNI( pItem1, 1 ); + texture.width = hb_arrayGetNI( pItem1, 2 ); + texture.height = hb_arrayGetNI( pItem1, 3 ); + texture.mipmaps = hb_arrayGetNI( pItem1, 4 ); + texture.format = hb_arrayGetNI( pItem1, 5 ); + + Vector2 tiling; + + tiling.x = ( float ) hb_arrayGetND( pItem2, 1 ); + tiling.y = ( float ) hb_arrayGetND( pItem2, 2 ); + + Vector2 offset; + + offset.x = ( float ) hb_arrayGetND( pItem3, 1 ); + offset.y = ( float ) hb_arrayGetND( pItem3, 2 ); + + Rectangle quad; + + quad.x = ( float ) hb_arrayGetND( pItem4, 1 ); + quad.y = ( float ) hb_arrayGetND( pItem4, 2 ); + quad.width = ( float ) hb_arrayGetND( pItem4, 3 ); + quad.height = ( float ) hb_arrayGetND( pItem4, 4 ); + + Color tint; + + tint.r = ( unsigned char ) hb_arrayGetNI( pItem5, 1 ); + tint.g = ( unsigned char ) hb_arrayGetNI( pItem5, 2 ); + tint.b = ( unsigned char ) hb_arrayGetNI( pItem5, 3 ); + tint.a = ( unsigned char ) hb_arrayGetNI( pItem5, 4 ); + + DrawTextureQuad( texture, tiling, offset, quad, tint ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint); // Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest. +HB_FUNC( DRAWTEXTURETILED ) +{ + PHB_ITEM pItem1, pItem2, pItem3, pItem4, pItem5; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 5 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 && + ( pItem3 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 4 && + ( pItem4 = hb_param( 4, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem4 ) == 2 && + hb_param( 5, HB_IT_NUMERIC ) != NULL && + hb_param( 6, HB_IT_NUMERIC ) != NULL && + ( pItem5 = hb_param( 7, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem5 ) == 4 ) + { + Texture2D texture; + + texture.id = ( unsigned int ) hb_arrayGetNI( pItem1, 1 ); + texture.width = hb_arrayGetNI( pItem1, 2 ); + texture.height = hb_arrayGetNI( pItem1, 3 ); + texture.mipmaps = hb_arrayGetNI( pItem1, 4 ); + texture.format = hb_arrayGetNI( pItem1, 5 ); + + Rectangle source; + + source.x = ( float ) hb_arrayGetND( pItem2, 1 ); + source.y = ( float ) hb_arrayGetND( pItem2, 2 ); + source.width = ( float ) hb_arrayGetND( pItem2, 3 ); + source.height = ( float ) hb_arrayGetND( pItem2, 4 ); + + Rectangle dest; + + dest.x = ( float ) hb_arrayGetND( pItem3, 1 ); + dest.y = ( float ) hb_arrayGetND( pItem3, 2 ); + dest.width = ( float ) hb_arrayGetND( pItem3, 3 ); + dest.height = ( float ) hb_arrayGetND( pItem3, 4 ); + + Vector2 origin; + + origin.x = ( float ) hb_arrayGetND( pItem4, 1 ); + origin.y = ( float ) hb_arrayGetND( pItem4, 2 ); + + Color tint; + + tint.r = ( unsigned char ) hb_arrayGetNI( pItem5, 1 ); + tint.g = ( unsigned char ) hb_arrayGetNI( pItem5, 2 ); + tint.b = ( unsigned char ) hb_arrayGetNI( pItem5, 3 ); + tint.a = ( unsigned char ) hb_arrayGetNI( pItem5, 4 ); + + DrawTextureTiled( texture, source, dest, origin, ( float ) hb_parnd( 5 ), ( float ) hb_parnd( 6 ), tint ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + // void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draw a part of a texture defined by a rectangle with 'pro' parameters -// void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draws a texture (or part of it) that stretches or shrinks nicely +HB_FUNC( DRAWTEXTUREPRO ) +{ + PHB_ITEM pItem1, pItem2, pItem3, pItem4, pItem5; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 5 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 4 && + ( pItem3 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 4 && + ( pItem4 = hb_param( 4, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem4 ) == 2 && + hb_param( 5, HB_IT_NUMERIC ) != NULL && + ( pItem5 = hb_param( 6, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem5 ) == 4 ) + { + Texture2D texture; + + texture.id = ( unsigned int ) hb_arrayGetNI( pItem1, 1 ); + texture.width = hb_arrayGetNI( pItem1, 2 ); + texture.height = hb_arrayGetNI( pItem1, 3 ); + texture.mipmaps = hb_arrayGetNI( pItem1, 4 ); + texture.format = hb_arrayGetNI( pItem1, 5 ); + + Rectangle source; + + source.x = ( float ) hb_arrayGetND( pItem2, 1 ); + source.y = ( float ) hb_arrayGetND( pItem2, 2 ); + source.width = ( float ) hb_arrayGetND( pItem2, 3 ); + source.height = ( float ) hb_arrayGetND( pItem2, 4 ); + + Rectangle dest; + + dest.x = ( float ) hb_arrayGetND( pItem3, 1 ); + dest.y = ( float ) hb_arrayGetND( pItem3, 2 ); + dest.width = ( float ) hb_arrayGetND( pItem3, 3 ); + dest.height = ( float ) hb_arrayGetND( pItem3, 4 ); + + Vector2 origin; + + origin.x = ( float ) hb_arrayGetND( pItem4, 1 ); + origin.y = ( float ) hb_arrayGetND( pItem4, 2 ); + + Color tint; + + tint.r = ( unsigned char ) hb_arrayGetNI( pItem5, 1 ); + tint.g = ( unsigned char ) hb_arrayGetNI( pItem5, 2 ); + tint.b = ( unsigned char ) hb_arrayGetNI( pItem5, 3 ); + tint.a = ( unsigned char ) hb_arrayGetNI( pItem5, 4 ); + + DrawTexturePro( texture, source, dest, origin, ( float ) hb_parnd( 5 ), tint ); + } + else + { + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} + +//void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draws a texture (or part of it) that stretches or shrinks nicely + +//void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointsCount, Color tint); // Draw a textured polygon +HB_FUNC( DRAWTEXTUREPOLY ) +{ + PHB_ITEM pItem1, pItem2, pItem3, pItem4, pItem5; + + if( ( pItem1 = hb_param( 1, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem1 ) == 5 && + ( pItem2 = hb_param( 2, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem2 ) == 2 && + ( pItem3 = hb_param( 3, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem3 ) == 2 && + ( pItem4 = hb_param( 4, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem4 ) == 2 && + hb_param( 5, HB_IT_INTEGER ) != NULL && + ( pItem5 = hb_param( 6, HB_IT_ARRAY ) ) != NULL && hb_arrayLen( pItem5 ) == 4 ) + { + Texture2D texture; + + texture.id = ( unsigned int ) hb_arrayGetNI( pItem1, 1 ); + texture.width = hb_arrayGetNI( pItem1, 2 ); + texture.height = hb_arrayGetNI( pItem1, 3 ); + texture.mipmaps = hb_arrayGetNI( pItem1, 4 ); + texture.format = hb_arrayGetNI( pItem1, 5 ); + + Vector2 center; + + center.x = ( float ) hb_arrayGetND( pItem2, 1 ); + center.y = ( float ) hb_arrayGetND( pItem2, 2 ); + + Vector2 points; + + points.x = ( float ) hb_arrayGetND( pItem3, 1 ); + points.y = ( float ) hb_arrayGetND( pItem3, 2 ); + + Vector2 texcoords; + + texcoords.x = ( float ) hb_arrayGetND( pItem4, 1 ); + texcoords.y = ( float ) hb_arrayGetND( pItem4, 2 ); + + Color tint; + + tint.r = ( unsigned char ) hb_arrayGetNI( pItem5, 1 ); + tint.g = ( unsigned char ) hb_arrayGetNI( pItem5, 2 ); + tint.b = ( unsigned char ) hb_arrayGetNI( pItem5, 3 ); + tint.a = ( unsigned char ) hb_arrayGetNI( pItem5, 4 ); + + DrawTexturePoly( texture, center, &points, &texcoords, hb_parni( 5 ), tint ); + } + else + { + hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } +} // Color/pixel related functions