8
.github/FUNDING.yml
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: raysan5
|
||||||
|
patreon: # raylib
|
||||||
|
open_collective: # Replace with a single Open Collective username
|
||||||
|
ko_fi: # raysan
|
||||||
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
custom: # Replace with a single custom sponsorship URL
|
||||||
30
.github/ISSUE_TEMPLATE/custom-issue-template.md
vendored
|
|
@ -1,30 +0,0 @@
|
||||||
---
|
|
||||||
name: custom issue template
|
|
||||||
about: generic template for new issues
|
|
||||||
title: "[module] Short description of the issue/bug/feature"
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Please, before submitting a new issue verify and check:
|
|
||||||
|
|
||||||
- [ ] I tested it on latest raylib version from master branch
|
|
||||||
- [ ] I checked there is no similar issue already reported
|
|
||||||
- [ ] My code has no errors or misuse of raylib
|
|
||||||
|
|
||||||
### Issue description
|
|
||||||
|
|
||||||
*Briefly describe the issue you are experiencing (or the feature you want to see added to raylib). Tell us what you were trying to do and what happened instead. Remember, this is not the best place to ask questions. For questions, go to [raylib Discord server](https://discord.gg/VkzNHUE).*
|
|
||||||
|
|
||||||
### Environment
|
|
||||||
|
|
||||||
*Provide your Platform, Operating System, OpenGL version, GPU details where you experienced the issue.*
|
|
||||||
|
|
||||||
### Issue Screenshot
|
|
||||||
|
|
||||||
*If possible, provide a screenshot that illustrates the issue. Usually an image is better than a thousand words.*
|
|
||||||
|
|
||||||
### Code Example
|
|
||||||
|
|
||||||
*Provide minimal reproduction code to test the issue. Please, format the code properly and try to keep it as simple as possible, just focusing on the experienced issue.*
|
|
||||||
3
.gitignore
vendored
|
|
@ -30,6 +30,7 @@ Thumbs.db
|
||||||
*.cache
|
*.cache
|
||||||
*.ilk
|
*.ilk
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
[Bb]in
|
[Bb]in
|
||||||
[Dd]ebug/
|
[Dd]ebug/
|
||||||
[Dd]ebug.win32/
|
[Dd]ebug.win32/
|
||||||
|
|
@ -51,6 +52,8 @@ packages/
|
||||||
*.o
|
*.o
|
||||||
*.exe
|
*.exe
|
||||||
*.a
|
*.a
|
||||||
|
*.bc
|
||||||
|
*.so
|
||||||
!raylib.rc.o
|
!raylib.rc.o
|
||||||
|
|
||||||
# Ignore all examples files
|
# Ignore all examples files
|
||||||
|
|
|
||||||
|
|
@ -120,9 +120,12 @@ before_install:
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cd build
|
- cd build
|
||||||
- if test -n "$WAYLAND";
|
- if test -n "$WAYLAND"; then
|
||||||
then wget https://mirrors.kernel.org/ubuntu/pool/universe/e/extra-cmake-modules/extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb;
|
wget https://mirrors.edge.kernel.org/ubuntu/pool/universe/e/extra-cmake-modules/extra-cmake-modules_5.44.0-0ubuntu1_amd64.deb;
|
||||||
sudo dpkg -i extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb;
|
sudo apt-get clean;
|
||||||
|
sudo apt-get update;
|
||||||
|
sudo apt-get install dpkg;
|
||||||
|
sudo dpkg -i extra-cmake-modules_5.44.0-0ubuntu1_amd64.deb;
|
||||||
git clone git://anongit.freedesktop.org/wayland/wayland-protocols;
|
git clone git://anongit.freedesktop.org/wayland/wayland-protocols;
|
||||||
pushd wayland-protocols;
|
pushd wayland-protocols;
|
||||||
git checkout 1.15 && ./autogen.sh --prefix=/usr && make && sudo make install;
|
git checkout 1.15 && ./autogen.sh --prefix=/usr && make && sudo make install;
|
||||||
|
|
|
||||||
16
BINDINGS.md
|
|
@ -4,24 +4,36 @@ Some people ported raylib to other languages in form of bindings or wrappers to
|
||||||
|
|
||||||
- [raylib](https://github.com/raysan5/raylib) : raylib **C/C++** version (default)
|
- [raylib](https://github.com/raysan5/raylib) : raylib **C/C++** version (default)
|
||||||
- [raylib-lua](https://github.com/raysan5/raylib-lua) : raylib **Lua** binding
|
- [raylib-lua](https://github.com/raysan5/raylib-lua) : raylib **Lua** binding
|
||||||
- [raylib-lua-ffi](https://github.com/raysan5/raylib/issues/693) : raylib **Lua** ffi binding
|
- [raylib-lua-ffi](https://github.com/raysan5/raylib/issues/693) : raylib **Lua** binding
|
||||||
- [raylib-go](https://github.com/gen2brain/raylib-go) : raylib **Go** binding
|
- [raylib-go](https://github.com/gen2brain/raylib-go) : raylib **Go** binding
|
||||||
- [raylib-Nim](https://gitlab.com/define-private-public/raylib-Nim) : raylib **Nim** binding
|
- [raylib-Nim](https://gitlab.com/define-private-public/raylib-Nim) : raylib **Nim** binding
|
||||||
- [raylib-cr](https://github.com/AregevDev/raylib-cr) : raylib **Crystal** binding
|
- [raylib-cr](https://github.com/AregevDev/raylib-cr) : raylib **Crystal** binding
|
||||||
- [cray](https://gitlab.com/Zatherz/cray) - raylib **Crystal** binding
|
- [cray](https://gitlab.com/Zatherz/cray) : raylib **Crystal** binding
|
||||||
|
- [cray](https://github.com/tapgg/cray) : raylib **Crystal** binding
|
||||||
- [Graphics::Raylib](https://metacpan.org/pod/Graphics::Raylib) : raylib **Perl** wrapper
|
- [Graphics::Raylib](https://metacpan.org/pod/Graphics::Raylib) : raylib **Perl** wrapper
|
||||||
- [raylib-pascal](https://github.com/drezgames/raylib-pascal) - raylib **Pascal** binding
|
- [raylib-pascal](https://github.com/drezgames/raylib-pascal) - raylib **Pascal** binding
|
||||||
|
- [raylib-pas](https://github.com/tazdij/raylib-pas) - raylib **Pascal** binding (including rlgl & raymath)
|
||||||
- [Raylib-cs](https://github.com/ChrisDill/Raylib-cs) : raylib **C#** binding
|
- [Raylib-cs](https://github.com/ChrisDill/Raylib-cs) : raylib **C#** binding
|
||||||
- [RaylibSharp](https://github.com/TheLumaio/RaylibSharp) : raylib **C#** binding
|
- [RaylibSharp](https://github.com/TheLumaio/RaylibSharp) : raylib **C#** binding
|
||||||
- [raylib-ruby-ffi](https://github.com/D3nX/raylib-ruby-ffi) : raylib **Ruby** binding
|
- [raylib-ruby-ffi](https://github.com/D3nX/raylib-ruby-ffi) : raylib **Ruby** binding
|
||||||
- [raylib-rs](https://github.com/deltaphc/raylib-rs) : raylib **Rust** binding
|
- [raylib-rs](https://github.com/deltaphc/raylib-rs) : raylib **Rust** binding
|
||||||
- [raylib-py](https://github.com/overdev/raylib-py) : raylib **Python** binding
|
- [raylib-py](https://github.com/overdev/raylib-py) : raylib **Python** binding
|
||||||
|
- [raylib-python-cffi](https://github.com/electronstudio/raylib-python-cffi) : raylib **Python** binding
|
||||||
- [raylib-haskell](https://github.com/DevJac/raylib-haskell) : raylib **Haskell** binding
|
- [raylib-haskell](https://github.com/DevJac/raylib-haskell) : raylib **Haskell** binding
|
||||||
- [raylib-java](https://github.com/XoanaIO/raylib-java) : raylib **Java** binding
|
- [raylib-java](https://github.com/XoanaIO/raylib-java) : raylib **Java** binding
|
||||||
- [raylib-chaiscript](https://github.com/RobLoach/raylib-chaiscript) : raylib **ChaiScript** binding
|
- [raylib-chaiscript](https://github.com/RobLoach/raylib-chaiscript) : raylib **ChaiScript** binding
|
||||||
- [node-raylib](https://github.com/RobLoach/node-raylib) : **Node.js** raylib binding
|
- [node-raylib](https://github.com/RobLoach/node-raylib) : **Node.js** raylib binding
|
||||||
- [raylib-odin](https://github.com/kevinw/raylib-odin): **Odin** raylib binding
|
- [raylib-odin](https://github.com/kevinw/raylib-odin): **Odin** raylib binding
|
||||||
- [raylib-factor](https://github.com/Silverbeard00/raylib-factor): **Factor** raylib binding
|
- [raylib-factor](https://github.com/Silverbeard00/raylib-factor): **Factor** raylib binding
|
||||||
|
- [cl-raylib](https://github.com/longlene/cl-raylib) : raylib **Common Lisp** binding
|
||||||
|
- [raylib-nim](https://github.com/Skrylar/raylib-nim) : raylib **Nim** binding
|
||||||
|
- [raylib-php](https://github.com/joseph-montanez/raylib-php) : raylib **PHP 7** binding
|
||||||
|
- [raylib-php-ffi](https://github.com/oraoto/raylib-php-ffi) : raylib **PHP** binding
|
||||||
|
- [raylib-d](https://github.com/0xFireball/raylib_d) : raylib **dlang** binding
|
||||||
|
- [raylib-ruby](https://github.com/a0/raylib-ruby) : raylib **Ruby** wrapper
|
||||||
|
- [conan-raylib](https://github.com/veyroter/conan-raylib) : raylib **conan** package
|
||||||
|
- [raylib-squirrel](https://github.com/RobLoach/raylib-squirrel) : raylib **squirrel** binding (probe of concept)
|
||||||
|
- [raylib-mruby](https://github.com/lihaochen910/raylib-mruby) : raylib **mruby** binding
|
||||||
- *[raylib COBOL Usage example](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib)*
|
- *[raylib COBOL Usage example](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib)*
|
||||||
- *raylib flat-assembler Usage example*: not uploaded yet...
|
- *raylib flat-assembler Usage example*: not uploaded yet...
|
||||||
|
|
||||||
|
|
|
||||||
56
CHANGELOG
|
|
@ -1,27 +1,32 @@
|
||||||
changelog
|
changelog
|
||||||
---------
|
---------
|
||||||
|
|
||||||
Current Release: raylib 2.0.0 (July 2018)
|
Current Release: raylib 2.5.0 (31 May 2019)
|
||||||
|
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
Release: raylib 2.5 (May 2019)
|
Release: raylib 2.5 (May 2019)
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
KEY CHANGES:
|
KEY CHANGES:
|
||||||
- New text management API
|
- [core] Redesigned Gamepad mechanism, now common to all platforms and gamepads
|
||||||
- Cubemap textures support
|
- [core] HighDPI monitors support with automatic content scaling
|
||||||
- Skeletal model animation support
|
- [rlgl] Complete module redesign to use one single internal buffer
|
||||||
- New textures drawing: Quad and N-Patch based rectangles
|
- [rlgl] VR system redesign to allow custom device parameters and distortion shader
|
||||||
- New drawing shapes available: CircleSector, Ring and RectangleRounded
|
- [shapes] New drawing shapes available: CircleSector, Ring and RectangleRounded
|
||||||
- VR system redesign to allow custom device parameters and distortion shader
|
- [text] New text management API (multiple functions)
|
||||||
|
- [text] Full Unicode support (utf8 text)
|
||||||
|
- [textures] Cubemap textures support
|
||||||
|
- [textures] Quad and N-Patch drawing
|
||||||
|
- [models] Skeletal model animation support
|
||||||
|
- [models] Support multiple meshes per model
|
||||||
|
- [models] Support glTF model loading
|
||||||
|
|
||||||
Detailed changes:
|
Detailed changes:
|
||||||
[build] ...
|
[build] REVIEWED: Default raylib and examples Makefile
|
||||||
[build] REVIEWED: Notepad++ NppExec scripts
|
[build] REVIEWED: Notepad++ NppExec scripts
|
||||||
[build] REVIEWED: VS2015 and VS2017 projects
|
[build] REVIEWED: VS2015 and VS2017 projects
|
||||||
[build] REVIEWED: Android APK build pipeline
|
[build] REVIEWED: Android APK build pipeline
|
||||||
|
|
||||||
[core] Converted most #defined values as enum values
|
[core] Converted most #defined values as enum values
|
||||||
[core] Complete redesign of RPI input system
|
[core] Complete redesign of RPI input system to use evdev events
|
||||||
[core] ADDED: IsWindowResized() - Check if window has been resized
|
[core] ADDED: IsWindowResized() - Check if window has been resized
|
||||||
[core] ADDED: IsWindowHidden() - Check if window is currently hidden
|
[core] ADDED: IsWindowHidden() - Check if window is currently hidden
|
||||||
[core] ADDED: UnhideWindow() - Show the window
|
[core] ADDED: UnhideWindow() - Show the window
|
||||||
|
|
@ -105,25 +110,44 @@ Detailed changes:
|
||||||
[raudio] ADDED: IsAudioStreamPlaying() - Check if audio stream is playing
|
[raudio] ADDED: IsAudioStreamPlaying() - Check if audio stream is playing
|
||||||
[raudio] ADDED: SetAudioStreamVolume() - Set volume for audio stream (1.0 is max level)
|
[raudio] ADDED: SetAudioStreamVolume() - Set volume for audio stream (1.0 is max level)
|
||||||
[raudio] ADDED: SetAudioStreamPitch() - Set pitch for audio stream (1.0 is base level)
|
[raudio] ADDED: SetAudioStreamPitch() - Set pitch for audio stream (1.0 is base level)
|
||||||
|
[examples] Complete review of full examples collection, many additions
|
||||||
[examples] ADDED: core_custom_logging - Custom trace log system
|
[examples] ADDED: core_custom_logging - Custom trace log system
|
||||||
[examples] ADDED: core_input_multitouch - Multitouch input example
|
[examples] ADDED: core_input_multitouch - Multitouch input example
|
||||||
|
[examples] ADDED: core_window_letterbox - Window adapted to screen
|
||||||
|
[examples] ADDED: core_loading_thread - Data loading in second thread
|
||||||
|
[examples] REVIEWED: core_input_gamepad - Adapted to new gamepad system
|
||||||
[examples] REVIEWED: core_vr_simulator - HMD device parameters and distortion shader should be provided
|
[examples] REVIEWED: core_vr_simulator - HMD device parameters and distortion shader should be provided
|
||||||
[examples] ADDED: core_window_scale_letterbox - Windows resizing and letterbox content
|
[examples] ADDED: core_window_scale_letterbox - Windows resizing and letterbox content
|
||||||
[examples] ADDED: shapes_rectangle_scaling_mouse - Scale a rectangle with mouse
|
[examples] ADDED: shapes_rectangle_scaling_mouse - Scale a rectangle with mouse
|
||||||
TODO: [examples] ADDED: shapes_draw_circle_sector - Circle sector drawing
|
[examples] ADDED: shapes_draw_circle_sector - Circle sector drawing
|
||||||
TODO: [examples] ADDED: shapes_draw_ring - Ring drawing
|
[examples] ADDED: shapes_draw_ring - Ring drawing
|
||||||
TODO: [examples] ADDED: shapes_draw_rectangle_rounded - Rounded rectangle drawing
|
[examples] ADDED: shapes_draw_rectangle_rounded - Rounded rectangle drawing
|
||||||
|
[examples] ADDED: shapes_bouncing_ball - Ball bouncing in the screen
|
||||||
|
[examples] ADDED: shapes_collision_area - Collision detection and drawing
|
||||||
|
[examples] ADDED: shapes_following_eyes - Some maths on eyes and mouse
|
||||||
|
[examples] ADDED: shapes_easings_ball_anim - Ball animation
|
||||||
|
[examples] ADDED: shapes_easings_box_anim - Box animation
|
||||||
|
[examples] ADDED: shapes_easings_rectangle_array - Rectangles animation
|
||||||
|
[examples] REVIEWED: shapes_colors_palette - Reviewed color selection and text displaying
|
||||||
[examples] ADDED: textures_background_scrolling - Scrolling and parallaz background effect
|
[examples] ADDED: textures_background_scrolling - Scrolling and parallaz background effect
|
||||||
[examples] ADDED: textures_image_npatch - Drawing N-Patch based boxes
|
[examples] ADDED: textures_image_npatch - Drawing N-Patch based boxes
|
||||||
TODO: [examples] ADDED: textures_sprite_button
|
[examples] ADDED: textures_sprite_button - Sprite button with sound
|
||||||
TODO: [examples] ADDED: textures_sprite_explosion
|
[examples] ADDED: textures_sprite_explosion - Sprite explosion with sound
|
||||||
|
[examples] ADDED: textures_bunnymark - Benchmarking test
|
||||||
[examples] ADDED: text_draw_inside_rectangle - Drawing text inside a delimited rectangle box
|
[examples] ADDED: text_draw_inside_rectangle - Drawing text inside a delimited rectangle box
|
||||||
|
[examples] ADDED: text_unicode - Multiple languages text drawing
|
||||||
|
[examples] ADDED: text_rectangle_bound - Fit text inside a rectangle
|
||||||
|
[examples] REVIEWED: text_bmfont_ttf - Simplified example
|
||||||
[examples] ADDED: models_animation - Animated models loading and animation playing
|
[examples] ADDED: models_animation - Animated models loading and animation playing
|
||||||
[examples] ADDED: models_obj_viewer - Draw and drop models viewer
|
[examples] ADDED: models_obj_viewer - Draw and drop models viewer
|
||||||
[examples] ADDED: models_rlgl_solar_system - Solar system simulation using rlgl functionality
|
[examples] ADDED: models_rlgl_solar_system - Solar system simulation using rlgl functionality
|
||||||
|
[examples] ADDED: models_first_person_maze - 3D maze fps
|
||||||
[examples] ADDED: shaders_palette_switch - Switching color palette on shader
|
[examples] ADDED: shaders_palette_switch - Switching color palette on shader
|
||||||
[examples] ADDED: shaders_raymarching - Raymarching shader
|
[examples] ADDED: shaders_raymarching - Raymarching shader
|
||||||
[examples] ADDED: shaders_texture_drawing - Texture drawing on GPU
|
[examples] ADDED: shaders_texture_drawing - Texture drawing on GPU
|
||||||
|
[examples] ADDED: shaders_texture_waves - Texture waves on shader
|
||||||
|
[examples] ADDED: shaders_julia_set - Julia set fractals
|
||||||
|
[examples] ADDED: shaders_eratosthenes - Prime number visualization shader
|
||||||
[examples] REVIEWED: audio_raw_stream - Mostly rewritten
|
[examples] REVIEWED: audio_raw_stream - Mostly rewritten
|
||||||
[games] ADDED: GGJ19 game - Cat vs Roomba
|
[games] ADDED: GGJ19 game - Cat vs Roomba
|
||||||
[*] Updated external libraries to latest version
|
[*] Updated external libraries to latest version
|
||||||
|
|
@ -134,7 +158,7 @@ Release: raylib 2.0 (July 2018)
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
KEY CHANGES:
|
KEY CHANGES:
|
||||||
- Removed external dependencies (GLFW3 and OpenAL)
|
- Removed external dependencies (GLFW3 and OpenAL)
|
||||||
- Complete redesign of audio module to use mini_al audio library
|
- Complete redesign of audio module to use miniaudio library
|
||||||
- Support AppVeyor and Travis CI (continuous integration) building
|
- Support AppVeyor and Travis CI (continuous integration) building
|
||||||
- Reviewed raymath.h for better consistency and performance (inlining)
|
- Reviewed raymath.h for better consistency and performance (inlining)
|
||||||
- Refactor all #define SUPPORT_* into a single config.h
|
- Refactor all #define SUPPORT_* into a single config.h
|
||||||
|
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
# Contributor Covenant Code of Conduct
|
|
||||||
|
|
||||||
## Our Pledge
|
|
||||||
|
|
||||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
||||||
|
|
||||||
## Our Standards
|
|
||||||
|
|
||||||
Examples of behavior that contributes to creating a positive environment include:
|
|
||||||
|
|
||||||
* Using welcoming and inclusive language
|
|
||||||
* Being respectful of differing viewpoints and experiences
|
|
||||||
* Gracefully accepting constructive criticism
|
|
||||||
* Focusing on what is best for the community
|
|
||||||
* Showing empathy towards other community members
|
|
||||||
|
|
||||||
Examples of unacceptable behavior by participants include:
|
|
||||||
|
|
||||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
|
||||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
||||||
* Public or private harassment
|
|
||||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
|
||||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
||||||
|
|
||||||
## Our Responsibilities
|
|
||||||
|
|
||||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
|
||||||
|
|
||||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
|
||||||
|
|
||||||
## Scope
|
|
||||||
|
|
||||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
|
||||||
|
|
||||||
## Enforcement
|
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at ray@raylib.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
|
||||||
|
|
||||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
|
||||||
|
|
||||||
## Attribution
|
|
||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
|
||||||
|
|
||||||
[homepage]: http://contributor-covenant.org
|
|
||||||
[version]: http://contributor-covenant.org/version/1/4/
|
|
||||||
|
|
@ -2,6 +2,14 @@
|
||||||
|
|
||||||
Hello contributors! Welcome to raylib!
|
Hello contributors! Welcome to raylib!
|
||||||
|
|
||||||
|
Do you enjoy raylib and want to contribute? Nice! You can help with the following points:
|
||||||
|
|
||||||
|
- C programming - Can you write/review/test/improve the code?
|
||||||
|
- Documentation/Tutorials/Example - Can you write some tutorial/example?
|
||||||
|
- Web Development - Can you help [with the web](https://github.com/raysan5/raylib.com)?
|
||||||
|
- Porting to other platforms - Can you port and compile raylib on another systems?
|
||||||
|
- Testing - Can you find some bugs on raylib?
|
||||||
|
|
||||||
This document contains a set of guidelines to contribute to the project. These are mostly guidelines, not rules.
|
This document contains a set of guidelines to contribute to the project. These are mostly guidelines, not rules.
|
||||||
Use your best judgement, and feel free to propose changes to this document in a pull-request.
|
Use your best judgement, and feel free to propose changes to this document in a pull-request.
|
||||||
|
|
||||||
|
|
@ -89,29 +97,40 @@ contributing (in some way or another) to make the raylib project better. Huge th
|
||||||
- [Chris Hemingway](https://github.com/cHemingway) for improving raylib on OSX build system.
|
- [Chris Hemingway](https://github.com/cHemingway) for improving raylib on OSX build system.
|
||||||
- [Emanuele Petriglia](https://github.com/LelixSuper) for working on multiple GNU/Linux improvements and developing [TicTacToe](https://github.com/LelixSuper/TicTacToe) raylib game.
|
- [Emanuele Petriglia](https://github.com/LelixSuper) for working on multiple GNU/Linux improvements and developing [TicTacToe](https://github.com/LelixSuper/TicTacToe) raylib game.
|
||||||
- [Joshua Reisenauer](https://github.com/kd7tck) for adding audio modules support (XM, MOD) and reviewing audio system.
|
- [Joshua Reisenauer](https://github.com/kd7tck) for adding audio modules support (XM, MOD) and reviewing audio system.
|
||||||
- [Marcelo Paez](https://github.com/paezao) for his help on OSX to solve High DPI display issue. Thanks Marcelo!
|
- [Marcelo Paez](https://github.com/paezao) for helping on OSX High DPI display issue.
|
||||||
- [Ghassan Al-Mashareqa](https://github.com/ghassanpl) for his amazing contribution with raylib Lua module, I just work over his code to implement [rlua](https://github.com/raysan5/raylib/blob/master/src/rlua.h)
|
- [Ghassan Al-Mashareqa](https://github.com/ghassanpl) for an amazing contribution to raylib Lua module.
|
||||||
- [Teodor Stoenescu](https://github.com/teodor-stoenescu) for his improvements on OBJ object loading.
|
- [Teodor Stoenescu](https://github.com/teodor-stoenescu) for improvements on OBJ object loading.
|
||||||
- [RDR8](https://github.com/RDR8) for helping with Linux build improvements
|
- [RDR8](https://github.com/RDR8) for helping with Linux build improvements.
|
||||||
- [Saggi Mizrahi](https://github.com/ficoos) for multiple fixes on Linux and audio system
|
- [Saggi Mizrahi](https://github.com/ficoos) for multiple fixes on Linux and audio system.
|
||||||
- [Daniel Lemos](https://github.com/xspager) for fixing issues on Linux games building
|
- [Daniel Lemos](https://github.com/xspager) for fixing issues on Linux games building.
|
||||||
- [Joel Davis](https://github.com/joeld42) for adding raycast picking utilities and a [great example](https://github.com/raysan5/raylib/blob/master/examples/models/models_mesh_picking.c)
|
- [Joel Davis](https://github.com/joeld42) for adding raycast picking utilities and a [great example](https://github.com/raysan5/raylib/blob/master/examples/models/models_mesh_picking.c)
|
||||||
- [Richard Goodwin](https://github.com/AudioMorphology) for adding RPI touchscreen support
|
- [Richard Goodwin](https://github.com/AudioMorphology) for adding RPI touchscreen support.
|
||||||
- [Milan Nikolic](https://github.com/gen2brain) for adding Android build support with custom standalone toolchain
|
- [Milan Nikolic](https://github.com/gen2brain) for adding Android build support with custom standalone toolchain.
|
||||||
- [Michael Vetter](https://github.com/jubalh) for improvements on build system and his work on Suse Linux package... and multiple fixes!
|
- [Michael Vetter](https://github.com/jubalh) for improvements on build system and his work on Suse Linux package... and multiple fixes!
|
||||||
- [Wilhem Barbier](https://github.com/nounoursheureux) for adding Image generation functions and some fixes
|
- [Wilhem Barbier](https://github.com/nounoursheureux) for adding Image generation functions, shaders work and some fixes.
|
||||||
- [Benjamin Summerton](https://github.com/define-private-public) for improving OSX building and his amazing work on CMake build sytem
|
- [Benjamin Summerton](https://github.com/define-private-public) for improving OSX building and his amazing work on CMake build sytem.
|
||||||
- [MartinFX](https://github.com/Martinfx) for adding compilation support for FreeBSD OS and derivatives
|
- [MartinFX](https://github.com/Martinfx) for adding compilation support for FreeBSD OS and derivatives.
|
||||||
- [Wilhem Barbier](https://github.com/nounoursheureux) for supporting default shaders on shader loading, if shader not provided
|
- [Ahmad Fatoum](https://github.com/a3f) for implementing CI support for raylib (Travis and AppVeyor) and great improvements on build system.
|
||||||
- [Ahmad Fatoum](https://github.com/a3f) for implementing continuus integration support for raylib (Travis and AppVeyor) and greatly improving build system.
|
- [SamNChiet](https://github.com/SamNChiet) for a greatly improved UWP input implementation.
|
||||||
- [SamNChiet](https://github.com/SamNChiet) for his work on UWP inputs implementation.
|
- [David Reid](https://github.com/mackron) for a complete review of audio module to support his amazing miniaudio library.
|
||||||
- [David Reid](https://github.com/mackron) for a complete review of audio module to support his amazing mini_al audio library.
|
|
||||||
- [Kai](https://github.com/questor) for multiple code reviews and improvements.
|
- [Kai](https://github.com/questor) for multiple code reviews and improvements.
|
||||||
- [RDR8](https://github.com/RDR8) for his work on Makefiles for Linux
|
|
||||||
- [Max Danielsson](https://github.com/autious) for adding support for orthographic 3d camera projection
|
- [Max Danielsson](https://github.com/autious) for adding support for orthographic 3d camera projection
|
||||||
- [Lumaio](https://github.com/TheLumaio) for his great work on GBuffers and GetCollisionRayModel()
|
- [Lumaio](https://github.com/TheLumaio) for his great work on GBuffers and GetCollisionRayModel().
|
||||||
- [Jonas Daeyaert](https://github.com/culacant) for his amazing work on IQM animated models support
|
- [Jonas Daeyaert](https://github.com/culacant) for an amazing work on IQM animated models support.
|
||||||
- [Seth Archambault](https://github.com/SethArchambault) for his work on Android Gamepad support (SNES model)
|
- [Seth Archambault](https://github.com/SethArchambault) for the work on Android Gamepad support (SNES model).
|
||||||
- [D3nX](https://github.com/D3nX) for adding Code::Blocks project template.
|
- [D3nX](https://github.com/D3nX) for adding Code::Blocks project template.
|
||||||
|
- [Jak Barnes](https://github.com/Syphonx) for a great work on `rnet`, new raylib network module
|
||||||
|
- [Vlad Adrian](https://github.com/Demizdor) for an amazing work on Unicode support, new shapes functions and raygui.
|
||||||
|
- [Reece Mackie](https://github.com/Rover656) for a great work on improving UWP support
|
||||||
|
- [flashback-fx](flashback-fx) for improving easings library and example
|
||||||
|
- [Jorge A. Gomes](https://github.com/overdev) for adding nine-patch textures support and example
|
||||||
|
- [Berni8k](https://github.com/Berni8k) for improving Raspberry Pi input system, using evdev
|
||||||
|
- [Wilhem Barbier](https://github.com/wbrbr) for implementing glTF loading support and solving several issues
|
||||||
|
- [Marco Lizza](https://github.com/MarcoLizza) for improving logging system and multiple issues
|
||||||
|
- [Anata](https://github.com/anatagawa) for creating amazing examples and contributing with them
|
||||||
|
- [Narice](https://github.com/narice) made easings.h includable as standalone header
|
||||||
|
- [Eric J.](https://github.com/ProfJski) for shaders_eratosthenes example contribution
|
||||||
|
- [PompPenguin](https://github.com/PompPenguin) for reviewing 3rd person camera
|
||||||
|
- [Mohamed Shazan](https://github.com/msmshazan) for adding support for ANGLE graphics backend
|
||||||
|
|
||||||
Please, if I forget someone in this list, excuse me and send a PR!
|
Please, if I forget someone in this list, excuse me and send a PR!
|
||||||
|
|
|
||||||
39
HELPME.md
|
|
@ -1,39 +0,0 @@
|
||||||
help me!
|
|
||||||
--------
|
|
||||||
|
|
||||||
I’m working hard on raylib but my resources are quite limited. If you enjoy raylib and want to help / contribute in some way,
|
|
||||||
please, [let me know][raysan5].
|
|
||||||
|
|
||||||
The following help is highly appreciated:
|
|
||||||
|
|
||||||
- C programming - Can you write / review / test / improve the code?
|
|
||||||
- Documentation / Tutorials / Example writters - Can you write some tutorial / example?
|
|
||||||
- Web Development - Can you help with the web? SEO, style, code writting: https://github.com/raysan5/raylib.com
|
|
||||||
- Porting to Linux, OSX, RaspberryPi, consoles... - Can you compile and test raylib on another systems?
|
|
||||||
- Testers of current features and multiple systems - Can you find some bug on raylib?
|
|
||||||
|
|
||||||
If you can not help on any of the above points but you still want to contribute in some way... please, consider helping
|
|
||||||
with a small [donation](http://www.raylib.com/helpme.html) or contributing with [raylib patreon](https://www.patreon.com/raylib). It will really motivate to continue improving this project...
|
|
||||||
|
|
||||||
raylib philosophy
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* raylib is a tool to enjoy videogames programming, every single function in raylib should be a tutorial on itself.
|
|
||||||
* raylib is SIMPLE and EASY-TO-USE, I tried to keep it compact with a small set of functions, if a function is too complex or has not a clear usefulness, better not to include it.
|
|
||||||
* raylib is open source and free; educators and institutions can use this tool to TEACH videogames programming completely by free.
|
|
||||||
* raylib is collaborative; contribution of tutorials / code-examples / bugs-solving / code-comments are highly appreciated.
|
|
||||||
* raylib's license (and its external libs respective licenses) allow using it for commercial products.
|
|
||||||
|
|
||||||
contact
|
|
||||||
-------
|
|
||||||
|
|
||||||
* Webpage: [http://www.raylib.com](http://www.raylib.com)
|
|
||||||
* Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5)
|
|
||||||
* 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/raylib](https://www.patreon.com/raylib)
|
|
||||||
* Discord: [https://discord.gg/raylib](https://discord.gg/VkzNHUE)
|
|
||||||
* YouTube: [https://www.youtube.com/channel/raylib](https://www.youtube.com/channel/UC8WIBkhYb5sBNqXO1mZ7WSQ)
|
|
||||||
|
|
||||||
[raysan5]: mailto:ray@raylib.com "Ramon Santamaria - Ray San"
|
|
||||||
115
HISTORY.md
|
|
@ -3,24 +3,15 @@
|
||||||
history
|
history
|
||||||
-------
|
-------
|
||||||
|
|
||||||
I've developed videogames for some years and 4 years ago I started teaching videogames development
|
I've developed videogames since 2006 and in 2012 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 videogames programming, I found WinBGI; it was great and it worked very well with students, in just a couple of weeks that people that had never written a single line of code were able to program (and understand) a simple PONG and some of them even a BREAKOUT!
|
||||||
videogames programming, I found WinBGI; it was great and it worked very well with students, in just a
|
|
||||||
couple of weeks that people that had never written a single line of code were able to program (and understand)
|
|
||||||
a simple PONG and some of them even a BREAKOUT!
|
|
||||||
|
|
||||||
But WinBGI was not the clearer and most organized lib. There were a lot of things I found useless and
|
But WinBGI was not the clearer and most organized lib. There were a lot of things I found confusing and some function names were not clear enough for most of the students; not to mention points like no transparencies support or no hardware acceleration.
|
||||||
confusing and some function names were not clear enough for most of the students; not to mention points
|
|
||||||
like no transparencies support or no hardware acceleration.
|
|
||||||
|
|
||||||
So, I decided to create my own lib, hardware accelerated, clear function names, quite organized, well structured,
|
So, I decided to create my own library, hardware accelerated, clear function names, quite organized, well structured, plain C coding and, the most important, primarily intended to learn videogames programming.
|
||||||
plain C coding and, the most important, primarily intended to LEARN videogames programming.
|
|
||||||
|
|
||||||
I've coded quite a lot in C# and XNA and I really love it (in fact, my students learn C# after C),
|
Most of my videogames coding experience was in C# and XNA and I really love it (in fact, my students learn C# after C), 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.
|
||||||
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 started as a weekend project and after three months of hard work, raylib 1.0 was published on November 2013.
|
raylib started as a weekend project and after three months of hard work, raylib 1.0 was published on November 2013.
|
||||||
|
|
||||||
|
|
@ -29,32 +20,24 @@ Enjoy it.
|
||||||
notes on raylib 1.1
|
notes on raylib 1.1
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
On April 2014, after 6 month of first raylib release, raylib 1.1 has been released. This new version presents a
|
On April 2014, after 6 month of first raylib release, raylib 1.1 has been released. This new version presents a complete internal redesign of the library to support OpenGL 1.1, OpenGL 3.3+ and OpenGL ES 2.0.
|
||||||
complete internal redesign of the library to support OpenGL 1.1, OpenGL 3.3+ and OpenGL ES 2.0.
|
|
||||||
|
|
||||||
A new module named [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) has been added to the library. This new module translates raylib-OpenGL-style
|
A new module named [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) has been added to the library. This new module translates raylib-OpenGL-style immediate mode functions (i.e. rlVertex3f(), rlBegin(), ...) to different versions of OpenGL (1.1, 3.3+, ES2), selectable by one define.
|
||||||
immediate mode functions (i.e. rlVertex3f(), rlBegin(), ...) to different versions of OpenGL (1.1, 3.3+, ES2), selectable by one define.
|
|
||||||
|
|
||||||
[rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) also comes with a second new module named [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h), which includes
|
[rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) also comes with a second new module named [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h), which includes a bunch of useful functions for 3d-math with vectors, matrices and quaternions.
|
||||||
a bunch of useful functions for 3d-math with vectors, matrices and quaternions.
|
|
||||||
|
|
||||||
Some other big changes of this new version have been the support for OGG files loading and stream playing, and the
|
Some other big changes of this new version have been the support for OGG files loading and stream playing, and the support of DDS texture files (compressed and uncompressed) along with mipmaps support.
|
||||||
support of DDS texture files (compressed and uncompressed) along with mipmaps support.
|
|
||||||
|
|
||||||
Lots of code changes and lot of testing have concluded in this amazing new raylib 1.1.
|
Lots of code changes and lot of testing have concluded in this amazing new raylib 1.1.
|
||||||
|
|
||||||
notes on raylib 1.2
|
notes on raylib 1.2
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
On September 2014, after 5 month of raylib 1.1 release, it comes raylib 1.2. Again, this version presents a
|
On September 2014, after 5 month of raylib 1.1 release, it comes raylib 1.2. Again, this version presents a complete internal redesign of [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module to support two new platforms: [Android](http://www.android.com/) and [Raspberry Pi](http://www.raspberrypi.org/).
|
||||||
complete internal redesign of [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module to support two new platforms: [Android](http://www.android.com/) and [Raspberry Pi](http://www.raspberrypi.org/).
|
|
||||||
|
|
||||||
It's been some month of really hard work to accomodate raylib to those new platforms while keeping it easy for the user.
|
It's been some month of really hard work to accomodate raylib to those new platforms while keeping it easy for the users. On Android, raylib manages internally the activity cicle, as well as the inputs; on Raspberry Pi, a complete raw input system has been written from scratch.
|
||||||
On Android, raylib manages internally the activity cicle, as well as the inputs; on Raspberry Pi, a complete raw input
|
|
||||||
system has been written from scratch.
|
|
||||||
|
|
||||||
A new display initialization system has been created to support multiple resolutions, adding black bars if required;
|
A new display initialization system has been created to support multiple resolutions, adding black bars if required; user only defines desired screen size and it gets properly displayed.
|
||||||
user only defines desired screen size and it gets properly displayed.
|
|
||||||
|
|
||||||
Now raylib can easily deploy games to Android devices and Raspberry Pi (console mode).
|
Now raylib can easily deploy games to Android devices and Raspberry Pi (console mode).
|
||||||
|
|
||||||
|
|
@ -65,21 +48,17 @@ In December 2014, new raylib 1.2.2 was published with support to compile directl
|
||||||
notes on raylib 1.3
|
notes on raylib 1.3
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
On September 2015, after 1 year of raylib 1.2 release, arrives raylib 1.3. This version adds shaders functionality,
|
On September 2015, after 1 year of raylib 1.2 release, arrives raylib 1.3. This version adds shaders functionality, improves tremendously textures module and also provides some new modules (camera system, gestures system, immediate-mode gui).
|
||||||
improves tremendously textures module and also provides some new modules (camera system, gestures system, IMGUI).
|
|
||||||
|
|
||||||
Shaders support is the biggest addition to raylib 1.3, with support for easy shaders loading and use. Loaded shaders can be
|
Shaders support is the biggest addition to raylib 1.3, with support for easy shaders loading and use. Loaded shaders can be attached to 3d models or used as fullscreen postrocessing effects. A bunch of postprocessing shaders are also included in this release, check raylib/shaders folder.
|
||||||
attached to 3d models or used as fullscreen postrocessing effects. A bunch of postprocessing shaders are also included
|
|
||||||
in this release, check raylib/shaders folder.
|
|
||||||
|
|
||||||
Textures module has grown to support most of the internal texture formats available in OpenGL (RGB565, RGB888, RGBA5551, RGBA4444, etc.), including compressed texture formats (DXT, ETC1, ETC2, ASTC, PVRT); raylib 1.3 can load .dds, .pkm, .ktx, .astc and .pvr files.
|
Textures module has grown to support most of the internal texture formats available in OpenGL (RGB565, RGB888, RGBA5551, RGBA4444, etc.), including compressed texture formats (DXT, ETC1, ETC2, ASTC, PVRT); raylib 1.3 can load .dds, .pkm, .ktx, .astc and .pvr files.
|
||||||
A brand new [camera](https://github.com/raysan5/raylib/blob/master/src/camera.c) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person).
|
|
||||||
Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_first_person.c).
|
A brand new [camera](https://github.com/raysan5/raylib/blob/master/src/camera.c) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person). Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_first_person.c).
|
||||||
|
|
||||||
New [gestures](https://github.com/raysan5/raylib/blob/master/src/gestures.h) module simplifies gestures detection on Android and HTML5 programs.
|
New [gestures](https://github.com/raysan5/raylib/blob/master/src/gestures.h) module simplifies gestures detection on Android and HTML5 programs.
|
||||||
|
|
||||||
[raygui](https://github.com/raysan5/raylib/blob/master/src/raygui.h), the new IMGUI (Immediate Mode GUI) module offers a set of functions to create simple user interfaces,
|
[raygui](https://github.com/raysan5/raylib/blob/master/src/raygui.h), the new immediate-mode GUI module offers a set of functions to create simple user interfaces, primary intended for tools development. It's still in experimental state but already fully functional.
|
||||||
primary intended for tools development. It's still in experimental state but already fully functional.
|
|
||||||
|
|
||||||
Most of the examples have been completely rewritten and +10 new examples have been added to show the new raylib features.
|
Most of the examples have been completely rewritten and +10 new examples have been added to show the new raylib features.
|
||||||
|
|
||||||
|
|
@ -88,29 +67,22 @@ Lots of code changes and lot of testing have concluded in this amazing new rayli
|
||||||
notes on raylib 1.4
|
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,
|
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.
|
||||||
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/master/src/raylib.h#L673) have been added to crop, resize, colorize, flip, dither and even draw image-to-image or text-to-image.
|
First big addition is a set of [Image manipulation functions](https://github.com/raysan5/raylib/blob/master/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.
|
||||||
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).
|
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.
|
||||||
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/master/src/physac.h) physics module for basic 2D physics support. Still in development but already functional.
|
New [physac](https://github.com/raysan5/raylib/blob/master/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.
|
||||||
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/master/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.
|
[raymath](https://github.com/raysan5/raylib/blob/master/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/master/src/gestures.c) module has redesigned and simplified, now it can process touch events from any source, including mouse.
|
[gestures](https://github.com/raysan5/raylib/blob/master/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.
|
||||||
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`).
|
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).
|
||||||
Gamepad support has also been added (experimental).
|
|
||||||
|
|
||||||
Other important improvements are the functional raycast system for 3D picking, including some ray collision-detection functions,
|
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).
|
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/master/src/easings.h) module has also been added for values animation.
|
||||||
A simple [easings](https://github.com/raysan5/raylib/blob/master/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
|
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.
|
how to create some classic games like Arkanoid, Asteroids, Missile Commander, Snake or Tetris.
|
||||||
|
|
@ -180,7 +152,7 @@ Improved library consistency and organization in general. Functions and paramete
|
||||||
|
|
||||||
Some other features: Gamepad support on HTML5, RPI touch screen support, 32bit audio support, frames timing improvements, public log system, rres file format support, automatic GIF recording...
|
Some other features: Gamepad support on HTML5, RPI touch screen support, 32bit audio support, frames timing improvements, public log system, rres file format support, automatic GIF recording...
|
||||||
|
|
||||||
And here it is another version of **raylib, a simple and easy-to-use library to learn videogames programming**. Enjoy it.
|
And here it is another version of **raylib, a simple and easy-to-use library to enjoy videogames programming**. Enjoy it.
|
||||||
|
|
||||||
notes on raylib 1.8
|
notes on raylib 1.8
|
||||||
-------------------
|
-------------------
|
||||||
|
|
@ -195,9 +167,9 @@ PBR Materials support, a completely redesigned shaders and material system allow
|
||||||
|
|
||||||
Custom Android APK build pipeline with [simple Makefile](https://github.com/raysan5/raylib/blob/master/templates/simple_game/Makefile). Actually, full code building mechanism based on plain Makefile has been completely reviewed and Android building has been added for sources and also for examples and templates building into final APK package. This way, raylib Android building has been greatly simplified and integrated seamlessly into standard build scripts.
|
Custom Android APK build pipeline with [simple Makefile](https://github.com/raysan5/raylib/blob/master/templates/simple_game/Makefile). Actually, full code building mechanism based on plain Makefile has been completely reviewed and Android building has been added for sources and also for examples and templates building into final APK package. This way, raylib Android building has been greatly simplified and integrated seamlessly into standard build scripts.
|
||||||
|
|
||||||
[rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) module has been completely reviewed and most of the functions renamed for consistency. This way, standalone usage of rlgl is promoted, with a [complete example provided](https://github.com/raysan5/raylib/blob/master/examples/others/rlgl_standalone.c). rlgl offers a pseudo-OpenGL 1.1 immediate-mode programming-style layer, with backends to multiple OpenGL versions.
|
[rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) module has been completely reviewed and most of the functions renamed for consistency. This way, standalone usage of rlgl is promoted, with a [complete example provided](https://github.com/raysan5/raylib/blob/master/examples/others/rlgl_standalone.c). rlgl offers a pseudo-OpenGL 1.1 immediate-mode programming-style layer, with backends to multiple OpenGL versions.
|
||||||
|
|
||||||
[raymath](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) library has been also reviewed to align with other advance math libraries like [GLM](https://github.com/g-truc/glm). Matrix math has been improved and simplified, some new Quaternion functions have been added and Vector3 functions have been renamed all around the library for consistency with new Vector2 functionality.
|
[raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h) library has been also reviewed to align with other advance math libraries like [GLM](https://github.com/g-truc/glm). Matrix math has been improved and simplified, some new Quaternion functions have been added and Vector3 functions have been renamed all around the library for consistency with new Vector2 functionality.
|
||||||
|
|
||||||
Additionally, as always, examples and templates have been reviewed to work with new version (some new examples have been added), all external libraries have been updated to latest stable version and latest Notepad++ and MinGW have been configured to work with new raylib. For a full list of changes, just check [CHANGELOG](CHANGELOG).
|
Additionally, as always, examples and templates have been reviewed to work with new version (some new examples have been added), all external libraries have been updated to latest stable version and latest Notepad++ and MinGW have been configured to work with new raylib. For a full list of changes, just check [CHANGELOG](CHANGELOG).
|
||||||
|
|
||||||
|
|
@ -210,11 +182,11 @@ It's been 9 month since last raylib version was published, a lots of things have
|
||||||
|
|
||||||
In **raylib 2.0** the full API has been carefully reviewed for better consistency, some new functionality has been added and the overall raylib experience has been greatly improved... The key features of new version are:
|
In **raylib 2.0** the full API has been carefully reviewed for better consistency, some new functionality has been added and the overall raylib experience has been greatly improved... The key features of new version are:
|
||||||
|
|
||||||
**Complete removal of external dependencies.** Finally, raylib does not require external libraries to be installed and linked along with raylib, all required libraries are contained and compiled within raylib. Obviously some external libraries are related but only the strictly platform-dependant required ones, that comes installed with the OS. So, raylib becomes a self-contained platform-independent games development library.
|
**Complete removal of external dependencies.** Finally, raylib does not require external libraries to be installed and linked along with raylib, all required libraries are contained and compiled within raylib. Obviously some external libraries are required but only the strictly platform-dependant ones, the ones that come installed with the OS. So, raylib becomes a self-contained platform-independent games development library.
|
||||||
|
|
||||||
**Full redesign of audio module to use the amazing mini_al audio library**, along with external dependencies removal, OpenAL library has been replaced by mini_al, this brand new library offers automatic dynamic linking with default OS audio systems. Undoubtly, the perfect low-level companion for raylib audio module!
|
**Full redesign of audio module to use the amazing miniaudio library**, along with external dependencies removal, OpenAL library has been replaced by [miniaudio](https://github.com/dr-soft/miniaudio), this brand new library offers automatic dynamic linking with default OS audio systems. Undoubtly, the perfect low-level companion for raylib audio module!
|
||||||
|
|
||||||
**Support for continuous integration building*** through AppVeyor and Travis CI. As a consequence, raylib GitHub develop branch has been completely removed simplyfing the code-base to a single master branch, always stable. Every time a new commit is deployed, library is compiled for **up-to 12 different configurations**, including multiple platforms, 32bit/64bit and multiple compiler options! All those binaries are automatically attached to any new release!
|
**Support for continuous integration building*** through AppVeyor and Travis CI. Consequently, raylib GitHub develop branch has been removed, simplyfing the code-base to a single master branch, always stable. Every time a new commit is deployed, library is compiled for **up-to 12 different configurations**, including multiple platforms, 32bit/64bit and multiple compiler options! All those binaries are automatically attached to any new release!
|
||||||
|
|
||||||
**More platforms supported and tested**, including BSD family (FreeBSD, openBSD, NetBSD, DragonFly) and Linux-based family platforms (openSUSE, Debian, Ubuntu, Arch, NixOS...). raylib has already been added to some package managers! Oh, and last but not less important, **Android 64bit** is already supported by raylib!
|
**More platforms supported and tested**, including BSD family (FreeBSD, openBSD, NetBSD, DragonFly) and Linux-based family platforms (openSUSE, Debian, Ubuntu, Arch, NixOS...). raylib has already been added to some package managers! Oh, and last but not less important, **Android 64bit** is already supported by raylib!
|
||||||
|
|
||||||
|
|
@ -224,9 +196,32 @@ Refactored all raylib configuration #defines into a **centralized `config.h` hea
|
||||||
|
|
||||||
A part of that, lots of new features, like a brand **new font rendering and packaging system** for TTF fonts with **SDF support** (thanks to the amazing STB headers), new functions for **CPU image data manipulation**, new orthographic 3d camera mode, a complete review of `raymath.h` single-file header-only library for better consistency and performance, new examples and way, [way more](https://github.com/raysan5/raylib/blob/master/CHANGELOG).
|
A part of that, lots of new features, like a brand **new font rendering and packaging system** for TTF fonts with **SDF support** (thanks to the amazing STB headers), new functions for **CPU image data manipulation**, new orthographic 3d camera mode, a complete review of `raymath.h` single-file header-only library for better consistency and performance, new examples and way, [way more](https://github.com/raysan5/raylib/blob/master/CHANGELOG).
|
||||||
|
|
||||||
Probably by now, **raylib 2.0 is the simplest and easiest-to-use library to learn (and understand) videogames programming**... but, undoubtly its development has exceeded any initial objective; raylib has become a simple and easy-to-use trully multiplatform portable standalone media library with thousands of possibilities... and that's just the beginning!
|
Probably by now, **raylib 2.0 is the simplest and easiest-to-use library to enjoy (and learn) videogames programming**... but, undoubtly its development has exceeded any initial objective; raylib has become a simple and easy-to-use trully multiplatform portable standalone media library with thousands of possibilities... and that's just the beginning!
|
||||||
|
|
||||||
notes on raylib 2.5
|
notes on raylib 2.5
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
SOON.
|
After almost one years since latest raylib installment, here it is **raylib 2.5**. A lot of work has been put on this new version and consequently I decided to bump versioning several digits. The complete list of changes and additions is humungous, details can be found in the [CHANGELOG](CHANGELOG), and here it is a short recap with the highlight improvements.
|
||||||
|
|
||||||
|
New **window management and filesystem functions** to query monitor information, deal with clipboard, check directory files info and even launch a URL with default system web browser. Experimental **High-DPI monitor support** has also been added through a compile flag.
|
||||||
|
|
||||||
|
**Redesigned Gamepad mechanism**, now generic for all platforms and gamepads, no more specific gamepad configurations.
|
||||||
|
**Redesigned UWP input system**, now raylib supports UWP seamlessly, previous implementation required a custom input system implemented in user code.
|
||||||
|
|
||||||
|
`rlgl` module has been redesigned to **support a unique buffer for shapes drawing batching**, including LINES, TRIANGLES, QUADS in the same indexed buffer, also added support for multi-buffering if required. Additionally, `rlPushMatrix()`/`rlPopMatrix()` functionality has been reviewed to behave exactly like OpenGL 1.1, `models_rlgl_solar_system` example has been added to illustrate this behaviour.
|
||||||
|
|
||||||
|
**VR simulator** has been reviewed to **allow custom configuration of Head-Mounted-Device parameters and distortion shader**, `core_vr_simulator` has been properly adapted to showcase this new functionality, now the VR simulator is a generic configurable stereo rendering system that allows any VR device simulation with just a few lines of code or even dynamic tweaking of HMD parameters.
|
||||||
|
|
||||||
|
Support for **Unicode text drawing**; now raylib processes UTF8 strings on drawing, supporting Unicode codepoints, allowing rendering mostly any existent language (as long as the font with the glyphs is provided). An amazing example showing this feature has also been added: `text_unicode`.
|
||||||
|
|
||||||
|
Brand **new text management API**, with the addition of multiple functions to deal with string data, including functionality like replace, insert, join, split, append, to uppercase, to lower... Note that most of those functions are intended for text management on rendering, using pre-loaded internal buffers, avoiding new memory allocation that user should free manually.
|
||||||
|
|
||||||
|
Multiple **new shapes and textures drawing functions** to support rings (`DrawRing()`, `DrawRingLines()`), circle sectors (`DrawCircleSector()`, `DrawCircleSectorLines()`), rounded rectangles (`DrawRectangleRounded()`, `DrawRectangleRoundedLines()`) and also n-patch textures (`DrawTextureNPatch()`), detailed examples have been added to illustrate all this new functionality.
|
||||||
|
|
||||||
|
Experimental **cubemap support**, to automatically load multiple cubemap layouts (`LoadTextureCubemap()`). It required some internal `rlgl` redesign to allow cubemap textures.
|
||||||
|
|
||||||
|
**Skeletal animation support for 3d models**, this addition implied a redesign of `Model` data structure to accomodate multiple mesh/multiple materials support and bones information. Multiple models functions have been reviewed and added on this process, also **glTF models loading support** has been added.
|
||||||
|
|
||||||
|
This is a just a brief list with some of the changes of the new **raylib 2.5** but there is way more, about **70 new functions** have been added and several subsystems have been redesigned. More than **30 new examples** have been created to show the new functionalities and better illustrate already available ones.
|
||||||
|
|
||||||
|
It has been a long year of hard work to make raylib a solid technology to develop new products over it.
|
||||||
|
|
|
||||||
27
LICENSE.md
|
|
@ -27,23 +27,26 @@ applications, and to alter it and redistribute it freely, subject to the followi
|
||||||
fonts
|
fonts
|
||||||
------
|
------
|
||||||
|
|
||||||
The following fonts [provided with raylib](https://github.com/raysan5/raylib/tree/master/examples/text/resources/fonts) are free to use (freeware) and have been designed by the following people:
|
* [Alpha Beta](https://www.dafont.com/es/alpha-beta.font) - Brian Kent (AEnigma)
|
||||||
|
* [Setback](https://www.dafont.com/es/setback.font) - Brian Kent (AEnigma)
|
||||||
* Alpha Beta - Brian Kent (AEnigma)
|
* [Jupiter Crash](https://www.dafont.com/es/jupiter-crash.font) - Brian Kent (AEnigma)
|
||||||
* Setback - Brian Kent (AEnigma)
|
* [Alagard](https://www.dafont.com/es/alagard.font) - Hewett Tsoi
|
||||||
* Jupiter Crash - Brian Kent (AEnigma)
|
* [Romulus](https://www.dafont.com/es/romulus.font) - Hewett Tsoi
|
||||||
* Alagard - Hewett Tsoi
|
* [Mecha](https://www.dafont.com/es/mecha-cf.font) - Captain Falcon
|
||||||
* Romulus - Hewett Tsoi
|
* [PixelPlay](https://www.dafont.com/es/pixelplay.font) - Aleksander Shevchuk
|
||||||
* Mecha - Captain Falcon
|
* [PixAntiqua](https://www.dafont.com/es/pixantiqua.font) - Gerhard Großmann
|
||||||
* PixelPlay - Aleksander Shevchuk
|
* [Kaiserzeit Gotisch](https://www.dafont.com/es/kaiserzeit-gotisch.font) - Dieter Steffmann
|
||||||
* PixAntiqua - Gerhard Großmann
|
* [Noto CJK](https://www.google.com/get/noto/help/cjk/) - Google Fonts
|
||||||
|
* [Anonymous Pro](https://fonts.google.com/specimen/Anonymous+Pro) - Mark Simonson
|
||||||
|
|
||||||
2d art
|
2d art
|
||||||
------
|
------
|
||||||
|
|
||||||
[scarfy spritesheet](https://github.com/raysan5/raylib/blob/master/examples/textures/resources/scarfy.png) and [fudesumi image](https://github.com/raysan5/raylib/blob/master/examples/textures/resources/fudesumi.png) have been created by [Eiden Marsal](https://www.artstation.com/artist/marshall_z) and are licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
|
* [Scarfy](https://github.com/raysan5/raylib/blob/master/examples/textures/resources/scarfy.png) - [Eiden Marsal](https://www.artstation.com/artist/marshall_z), licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
|
||||||
|
* [Fudesumi](https://github.com/raysan5/raylib/blob/master/examples/textures/resources/fudesumi.png) - [Eiden Marsal](https://www.artstation.com/artist/marshall_z), licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
|
||||||
|
* [Cyberpunk Street Environment](https://ansimuz.itch.io/cyberpunk-street-environment) - Luis Zuno ([@ansimuz](https://twitter.com/ansimuz)), licensed as [CC-BY-3.0](http://creativecommons.org/licenses/by/3.0/)
|
||||||
|
|
||||||
3d models
|
3d models
|
||||||
---------
|
---------
|
||||||
|
|
||||||
[medieval city 3d models and textures](https://github.com/raysan5/raylib/tree/master/examples/models/resources/medieval) have been created by Alberto Cano and are licensed as [Creative Commons Attribution-NonCommercial 4.0](https://creativecommons.org/licenses/by-nc/4.0/legalcode)
|
* [Medieval City](https://github.com/raysan5/raylib/tree/master/examples/models/resources/models) - Alberto Cano, licensed as [Creative Commons Attribution-NonCommercial 4.0](https://creativecommons.org/licenses/by-nc/4.0/legalcode)
|
||||||
|
|
|
||||||
23
README.md
|
|
@ -4,12 +4,11 @@
|
||||||
|
|
||||||
raylib is highly inspired by Borland BGI graphics lib and by XNA framework and it's specially well suited for prototyping, tooling, graphical applications, embedded systems and education.
|
raylib is highly inspired by Borland BGI graphics lib and by XNA framework and it's specially well suited for prototyping, tooling, graphical applications, embedded systems and education.
|
||||||
|
|
||||||
*NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming;
|
*NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no auto-debugging... just coding in the most pure spartan-programmers way.*
|
||||||
no fancy interface, no visual helpers, no auto-debugging... just coding in the most
|
|
||||||
pure spartan-programmers way.*
|
|
||||||
|
|
||||||
Ready to learn? Jump to [code examples!](http://www.raylib.com/examples.html)
|
Ready to learn? Jump to [code examples!](http://www.raylib.com/examples.html)
|
||||||
|
|
||||||
|
|
||||||
[](https://travis-ci.org/raysan5/raylib)
|
[](https://travis-ci.org/raysan5/raylib)
|
||||||
[](https://ci.appveyor.com/project/raysan5/raylib)
|
[](https://ci.appveyor.com/project/raysan5/raylib)
|
||||||
[](https://discord.gg/VkzNHUE)
|
[](https://discord.gg/VkzNHUE)
|
||||||
|
|
@ -23,21 +22,24 @@ features
|
||||||
- Written in plain C code (C99) in PascalCase/camelCase notation
|
- Written in plain C code (C99) in PascalCase/camelCase notation
|
||||||
- Hardware accelerated with OpenGL (**1.1, 2.1, 3.3 or ES 2.0**)
|
- Hardware accelerated with OpenGL (**1.1, 2.1, 3.3 or ES 2.0**)
|
||||||
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h)
|
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h)
|
||||||
- Multiple Fonts formats supported (XNA fonts, AngelCode fonts, TTF)
|
- Multiple **Fonts** formats supported (XNA fonts, AngelCode fonts, TTF)
|
||||||
- Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
|
- Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
|
||||||
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
|
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
|
||||||
- Flexible Materials system, supporting classic maps and **PBR maps**
|
- Flexible Materials system, supporting classic maps and **PBR maps**
|
||||||
- Custom shaders, including model and postprocessing shaders.
|
- **Animated 3D models** supported (skeletal bones animation)
|
||||||
|
- Shaders support, including model and postprocessing shaders.
|
||||||
- **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
|
- **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
|
||||||
- Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
|
- Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
|
||||||
- **VR stereo rendering** support with configurable HMD device parameters
|
- **VR stereo rendering** support with configurable HMD device parameters
|
||||||
- Bindings to [multiple code languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
- Huge examples collection with [+95 code examples](https://www.raylib.com/examples.html)!
|
||||||
|
- Bindings to [+25 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
||||||
|
|
||||||
raylib uses on its [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module the outstanding [GLFW3](http://www.glfw.org/) library, embedded inside raylib in the form of [rglfw](https://github.com/raysan5/raylib/blob/master/src/rglfw.c) module, to avoid external dependencies.
|
|
||||||
|
|
||||||
raylib uses on its [raudio](https://github.com/raysan5/raylib/blob/master/src/raudio.c) module, the amazing [miniaudio](https://github.com/dr-soft/miniaudio) audio library to support multiple platforms and multiple audio backends.
|
raylib uses on its [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module the outstanding [GLFW3](http://www.glfw.org/) library, embedded in the form of [rglfw](https://github.com/raysan5/raylib/blob/master/src/rglfw.c) module, to avoid external dependencies.
|
||||||
|
|
||||||
raylib uses internally multiple single-file header-only libraries to support multiple fileformats loading and saving, all those libraries are embedded with raylib and available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory. Check [raylib Wiki](https://github.com/raysan5/raylib/wiki/raylib-dependencies) for a detailed list.
|
raylib uses on its [raudio](https://github.com/raysan5/raylib/blob/master/src/raudio.c) module, the amazing [miniaudio](https://github.com/dr-soft/miniaudio) library to support multiple platforms and multiple audio backends.
|
||||||
|
|
||||||
|
raylib uses internally multiple single-file header-only libraries to support different fileformats loading and saving, all those libraries are embedded with raylib and available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory. Check [raylib Wiki](https://github.com/raysan5/raylib/wiki/raylib-dependencies) for a detailed list.
|
||||||
|
|
||||||
*On Android platform, `native_app_glue module` module (provided by Android NDK) and native Android libraries are used to manage window/context, inputs and activity life cycle.*
|
*On Android platform, `native_app_glue module` module (provided by Android NDK) and native Android libraries are used to manage window/context, inputs and activity life cycle.*
|
||||||
|
|
||||||
|
|
@ -63,9 +65,8 @@ contact
|
||||||
* Webpage: [http://www.raylib.com](http://www.raylib.com)
|
* Webpage: [http://www.raylib.com](http://www.raylib.com)
|
||||||
* Discord: [https://discord.gg/raylib](https://discord.gg/VkzNHUE)
|
* Discord: [https://discord.gg/raylib](https://discord.gg/VkzNHUE)
|
||||||
* 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)
|
|
||||||
* Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
|
||||||
* Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5)
|
* Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5)
|
||||||
|
* Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
||||||
* Patreon: [https://www.patreon.com/raylib](https://www.patreon.com/raylib)
|
* Patreon: [https://www.patreon.com/raylib](https://www.patreon.com/raylib)
|
||||||
* YouTube: [https://www.youtube.com/channel/raylib](https://www.youtube.com/channel/UC8WIBkhYb5sBNqXO1mZ7WSQ)
|
* YouTube: [https://www.youtube.com/channel/raylib](https://www.youtube.com/channel/UC8WIBkhYb5sBNqXO1mZ7WSQ)
|
||||||
|
|
||||||
|
|
|
||||||
25
ROADMAP.md
|
|
@ -1,16 +1,25 @@
|
||||||
roadmap
|
roadmap
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Current version of raylib is complete and functional but there is still a lot of room for improvement.
|
Here it is a wish-list with features and ideas to improve the library. Note that features listed here are quite high-level and could be long term additions for the library. Current version of raylib is complete and functional but there is a lot of room for improvement.
|
||||||
Here it is a wish-list with features and ideas to improve the library.
|
|
||||||
|
|
||||||
Note that [raylib source code](https://github.com/raysan5/raylib/tree/master/src) has some *TODO* marks around code with pending things to review and improve. Check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
|
[raylib source code](https://github.com/raysan5/raylib/tree/master/src) has some *TODO* marks around code with pending things to review and improve.
|
||||||
|
Also, check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
|
||||||
|
|
||||||
**raylib 2.x**
|
**raylib 2.x**
|
||||||
- [ ] rnet: Network module
|
- [ ] rnet: raylib network module
|
||||||
- [ ] Support Vulkan API (GRAPHICS_API_VULKAN)
|
- [ ] rres: raylib resource packer
|
||||||
|
- [ ] rlvk: raylib Vulkan API support (GRAPHICS_API_VULKAN)
|
||||||
- [ ] Basic CPU/GPU stats sytem (memory, draws, time...)
|
- [ ] Basic CPU/GPU stats sytem (memory, draws, time...)
|
||||||
- [x] Support Animated models (2.5)
|
|
||||||
|
**raylib 2.5**
|
||||||
|
- [x] Support Animated models
|
||||||
|
- [x] Support glTF models file format
|
||||||
|
- [x] Unicode support on text drawing
|
||||||
|
|
||||||
|
**raylib 2.0**
|
||||||
|
- [x] Removed external dependencies (GLFW3 and OpenAL)
|
||||||
|
- [x] Support TCC compiler (32bit and 64bit)
|
||||||
|
|
||||||
**raylib 1.8**
|
**raylib 1.8**
|
||||||
- [x] Improved Materials system with PBR support
|
- [x] Improved Materials system with PBR support
|
||||||
|
|
@ -47,7 +56,3 @@ Note that [raylib source code](https://github.com/raysan5/raylib/tree/master/src
|
||||||
- [x] Redesign gestures module to be multiplatform
|
- [x] Redesign gestures module to be multiplatform
|
||||||
- [x] Module raymath as header-only and functions inline
|
- [x] Module raymath as header-only and functions inline
|
||||||
- [x] Add Easings module (easings.h)
|
- [x] Add Easings module (easings.h)
|
||||||
|
|
||||||
Any feature missing? Do you have a request? [Let me know!][raysan5]
|
|
||||||
|
|
||||||
[raysan5]: mailto:ray@raylib.com "Ramon Santamaria - Ray San"
|
|
||||||
|
|
|
||||||
13
SPONSORS.md
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
The following people has contributed with a generous donation to raylib project.
|
||||||
|
|
||||||
|
## 🥇 Gold Contributors
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
## 🥈 Silver Contributors
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
## 🥉 Bronce Contributors
|
||||||
|
|
||||||
|
...
|
||||||
|
|
@ -12,12 +12,14 @@
|
||||||
# raylib_DEFINITIONS - Compiler switches required for using raylib
|
# raylib_DEFINITIONS - Compiler switches required for using raylib
|
||||||
|
|
||||||
set(XPREFIX PC_RAYLIB)
|
set(XPREFIX PC_RAYLIB)
|
||||||
|
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
pkg_check_modules(${XPREFIX} QUIET raylib)
|
||||||
|
|
||||||
if (raylib_USE_STATIC_LIBS)
|
if (raylib_USE_STATIC_LIBS)
|
||||||
set(XPREFIX ${XPREFIX}_STATIC)
|
set(XPREFIX ${XPREFIX}_STATIC)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(PkgConfig QUIET)
|
|
||||||
pkg_check_modules(${XPREFIX} QUIET raylib)
|
|
||||||
set(raylib_DEFINITIONS ${${XPREFIX}_CFLAGS})
|
set(raylib_DEFINITIONS ${${XPREFIX}_CFLAGS})
|
||||||
|
|
||||||
find_path(raylib_INCLUDE_DIR
|
find_path(raylib_INCLUDE_DIR
|
||||||
|
|
@ -25,18 +27,17 @@ find_path(raylib_INCLUDE_DIR
|
||||||
HINTS ${${XPREFIX}_INCLUDE_DIRS}
|
HINTS ${${XPREFIX}_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(RAYLIB_NAMES raylib)
|
||||||
|
|
||||||
if (raylib_USE_STATIC_LIBS)
|
if (raylib_USE_STATIC_LIBS)
|
||||||
find_library(raylib_LIBRARY
|
set(RAYLIB_NAMES libraylib.a raylib.lib ${RAYLIB_NAMES})
|
||||||
NAMES raylib_static
|
|
||||||
HINTS ${${XPREFIX}_LIBRARY_DIRS}
|
|
||||||
)
|
|
||||||
else ()
|
|
||||||
find_library(raylib_LIBRARY
|
|
||||||
NAMES raylib
|
|
||||||
HINTS ${${XPREFIX}_LIBRARY_DIRS}
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
find_library(raylib_LIBRARY
|
||||||
|
NAMES ${RAYLIB_NAMES}
|
||||||
|
HINTS ${${XPREFIX}_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
set(raylib_LIBRARIES ${raylib_LIBRARY})
|
set(raylib_LIBRARIES ${raylib_LIBRARY})
|
||||||
set(raylib_LIBRARY_DIRS ${${XPREFIX}_LIBRARY_DIRS})
|
set(raylib_LIBRARY_DIRS ${${XPREFIX}_LIBRARY_DIRS})
|
||||||
set(raylib_LIBRARY_DIR ${raylib_LIBRARY_DIRS})
|
set(raylib_LIBRARY_DIR ${raylib_LIBRARY_DIRS})
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ foreach(example_dir ${example_dirs})
|
||||||
list(APPEND example_resources ${resources})
|
list(APPEND example_resources ${resources})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if (NOT CMAKE_SYSTEM STRLESS "Darwin-18.0.0")
|
if (APPLE AND NOT CMAKE_SYSTEM STRLESS "Darwin-18.0.0")
|
||||||
add_definitions(-DGL_SILENCE_DEPRECATION)
|
add_definitions(-DGL_SILENCE_DEPRECATION)
|
||||||
MESSAGE(AUTHOR_WARNING "OpenGL is deprecated starting with macOS 10.14 (Mojave)!")
|
MESSAGE(AUTHOR_WARNING "OpenGL is deprecated starting with macOS 10.14 (Mojave)!")
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -67,6 +67,8 @@ if(${PLATFORM} MATCHES "Android")
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_heightmap.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_heightmap.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_billboard.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_billboard.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_rlgl_solar_system.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_rlgl_solar_system.c)
|
||||||
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_rlgl_full_solar_system.c)
|
||||||
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_solar_system.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_obj_viewer.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_obj_viewer.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_animation.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_animation.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_first_person_maze.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_first_person_maze.c)
|
||||||
|
|
@ -76,15 +78,19 @@ if(${PLATFORM} MATCHES "Android")
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_postprocessing.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_postprocessing.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_raymarching.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_raymarching.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_palette_switch.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_palette_switch.c)
|
||||||
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_basic_lighting.c)
|
||||||
|
|
||||||
elseif(${PLATFORM} MATCHES "Web")
|
elseif(${PLATFORM} MATCHES "Web")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1")
|
||||||
# Since WASM is used, ALLOW_MEMORY_GROWTH has no extra overheads
|
# Since WASM is used, ALLOW_MEMORY_GROWTH has no extra overheads
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1 --no-heap-copy")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1 --no-heap-copy")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/templates/web_shell/shell.html")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/src/shell.html")
|
||||||
|
|
||||||
set(OUTPUT_EXT ".html")
|
set(OUTPUT_EXT ".html")
|
||||||
|
|
||||||
|
# Remove the -rdynamic flag because otherwise emscripten
|
||||||
|
# does not generate HTML+JS+WASM files, only a non-working
|
||||||
|
# and fat HTML
|
||||||
|
string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_C_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(BEFORE SYSTEM others/external/include)
|
include_directories(BEFORE SYSTEM others/external/include)
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
# Define required raylib variables
|
# Define required raylib variables
|
||||||
PROJECT_NAME ?= raylib_examples
|
PROJECT_NAME ?= raylib_examples
|
||||||
RAYLIB_VERSION ?= 2.5.0
|
RAYLIB_VERSION ?= 2.5.0
|
||||||
RAYLIB_API_VERSION ?= 1
|
RAYLIB_API_VERSION ?= 2
|
||||||
RAYLIB_PATH ?= ..
|
RAYLIB_PATH ?= ..
|
||||||
|
|
||||||
# Define default options
|
# Define default options
|
||||||
|
|
@ -52,7 +52,7 @@ RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include
|
||||||
RAYLIB_LIBTYPE ?= STATIC
|
RAYLIB_LIBTYPE ?= STATIC
|
||||||
|
|
||||||
# Build mode for project: DEBUG or RELEASE
|
# Build mode for project: DEBUG or RELEASE
|
||||||
RAYLIB_BUILD_MODE ?= RELEASE
|
BUILD_MODE ?= RELEASE
|
||||||
|
|
||||||
# Use external GLFW library instead of rglfw module
|
# Use external GLFW library instead of rglfw module
|
||||||
# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3
|
# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3
|
||||||
|
|
@ -62,8 +62,6 @@ USE_EXTERNAL_GLFW ?= FALSE
|
||||||
# by default it uses X11 windowing system
|
# by default it uses X11 windowing system
|
||||||
USE_WAYLAND_DISPLAY ?= FALSE
|
USE_WAYLAND_DISPLAY ?= FALSE
|
||||||
|
|
||||||
# NOTE: On PLATFORM_WEB OpenAL Soft backend is used by default (check raylib/src/Makefile)
|
|
||||||
|
|
||||||
# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
|
# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
|
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
|
||||||
|
|
@ -117,9 +115,9 @@ endif
|
||||||
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# Emscripten required variables
|
# Emscripten required variables
|
||||||
EMSDK_PATH = C:/emsdk
|
EMSDK_PATH ?= C:/emsdk
|
||||||
EMSCRIPTEN_VERSION = 1.38.30
|
EMSCRIPTEN_VERSION ?= 1.38.31
|
||||||
CLANG_VERSION = e1.38.30_64bit
|
CLANG_VERSION = e$(EMSCRIPTEN_VERSION)_64bit
|
||||||
PYTHON_VERSION = 2.7.13.1_64bit\python-2.7.13.amd64
|
PYTHON_VERSION = 2.7.13.1_64bit\python-2.7.13.amd64
|
||||||
NODE_VERSION = 8.9.1_64bit
|
NODE_VERSION = 8.9.1_64bit
|
||||||
export PATH = $(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
|
export PATH = $(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
|
||||||
|
|
@ -127,27 +125,8 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define raylib release directory for compiled library.
|
# Define raylib release directory for compiled library.
|
||||||
# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version.
|
# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
|
||||||
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/src
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
|
||||||
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/src
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
|
||||||
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/src
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM_OS),BSD)
|
|
||||||
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/src
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
|
||||||
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/src
|
|
||||||
endif
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
|
||||||
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/src
|
|
||||||
endif
|
|
||||||
|
|
||||||
# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries
|
# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries
|
||||||
# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH
|
# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH
|
||||||
|
|
@ -155,7 +134,7 @@ endif
|
||||||
# without formal installation from ../src/Makefile. It aids portability and is useful if you have
|
# without formal installation from ../src/Makefile. It aids portability and is useful if you have
|
||||||
# multiple versions of raylib, have raylib installed to a non-standard location, or want to
|
# multiple versions of raylib, have raylib installed to a non-standard location, or want to
|
||||||
# bundle libraylib.so with your game. Change it to your liking.
|
# bundle libraylib.so with your game. Change it to your liking.
|
||||||
# Note: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH,
|
# NOTE: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH,
|
||||||
# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH,
|
# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH,
|
||||||
# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH)
|
# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH)
|
||||||
# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute.
|
# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute.
|
||||||
|
|
@ -185,8 +164,9 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
|
|
||||||
# HTML5 emscripten compiler
|
# HTML5 emscripten compiler
|
||||||
|
# WARNING: To compile to HTML5, code must be redesigned
|
||||||
|
# to use emscripten.h and emscripten_set_main_loop()
|
||||||
CC = emcc
|
CC = emcc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
@ -201,14 +181,21 @@ endif
|
||||||
|
|
||||||
# Define compiler flags:
|
# Define compiler flags:
|
||||||
# -O1 defines optimization level
|
# -O1 defines optimization level
|
||||||
# -g enable debugging
|
# -g include debug information on compilation
|
||||||
# -s strip unnecessary data from build
|
# -s strip unnecessary data from build
|
||||||
# -Wall turns on most, but not all, compiler warnings
|
# -Wall turns on most, but not all, compiler warnings
|
||||||
# -std=c99 defines C language mode (standard C from 1999 revision)
|
# -std=c99 defines C language mode (standard C from 1999 revision)
|
||||||
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
||||||
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
|
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
|
||||||
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
|
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
|
||||||
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
|
CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
|
||||||
|
|
||||||
|
ifeq ($(BUILD_MODE),DEBUG)
|
||||||
|
CFLAGS += -g
|
||||||
|
endif
|
||||||
|
ifeq ($(RAYLIB_BUILD_MODE),RELEASE)
|
||||||
|
CFLAGS += -O1 -s
|
||||||
|
endif
|
||||||
|
|
||||||
# Additional flags for compiler (if desired)
|
# Additional flags for compiler (if desired)
|
||||||
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
|
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
|
||||||
|
|
@ -216,13 +203,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||||
# resource file contains windows executable icon and properties
|
# resource file contains windows executable icon and properties
|
||||||
# -Wl,--subsystem,windows hides the console window
|
# -Wl,--subsystem,windows hides the console window
|
||||||
CFLAGS += $(RAYLIB_PATH)/raylib.rc.data -Wl,--subsystem,windows
|
CFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data -Wl,--subsystem,windows
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
|
|
||||||
CFLAGS += -g
|
|
||||||
#CC = clang
|
|
||||||
endif
|
|
||||||
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
||||||
CFLAGS += -D_DEFAULT_SOURCE
|
CFLAGS += -D_DEFAULT_SOURCE
|
||||||
endif
|
endif
|
||||||
|
|
@ -238,34 +221,35 @@ endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# -Os # size optimization
|
# -Os # size optimization
|
||||||
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
||||||
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
|
||||||
# -s USE_GLFW=3 # Use glfw3 library (context/input management)
|
# -s USE_GLFW=3 # Use glfw3 library (context/input management)
|
||||||
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
|
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
|
||||||
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
|
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
|
||||||
# -s USE_PTHREADS=1 # multithreading support
|
# -s USE_PTHREADS=1 # multithreading support
|
||||||
# -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly)
|
# -s WASM=0 # disable Web Assembly, emitted by default
|
||||||
# -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow)
|
# -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow)
|
||||||
# -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter
|
# -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter
|
||||||
# -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data
|
# -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data
|
||||||
|
# -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off)
|
||||||
# --profiling # include information for code profiling
|
# --profiling # include information for code profiling
|
||||||
|
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --preload-file resources # specify a resources folder for data compilation
|
||||||
CFLAGS += -Os -s USE_GLFW=3 -s ASSERTIONS=2 -s WASM=1 -s FORCE_FILESYSTEM=1
|
CFLAGS += -Os -s USE_GLFW=3 -s FORCE_FILESYSTEM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 --preload-file $(dir $<)resources@resources
|
||||||
# -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 --preload-file audio/resources@resources
|
ifeq ($(BUILD_MODE), DEBUG)
|
||||||
|
CFLAGS += -s ASSERTIONS=1 --profiling
|
||||||
|
endif
|
||||||
# NOTE: Simple raylib examples are compiled to be interpreter by emterpreter, that way,
|
# NOTE: Simple raylib examples are compiled to be interpreter by emterpreter, that way,
|
||||||
# we can compile same code for ALL platforms with no change required, but, working on bigger
|
# we can compile same code for ALL platforms with no change required, but, working on bigger
|
||||||
# projects, code needs to be refactored to avoid a blocking while() loop, moving Update and Draw
|
# projects, code needs to be refactored to avoid a blocking while() loop, moving Update and Draw
|
||||||
# logic to a self contained function: UpdateDrawFrame(), check core_basic_window_web.c for reference.
|
# logic to a self contained function: UpdateDrawFrame(), check core_basic_window_web.c for reference.
|
||||||
|
|
||||||
# Define a custom shell .html and output extension
|
# Define a custom shell .html and output extension
|
||||||
CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
|
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
||||||
EXT = .html
|
EXT = .html
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define include paths for required headers.
|
# Define include paths for required headers
|
||||||
# Precedence: immediately local, raysan5 provided sources
|
|
||||||
# NOTE: Several external required libraries (stb and others)
|
# NOTE: Several external required libraries (stb and others)
|
||||||
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
|
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
|
||||||
|
|
||||||
# Define additional directories containing required header files
|
# Define additional directories containing required header files
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
|
|
@ -287,7 +271,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define library paths containing required libs.
|
# Define library paths containing required libs.
|
||||||
# Precedence: immediately local, then raysan5 provided libs
|
|
||||||
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
|
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
|
||||||
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
|
|
@ -298,7 +281,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
# Reset everything.
|
# Reset everything.
|
||||||
# Precedence: immediately local, installed version, raysan5 provided libs
|
# Precedence: immediately local, installed version, raysan5 provided libs
|
||||||
LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
|
LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
@ -320,10 +303,12 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
# Libraries for Debian GNU/Linux desktop compiling
|
# Libraries for Debian GNU/Linux desktop compiling
|
||||||
# NOTE: Required packages: libegl1-mesa-dev
|
# NOTE: Required packages: libegl1-mesa-dev
|
||||||
LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
|
LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
|
||||||
|
|
||||||
# On X11 requires also below libraries
|
# On X11 requires also below libraries
|
||||||
LDLIBS += -lX11
|
LDLIBS += -lX11
|
||||||
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
|
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
|
||||||
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
|
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
|
||||||
|
|
||||||
# On Wayland windowing system, additional libraries requires
|
# On Wayland windowing system, additional libraries requires
|
||||||
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
|
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
|
||||||
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
|
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
|
||||||
|
|
@ -342,6 +327,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
||||||
# NOTE: Required packages: mesa-libs
|
# NOTE: Required packages: mesa-libs
|
||||||
LDLIBS = -lraylib -lGL -lpthread -lm
|
LDLIBS = -lraylib -lGL -lpthread -lm
|
||||||
|
|
||||||
# On XWindow requires also below libraries
|
# On XWindow requires also below libraries
|
||||||
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
|
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
|
||||||
endif
|
endif
|
||||||
|
|
@ -360,78 +346,109 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc
|
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define all object files required
|
# Define all source files required
|
||||||
EXAMPLES = \
|
EXAMPLES = \
|
||||||
core/core_basic_window \
|
core/core_basic_window \
|
||||||
core/core_input_keys \
|
core/core_input_keys \
|
||||||
core/core_input_mouse \
|
core/core_input_mouse \
|
||||||
core/core_mouse_wheel \
|
core/core_input_mouse_wheel \
|
||||||
core/core_input_gamepad \
|
core/core_input_gamepad \
|
||||||
core/core_random_values \
|
core/core_input_multitouch \
|
||||||
core/core_color_select \
|
core/core_input_gestures \
|
||||||
core/core_drop_files \
|
core/core_2d_camera \
|
||||||
core/core_storage_values \
|
core/core_3d_camera_mode \
|
||||||
core/core_gestures_detection \
|
|
||||||
core/core_3d_mode \
|
|
||||||
core/core_3d_picking \
|
|
||||||
core/core_3d_camera_free \
|
core/core_3d_camera_free \
|
||||||
core/core_3d_camera_first_person \
|
core/core_3d_camera_first_person \
|
||||||
core/core_2d_camera \
|
core/core_3d_picking \
|
||||||
core/core_world_screen \
|
core/core_world_screen \
|
||||||
|
core/core_custom_logging \
|
||||||
|
core/core_window_letterbox \
|
||||||
|
core/core_drop_files \
|
||||||
|
core/core_random_values \
|
||||||
|
core/core_scissor_test \
|
||||||
|
core/core_storage_values \
|
||||||
core/core_vr_simulator \
|
core/core_vr_simulator \
|
||||||
core/core_input_multitouch \
|
core/core_loading_thread \
|
||||||
shapes/shapes_logo_raylib \
|
|
||||||
shapes/shapes_basic_shapes \
|
shapes/shapes_basic_shapes \
|
||||||
|
shapes/shapes_bouncing_ball \
|
||||||
shapes/shapes_colors_palette \
|
shapes/shapes_colors_palette \
|
||||||
|
shapes/shapes_logo_raylib \
|
||||||
shapes/shapes_logo_raylib_anim \
|
shapes/shapes_logo_raylib_anim \
|
||||||
|
shapes/shapes_rectangle_scaling \
|
||||||
shapes/shapes_lines_bezier \
|
shapes/shapes_lines_bezier \
|
||||||
|
shapes/shapes_collision_area \
|
||||||
|
shapes/shapes_following_eyes \
|
||||||
|
shapes/shapes_easings_ball_anim \
|
||||||
|
shapes/shapes_easings_box_anim \
|
||||||
|
shapes/shapes_easings_rectangle_array \
|
||||||
|
shapes/shapes_draw_ring \
|
||||||
|
shapes/shapes_draw_circle_sector \
|
||||||
|
shapes/shapes_draw_rectangle_rounded \
|
||||||
|
text/text_raylib_fonts \
|
||||||
|
text/text_font_spritefont \
|
||||||
|
text/text_font_loading \
|
||||||
|
text/text_font_filters \
|
||||||
|
text/text_font_sdf \
|
||||||
|
text/text_format_text \
|
||||||
|
text/text_input_box \
|
||||||
|
text/text_writing_anim \
|
||||||
|
text/text_rectangle_bounds \
|
||||||
|
text/text_unicode \
|
||||||
textures/textures_logo_raylib \
|
textures/textures_logo_raylib \
|
||||||
textures/textures_image_loading \
|
textures/textures_mouse_painting \
|
||||||
textures/textures_rectangle \
|
textures/textures_rectangle \
|
||||||
textures/textures_srcrec_dstrec \
|
textures/textures_srcrec_dstrec \
|
||||||
|
textures/textures_image_drawing \
|
||||||
|
textures/textures_image_generation \
|
||||||
|
textures/textures_image_loading \
|
||||||
|
textures/textures_image_processing \
|
||||||
|
textures/textures_image_text \
|
||||||
textures/textures_to_image \
|
textures/textures_to_image \
|
||||||
textures/textures_raw_data \
|
textures/textures_raw_data \
|
||||||
textures/textures_particles_blending \
|
textures/textures_particles_blending \
|
||||||
textures/textures_image_processing \
|
textures/textures_npatch_drawing \
|
||||||
textures/textures_image_drawing \
|
textures/textures_background_scrolling \
|
||||||
textures/textures_image_generation \
|
textures/textures_sprite_button \
|
||||||
textures/textures_image_text \
|
textures/textures_sprite_explosion \
|
||||||
text/text_sprite_fonts \
|
textures/textures_bunnymark \
|
||||||
text/text_bmfont_ttf \
|
models/models_animation \
|
||||||
text/text_raylib_fonts \
|
|
||||||
text/text_format_text \
|
|
||||||
text/text_writing_anim \
|
|
||||||
text/text_ttf_loading \
|
|
||||||
text/text_bmfont_unordered \
|
|
||||||
text/text_input_box \
|
|
||||||
text/text_font_sdf \
|
|
||||||
models/models_geometric_shapes \
|
|
||||||
models/models_box_collisions \
|
|
||||||
models/models_billboard \
|
models/models_billboard \
|
||||||
models/models_obj_loading \
|
models/models_box_collisions \
|
||||||
models/models_obj_viewer \
|
|
||||||
models/models_heightmap \
|
|
||||||
models/models_cubicmap \
|
models/models_cubicmap \
|
||||||
models/models_mesh_picking \
|
models/models_first_person_maze \
|
||||||
models/models_mesh_generation \
|
models/models_geometric_shapes \
|
||||||
models/models_material_pbr \
|
models/models_material_pbr \
|
||||||
|
models/models_mesh_generation \
|
||||||
|
models/models_mesh_picking \
|
||||||
|
models/models_loading \
|
||||||
|
models/models_orthographic_projection \
|
||||||
|
models/models_rlgl_solar_system \
|
||||||
models/models_skybox \
|
models/models_skybox \
|
||||||
models/models_yaw_pitch_roll \
|
models/models_yaw_pitch_roll \
|
||||||
|
models/models_heightmap \
|
||||||
shaders/shaders_model_shader \
|
shaders/shaders_model_shader \
|
||||||
shaders/shaders_shapes_textures \
|
shaders/shaders_shapes_textures \
|
||||||
shaders/shaders_custom_uniform \
|
shaders/shaders_custom_uniform \
|
||||||
shaders/shaders_postprocessing \
|
shaders/shaders_postprocessing \
|
||||||
shaders/shaders_raymarching \
|
|
||||||
shaders/shaders_palette_switch \
|
shaders/shaders_palette_switch \
|
||||||
audio/audio_sound_loading \
|
shaders/shaders_raymarching \
|
||||||
audio/audio_music_stream \
|
shaders/shaders_texture_drawing \
|
||||||
|
shaders/shaders_texture_waves \
|
||||||
|
shaders/shaders_julia_set \
|
||||||
|
shaders/shaders_eratosthenes \
|
||||||
|
shaders/shaders_basic_lighting \
|
||||||
|
shaders/shaders_fog \
|
||||||
|
shaders/shaders_simple_mask \
|
||||||
audio/audio_module_playing \
|
audio/audio_module_playing \
|
||||||
|
audio/audio_music_stream \
|
||||||
audio/audio_raw_stream \
|
audio/audio_raw_stream \
|
||||||
|
audio/audio_sound_loading \
|
||||||
|
audio/audio_multichannel_sound \
|
||||||
physac/physics_demo \
|
physac/physics_demo \
|
||||||
physac/physics_friction \
|
physac/physics_friction \
|
||||||
physac/physics_movement \
|
physac/physics_movement \
|
||||||
physac/physics_restitution \
|
physac/physics_restitution \
|
||||||
physac/physics_shatter \
|
physac/physics_shatter
|
||||||
|
|
||||||
|
|
||||||
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
||||||
|
|
@ -448,12 +465,6 @@ else
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# fix dylib install path name for each executable (MAC)
|
|
||||||
fix_dylib:
|
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
|
||||||
find . -type f -perm +ugo+x -print0 | xargs -t -0 -R 1 -I file install_name_tool -change libglfw.3.0.dylib ../external/glfw3/lib/osx/libglfw.3.0.dylib file
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Clean everything
|
# Clean everything
|
||||||
clean:
|
clean:
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
|
|
@ -461,7 +472,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
del *.o *.exe /s
|
del *.o *.exe /s
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv
|
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable|x-pie-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
ifeq ($(PLATFORM_OS),OSX)
|
||||||
find . -type f -perm +ugo+x -delete
|
find . -type f -perm +ugo+x -delete
|
||||||
|
|
@ -476,3 +487,4 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
del *.o *.html *.js
|
del *.o *.html *.js
|
||||||
endif
|
endif
|
||||||
@echo Cleaning done
|
@echo Cleaning done
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,9 @@ APP_KEYSTORE_PASS ?= raylib
|
||||||
|
|
||||||
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
|
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
|
||||||
RAYLIB_LIBTYPE ?= STATIC
|
RAYLIB_LIBTYPE ?= STATIC
|
||||||
RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\$(ANDROID_ARCH_NAME)
|
|
||||||
|
# Library path for libraylib.a/libraylib.so
|
||||||
|
RAYLIB_LIB_PATH = $(RAYLIB_PATH)\src
|
||||||
|
|
||||||
# Shared libs must be added to APK if required
|
# Shared libs must be added to APK if required
|
||||||
# NOTE: Generated NativeLoader.java automatically load those libraries
|
# NOTE: Generated NativeLoader.java automatically load those libraries
|
||||||
|
|
@ -104,7 +106,7 @@ CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical
|
||||||
CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION)
|
CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION)
|
||||||
|
|
||||||
# Paths containing required header files
|
# Paths containing required header files
|
||||||
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src/external/android/native_app_glue
|
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external/android/native_app_glue
|
||||||
|
|
||||||
# Linker options
|
# Linker options
|
||||||
LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a
|
LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
*
|
*
|
||||||
* raylib [audio] example - Module playing (streaming)
|
* raylib [audio] example - Module playing (streaming)
|
||||||
*
|
*
|
||||||
* NOTE: This example requires OpenAL Soft library installed
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 1.5 (www.raylib.com)
|
* This example has been created using raylib 1.5 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
|
|
@ -23,12 +21,12 @@ typedef struct {
|
||||||
Color color;
|
Color color;
|
||||||
} CircleWave;
|
} CircleWave;
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X
|
SetConfigFlags(FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X
|
||||||
|
|
||||||
|
|
@ -40,7 +38,7 @@ int main()
|
||||||
YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE };
|
YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE };
|
||||||
|
|
||||||
// Creates ome circles for visual effect
|
// Creates ome circles for visual effect
|
||||||
CircleWave circles[MAX_CIRCLES];
|
CircleWave circles[MAX_CIRCLES] = { 0 };
|
||||||
|
|
||||||
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
|
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
|
|
@ -48,13 +46,13 @@ int main()
|
||||||
circles[i].radius = GetRandomValue(10, 40);
|
circles[i].radius = GetRandomValue(10, 40);
|
||||||
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius);
|
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius);
|
||||||
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius);
|
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius);
|
||||||
circles[i].speed = (float)GetRandomValue(1, 100)/20000.0f;
|
circles[i].speed = (float)GetRandomValue(1, 100)/2000.0f;
|
||||||
circles[i].color = colors[GetRandomValue(0, 13)];
|
circles[i].color = colors[GetRandomValue(0, 13)];
|
||||||
}
|
}
|
||||||
|
|
||||||
Music xm = LoadMusicStream("resources/chiptun1.mod");
|
Music music = LoadMusicStream("resources/mini1111.xm");
|
||||||
|
|
||||||
PlayMusicStream(xm);
|
PlayMusicStream(music);
|
||||||
|
|
||||||
float timePlayed = 0.0f;
|
float timePlayed = 0.0f;
|
||||||
bool pause = false;
|
bool pause = false;
|
||||||
|
|
@ -67,13 +65,13 @@ int main()
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
UpdateMusicStream(xm); // Update music buffer with new stream data
|
UpdateMusicStream(music); // Update music buffer with new stream data
|
||||||
|
|
||||||
// Restart music playing (stop and play)
|
// Restart music playing (stop and play)
|
||||||
if (IsKeyPressed(KEY_SPACE))
|
if (IsKeyPressed(KEY_SPACE))
|
||||||
{
|
{
|
||||||
StopMusicStream(xm);
|
StopMusicStream(music);
|
||||||
PlayMusicStream(xm);
|
PlayMusicStream(music);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pause/Resume music playing
|
// Pause/Resume music playing
|
||||||
|
|
@ -81,12 +79,12 @@ int main()
|
||||||
{
|
{
|
||||||
pause = !pause;
|
pause = !pause;
|
||||||
|
|
||||||
if (pause) PauseMusicStream(xm);
|
if (pause) PauseMusicStream(music);
|
||||||
else ResumeMusicStream(xm);
|
else ResumeMusicStream(music);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get timePlayed scaled to bar dimensions
|
// Get timePlayed scaled to bar dimensions
|
||||||
timePlayed = GetMusicTimePlayed(xm)/GetMusicTimeLength(xm)*(screenWidth - 40);
|
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*(screenWidth - 40);
|
||||||
|
|
||||||
// Color circles animation
|
// Color circles animation
|
||||||
for (int i = MAX_CIRCLES - 1; (i >= 0) && !pause; i--)
|
for (int i = MAX_CIRCLES - 1; (i >= 0) && !pause; i--)
|
||||||
|
|
@ -103,7 +101,7 @@ int main()
|
||||||
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius);
|
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius);
|
||||||
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius);
|
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius);
|
||||||
circles[i].color = colors[GetRandomValue(0, 13)];
|
circles[i].color = colors[GetRandomValue(0, 13)];
|
||||||
circles[i].speed = (float)GetRandomValue(1, 100)/20000.0f;
|
circles[i].speed = (float)GetRandomValue(1, 100)/2000.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
@ -130,7 +128,7 @@ int main()
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
UnloadMusicStream(xm); // Unload music stream buffers from RAM
|
UnloadMusicStream(music); // Unload music stream buffers from RAM
|
||||||
|
|
||||||
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
||||||
|
|
||||||
|
|
|
||||||
100
examples/audio/audio_multichannel_sound.c
Normal file
|
|
@ -0,0 +1,100 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [audio] example - Multichannel sound playing
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 2.6 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Example contributed by Chris Camacho (@codifies) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Chris Camacho (@codifies) and Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [audio] example - Multichannel sound playing");
|
||||||
|
|
||||||
|
InitAudioDevice(); // Initialize audio device
|
||||||
|
|
||||||
|
Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file
|
||||||
|
Sound fxOgg = LoadSound("resources/tanatana.ogg"); // Load OGG audio file
|
||||||
|
|
||||||
|
int frame = 0;
|
||||||
|
|
||||||
|
SetSoundVolume(fxWav, 0.2);
|
||||||
|
PlaySound(fxOgg);
|
||||||
|
|
||||||
|
bool inhibitWav = false;
|
||||||
|
bool inhibitOgg = false;
|
||||||
|
int maxFrame = 60;
|
||||||
|
|
||||||
|
int soundsCounter = 0;
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
frame++;
|
||||||
|
|
||||||
|
if (IsKeyDown(KEY_ENTER)) inhibitWav = !inhibitWav;
|
||||||
|
if (IsKeyDown(KEY_SPACE)) inhibitOgg = !inhibitOgg;
|
||||||
|
|
||||||
|
// Deliberatly hammer the play pool to see what dropping old pool entries sounds like....
|
||||||
|
if ((frame%5) == 0)
|
||||||
|
{
|
||||||
|
if (!inhibitWav) PlaySoundMulti(fxWav);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frame == maxFrame)
|
||||||
|
{
|
||||||
|
if (!inhibitOgg) PlaySoundMulti(fxOgg);
|
||||||
|
|
||||||
|
frame = 0;
|
||||||
|
maxFrame = GetRandomValue(6,12);
|
||||||
|
}
|
||||||
|
|
||||||
|
soundsCounter = GetSoundsPlaying();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
DrawText("Multichannel sound abuse!", 200, 180, 20, LIGHTGRAY);
|
||||||
|
DrawText("Space to inhibit new ogg triggering", 200, 200, 20, LIGHTGRAY);
|
||||||
|
DrawText("Enter to inhibit new wav triggering", 200, 220, 20, LIGHTGRAY);
|
||||||
|
|
||||||
|
DrawText(FormatText("Number of concurrentsounds: %i", soundsCounter), 200, 280, 20, LIGHTGRAY);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
StopSoundMulti(); // We must stop the buffer pool before unloading
|
||||||
|
|
||||||
|
UnloadSound(fxWav); // Unload sound data
|
||||||
|
UnloadSound(fxOgg); // Unload sound data
|
||||||
|
|
||||||
|
CloseAudioDevice(); // Close audio device
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
*
|
*
|
||||||
* raylib [audio] example - Music playing (streaming)
|
* raylib [audio] example - Music playing (streaming)
|
||||||
*
|
*
|
||||||
* NOTE: This example requires OpenAL Soft library installed
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 1.3 (www.raylib.com)
|
* This example has been created using raylib 1.3 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
|
|
@ -13,12 +11,12 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)");
|
InitWindow(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
*
|
*
|
||||||
* raylib [audio] example - Raw audio streaming
|
* raylib [audio] example - Raw audio streaming
|
||||||
*
|
*
|
||||||
* NOTE: This example requires OpenAL Soft library installed
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 1.6 (www.raylib.com)
|
* This example has been created using raylib 1.6 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
|
* Example created by Ramon Santamaria (@raysan5) and reviewed by James Hofmann (@triplefox)
|
||||||
|
*
|
||||||
* Copyright (c) 2015-2019 Ramon Santamaria (@raysan5) and James Hofmann (@triplefox)
|
* Copyright (c) 2015-2019 Ramon Santamaria (@raysan5) and James Hofmann (@triplefox)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
@ -20,12 +20,12 @@
|
||||||
#define MAX_SAMPLES 512
|
#define MAX_SAMPLES 512
|
||||||
#define MAX_SAMPLES_PER_UPDATE 4096
|
#define MAX_SAMPLES_PER_UPDATE 4096
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - raw audio streaming");
|
InitWindow(screenWidth, screenHeight, "raylib [audio] example - raw audio streaming");
|
||||||
|
|
||||||
|
|
@ -99,7 +99,7 @@ int main()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refill audio stream if required
|
// Refill audio stream if required
|
||||||
if (IsAudioBufferProcessed(stream))
|
if (IsAudioStreamProcessed(stream))
|
||||||
{
|
{
|
||||||
// Synthesize a buffer that is exactly the requested size
|
// Synthesize a buffer that is exactly the requested size
|
||||||
int writeCursor = 0;
|
int writeCursor = 0;
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
*
|
*
|
||||||
* raylib [audio] example - Sound loading and playing
|
* raylib [audio] example - Sound loading and playing
|
||||||
*
|
*
|
||||||
* NOTE: This example requires OpenAL Soft library installed
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 1.0 (www.raylib.com)
|
* This example has been created using raylib 1.0 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
|
|
@ -13,12 +11,12 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing");
|
InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing");
|
||||||
|
|
||||||
|
|
@ -27,7 +25,7 @@ int main()
|
||||||
Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file
|
Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file
|
||||||
Sound fxOgg = LoadSound("resources/tanatana.ogg"); // Load OGG audio file
|
Sound fxOgg = LoadSound("resources/tanatana.ogg"); // Load OGG audio file
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
|
@ -46,7 +44,6 @@ int main()
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY);
|
DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY);
|
||||||
|
|
||||||
DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY);
|
DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
|
||||||
|
|
@ -13,18 +13,18 @@
|
||||||
|
|
||||||
#define MAX_BUILDINGS 100
|
#define MAX_BUILDINGS 100
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera");
|
||||||
|
|
||||||
Rectangle player = { 400, 280, 40, 40 };
|
Rectangle player = { 400, 280, 40, 40 };
|
||||||
Rectangle buildings[MAX_BUILDINGS];
|
Rectangle buildings[MAX_BUILDINGS] = { 0 };
|
||||||
Color buildColors[MAX_BUILDINGS];
|
Color buildColors[MAX_BUILDINGS] = { 0 };
|
||||||
|
|
||||||
int spacing = 0;
|
int spacing = 0;
|
||||||
|
|
||||||
|
|
@ -40,14 +40,13 @@ int main()
|
||||||
buildColors[i] = (Color){ GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255 };
|
buildColors[i] = (Color){ GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255 };
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera2D camera;
|
Camera2D camera = { 0 };
|
||||||
|
|
||||||
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
||||||
camera.offset = (Vector2){ 0, 0 };
|
camera.offset = (Vector2){ screenWidth/2, screenHeight/2 };
|
||||||
camera.rotation = 0.0f;
|
camera.rotation = 0.0f;
|
||||||
camera.zoom = 1.0f;
|
camera.zoom = 1.0f;
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
|
@ -55,16 +54,10 @@ int main()
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (IsKeyDown(KEY_RIGHT))
|
|
||||||
{
|
// Player movement
|
||||||
player.x += 2; // Player movement
|
if (IsKeyDown(KEY_RIGHT)) player.x += 2;
|
||||||
camera.offset.x -= 2; // Camera displacement with player movement
|
else if (IsKeyDown(KEY_LEFT)) player.x -= 2;
|
||||||
}
|
|
||||||
else if (IsKeyDown(KEY_LEFT))
|
|
||||||
{
|
|
||||||
player.x -= 2; // Player movement
|
|
||||||
camera.offset.x += 2; // Camera displacement with player movement
|
|
||||||
}
|
|
||||||
|
|
||||||
// Camera target follows player
|
// Camera target follows player
|
||||||
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
||||||
|
|
|
||||||
284
examples/core/core_2d_camera_ext.c
Normal file
|
|
@ -0,0 +1,284 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [core] example - 2d camera extended
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 1.5 (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 "raymath.h"
|
||||||
|
|
||||||
|
#define G 400
|
||||||
|
#define PLAYER_JUMP_SPD 350.f
|
||||||
|
#define PLAYER_HOR_SPD 200.f
|
||||||
|
|
||||||
|
typedef struct Player {
|
||||||
|
Vector2 pos;
|
||||||
|
float vel;
|
||||||
|
int canJump;
|
||||||
|
} Player;
|
||||||
|
|
||||||
|
typedef struct EnvItem {
|
||||||
|
Rectangle rect;
|
||||||
|
int blocking;
|
||||||
|
Color color;
|
||||||
|
} EnvItem;
|
||||||
|
|
||||||
|
void updateCameraCenter(
|
||||||
|
float delta,
|
||||||
|
Camera2D *camera,
|
||||||
|
Player *player,
|
||||||
|
EnvItem *envItems,
|
||||||
|
int envItemsLength,
|
||||||
|
int width, int height
|
||||||
|
) {
|
||||||
|
camera->offset = (Vector2){ width/2, height/2 };
|
||||||
|
camera->target = player->pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateCameraCenterInsideMap(
|
||||||
|
float delta,
|
||||||
|
Camera2D *camera,
|
||||||
|
Player *player,
|
||||||
|
EnvItem *envItems,
|
||||||
|
int envItemsLength,
|
||||||
|
int width, int height
|
||||||
|
) {
|
||||||
|
camera->target = player->pos;
|
||||||
|
camera->offset = (Vector2){ width/2, height/2 };
|
||||||
|
float minX = 1000, minY = 1000, maxX = -1000, maxY = -1000;
|
||||||
|
for (int i = 0; i < envItemsLength; i++) {
|
||||||
|
EnvItem *ei = envItems + i;
|
||||||
|
minX = fminf(ei->rect.x, minX);
|
||||||
|
maxX = fmaxf(ei->rect.x + ei->rect.width, maxX);
|
||||||
|
minY = fminf(ei->rect.y, minY);
|
||||||
|
maxY = fmaxf(ei->rect.y + ei->rect.height, maxY);
|
||||||
|
}
|
||||||
|
Vector2 max = GetWorldToScreen2D((Vector2){ maxX, maxY }, *camera);
|
||||||
|
Vector2 min = GetWorldToScreen2D((Vector2){ minX, minY }, *camera);
|
||||||
|
if (max.x < width) {
|
||||||
|
camera->offset.x = width - (max.x - width/2);
|
||||||
|
}
|
||||||
|
if (max.y < height) {
|
||||||
|
camera->offset.y = height - (max.y - height/2);
|
||||||
|
}
|
||||||
|
if (min.x > 0) {
|
||||||
|
camera->offset.x = width/2 - min.x;
|
||||||
|
}
|
||||||
|
if (min.y > 0) {
|
||||||
|
camera->offset.y = height/2- min.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateCameraCenterSmoothFollow(
|
||||||
|
float delta,
|
||||||
|
Camera2D *camera,
|
||||||
|
Player *player,
|
||||||
|
EnvItem *envItems,
|
||||||
|
int envItemsLength,
|
||||||
|
int width, int height
|
||||||
|
) {
|
||||||
|
static float minSpeed = 30;
|
||||||
|
static float minEffectLength = 10;
|
||||||
|
static float fractionSpeed = 0.8f;
|
||||||
|
camera->offset = (Vector2){ width/2, height/2 };
|
||||||
|
Vector2 diff = Vector2Subtract(player->pos, camera->target);
|
||||||
|
float length = Vector2Length(diff);
|
||||||
|
if (length > minEffectLength) {
|
||||||
|
float speed = fmaxf(fractionSpeed * length, minSpeed);
|
||||||
|
camera->target = Vector2Add(camera->target, Vector2Scale(diff, speed*delta/length));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateCameraEvenOutOnLanding(
|
||||||
|
float delta,
|
||||||
|
Camera2D *camera,
|
||||||
|
Player *player,
|
||||||
|
EnvItem *envItems,
|
||||||
|
int envItemsLength,
|
||||||
|
int width, int height
|
||||||
|
) {
|
||||||
|
static float evenOutSpeed = 700;
|
||||||
|
static int eveningOut = false;
|
||||||
|
static float evenOutTarget;
|
||||||
|
camera->offset = (Vector2){ width/2, height/2 };
|
||||||
|
camera->target.x = player->pos.x;
|
||||||
|
if (eveningOut) {
|
||||||
|
if (evenOutTarget > camera->target.y) {
|
||||||
|
camera->target.y += evenOutSpeed * delta;
|
||||||
|
if (camera->target.y > evenOutTarget) {
|
||||||
|
camera->target.y = evenOutTarget;
|
||||||
|
eveningOut = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
camera->target.y -= evenOutSpeed * delta;
|
||||||
|
if (camera->target.y < evenOutTarget) {
|
||||||
|
camera->target.y = evenOutTarget;
|
||||||
|
eveningOut = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (player->canJump &&
|
||||||
|
player->vel == 0 &&
|
||||||
|
player->pos.y != camera->target.y
|
||||||
|
) {
|
||||||
|
eveningOut = 1;
|
||||||
|
evenOutTarget = player->pos.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateCameraPlayerBoundsPush(
|
||||||
|
float delta,
|
||||||
|
Camera2D *camera,
|
||||||
|
Player *player,
|
||||||
|
EnvItem *envItems,
|
||||||
|
int envItemsLength,
|
||||||
|
int width, int height
|
||||||
|
) {
|
||||||
|
static Vector2 bbox = { 0.2f, 0.2f };
|
||||||
|
|
||||||
|
Vector2 bboxWorldMin = GetScreenToWorld2D((Vector2){ (1 - bbox.x) * 0.5 * width, (1 - bbox.y) * 0.5 * height }, *camera);
|
||||||
|
Vector2 bboxWorldMax = GetScreenToWorld2D((Vector2){ (1 + bbox.x) * 0.5 * width, (1 + bbox.y) * 0.5 * height }, *camera);
|
||||||
|
camera->offset = (Vector2){ (1 - bbox.x) * 0.5 * width, (1 - bbox.y) * 0.5 * height };
|
||||||
|
|
||||||
|
if (player->pos.x < bboxWorldMin.x) {
|
||||||
|
camera->target.x = player->pos.x;
|
||||||
|
}
|
||||||
|
if (player->pos.y < bboxWorldMin.y) {
|
||||||
|
camera->target.y = player->pos.y;
|
||||||
|
}
|
||||||
|
if (player->pos.x > bboxWorldMax.x) {
|
||||||
|
camera->target.x = bboxWorldMin.x + (player->pos.x - bboxWorldMax.x);
|
||||||
|
}
|
||||||
|
if (player->pos.y > bboxWorldMax.y) {
|
||||||
|
camera->target.y = bboxWorldMin.y + (player->pos.y - bboxWorldMax.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void updatePlayer(float delta, Player *player, EnvItem *envItems, int envItemsLength) {
|
||||||
|
if (IsKeyDown(KEY_LEFT)) player->pos.x -= PLAYER_HOR_SPD*delta;
|
||||||
|
if (IsKeyDown(KEY_RIGHT)) player->pos.x += PLAYER_HOR_SPD*delta;
|
||||||
|
if (IsKeyDown(KEY_SPACE) && player->canJump) {
|
||||||
|
player->vel = -PLAYER_JUMP_SPD;
|
||||||
|
player->canJump = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hitObstacle = 0;
|
||||||
|
for (int i = 0; i < envItemsLength; i++) {
|
||||||
|
EnvItem *ei = envItems + i;
|
||||||
|
Vector2 *p = &(player->pos);
|
||||||
|
if (ei->blocking &&
|
||||||
|
ei->rect.x <= p->x &&
|
||||||
|
ei->rect.x + ei->rect.width >= p->x &&
|
||||||
|
ei->rect.y >= p->y &&
|
||||||
|
ei->rect.y < p->y + player->vel * delta)
|
||||||
|
{
|
||||||
|
hitObstacle = 1;
|
||||||
|
player->vel = 0.0f;
|
||||||
|
p->y = ei->rect.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hitObstacle) {
|
||||||
|
player->pos.y += player->vel * delta;
|
||||||
|
player->vel += G * delta;
|
||||||
|
player->canJump = 0;
|
||||||
|
} else {
|
||||||
|
player->canJump = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void renderWorld(Player *player, EnvItem *envItems, int envItemsLength) {
|
||||||
|
for (int i = 0; i < envItemsLength; i++) {
|
||||||
|
DrawRectangleRec(envItems[i].rect, envItems[i].color);
|
||||||
|
}
|
||||||
|
Rectangle playerRect = { player->pos.x - 20, player->pos.y - 40, 40, 40 };
|
||||||
|
DrawRectangleRec(playerRect, RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera");
|
||||||
|
SetTargetFPS(60);
|
||||||
|
|
||||||
|
Player player;
|
||||||
|
player.pos = (Vector2){ 400, 280 };
|
||||||
|
player.vel = 0;
|
||||||
|
player.canJump = 0;
|
||||||
|
EnvItem envItems[] = {
|
||||||
|
{{ 0, 0, 1000, 400 }, 0, LIGHTGRAY },
|
||||||
|
{{ 0, 400, 1000, 200 }, 1, GRAY },
|
||||||
|
{{ 300, 200, 400, 10 }, 1, GRAY },
|
||||||
|
{{ 250, 300, 100, 10 }, 1, GRAY },
|
||||||
|
{{ 650, 300, 100, 10 }, 1, GRAY }
|
||||||
|
};
|
||||||
|
int envItemsLength = sizeof(envItems) / sizeof (envItems[0]);
|
||||||
|
|
||||||
|
Camera2D camera = { 0 };
|
||||||
|
camera.target = player.pos;
|
||||||
|
camera.offset = (Vector2){ screenWidth/2, screenHeight/2 };
|
||||||
|
camera.rotation = 0.0f;
|
||||||
|
camera.zoom = 1.0f;
|
||||||
|
|
||||||
|
int cameraOption = 0;
|
||||||
|
void (*cameraUpdaters[])(float, Camera2D*, Player*, EnvItem*, int, int, int) = {
|
||||||
|
updateCameraCenter,
|
||||||
|
updateCameraCenterInsideMap,
|
||||||
|
updateCameraCenterSmoothFollow,
|
||||||
|
updateCameraEvenOutOnLanding,
|
||||||
|
updateCameraPlayerBoundsPush
|
||||||
|
};
|
||||||
|
int cameraUpdatersLength = sizeof(cameraUpdaters) / sizeof(cameraUpdaters[0]);
|
||||||
|
char* cameraDescriptions[] = {
|
||||||
|
"Follow player center",
|
||||||
|
"Follow player center, but clamp to map edges",
|
||||||
|
"Follow player center; smoothed",
|
||||||
|
"Follow player center horizontally; updateplayer center vertically after landing",
|
||||||
|
"Player push camera on getting too close to screen edge"
|
||||||
|
};
|
||||||
|
|
||||||
|
while (!WindowShouldClose()) {
|
||||||
|
float delta = GetFrameTime();
|
||||||
|
updatePlayer(delta, &player, envItems, envItemsLength);
|
||||||
|
|
||||||
|
camera.zoom += ((float)GetMouseWheelMove()*0.05f);
|
||||||
|
if (camera.zoom > 3.0f) camera.zoom = 3.0f;
|
||||||
|
else if (camera.zoom < 0.25f) camera.zoom = 0.25f;
|
||||||
|
if (IsKeyPressed(KEY_R))
|
||||||
|
{
|
||||||
|
camera.zoom = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_C)) {
|
||||||
|
cameraOption = (cameraOption + 1) % cameraUpdatersLength;
|
||||||
|
}
|
||||||
|
cameraUpdaters[cameraOption](delta, &camera, &player, envItems, envItemsLength, screenWidth, screenHeight);
|
||||||
|
|
||||||
|
BeginDrawing();
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
BeginMode2D(camera);
|
||||||
|
renderWorld(&player, envItems, envItemsLength);
|
||||||
|
EndMode2D();
|
||||||
|
|
||||||
|
DrawText("Controls:", 20, 20, 10, BLACK);
|
||||||
|
DrawText("- Right/Left to move", 40, 40, 10, DARKGRAY);
|
||||||
|
DrawText("- Space to jump", 40, 60, 10, DARKGRAY);
|
||||||
|
DrawText("- Mouse Wheel to Zoom in-out, R to reset zoom", 40, 80, 10, DARKGRAY);
|
||||||
|
DrawText("- C to change camera mode", 40, 100, 10, DARKGRAY);
|
||||||
|
DrawText("Current camera mode:", 20, 120, 10, BLACK);
|
||||||
|
DrawText(cameraDescriptions[cameraOption], 40, 140, 10, DARKGRAY);
|
||||||
|
EndDrawing();
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -13,12 +13,12 @@
|
||||||
|
|
||||||
#define MAX_COLUMNS 20
|
#define MAX_COLUMNS 20
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person");
|
||||||
|
|
||||||
|
|
@ -31,9 +31,9 @@ int main()
|
||||||
camera.type = CAMERA_PERSPECTIVE;
|
camera.type = CAMERA_PERSPECTIVE;
|
||||||
|
|
||||||
// Generates some random columns
|
// Generates some random columns
|
||||||
float heights[MAX_COLUMNS];
|
float heights[MAX_COLUMNS] = { 0.0f };
|
||||||
Vector3 positions[MAX_COLUMNS];
|
Vector3 positions[MAX_COLUMNS] = { 0 };
|
||||||
Color colors[MAX_COLUMNS];
|
Color colors[MAX_COLUMNS] = { 0 };
|
||||||
|
|
||||||
for (int i = 0; i < MAX_COLUMNS; i++)
|
for (int i = 0; i < MAX_COLUMNS; i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -11,17 +11,17 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
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
|
||||||
Camera3D camera;
|
Camera3D camera = { 0 };
|
||||||
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
|
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
|
||||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [core] example - Initialize 3d mode
|
* raylib [core] example - Initialize 3d camera mode
|
||||||
*
|
*
|
||||||
* This example has been created using raylib 1.0 (www.raylib.com)
|
* This example has been created using raylib 1.0 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
|
@ -11,17 +11,17 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera mode");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera3D camera;
|
Camera3D camera = { 0 };
|
||||||
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position
|
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.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
|
|
@ -11,17 +11,17 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
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;
|
Camera camera = { 0 };
|
||||||
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
|
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
|
||||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
|
@ -31,7 +31,7 @@ int main()
|
||||||
Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
|
Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
|
||||||
Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
|
Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
|
||||||
|
|
||||||
Ray ray = {0.0f, 0.0f, 0.0f}; // Picking line ray
|
Ray ray = { 0 }; // Picking line ray
|
||||||
|
|
||||||
bool collision = false;
|
bool collision = false;
|
||||||
|
|
||||||
|
|
@ -48,6 +48,8 @@ int main()
|
||||||
UpdateCamera(&camera); // Update camera
|
UpdateCamera(&camera); // Update camera
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||||
|
{
|
||||||
|
if (!collision)
|
||||||
{
|
{
|
||||||
ray = GetMouseRay(GetMousePosition(), camera);
|
ray = GetMouseRay(GetMousePosition(), camera);
|
||||||
|
|
||||||
|
|
@ -56,6 +58,8 @@ int main()
|
||||||
(BoundingBox){(Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 },
|
(BoundingBox){(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 }});
|
||||||
}
|
}
|
||||||
|
else collision = false;
|
||||||
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
|
||||||
|
|
@ -21,16 +21,16 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
|
|
||||||
|
|
@ -1,94 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [core] example - Color selection by mouse (collision detection)
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 1.0 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
int screenWidth = 800;
|
|
||||||
int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - color selection (collision detection)");
|
|
||||||
|
|
||||||
Color colors[21] = { DARKGRAY, MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, DARKBROWN,
|
|
||||||
GRAY, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, YELLOW,
|
|
||||||
GREEN, SKYBLUE, PURPLE, BEIGE };
|
|
||||||
|
|
||||||
Rectangle colorsRecs[21]; // Rectangles array
|
|
||||||
|
|
||||||
// Fills colorsRecs data (for every rectangle)
|
|
||||||
for (int i = 0; i < 21; i++)
|
|
||||||
{
|
|
||||||
colorsRecs[i].x = 20 + 100*(i%7) + 10*(i%7);
|
|
||||||
colorsRecs[i].y = 60 + 100*(i/7) + 10*(i/7);
|
|
||||||
colorsRecs[i].width = 100;
|
|
||||||
colorsRecs[i].height = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool selected[21] = { false }; // Selected rectangles indicator
|
|
||||||
|
|
||||||
Vector2 mousePoint;
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
mousePoint = GetMousePosition();
|
|
||||||
|
|
||||||
for (int i = 0; i < 21; i++) // Iterate along all the rectangles
|
|
||||||
{
|
|
||||||
if (CheckCollisionPointRec(mousePoint, colorsRecs[i]))
|
|
||||||
{
|
|
||||||
colors[i].a = 120;
|
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) selected[i] = !selected[i];
|
|
||||||
}
|
|
||||||
else colors[i].a = 255;
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
for (int i = 0; i < 21; i++) // Draw all rectangles
|
|
||||||
{
|
|
||||||
DrawRectangleRec(colorsRecs[i], colors[i]);
|
|
||||||
|
|
||||||
// Draw four rectangles around selected rectangle
|
|
||||||
if (selected[i])
|
|
||||||
{
|
|
||||||
DrawRectangle(colorsRecs[i].x, colorsRecs[i].y, 100, 10, RAYWHITE); // Square top rectangle
|
|
||||||
DrawRectangle(colorsRecs[i].x, colorsRecs[i].y, 10, 100, RAYWHITE); // Square left rectangle
|
|
||||||
DrawRectangle(colorsRecs[i].x + 90, colorsRecs[i].y, 10, 100, RAYWHITE); // Square right rectangle
|
|
||||||
DrawRectangle(colorsRecs[i].x, colorsRecs[i].y + 90, 100, 10, RAYWHITE); // Square bottom rectangle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 14 KiB |
|
|
@ -5,7 +5,9 @@
|
||||||
* This example has been created using raylib 2.1 (www.raylib.com)
|
* This example has been created using raylib 2.1 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2018 Ramon Santamaria (@raysan5) and Pablo Marcos Oltra (@pamarcos)
|
* Example contributed by Pablo Marcos Oltra (@pamarcos) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 Pablo Marcos Oltra (@pamarcos) and Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
@ -17,7 +19,7 @@
|
||||||
// Custom logging funtion
|
// Custom logging funtion
|
||||||
void LogCustom(int msgType, const char *text, va_list args)
|
void LogCustom(int msgType, const char *text, va_list args)
|
||||||
{
|
{
|
||||||
char timeStr[64];
|
char timeStr[64] = { 0 };
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
struct tm *tm_info = localtime(&now);
|
struct tm *tm_info = localtime(&now);
|
||||||
|
|
||||||
|
|
@ -41,8 +43,8 @@ int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
// First thing we do is setting our custom logger to ensure everything raylib logs
|
// First thing we do is setting our custom logger to ensure everything raylib logs
|
||||||
// will use our own logger instead of its internal one
|
// will use our own logger instead of its internal one
|
||||||
|
|
@ -50,7 +52,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - custom logging");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - custom logging");
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
|
|
||||||
|
|
@ -13,19 +13,19 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files");
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
char **droppedFiles = { 0 };
|
char **droppedFiles = { 0 };
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@
|
||||||
* - PLAYSTATION(R)3 Controller
|
* - PLAYSTATION(R)3 Controller
|
||||||
* Check raylib.h for buttons configuration
|
* Check raylib.h for buttons configuration
|
||||||
*
|
*
|
||||||
* This example has been created using raylib 1.6 (www.raylib.com)
|
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
|
* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
@ -26,12 +26,12 @@
|
||||||
#define PS3_NAME_ID "PLAYSTATION(R)3 Controller"
|
#define PS3_NAME_ID "PLAYSTATION(R)3 Controller"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation
|
SetConfigFlags(FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ int main()
|
||||||
Texture2D texPs3Pad = LoadTexture("resources/ps3.png");
|
Texture2D texPs3Pad = LoadTexture("resources/ps3.png");
|
||||||
Texture2D texXboxPad = LoadTexture("resources/xbox.png");
|
Texture2D texXboxPad = LoadTexture("resources/xbox.png");
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [core] example - Gestures Detection
|
* raylib [core] example - Input Gestures Detection
|
||||||
*
|
*
|
||||||
* This example has been created using raylib 1.4 (www.raylib.com)
|
* 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)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
|
@ -14,14 +14,14 @@
|
||||||
|
|
||||||
#define MAX_GESTURE_STRINGS 20
|
#define MAX_GESTURE_STRINGS 20
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - gestures detection");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures");
|
||||||
|
|
||||||
Vector2 touchPosition = { 0, 0 };
|
Vector2 touchPosition = { 0, 0 };
|
||||||
Rectangle touchArea = { 220, 10, screenWidth - 230, screenHeight - 20 };
|
Rectangle touchArea = { 220, 10, screenWidth - 230, screenHeight - 20 };
|
||||||
|
|
@ -34,7 +34,7 @@ int main()
|
||||||
|
|
||||||
//SetGesturesEnabled(0b0000000000001001); // Enable only some gestures to be detected
|
//SetGesturesEnabled(0b0000000000001001); // Enable only some gestures to be detected
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
|
@ -11,18 +11,18 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input");
|
||||||
|
|
||||||
Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 };
|
Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 };
|
||||||
|
|
||||||
SetTargetFPS(60); // Set target frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
|
|
||||||
|
|
@ -11,19 +11,19 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input");
|
||||||
|
|
||||||
Vector2 ballPosition = { -100.0f, -100.0f };
|
Vector2 ballPosition = { -100.0f, -100.0f };
|
||||||
Color ballColor = DARKBLUE;
|
Color ballColor = DARKBLUE;
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [core] examples - Mouse wheel
|
* raylib [core] examples - Mouse wheel input
|
||||||
*
|
*
|
||||||
* This test has been created using raylib 1.1 (www.raylib.com)
|
* This test has been created using raylib 1.1 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
|
@ -11,19 +11,19 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse wheel");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - input mouse wheel");
|
||||||
|
|
||||||
int boxPositionY = screenHeight/2 - 40;
|
int boxPositionY = screenHeight/2 - 40;
|
||||||
int scrollSpeed = 4; // Scrolling speed in pixels
|
int scrollSpeed = 4; // Scrolling speed in pixels
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
|
@ -5,18 +5,20 @@
|
||||||
* This example has been created using raylib 2.1 (www.raylib.com)
|
* This example has been created using raylib 2.1 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2014-2019 Berni and Ramon Santamaria (@raysan5)
|
* Example contributed by Berni (@Berni8k) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Berni (@Berni8k) and Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - input multitouch");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - input multitouch");
|
||||||
|
|
||||||
|
|
@ -24,9 +26,9 @@ int main()
|
||||||
Color ballColor = BEIGE;
|
Color ballColor = BEIGE;
|
||||||
|
|
||||||
int touchCounter = 0;
|
int touchCounter = 0;
|
||||||
Vector2 touchPosition;
|
Vector2 touchPosition = { 0.0f };
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
|
|
||||||
|
|
@ -15,21 +15,24 @@
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#include "pthread.h" // POSIX style threads management
|
#include "pthread.h" // POSIX style threads management
|
||||||
#include <stdatomic.h>
|
|
||||||
|
|
||||||
#include <time.h> // Required for clock() function
|
#include <stdatomic.h> // C11 atomic data types
|
||||||
|
|
||||||
|
#include <time.h> // Required for: clock()
|
||||||
|
|
||||||
|
// Using C11 atomics for synchronization
|
||||||
|
// NOTE: A plain bool (or any plain data type for that matter) can't be used for inter-thread synchronization
|
||||||
static atomic_bool dataLoaded = ATOMIC_VAR_INIT(false); // Data Loaded completion indicator
|
static atomic_bool dataLoaded = ATOMIC_VAR_INIT(false); // Data Loaded completion indicator
|
||||||
static void *LoadDataThread(void *arg); // Loading data thread function declaration
|
static void *LoadDataThread(void *arg); // Loading data thread function declaration
|
||||||
|
|
||||||
static int dataProgress = 0; // Data progress accumulator
|
static int dataProgress = 0; // Data progress accumulator
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - loading thread");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - loading thread");
|
||||||
|
|
||||||
|
|
@ -38,7 +41,7 @@ int main()
|
||||||
enum { STATE_WAITING, STATE_LOADING, STATE_FINISHED } state = STATE_WAITING;
|
enum { STATE_WAITING, STATE_LOADING, STATE_FINISHED } state = STATE_WAITING;
|
||||||
int framesCounter = 0;
|
int framesCounter = 0;
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
|
@ -49,6 +52,7 @@ int main()
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case STATE_WAITING:
|
case STATE_WAITING:
|
||||||
|
{
|
||||||
if (IsKeyPressed(KEY_ENTER))
|
if (IsKeyPressed(KEY_ENTER))
|
||||||
{
|
{
|
||||||
int error = pthread_create(&threadId, NULL, &LoadDataThread, NULL);
|
int error = pthread_create(&threadId, NULL, &LoadDataThread, NULL);
|
||||||
|
|
@ -57,16 +61,18 @@ int main()
|
||||||
|
|
||||||
state = STATE_LOADING;
|
state = STATE_LOADING;
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
case STATE_LOADING:
|
case STATE_LOADING:
|
||||||
|
{
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
if (atomic_load(&dataLoaded))
|
if (atomic_load(&dataLoaded))
|
||||||
{
|
{
|
||||||
framesCounter = 0;
|
framesCounter = 0;
|
||||||
state = STATE_FINISHED;
|
state = STATE_FINISHED;
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
case STATE_FINISHED:
|
case STATE_FINISHED:
|
||||||
|
{
|
||||||
if (IsKeyPressed(KEY_ENTER))
|
if (IsKeyPressed(KEY_ENTER))
|
||||||
{
|
{
|
||||||
// Reset everything to launch again
|
// Reset everything to launch again
|
||||||
|
|
@ -74,7 +80,8 @@ int main()
|
||||||
dataProgress = 0;
|
dataProgress = 0;
|
||||||
state = STATE_WAITING;
|
state = STATE_WAITING;
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -84,19 +91,22 @@ int main()
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
switch(state) {
|
switch (state)
|
||||||
case STATE_WAITING:
|
{
|
||||||
DrawText("PRESS ENTER to START LOADING DATA", 150, 170, 20, DARKGRAY);
|
case STATE_WAITING: DrawText("PRESS ENTER to START LOADING DATA", 150, 170, 20, DARKGRAY); break;
|
||||||
break;
|
|
||||||
case STATE_LOADING:
|
case STATE_LOADING:
|
||||||
|
{
|
||||||
DrawRectangle(150, 200, dataProgress, 60, SKYBLUE);
|
DrawRectangle(150, 200, dataProgress, 60, SKYBLUE);
|
||||||
if ((framesCounter/15)%2)
|
if ((framesCounter/15)%2) DrawText("LOADING DATA...", 240, 210, 40, DARKBLUE);
|
||||||
DrawText("LOADING DATA...", 240, 210, 40, DARKBLUE);
|
|
||||||
break;
|
} break;
|
||||||
case STATE_FINISHED:
|
case STATE_FINISHED:
|
||||||
|
{
|
||||||
DrawRectangle(150, 200, 500, 60, LIME);
|
DrawRectangle(150, 200, 500, 60, LIME);
|
||||||
DrawText("DATA LOADED!", 250, 210, 40, GREEN);
|
DrawText("DATA LOADED!", 250, 210, 40, GREEN);
|
||||||
break;
|
|
||||||
|
} break;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawRectangleLines(150, 200, 500, 60, DARKGRAY);
|
DrawRectangleLines(150, 200, 500, 60, DARKGRAY);
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - generate random values");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - generate random values");
|
||||||
|
|
||||||
|
|
|
||||||
71
examples/core/core_scissor_test.c
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [core] example - Scissor test
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Example contributed by Chris Dill (@MysteriousSpace) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Chris Dill (@MysteriousSpace)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - scissor test");
|
||||||
|
|
||||||
|
Rectangle scissorArea = { 0, 0, 300, 300 };
|
||||||
|
bool scissorMode = true;
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsKeyPressed(KEY_S)) scissorMode = !scissorMode;
|
||||||
|
|
||||||
|
// Centre the scissor area around the mouse position
|
||||||
|
scissorArea.x = GetMouseX() - scissorArea.width/2;
|
||||||
|
scissorArea.y = GetMouseY() - scissorArea.height/2;
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
if (scissorMode) BeginScissorMode(scissorArea.x, scissorArea.y, scissorArea.width, scissorArea.height);
|
||||||
|
|
||||||
|
// Draw full screen rectangle and some text
|
||||||
|
// NOTE: Only part defined by scissor area will be rendered
|
||||||
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), RED);
|
||||||
|
DrawText("Move the mouse around to reveal this text!", 190, 200, 20, LIGHTGRAY);
|
||||||
|
|
||||||
|
if (scissorMode) EndScissorMode();
|
||||||
|
|
||||||
|
DrawRectangleLinesEx(scissorArea, 1, BLACK);
|
||||||
|
DrawText("Press S to toggle scissor test", 10, 10, 20, BLACK);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
examples/core/core_scissor_test.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
|
|
@ -14,21 +14,20 @@
|
||||||
// NOTE: Storage positions must start with 0, directly related to file memory layout
|
// NOTE: Storage positions must start with 0, directly related to file memory layout
|
||||||
typedef enum { STORAGE_SCORE = 0, STORAGE_HISCORE } StorageData;
|
typedef enum { STORAGE_SCORE = 0, STORAGE_HISCORE } StorageData;
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - storage save/load values");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - storage save/load values");
|
||||||
|
|
||||||
int score = 0;
|
int score = 0;
|
||||||
int hiscore = 0;
|
int hiscore = 0;
|
||||||
|
|
||||||
int framesCounter = 0;
|
int framesCounter = 0;
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
|
|
||||||
|
|
@ -11,15 +11,22 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
#define GLSL_VERSION 330
|
||||||
|
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
|
#define GLSL_VERSION 100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 1080;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 600;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
// NOTE: screenWidth/screenHeight should match VR device aspect ratio
|
// NOTE: screenWidth/screenHeight should match VR device aspect ratio
|
||||||
|
|
||||||
|
SetConfigFlags(FLAG_MSAA_4X_HINT);
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - vr simulator");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - vr simulator");
|
||||||
|
|
||||||
// Init VR simulator (Oculus Rift CV1 parameters)
|
// Init VR simulator (Oculus Rift CV1 parameters)
|
||||||
|
|
@ -49,12 +56,12 @@ int main()
|
||||||
hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3
|
hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3
|
||||||
|
|
||||||
// Distortion shader (uses device lens distortion and chroma)
|
// Distortion shader (uses device lens distortion and chroma)
|
||||||
Shader distortion = LoadShader(0, "resources/distortion.fs");
|
Shader distortion = LoadShader(0, FormatText("resources/distortion%i.fs", GLSL_VERSION));
|
||||||
|
|
||||||
SetVrConfiguration(hmd, distortion); // Set Vr device parameters for stereo rendering
|
SetVrConfiguration(hmd, distortion); // Set Vr device parameters for stereo rendering
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera;
|
Camera camera = { 0 };
|
||||||
camera.position = (Vector3){ 5.0f, 2.0f, 5.0f }; // Camera position
|
camera.position = (Vector3){ 5.0f, 2.0f, 5.0f }; // Camera position
|
||||||
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
|
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@
|
||||||
* This example has been created using raylib 2.5 (www.raylib.com)
|
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019 Anata and Ramon Santamaria (@raysan5)
|
* Example contributed by Anata (@anatagawa) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Anata (@anatagawa) and Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
@ -14,7 +16,7 @@
|
||||||
#define max(a, b) ((a)>(b)? (a) : (b))
|
#define max(a, b) ((a)>(b)? (a) : (b))
|
||||||
#define min(a, b) ((a)<(b)? (a) : (b))
|
#define min(a, b) ((a)<(b)? (a) : (b))
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
const int windowWidth = 800;
|
const int windowWidth = 800;
|
||||||
const int windowHeight = 450;
|
const int windowHeight = 450;
|
||||||
|
|
@ -27,14 +29,14 @@ int main()
|
||||||
int gameScreenWidth = 640;
|
int gameScreenWidth = 640;
|
||||||
int gameScreenHeight = 480;
|
int gameScreenHeight = 480;
|
||||||
|
|
||||||
// Render texture initialization
|
// Render texture initialization, used to hold the rendering result so we can easily resize it
|
||||||
RenderTexture2D target = LoadRenderTexture(gameScreenWidth, gameScreenHeight);
|
RenderTexture2D target = LoadRenderTexture(gameScreenWidth, gameScreenHeight);
|
||||||
SetTextureFilter(target.texture, FILTER_BILINEAR); // Texture scale filter to use
|
SetTextureFilter(target.texture, FILTER_BILINEAR); // Texture scale filter to use
|
||||||
|
|
||||||
Color colors[10] = { 0 };
|
Color colors[10] = { 0 };
|
||||||
for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 };
|
for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 };
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
|
|
@ -57,14 +59,14 @@ int main()
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(BLACK);
|
ClearBackground(BLACK);
|
||||||
|
|
||||||
// Draw everything in the render texture
|
// Draw everything in the render texture, note this will not be rendered on screen, yet
|
||||||
BeginTextureMode(target);
|
BeginTextureMode(target);
|
||||||
|
|
||||||
ClearBackground(RAYWHITE); // Clear render texture background color
|
ClearBackground(RAYWHITE); // Clear render texture background color
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) DrawRectangle(0, (gameScreenHeight/10)*i, gameScreenWidth, gameScreenHeight/10, colors[i]);
|
for (int i = 0; i < 10; i++) DrawRectangle(0, (gameScreenHeight/10)*i, gameScreenWidth, gameScreenHeight/10, colors[i]);
|
||||||
|
|
||||||
DrawText("You can resize the window,\nand see the screen scaling!", 10, 25, 20, WHITE);
|
DrawText("If executed inside a window,\nyou can resize the window,\nand see the screen scaling!", 10, 25, 20, WHITE);
|
||||||
|
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
|
||||||
|
|
||||||
|
|
@ -29,8 +29,7 @@ int main()
|
||||||
camera.type = CAMERA_PERSPECTIVE;
|
camera.type = CAMERA_PERSPECTIVE;
|
||||||
|
|
||||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||||
|
Vector2 cubeScreenPosition = { 0.0f, 0.0f };
|
||||||
Vector2 cubeScreenPosition;
|
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
||||||
|
|
||||||
|
|
|
||||||
52
examples/core/resources/distortion100.fs
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
#version 100
|
||||||
|
|
||||||
|
precision mediump float;
|
||||||
|
|
||||||
|
// Input vertex attributes (from vertex shader)
|
||||||
|
varying vec2 fragTexCoord;
|
||||||
|
varying vec4 fragColor;
|
||||||
|
|
||||||
|
// Input uniform values
|
||||||
|
uniform sampler2D texture0;
|
||||||
|
uniform vec4 colDiffuse;
|
||||||
|
|
||||||
|
// NOTE: Add here your custom variables
|
||||||
|
uniform vec2 leftLensCenter;
|
||||||
|
uniform vec2 rightLensCenter;
|
||||||
|
uniform vec2 leftScreenCenter;
|
||||||
|
uniform vec2 rightScreenCenter;
|
||||||
|
uniform vec2 scale;
|
||||||
|
uniform vec2 scaleIn;
|
||||||
|
uniform vec4 hmdWarpParam;
|
||||||
|
uniform vec4 chromaAbParam;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// Compute lens distortion
|
||||||
|
vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter;
|
||||||
|
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter;
|
||||||
|
vec2 theta = (fragTexCoord - lensCenter)*scaleIn;
|
||||||
|
float rSq = theta.x*theta.x + theta.y*theta.y;
|
||||||
|
vec2 theta1 = theta*(hmdWarpParam.x + hmdWarpParam.y*rSq + hmdWarpParam.z*rSq*rSq + hmdWarpParam.w*rSq*rSq*rSq);
|
||||||
|
vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq);
|
||||||
|
vec2 tcBlue = lensCenter + scale*thetaBlue;
|
||||||
|
|
||||||
|
if (any(bvec2(clamp(tcBlue, screenCenter - vec2(0.25, 0.5), screenCenter + vec2(0.25, 0.5)) - tcBlue)))
|
||||||
|
{
|
||||||
|
// Set black fragment for everything outside the lens border
|
||||||
|
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Compute color chroma aberration
|
||||||
|
float blue = texture2D(texture0, tcBlue).b;
|
||||||
|
vec2 tcGreen = lensCenter + scale*theta1;
|
||||||
|
float green = texture2D(texture0, tcGreen).g;
|
||||||
|
|
||||||
|
vec2 thetaRed = theta1*(chromaAbParam.x + chromaAbParam.y*rSq);
|
||||||
|
vec2 tcRed = lensCenter + scale*thetaRed;
|
||||||
|
|
||||||
|
float red = texture2D(texture0, tcRed).r;
|
||||||
|
gl_FragColor = vec4(red, green, blue, 1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,17 @@
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
|
// Input vertex attributes (from vertex shader)
|
||||||
in vec2 fragTexCoord;
|
in vec2 fragTexCoord;
|
||||||
in vec4 fragColor;
|
in vec4 fragColor;
|
||||||
|
|
||||||
|
// Input uniform values
|
||||||
|
uniform sampler2D texture0;
|
||||||
|
uniform vec4 colDiffuse;
|
||||||
|
|
||||||
|
// Output fragment color
|
||||||
out vec4 finalColor;
|
out vec4 finalColor;
|
||||||
|
|
||||||
uniform sampler2D texture0;
|
// NOTE: Add here your custom variables
|
||||||
uniform vec2 leftLensCenter = vec2(0.288, 0.5);
|
uniform vec2 leftLensCenter = vec2(0.288, 0.5);
|
||||||
uniform vec2 rightLensCenter = vec2(0.712, 0.5);
|
uniform vec2 rightLensCenter = vec2(0.712, 0.5);
|
||||||
uniform vec2 leftScreenCenter = vec2(0.25, 0.5);
|
uniform vec2 leftScreenCenter = vec2(0.25, 0.5);
|
||||||
|
|
@ -16,6 +23,7 @@ uniform vec4 chromaAbParam = vec4(0.996, -0.004, 1.014, 0.0);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
// Compute lens distortion
|
||||||
vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter;
|
vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter;
|
||||||
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter;
|
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter;
|
||||||
vec2 theta = (fragTexCoord - lensCenter)*scaleIn;
|
vec2 theta = (fragTexCoord - lensCenter)*scaleIn;
|
||||||
|
|
@ -26,10 +34,12 @@ void main()
|
||||||
|
|
||||||
if (any(bvec2(clamp(tcBlue, screenCenter - vec2(0.25, 0.5), screenCenter + vec2(0.25, 0.5)) - tcBlue)))
|
if (any(bvec2(clamp(tcBlue, screenCenter - vec2(0.25, 0.5), screenCenter + vec2(0.25, 0.5)) - tcBlue)))
|
||||||
{
|
{
|
||||||
|
// Set black fragment for everything outside the lens border
|
||||||
finalColor = vec4(0.0, 0.0, 0.0, 1.0);
|
finalColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Compute color chroma aberration
|
||||||
float blue = texture(texture0, tcBlue).b;
|
float blue = texture(texture0, tcBlue).b;
|
||||||
vec2 tcGreen = lensCenter + scale*theta1;
|
vec2 tcGreen = lensCenter + scale*theta1;
|
||||||
float green = texture(texture0, tcGreen).g;
|
float green = texture(texture0, tcGreen).g;
|
||||||
|
|
@ -40,4 +50,4 @@ void main()
|
||||||
float red = texture(texture0, tcRed).r;
|
float red = texture(texture0, tcRed).r;
|
||||||
finalColor = vec4(red, green, blue, 1.0);
|
finalColor = vec4(red, green, blue, 1.0);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
@ -5,18 +5,27 @@
|
||||||
* This example has been created using raylib 2.5 (www.raylib.com)
|
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019 Ramon Santamaria (@raysan5) and @culacant
|
* Example contributed by Culacant (@culacant) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Culacant (@culacant) and Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
********************************************************************************************
|
||||||
|
*
|
||||||
|
* To export a model from blender, make sure it is not posed, the vertices need to be in the
|
||||||
|
* same position as they would be in edit mode.
|
||||||
|
* and that the scale of your models is set to 0. Scaling can be done from the export menu.
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - model animation");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - model animation");
|
||||||
|
|
||||||
|
|
@ -89,8 +98,11 @@ int main()
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
UnloadTexture(texture); // Unload texture
|
||||||
|
|
||||||
// Unload model animations data
|
// Unload model animations data
|
||||||
for (int i = 0; i < animsCount; i++) UnloadModelAnimation(anims[i]);
|
for (int i = 0; i < animsCount; i++) UnloadModelAnimation(anims[i]);
|
||||||
|
RL_FREE(anims);
|
||||||
|
|
||||||
UnloadModel(model); // Unload model
|
UnloadModel(model); // Unload model
|
||||||
|
|
||||||
|
|
|
||||||
BIN
examples/models/models_animation.png
Normal file
|
After Width: | Height: | Size: 65 KiB |
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@
|
||||||
|
|
||||||
#include <stdlib.h> // Required for: free()
|
#include <stdlib.h> // Required for: free()
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - first person maze");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - first person maze");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
|
||||||
|
|
||||||
|
|
|
||||||
142
examples/models/models_loading.c
Normal file
|
|
@ -0,0 +1,142 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [models] example - Models loading
|
||||||
|
*
|
||||||
|
* raylib supports multiple models file formats:
|
||||||
|
*
|
||||||
|
* - OBJ > Text file, must include vertex position-texcoords-normals information,
|
||||||
|
* if files references some .mtl materials file, it will be loaded (or try to)
|
||||||
|
* - GLTF > Modern text/binary file format, includes lot of information and it could
|
||||||
|
* also reference external files, raylib will try loading mesh and materials data
|
||||||
|
* - IQM > Binary file format including mesh vertex data but also animation data,
|
||||||
|
* raylib can load .iqm animations.
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 2.6 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - models loading");
|
||||||
|
|
||||||
|
// Define the camera to look into our 3d world
|
||||||
|
Camera camera = { 0 };
|
||||||
|
camera.position = (Vector3){ 50.0f, 50.0f, 50.0f }; // Camera position
|
||||||
|
camera.target = (Vector3){ 0.0f, 10.0f, 0.0f }; // Camera looking at point
|
||||||
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
|
camera.type = CAMERA_PERSPECTIVE; // Camera mode type
|
||||||
|
|
||||||
|
Model model = LoadModel("resources/models/castle.obj"); // Load model
|
||||||
|
Texture2D texture = LoadTexture("resources/models/castle_diffuse.png"); // Load model texture
|
||||||
|
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||||
|
|
||||||
|
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
|
|
||||||
|
BoundingBox bounds = MeshBoundingBox(model.meshes[0]); // Set model bounds
|
||||||
|
|
||||||
|
// NOTE: bounds are calculated from the original size of the model,
|
||||||
|
// if model is scaled on drawing, bounds must be also scaled
|
||||||
|
|
||||||
|
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
||||||
|
|
||||||
|
bool selected = false; // Selected object flag
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
UpdateCamera(&camera);
|
||||||
|
|
||||||
|
// Load new models/textures on drag&drop
|
||||||
|
if (IsFileDropped())
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
char **droppedFiles = GetDroppedFiles(&count);
|
||||||
|
|
||||||
|
if (count == 1) // Only support one file dropped
|
||||||
|
{
|
||||||
|
if (IsFileExtension(droppedFiles[0], ".obj") ||
|
||||||
|
IsFileExtension(droppedFiles[0], ".gltf") ||
|
||||||
|
IsFileExtension(droppedFiles[0], ".iqm")) // Model file formats supported
|
||||||
|
{
|
||||||
|
UnloadModel(model); // Unload previous model
|
||||||
|
model = LoadModel(droppedFiles[0]); // Load new model
|
||||||
|
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set current map diffuse texture
|
||||||
|
|
||||||
|
bounds = MeshBoundingBox(model.meshes[0]);
|
||||||
|
|
||||||
|
// TODO: Move camera position from target enough distance to visualize model properly
|
||||||
|
}
|
||||||
|
else if (IsFileExtension(droppedFiles[0], ".png")) // Texture file formats supported
|
||||||
|
{
|
||||||
|
// Unload current model texture and load new one
|
||||||
|
UnloadTexture(texture);
|
||||||
|
texture = LoadTexture(droppedFiles[0]);
|
||||||
|
model.materials[0].maps[MAP_DIFFUSE].texture = texture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClearDroppedFiles(); // Clear internal buffers
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select model on mouse click
|
||||||
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||||
|
{
|
||||||
|
// Check collision between ray and box
|
||||||
|
if (CheckCollisionRayBox(GetMouseRay(GetMousePosition(), camera), bounds)) selected = !selected;
|
||||||
|
else selected = false;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
BeginMode3D(camera);
|
||||||
|
|
||||||
|
DrawModel(model, position, 1.0f, WHITE); // Draw 3d model with texture
|
||||||
|
|
||||||
|
DrawGrid(20, 10.0f); // Draw a grid
|
||||||
|
|
||||||
|
if (selected) DrawBoundingBox(bounds, GREEN); // Draw selection box
|
||||||
|
|
||||||
|
EndMode3D();
|
||||||
|
|
||||||
|
DrawText("Drag & drop model to load mesh/texture.", 10, GetScreenHeight() - 20, 10, DARKGRAY);
|
||||||
|
if (selected) DrawText("MODEL SELECTED", GetScreenWidth() - 110, 10, 10, GREEN);
|
||||||
|
|
||||||
|
DrawText("(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||||
|
|
||||||
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
UnloadTexture(texture); // Unload texture
|
||||||
|
UnloadModel(model); // Unload model
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
examples/models/models_loading.png
Normal file
|
After Width: | Height: | Size: 217 KiB |
|
|
@ -25,12 +25,12 @@
|
||||||
// PBR material loading
|
// PBR material loading
|
||||||
static Material LoadMaterialPBR(Color albedo, float metalness, float roughness);
|
static Material LoadMaterialPBR(Color albedo, float metalness, float roughness);
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
|
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - pbr material");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - pbr material");
|
||||||
|
|
@ -50,16 +50,15 @@ int main()
|
||||||
// NOTE: New VBO for tangents is generated at default location and also binded to mesh VAO
|
// NOTE: New VBO for tangents is generated at default location and also binded to mesh VAO
|
||||||
MeshTangents(&model.meshes[0]);
|
MeshTangents(&model.meshes[0]);
|
||||||
|
|
||||||
|
UnloadMaterial(model.materials[0]); // get rid of default material
|
||||||
model.materials[0] = LoadMaterialPBR((Color){ 255, 255, 255, 255 }, 1.0f, 1.0f);
|
model.materials[0] = LoadMaterialPBR((Color){ 255, 255, 255, 255 }, 1.0f, 1.0f);
|
||||||
|
|
||||||
// Define lights attributes
|
// Create lights
|
||||||
// NOTE: Shader is passed to every light on creation to define shader bindings internally
|
// NOTE: Lights are added to an internal lights pool automatically
|
||||||
Light lights[MAX_LIGHTS] = {
|
CreateLight(LIGHT_POINT, (Vector3){ LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 0, 255 }, model.materials[0].shader);
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 0, 255 }, model.materials[0].shader),
|
CreateLight(LIGHT_POINT, (Vector3){ 0.0f, LIGHT_HEIGHT, LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 255, 0, 255 }, model.materials[0].shader);
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ 0.0f, LIGHT_HEIGHT, LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 255, 0, 255 }, model.materials[0].shader),
|
CreateLight(LIGHT_POINT, (Vector3){ -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 0, 255, 255 }, model.materials[0].shader);
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 0, 255, 255 }, model.materials[0].shader),
|
CreateLight(LIGHT_DIRECTIONAL, (Vector3){ 0.0f, LIGHT_HEIGHT*2.0f, -LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 255, 255 }, model.materials[0].shader);
|
||||||
CreateLight(LIGHT_DIRECTIONAL, (Vector3){ 0.0f, LIGHT_HEIGHT*2.0f, -LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 255, 255 }, model.materials[0].shader)
|
|
||||||
};
|
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
||||||
|
|
||||||
|
|
@ -100,7 +99,20 @@ int main()
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
UnloadModel(model); // Unload skybox model
|
|
||||||
|
// Shaders and textures must be unloaded by user,
|
||||||
|
// they could be in use by other models
|
||||||
|
UnloadTexture(model.materials[0].maps[MAP_ALBEDO].texture);
|
||||||
|
UnloadTexture(model.materials[0].maps[MAP_NORMAL].texture);
|
||||||
|
UnloadTexture(model.materials[0].maps[MAP_METALNESS].texture);
|
||||||
|
UnloadTexture(model.materials[0].maps[MAP_ROUGHNESS].texture);
|
||||||
|
UnloadTexture(model.materials[0].maps[MAP_OCCLUSION].texture);
|
||||||
|
UnloadTexture(model.materials[0].maps[MAP_IRRADIANCE].texture);
|
||||||
|
UnloadTexture(model.materials[0].maps[MAP_PREFILTER].texture);
|
||||||
|
UnloadTexture(model.materials[0].maps[MAP_BRDF].texture);
|
||||||
|
UnloadShader(model.materials[0].shader);
|
||||||
|
|
||||||
|
UnloadModel(model); // Unload model
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -112,12 +124,13 @@ int main()
|
||||||
// NOTE: PBR shader is loaded inside this function
|
// NOTE: PBR shader is loaded inside this function
|
||||||
static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
|
static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
|
||||||
{
|
{
|
||||||
Material mat = { 0 }; // NOTE: All maps textures are set to { 0 }
|
Material mat = LoadMaterialDefault(); // Initialize material to default
|
||||||
|
|
||||||
#define PATH_PBR_VS "resources/shaders/pbr.vs" // Path to physically based rendering vertex shader
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define PATH_PBR_FS "resources/shaders/pbr.fs" // Path to physically based rendering fragment shader
|
mat.shader = LoadShader("resources/shaders/glsl330/pbr.vs", "resources/shaders/glsl330/pbr.fs");
|
||||||
|
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
mat.shader = LoadShader(PATH_PBR_VS, PATH_PBR_FS);
|
mat.shader = LoadShader("resources/shaders/glsl100/pbr.vs", "resources/shaders/glsl100/pbr.fs");
|
||||||
|
#endif
|
||||||
|
|
||||||
// Get required locations points for PBR material
|
// Get required locations points for PBR material
|
||||||
// NOTE: Those location names must be available and used in the shader code
|
// NOTE: Those location names must be available and used in the shader code
|
||||||
|
|
@ -134,7 +147,7 @@ static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
|
||||||
|
|
||||||
// Set view matrix location
|
// Set view matrix location
|
||||||
mat.shader.locs[LOC_MATRIX_MODEL] = GetShaderLocation(mat.shader, "matModel");
|
mat.shader.locs[LOC_MATRIX_MODEL] = GetShaderLocation(mat.shader, "matModel");
|
||||||
mat.shader.locs[LOC_MATRIX_VIEW] = GetShaderLocation(mat.shader, "view");
|
//mat.shader.locs[LOC_MATRIX_VIEW] = GetShaderLocation(mat.shader, "view");
|
||||||
mat.shader.locs[LOC_VECTOR_VIEW] = GetShaderLocation(mat.shader, "viewPos");
|
mat.shader.locs[LOC_VECTOR_VIEW] = GetShaderLocation(mat.shader, "viewPos");
|
||||||
|
|
||||||
// Set PBR standard maps
|
// Set PBR standard maps
|
||||||
|
|
@ -144,23 +157,33 @@ static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
|
||||||
mat.maps[MAP_ROUGHNESS].texture = LoadTexture("resources/pbr/trooper_roughness.png");
|
mat.maps[MAP_ROUGHNESS].texture = LoadTexture("resources/pbr/trooper_roughness.png");
|
||||||
mat.maps[MAP_OCCLUSION].texture = LoadTexture("resources/pbr/trooper_ao.png");
|
mat.maps[MAP_OCCLUSION].texture = LoadTexture("resources/pbr/trooper_ao.png");
|
||||||
|
|
||||||
// Set environment maps
|
// Load equirectangular to cubemap shader
|
||||||
#define PATH_CUBEMAP_VS "resources/shaders/cubemap.vs" // Path to equirectangular to cubemap vertex shader
|
#if defined(PLATFORM_DESKTOP)
|
||||||
#define PATH_CUBEMAP_FS "resources/shaders/cubemap.fs" // Path to equirectangular to cubemap fragment shader
|
Shader shdrCubemap = LoadShader("resources/shaders/glsl330/cubemap.vs", "resources/shaders/glsl330/cubemap.fs");
|
||||||
#define PATH_SKYBOX_VS "resources/shaders/skybox.vs" // Path to skybox vertex shader
|
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
#define PATH_IRRADIANCE_FS "resources/shaders/irradiance.fs" // Path to irradiance (GI) calculation fragment shader
|
Shader shdrCubemap = LoadShader("resources/shaders/glsl100/cubemap.vs", "resources/shaders/glsl100/cubemap.fs");
|
||||||
#define PATH_PREFILTER_FS "resources/shaders/prefilter.fs" // Path to reflection prefilter calculation fragment shader
|
#endif
|
||||||
#define PATH_BRDF_VS "resources/shaders/brdf.vs" // Path to bidirectional reflectance distribution function vertex shader
|
|
||||||
#define PATH_BRDF_FS "resources/shaders/brdf.fs" // Path to bidirectional reflectance distribution function fragment shader
|
|
||||||
|
|
||||||
Shader shdrCubemap = LoadShader(PATH_CUBEMAP_VS, PATH_CUBEMAP_FS);
|
// Load irradiance (GI) calculation shader
|
||||||
printf("Loaded shader: cubemap\n");
|
#if defined(PLATFORM_DESKTOP)
|
||||||
Shader shdrIrradiance = LoadShader(PATH_SKYBOX_VS, PATH_IRRADIANCE_FS);
|
Shader shdrIrradiance = LoadShader("resources/shaders/glsl330/skybox.vs", "resources/shaders/glsl330/irradiance.fs");
|
||||||
printf("Loaded shader: irradiance\n");
|
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
Shader shdrPrefilter = LoadShader(PATH_SKYBOX_VS, PATH_PREFILTER_FS);
|
Shader shdrIrradiance = LoadShader("resources/shaders/glsl100/skybox.vs", "resources/shaders/glsl100/irradiance.fs");
|
||||||
printf("Loaded shader: prefilter\n");
|
#endif
|
||||||
Shader shdrBRDF = LoadShader(PATH_BRDF_VS, PATH_BRDF_FS);
|
|
||||||
printf("Loaded shader: brdf\n");
|
// Load reflection prefilter calculation shader
|
||||||
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
Shader shdrPrefilter = LoadShader("resources/shaders/glsl330/skybox.vs", "resources/shaders/glsl330/prefilter.fs");
|
||||||
|
#else
|
||||||
|
Shader shdrPrefilter = LoadShader("resources/shaders/glsl100/skybox.vs", "resources/shaders/glsl100/prefilter.fs");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Load bidirectional reflectance distribution function shader
|
||||||
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
Shader shdrBRDF = LoadShader("resources/shaders/glsl330/brdf.vs", "resources/shaders/glsl330/brdf.fs");
|
||||||
|
#else
|
||||||
|
Shader shdrBRDF = LoadShader("resources/shaders/glsl100/brdf.vs", "resources/shaders/glsl100/brdf.fs");
|
||||||
|
#endif
|
||||||
|
|
||||||
// Setup required shader locations
|
// Setup required shader locations
|
||||||
SetShaderValue(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), (int[1]){ 0 }, UNIFORM_INT);
|
SetShaderValue(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), (int[1]){ 0 }, UNIFORM_INT);
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,14 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#define NUM_MODELS 8 // We generate 8 parametric 3d shapes
|
#define NUM_MODELS 8 // Parametric 3d shapes to generate
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh generation");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh generation");
|
||||||
|
|
||||||
|
|
@ -27,7 +27,7 @@ int main()
|
||||||
Texture2D texture = LoadTextureFromImage(checked);
|
Texture2D texture = LoadTextureFromImage(checked);
|
||||||
UnloadImage(checked);
|
UnloadImage(checked);
|
||||||
|
|
||||||
Model models[NUM_MODELS];
|
Model models[NUM_MODELS] = { 0 };
|
||||||
|
|
||||||
models[0] = LoadModelFromMesh(GenMeshPlane(2, 2, 5, 5));
|
models[0] = LoadModelFromMesh(GenMeshPlane(2, 2, 5, 5));
|
||||||
models[1] = LoadModelFromMesh(GenMeshCube(2.0f, 1.0f, 2.0f));
|
models[1] = LoadModelFromMesh(GenMeshCube(2.0f, 1.0f, 2.0f));
|
||||||
|
|
@ -115,6 +115,7 @@ int main()
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
UnloadTexture(texture); // Unload texture
|
||||||
|
|
||||||
// Unload models data (GPU VRAM)
|
// Unload models data (GPU VRAM)
|
||||||
for (int i = 0; i < NUM_MODELS; i++) UnloadModel(models[i]);
|
for (int i = 0; i < NUM_MODELS; i++) UnloadModel(models[i]);
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,9 @@
|
||||||
* This example has been created using raylib 1.7 (www.raylib.com)
|
* This example has been created using raylib 1.7 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
* Example contributed by Joel Davis (@joeld42) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
* Example contributed by Joel Davis (@joeld42)
|
*
|
||||||
|
* Copyright (c) 2017 Joel Davis (@joeld42) and Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
@ -15,12 +16,12 @@
|
||||||
|
|
||||||
#define FLT_MAX 340282346638528859811704183484516925440.0f // Maximum value of a float, from bit pattern 01111111011111111111111111111111
|
#define FLT_MAX 340282346638528859811704183484516925440.0f // Maximum value of a float, from bit pattern 01111111011111111111111111111111
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh picking");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh picking");
|
||||||
|
|
||||||
|
|
@ -104,7 +105,7 @@ int main()
|
||||||
|
|
||||||
// Check ray collision against model
|
// Check ray collision against model
|
||||||
// NOTE: It considers model.transform matrix!
|
// NOTE: It considers model.transform matrix!
|
||||||
meshHitInfo = GetCollisionRayModel(ray, &tower);
|
meshHitInfo = GetCollisionRayModel(ray, tower);
|
||||||
|
|
||||||
if ((meshHitInfo.hit) && (meshHitInfo.distance < nearestHit.distance))
|
if ((meshHitInfo.hit) && (meshHitInfo.distance < nearestHit.distance))
|
||||||
{
|
{
|
||||||
|
|
@ -112,7 +113,6 @@ int main()
|
||||||
cursorColor = ORANGE;
|
cursorColor = ORANGE;
|
||||||
hitObjectName = "Mesh";
|
hitObjectName = "Mesh";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hitMeshBBox = false;
|
hitMeshBBox = false;
|
||||||
|
|
|
||||||
|
|
@ -1,80 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [models] example - Load and draw a 3d model (OBJ)
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 1.3 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
int screenWidth = 800;
|
|
||||||
int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading");
|
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
|
||||||
Camera camera = { 0 };
|
|
||||||
camera.position = (Vector3){ 8.0f, 8.0f, 8.0f }; // Camera position
|
|
||||||
camera.target = (Vector3){ 0.0f, 2.5f, 0.0f }; // Camera looking at point
|
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
|
||||||
camera.type = CAMERA_PERSPECTIVE; // Camera mode type
|
|
||||||
|
|
||||||
Model model = LoadModel("resources/models/castle.obj"); // Load OBJ model
|
|
||||||
Texture2D texture = LoadTexture("resources/models/castle_diffuse.png"); // Load model texture
|
|
||||||
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
//...
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
BeginMode3D(camera);
|
|
||||||
|
|
||||||
DrawModel(model, position, 0.2f, WHITE); // Draw 3d model with texture
|
|
||||||
|
|
||||||
DrawGrid(10, 1.0f); // Draw a grid
|
|
||||||
|
|
||||||
DrawGizmo(position); // Draw gizmo
|
|
||||||
|
|
||||||
EndMode3D();
|
|
||||||
|
|
||||||
DrawText("(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
UnloadTexture(texture); // Unload texture
|
|
||||||
UnloadModel(model); // Unload model
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 260 KiB |
|
|
@ -1,127 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [models] example - OBJ models viewer
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 2.0 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
#include <string.h> // Required for: strcpy()
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
int screenWidth = 800;
|
|
||||||
int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib example - obj viewer");
|
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
|
||||||
Camera camera = {{ 30.0f, 30.0f, 30.0f }, { 0.0f, 10.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
|
||||||
|
|
||||||
Model model = LoadModel("resources/models/turret.obj"); // Load default model obj
|
|
||||||
Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load default model texture
|
|
||||||
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Bind texture to model
|
|
||||||
|
|
||||||
Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position
|
|
||||||
BoundingBox bounds = MeshBoundingBox(model.meshes[0]); // Set model bounds
|
|
||||||
bool selected = false; // Selected object flag
|
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
|
||||||
|
|
||||||
char objFilename[64] = "turret.obj";
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
if (IsFileDropped())
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
char **droppedFiles = GetDroppedFiles(&count);
|
|
||||||
|
|
||||||
if (count == 1)
|
|
||||||
{
|
|
||||||
if (IsFileExtension(droppedFiles[0], ".obj"))
|
|
||||||
{
|
|
||||||
for (int i = 0; i < model.meshCount; i++) UnloadMesh(&model.meshes[i]);
|
|
||||||
model.meshes = LoadMeshes(droppedFiles[0], &model.meshCount);
|
|
||||||
bounds = MeshBoundingBox(model.meshes[0]);
|
|
||||||
}
|
|
||||||
else if (IsFileExtension(droppedFiles[0], ".png"))
|
|
||||||
{
|
|
||||||
UnloadTexture(texture);
|
|
||||||
texture = LoadTexture(droppedFiles[0]);
|
|
||||||
model.materials[0].maps[MAP_DIFFUSE].texture = texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(objFilename, GetFileName(droppedFiles[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
ClearDroppedFiles(); // Clear internal buffers
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateCamera(&camera);
|
|
||||||
|
|
||||||
// Select model on mouse click
|
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
|
||||||
{
|
|
||||||
// Check collision between ray and box
|
|
||||||
if (CheckCollisionRayBox(GetMouseRay(GetMousePosition(), camera), bounds)) selected = !selected;
|
|
||||||
else selected = false;
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
BeginMode3D(camera);
|
|
||||||
|
|
||||||
DrawModel(model, position, 1.0f, WHITE); // Draw 3d model with texture
|
|
||||||
|
|
||||||
DrawGrid(20.0, 10.0); // Draw a grid
|
|
||||||
|
|
||||||
if (selected) DrawBoundingBox(bounds, GREEN);
|
|
||||||
|
|
||||||
EndMode3D();
|
|
||||||
|
|
||||||
DrawText("Free camera default controls:", 10, 20, 10, DARKGRAY);
|
|
||||||
DrawText("- Mouse Wheel to Zoom in-out", 20, 40, 10, GRAY);
|
|
||||||
DrawText("- Mouse Wheel Pressed to Pan", 20, 60, 10, GRAY);
|
|
||||||
DrawText("- Alt + Mouse Wheel Pressed to Rotate", 20, 80, 10, GRAY);
|
|
||||||
DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 20, 100, 10, GRAY);
|
|
||||||
|
|
||||||
DrawText("Drag & drop .obj/.png to load mesh/texture.", 10, GetScreenHeight() - 20, 10, DARKGRAY);
|
|
||||||
DrawText(FormatText("Current file: %s", objFilename), 250, GetScreenHeight() - 20, 10, GRAY);
|
|
||||||
if (selected) DrawText("MODEL SELECTED", GetScreenWidth() - 110, 10, 10, GREEN);
|
|
||||||
|
|
||||||
DrawText("(c) Turret 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
UnloadModel(model); // Unload model
|
|
||||||
|
|
||||||
ClearDroppedFiles(); // Clear internal buffers
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 95 KiB |
|
|
@ -4,10 +4,12 @@
|
||||||
*
|
*
|
||||||
* This program is heavily based on the geometric objects example
|
* This program is heavily based on the geometric objects example
|
||||||
*
|
*
|
||||||
* This example has been created using raylib 1.9.7 (www.raylib.com)
|
* This example has been created using raylib 2.0 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2018 Max Danielsson & Ramon Santamaria (@raysan5)
|
* Example contributed by Max Danielsson (@autious) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 Max Danielsson (@autious) and Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
@ -16,12 +18,12 @@
|
||||||
#define FOVY_PERSPECTIVE 45.0f
|
#define FOVY_PERSPECTIVE 45.0f
|
||||||
#define WIDTH_ORTHOGRAPHIC 10.0f
|
#define WIDTH_ORTHOGRAPHIC 10.0f
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
|
||||||
|
|
||||||
|
|
|
||||||
283
examples/models/models_rlgl_full_solar_system.c
Normal file
|
|
@ -0,0 +1,283 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [models] example - rlgl module usage with push/pop matrix transformations
|
||||||
|
*
|
||||||
|
* This example uses [rlgl] module funtionality (pseudo-OpenGL 1.1 style coding)
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 Ramon Santamaria (@raysan5)
|
||||||
|
* Copyright (c) 2019 Aldrin Martoq (@aldrinmartoq)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
#include "rlgl.h"
|
||||||
|
|
||||||
|
#define MAX_BODY_CHILDREN 10
|
||||||
|
float rotationSpeed = 0.2;
|
||||||
|
|
||||||
|
// A celestial body that has children bodies orbiting around
|
||||||
|
typedef struct Body {
|
||||||
|
const char *label; // label of the body, for ex: moon
|
||||||
|
float radius; // object radius
|
||||||
|
float orbitRadius; // orbit average radius
|
||||||
|
float orbitPeriod; // time the body takes to do a full loop
|
||||||
|
Color color; // color of the body
|
||||||
|
float orbitPosition; // current orbit position
|
||||||
|
Vector2 labelPosition; // label position in screen
|
||||||
|
struct Body *children[MAX_BODY_CHILDREN]; // children array
|
||||||
|
int childrenCount; // children count
|
||||||
|
} Body;
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Module Functions Declaration
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
Body CreateBody(float radius, float orbitRadius, float orbitPeriod, Color color, const char *label); // Initializes a new Body with the given parameters
|
||||||
|
void AddBodyChildren(Body *parent, Body *children); // Add a children body to the parent body
|
||||||
|
void DrawSphereBasic(Color color); // Draw sphere without any matrix transformation
|
||||||
|
void DrawBody(Body *body, Camera *camera); // Draw body and its children, updating labelPosition
|
||||||
|
void DrawLabels(Body *body); // Draw body label and its children labels
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 1024;
|
||||||
|
const int screenHeight = 768;
|
||||||
|
const char *text;
|
||||||
|
bool gridEnabled = true;
|
||||||
|
bool helpEnabled = false;
|
||||||
|
bool labelEnabled = true;
|
||||||
|
bool cameraParametersEnabled = true;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - rlgl module usage with push/pop matrix transformations");
|
||||||
|
|
||||||
|
// Define the camera to look into our 3d world
|
||||||
|
Camera camera = { 0 };
|
||||||
|
camera.position = (Vector3){ 8.0f, 8.0f, 8.0f };
|
||||||
|
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
||||||
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||||
|
camera.fovy = 45.0f;
|
||||||
|
camera.type = CAMERA_PERSPECTIVE;
|
||||||
|
|
||||||
|
SetCameraMode(camera, CAMERA_FREE);
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Create Bodies
|
||||||
|
Body sun = CreateBody(0.2, 0.0, 0, GOLD, "sun");
|
||||||
|
Body moon = CreateBody(0.05, 0.200, 24, GRAY, "moon");
|
||||||
|
Body mercury = CreateBody(0.05, 0.396, 90, GRAY, "mercury");
|
||||||
|
Body venus = CreateBody(0.05, 0.723, 210, MAGENTA, "venus");
|
||||||
|
Body earth = CreateBody(0.05, 1.000, 365, BLUE, "earth");
|
||||||
|
Body mars = CreateBody(0.05, 1.523, 690, RED, "mars");
|
||||||
|
Body jupiter = CreateBody(0.05, 5.200, 4260, BROWN, "jupiter");
|
||||||
|
Body saturn = CreateBody(0.05, 9.532, 10620, GREEN, "saturn");
|
||||||
|
Body uranus = CreateBody(0.05, 19.180, 30270, SKYBLUE, "uranus");
|
||||||
|
Body neptune = CreateBody(0.05, 30.056, 59370, PURPLE, "neptune");
|
||||||
|
Body pluto = CreateBody(0.05, 39.463, 89310, DARKGREEN, "pluto");
|
||||||
|
|
||||||
|
AddBodyChildren(&sun, &mercury);
|
||||||
|
AddBodyChildren(&sun, &venus);
|
||||||
|
AddBodyChildren(&sun, &earth);
|
||||||
|
AddBodyChildren(&sun, &mars);
|
||||||
|
AddBodyChildren(&sun, &jupiter);
|
||||||
|
AddBodyChildren(&sun, &saturn);
|
||||||
|
AddBodyChildren(&sun, &uranus);
|
||||||
|
AddBodyChildren(&sun, &neptune);
|
||||||
|
AddBodyChildren(&sun, &pluto);
|
||||||
|
|
||||||
|
AddBodyChildren(&earth, &moon);
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
UpdateCamera(&camera);
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_G)) {
|
||||||
|
gridEnabled = !gridEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_H)) {
|
||||||
|
helpEnabled = !helpEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_L)) {
|
||||||
|
labelEnabled = !labelEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_P)) {
|
||||||
|
cameraParametersEnabled = !cameraParametersEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_LEFT)) {
|
||||||
|
rotationSpeed -= 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_RIGHT)) {
|
||||||
|
rotationSpeed += 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
BeginMode3D(camera);
|
||||||
|
|
||||||
|
DrawBody(&sun, &camera);
|
||||||
|
|
||||||
|
// Some reference elements (not affected by previous matrix transformations)
|
||||||
|
if (gridEnabled) {
|
||||||
|
DrawGrid(80, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
EndMode3D();
|
||||||
|
|
||||||
|
if (labelEnabled) {
|
||||||
|
DrawLabels(&sun);
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawText("FULL SOLAR SYSTEM", 400, 10, 20, MAROON);
|
||||||
|
text = FormatText("SPEED: %2.2f", rotationSpeed);
|
||||||
|
DrawText(text, 1024 / 2 - MeasureText(text, 20) / 2, 30, 20, MAROON);
|
||||||
|
|
||||||
|
if (cameraParametersEnabled) {
|
||||||
|
text = FormatText("Camera\nposition: [%3.3f, %3.3f, %3.3f]\ntarget: [%3.3f, %3.3f, %3.3f]\nup: [%3.3f, %3.3f, %3.3f]",
|
||||||
|
camera.position.x, camera.position.y, camera.position.z,
|
||||||
|
camera.target.x, camera.target.y, camera.target.z,
|
||||||
|
camera.up.x, camera.up.y, camera.up.z);
|
||||||
|
DrawText(text, 10, 50, 20, MAROON);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helpEnabled) {
|
||||||
|
DrawText("Keys:\n- [g] toggle grid\n- [h] toggle help\n- [l] toggle labels\n- [p] toggle camera parameters\n- [left/right arrows] increase/decrease speed by 0.1", 200, 200, 20, MAROON);
|
||||||
|
} else {
|
||||||
|
DrawText("press [h] for help", 1016 - MeasureText("press [h] for help", 20), 740, 20, MAROON);
|
||||||
|
}
|
||||||
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------
|
||||||
|
// Module Functions Definitions (local)
|
||||||
|
//--------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Creates a new body
|
||||||
|
Body CreateBody(float radius, float orbitRadius, float orbitPeriod, Color color, const char *label)
|
||||||
|
{
|
||||||
|
Body body;
|
||||||
|
|
||||||
|
body.label = label;
|
||||||
|
body.radius = radius;
|
||||||
|
body.orbitRadius = orbitRadius;
|
||||||
|
body.orbitPeriod = orbitPeriod;
|
||||||
|
body.color = color;
|
||||||
|
body.childrenCount = 0;
|
||||||
|
body.orbitPosition = 0.0;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddBodyChildren(Body *parent, Body *children) {
|
||||||
|
if (parent->childrenCount >= MAX_BODY_CHILDREN) {
|
||||||
|
TraceLog(LOG_ERROR, "BODY HAS TOO MANY CHILDREN");
|
||||||
|
} else {
|
||||||
|
parent->children[parent->childrenCount] = children;
|
||||||
|
parent->childrenCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw body and its children
|
||||||
|
void DrawBody(Body *body, Camera *camera)
|
||||||
|
{
|
||||||
|
rlPushMatrix();
|
||||||
|
rlScalef(body->radius, body->radius, body->radius); // Scale Sun
|
||||||
|
DrawSphereBasic(body->color); // Draw the body
|
||||||
|
rlPopMatrix();
|
||||||
|
|
||||||
|
body->labelPosition = GetWorldToScreen((Vector3) { body->orbitRadius, body->radius, 0.0 }, *camera);
|
||||||
|
|
||||||
|
for (int i = 0; i < body->childrenCount; i++) {
|
||||||
|
Body *child = body->children[i];
|
||||||
|
child->orbitPosition += rotationSpeed * 360 / child->orbitPeriod;
|
||||||
|
rlPushMatrix();
|
||||||
|
rlRotatef(child->orbitPosition, 0.0, 1.0, 0.0);
|
||||||
|
rlTranslatef(child->orbitRadius, 0.0, 0.0);
|
||||||
|
rlRotatef(-child->orbitPosition, 0.0, 1.0, 0.0);
|
||||||
|
|
||||||
|
DrawBody(child, camera);
|
||||||
|
rlPopMatrix();
|
||||||
|
|
||||||
|
DrawCircle3D((Vector3){ 0.0f, 0.0f, 0.0f }, child->orbitRadius, (Vector3){ 1.0f, 0.0f, 0.0f }, 90.0f, child->color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw body label and its children labels
|
||||||
|
void DrawLabels(Body *body)
|
||||||
|
{
|
||||||
|
DrawText(body->label, body->labelPosition.x - MeasureText(body->label, 20) / 2, body->labelPosition.y, 20, BLACK);
|
||||||
|
|
||||||
|
for (int i = 0; i < body->childrenCount; i++) {
|
||||||
|
Body *child = body->children[i];
|
||||||
|
|
||||||
|
DrawLabels(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Draw sphere without any matrix transformation
|
||||||
|
// NOTE: Sphere is drawn in world position ( 0, 0, 0 ) with radius 1.0f
|
||||||
|
void DrawSphereBasic(Color color)
|
||||||
|
{
|
||||||
|
int rings = 16;
|
||||||
|
int slices = 16;
|
||||||
|
|
||||||
|
rlBegin(RL_TRIANGLES);
|
||||||
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
|
for (int i = 0; i < (rings + 2); i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < slices; j++)
|
||||||
|
{
|
||||||
|
rlVertex3f(cosf(DEG2RAD*(270+(180/(rings + 1))*i))*sinf(DEG2RAD*(j*360/slices)),
|
||||||
|
sinf(DEG2RAD*(270+(180/(rings + 1))*i)),
|
||||||
|
cosf(DEG2RAD*(270+(180/(rings + 1))*i))*cosf(DEG2RAD*(j*360/slices)));
|
||||||
|
rlVertex3f(cosf(DEG2RAD*(270+(180/(rings + 1))*(i+1)))*sinf(DEG2RAD*((j+1)*360/slices)),
|
||||||
|
sinf(DEG2RAD*(270+(180/(rings + 1))*(i+1))),
|
||||||
|
cosf(DEG2RAD*(270+(180/(rings + 1))*(i+1)))*cosf(DEG2RAD*((j+1)*360/slices)));
|
||||||
|
rlVertex3f(cosf(DEG2RAD*(270+(180/(rings + 1))*(i+1)))*sinf(DEG2RAD*(j*360/slices)),
|
||||||
|
sinf(DEG2RAD*(270+(180/(rings + 1))*(i+1))),
|
||||||
|
cosf(DEG2RAD*(270+(180/(rings + 1))*(i+1)))*cosf(DEG2RAD*(j*360/slices)));
|
||||||
|
|
||||||
|
rlVertex3f(cosf(DEG2RAD*(270+(180/(rings + 1))*i))*sinf(DEG2RAD*(j*360/slices)),
|
||||||
|
sinf(DEG2RAD*(270+(180/(rings + 1))*i)),
|
||||||
|
cosf(DEG2RAD*(270+(180/(rings + 1))*i))*cosf(DEG2RAD*(j*360/slices)));
|
||||||
|
rlVertex3f(cosf(DEG2RAD*(270+(180/(rings + 1))*(i)))*sinf(DEG2RAD*((j+1)*360/slices)),
|
||||||
|
sinf(DEG2RAD*(270+(180/(rings + 1))*(i))),
|
||||||
|
cosf(DEG2RAD*(270+(180/(rings + 1))*(i)))*cosf(DEG2RAD*((j+1)*360/slices)));
|
||||||
|
rlVertex3f(cosf(DEG2RAD*(270+(180/(rings + 1))*(i+1)))*sinf(DEG2RAD*((j+1)*360/slices)),
|
||||||
|
sinf(DEG2RAD*(270+(180/(rings + 1))*(i+1))),
|
||||||
|
cosf(DEG2RAD*(270+(180/(rings + 1))*(i+1)))*cosf(DEG2RAD*((j+1)*360/slices)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rlEnd();
|
||||||
|
}
|
||||||
|
|
@ -22,7 +22,7 @@ void DrawSphereBasic(Color color); // Draw sphere without any matrix transf
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox loading and drawing");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox loading and drawing");
|
||||||
|
|
||||||
|
|
@ -29,11 +29,19 @@ int main()
|
||||||
|
|
||||||
// Load skybox shader and set required locations
|
// Load skybox shader and set required locations
|
||||||
// NOTE: Some locations are automatically set at shader loading
|
// NOTE: Some locations are automatically set at shader loading
|
||||||
skybox.materials[0].shader = LoadShader("resources/shaders/skybox.vs", "resources/shaders/skybox.fs");
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
skybox.materials[0].shader = LoadShader("resources/shaders/glsl330/skybox.vs", "resources/shaders/glsl330/skybox.fs");
|
||||||
|
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
|
skybox.materials[0].shader = LoadShader("resources/shaders/glsl100/skybox.vs", "resources/shaders/glsl100/skybox.fs");
|
||||||
|
#endif
|
||||||
SetShaderValue(skybox.materials[0].shader, GetShaderLocation(skybox.materials[0].shader, "environmentMap"), (int[1]){ MAP_CUBEMAP }, UNIFORM_INT);
|
SetShaderValue(skybox.materials[0].shader, GetShaderLocation(skybox.materials[0].shader, "environmentMap"), (int[1]){ MAP_CUBEMAP }, UNIFORM_INT);
|
||||||
|
|
||||||
// Load cubemap shader and setup required shader locations
|
// Load cubemap shader and setup required shader locations
|
||||||
Shader shdrCubemap = LoadShader("resources/shaders/cubemap.vs", "resources/shaders/cubemap.fs");
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
Shader shdrCubemap = LoadShader("resources/shaders/glsl330/cubemap.vs", "resources/shaders/glsl330/cubemap.fs");
|
||||||
|
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
||||||
|
Shader shdrCubemap = LoadShader("resources/shaders/glsl100/cubemap.vs", "resources/shaders/glsl100/cubemap.fs");
|
||||||
|
#endif
|
||||||
SetShaderValue(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), (int[1]){ 0 }, UNIFORM_INT);
|
SetShaderValue(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), (int[1]){ 0 }, UNIFORM_INT);
|
||||||
|
|
||||||
// Load HDR panorama (sphere) texture
|
// Load HDR panorama (sphere) texture
|
||||||
|
|
@ -81,7 +89,10 @@ int main()
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
UnloadModel(skybox); // Unload skybox model (and textures)
|
UnloadShader(skybox.materials[0].shader);
|
||||||
|
UnloadTexture(skybox.materials[0].maps[MAP_CUBEMAP].texture);
|
||||||
|
|
||||||
|
UnloadModel(skybox); // Unload skybox model
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
244
examples/models/models_solar_system.c
Normal file
|
|
@ -0,0 +1,244 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [models] example - full solar system
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Aldrin Martoq (@aldrinmartoq)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
#include "rlgl.h"
|
||||||
|
|
||||||
|
#define MAX_BODY_CHILDREN 10
|
||||||
|
float rotationSpeed = 0.2;
|
||||||
|
|
||||||
|
// A celestial body that has children bodies orbiting around
|
||||||
|
typedef struct Body {
|
||||||
|
const char *label; // label of the body, for ex: moon
|
||||||
|
float radius; // object radius
|
||||||
|
float orbitRadius; // orbit average radius
|
||||||
|
float orbitPeriod; // time the body takes to do a full orbit loop
|
||||||
|
float rotationPeriod; // time the body takes to do a full rotation on itself
|
||||||
|
Texture2D texture; // texture of the body
|
||||||
|
Model model; // model of the body
|
||||||
|
float orbitPosition; // current orbit position
|
||||||
|
float rotationPosition; // current rotation position
|
||||||
|
Vector2 labelPosition; // label position in screen
|
||||||
|
struct Body *children[MAX_BODY_CHILDREN]; // children array
|
||||||
|
int childrenCount; // children count
|
||||||
|
} Body;
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Module Functions Declaration
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
Body CreateBody(float radius, float orbitRadius, float orbitPeriod, const char *label, const char *texture); // Initializes a new Body with the given parameters
|
||||||
|
void AddBodyChildren(Body *parent, Body *children); // Add a children body to the parent body
|
||||||
|
void DrawBody(Body *body, Camera *camera); // Draw body and its children, updating labelPosition
|
||||||
|
void DrawLabels(Body *body); // Draw body label and its children labels
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 1024;
|
||||||
|
const int screenHeight = 768;
|
||||||
|
const char *text;
|
||||||
|
bool gridEnabled = true;
|
||||||
|
bool helpEnabled = false;
|
||||||
|
bool labelEnabled = true;
|
||||||
|
bool cameraParametersEnabled = true;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - solar system");
|
||||||
|
|
||||||
|
// Define the camera to look into our 3d world
|
||||||
|
Camera camera = { 0 };
|
||||||
|
camera.position = (Vector3){ 16.0f, 16.0f, 16.0f };
|
||||||
|
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
||||||
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||||
|
camera.fovy = 45.0f;
|
||||||
|
camera.type = CAMERA_PERSPECTIVE;
|
||||||
|
|
||||||
|
SetCameraMode(camera, CAMERA_FREE);
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Create Bodies
|
||||||
|
Body sun = CreateBody(0.2, 0.0, 0, "sun", "2k_sun");
|
||||||
|
Body moon = CreateBody(0.05, 0.200, 24, "moon", "2k_moon");
|
||||||
|
Body mercury = CreateBody(0.05, 0.396, 90, "mercury", "2k_mercury");
|
||||||
|
Body venus = CreateBody(0.05, 0.723, 210, "venus", "2k_venus_atmosphere");
|
||||||
|
Body earth = CreateBody(0.05, 1.000, 365, "earth", "2k_earth_daymap");
|
||||||
|
Body mars = CreateBody(0.05, 1.523, 690, "mars", "2k_mars");
|
||||||
|
Body jupiter = CreateBody(0.05, 5.200, 4260, "jupiter", "2k_jupiter");
|
||||||
|
Body saturn = CreateBody(0.05, 9.532, 10620, "saturn", "2k_saturn");
|
||||||
|
Body uranus = CreateBody(0.05, 19.180, 30270, "uranus", "2k_uranus");
|
||||||
|
Body neptune = CreateBody(0.05, 30.056, 59370, "neptune", "2k_neptune");
|
||||||
|
Body pluto = CreateBody(0.05, 39.463, 89310, "pluto", "2k_eris_fictional");
|
||||||
|
|
||||||
|
AddBodyChildren(&sun, &mercury);
|
||||||
|
// AddBodyChildren(&sun, &venus);
|
||||||
|
AddBodyChildren(&sun, &earth);
|
||||||
|
// AddBodyChildren(&sun, &mars);
|
||||||
|
// AddBodyChildren(&sun, &jupiter);
|
||||||
|
// AddBodyChildren(&sun, &saturn);
|
||||||
|
// AddBodyChildren(&sun, &uranus);
|
||||||
|
// AddBodyChildren(&sun, &neptune);
|
||||||
|
// AddBodyChildren(&sun, &pluto);
|
||||||
|
|
||||||
|
AddBodyChildren(&earth, &moon);
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
UpdateCamera(&camera);
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_G)) {
|
||||||
|
gridEnabled = !gridEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_H)) {
|
||||||
|
helpEnabled = !helpEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_L)) {
|
||||||
|
labelEnabled = !labelEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_P)) {
|
||||||
|
cameraParametersEnabled = !cameraParametersEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_LEFT)) {
|
||||||
|
rotationSpeed -= 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_RIGHT)) {
|
||||||
|
rotationSpeed += 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(BLACK);
|
||||||
|
|
||||||
|
BeginMode3D(camera);
|
||||||
|
|
||||||
|
DrawBody(&sun, &camera);
|
||||||
|
|
||||||
|
// Some reference elements (not affected by previous matrix transformations)
|
||||||
|
if (gridEnabled) {
|
||||||
|
DrawGrid(80, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
EndMode3D();
|
||||||
|
|
||||||
|
if (labelEnabled) {
|
||||||
|
DrawLabels(&sun);
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawText("FULL SOLAR SYSTEM", 400, 10, 20, YELLOW);
|
||||||
|
text = FormatText("SPEED: %2.2f", rotationSpeed);
|
||||||
|
DrawText(text, 1024 / 2 - MeasureText(text, 20) / 2, 30, 20, YELLOW);
|
||||||
|
|
||||||
|
if (cameraParametersEnabled) {
|
||||||
|
text = FormatText("Camera\nposition: [%3.3f, %3.3f, %3.3f]\ntarget: [%3.3f, %3.3f, %3.3f]\nup: [%3.3f, %3.3f, %3.3f]",
|
||||||
|
camera.position.x, camera.position.y, camera.position.z,
|
||||||
|
camera.target.x, camera.target.y, camera.target.z,
|
||||||
|
camera.up.x, camera.up.y, camera.up.z);
|
||||||
|
DrawText(text, 10, 50, 20, YELLOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helpEnabled) {
|
||||||
|
DrawText("Keys:\n- [g] toggle grid\n- [h] toggle help\n- [l] toggle labels\n- [p] toggle camera parameters\n- [left/right arrows] increase/decrease speed by 0.1", 200, 200, 20, YELLOW);
|
||||||
|
} else {
|
||||||
|
DrawText("press [h] for help", 1016 - MeasureText("press [h] for help", 20), 740, 20, YELLOW);
|
||||||
|
}
|
||||||
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------
|
||||||
|
// Module Functions Definitions (local)
|
||||||
|
//--------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Creates a new body
|
||||||
|
Body CreateBody(float radius, float orbitRadius, float orbitPeriod, const char *label, const char *texture_name)
|
||||||
|
{
|
||||||
|
Body body;
|
||||||
|
Texture2D texture = LoadTexture(FormatText("resources/solar_system/%s.png", texture_name));
|
||||||
|
|
||||||
|
GenTextureMipmaps(&texture);
|
||||||
|
|
||||||
|
body.label = label;
|
||||||
|
body.radius = radius * 10;
|
||||||
|
body.orbitRadius = orbitRadius * 10;
|
||||||
|
body.orbitPeriod = orbitPeriod;
|
||||||
|
body.model = LoadModel("resources/solar_system/sphere.obj");
|
||||||
|
body.model.materials[0].maps[MAP_DIFFUSE].texture = texture;
|
||||||
|
body.childrenCount = 0;
|
||||||
|
body.orbitPosition = 0.0;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddBodyChildren(Body *parent, Body *children) {
|
||||||
|
if (parent->childrenCount >= MAX_BODY_CHILDREN) {
|
||||||
|
TraceLog(LOG_ERROR, "BODY HAS TOO MANY CHILDREN");
|
||||||
|
} else {
|
||||||
|
parent->children[parent->childrenCount] = children;
|
||||||
|
parent->childrenCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw body and its children
|
||||||
|
void DrawBody(Body *body, Camera *camera)
|
||||||
|
{
|
||||||
|
DrawModel(body->model, (Vector3) { 0.0f, 0.0f, 0.0f}, body->radius, WHITE);
|
||||||
|
|
||||||
|
body->labelPosition = GetWorldToScreen((Vector3) { body->orbitRadius, body->radius, 0.0 }, *camera);
|
||||||
|
|
||||||
|
for (int i = 0; i < body->childrenCount; i++) {
|
||||||
|
Body *child = body->children[i];
|
||||||
|
child->orbitPosition += rotationSpeed * 360 / child->orbitPeriod;
|
||||||
|
rlPushMatrix();
|
||||||
|
rlRotatef(child->orbitPosition, 0.0, 1.0, 0.0);
|
||||||
|
rlTranslatef(child->orbitRadius, 0.0, 0.0);
|
||||||
|
rlRotatef(-child->orbitPosition, 0.0, 1.0, 0.0);
|
||||||
|
|
||||||
|
DrawBody(child, camera);
|
||||||
|
rlPopMatrix();
|
||||||
|
|
||||||
|
DrawCircle3D((Vector3){ 0.0f, 0.0f, 0.0f }, child->orbitRadius, (Vector3){ 1.0f, 0.0f, 0.0f }, 90.0f, GRAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw body label and its children labels
|
||||||
|
void DrawLabels(Body *body)
|
||||||
|
{
|
||||||
|
DrawText(body->label, body->labelPosition.x - MeasureText(body->label, 20) / 2, body->labelPosition.y, 20, WHITE);
|
||||||
|
|
||||||
|
for (int i = 0; i < body->childrenCount; i++) {
|
||||||
|
Body *child = body->children[i];
|
||||||
|
|
||||||
|
DrawLabels(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
112
examples/models/models_waving_cubes.c
Normal file
|
|
@ -0,0 +1,112 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [models] example - Waving cubes
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Example contributed by Codecat (@codecat) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Codecat (@codecat) and Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - waving cubes");
|
||||||
|
|
||||||
|
// Initialize the camera
|
||||||
|
Camera3D camera = { 0 };
|
||||||
|
camera.position = (Vector3){ 30.0f, 20.0f, 30.0f };
|
||||||
|
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
||||||
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||||
|
camera.fovy = 70.0f;
|
||||||
|
camera.type = CAMERA_PERSPECTIVE;
|
||||||
|
|
||||||
|
// Specify the amount of blocks in each direction
|
||||||
|
const int numBlocks = 15;
|
||||||
|
|
||||||
|
SetTargetFPS(60);
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
double time = GetTime();
|
||||||
|
|
||||||
|
// Calculate time scale for cube position and size
|
||||||
|
float scale = (2.0f + (float)sin(time))*0.7f;
|
||||||
|
|
||||||
|
// Move camera around the scene
|
||||||
|
double cameraTime = time*0.3;
|
||||||
|
camera.position.x = (float)cos(cameraTime)*40.0f;
|
||||||
|
camera.position.z = (float)sin(cameraTime)*40.0f;
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
BeginMode3D(camera);
|
||||||
|
|
||||||
|
DrawGrid(10, 5.0f);
|
||||||
|
|
||||||
|
for (int x = 0; x < numBlocks; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < numBlocks; y++)
|
||||||
|
{
|
||||||
|
for (int z = 0; z < numBlocks; z++)
|
||||||
|
{
|
||||||
|
// Scale of the blocks depends on x/y/z positions
|
||||||
|
float blockScale = (x + y + z)/30.0f;
|
||||||
|
|
||||||
|
// Scatter makes the waving effect by adding blockScale over time
|
||||||
|
float scatter = sinf(blockScale*20.0f + (float)(time*4.0f));
|
||||||
|
|
||||||
|
// Calculate the cube position
|
||||||
|
Vector3 cubePos = {
|
||||||
|
(float)(x - numBlocks/2)*(scale*3.0f) + scatter,
|
||||||
|
(float)(y - numBlocks/2)*(scale*2.0f) + scatter,
|
||||||
|
(float)(z - numBlocks/2)*(scale*3.0f) + scatter
|
||||||
|
};
|
||||||
|
|
||||||
|
// Pick a color with a hue depending on cube position for the rainbow color effect
|
||||||
|
Color cubeColor = ColorFromHSV((Vector3){ (float)(((x + y + z)*18)%360), 0.75f, 0.9f });
|
||||||
|
|
||||||
|
// Calculate cube size
|
||||||
|
float cubeSize = (2.4f - scale)*blockScale;
|
||||||
|
|
||||||
|
// And finally, draw the cube!
|
||||||
|
DrawCube(cubePos, cubeSize, cubeSize, cubeSize, cubeColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EndMode3D();
|
||||||
|
|
||||||
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
examples/models/models_waving_cubes.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
|
|
@ -5,9 +5,9 @@
|
||||||
* This example has been created using raylib 1.8 (www.raylib.com)
|
* This example has been created using raylib 1.8 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Example based on Berni work on Raspberry Pi.
|
* Example contributed by Berni (@Berni8k) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
|
* Copyright (c) 2017 Berni (@Berni8k) and Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
@ -17,10 +17,7 @@
|
||||||
// Draw angle gauge controls
|
// Draw angle gauge controls
|
||||||
void DrawAngleGauge(Texture2D angleGauge, int x, int y, float angle, char title[], Color color);
|
void DrawAngleGauge(Texture2D angleGauge, int x, int y, float angle, char title[], Color color);
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
int main(void)
|
||||||
// Main entry point
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
int main()
|
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -53,10 +50,10 @@ int main()
|
||||||
float roll = 0.0f;
|
float roll = 0.0f;
|
||||||
float yaw = 0.0f;
|
float yaw = 0.0f;
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
|
|
@ -95,6 +92,7 @@ int main()
|
||||||
while (pitchOffset < -180) pitchOffset += 360;
|
while (pitchOffset < -180) pitchOffset += 360;
|
||||||
pitchOffset *= 10;
|
pitchOffset *= 10;
|
||||||
|
|
||||||
|
/* matrix transform done with multiplication to combine rotations
|
||||||
Matrix transform = MatrixIdentity();
|
Matrix transform = MatrixIdentity();
|
||||||
|
|
||||||
transform = MatrixMultiply(transform, MatrixRotateZ(DEG2RAD*roll));
|
transform = MatrixMultiply(transform, MatrixRotateZ(DEG2RAD*roll));
|
||||||
|
|
@ -102,8 +100,11 @@ int main()
|
||||||
transform = MatrixMultiply(transform, MatrixRotateY(DEG2RAD*yaw));
|
transform = MatrixMultiply(transform, MatrixRotateY(DEG2RAD*yaw));
|
||||||
|
|
||||||
model.transform = transform;
|
model.transform = transform;
|
||||||
//----------------------------------------------------------------------------------
|
*/
|
||||||
|
// matrix created from multiple axes at once
|
||||||
|
model.transform = MatrixRotateXYZ((Vector3){DEG2RAD*pitch,DEG2RAD*yaw,DEG2RAD*roll});
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
@ -168,6 +169,7 @@ int main()
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Unload all loaded data
|
// Unload all loaded data
|
||||||
|
UnloadTexture(model.materials[0].maps[MAP_DIFFUSE].texture);
|
||||||
UnloadModel(model);
|
UnloadModel(model);
|
||||||
|
|
||||||
UnloadRenderTexture(framebuffer);
|
UnloadRenderTexture(framebuffer);
|
||||||
|
|
|
||||||
BIN
examples/models/resources/models/Duck/Duck.glb
Normal file
219
examples/models/resources/models/Duck/Duck.gltf
Normal file
|
|
@ -0,0 +1,219 @@
|
||||||
|
{
|
||||||
|
"asset": {
|
||||||
|
"generator": "COLLADA2GLTF",
|
||||||
|
"version": "2.0"
|
||||||
|
},
|
||||||
|
"scene": 0,
|
||||||
|
"scenes": [
|
||||||
|
{
|
||||||
|
"nodes": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nodes": [
|
||||||
|
{
|
||||||
|
"children": [
|
||||||
|
2,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"matrix": [
|
||||||
|
0.009999999776482582,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.009999999776482582,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.009999999776482582,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
1.0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matrix": [
|
||||||
|
-0.7289686799049377,
|
||||||
|
0.0,
|
||||||
|
-0.6845470666885376,
|
||||||
|
0.0,
|
||||||
|
-0.4252049028873444,
|
||||||
|
0.7836934328079224,
|
||||||
|
0.4527972936630249,
|
||||||
|
0.0,
|
||||||
|
0.5364750623703003,
|
||||||
|
0.6211478114128113,
|
||||||
|
-0.571287989616394,
|
||||||
|
0.0,
|
||||||
|
400.1130065917969,
|
||||||
|
463.2640075683594,
|
||||||
|
-431.0780334472656,
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
"camera": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mesh": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cameras": [
|
||||||
|
{
|
||||||
|
"perspective": {
|
||||||
|
"aspectRatio": 1.5,
|
||||||
|
"yfov": 0.6605925559997559,
|
||||||
|
"zfar": 10000.0,
|
||||||
|
"znear": 1.0
|
||||||
|
},
|
||||||
|
"type": "perspective"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"meshes": [
|
||||||
|
{
|
||||||
|
"primitives": [
|
||||||
|
{
|
||||||
|
"attributes": {
|
||||||
|
"NORMAL": 1,
|
||||||
|
"POSITION": 2,
|
||||||
|
"TEXCOORD_0": 3
|
||||||
|
},
|
||||||
|
"indices": 0,
|
||||||
|
"mode": 4,
|
||||||
|
"material": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "LOD3spShape"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"accessors": [
|
||||||
|
{
|
||||||
|
"bufferView": 0,
|
||||||
|
"byteOffset": 0,
|
||||||
|
"componentType": 5123,
|
||||||
|
"count": 12636,
|
||||||
|
"max": [
|
||||||
|
2398
|
||||||
|
],
|
||||||
|
"min": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"type": "SCALAR"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView": 1,
|
||||||
|
"byteOffset": 0,
|
||||||
|
"componentType": 5126,
|
||||||
|
"count": 2399,
|
||||||
|
"max": [
|
||||||
|
0.9995989799499512,
|
||||||
|
0.999580979347229,
|
||||||
|
0.9984359741210938
|
||||||
|
],
|
||||||
|
"min": [
|
||||||
|
-0.9990839958190918,
|
||||||
|
-1.0,
|
||||||
|
-0.9998319745063782
|
||||||
|
],
|
||||||
|
"type": "VEC3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView": 1,
|
||||||
|
"byteOffset": 28788,
|
||||||
|
"componentType": 5126,
|
||||||
|
"count": 2399,
|
||||||
|
"max": [
|
||||||
|
96.17990112304688,
|
||||||
|
163.97000122070313,
|
||||||
|
53.92519760131836
|
||||||
|
],
|
||||||
|
"min": [
|
||||||
|
-69.29850006103516,
|
||||||
|
9.929369926452637,
|
||||||
|
-61.32819747924805
|
||||||
|
],
|
||||||
|
"type": "VEC3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView": 2,
|
||||||
|
"byteOffset": 0,
|
||||||
|
"componentType": 5126,
|
||||||
|
"count": 2399,
|
||||||
|
"max": [
|
||||||
|
0.9833459854125976,
|
||||||
|
0.9800369739532472
|
||||||
|
],
|
||||||
|
"min": [
|
||||||
|
0.026409000158309938,
|
||||||
|
0.01996302604675293
|
||||||
|
],
|
||||||
|
"type": "VEC2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"materials": [
|
||||||
|
{
|
||||||
|
"pbrMetallicRoughness": {
|
||||||
|
"baseColorTexture": {
|
||||||
|
"index": 0
|
||||||
|
},
|
||||||
|
"metallicFactor": 0.0
|
||||||
|
},
|
||||||
|
"emissiveFactor": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"name": "blinn3-fx"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"textures": [
|
||||||
|
{
|
||||||
|
"sampler": 0,
|
||||||
|
"source": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"images": [
|
||||||
|
{
|
||||||
|
"uri": "DuckCM.png"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"samplers": [
|
||||||
|
{
|
||||||
|
"magFilter": 9729,
|
||||||
|
"minFilter": 9986,
|
||||||
|
"wrapS": 10497,
|
||||||
|
"wrapT": 10497
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"bufferViews": [
|
||||||
|
{
|
||||||
|
"buffer": 0,
|
||||||
|
"byteOffset": 76768,
|
||||||
|
"byteLength": 25272,
|
||||||
|
"target": 34963
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer": 0,
|
||||||
|
"byteOffset": 0,
|
||||||
|
"byteLength": 57576,
|
||||||
|
"byteStride": 12,
|
||||||
|
"target": 34962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer": 0,
|
||||||
|
"byteOffset": 57576,
|
||||||
|
"byteLength": 19192,
|
||||||
|
"byteStride": 8,
|
||||||
|
"target": 34962
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"buffers": [
|
||||||
|
{
|
||||||
|
"byteLength": 102040,
|
||||||
|
"uri": "Duck0.bin"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
BIN
examples/models/resources/models/Duck/Duck0.bin
Normal file
BIN
examples/models/resources/models/Duck/DuckCM.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
14
examples/models/resources/models/Duck/Duck_license.txt
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Duck
|
||||||
|
## Screenshot
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## License Information
|
||||||
|
|
||||||
|
Copyright 2006 Sony Computer Entertainment Inc.
|
||||||
|
|
||||||
|
Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:
|
||||||
|
|
||||||
|
http://research.scea.com/scea_shared_source_license.html
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||||
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 434 KiB |
|
Before Width: | Height: | Size: 7.3 MiB After Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 547 KiB |
|
Before Width: | Height: | Size: 4.7 MiB After Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 2.7 MiB After Width: | Height: | Size: 717 KiB |
|
Before Width: | Height: | Size: 364 KiB After Width: | Height: | Size: 295 KiB |