Merge remote-tracking branch 'refs/remotes/raysan5/master'

This commit is contained in:
victorfisac 2016-02-26 14:32:30 +01:00
commit ce56fcb1ed
276 changed files with 53232 additions and 4695 deletions

2
.gitignore vendored
View file

@ -60,3 +60,5 @@ xcschememanagement.plist
._.* ._.*
xcuserdata/ xcuserdata/
DerivedData/ DerivedData/
*.dll
src/libraylib.a

View file

@ -1,11 +1,48 @@
changelog changelog
--------- ---------
Current Release: raylib 1.3.0 (03 September 2015) Current Release: raylib 1.4.0 (22 February 2016)
NOTE: Only versions marked as 'Release' are available in installer, updates are only available as source. NOTE: Only versions marked as 'Release' are available in installer, updates are only available as source.
NOTE: Current Release includes all previous updates. NOTE: Current Release includes all previous updates.
-----------------------------------------------
Release: raylib 1.4.0 (22 February 2016)
-----------------------------------------------
NOTE:
This version supposed another big improvement for raylib, inlcuding new modules and new features.
More than 30 new functions have been added to previous raylib version.
Around 8 new examples and +10 new game samples have been added.
BIG changes:
[textures] IMAGE MANIPULATION: Functions to crop, resize, colorize, flip, dither and even draw image-to-image or text-to-image.
[text] SPRITEFONT SUPPORT: Added support for AngelCode fonts (.fnt) and TrueType fonts (.ttf).
[gestures] REDESIGN: Gestures system simplified and prepared to process generic touch events, including mouse events (multiplatform).
[physac] NEW MODULE: Basic 2D physics support, use colliders and rigidbodies; apply forces to physic objects.
other changes:
[rlgl] Removed GLEW library dependency, now using GLAD
[rlgl] Implemented alternative to glGetTexImage() on OpenGL ES
[rlgl] Using depth data on batch drawing
[rlgl] Reviewed glReadPixels() function
[core][rlgl] Reviewed raycast system, now 3D picking works
[core] Android: Reviewed Android App cycle, paused if inactive
[shaders] Implemented Blinn-Phong lighting shading model
[textures] Implemented Floyd-Steinberg dithering - ImageDither()
[text] Added line-break support to DrawText()
[text] Added TrueType Fonts support (using stb_truetype)
[models] Implement function: CalculateBoundingBox(Mesh mesh)
[models] Added functions to check Ray collisions
[models] Improve map resolution control on LoadHeightmap()
[camera] Corrected small-glitch on zoom-in with mouse-wheel
[gestures] Implemented SetGesturesEnabled() to enable only some gestures
[gestures] Implemented GetElapsedTime() on Windows system
[gestures] Support mouse gestures for desktop platforms
[raymath] Complete review of the module and converted to header-only
[easings] Added new module for easing animations
[stb] Updated to latest headers versions
[*] Lots of tweaks around
----------------------------------------------- -----------------------------------------------
Release: raylib 1.3.0 (01 September 2015) Release: raylib 1.3.0 (01 September 2015)
----------------------------------------------- -----------------------------------------------

View file

@ -32,6 +32,8 @@ contact
* Webpage: [http://www.raylib.com](http://www.raylib.com) * Webpage: [http://www.raylib.com](http://www.raylib.com)
* Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5) * Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5)
* Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames) * Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames)
* Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
* Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5)
* Patreon: [https://www.patreon.com/raysan5](https://www.patreon.com/raysan5)
[raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San"
[raysan5]: mailto:raysan@raysanweb.com "Ramon Santamaria - Ray San"

View file

@ -41,7 +41,7 @@ All rBMF fonts provided with raylib are free to use (freeware) and have been des
3d models 3d models
--------- ---------
dwarf 3d model used in examples is created by Daniel Moreno and licensed as Creative Commons Attribution-NonCommercial 3.0 dwarf 3d model used in examples is created by David Moreno and licensed as Creative Commons Attribution-NonCommercial 3.0
Full license provided below: Full license provided below:

160
README.md
View file

@ -6,7 +6,6 @@ about
raylib is a simple and easy-to-use library to learn videogames programming. raylib is a simple and easy-to-use library to learn videogames programming.
raylib is highly inspired by Borland BGI graphics lib and by XNA framework. raylib is highly inspired by Borland BGI graphics lib and by XNA framework.
Allegro and SDL have also been analyzed for reference.
NOTE for ADVENTURERS: raylib is a programming library to learn videogames programming; NOTE for ADVENTURERS: raylib is a programming library to learn videogames programming;
no fancy interface, no visual helpers, no auto-debugging... just coding in the most no fancy interface, no visual helpers, no auto-debugging... just coding in the most
@ -15,7 +14,7 @@ pure spartan-programmers way. Are you ready to learn? Jump to [code examples!](h
history history
------- -------
I've developed videogames for some years and last year I had to taught videogames development I've developed videogames for some years and 4 years ago I started teaching videogames development
to young people with artistic profile, most of them had never written a single line of code. to young people with artistic profile, most of them had never written a single line of code.
I started with C language basis and, after searching for the most simple and easy-to-use library to teach I started with C language basis and, after searching for the most simple and easy-to-use library to teach
@ -34,7 +33,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,15 +98,38 @@ 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. For this new version, lots of parts of the library have been reviewed, lots of bugs have been solved and some interesting features have been added.
First big addition is a set of [Image manipulation functions](https://github.com/raysan5/raylib/blob/develop/src/raylib.h#L673) have been added to crop, resize, colorize, flip, dither and even draw image-to-image or text-to-image. Now a basic image processing can be done before converting the image to texture for usage.
SpriteFonts system has been improved, adding support for AngelCode fonts (.fnt) and TrueType Fonts (using [stb_truetype](https://github.com/nothings/stb/blob/master/stb_truetype.h) helper library). Now raylib can read standard .fnt font data and also generate at loading a SpriteFont from a TTF file.
New [physac](https://github.com/raysan5/raylib/blob/develop/src/physac.h) physics module for basic 2D physics support. Still in development but already functional. Module comes with some usage examples for basic jump and level interaction and also force-based physic movements.
[raymath](https://github.com/raysan5/raylib/blob/develop/src/raymath.h) module has been reviewed; some bugs have been solved and the module has been converted to a header-only file for easier portability, optionally, functions can also be used as inline.
[gestures](https://github.com/raysan5/raylib/blob/develop/src/gestures.c) module has redesigned and simplified, now it can process touch events from any source, including mouse. This way, gestures system can be used on any platform providing an unified way to work with inputs and allowing the user to create multiplatform games with only one source code.
Raspberry Pi input system has been redesigned to better read raw inputs using generic Linux event handlers (keyboard:`stdin`, mouse:`/dev/input/mouse0`, gamepad:`/dev/input/js0`). Gamepad support has also been added (experimental).
Other important improvements are the functional raycast system for 3D picking, including some ray collision-detection functions, and the addition of two simple functions for persistent data storage. Now raylib user can save and load game data in a file (only some platforms supported). A simple [easings](https://github.com/raysan5/raylib/blob/develop/src/easings.h) module has also been added for values animation.
Up to 8 new code examples have been added to show the new raylib features and +10 complete game samples have been provided to learn how to create some classic games like Arkanoid, Asteroids, Missile Commander, Snake or Tetris.
Lots of code changes and lots of hours of hard work 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 (DXT, ETC, PVRT, ASTC)
* 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)
* Audio loading and playing with streaming support (WAV and OGG) * Audio loading and playing with streaming support (WAV and OGG)
@ -145,126 +167,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
------- -------
@ -272,6 +180,9 @@ contact
* Webpage: [http://www.raylib.com](http://www.raylib.com) * Webpage: [http://www.raylib.com](http://www.raylib.com)
* Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5) * Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5)
* Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames) * Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames)
* Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
* Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5)
* Patreon: [https://www.patreon.com/raysan5](https://www.patreon.com/raysan5)
If you are using raylib and you enjoy it, please, [let me know][raysan5]. If you are using raylib and you enjoy it, please, [let me know][raysan5].
@ -292,6 +203,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

@ -1,25 +1,37 @@
roadmap roadmap
------- -------
Current version of raylib is quite complete and functional but there is still a lot of things I would like to improve. Current version of raylib is quite complete and functional but there is still a lot of things to add and improve.
Here it is a list of features I would like to add and functions to improve. Here it is a wish list of features I would like to add and functions to improve.
Around the source code there are multiple TODO points with pending revisions/bugs and here it is a list of desired features. Note that around the raylib source code there are multiple TODO points with pending revisions/bugs. Check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
raylib v1.4 raylib 1.5
- TTF fonts support (using stb_truetype) Redesign Shaders/Textures system, use Materials
- Raycast system for 3D picking (including collisions detection) Redesign physics module (physac)
- Remove GLEW dependency (use another solution... glad?) Basic GPU stats sytem (memory, draws, time...)
- Floyd-Steinberg dithering on 16bit image format conversion Procedural image generation functions (spot, gradient, noise...)
- Basic image manipulation functions (crop, resize, draw...) Procedural mesh generation functions (cube, cone, sphere...)
- Basic image procedural generation (spot, gradient, noise...) Touch-based camera controls for Android
- Basic GPU stats sytem (memory, draws, time...) Skybox and Fog support
- LUA scripting support (wrapper to lua lib) [IN PROGRESS] LUA scripting support (wrapper to lua lib)
Check [GITHUB ISSUES][issues] for further details on implementation status for this features! raylib 1.4
[DONE] TTF fonts support (using stb_truetype)
[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] Add Physics module (physac)
[DONE] Remove GLEW dependency -> Replaced by GLAD
[DONE] Redesign Raspberry PI inputs system
[DONE] Redesign gestures module to be multiplatform
[DONE] Module raymath as header-only and functions inline
[DONE] Add Easings module (easings.h)
Any feature missing? Do you have a request? [Let me know!][raysan5] Any feature missing? Do you have a request? [Let me know!][raysan5]
[raysan5]: mailto:raysan@raysanweb.com "Ramon Santamaria - Ray San" [raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San"
[isssues]: https://github.com/raysan5/raylib/issues [isssues]: https://github.com/raysan5/raylib/issues

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

@ -22,8 +22,8 @@ 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 (position, target, up vector)
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 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)
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
@ -44,14 +47,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();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Before After
Before After

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 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)
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,12 +21,18 @@ 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;
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)
Vector3 cubePosition = { 0.0, 1.0, 0.0 }; Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
Ray ray; // Picking line ray Ray ray; // Picking line ray
bool collision = false;
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
@ -45,7 +51,10 @@ int main()
// NOTE: This function is NOT WORKING properly! // NOTE: This function is NOT WORKING properly!
ray = GetMouseRay(GetMousePosition(), camera); ray = GetMouseRay(GetMousePosition(), camera);
// TODO: Check collision between ray and box // Check collision between ray and box
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 });
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -57,17 +66,19 @@ int main()
Begin3dMode(camera); Begin3dMode(camera);
DrawCube(cubePosition, 2, 2, 2, GRAY); DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY);
DrawCubeWires(cubePosition, 2, 2, 2, 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);
if(collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, screenHeight * 0.1f, 30, GREEN);
DrawFPS(10, 10); DrawFPS(10, 10);
EndDrawing(); EndDrawing();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Before After
Before After

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

@ -0,0 +1,115 @@
/*******************************************************************************************
*
* raylib [core] example - Gestures Detection
*
* This example has been created using raylib 1.4 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2016 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
#include <string.h>
#define MAX_GESTURE_STRINGS 20
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - gestures detection");
Vector2 touchPosition = { 0, 0 };
Rectangle touchArea = { 220, 10, screenWidth - 230, screenHeight - 20 };
int gesturesCount = 0;
char gestureStrings[MAX_GESTURE_STRINGS][32];
int currentGesture = GESTURE_NONE;
int lastGesture = GESTURE_NONE;
//SetGesturesEnabled(0b0000000000001001); // Enable only some gestures to be detected
SetTargetFPS(30);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
lastGesture = currentGesture;
touchPosition = GetTouchPosition(0);
if (CheckCollisionPointRec(touchPosition, touchArea) && IsGestureDetected())
{
currentGesture = GetGestureType();
if (currentGesture != lastGesture)
{
// Store gesture string
switch (currentGesture)
{
case GESTURE_TAP: strcpy(gestureStrings[gesturesCount], "GESTURE TAP"); break;
case GESTURE_DOUBLETAP: strcpy(gestureStrings[gesturesCount], "GESTURE DOUBLETAP"); break;
case GESTURE_HOLD: strcpy(gestureStrings[gesturesCount], "GESTURE HOLD"); break;
case GESTURE_DRAG: strcpy(gestureStrings[gesturesCount], "GESTURE DRAG"); break;
case GESTURE_SWIPE_RIGHT: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE RIGHT"); break;
case GESTURE_SWIPE_LEFT: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE LEFT"); break;
case GESTURE_SWIPE_UP: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE UP"); break;
case GESTURE_SWIPE_DOWN: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE DOWN"); break;
default: break;
}
gesturesCount++;
// Reset gestures strings
if (gesturesCount >= MAX_GESTURE_STRINGS)
{
for (int i = 0; i < MAX_GESTURE_STRINGS; i++) strcpy(gestureStrings[i], "\0");
gesturesCount = 0;
}
}
}
else currentGesture = GESTURE_NONE;
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawRectangleRec(touchArea, GRAY);
DrawRectangle(225, 15, screenWidth - 240, screenHeight - 30, RAYWHITE);
DrawText("GESTURES TEST AREA", screenWidth - 270, screenHeight - 40, 20, Fade(GRAY, 0.5f));
for (int i = 0; i < gesturesCount; i++)
{
if (i%2 == 0) DrawRectangle(10, 30 + 20*i, 200, 20, Fade(LIGHTGRAY, 0.5f));
else DrawRectangle(10, 30 + 20*i, 200, 20, Fade(LIGHTGRAY, 0.3f));
if (i < gesturesCount - 1) DrawText(gestureStrings[i], 35, 36 + 20*i, 10, DARKGRAY);
else DrawText(gestureStrings[i], 35, 36 + 20*i, 10, MAROON);
}
DrawRectangleLines(10, 29, 200, screenHeight - 50, GRAY);
DrawText("DETECTED GESTURES", 50, 15, 10, GRAY);
if (currentGesture != GESTURE_NONE) DrawCircleV(touchPosition, 30, MAROON);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

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,10 @@ 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 }; Color ballColor = DARKBLUE;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
// Main game loop // Main game loop
@ -29,14 +31,11 @@ int main()
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballPosition = GetMousePosition();
{
mouseX = GetMouseX();
mouseY = GetMouseY();
ballPosition.x = (float)mouseX; if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballColor = MAROON;
ballPosition.y = (float)mouseY; else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) ballColor = LIME;
} else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
@ -45,9 +44,9 @@ int main()
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawCircleV(ballPosition, 40, GOLD); DrawCircleV(ballPosition, 40, ballColor);
DrawText("mouse click to draw the ball", 10, 10, 20, DARKGRAY); DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

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