- C 86.6%
- Lua 7.4%
- Makefile 2.3%
- Zig 1.2%
- CMake 1%
- Other 1.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
A spherical linear interpolation from one Vector3 point to another, without quaternions, and with selectable radius and orientation of arc.
These comments were in the function definition but to keep the header uncluttered I've put them here. It explains the math.
//Provides a constant-rate interpolation along an arc from v1 to v2 as t goes from 0 to 1.0, i.e. a spherical linear interpolation (slerp)
//The basic formula is as follows: (https://en.wikipedia.org/wiki/Slerp)
//Define omega as the angle between the two points using omega=acos( a-dot-b / ||a||*||b|| ) (Law of cosines)
//slerp(v1,v2,t) = ( sin((1-t)omega)/sin(omega) )*v1 + ( sin(t*omega)/sin(omega) )*v2
//However, the basic formula has two drawbacks. First, the center of the arc always lies on the midpoint, so the arc is a semi-circle. One might want a flatter arc with an increased radius and thus a center located off the midpoint
//Second, the arc is drawn with reference to the origin (i.e., it arcs away from wherever the origin is). One might wish to specify a different direction of the arc.
//This formula permits both parameters: iradius increases the radius from the minimum which is half the distance between the two points. So the resulting radius of the arc is iradius+Length(midpoint-v1)
//Theta (in radians) rotates the direction of the arc around the line connecting the two points (think of a jumprope)
//Overview of formula below: We define L as the line between v1 and v2. L=v2-v1. Midpoint is the midpoint of this line: M=v1+0.5*L. From the midpoint we will construct an arc centerpoint, on a radial line perpendicular to L and rotated around it by theta.
//For the plane of rotation of the radial line, we construct a plane normal to L at M. The plane by definition has the form (L.x)*X+(L.y)*Y+(L.z)*Z+D=0. To locate the plane at the midpoint, we substitute the midpoint into the equation and solve for D. So D=-(L-dot-M).
//Next we need to pick two orthogonal vectors in this plane as a basis for rotating the the radial line of the arc around it. We call these vectors F and G. The choice of lines on the plane is infinite and arbitrary.
//So we choose an easy point to solve: the intersection of the plane and the x-axis (where y==0 && z==0). This works in all cases except those where (1) the plane is parallel to the x-axis, which happens when L.x==0. So in this case we choose y-axis or z-axis instead which are just as easy, and (2) the midpoint is very close to the origin, in which case we just move aside a small amount to avoid denominators close to zero
//The x-intercept (called Incept below) is some vector {x,0,0} so we substitute this into the equation for the plane and obtain x=-D/L.x. Incept={-D/L.x,0,0} F is therefore the line between the midpoint and this intercept. F=Incept-midpoint. We normalize F because we will use it to rotate the radial line.
//The second vector must be orthogonal to F and L. It is easily obtained by LxF (cross product). We normalize G as well.
//Now F and G permit us to rotate the radial line by theta.
//The centerpoint of the arc, called perp below, becomes midpoint+(F*cos(theta)+G*sin(theta))*radius).
//Finally we translate our start and end point into a coordinate system with its center at perp: a=v1-perp and b=v2-perp. We apply our basic slerp formula to points a and b. We translate our result back into the original coordinate frame returning r+perp
|
||
| .github | ||
| cmake | ||
| examples | ||
| logo | ||
| parser | ||
| projects | ||
| src | ||
| .gitignore | ||
| BINDINGS.md | ||
| CHANGELOG | ||
| CMakeLists.txt | ||
| CMakeOptions.txt | ||
| CONTRIBUTING.md | ||
| CONTRIBUTORS.md | ||
| CONVENTIONS.md | ||
| HISTORY.md | ||
| LICENSE | ||
| raylib.pc.in | ||
| README.md | ||
| ROADMAP.md | ||
| SPONSORS.md | ||
raylib is a simple and easy-to-use library to enjoy videogames programming.
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; 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!
features
- NO external dependencies, all required libraries are bundled into raylib
- Multiple platforms supported: Windows, Linux, MacOS, RPI, Android, HTML5... and more!
- Written in plain C code (C99) in PascalCase/camelCase notation
- Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES 2.0)
- Unique OpenGL abstraction layer (usable as standalone module): rlgl
- Multiple Fonts formats supported (TTF, XNA fonts, AngelCode fonts)
- Multiple texture formats supported, including compressed formats (DXT, ETC, ASTC)
- Full 3D support, including 3D Shapes, Models, Billboards, Heightmaps and more!
- Flexible Materials system, supporting classic maps and PBR maps
- Animated 3D models supported (skeletal bones animation) (IQM, glTF)
- Shaders support, including model and postprocessing shaders.
- Powerful math module for Vector, Matrix and Quaternion operations: raymath
- Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
- VR stereo rendering support with configurable HMD device parameters
- Huge examples collection with +120 code examples!
- Bindings to +50 programming languages!
- Free and open source.
raylib uses internally some libraries for window/graphics/inputs management and also to support different fileformats loading, all those libraries are embedded with raylib and are available in src/external directory. Check raylib dependencies on raylib Wiki for a detailed list.
basic example
This is a basic raylib example, it creates a window and it draws the text "Congrats! You created your first window!" in the middle of the screen. Check this example running live on web here.
#include "raylib.h"
int main(void)
{
InitWindow(800, 450, "raylib [core] example - basic window");
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing();
}
CloseWindow();
return 0;
}
build and installation
raylib binary releases for Windows, Linux and macOS are available at the Github Releases page.
raylib is also available via multiple package managers on multiple OS distributions.
Installing and building raylib via vcpkg
You can download and install raylib using the vcpkg dependency manager:
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
vcpkg install raylib
The raylib port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.
Installing and building raylib via conan
You can download and install raylib using the conan dependency manager:
https://docs.conan.io/en/latest/getting_started.html
The raylib recipe in conan is kept up to date by conan team members and community contributors. If the version is out of date, please create an issue or pull request on the conan-center-index repository.
Installing and building raylib on multiple platforms
raylib Wiki contains detailed instructions on building and usage on multiple platforms.
- Working on Windows
- Working on macOS
- Working on GNU Linux
- Working on FreeBSD
- Working on Raspberry Pi
- Working for Android
- Working for Web (HTML5)
- Working anywhere with CMake
Note that Wiki is open for edit, if you find some issue while building raylib for your target platform, feel free to edit the Wiki or open and issue related to it.
Setup raylib with multiple IDEs
raylib has been developed on Windows platform using Notepad++ and MinGW GCC compiler but it can be used with other IDEs on multiple platforms.
Projects directory contains several ready-to-use project templates to build raylib and code examples with multiple IDEs.
Note that there are lots of IDEs supported, some of the provided templates could require some review, please, if you find some issue with some template or you think they could be improved, feel free to send a PR or open a related issue.
learning and docs
raylib is designed to be learned using the examples as the main reference. There is no standard API documentation but there is a cheatsheet containing all the functions available on the library and a short description of each one of them, input parameters and result value names should be intuitive enough to understand how each function works.
Some additional documentation about raylib design can be found in raylib GitHub Wiki. Here the more relevant links:
- raylib cheatsheet
- raylib architecture
- raylib library design
- raylib examples collection
- raylib games collection
contact and networks
raylib is present in several networks and raylib community is growing everyday. If you are using raylib and enjoying it, feel free to join us in any of these networks. The most active network is our Discord server! :)
- Webpage: http://www.raylib.com
- Discord: https://discord.gg/raylib
- Twitter: http://www.twitter.com/raysan5
- Twitch: http://www.twitch.tv/raysan5
- Reddit: https://www.reddit.com/r/raylib
- Patreon: https://www.patreon.com/raylib
- YouTube: https://www.youtube.com/channel/raylib
license
raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check LICENSE for further details.