Merge branch 'master' into master

This commit is contained in:
Jon Daniel 2025-08-08 02:24:57 +02:00 • committed by GitHub
commit 0842aabe5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
163 changed files with 2557 additions and 769 deletions

View file

@ -30,17 +30,17 @@ jobs:
- bits: 32 - bits: 32
ARCH: "i386" ARCH: "i386"
ARCH_NAME: "i386" ARCH_NAME: "i386"
COMPILER_PATH: "/user/bin" COMPILER_PATH: "/usr/bin"
runner: "ubuntu-latest" runner: "ubuntu-latest"
- bits: 64 - bits: 64
ARCH: "x86_64" ARCH: "x86_64"
ARCH_NAME: "amd64" ARCH_NAME: "amd64"
COMPILER_PATH: "/user/bin" COMPILER_PATH: "/usr/bin"
runner: "ubuntu-latest" runner: "ubuntu-latest"
- bits: 64 - bits: 64
ARCH: "aarch64" ARCH: "aarch64"
ARCH_NAME: "arm64" ARCH_NAME: "arm64"
COMPILER_PATH: "/user/bin" COMPILER_PATH: "/usr/bin"
runner: "ubuntu-24.04-arm" runner: "ubuntu-24.04-arm"
runs-on: ${{ matrix.runner }} runs-on: ${{ matrix.runner }}

View file

@ -145,7 +145,6 @@ These are older raylib bindings that are more than 2 versions old or have not be
| [clj-raylib](https://github.com/lsevero/clj-raylib) | 3.0 | [Clojure](https://clojure.org) | | [clj-raylib](https://github.com/lsevero/clj-raylib) | 3.0 | [Clojure](https://clojure.org) |
| [QuickJS-raylib](https://github.com/sntg-p/QuickJS-raylib) | 3.0 | [QuickJS](https://bellard.org/quickjs) | | [QuickJS-raylib](https://github.com/sntg-p/QuickJS-raylib) | 3.0 | [QuickJS](https://bellard.org/quickjs) |
| [raylib-duktape](https://github.com/RobLoach/raylib-duktape) | 2.6 | [JavaScript (Duktape)](https://en.wikipedia.org/wiki/JavaScript) | | [raylib-duktape](https://github.com/RobLoach/raylib-duktape) | 2.6 | [JavaScript (Duktape)](https://en.wikipedia.org/wiki/JavaScript) |
| [raylib-v7](https://github.com/Rabios/raylib-v7) | 3.5 | [JavaScript (v7)](https://en.wikipedia.org/wiki/JavaScript) |
| [raylib-chaiscript](https://github.com/RobLoach/raylib-chaiscript) | 2.6 | [ChaiScript](http://chaiscript.com) | | [raylib-chaiscript](https://github.com/RobLoach/raylib-chaiscript) | 2.6 | [ChaiScript](http://chaiscript.com) |
| [raylib-squirrel](https://github.com/RobLoach/raylib-squirrel) | 2.5 | [Squirrel](http://www.squirrel-lang.org) | | [raylib-squirrel](https://github.com/RobLoach/raylib-squirrel) | 2.5 | [Squirrel](http://www.squirrel-lang.org) |
| [racket-raylib-2d](https://github.com/arvyy/racket-raylib-2d) | 2.5 | [Racket](https://racket-lang.org) | | [racket-raylib-2d](https://github.com/arvyy/racket-raylib-2d) | 2.5 | [Racket](https://racket-lang.org) |

View file

@ -28,6 +28,10 @@ Some other conventions to follow:
- **ALWAYS** initialize all defined variables. - **ALWAYS** initialize all defined variables.
- **Do not use TABS**, use 4 spaces instead. - **Do not use TABS**, use 4 spaces instead.
- Avoid trailing spaces, please, avoid them - Avoid trailing spaces, please, avoid them
- Comments always start with space + capital letter and never end with a '.', place them **before** the line(s) they refer to
```c
// This is a comment in raylib or raylib examples
```
- Control flow statements always are followed **by a space**: - Control flow statements always are followed **by a space**:
```c ```c
if (condition) value = 0; if (condition) value = 0;

View file

@ -639,6 +639,7 @@ SHADERS = \
shaders/shaders_mesh_instancing \ shaders/shaders_mesh_instancing \
shaders/shaders_model_shader \ shaders/shaders_model_shader \
shaders/shaders_multi_sample2d \ shaders/shaders_multi_sample2d \
shaders/shaders_normalmap \
shaders/shaders_palette_switch \ shaders/shaders_palette_switch \
shaders/shaders_postprocessing \ shaders/shaders_postprocessing \
shaders/shaders_raymarching \ shaders/shaders_raymarching \

View file

@ -639,6 +639,7 @@ SHADERS = \
shaders/shaders_mesh_instancing \ shaders/shaders_mesh_instancing \
shaders/shaders_model_shader \ shaders/shaders_model_shader \
shaders/shaders_multi_sample2d \ shaders/shaders_multi_sample2d \
shaders/shaders_normalmap \
shaders/shaders_palette_switch \ shaders/shaders_palette_switch \
shaders/shaders_postprocessing \ shaders/shaders_postprocessing \
shaders/shaders_raymarching \ shaders/shaders_raymarching \
@ -1201,6 +1202,14 @@ shaders/shaders_multi_sample2d: shaders/shaders_multi_sample2d.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/color_mix.fs@resources/shaders/glsl100/color_mix.fs --preload-file shaders/resources/shaders/glsl100/color_mix.fs@resources/shaders/glsl100/color_mix.fs
shaders/shaders_normalmap: shaders/shaders_normalmap.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/normalmap.vs@resources/shaders/glsl100/normalmap.vs \
--preload-file shaders/resources/shaders/glsl100/normalmap.fs@resources/shaders/glsl100/normalmap.fs \
--preload-file shaders/resources/models/plane.glb@resources/models/plane.glb \
--preload-file shaders/resources/tiles_diffuse.png@resources/tiles_diffuse.png \
--preload-file shaders/resources/tiles_normal.png@resources/tiles_normal.png
shaders/shaders_palette_switch: shaders/shaders_palette_switch.c shaders/shaders_palette_switch: shaders/shaders_palette_switch.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/palette_switch.fs@resources/shaders/glsl100/palette_switch.fs --preload-file shaders/resources/shaders/glsl100/palette_switch.fs@resources/shaders/glsl100/palette_switch.fs

View file

@ -16,8 +16,7 @@ You may find it easier to use than other toolchains, especially when it comes to
- `zig build [module]` to compile all examples for a module (e.g. `zig build core`) - `zig build [module]` to compile all examples for a module (e.g. `zig build core`)
- `zig build [example]` to compile _and run_ a particular example (e.g. `zig build core_basic_window`) - `zig build [example]` to compile _and run_ a particular example (e.g. `zig build core_basic_window`)
## EXAMPLES COLLECTION [TOTAL: 159] ## EXAMPLES COLLECTION [TOTAL: 160]
### category: core [36] ### category: core [36]
@ -171,7 +170,7 @@ Examples using raylib models functionality, including models loading/generation
| [models_bone_socket](models/models_bone_socket.c) | <img src="models/models_bone_socket.png" alt="models_bone_socket" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [iP](https://github.com/ipzaur) | | [models_bone_socket](models/models_bone_socket.c) | <img src="models/models_bone_socket.png" alt="models_bone_socket" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [iP](https://github.com/ipzaur) |
| [models_tesseract_view](models/models_tesseract_view.c) | <img src="models/models_tesseract_view.png" alt="models_tesseract_view" width="80"> | ⭐⭐☆☆ | 5.6 | 5.6 | [Timothy van der Valk](https://github.com/arceryz) | | [models_tesseract_view](models/models_tesseract_view.c) | <img src="models/models_tesseract_view.png" alt="models_tesseract_view" width="80"> | ⭐⭐☆☆ | 5.6 | 5.6 | [Timothy van der Valk](https://github.com/arceryz) |
### category: shaders [28] ### category: shaders [29]
Examples using raylib shaders functionality, including shaders loading, parameters configuration and drawing using them (model shaders and postprocessing shaders). This functionality is directly provided by raylib [rlgl](../src/rlgl.c) module. Examples using raylib shaders functionality, including shaders loading, parameters configuration and drawing using them (model shaders and postprocessing shaders). This functionality is directly provided by raylib [rlgl](../src/rlgl.c) module.
@ -194,6 +193,7 @@ Examples using raylib shaders functionality, including shaders loading, paramete
| [shaders_hot_reloading](shaders/shaders_hot_reloading.c) | <img src="shaders/shaders_hot_reloading.png" alt="shaders_hot_reloading" width="80"> | ⭐⭐⭐☆ | 3.0 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) | | [shaders_hot_reloading](shaders/shaders_hot_reloading.c) | <img src="shaders/shaders_hot_reloading.png" alt="shaders_hot_reloading" width="80"> | ⭐⭐⭐☆ | 3.0 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [shaders_mesh_instancing](shaders/shaders_mesh_instancing.c) | <img src="shaders/shaders_mesh_instancing.png" alt="shaders_mesh_instancing" width="80"> | ⭐⭐⭐⭐️ | 3.7 | 4.2 | [seanpringle](https://github.com/seanpringle) | | [shaders_mesh_instancing](shaders/shaders_mesh_instancing.c) | <img src="shaders/shaders_mesh_instancing.png" alt="shaders_mesh_instancing" width="80"> | ⭐⭐⭐⭐️ | 3.7 | 4.2 | [seanpringle](https://github.com/seanpringle) |
| [shaders_multi_sample2d](shaders/shaders_multi_sample2d.c) | <img src="shaders/shaders_multi_sample2d.png" alt="shaders_multi_sample2d" width="80"> | ⭐⭐☆☆ | 3.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) | | [shaders_multi_sample2d](shaders/shaders_multi_sample2d.c) | <img src="shaders/shaders_multi_sample2d.png" alt="shaders_multi_sample2d" width="80"> | ⭐⭐☆☆ | 3.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [shaders_normalmap](shaders/shaders_normalmap.c) | <img src="shaders/shaders_normalmap.png" alt="shaders_normalmap" width="80"> | ⭐⭐⭐⭐️ | 5.6 | 5.6 | [Jeremy Montgomery](https://github.com/Sir_Irk) |
| [shaders_spotlight](shaders/shaders_spotlight.c) | <img src="shaders/shaders_spotlight.png" alt="shaders_spotlight" width="80"> | ⭐⭐☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) | | [shaders_spotlight](shaders/shaders_spotlight.c) | <img src="shaders/shaders_spotlight.png" alt="shaders_spotlight" width="80"> | ⭐⭐☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
| [shaders_deferred_render](shaders/shaders_deferred_render.c) | <img src="shaders/shaders_deferred_render.png" alt="shaders_deferred_render" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [Justin Andreas Lacoste](https://github.com/27justin) | | [shaders_deferred_render](shaders/shaders_deferred_render.c) | <img src="shaders/shaders_deferred_render.png" alt="shaders_deferred_render" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [Justin Andreas Lacoste](https://github.com/27justin) |
| [shaders_hybrid_render](shaders/shaders_hybrid_render.c) | <img src="shaders/shaders_hybrid_render.png" alt="shaders_hybrid_render" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) | | [shaders_hybrid_render](shaders/shaders_hybrid_render.c) | <img src="shaders/shaders_hybrid_render.png" alt="shaders_hybrid_render" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) |

View file

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [audio] example - Mixed audio processing * raylib [audio] example - mixed audio processing
* *
* Example complexity rating: [★★★★] 4/4 * Example complexity rating: [★★★★] 4/4
* *

View file

@ -108,8 +108,6 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Sample mouse input.
mousePosition = GetMousePosition(); mousePosition = GetMousePosition();
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
@ -125,7 +123,7 @@ int main(void)
// Compute two cycles to allow the buffer padding, simplifying any modulation, resampling, etc. // Compute two cycles to allow the buffer padding, simplifying any modulation, resampling, etc.
if (frequency != oldFrequency) if (frequency != oldFrequency)
{ {
// Compute wavelength. Limit size in both directions. // Compute wavelength. Limit size in both directions
//int oldWavelength = waveLength; //int oldWavelength = waveLength;
waveLength = (int)(22050/frequency); waveLength = (int)(22050/frequency);
if (waveLength > MAX_SAMPLES/2) waveLength = MAX_SAMPLES/2; if (waveLength > MAX_SAMPLES/2) waveLength = MAX_SAMPLES/2;

View file

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [audio] example - Playing sound multiple times * raylib [audio] example - sound alias
* *
* Example complexity rating: [★★☆☆] 2/4 * Example complexity rating: [★★☆☆] 2/4
* *
@ -31,18 +31,18 @@ int main(void)
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - playing sound multiple times"); InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound alias");
InitAudioDevice(); // Initialize audio device InitAudioDevice(); // Initialize audio device
// load the sound list // Load audio file into the first slot as the 'source' sound,
soundArray[0] = LoadSound("resources/sound.wav"); // Load WAV audio file into the first slot as the 'source' sound
// this sound owns the sample data // this sound owns the sample data
for (int i = 1; i < MAX_SOUNDS; i++) soundArray[0] = LoadSound("resources/sound.wav");
{
soundArray[i] = LoadSoundAlias(soundArray[0]); // Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played // Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played
} for (int i = 1; i < MAX_SOUNDS; i++) soundArray[i] = LoadSoundAlias(soundArray[0]);
currentSound = 0; // set the sound list to the start
currentSound = 0; // Set the sound list to the start
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -54,14 +54,15 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_SPACE)) if (IsKeyPressed(KEY_SPACE))
{ {
PlaySound(soundArray[currentSound]); // play the next open sound slot PlaySound(soundArray[currentSound]); // Play the next open sound slot
currentSound++; // increment the sound slot currentSound++; // Increment the sound slot
if (currentSound >= MAX_SOUNDS) // if the sound slot is out of bounds, go back to 0
currentSound = 0;
// Note: a better way would be to look at the list for the first sound that is not playing and use that slot // If the sound slot is out of bounds, go back to 0
if (currentSound >= MAX_SOUNDS) currentSound = 0;
// NOTE: Another approach would be to look at the list for the first sound
// that is not playing and use that slot
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
@ -78,8 +79,7 @@ int main(void)
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
for (int i = 1; i < MAX_SOUNDS; i++) for (int i = 1; i < MAX_SOUNDS; i++) UnloadSoundAlias(soundArray[i]); // Unload sound aliases
UnloadSoundAlias(soundArray[i]); // Unload sound aliases
UnloadSound(soundArray[0]); // Unload source sound data UnloadSound(soundArray[0]); // Unload source sound data
CloseAudioDevice(); // Close audio device CloseAudioDevice(); // Close audio device

View file

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [audio] example - Playing spatialized 3D sound * raylib [audio] example - spatialized 3D sound
* *
* Example complexity rating: [★★☆☆] 2/4 * Example complexity rating: [★★☆☆] 2/4
* *
@ -32,7 +32,7 @@ int main(void)
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - Playing spatialized 3D sound"); InitWindow(screenWidth, screenHeight, "raylib [audio] example - spatialized 3D sound");
InitAudioDevice(); InitAudioDevice();

View file

@ -12,7 +12,7 @@
* 4. PollInputEvents() * 4. PollInputEvents()
* *
* To avoid steps 2, 3 and 4, flag SUPPORT_CUSTOM_FRAME_CONTROL can be enabled in * To avoid steps 2, 3 and 4, flag SUPPORT_CUSTOM_FRAME_CONTROL can be enabled in
* config.h (it requires recompiling raylib). This way those steps are up to the user. * config.h (it requires recompiling raylib). This way those steps are up to the user
* *
* Note that enabling this flag invalidates some functions: * Note that enabling this flag invalidates some functions:
* - GetFrameTime() * - GetFrameTime()

View file

@ -13,12 +13,10 @@
#include "raylib.h" #include "raylib.h"
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color) //------------------------------------------------------------------------------------
{ // Module functions declaration
Vector2 size = MeasureTextEx(GetFontDefault(), text, (float)fontSize, 3); //------------------------------------------------------------------------------------
Vector2 pos = (Vector2){x - size.x/2, y - size.y/2 }; static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color);
DrawTextEx(GetFontDefault(), text, pos, (float)fontSize, 3, color);
}
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
@ -31,10 +29,20 @@ int main(void)
const int screenHeight = 450; const int screenHeight = 450;
SetConfigFlags(FLAG_WINDOW_HIGHDPI | FLAG_WINDOW_RESIZABLE); SetConfigFlags(FLAG_WINDOW_HIGHDPI | FLAG_WINDOW_RESIZABLE);
InitWindow(screenWidth, screenHeight, "raylib [core] example - highdpi"); InitWindow(screenWidth, screenHeight, "raylib [core] example - highdpi");
SetWindowMinSize(450, 450); SetWindowMinSize(450, 450);
int logicalGridDescY = 120;
int logicalGridLabelY = logicalGridDescY + 30;
int logicalGridTop = logicalGridLabelY + 30;
int logicalGridBottom = logicalGridTop + 80;
int pixelGridTop = logicalGridBottom - 20;
int pixelGridBottom = pixelGridTop + 80;
int pixelGridLabelY = pixelGridBottom + 30;
int pixelGridDescY = pixelGridLabelY + 30;
int cellSize = 50;
float cellSizePx = (float)cellSize;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -44,67 +52,60 @@ int main(void)
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
int monitorCount = GetMonitorCount(); int monitorCount = GetMonitorCount();
if (monitorCount > 1 && IsKeyPressed(KEY_N)) {
SetWindowMonitor((GetCurrentMonitor() + 1) % monitorCount); if ((monitorCount > 1) && IsKeyPressed(KEY_N))
{
SetWindowMonitor((GetCurrentMonitor() + 1)%monitorCount);
} }
int currentMonitor = GetCurrentMonitor(); int currentMonitor = GetCurrentMonitor();
Vector2 dpiScale = GetWindowScaleDPI();
cellSizePx = ((float)cellSize)/dpiScale.x;
//----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
Vector2 dpiScale = GetWindowScaleDPI();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
int windowCenter = GetScreenWidth() / 2; int windowCenter = GetScreenWidth()/2;
DrawTextCenter(TextFormat("Dpi Scale: %f", dpiScale.x), windowCenter, 30, 40, DARKGRAY); DrawTextCenter(TextFormat("Dpi Scale: %f", dpiScale.x), windowCenter, 30, 40, DARKGRAY);
DrawTextCenter(TextFormat("Monitor: %d/%d ([N] next monitor)", currentMonitor+1, monitorCount), windowCenter, 70, 16, LIGHTGRAY); DrawTextCenter(TextFormat("Monitor: %d/%d ([N] next monitor)", currentMonitor+1, monitorCount), windowCenter, 70, 20, LIGHTGRAY);
const int logicalGridDescY = 120;
const int logicalGridLabelY = logicalGridDescY + 30;
const int logicalGridTop = logicalGridLabelY + 30;
const int logicalGridBottom = logicalGridTop + 80;
const int pixelGridTop = logicalGridBottom - 20;
const int pixelGridBottom = pixelGridTop + 80;
const int pixelGridLabelY = pixelGridBottom + 30;
const int pixelGridDescY = pixelGridLabelY + 30;
const int cellSize = 50;
const float cellSizePx = ((float)cellSize) / dpiScale.x;
DrawTextCenter(TextFormat("Window is %d \"logical points\" wide", GetScreenWidth()), windowCenter, logicalGridDescY, 20, ORANGE); DrawTextCenter(TextFormat("Window is %d \"logical points\" wide", GetScreenWidth()), windowCenter, logicalGridDescY, 20, ORANGE);
bool odd = true; bool odd = true;
for (int i = cellSize; i < GetScreenWidth(); i += cellSize, odd = !odd) { for (int i = cellSize; i < GetScreenWidth(); i += cellSize, odd = !odd)
if (odd) { {
DrawRectangle(i, logicalGridTop, cellSize, logicalGridBottom-logicalGridTop, ORANGE); if (odd) DrawRectangle(i, logicalGridTop, cellSize, logicalGridBottom-logicalGridTop, ORANGE);
}
DrawTextCenter(TextFormat("%d", i), i, logicalGridLabelY, 12, LIGHTGRAY); DrawTextCenter(TextFormat("%d", i), i, logicalGridLabelY, 10, LIGHTGRAY);
DrawLine(i, logicalGridLabelY + 10, i, logicalGridBottom, GRAY); DrawLine(i, logicalGridLabelY + 10, i, logicalGridBottom, GRAY);
} }
odd = true; odd = true;
const int minTextSpace = 30; const int minTextSpace = 30;
int last_text_x = -minTextSpace; int lastTextX = -minTextSpace;
for (int i = cellSize; i < GetRenderWidth(); i += cellSize, odd = !odd) { for (int i = cellSize; i < GetRenderWidth(); i += cellSize, odd = !odd)
int x = (int)(((float)i) / dpiScale.x); {
if (odd) { int x = (int)(((float)i)/dpiScale.x);
DrawRectangle(x, pixelGridTop, (int)cellSizePx, pixelGridBottom-pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 }); if (odd) DrawRectangle(x, pixelGridTop, (int)cellSizePx, pixelGridBottom - pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 });
}
DrawLine(x, pixelGridTop, (int)(((float)i) / dpiScale.x), pixelGridLabelY - 10, GRAY); DrawLine(x, pixelGridTop, (int)(((float)i) / dpiScale.x), pixelGridLabelY - 10, GRAY);
if (x - last_text_x >= minTextSpace) {
DrawTextCenter(TextFormat("%d", i), x, pixelGridLabelY, 12, LIGHTGRAY); if ((x - lastTextX) >= minTextSpace)
last_text_x = x; {
DrawTextCenter(TextFormat("%d", i), x, pixelGridLabelY, 10, LIGHTGRAY);
lastTextX = x;
} }
} }
DrawTextCenter(TextFormat("Window is %d \"physical pixels\" wide", GetRenderWidth()), windowCenter, pixelGridDescY, 20, BLUE); DrawTextCenter(TextFormat("Window is %d \"physical pixels\" wide", GetRenderWidth()), windowCenter, pixelGridDescY, 20, BLUE);
{
const char *text = "Can you see this?"; const char *text = "Can you see this?";
Vector2 size = MeasureTextEx(GetFontDefault(), text, 16, 3); Vector2 size = MeasureTextEx(GetFontDefault(), text, 20, 3);
Vector2 pos = (Vector2){GetScreenWidth() - size.x - 5, GetScreenHeight() - size.y - 5}; Vector2 pos = (Vector2){ GetScreenWidth() - size.x - 5, GetScreenHeight() - size.y - 5 };
DrawTextEx(GetFontDefault(), text, pos, 16, 3, LIGHTGRAY); DrawTextEx(GetFontDefault(), text, pos, 20, 3, LIGHTGRAY);
}
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -117,3 +118,13 @@ int main(void)
return 0; return 0;
} }
//------------------------------------------------------------------------------------
// Module functions definition
//------------------------------------------------------------------------------------
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color)
{
Vector2 size = MeasureTextEx(GetFontDefault(), text, (float)fontSize, 3);
Vector2 pos = (Vector2){ x - size.x/2, y - size.y/2 };
DrawTextEx(GetFontDefault(), text, pos, (float)fontSize, 3, color);
}

Some files were not shown because too many files have changed in this diff Show more