Merge remote-tracking branch 'refs/remotes/raysan5/develop' into develop

This commit is contained in:
victorfisac 2016-01-20 13:48:00 +01:00
commit c04752c0e4
76 changed files with 635 additions and 653 deletions

152
README.md
View file

@ -34,7 +34,7 @@ I've coded quite a lot in C# and XNA and I really love it (in fact, my students
so, I decided to use C# language notation and XNA naming conventions. That way, students can jump from so, I decided to use C# language notation and XNA naming conventions. That way, students can jump from
raylib to XNA, MonoGame or similar libs extremely easily. raylib to XNA, MonoGame or similar libs extremely easily.
raylib started as a weekend project and after three months of hard work, first version was published. raylib started as a weekend project and after three months of hard work, raylib 1.0 was published on November 2013.
Enjoy it. Enjoy it.
@ -99,14 +99,37 @@ Most of the examples have been completely rewritten and +10 new examples have be
Lots of code changes and lot of testing have concluded in this amazing new raylib 1.3. Lots of code changes and lot of testing have concluded in this amazing new raylib 1.3.
notes on raylib 1.4
-------------------
On February 2016, after 4 months of raylib 1.3 release, it comes raylib 1.4.
Lots of parts of the library have been reviewed to better accomodate to shaders systems and multiple new features have been added.
SpriteFonts system has been improved, adding support for AngelCode fonts (.fnt) and TTF fonts (using stb_truetype).
Finally, raycast system for 3D picking is working, including some ray collision-detection functions.
A set of Image manipulation functions have been added to crop, resize, colorize, dither and even draw image-to-image or text-to-image.
Two new functions added for persistent data storage.
New [physac](https://github.com/raysan5/raylib/blob/develop/src/physac.h) physics module!
Complete LUA scripting support to allow raylib usage from LUA and LUA scripts support within raylib.
Up to 8 new examples have been added to show the new raylib features.
Lots of code changes and lot of testing have concluded in this amazing new raylib 1.4.
features features
-------- --------
* Written in plain C code (C99) * Written in plain C code (C99)
* Uses C# PascalCase/camelCase notation * Uses C# PascalCase/camelCase notation
* Hardware accelerated with OpenGL (1.1, 3.3 or ES2) * Hardware accelerated with OpenGL (1.1, 3.3 or ES2)
* Unique OpenGL abstraction layer: [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) * Unique OpenGL abstraction layer (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c)
* Powerful fonts module with SpriteFonts support * Powerful fonts module with multiple SpriteFonts formats support (XNA bitmap fonts, AngelCode fonts, TTF)
* Outstanding texture formats support, including compressed formats * Outstanding texture formats support, including compressed formats
* Basic 3d support for Shapes, Models, Billboards, Heightmaps and Cubicmaps * Basic 3d support for Shapes, Models, Billboards, Heightmaps and Cubicmaps
* Powerful math module for Vector and Matrix operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.c) * Powerful math module for Vector and Matrix operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.c)
@ -145,126 +168,12 @@ Since raylib v1.1, you can download a Windows Installer package for easy install
building source (generate libraylib.a) building source (generate libraylib.a)
-------------------------------------- --------------------------------------
**Building raylib sources on desktop platforms:** Check raylib wiki page: [Building source](https://github.com/raysan5/raylib/wiki/Building-source)
_Step 1:_ Using MinGW make tool, just navigate from command line to `raylib/src/` folder and type:
mingw32-make PLATFORM=PLATFORM_DESKTOP
NOTE: By default raylib compiles using OpenGL 1.1 to maximize compatibility; to use OpenGL 3.3 just type:
mingw32-make PLATFORM=PLATFORM_DESKTOP GRAPHICS=GRAPHICS_API_OPENGL_33
**Building raylib sources on Raspberry Pi:**
_Step 1._ Make sure you have installed in your Raspberry Pi OpenAL Soft library for audio:
sudo apt-get install openal1
_Step 2._ Navigate from command line to `raylib/src/` folder and type:
make
**Building raylib sources for Android:**
_Step 1._ Make sure you have installed Android SDK, Android NDK and Apache Ant tools:
> Download and decompress on C: [Android SDK r23](http://dl.google.com/android/android-sdk_r23.0.2-windows.zip)
> Download and decompress on C: [Android NDK r10b](http://dl.google.com/android/ndk/android-ndk32-r10b-windows-x86.zip)
> Download and decompress on C: [Apache Ant 1.9.4](http://ftp.cixug.es/apache//ant/binaries/apache-ant-1.9.4-bin.zip)
_Step 2._ Create the following environment variables with the correct paths:
ANDROID_SDK_TOOLS = C:\android-sdk\platform-tools
ANDROID_NDK_ROOT = C:\android-ndk-r10b
ANT_HOME = C:\apache-ant-1.9.4
_Step 3._ Navigate from command line to folder `raylib/template_android/` and type:
%ANDROID_NDK_ROOT%\ndk-build
NOTE: libraylib.a will be generated in folder `raylib/src_android/obj/local/armeabi/`, it must be copied
to Android project; if using `raylib/template_android` project, copy it to `raylib/template_android/jni/libs/`.
**Building raylib sources for Web (HTML5)**
_Step 1._ Make sure you have installed emscripten SDK:
> Download latest version from [here](http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html). I recommend downloading the [Portable Emscripten SDK for Windows](https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-1.25.0-portable-64bit.zip) and decompress it in `C:\emsdk-1.25.0` folder. After that, follow the portable version installation instructions.
_Step 2._ Open `raylib/src/makefile` on Notepad++ and run the script named `raylib_makefile_emscripten`
building examples building examples
----------------- -----------------
**Building raylib examples on desktop platforms:** Check raylib wiki page: [Building examples](https://github.com/raysan5/raylib/wiki/Building-examples)
_Step 1:_ Using MinGW make tool, just navigate from command line to `raylib/examples/` folder and type:
mingw32-make PLATFORM=PLATFORM_DESKTOP
NOTE: Make sure the following libs (and their headers) are placed on their respectibe MinGW folders:
libglfw3.a - GLFW3 (static version)
libglew32.a - GLEW, OpenGL extension loading, only required if using OpenGL 3.3+ or ES2
libopenal32.a - OpenAL Soft, audio device management
**Building raylib examples on Raspberry Pi:**
_Step 1._ Make sure you have installed in your Raspberry Pi OpenAL Soft library for audio:
sudo apt-get install openal1
_Step 2._ Navigate from command line to `raylib/examples/` folder and type:
make
**Building raylib examples for HTML5 (emscripten):**
_Step 1._ Make sure you have installed emscripten SDK:
> Download latest version from [here](http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html). I recommend downloading the [Portable Emscripten SDK for Windows](https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-1.25.0-portable-64bit.zip) and decompress it in `C:\emsdk-1.25.0` folder. After that, follow the portable version installation instructions.
_Step 2._ Open `raylib/examples/makefile` on Notepad++ and run the script named `raylib_makefile_emscripten`
NOTE: At this moment, raylib examples are not ready to directly compile for HTML5, code needs to be reorganized due to the way web browsers work. To see how code should be refactored to fit compilation for web, check [core_basic_window_web.c](https://github.com/raysan5/raylib/blob/master/examples/core_basic_window_web.c) example.
**Building raylib project for Android (using template):**
_Step 1._ Make sure you have installed Android SDK, Android NDK and Apache Ant tools:
> Download and decompress on C: [Android SDK r23] (http://dl.google.com/android/android-sdk_r23.0.2-windows.zip)
> Download and decompress on C: [Android NDK r10b] (http://dl.google.com/android/ndk/android-ndk32-r10b-windows-x86.zip)
> Download and decompress on C: [Apache Ant 1.9.4] (http://ftp.cixug.es/apache//ant/binaries/apache-ant-1.9.4-bin.zip)
_Step 2._ Create the following environment variables with the correct paths:
ANDROID_SDK_TOOLS = C:\android-sdk\platform-tools
ANDROID_NDK_ROOT = C:\android-ndk-r10b
ANT_HOME = C:\apache-ant-1.9.4
_Step 3._ To compile project, navigate from command line to folder `raylib/template_android/` and type:
%ANDROID_NDK_ROOT%\ndk-build
_Step 4._ To generate APK, navigate to folder `raylib/template_android/` and type:
%ANT_HOME%\bin\ant debug
_Step 5:_ To install APK into connected device (previously intalled drivers and activated USB debug mode on device):
%ANT_HOME%\bin\ant installd
_Step 6:_ To view log output from device:
%ANDROID_SDK_TOOLS%\adb logcat -c
%ANDROID_SDK_TOOLS%\adb -d logcat raylib:V *:S
**If you have any doubt, [just let me know][raysan5].**
contact contact
------- -------
@ -292,6 +201,9 @@ The following people have contributed in some way to make raylib project a reali
- Daniel Moreno for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com)) - Daniel Moreno for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
- Daniel Gomez for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com)) - Daniel Gomez for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
- Sergio Martinez for helping on raygui development and tools development. - Sergio Martinez for helping on raygui development and tools development.
- Victor Fisac for developing physics raylib module (physac) and implementing light shaders and raycast system... and multiple tools and games.
- Albert Martos for helping on raygui and porting examples and game-templates to Android and HTML5.
- Ian Eito for helping on raygui and porting examples and game-templates to Android and HTML5.
[raysan5]: mailto:raysan@raysanweb.com "Ramon Santamaria - Ray San" [raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San"

View file

@ -8,14 +8,17 @@ Around the source code there are multiple TODO points with pending revisions/bug
raylib v1.4 raylib v1.4
- TTF fonts support (using stb_truetype) [DONE] TTF fonts support (using stb_truetype)
- Raycast system for 3D picking (including collisions detection) [DONE] Raycast system for 3D picking (including collisions detection)
[DONE] Floyd-Steinberg dithering on 16bit image format conversion
[DONE] Basic image manipulation functions (crop, resize, draw...)
[DONE] Storage load/save data functionality
[DONE] Physics module
[IN PROGRESS] LUA scripting support (wrapper to lua lib)
- Remove GLEW dependency (use another solution... glad?) - Remove GLEW dependency (use another solution... glad?)
- Floyd-Steinberg dithering on 16bit image format conversion
- Basic image manipulation functions (crop, resize, draw...)
- Basic image procedural generation (spot, gradient, noise...) - Basic image procedural generation (spot, gradient, noise...)
- Basic GPU stats sytem (memory, draws, time...) - Basic GPU stats sytem (memory, draws, time...)
- LUA scripting support (wrapper to lua lib)
Check [GITHUB ISSUES][issues] for further details on implementation status for this features! Check [GITHUB ISSUES][issues] for further details on implementation status for this features!

View file

@ -27,7 +27,7 @@ int main()
PlayMusicStream("resources/audio/guitar_noodling.ogg"); // Play music stream PlayMusicStream("resources/audio/guitar_noodling.ogg"); // Play music stream
int framesCounter = 0; int framesCounter = 0;
float timePlayed = 0; float timePlayed = 0.0f;
//float volume = 1.0; //float volume = 1.0;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second

View file

@ -26,6 +26,8 @@ int main()
Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file
Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file
SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -23,7 +23,7 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person"); InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }};
// Generates some random columns // Generates some random columns
float heights[MAX_COLUMNS]; float heights[MAX_COLUMNS];
@ -37,7 +37,7 @@ int main()
colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 }; colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
} }
Vector3 playerPosition = { 4, 2, 4 }; // Define player position Vector3 playerPosition = { 4.0f, 2.0f, 4.0f }; // Define player position
SetCameraMode(CAMERA_FIRST_PERSON); // Set a first person camera mode SetCameraMode(CAMERA_FIRST_PERSON); // Set a first person camera mode
@ -60,16 +60,16 @@ int main()
Begin3dMode(camera); Begin3dMode(camera);
DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 32, 32 }, LIGHTGRAY); // Draw ground DrawPlane((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector2){ 32.0f, 32.0f }, LIGHTGRAY); // Draw ground
DrawCube((Vector3){ -16, 2.5, 0 }, 1, 5, 32, BLUE); // Draw a blue wall DrawCube((Vector3){ -16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, BLUE); // Draw a blue wall
DrawCube((Vector3){ 16, 2.5, 0 }, 1, 5, 32, LIME); // Draw a green wall DrawCube((Vector3){ 16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, LIME); // Draw a green wall
DrawCube((Vector3){ 0, 2.5, 16 }, 32, 5, 1, GOLD); // Draw a yellow wall DrawCube((Vector3){ 0.0f, 2.5f, 16.0f }, 32.0f, 5.0f, 1.0f, GOLD); // Draw a yellow wall
// Draw some cubes around // Draw some cubes around
for (int i = 0; i < MAX_COLUMNS; i++) for (int i = 0; i < MAX_COLUMNS; i++)
{ {
DrawCube(positions[i], 2, heights[i], 2, colors[i]); DrawCube(positions[i], 2.0f, heights[i], 2.0f, colors[i]);
DrawCubeWires(positions[i], 2, heights[i], 2, MAROON); DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, MAROON);
} }
End3dMode(); End3dMode();

View file

@ -21,9 +21,12 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera;
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f };
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
Vector3 cubePosition = { 0.0, 0.0, 0.0 }; Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
SetCameraMode(CAMERA_FREE); // Set a free camera mode SetCameraMode(CAMERA_FREE); // Set a free camera mode
SetCameraPosition(camera.position); // Set internal camera position to match our camera position SetCameraPosition(camera.position); // Set internal camera position to match our camera position
@ -48,10 +51,10 @@ int main()
Begin3dMode(camera); Begin3dMode(camera);
DrawCube(cubePosition, 2, 2, 2, RED); DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
DrawCubeWires(cubePosition, 2, 2, 2, MAROON); DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
DrawGrid(10.0, 1.0); DrawGrid(10, 1.0f);
End3dMode(); End3dMode();

View file

@ -21,11 +21,14 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode"); InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera;
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f };
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
Vector3 cubePosition = { 0.0, 0.0, 0.0 }; Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
//SetTargetFPS(60); // Set our game to run at 60 frames-per-second, but not now... SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
@ -40,14 +43,14 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(WHITE); ClearBackground(RAYWHITE);
Begin3dMode(camera); Begin3dMode(camera);
DrawCube(cubePosition, 2, 2, 2, RED); DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
DrawCubeWires(cubePosition, 2, 2, 2, MAROON); DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
DrawGrid(10.0, 1.0); DrawGrid(10, 1.0f);
End3dMode(); End3dMode();

View file

@ -21,10 +21,10 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking"); InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }};
Vector3 cubePosition = { 0.0, 1.0, 0.0 }; Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
Vector3 cubeSize = { 2.0, 2.0, 2.0 }; Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
Ray ray; // Picking line ray Ray ray; // Picking line ray
@ -50,8 +50,8 @@ int main()
// Check collision between ray and box // Check collision between ray and box
collision = CheckCollisionRayBox(ray, collision = CheckCollisionRayBox(ray,
(Vector3){cubePosition.x - cubeSize.x / 2,cubePosition.y - cubeSize.y / 2,cubePosition.z - cubeSize.z / 2}, (Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 },
(Vector3){cubePosition.x + cubeSize.x / 2,cubePosition.y + cubeSize.y / 2,cubePosition.z + cubeSize.z / 2}); (Vector3){ cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2, cubePosition.z + cubeSize.z/2 });
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -66,10 +66,10 @@ int main()
DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY); DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY);
DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY); DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY);
DrawGrid(10.0, 1.0);
DrawRay(ray, MAROON); DrawRay(ray, MAROON);
DrawGrid(10, 1.0f);
End3dMode(); End3dMode();
DrawText("Try selecting the box with mouse!", 240, 10, 20, GRAY); DrawText("Try selecting the box with mouse!", 240, 10, 20, GRAY);

View file

@ -29,6 +29,8 @@ int main()
int screenHeight = 450; int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window"); InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -23,8 +23,8 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input"); InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
Vector2 ballPosition = { screenWidth/2, screenHeight/2 }; Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 };
Vector2 gamepadMovement = { 0, 0 }; Vector2 gamepadMovement = { 0.0f, 0.0f };
SetTargetFPS(60); // Set target frames-per-second SetTargetFPS(60); // Set target frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -43,8 +43,8 @@ int main()
if (IsGamepadButtonPressed(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_A)) if (IsGamepadButtonPressed(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_A))
{ {
ballPosition.x = screenWidth/2; ballPosition.x = (float)screenWidth/2;
ballPosition.y = screenHeight/2; ballPosition.y = (float)screenHeight/2;
} }
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View file

@ -20,7 +20,7 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input"); InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input");
Vector2 ballPosition = { screenWidth/2, screenHeight/2 }; Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 };
SetTargetFPS(60); // Set target frames-per-second SetTargetFPS(60); // Set target frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -30,10 +30,10 @@ int main()
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 0.8; if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 0.8f;
if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 0.8; if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 0.8f;
if (IsKeyDown(KEY_UP)) ballPosition.y -= 0.8; if (IsKeyDown(KEY_UP)) ballPosition.y -= 0.8f;
if (IsKeyDown(KEY_DOWN)) ballPosition.y += 0.8; if (IsKeyDown(KEY_DOWN)) ballPosition.y += 0.8f;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View file

@ -20,8 +20,9 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input"); InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input");
int mouseX, mouseY; Vector2 ballPosition = { -100.0f, -100.0f };
Vector2 ballPosition = { -100.0, -100.0 };
SetTargetFPS(60);
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
// Main game loop // Main game loop
@ -31,11 +32,7 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{ {
mouseX = GetMouseX(); ballPosition = GetMousePosition();
mouseY = GetMouseY();
ballPosition.x = (float)mouseX;
ballPosition.y = (float)mouseY;
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View file

@ -22,7 +22,7 @@ int main()
int framesCounter = 0; // Variable used to count frames int framesCounter = 0; // Variable used to count frames
int randValue = GetRandomValue(-8,5); // Get a random integer number between -8 and 5 (both included) int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included)
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -37,7 +37,7 @@ int main()
// Every two seconds (120 frames) a new random value is generated // Every two seconds (120 frames) a new random value is generated
if (((framesCounter/120)%2) == 1) if (((framesCounter/120)%2) == 1)
{ {
randValue = GetRandomValue(-8,5); randValue = GetRandomValue(-8, 5);
framesCounter = 0; framesCounter = 0;
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View file

@ -21,9 +21,9 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }};
Vector3 cubePosition = { 0.0, 0.0, 0.0 }; Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
Vector2 cubeScreenPosition; Vector2 cubeScreenPosition;
@ -53,10 +53,10 @@ int main()
Begin3dMode(camera); Begin3dMode(camera);
DrawCube(cubePosition, 2, 2, 2, RED); DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
DrawCubeWires(cubePosition, 2, 2, 2, MAROON); DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
DrawGrid(10.0, 1.0); DrawGrid(10, 1.0f);
End3dMode(); End3dMode();

View file

@ -21,10 +21,10 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards"); InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = {{ 5.0, 4.0, 5.0 }, { 0.0, 2.0, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera = {{ 5.0f, 4.0f, 5.0f }, { 0.0f, 2.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }};
Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard
Vector3 billPosition = { 0.0, 2.0, 0.0 }; // Position where draw billboard Vector3 billPosition = { 0.0f, 2.0f, 0.0f }; // Position where draw billboard
SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
SetCameraPosition(camera.position); // Set internal camera position to match our camera position SetCameraPosition(camera.position); // Set internal camera position to match our camera position
@ -49,10 +49,10 @@ int main()
Begin3dMode(camera); Begin3dMode(camera);
DrawGrid(10.0, 1.0); // Draw a grid
DrawBillboard(camera, bill, billPosition, 2.0f, WHITE); DrawBillboard(camera, bill, billPosition, 2.0f, WHITE);
DrawGrid(10, 1.0f); // Draw a grid
End3dMode(); End3dMode();
DrawFPS(10, 10); DrawFPS(10, 10);

View file

@ -21,16 +21,16 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions"); InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }};
Vector3 playerPosition = { 0, 1, 2 }; Vector3 playerPosition = { 0.0f, 1.0f, 2.0f };
Vector3 playerSize = { 1, 2, 1 }; Vector3 playerSize = { 1.0f, 2.0f, 1.0f };
Color playerColor = GREEN; Color playerColor = GREEN;
Vector3 enemyBoxPos = { -4, 1, 0 }; Vector3 enemyBoxPos = { -4.0f, 1.0f, 0.0f };
Vector3 enemyBoxSize = { 2, 2, 2 }; Vector3 enemyBoxSize = { 2.0f, 2.0f, 2.0f };
Vector3 enemySpherePos = { 4, 0, 0 }; Vector3 enemySpherePos = { 4.0f, 0.0f, 0.0f };
float enemySphereSize = 1.5f; float enemySphereSize = 1.5f;
bool collision = false; bool collision = false;
@ -98,7 +98,7 @@ int main()
// Draw player // Draw player
DrawCubeV(playerPosition, playerSize, playerColor); DrawCubeV(playerPosition, playerSize, playerColor);
DrawGrid(10.0, 1.0); // Draw a grid DrawGrid(10, 1.0f); // Draw a grid
End3dMode(); End3dMode();

View file

@ -21,7 +21,7 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing"); InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = {{ 16.0, 14.0, 16.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera = {{ 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }};
Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM) Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM) Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM)
@ -31,7 +31,7 @@ int main()
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture
SetModelTexture(&map, texture); // Bind texture to map model SetModelTexture(&map, texture); // Bind texture to map model
Vector3 mapPosition = { -16, 0.0, -8 }; // Set model position Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position
UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM

View file

@ -21,7 +21,7 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes"); InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }};
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -42,21 +42,21 @@ int main()
Begin3dMode(camera); Begin3dMode(camera);
DrawCube((Vector3){-4, 0, 2}, 2, 5, 2, RED); DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED);
DrawCubeWires((Vector3){-4, 0, 2}, 2, 5, 2, GOLD); DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD);
DrawCubeWires((Vector3){-4, 0, -2}, 3, 6, 2, MAROON); DrawCubeWires((Vector3){-4.0f, 0.0f, -2.0f}, 3.0f, 6.0f, 2.0f, MAROON);
DrawSphere((Vector3){-1, 0, -2}, 1, GREEN); DrawSphere((Vector3){-1.0f, 0.0f, -2.0f}, 1.0f, GREEN);
DrawSphereWires((Vector3){1, 0, 2}, 2, 16, 16, LIME); DrawSphereWires((Vector3){1.0f, 0.0f, 2.0f}, 2.0f, 16, 16, LIME);
DrawCylinder((Vector3){4, 0, -2}, 1, 2, 3, 4, SKYBLUE); DrawCylinder((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, SKYBLUE);
DrawCylinderWires((Vector3){4, 0, -2}, 1, 2, 3, 4, DARKBLUE); DrawCylinderWires((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, DARKBLUE);
DrawCylinderWires((Vector3){4.5, -1, 2}, 1, 1, 2, 6, BROWN); DrawCylinderWires((Vector3){4.5f, -1.0f, 2.0f}, 1.0f, 1.0f, 2.0f, 6, BROWN);
DrawCylinder((Vector3){1, 0, -4}, 0, 1.5, 3, 8, GOLD); DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD);
DrawCylinderWires((Vector3){1, 0, -4}, 0, 1.5, 3, 8, PINK); DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK);
DrawGrid(10.0, 1.0); // Draw a grid DrawGrid(10, 1.0f); // Draw a grid
End3dMode(); End3dMode();

View file

@ -21,13 +21,13 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing"); InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
// Define our custom camera to look into our 3d world // Define our custom camera to look into our 3d world
Camera camera = {{ 24.0, 18.0, 24.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera = {{ 24.0f, 18.0f, 24.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }};
Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM) Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM) Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
Model map = LoadHeightmap(image, 32); // Load heightmap model Model map = LoadHeightmap(image, 32); // Load heightmap model
SetModelTexture(&map, texture); // Bind texture to model SetModelTexture(&map, texture); // Bind texture to model
Vector3 mapPosition = { -16, 0.0, -16 }; // Set model position (depends on model scaling!) Vector3 mapPosition = { -16.0f, 0.0f, -16.0f }; // Set model position (depends on model scaling!)
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM

View file

@ -21,12 +21,12 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading"); InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera = {{ 3.0, 3.0, 3.0 }, { 0.0, 1.5, 0.0 }, { 0.0, 1.0, 0.0 }}; Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }};
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture
SetModelTexture(&dwarf, texture); // Bind texture to model SetModelTexture(&dwarf, texture); // Bind texture to model
Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -49,7 +49,7 @@ int main()
DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
DrawGrid(10.0, 1.0); // Draw a grid DrawGrid(10, 1.0f); // Draw a grid
DrawGizmo(position); // Draw gizmo DrawGizmo(position); // Draw gizmo

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