Merge branch 'raysan5:master' into dynamic-font-atlas
This commit is contained in:
commit
7b27628dfc
|
|
@ -45,7 +45,6 @@ cmake_dependent_option(SUPPORT_GIF_RECORDING "Allow automatic gif recording of c
|
||||||
cmake_dependent_option(SUPPORT_BUSY_WAIT_LOOP "Use busy wait loop for timing sync instead of a high-resolution timer" OFF CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_BUSY_WAIT_LOOP "Use busy wait loop for timing sync instead of a high-resolution timer" OFF CUSTOMIZE_BUILD OFF)
|
||||||
cmake_dependent_option(SUPPORT_EVENTS_WAITING "Wait for events passively (sleeping while no events) instead of polling them actively every frame" OFF CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_EVENTS_WAITING "Wait for events passively (sleeping while no events) instead of polling them actively every frame" OFF CUSTOMIZE_BUILD OFF)
|
||||||
cmake_dependent_option(SUPPORT_WINMM_HIGHRES_TIMER "Setting a higher resolution can improve the accuracy of time-out intervals in wait functions" OFF CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_WINMM_HIGHRES_TIMER "Setting a higher resolution can improve the accuracy of time-out intervals in wait functions" OFF CUSTOMIZE_BUILD OFF)
|
||||||
cmake_dependent_option(SUPPORT_DATA_STORAGE "Support for persistent data storage" ON CUSTOMIZE_BUILD ON)
|
|
||||||
cmake_dependent_option(SUPPORT_COMPRESSION_API "Support for compression API" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_COMPRESSION_API "Support for compression API" ON CUSTOMIZE_BUILD ON)
|
||||||
|
|
||||||
# rshapes.c
|
# rshapes.c
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ raylib is also available via multiple [package managers](https://github.com/rays
|
||||||
- [Working for Web (HTML5)](https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5))
|
- [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)
|
- [Working anywhere with CMake](https://github.com/raysan5/raylib/wiki/Working-with-CMake)
|
||||||
|
|
||||||
*Note that Wiki is open for edit, if you find some issue while building raylib for your target platform, feel free to edit the Wiki or open and issue related to it.*
|
*Note that the Wiki is open for edit, if you find some issues while building raylib for your target platform, feel free to edit the Wiki or open an issue related to it.*
|
||||||
|
|
||||||
#### Setup raylib with multiple IDEs
|
#### Setup raylib with multiple IDEs
|
||||||
|
|
||||||
|
|
@ -109,14 +109,14 @@ raylib has been developed on Windows platform using [Notepad++](https://notepad-
|
||||||
|
|
||||||
[Projects directory](https://github.com/raysan5/raylib/tree/master/projects) contains several ready-to-use **project templates** to build raylib and code examples with multiple IDEs.
|
[Projects directory](https://github.com/raysan5/raylib/tree/master/projects) contains several ready-to-use **project templates** to build raylib and code examples with multiple IDEs.
|
||||||
|
|
||||||
*Note that there are lots of IDEs supported, some of the provided templates could require some review, please, if you find some issue with some template or you think they could be improved, feel free to send a PR or open a related issue.*
|
*Note that there are lots of IDEs supported, some of the provided templates could require some review, so please, if you find some issue with a template or you think they could be improved, feel free to send a PR or open a related issue.*
|
||||||
|
|
||||||
learning and docs
|
learning and docs
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
raylib is designed to be learned using [the examples](https://github.com/raysan5/raylib/tree/master/examples) as the main reference. There is no standard API documentation but there is a [**cheatsheet**](https://www.raylib.com/cheatsheet/cheatsheet.html) containing all the functions available on the library and a short description of each one of them, input parameters and result value names should be intuitive enough to understand how each function works.
|
raylib is designed to be learned using [the examples](https://github.com/raysan5/raylib/tree/master/examples) as the main reference. There is no standard API documentation but there is a [**cheatsheet**](https://www.raylib.com/cheatsheet/cheatsheet.html) containing all the functions available on the library a short description of each one of them, input parameters and result value names should be intuitive enough to understand how each function works.
|
||||||
|
|
||||||
Some additional documentation about raylib design can be found in raylib GitHub Wiki. Here the more relevant links:
|
Some additional documentation about raylib design can be found in raylib GitHub Wiki. Here are the relevant links:
|
||||||
|
|
||||||
- [raylib cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html)
|
- [raylib cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html)
|
||||||
- [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture)
|
- [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture)
|
||||||
|
|
|
||||||
12
ROADMAP.md
12
ROADMAP.md
|
|
@ -1,19 +1,19 @@
|
||||||
# raylib roadmap
|
# raylib roadmap
|
||||||
|
|
||||||
Here it is a wish-list with features and ideas to improve the library. Note that features listed here are usually long term improvements or just describe a route to follow for the library. There are also some additional places to look for raylib improvements of ideas:
|
Here it is a wishlist with features and ideas to improve the library. Note that features listed here are usually long term improvements or just describe a route to follow for the library. There are also some additional places to look for raylib improvements and ideas:
|
||||||
|
|
||||||
- [GitHub Issues](https://github.com/raysan5/raylib/issues) has several open issues for possible improvements or bugs to fix.
|
- [GitHub Issues](https://github.com/raysan5/raylib/issues) has several open issues for possible improvements or bugs to fix.
|
||||||
- [raylib source code](https://github.com/raysan5/raylib/tree/master/src) has multiple *TODO* comments around code with pending things to review or improve.
|
- [raylib source code](https://github.com/raysan5/raylib/tree/master/src) has multiple *TODO* comments around code with pending things to review or improve.
|
||||||
- [raylib wishlist](https://github.com/raysan5/raylib/discussions/1502) is open to everyone to ask for improvements, feel free to check and comment.
|
- raylib wishlists discussions (https://github.com/raysan5/raylib/discussions/1502, https://github.com/raysan5/raylib/discussions/2272) are open to everyone to ask for improvements, feel free to check and comment.
|
||||||
|
|
||||||
_Current version of raylib is complete and functional but, as always, there is lot of room for improvement._
|
_Current version of raylib is complete and functional but there is always room for improvements._
|
||||||
|
|
||||||
**raylib 4.x**
|
**raylib 4.x**
|
||||||
- [ ] Redesign camera module (more flexible) ([#1143](https://github.com/raysan5/raylib/issues/1143))
|
- [ ] Redesign camera module (more flexible) ([#1143](https://github.com/raysan5/raylib/issues/1143), https://github.com/raysan5/raylib/discussions/2507)
|
||||||
- [ ] Redesign gestures system, improve touch inputs management
|
- [ ] Redesign gestures system, improve touch inputs management
|
||||||
- [ ] Better documentation and improved examples
|
- [ ] Better documentation and improved examples
|
||||||
- [ ] Focus on HTML5 and embedded platforms
|
- [ ] Focus on HTML5 ([raylib 5k gamejam](https://itch.io/jam/raylib-5k-gamejam)) and embedded platforms (RPI and similar SOCs)
|
||||||
- [ ] Additional support libraries: [raygui](https://github.com/raysan5/raygui), [rres](https://github.com/raysan5/rres)...
|
- [x] Additional support libraries: [raygui](https://github.com/raysan5/raygui), [rres](https://github.com/raysan5/rres)
|
||||||
|
|
||||||
**raylib 4.0**
|
**raylib 4.0**
|
||||||
- [x] Improved consistency and coherency in raylib API
|
- [x] Improved consistency and coherency in raylib API
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ if (${CUSTOMIZE_BUILD})
|
||||||
define_if("raylib" SUPPORT_BUSY_WAIT_LOOP)
|
define_if("raylib" SUPPORT_BUSY_WAIT_LOOP)
|
||||||
define_if("raylib" SUPPORT_EVENTS_WAITING)
|
define_if("raylib" SUPPORT_EVENTS_WAITING)
|
||||||
define_if("raylib" SUPPORT_WINMM_HIGHRES_TIMER)
|
define_if("raylib" SUPPORT_WINMM_HIGHRES_TIMER)
|
||||||
define_if("raylib" SUPPORT_DATA_STORAGE)
|
|
||||||
define_if("raylib" SUPPORT_COMPRESSION_API)
|
define_if("raylib" SUPPORT_COMPRESSION_API)
|
||||||
define_if("raylib" SUPPORT_QUADS_DRAW_MODE)
|
define_if("raylib" SUPPORT_QUADS_DRAW_MODE)
|
||||||
define_if("raylib" SUPPORT_IMAGE_EXPORT)
|
define_if("raylib" SUPPORT_IMAGE_EXPORT)
|
||||||
|
|
|
||||||
|
|
@ -388,7 +388,6 @@ CORE = \
|
||||||
core/core_storage_values \
|
core/core_storage_values \
|
||||||
core/core_vr_simulator \
|
core/core_vr_simulator \
|
||||||
core/core_loading_thread \
|
core/core_loading_thread \
|
||||||
core/core_quat_conversion \
|
|
||||||
core/core_window_flags \
|
core/core_window_flags \
|
||||||
core/core_split_screen \
|
core/core_split_screen \
|
||||||
core/core_smooth_pixelperfect \
|
core/core_smooth_pixelperfect \
|
||||||
|
|
|
||||||
|
|
@ -402,7 +402,6 @@ CORE = \
|
||||||
core/core_storage_values \
|
core/core_storage_values \
|
||||||
core/core_vr_simulator \
|
core/core_vr_simulator \
|
||||||
core/core_loading_thread \
|
core/core_loading_thread \
|
||||||
core/core_quat_conversion \
|
|
||||||
core/core_window_flags \
|
core/core_window_flags \
|
||||||
core/core_split_screen \
|
core/core_split_screen \
|
||||||
core/core_smooth_pixelperfect \
|
core/core_smooth_pixelperfect \
|
||||||
|
|
@ -594,9 +593,6 @@ core/core_vr_simulator: core/core_vr_simulator.c
|
||||||
core/core_loading_thread: core/core_loading_thread.c
|
core/core_loading_thread: core/core_loading_thread.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s USE_PTHREADS=1
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -s USE_PTHREADS=1
|
||||||
|
|
||||||
core/core_quat_conversion: core/core_quat_conversion.c
|
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
|
||||||
|
|
||||||
core/core_window_flags: core/core_window_flags.c
|
core/core_window_flags: core/core_window_flags.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ Examples using raylib core platform functionality like window creation, inputs,
|
||||||
| 20 | [core_storage_values](core/core_storage_values.c) | <img src="core/core_storage_values.png" alt="core_storage_values" width="200"> | ray | |
|
| 20 | [core_storage_values](core/core_storage_values.c) | <img src="core/core_storage_values.png" alt="core_storage_values" width="200"> | ray | |
|
||||||
| 21 | [core_vr_simulator](core/core_vr_simulator.c) | <img src="core/core_vr_simulator.png" alt="core_vr_simulator" width="200"> | ray | ⭐️ |
|
| 21 | [core_vr_simulator](core/core_vr_simulator.c) | <img src="core/core_vr_simulator.png" alt="core_vr_simulator" width="200"> | ray | ⭐️ |
|
||||||
| 22 | [core_loading_thread](core/core_loading_thread.c) | <img src="core/core_loading_thread.png" alt="core_loading_thread" width="200"> | ray | |
|
| 22 | [core_loading_thread](core/core_loading_thread.c) | <img src="core/core_loading_thread.png" alt="core_loading_thread" width="200"> | ray | |
|
||||||
| 23 | [core/core_quat_conversion](core/core_quat_conversion.c) | <img src="core/core_quat_conversion.png" alt="core_quat_conversion" width="200"> | [Chris Camacho](https://github.com/codifies) | |
|
|
||||||
| 24 | [core/core_window_flags](core/core_window_flags.c) | <img src="core/core_window_flags.png" alt="core_window_flags" width="200"> | ray | |
|
| 24 | [core/core_window_flags](core/core_window_flags.c) | <img src="core/core_window_flags.png" alt="core_window_flags" width="200"> | ray | |
|
||||||
|
|
||||||
### category: shapes
|
### category: shapes
|
||||||
|
|
|
||||||
|
|
@ -1,135 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [core] example - quat conversions
|
|
||||||
*
|
|
||||||
* Generally you should really stick to eulers OR quats...
|
|
||||||
* This tests that various conversions are equivalent.
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 3.5 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
*
|
|
||||||
* Example contributed by Chris Camacho (@chriscamacho) and reviewed by Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020-2021 Chris Camacho (@chriscamacho) and Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
#include "raymath.h"
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - quat conversions");
|
|
||||||
|
|
||||||
Camera3D camera = { 0 };
|
|
||||||
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position
|
|
||||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
|
||||||
|
|
||||||
// Load a cylinder model for testing
|
|
||||||
Model model = LoadModelFromMesh(GenMeshCylinder(0.2f, 1.0f, 32));
|
|
||||||
|
|
||||||
// Generic quaternion for operations
|
|
||||||
Quaternion q1 = { 0 };
|
|
||||||
|
|
||||||
// Transform matrices required to draw 4 cylinders
|
|
||||||
Matrix m1 = { 0 };
|
|
||||||
Matrix m2 = { 0 };
|
|
||||||
Matrix m3 = { 0 };
|
|
||||||
Matrix m4 = { 0 };
|
|
||||||
|
|
||||||
// Generic vectors for rotations
|
|
||||||
Vector3 v1 = { 0 };
|
|
||||||
Vector3 v2 = { 0 };
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
if (v2.x < 0) v2.x += PI*2;
|
|
||||||
if (v2.y < 0) v2.y += PI*2;
|
|
||||||
if (v2.z < 0) v2.z += PI*2;
|
|
||||||
|
|
||||||
if (!IsKeyDown(KEY_SPACE))
|
|
||||||
{
|
|
||||||
v1.x += 0.01f;
|
|
||||||
v1.y += 0.03f;
|
|
||||||
v1.z += 0.05f;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (v1.x > PI*2) v1.x -= PI*2;
|
|
||||||
if (v1.y > PI*2) v1.y -= PI*2;
|
|
||||||
if (v1.z > PI*2) v1.z -= PI*2;
|
|
||||||
|
|
||||||
q1 = QuaternionFromEuler(v1.x, v1.y, v1.z);
|
|
||||||
m1 = MatrixRotateZYX(v1);
|
|
||||||
m2 = QuaternionToMatrix(q1);
|
|
||||||
|
|
||||||
q1 = QuaternionFromMatrix(m1);
|
|
||||||
m3 = QuaternionToMatrix(q1);
|
|
||||||
|
|
||||||
v2 = QuaternionToEuler(q1); // Angles returned in radians
|
|
||||||
|
|
||||||
m4 = MatrixRotateZYX(v2);
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
BeginMode3D(camera);
|
|
||||||
|
|
||||||
model.transform = m1;
|
|
||||||
DrawModel(model, (Vector3){ -1, 0, 0 }, 1.0f, RED);
|
|
||||||
|
|
||||||
model.transform = m2;
|
|
||||||
DrawModel(model, (Vector3){ 1, 0, 0 }, 1.0f, RED);
|
|
||||||
|
|
||||||
model.transform = m3;
|
|
||||||
DrawModel(model, (Vector3){ 0, 0, 0 }, 1.0f, RED);
|
|
||||||
|
|
||||||
model.transform = m4;
|
|
||||||
DrawModel(model, (Vector3){ 0, 0, -1 }, 1.0f, RED);
|
|
||||||
|
|
||||||
DrawGrid(10, 1.0f);
|
|
||||||
|
|
||||||
EndMode3D();
|
|
||||||
|
|
||||||
DrawText(TextFormat("%2.3f", v1.x), 20, 20, 20, (v1.x == v2.x)? GREEN: BLACK);
|
|
||||||
DrawText(TextFormat("%2.3f", v1.y), 20, 40, 20, (v1.y == v2.y)? GREEN: BLACK);
|
|
||||||
DrawText(TextFormat("%2.3f", v1.z), 20, 60, 20, (v1.z == v2.z)? GREEN: BLACK);
|
|
||||||
|
|
||||||
DrawText(TextFormat("%2.3f", v2.x), 200, 20, 20, (v1.x == v2.x)? GREEN: BLACK);
|
|
||||||
DrawText(TextFormat("%2.3f", v2.y), 200, 40, 20, (v1.y == v2.y)? GREEN: BLACK);
|
|
||||||
DrawText(TextFormat("%2.3f", v2.z), 200, 60, 20, (v1.z == v2.z)? GREEN: BLACK);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
UnloadModel(model); // Unload model data (mesh and materials)
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
|
|
@ -11,12 +11,20 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#include <stdlib.h> // Required for: calloc(), free()
|
||||||
|
|
||||||
|
#define STORAGE_DATA_FILE "storage.data" // Storage file
|
||||||
|
|
||||||
// NOTE: Storage positions must start with 0, directly related to file memory layout
|
// NOTE: Storage positions must start with 0, directly related to file memory layout
|
||||||
typedef enum {
|
typedef enum {
|
||||||
STORAGE_POSITION_SCORE = 0,
|
STORAGE_POSITION_SCORE = 0,
|
||||||
STORAGE_POSITION_HISCORE = 1
|
STORAGE_POSITION_HISCORE = 1
|
||||||
} StorageData;
|
} StorageData;
|
||||||
|
|
||||||
|
// Persistent storage functions
|
||||||
|
static bool SaveStorageValue(unsigned int position, int value);
|
||||||
|
static int LoadStorageValue(unsigned int position);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
@ -87,4 +95,97 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save integer value to storage file (to defined position)
|
||||||
|
// NOTE: Storage positions is directly related to file memory layout (4 bytes each integer)
|
||||||
|
bool SaveStorageValue(unsigned int position, int value)
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
unsigned int dataSize = 0;
|
||||||
|
unsigned int newDataSize = 0;
|
||||||
|
unsigned char *fileData = LoadFileData(STORAGE_DATA_FILE, &dataSize);
|
||||||
|
unsigned char *newFileData = NULL;
|
||||||
|
|
||||||
|
if (fileData != NULL)
|
||||||
|
{
|
||||||
|
if (dataSize <= (position*sizeof(int)))
|
||||||
|
{
|
||||||
|
// Increase data size up to position and store value
|
||||||
|
newDataSize = (position + 1)*sizeof(int);
|
||||||
|
newFileData = (unsigned char *)RL_REALLOC(fileData, newDataSize);
|
||||||
|
|
||||||
|
if (newFileData != NULL)
|
||||||
|
{
|
||||||
|
// RL_REALLOC succeded
|
||||||
|
int *dataPtr = (int *)newFileData;
|
||||||
|
dataPtr[position] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// RL_REALLOC failed
|
||||||
|
TraceLog(LOG_WARNING, "FILEIO: [%s] Failed to realloc data (%u), position in bytes (%u) bigger than actual file size", STORAGE_DATA_FILE, dataSize, position*sizeof(int));
|
||||||
|
|
||||||
|
// We store the old size of the file
|
||||||
|
newFileData = fileData;
|
||||||
|
newDataSize = dataSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Store the old size of the file
|
||||||
|
newFileData = fileData;
|
||||||
|
newDataSize = dataSize;
|
||||||
|
|
||||||
|
// Replace value on selected position
|
||||||
|
int *dataPtr = (int *)newFileData;
|
||||||
|
dataPtr[position] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
success = SaveFileData(STORAGE_DATA_FILE, newFileData, newDataSize);
|
||||||
|
RL_FREE(newFileData);
|
||||||
|
|
||||||
|
TraceLog(LOG_INFO, "FILEIO: [%s] Saved storage value: %i", STORAGE_DATA_FILE, value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TraceLog(LOG_INFO, "FILEIO: [%s] File created successfully", STORAGE_DATA_FILE);
|
||||||
|
|
||||||
|
dataSize = (position + 1)*sizeof(int);
|
||||||
|
fileData = (unsigned char *)RL_MALLOC(dataSize);
|
||||||
|
int *dataPtr = (int *)fileData;
|
||||||
|
dataPtr[position] = value;
|
||||||
|
|
||||||
|
success = SaveFileData(STORAGE_DATA_FILE, fileData, dataSize);
|
||||||
|
UnloadFileData(fileData);
|
||||||
|
|
||||||
|
TraceLog(LOG_INFO, "FILEIO: [%s] Saved storage value: %i", STORAGE_DATA_FILE, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load integer value from storage file (from defined position)
|
||||||
|
// NOTE: If requested position could not be found, value 0 is returned
|
||||||
|
int LoadStorageValue(unsigned int position)
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
unsigned int dataSize = 0;
|
||||||
|
unsigned char *fileData = LoadFileData(STORAGE_DATA_FILE, &dataSize);
|
||||||
|
|
||||||
|
if (fileData != NULL)
|
||||||
|
{
|
||||||
|
if (dataSize < (position*4)) TraceLog(LOG_WARNING, "FILEIO: [%s] Failed to find storage position: %i", STORAGE_DATA_FILE, position);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int *dataPtr = (int *)fileData;
|
||||||
|
value = dataPtr[position];
|
||||||
|
}
|
||||||
|
|
||||||
|
UnloadFileData(fileData);
|
||||||
|
|
||||||
|
TraceLog(LOG_INFO, "FILEIO: [%s] Loaded storage value: %i", STORAGE_DATA_FILE, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
@ -1,25 +1,16 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [models] example - Load models gltf
|
* raylib [models] example - loading gltf
|
||||||
*
|
*
|
||||||
* This example has been created using raylib 3.5 (www.raylib.com)
|
* This example has been created using raylib 4.2 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* NOTE: To export a model from Blender, make sure it is not posed, the vertices need to be
|
* Copyright (c) 2022 Ramon Santamaria (@raysan5)
|
||||||
* in the same position as they would be in edit mode.
|
|
||||||
* Also make sure the scale parameter of your models is set to 0.0,
|
|
||||||
* scaling can be applied from the export menu.
|
|
||||||
*
|
|
||||||
* Example contributed by Hristo Stamenov (@object71) and reviewed by Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2021 Hristo Stamenov (@object71) and Ramon Santamaria (@raysan5)
|
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#define MAX_GLTF_MODELS 8
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
@ -30,7 +21,7 @@ int main(void)
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - model");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - loading gltf");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = { 0 };
|
Camera camera = { 0 };
|
||||||
|
|
@ -40,18 +31,8 @@ int main(void)
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
||||||
|
|
||||||
// Load some models
|
// Loaf gltf model
|
||||||
Model model[MAX_GLTF_MODELS] = { 0 };
|
Model model = LoadModel("resources/models/gltf/robot.glb");
|
||||||
model[0] = LoadModel("resources/models/gltf/raylib_32x32.glb");
|
|
||||||
model[1] = LoadModel("resources/models/gltf/rigged_figure.glb");
|
|
||||||
model[2] = LoadModel("resources/models/gltf/GearboxAssy.glb");
|
|
||||||
model[3] = LoadModel("resources/models/gltf/BoxAnimated.glb");
|
|
||||||
model[4] = LoadModel("resources/models/gltf/AnimatedTriangle.gltf");
|
|
||||||
model[5] = LoadModel("resources/models/gltf/AnimatedMorphCube.glb");
|
|
||||||
model[6] = LoadModel("resources/models/gltf/vertex_colored_object.glb");
|
|
||||||
model[7] = LoadModel("resources/models/gltf/girl.glb");
|
|
||||||
|
|
||||||
int currentModel = 0;
|
|
||||||
|
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
|
|
||||||
|
|
@ -66,18 +47,6 @@ int main(void)
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
UpdateCamera(&camera); // Update our camera with inputs
|
UpdateCamera(&camera); // Update our camera with inputs
|
||||||
|
|
||||||
if (IsKeyReleased(KEY_RIGHT))
|
|
||||||
{
|
|
||||||
currentModel++;
|
|
||||||
if (currentModel == MAX_GLTF_MODELS) currentModel = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyReleased(KEY_LEFT))
|
|
||||||
{
|
|
||||||
currentModel--;
|
|
||||||
if (currentModel < 0) currentModel = MAX_GLTF_MODELS - 1;
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
@ -88,7 +57,7 @@ int main(void)
|
||||||
|
|
||||||
BeginMode3D(camera);
|
BeginMode3D(camera);
|
||||||
|
|
||||||
DrawModel(model[currentModel], position, 1.0f, WHITE);
|
DrawModel(model, position, 1.0f, WHITE);
|
||||||
DrawGrid(10, 1.0f); // Draw a grid
|
DrawGrid(10, 1.0f); // Draw a grid
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
@ -99,8 +68,8 @@ int main(void)
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
for (int i = 0; i < MAX_GLTF_MODELS; i++) UnloadModel(model[i]); // Unload models
|
UnloadModel(model); // Unload model and meshes/material
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
| resource | author | licence | notes |
|
| resource | author | licence | notes |
|
||||||
| :------------------- | :---------: | :------ | :---- |
|
| :------------------- | :---------: | :------ | :---- |
|
||||||
| models/obj/castle.obj,<br>models/castle_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
| models/obj/castle.obj,<br>models/obj/castle_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
||||||
| models/obj/bridge.obj,<br>models/bridge_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
| models/obj/bridge.obj,<br>models/obj/bridge_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
||||||
| models/obj/house.obj,<br>models/house_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
| models/obj/house.obj,<br>models/obj/house_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
||||||
| models/obj/market.obj,<br>models/market_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
| models/obj/market.obj,<br>models/obj/market_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
||||||
| models/obj/turret.obj,<br>models/turret_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
| models/obj/turret.obj,<br>models/obj/turret_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
||||||
| models/obj/well.obj,<br>models/well_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
| models/obj/well.obj,<br>models/obj/well_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
|
||||||
| models/obj/cube.obj,<br>models/cube_diffuse.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
| models/obj/cube.obj,<br>models/obj/cube_diffuse.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
||||||
| models/obj/plane.gltf,<br>models/gltf/plane/plane.bin,<br>models/gltf/plane/plane_diffuse.png | [GiaHanLam](https://sketchfab.com/GiaHanLam) | [CC-BY](https://creativecommons.org/licenses/by/4.0/) | Used by: [`models_yaw_pitch_roll.c`](https://github.com/raysan5/raylib/blob/master/examples/models/models_yaw_pitch_roll.c)
|
| models/obj/plane.obj,<br>models/obj/plane_diffuse.png | [GiaHanLam](https://sketchfab.com/GiaHanLam) | [CC-BY](https://creativecommons.org/licenses/by/4.0/) | Used by: [`models_yaw_pitch_roll.c`](https://github.com/raysan5/raylib/blob/master/examples/models/models_yaw_pitch_roll.c)
|
||||||
| models/iqm/guy.iqm,<br>models/iqm/guyanim.iqm,<br>models/iqm/guytex.png,<br>models/iqm/guy.blend | [@culacant](https://github.com/culacant) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
| models/iqm/guy.iqm,<br>models/iqm/guyanim.iqm,<br>models/iqm/guytex.png,<br>models/iqm/guy.blend | [@culacant](https://github.com/culacant) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
||||||
| models/iqm/vertex_colored_object.iqm | ❔ | ❔ | - |
|
| models/gltf/robot.glb,<br>models/gltf/robot.blend | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
|
||||||
| models/gltf/... | _various_ | Check [LICENSE](https://github.com/raysan5/raylib/blob/master/examples/models/resources/models/gltf/LICENSE) | - |
|
|
||||||
| models/vox/chr_knight.vox | ❔ | ❔ | - |
|
| models/vox/chr_knight.vox | ❔ | ❔ | - |
|
||||||
| models/vox/chr_sword.vox | ❔ | ❔ | - |
|
| models/vox/chr_sword.vox | ❔ | ❔ | - |
|
||||||
| models/vox/monu9.vox | ❔ | ❔ | - |
|
| models/vox/monu9.vox | ❔ | ❔ | - |
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1,118 +0,0 @@
|
||||||
{
|
|
||||||
"scene" : 0,
|
|
||||||
"scenes" : [
|
|
||||||
{
|
|
||||||
"nodes" : [ 0 ]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
"nodes" : [
|
|
||||||
{
|
|
||||||
"mesh" : 0,
|
|
||||||
"rotation" : [ 0.0, 0.0, 0.0, 1.0 ]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
"meshes" : [
|
|
||||||
{
|
|
||||||
"primitives" : [ {
|
|
||||||
"attributes" : {
|
|
||||||
"POSITION" : 1
|
|
||||||
},
|
|
||||||
"indices" : 0
|
|
||||||
} ]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
"animations": [
|
|
||||||
{
|
|
||||||
"samplers" : [
|
|
||||||
{
|
|
||||||
"input" : 2,
|
|
||||||
"interpolation" : "LINEAR",
|
|
||||||
"output" : 3
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"channels" : [ {
|
|
||||||
"sampler" : 0,
|
|
||||||
"target" : {
|
|
||||||
"node" : 0,
|
|
||||||
"path" : "rotation"
|
|
||||||
}
|
|
||||||
} ]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
"buffers" : [
|
|
||||||
{
|
|
||||||
"uri" : "data:application/octet-stream;base64,AAABAAIAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAA=",
|
|
||||||
"byteLength" : 44
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"uri" : "data:application/octet-stream;base64,AAAAAAAAgD4AAAA/AABAPwAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAD0/TQ/9P00PwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAPT9ND/0/TS/AAAAAAAAAAAAAAAAAACAPw==",
|
|
||||||
"byteLength" : 100
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"bufferViews" : [
|
|
||||||
{
|
|
||||||
"buffer" : 0,
|
|
||||||
"byteOffset" : 0,
|
|
||||||
"byteLength" : 6,
|
|
||||||
"target" : 34963
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"buffer" : 0,
|
|
||||||
"byteOffset" : 8,
|
|
||||||
"byteLength" : 36,
|
|
||||||
"target" : 34962
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"buffer" : 1,
|
|
||||||
"byteOffset" : 0,
|
|
||||||
"byteLength" : 100
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"accessors" : [
|
|
||||||
{
|
|
||||||
"bufferView" : 0,
|
|
||||||
"byteOffset" : 0,
|
|
||||||
"componentType" : 5123,
|
|
||||||
"count" : 3,
|
|
||||||
"type" : "SCALAR",
|
|
||||||
"max" : [ 2 ],
|
|
||||||
"min" : [ 0 ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView" : 1,
|
|
||||||
"byteOffset" : 0,
|
|
||||||
"componentType" : 5126,
|
|
||||||
"count" : 3,
|
|
||||||
"type" : "VEC3",
|
|
||||||
"max" : [ 1.0, 1.0, 0.0 ],
|
|
||||||
"min" : [ 0.0, 0.0, 0.0 ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView" : 2,
|
|
||||||
"byteOffset" : 0,
|
|
||||||
"componentType" : 5126,
|
|
||||||
"count" : 5,
|
|
||||||
"type" : "SCALAR",
|
|
||||||
"max" : [ 1.0 ],
|
|
||||||
"min" : [ 0.0 ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView" : 2,
|
|
||||||
"byteOffset" : 20,
|
|
||||||
"componentType" : 5126,
|
|
||||||
"count" : 5,
|
|
||||||
"type" : "VEC4",
|
|
||||||
"max" : [ 0.0, 0.0, 1.0, 1.0 ],
|
|
||||||
"min" : [ 0.0, 0.0, 0.0, -0.707 ]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
"asset" : {
|
|
||||||
"version" : "2.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
|
@ -1,23 +1,2 @@
|
||||||
Rigged Figure model has been created by Cesium (https://cesium.com/cesiumjs/),
|
robot.glb model by @Quaternius (https://www.patreon.com/quaternius)
|
||||||
and licensed as Creative Commons Attribution 4.0 International License.
|
Licensed under CC0 1.0 Universal (CC0 1.0) - Public Domain Dedication (https://creativecommons.org/publicdomain/zero/1.0/)
|
||||||
|
|
||||||
Box Animated model has been created by Cesium (https://cesium.com/cesiumjs/)
|
|
||||||
and is licensed as Creative Commons Attribution 4.0 International License
|
|
||||||
|
|
||||||
Avocado model is provided by Microsoft
|
|
||||||
and licensed as CC0 Universal Public Domain
|
|
||||||
|
|
||||||
Animated Morph Cube model is provided by Microsoft
|
|
||||||
and licensed as CC0 Universal Public Domain
|
|
||||||
|
|
||||||
Animated Triangle model is licensed as CC0 Universal Public Domain
|
|
||||||
|
|
||||||
Gearbox Assy model has been provided by Okino Computer Graphics, using Okino Polytrans Software.
|
|
||||||
no license information was provided
|
|
||||||
|
|
||||||
Girl model has been provided by Hristo Stamenov (https://thatonegamedev.com/)
|
|
||||||
and licensed as CC0 Universal Public Domain
|
|
||||||
|
|
||||||
Check for details on CC0: https://creativecommons.org/publicdomain/zero/1.0/
|
|
||||||
Check for details on CC4: http://creativecommons.org/licenses/by/4.0/
|
|
||||||
GLTF sample models for testing are taken from: https://github.com/KhronosGroup/glTF-Sample-Models/
|
|
||||||
Binary file not shown.
Binary file not shown.
BIN
examples/models/resources/models/gltf/robot.blend
Normal file
BIN
examples/models/resources/models/gltf/robot.blend
Normal file
Binary file not shown.
BIN
examples/models/resources/models/gltf/robot.glb
Normal file
BIN
examples/models/resources/models/gltf/robot.glb
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -58,27 +58,25 @@ int main(void)
|
||||||
unsigned int golLogicProgram = rlLoadComputeShaderProgram(golLogicShader);
|
unsigned int golLogicProgram = rlLoadComputeShaderProgram(golLogicShader);
|
||||||
UnloadFileText(golLogicCode);
|
UnloadFileText(golLogicCode);
|
||||||
|
|
||||||
// Game of Life logic compute shader
|
// Game of Life logic render shader
|
||||||
Shader golRenderShader = LoadShader(NULL, "resources/shaders/glsl430/gol_render.glsl");
|
Shader golRenderShader = LoadShader(NULL, "resources/shaders/glsl430/gol_render.glsl");
|
||||||
int resUniformLoc = GetShaderLocation(golRenderShader, "resolution");
|
int resUniformLoc = GetShaderLocation(golRenderShader, "resolution");
|
||||||
|
|
||||||
// Game of Life transfert shader
|
// Game of Life transfert shader (CPU<->GPU download and upload)
|
||||||
char *golTransfertCode = LoadFileText("resources/shaders/glsl430/gol_transfert.glsl");
|
char *golTransfertCode = LoadFileText("resources/shaders/glsl430/gol_transfert.glsl");
|
||||||
unsigned int golTransfertShader = rlCompileShader(golTransfertCode, RL_COMPUTE_SHADER);
|
unsigned int golTransfertShader = rlCompileShader(golTransfertCode, RL_COMPUTE_SHADER);
|
||||||
unsigned int golTransfertProgram = rlLoadComputeShaderProgram(golTransfertShader);
|
unsigned int golTransfertProgram = rlLoadComputeShaderProgram(golTransfertShader);
|
||||||
UnloadFileText(golTransfertCode);
|
UnloadFileText(golTransfertCode);
|
||||||
|
|
||||||
// SSBOs
|
// Load shader storage buffer object (SSBO), id returned
|
||||||
unsigned int ssboA = rlLoadShaderBuffer(GOL_WIDTH*GOL_WIDTH*sizeof(unsigned int), NULL, RL_DYNAMIC_COPY);
|
unsigned int ssboA = rlLoadShaderBuffer(GOL_WIDTH*GOL_WIDTH*sizeof(unsigned int), NULL, RL_DYNAMIC_COPY);
|
||||||
unsigned int ssboB = rlLoadShaderBuffer(GOL_WIDTH*GOL_WIDTH*sizeof(unsigned int), NULL, RL_DYNAMIC_COPY);
|
unsigned int ssboB = rlLoadShaderBuffer(GOL_WIDTH*GOL_WIDTH*sizeof(unsigned int), NULL, RL_DYNAMIC_COPY);
|
||||||
|
unsigned int ssboTransfert = rlLoadShaderBuffer(sizeof(GolUpdateSSBO), NULL, RL_DYNAMIC_COPY);
|
||||||
struct GolUpdateSSBO transfertBuffer;
|
|
||||||
transfertBuffer.count = 0;
|
GolUpdateSSBO transfertBuffer = { 0 };
|
||||||
|
|
||||||
int transfertSSBO = rlLoadShaderBuffer(sizeof(struct GolUpdateSSBO), NULL, RL_DYNAMIC_COPY);
|
|
||||||
|
|
||||||
// Create a white texture of the size of the window to update
|
// Create a white texture of the size of the window to update
|
||||||
// each pixel of the window using the fragment shader
|
// each pixel of the window using the fragment shader: golRenderShader
|
||||||
Image whiteImage = GenImageColor(GOL_WIDTH, GOL_WIDTH, WHITE);
|
Image whiteImage = GenImageColor(GOL_WIDTH, GOL_WIDTH, WHITE);
|
||||||
Texture whiteTex = LoadTextureFromImage(whiteImage);
|
Texture whiteTex = LoadTextureFromImage(whiteImage);
|
||||||
UnloadImage(whiteImage);
|
UnloadImage(whiteImage);
|
||||||
|
|
@ -101,18 +99,16 @@ int main(void)
|
||||||
transfertBuffer.commands[transfertBuffer.count].enabled = IsMouseButtonDown(MOUSE_BUTTON_LEFT);
|
transfertBuffer.commands[transfertBuffer.count].enabled = IsMouseButtonDown(MOUSE_BUTTON_LEFT);
|
||||||
transfertBuffer.count++;
|
transfertBuffer.count++;
|
||||||
}
|
}
|
||||||
else if (transfertBuffer.count > 0)
|
else if (transfertBuffer.count > 0) // Process transfert buffer
|
||||||
{
|
{
|
||||||
// Process transfert buffer
|
|
||||||
|
|
||||||
// Send SSBO buffer to GPU
|
// Send SSBO buffer to GPU
|
||||||
rlUpdateShaderBufferElements(transfertSSBO, &transfertBuffer, sizeof(struct GolUpdateSSBO), 0);
|
rlUpdateShaderBufferElements(ssboTransfert, &transfertBuffer, sizeof(GolUpdateSSBO), 0);
|
||||||
|
|
||||||
// Process ssbo command
|
// Process ssbo commands on GPU
|
||||||
rlEnableShader(golTransfertProgram);
|
rlEnableShader(golTransfertProgram);
|
||||||
rlBindShaderBuffer(ssboA, 1);
|
rlBindShaderBuffer(ssboA, 1);
|
||||||
rlBindShaderBuffer(transfertSSBO, 3);
|
rlBindShaderBuffer(ssboTransfert, 3);
|
||||||
rlComputeShaderDispatch(transfertBuffer.count, 1, 1); // each GPU unit will process a command
|
rlComputeShaderDispatch(transfertBuffer.count, 1, 1); // Each GPU unit will process a command!
|
||||||
rlDisableShader();
|
rlDisableShader();
|
||||||
|
|
||||||
transfertBuffer.count = 0;
|
transfertBuffer.count = 0;
|
||||||
|
|
@ -160,7 +156,7 @@ int main(void)
|
||||||
// Unload shader buffers objects.
|
// Unload shader buffers objects.
|
||||||
rlUnloadShaderBuffer(ssboA);
|
rlUnloadShaderBuffer(ssboA);
|
||||||
rlUnloadShaderBuffer(ssboB);
|
rlUnloadShaderBuffer(ssboB);
|
||||||
rlUnloadShaderBuffer(transfertSSBO);
|
rlUnloadShaderBuffer(ssboTransfert);
|
||||||
|
|
||||||
// Unload compute shader programs
|
// Unload compute shader programs
|
||||||
rlUnloadShaderProgram(golTransfertProgram);
|
rlUnloadShaderProgram(golTransfertProgram);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
// Input vertex attributes (from vertex shader)
|
// Input vertex attributes (from vertex shader)
|
||||||
in vec3 fragPosition;
|
in vec3 fragPosition;
|
||||||
in vec2 fragTexCoord;
|
in vec2 fragTexCoord;
|
||||||
in vec4 fragColor;
|
//in vec4 fragColor;
|
||||||
in vec3 fragNormal;
|
in vec3 fragNormal;
|
||||||
|
|
||||||
// Input uniform values
|
// Input uniform values
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
in vec3 vertexPosition;
|
in vec3 vertexPosition;
|
||||||
in vec2 vertexTexCoord;
|
in vec2 vertexTexCoord;
|
||||||
in vec3 vertexNormal;
|
in vec3 vertexNormal;
|
||||||
in vec4 vertexColor;
|
//in vec4 vertexColor; // Not required
|
||||||
|
|
||||||
in mat4 instanceTransform;
|
in mat4 instanceTransform;
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ void main()
|
||||||
// Send vertex attributes to fragment shader
|
// Send vertex attributes to fragment shader
|
||||||
fragPosition = vec3(mvpi*vec4(vertexPosition, 1.0));
|
fragPosition = vec3(mvpi*vec4(vertexPosition, 1.0));
|
||||||
fragTexCoord = vertexTexCoord;
|
fragTexCoord = vertexTexCoord;
|
||||||
fragColor = vertexColor;
|
//fragColor = vertexColor;
|
||||||
fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0)));
|
fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0)));
|
||||||
|
|
||||||
// Calculate final vertex position
|
// Calculate final vertex position
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
#include "rlights.h"
|
#include "rlights.h"
|
||||||
|
|
||||||
#include <stdlib.h> // Required for: calloc(), free()
|
#include <stdlib.h> // Required for: calloc(), free()
|
||||||
#include <math.h> // Required for:
|
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define GLSL_VERSION 330
|
#define GLSL_VERSION 330
|
||||||
|
|
@ -27,7 +26,7 @@
|
||||||
#define GLSL_VERSION 100
|
#define GLSL_VERSION 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_INSTANCES 8000
|
#define MAX_INSTANCES 10000
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
|
|
@ -87,7 +86,9 @@ int main(void)
|
||||||
matInstances.shader = shader;
|
matInstances.shader = shader;
|
||||||
matInstances.maps[MATERIAL_MAP_DIFFUSE].color = RED;
|
matInstances.maps[MATERIAL_MAP_DIFFUSE].color = RED;
|
||||||
|
|
||||||
// Create a defult material with default internal shader for non-instanced mesh drawing
|
// Load default material (using raylib intenral default shader) for non-instanced mesh drawing
|
||||||
|
// WARNING: Default shader enables vertex color attribute BUT GenMeshCube() does not generate vertex colors, so,
|
||||||
|
// when drawing the color attribute is disabled and a default color value is provided as input for thevertex attribute
|
||||||
Material matDefault = LoadMaterialDefault();
|
Material matDefault = LoadMaterialDefault();
|
||||||
matDefault.maps[MATERIAL_MAP_DIFFUSE].color = BLUE;
|
matDefault.maps[MATERIAL_MAP_DIFFUSE].color = BLUE;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,6 @@
|
||||||
#define SUPPORT_GIF_RECORDING 1
|
#define SUPPORT_GIF_RECORDING 1
|
||||||
// Support CompressData() and DecompressData() functions
|
// Support CompressData() and DecompressData() functions
|
||||||
#define SUPPORT_COMPRESSION_API 1
|
#define SUPPORT_COMPRESSION_API 1
|
||||||
// Support saving binary data automatically to a generated storage.data file. This file is managed internally.
|
|
||||||
#define SUPPORT_DATA_STORAGE 1
|
|
||||||
// Support automatic generated events, loading and recording of those events when required
|
// Support automatic generated events, loading and recording of those events when required
|
||||||
//#define SUPPORT_EVENTS_AUTOMATION 1
|
//#define SUPPORT_EVENTS_AUTOMATION 1
|
||||||
// Support custom frame control, only for advance users
|
// Support custom frame control, only for advance users
|
||||||
|
|
|
||||||
|
|
@ -1038,6 +1038,8 @@ RLAPI void *MemAlloc(int size); // Internal me
|
||||||
RLAPI void *MemRealloc(void *ptr, int size); // Internal memory reallocator
|
RLAPI void *MemRealloc(void *ptr, int size); // Internal memory reallocator
|
||||||
RLAPI void MemFree(void *ptr); // Internal memory free
|
RLAPI void MemFree(void *ptr); // Internal memory free
|
||||||
|
|
||||||
|
RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available)
|
||||||
|
|
||||||
// Set custom callbacks
|
// Set custom callbacks
|
||||||
// WARNING: Callbacks setup is intended for advance users
|
// WARNING: Callbacks setup is intended for advance users
|
||||||
RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log
|
RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log
|
||||||
|
|
@ -1081,12 +1083,6 @@ RLAPI unsigned char *DecompressData(const unsigned char *compData, int compDataS
|
||||||
RLAPI char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize); // Encode data to Base64 string, memory must be MemFree()
|
RLAPI char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize); // Encode data to Base64 string, memory must be MemFree()
|
||||||
RLAPI unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize); // Decode Base64 string data, memory must be MemFree()
|
RLAPI unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize); // Decode Base64 string data, memory must be MemFree()
|
||||||
|
|
||||||
// Persistent storage management
|
|
||||||
RLAPI bool SaveStorageValue(unsigned int position, int value); // Save integer value to storage file (to defined position), returns true on success
|
|
||||||
RLAPI int LoadStorageValue(unsigned int position); // Load integer value from storage file (from defined position)
|
|
||||||
|
|
||||||
RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available)
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Input Handling Functions (Module: core)
|
// Input Handling Functions (Module: core)
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
@ -1447,7 +1443,6 @@ RLAPI void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transfo
|
||||||
RLAPI bool ExportMesh(Mesh mesh, const char *fileName); // Export mesh data to file, returns true on success
|
RLAPI bool ExportMesh(Mesh mesh, const char *fileName); // Export mesh data to file, returns true on success
|
||||||
RLAPI BoundingBox GetMeshBoundingBox(Mesh mesh); // Compute mesh bounding box limits
|
RLAPI BoundingBox GetMeshBoundingBox(Mesh mesh); // Compute mesh bounding box limits
|
||||||
RLAPI void GenMeshTangents(Mesh *mesh); // Compute mesh tangents
|
RLAPI void GenMeshTangents(Mesh *mesh); // Compute mesh tangents
|
||||||
RLAPI void GenMeshBinormals(Mesh *mesh); // Compute mesh binormals
|
|
||||||
|
|
||||||
// Mesh generation functions
|
// Mesh generation functions
|
||||||
RLAPI Mesh GenMeshPoly(int sides, float radius); // Generate polygonal mesh
|
RLAPI Mesh GenMeshPoly(int sides, float radius); // Generate polygonal mesh
|
||||||
|
|
|
||||||
115
src/rcore.c
115
src/rcore.c
|
|
@ -80,9 +80,6 @@
|
||||||
* provided by stb_image and stb_image_write libraries, so, those libraries must be enabled on textures module
|
* provided by stb_image and stb_image_write libraries, so, those libraries must be enabled on textures module
|
||||||
* for linkage
|
* for linkage
|
||||||
*
|
*
|
||||||
* #define SUPPORT_DATA_STORAGE
|
|
||||||
* Support saving binary data automatically to a generated storage.data file. This file is managed internally
|
|
||||||
*
|
|
||||||
* #define SUPPORT_EVENTS_AUTOMATION
|
* #define SUPPORT_EVENTS_AUTOMATION
|
||||||
* Support automatic generated events, loading and recording of those events when required
|
* Support automatic generated events, loading and recording of those events when required
|
||||||
*
|
*
|
||||||
|
|
@ -332,12 +329,6 @@
|
||||||
#define MAX_CHAR_PRESSED_QUEUE 16 // Maximum number of characters in the char input queue
|
#define MAX_CHAR_PRESSED_QUEUE 16 // Maximum number of characters in the char input queue
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SUPPORT_DATA_STORAGE)
|
|
||||||
#ifndef STORAGE_DATA_FILE
|
|
||||||
#define STORAGE_DATA_FILE "storage.data" // Automatic storage filename
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MAX_DECOMPRESSION_SIZE
|
#ifndef MAX_DECOMPRESSION_SIZE
|
||||||
#define MAX_DECOMPRESSION_SIZE 64 // Maximum size allocated for decompression in MB
|
#define MAX_DECOMPRESSION_SIZE 64 // Maximum size allocated for decompression in MB
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -3290,7 +3281,7 @@ unsigned char *DecompressData(const unsigned char *compData, int compDataSize, i
|
||||||
#if defined(SUPPORT_COMPRESSION_API)
|
#if defined(SUPPORT_COMPRESSION_API)
|
||||||
// Decompress data from a valid DEFLATE stream
|
// Decompress data from a valid DEFLATE stream
|
||||||
data = RL_CALLOC(MAX_DECOMPRESSION_SIZE*1024*1024, 1);
|
data = RL_CALLOC(MAX_DECOMPRESSION_SIZE*1024*1024, 1);
|
||||||
int length = sinflate(data, MAX_DECOMPRESSION_SIZE, compData, compDataSize);
|
int length = sinflate(data, MAX_DECOMPRESSION_SIZE*1024*1024, compData, compDataSize);
|
||||||
unsigned char *temp = RL_REALLOC(data, length);
|
unsigned char *temp = RL_REALLOC(data, length);
|
||||||
|
|
||||||
if (temp != NULL) data = temp;
|
if (temp != NULL) data = temp;
|
||||||
|
|
@ -3398,110 +3389,6 @@ unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize)
|
||||||
return decodedData;
|
return decodedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save integer value to storage file (to defined position)
|
|
||||||
// NOTE: Storage positions is directly related to file memory layout (4 bytes each integer)
|
|
||||||
bool SaveStorageValue(unsigned int position, int value)
|
|
||||||
{
|
|
||||||
bool success = false;
|
|
||||||
|
|
||||||
#if defined(SUPPORT_DATA_STORAGE)
|
|
||||||
char path[512] = { 0 };
|
|
||||||
strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, STORAGE_DATA_FILE));
|
|
||||||
|
|
||||||
unsigned int dataSize = 0;
|
|
||||||
unsigned int newDataSize = 0;
|
|
||||||
unsigned char *fileData = LoadFileData(path, &dataSize);
|
|
||||||
unsigned char *newFileData = NULL;
|
|
||||||
|
|
||||||
if (fileData != NULL)
|
|
||||||
{
|
|
||||||
if (dataSize <= (position*sizeof(int)))
|
|
||||||
{
|
|
||||||
// Increase data size up to position and store value
|
|
||||||
newDataSize = (position + 1)*sizeof(int);
|
|
||||||
newFileData = (unsigned char *)RL_REALLOC(fileData, newDataSize);
|
|
||||||
|
|
||||||
if (newFileData != NULL)
|
|
||||||
{
|
|
||||||
// RL_REALLOC succeded
|
|
||||||
int *dataPtr = (int *)newFileData;
|
|
||||||
dataPtr[position] = value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// RL_REALLOC failed
|
|
||||||
TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to realloc data (%u), position in bytes (%u) bigger than actual file size", path, dataSize, position*sizeof(int));
|
|
||||||
|
|
||||||
// We store the old size of the file
|
|
||||||
newFileData = fileData;
|
|
||||||
newDataSize = dataSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Store the old size of the file
|
|
||||||
newFileData = fileData;
|
|
||||||
newDataSize = dataSize;
|
|
||||||
|
|
||||||
// Replace value on selected position
|
|
||||||
int *dataPtr = (int *)newFileData;
|
|
||||||
dataPtr[position] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
success = SaveFileData(path, newFileData, newDataSize);
|
|
||||||
RL_FREE(newFileData);
|
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "FILEIO: [%s] Saved storage value: %i", path, value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TRACELOG(LOG_INFO, "FILEIO: [%s] File created successfully", path);
|
|
||||||
|
|
||||||
dataSize = (position + 1)*sizeof(int);
|
|
||||||
fileData = (unsigned char *)RL_MALLOC(dataSize);
|
|
||||||
int *dataPtr = (int *)fileData;
|
|
||||||
dataPtr[position] = value;
|
|
||||||
|
|
||||||
success = SaveFileData(path, fileData, dataSize);
|
|
||||||
UnloadFileData(fileData);
|
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "FILEIO: [%s] Saved storage value: %i", path, value);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load integer value from storage file (from defined position)
|
|
||||||
// NOTE: If requested position could not be found, value 0 is returned
|
|
||||||
int LoadStorageValue(unsigned int position)
|
|
||||||
{
|
|
||||||
int value = 0;
|
|
||||||
|
|
||||||
#if defined(SUPPORT_DATA_STORAGE)
|
|
||||||
char path[512] = { 0 };
|
|
||||||
strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, STORAGE_DATA_FILE));
|
|
||||||
|
|
||||||
unsigned int dataSize = 0;
|
|
||||||
unsigned char *fileData = LoadFileData(path, &dataSize);
|
|
||||||
|
|
||||||
if (fileData != NULL)
|
|
||||||
{
|
|
||||||
if (dataSize < (position*4)) TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to find storage position: %i", path, position);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int *dataPtr = (int *)fileData;
|
|
||||||
value = dataPtr[position];
|
|
||||||
}
|
|
||||||
|
|
||||||
UnloadFileData(fileData);
|
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "FILEIO: [%s] Loaded storage value: %i", path, value);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open URL with default system browser (if available)
|
// Open URL with default system browser (if available)
|
||||||
// NOTE: This function is only safe to use if you control the URL given.
|
// NOTE: This function is only safe to use if you control the URL given.
|
||||||
// A user could craft a malicious string performing another action.
|
// A user could craft a malicious string performing another action.
|
||||||
|
|
|
||||||
137
src/rmodels.c
137
src/rmodels.c
|
|
@ -152,7 +152,7 @@ void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color)
|
||||||
// WARNING: Be careful with internal buffer vertex alignment
|
// WARNING: Be careful with internal buffer vertex alignment
|
||||||
// when using RL_LINES or RL_TRIANGLES, data is aligned to fit
|
// when using RL_LINES or RL_TRIANGLES, data is aligned to fit
|
||||||
// lines-triangles-quads in the same indexed buffers!!!
|
// lines-triangles-quads in the same indexed buffers!!!
|
||||||
rlCheckRenderBatchLimit(8);
|
//rlCheckRenderBatchLimit(8);
|
||||||
|
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
|
|
@ -164,7 +164,7 @@ void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color)
|
||||||
// Draw a point in 3D space, actually a small line
|
// Draw a point in 3D space, actually a small line
|
||||||
void DrawPoint3D(Vector3 position, Color color)
|
void DrawPoint3D(Vector3 position, Color color)
|
||||||
{
|
{
|
||||||
rlCheckRenderBatchLimit(8);
|
//rlCheckRenderBatchLimit(8);
|
||||||
|
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlTranslatef(position.x, position.y, position.z);
|
rlTranslatef(position.x, position.y, position.z);
|
||||||
|
|
@ -179,7 +179,7 @@ void DrawPoint3D(Vector3 position, Color color)
|
||||||
// Draw a circle in 3D world space
|
// Draw a circle in 3D world space
|
||||||
void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color)
|
void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color)
|
||||||
{
|
{
|
||||||
rlCheckRenderBatchLimit(2*36);
|
//rlCheckRenderBatchLimit(2*36);
|
||||||
|
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlTranslatef(center.x, center.y, center.z);
|
rlTranslatef(center.x, center.y, center.z);
|
||||||
|
|
@ -200,7 +200,7 @@ void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rota
|
||||||
// Draw a color-filled triangle (vertex in counter-clockwise order!)
|
// Draw a color-filled triangle (vertex in counter-clockwise order!)
|
||||||
void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color)
|
void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color)
|
||||||
{
|
{
|
||||||
rlCheckRenderBatchLimit(8);
|
//rlCheckRenderBatchLimit(8);
|
||||||
|
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
|
|
@ -215,7 +215,7 @@ void DrawTriangleStrip3D(Vector3 *points, int pointCount, Color color)
|
||||||
{
|
{
|
||||||
if (pointCount >= 3)
|
if (pointCount >= 3)
|
||||||
{
|
{
|
||||||
rlCheckRenderBatchLimit(3*(pointCount - 2));
|
//rlCheckRenderBatchLimit(3*(pointCount - 2));
|
||||||
|
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
|
|
@ -247,7 +247,7 @@ void DrawCube(Vector3 position, float width, float height, float length, Color c
|
||||||
float y = 0.0f;
|
float y = 0.0f;
|
||||||
float z = 0.0f;
|
float z = 0.0f;
|
||||||
|
|
||||||
rlCheckRenderBatchLimit(36);
|
//rlCheckRenderBatchLimit(36);
|
||||||
|
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
// NOTE: Transformation is applied in inverse order (scale -> rotate -> translate)
|
// NOTE: Transformation is applied in inverse order (scale -> rotate -> translate)
|
||||||
|
|
@ -328,7 +328,7 @@ void DrawCubeWires(Vector3 position, float width, float height, float length, Co
|
||||||
float y = 0.0f;
|
float y = 0.0f;
|
||||||
float z = 0.0f;
|
float z = 0.0f;
|
||||||
|
|
||||||
rlCheckRenderBatchLimit(36);
|
//rlCheckRenderBatchLimit(36);
|
||||||
|
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlTranslatef(position.x, position.y, position.z);
|
rlTranslatef(position.x, position.y, position.z);
|
||||||
|
|
@ -405,7 +405,7 @@ void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float hei
|
||||||
float y = position.y;
|
float y = position.y;
|
||||||
float z = position.z;
|
float z = position.z;
|
||||||
|
|
||||||
rlCheckRenderBatchLimit(36);
|
//rlCheckRenderBatchLimit(36);
|
||||||
|
|
||||||
rlSetTexture(texture.id);
|
rlSetTexture(texture.id);
|
||||||
|
|
||||||
|
|
@ -468,7 +468,7 @@ void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, f
|
||||||
float texWidth = (float)texture.width;
|
float texWidth = (float)texture.width;
|
||||||
float texHeight = (float)texture.height;
|
float texHeight = (float)texture.height;
|
||||||
|
|
||||||
rlCheckRenderBatchLimit(36);
|
//rlCheckRenderBatchLimit(36);
|
||||||
|
|
||||||
rlSetTexture(texture.id);
|
rlSetTexture(texture.id);
|
||||||
|
|
||||||
|
|
@ -555,8 +555,8 @@ void DrawSphere(Vector3 centerPos, float radius, Color color)
|
||||||
// Draw sphere with extended parameters
|
// Draw sphere with extended parameters
|
||||||
void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color)
|
void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color)
|
||||||
{
|
{
|
||||||
int numVertex = (rings + 2)*slices*6;
|
//int numVertex = (rings + 2)*slices*6;
|
||||||
rlCheckRenderBatchLimit(numVertex);
|
//rlCheckRenderBatchLimit(numVertex);
|
||||||
|
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
// NOTE: Transformation is applied in inverse order (scale -> translate)
|
// NOTE: Transformation is applied in inverse order (scale -> translate)
|
||||||
|
|
@ -598,8 +598,8 @@ void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color
|
||||||
// Draw sphere wires
|
// Draw sphere wires
|
||||||
void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color)
|
void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color)
|
||||||
{
|
{
|
||||||
int numVertex = (rings + 2)*slices*6;
|
//int numVertex = (rings + 2)*slices*6;
|
||||||
rlCheckRenderBatchLimit(numVertex);
|
//rlCheckRenderBatchLimit(numVertex);
|
||||||
|
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
// NOTE: Transformation is applied in inverse order (scale -> translate)
|
// NOTE: Transformation is applied in inverse order (scale -> translate)
|
||||||
|
|
@ -645,8 +645,8 @@ void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float h
|
||||||
{
|
{
|
||||||
if (sides < 3) sides = 3;
|
if (sides < 3) sides = 3;
|
||||||
|
|
||||||
int numVertex = sides*6;
|
//int numVertex = sides*6;
|
||||||
rlCheckRenderBatchLimit(numVertex);
|
//rlCheckRenderBatchLimit(numVertex);
|
||||||
|
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlTranslatef(position.x, position.y, position.z);
|
rlTranslatef(position.x, position.y, position.z);
|
||||||
|
|
@ -704,8 +704,8 @@ void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float e
|
||||||
{
|
{
|
||||||
if (sides < 3) sides = 3;
|
if (sides < 3) sides = 3;
|
||||||
|
|
||||||
int numVertex = sides*6;
|
//int numVertex = sides*6;
|
||||||
rlCheckRenderBatchLimit(numVertex);
|
//rlCheckRenderBatchLimit(numVertex);
|
||||||
|
|
||||||
Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
|
Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
|
||||||
if ((direction.x == 0) && (direction.y == 0) && (direction.z == 0)) return;
|
if ((direction.x == 0) && (direction.y == 0) && (direction.z == 0)) return;
|
||||||
|
|
@ -763,8 +763,8 @@ void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, fl
|
||||||
{
|
{
|
||||||
if (sides < 3) sides = 3;
|
if (sides < 3) sides = 3;
|
||||||
|
|
||||||
int numVertex = sides*8;
|
//int numVertex = sides*8;
|
||||||
rlCheckRenderBatchLimit(numVertex);
|
//rlCheckRenderBatchLimit(numVertex);
|
||||||
|
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlTranslatef(position.x, position.y, position.z);
|
rlTranslatef(position.x, position.y, position.z);
|
||||||
|
|
@ -797,8 +797,8 @@ void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, fl
|
||||||
{
|
{
|
||||||
if (sides < 3) sides = 3;
|
if (sides < 3) sides = 3;
|
||||||
|
|
||||||
int numVertex = sides*6;
|
//int numVertex = sides*6;
|
||||||
rlCheckRenderBatchLimit(numVertex);
|
//rlCheckRenderBatchLimit(numVertex);
|
||||||
|
|
||||||
Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
|
Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
|
||||||
if ((direction.x == 0) && (direction.y == 0) && (direction.z == 0))return;
|
if ((direction.x == 0) && (direction.y == 0) && (direction.z == 0))return;
|
||||||
|
|
@ -843,7 +843,7 @@ void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, fl
|
||||||
// Draw a plane
|
// Draw a plane
|
||||||
void DrawPlane(Vector3 centerPos, Vector2 size, Color color)
|
void DrawPlane(Vector3 centerPos, Vector2 size, Color color)
|
||||||
{
|
{
|
||||||
rlCheckRenderBatchLimit(4);
|
//rlCheckRenderBatchLimit(4);
|
||||||
|
|
||||||
// NOTE: Plane is always created on XZ ground
|
// NOTE: Plane is always created on XZ ground
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
|
|
@ -881,7 +881,7 @@ void DrawGrid(int slices, float spacing)
|
||||||
{
|
{
|
||||||
int halfSlices = slices/2;
|
int halfSlices = slices/2;
|
||||||
|
|
||||||
rlCheckRenderBatchLimit((slices + 2)*4);
|
//rlCheckRenderBatchLimit((slices + 2)*4);
|
||||||
|
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
for (int i = -halfSlices; i <= halfSlices; i++)
|
for (int i = -halfSlices; i <= halfSlices; i++)
|
||||||
|
|
@ -1087,7 +1087,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
|
||||||
mesh->vaoId = rlLoadVertexArray();
|
mesh->vaoId = rlLoadVertexArray();
|
||||||
rlEnableVertexArray(mesh->vaoId);
|
rlEnableVertexArray(mesh->vaoId);
|
||||||
|
|
||||||
// NOTE: Attributes must be uploaded considering default locations points
|
// NOTE: Vertex attributes must be uploaded considering default locations points and available vertex data
|
||||||
|
|
||||||
// Enable vertex attributes: position (shader-location = 0)
|
// Enable vertex attributes: position (shader-location = 0)
|
||||||
void *vertices = mesh->animVertices != NULL ? mesh->animVertices : mesh->vertices;
|
void *vertices = mesh->animVertices != NULL ? mesh->animVertices : mesh->vertices;
|
||||||
|
|
@ -1100,6 +1100,9 @@ void UploadMesh(Mesh *mesh, bool dynamic)
|
||||||
rlSetVertexAttribute(1, 2, RL_FLOAT, 0, 0, 0);
|
rlSetVertexAttribute(1, 2, RL_FLOAT, 0, 0, 0);
|
||||||
rlEnableVertexAttribute(1);
|
rlEnableVertexAttribute(1);
|
||||||
|
|
||||||
|
// WARNING: When setting default vertex attribute values, the values for each generic vertex attribute
|
||||||
|
// is part of current state and it is maintained even if a different program object is used
|
||||||
|
|
||||||
if (mesh->normals != NULL)
|
if (mesh->normals != NULL)
|
||||||
{
|
{
|
||||||
// Enable vertex attributes: normals (shader-location = 2)
|
// Enable vertex attributes: normals (shader-location = 2)
|
||||||
|
|
@ -1110,7 +1113,8 @@ void UploadMesh(Mesh *mesh, bool dynamic)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Default color vertex attribute set to WHITE
|
// Default vertex attribute: normal
|
||||||
|
// WARNING: Default value provided to shader if location available
|
||||||
float value[3] = { 1.0f, 1.0f, 1.0f };
|
float value[3] = { 1.0f, 1.0f, 1.0f };
|
||||||
rlSetVertexAttributeDefault(2, value, SHADER_ATTRIB_VEC3, 3);
|
rlSetVertexAttributeDefault(2, value, SHADER_ATTRIB_VEC3, 3);
|
||||||
rlDisableVertexAttribute(2);
|
rlDisableVertexAttribute(2);
|
||||||
|
|
@ -1125,8 +1129,9 @@ void UploadMesh(Mesh *mesh, bool dynamic)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Default color vertex attribute set to WHITE
|
// Default vertex attribute: color
|
||||||
float value[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
// WARNING: Default value provided to shader if location available
|
||||||
|
float value[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; // WHITE
|
||||||
rlSetVertexAttributeDefault(3, value, SHADER_ATTRIB_VEC4, 4);
|
rlSetVertexAttributeDefault(3, value, SHADER_ATTRIB_VEC4, 4);
|
||||||
rlDisableVertexAttribute(3);
|
rlDisableVertexAttribute(3);
|
||||||
}
|
}
|
||||||
|
|
@ -1140,7 +1145,8 @@ void UploadMesh(Mesh *mesh, bool dynamic)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Default tangents vertex attribute
|
// Default vertex attribute: tangent
|
||||||
|
// WARNING: Default value provided to shader if location available
|
||||||
float value[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
float value[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
rlSetVertexAttributeDefault(4, value, SHADER_ATTRIB_VEC4, 4);
|
rlSetVertexAttributeDefault(4, value, SHADER_ATTRIB_VEC4, 4);
|
||||||
rlDisableVertexAttribute(4);
|
rlDisableVertexAttribute(4);
|
||||||
|
|
@ -1155,7 +1161,8 @@ void UploadMesh(Mesh *mesh, bool dynamic)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Default texcoord2 vertex attribute
|
// Default vertex attribute: texcoord2
|
||||||
|
// WARNING: Default value provided to shader if location available
|
||||||
float value[2] = { 0.0f, 0.0f };
|
float value[2] = { 0.0f, 0.0f };
|
||||||
rlSetVertexAttributeDefault(5, value, SHADER_ATTRIB_VEC2, 2);
|
rlSetVertexAttributeDefault(5, value, SHADER_ATTRIB_VEC2, 2);
|
||||||
rlDisableVertexAttribute(5);
|
rlDisableVertexAttribute(5);
|
||||||
|
|
@ -1293,8 +1300,10 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try binding vertex array objects (VAO)
|
// Try binding vertex array objects (VAO) or use VBOs if not possible
|
||||||
// or use VBOs if not possible
|
// WARNING: UploadMesh() enables all vertex attributes available in mesh and sets default attribute values
|
||||||
|
// for shader expected vertex attributes that are not provided by the mesh (i.e. colors)
|
||||||
|
// This could be a dangerous approach because different meshes with different shaders can enable/disable some attributes
|
||||||
if (!rlEnableVertexArray(mesh.vaoId))
|
if (!rlEnableVertexArray(mesh.vaoId))
|
||||||
{
|
{
|
||||||
// Bind mesh VBO data: vertex position (shader-location = 0)
|
// Bind mesh VBO data: vertex position (shader-location = 0)
|
||||||
|
|
@ -1326,8 +1335,8 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Set default value for unused attribute
|
// Set default value for defined vertex attribute in shader but not provided by mesh
|
||||||
// NOTE: Required when using default shader and no VAO support
|
// WARNING: It could result in GPU undefined behaviour
|
||||||
float value[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
float value[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
rlSetVertexAttributeDefault(material.shader.locs[SHADER_LOC_VERTEX_COLOR], value, SHADER_ATTRIB_VEC4, 4);
|
rlSetVertexAttributeDefault(material.shader.locs[SHADER_LOC_VERTEX_COLOR], value, SHADER_ATTRIB_VEC4, 4);
|
||||||
rlDisableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_COLOR]);
|
rlDisableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_COLOR]);
|
||||||
|
|
@ -1353,6 +1362,9 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
|
||||||
if (mesh.indices != NULL) rlEnableVertexBufferElement(mesh.vboId[6]);
|
if (mesh.indices != NULL) rlEnableVertexBufferElement(mesh.vboId[6]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WARNING: Disable vertex attribute color input if mesh can not provide that data (despite location being enabled in shader)
|
||||||
|
if (mesh.vboId[3] == 0) rlDisableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_COLOR]);
|
||||||
|
|
||||||
int eyeCount = 1;
|
int eyeCount = 1;
|
||||||
if (rlIsStereoRenderEnabled()) eyeCount = 2;
|
if (rlIsStereoRenderEnabled()) eyeCount = 2;
|
||||||
|
|
||||||
|
|
@ -1379,14 +1391,17 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
|
||||||
// Unbind all binded texture maps
|
// Unbind all binded texture maps
|
||||||
for (int i = 0; i < MAX_MATERIAL_MAPS; i++)
|
for (int i = 0; i < MAX_MATERIAL_MAPS; i++)
|
||||||
{
|
{
|
||||||
// Select current shader texture slot
|
if (material.maps[i].texture.id > 0)
|
||||||
rlActiveTextureSlot(i);
|
{
|
||||||
|
// Select current shader texture slot
|
||||||
|
rlActiveTextureSlot(i);
|
||||||
|
|
||||||
// Disable texture for active slot
|
// Disable texture for active slot
|
||||||
if ((i == MATERIAL_MAP_IRRADIANCE) ||
|
if ((i == MATERIAL_MAP_IRRADIANCE) ||
|
||||||
(i == MATERIAL_MAP_PREFILTER) ||
|
(i == MATERIAL_MAP_PREFILTER) ||
|
||||||
(i == MATERIAL_MAP_CUBEMAP)) rlDisableTextureCubemap();
|
(i == MATERIAL_MAP_CUBEMAP)) rlDisableTextureCubemap();
|
||||||
else rlDisableTexture();
|
else rlDisableTexture();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable all possible vertex array objects (or VBOs)
|
// Disable all possible vertex array objects (or VBOs)
|
||||||
|
|
@ -1568,6 +1583,9 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i
|
||||||
if (mesh.indices != NULL) rlEnableVertexBufferElement(mesh.vboId[6]);
|
if (mesh.indices != NULL) rlEnableVertexBufferElement(mesh.vboId[6]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WARNING: Disable vertex attribute color input if mesh can not provide that data (despite location being enabled in shader)
|
||||||
|
if (mesh.vboId[3] == 0) rlDisableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_COLOR]);
|
||||||
|
|
||||||
int eyeCount = 1;
|
int eyeCount = 1;
|
||||||
if (rlIsStereoRenderEnabled()) eyeCount = 2;
|
if (rlIsStereoRenderEnabled()) eyeCount = 2;
|
||||||
|
|
||||||
|
|
@ -1594,14 +1612,17 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i
|
||||||
// Unbind all binded texture maps
|
// Unbind all binded texture maps
|
||||||
for (int i = 0; i < MAX_MATERIAL_MAPS; i++)
|
for (int i = 0; i < MAX_MATERIAL_MAPS; i++)
|
||||||
{
|
{
|
||||||
// Select current shader texture slot
|
if (material.maps[i].texture.id > 0)
|
||||||
rlActiveTextureSlot(i);
|
{
|
||||||
|
// Select current shader texture slot
|
||||||
|
rlActiveTextureSlot(i);
|
||||||
|
|
||||||
// Disable texture for active slot
|
// Disable texture for active slot
|
||||||
if ((i == MATERIAL_MAP_IRRADIANCE) ||
|
if ((i == MATERIAL_MAP_IRRADIANCE) ||
|
||||||
(i == MATERIAL_MAP_PREFILTER) ||
|
(i == MATERIAL_MAP_PREFILTER) ||
|
||||||
(i == MATERIAL_MAP_CUBEMAP)) rlDisableTextureCubemap();
|
(i == MATERIAL_MAP_CUBEMAP)) rlDisableTextureCubemap();
|
||||||
else rlDisableTexture();
|
else rlDisableTexture();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable all possible vertex array objects (or VBOs)
|
// Disable all possible vertex array objects (or VBOs)
|
||||||
|
|
@ -3240,19 +3261,6 @@ void GenMeshTangents(Mesh *mesh)
|
||||||
TRACELOG(LOG_INFO, "MESH: Tangents data computed and uploaded for provided mesh");
|
TRACELOG(LOG_INFO, "MESH: Tangents data computed and uploaded for provided mesh");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute mesh binormals (aka bitangent)
|
|
||||||
void GenMeshBinormals(Mesh *mesh)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < mesh->vertexCount; i++)
|
|
||||||
{
|
|
||||||
//Vector3 normal = { mesh->normals[i*3 + 0], mesh->normals[i*3 + 1], mesh->normals[i*3 + 2] };
|
|
||||||
//Vector3 tangent = { mesh->tangents[i*4 + 0], mesh->tangents[i*4 + 1], mesh->tangents[i*4 + 2] };
|
|
||||||
//Vector3 binormal = Vector3Scale(Vector3CrossProduct(normal, tangent), mesh->tangents[i*4 + 3]);
|
|
||||||
|
|
||||||
// TODO: Register computed binormal in mesh->binormal?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a model (with texture if set)
|
// Draw a model (with texture if set)
|
||||||
void DrawModel(Model model, Vector3 position, float scale, Color tint)
|
void DrawModel(Model model, Vector3 position, float scale, Color tint)
|
||||||
{
|
{
|
||||||
|
|
@ -3332,7 +3340,7 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector
|
||||||
void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint)
|
void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint)
|
||||||
{
|
{
|
||||||
// NOTE: Billboard size will maintain source rectangle aspect ratio, size will represent billboard width
|
// NOTE: Billboard size will maintain source rectangle aspect ratio, size will represent billboard width
|
||||||
Vector2 sizeRatio = { size.x*(float)source.height/source.width, size.y };
|
Vector2 sizeRatio = { size.x*(float)source.width/source.height, size.y };
|
||||||
|
|
||||||
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
|
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
|
||||||
|
|
||||||
|
|
@ -4945,6 +4953,10 @@ static Model LoadGLTF(const char *fileName)
|
||||||
model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount*4, sizeof(unsigned char));
|
model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount*4, sizeof(unsigned char));
|
||||||
|
|
||||||
// Load 4 components of unsigned char data type into mesh.boneIds
|
// Load 4 components of unsigned char data type into mesh.boneIds
|
||||||
|
// TODO: It seems LOAD_ATTRIBUTE() macro does not work as expected in some cases,
|
||||||
|
// for cgltf_attribute_type_joints we have:
|
||||||
|
// - data.meshes[0] (256 vertices)
|
||||||
|
// - 256 values, provided as cgltf_type_vec4 of bytes (4 byte per joint, stride 4)
|
||||||
LOAD_ATTRIBUTE(attribute, 4, unsigned char, model.meshes[meshIndex].boneIds)
|
LOAD_ATTRIBUTE(attribute, 4, unsigned char, model.meshes[meshIndex].boneIds)
|
||||||
}
|
}
|
||||||
else TRACELOG(LOG_WARNING, "MODEL: [%s] Joint attribute data format not supported, use vec4 u8", fileName);
|
else TRACELOG(LOG_WARNING, "MODEL: [%s] Joint attribute data format not supported, use vec4 u8", fileName);
|
||||||
|
|
@ -4959,6 +4971,9 @@ static Model LoadGLTF(const char *fileName)
|
||||||
model.meshes[meshIndex].boneWeights = RL_CALLOC(model.meshes[meshIndex].vertexCount*4, sizeof(float));
|
model.meshes[meshIndex].boneWeights = RL_CALLOC(model.meshes[meshIndex].vertexCount*4, sizeof(float));
|
||||||
|
|
||||||
// Load 4 components of float data type into mesh.boneWeights
|
// Load 4 components of float data type into mesh.boneWeights
|
||||||
|
// for cgltf_attribute_type_weights we have:
|
||||||
|
// - data.meshes[0] (256 vertices)
|
||||||
|
// - 256 values, provided as cgltf_type_vec4 of float (4 byte per joint, stride 16)
|
||||||
LOAD_ATTRIBUTE(attribute, 4, float, model.meshes[meshIndex].boneWeights)
|
LOAD_ATTRIBUTE(attribute, 4, float, model.meshes[meshIndex].boneWeights)
|
||||||
}
|
}
|
||||||
else TRACELOG(LOG_WARNING, "MODEL: [%s] Joint weight attribute data format not supported, use vec4 float", fileName);
|
else TRACELOG(LOG_WARNING, "MODEL: [%s] Joint weight attribute data format not supported, use vec4 float", fileName);
|
||||||
|
|
|
||||||
|
|
@ -785,28 +785,26 @@ void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3,
|
||||||
|
|
||||||
rlSetTexture(texShapes.id);
|
rlSetTexture(texShapes.id);
|
||||||
|
|
||||||
rlPushMatrix();
|
rlBegin(RL_QUADS);
|
||||||
rlBegin(RL_QUADS);
|
rlNormal3f(0.0f, 0.0f, 1.0f);
|
||||||
rlNormal3f(0.0f, 0.0f, 1.0f);
|
|
||||||
|
|
||||||
// NOTE: Default raylib font character 95 is a white square
|
// NOTE: Default raylib font character 95 is a white square
|
||||||
rlColor4ub(col1.r, col1.g, col1.b, col1.a);
|
rlColor4ub(col1.r, col1.g, col1.b, col1.a);
|
||||||
rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height);
|
rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height);
|
||||||
rlVertex2f(rec.x, rec.y);
|
rlVertex2f(rec.x, rec.y);
|
||||||
|
|
||||||
rlColor4ub(col2.r, col2.g, col2.b, col2.a);
|
rlColor4ub(col2.r, col2.g, col2.b, col2.a);
|
||||||
rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
|
rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
|
||||||
rlVertex2f(rec.x, rec.y + rec.height);
|
rlVertex2f(rec.x, rec.y + rec.height);
|
||||||
|
|
||||||
rlColor4ub(col3.r, col3.g, col3.b, col3.a);
|
rlColor4ub(col3.r, col3.g, col3.b, col3.a);
|
||||||
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
|
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
|
||||||
rlVertex2f(rec.x + rec.width, rec.y + rec.height);
|
rlVertex2f(rec.x + rec.width, rec.y + rec.height);
|
||||||
|
|
||||||
rlColor4ub(col4.r, col4.g, col4.b, col4.a);
|
rlColor4ub(col4.r, col4.g, col4.b, col4.a);
|
||||||
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
|
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
|
||||||
rlVertex2f(rec.x + rec.width, rec.y);
|
rlVertex2f(rec.x + rec.width, rec.y);
|
||||||
rlEnd();
|
rlEnd();
|
||||||
rlPopMatrix();
|
|
||||||
|
|
||||||
rlSetTexture(0);
|
rlSetTexture(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user