A simple and easy-to-use library to enjoy videogames programming http://www.raylib.com
  • C 86.6%
  • Lua 7.4%
  • Makefile 2.3%
  • Zig 1.2%
  • CMake 1%
  • Other 1.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Eric J a86e313d5e
Update raymath.h
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
2021-07-11 15:11:40 -04:00
.github Review Discord link with Vanity URL 2021-03-20 20:22:44 +01:00
cmake There no longer is a library glfw_objlib and now it is only glfw. (#1818) 2021-06-09 09:49:13 +02:00
examples Update audio_raw_stream.c 2021-07-05 19:47:50 +02:00
logo Update raylib_logo_animation.gif 2021-04-20 12:29:54 +02:00
parser Improved raylib parser to export data as XML 2021-06-13 16:34:51 +02:00
projects Update raylib.vcxproj 2021-07-05 20:00:53 +02:00
src Update raymath.h 2021-07-11 15:11:40 -04:00
.gitignore Update .gitignore 2021-06-22 20:01:57 +02:00
BINDINGS.md Update raylib-ocaml to 3.7 (#1864) 2021-07-09 00:00:53 +02:00
CHANGELOG Update CHANGELOG 2021-04-26 18:00:33 +02:00
CMakeLists.txt Documentation cmake (#1549) 2021-01-26 14:34:27 +01:00
CMakeOptions.txt Update CMakeOptions.txt 2021-04-14 21:14:55 +02:00
CONTRIBUTING.md Update CONTRIBUTING.md 2021-04-15 12:31:55 +02:00
CONTRIBUTORS.md Create CONTRIBUTORS.md 2021-04-14 21:18:54 +02:00
CONVENTIONS.md Update CONVENTIONS.md 2021-06-24 19:03:05 +02:00
HISTORY.md Update HISTORY.md 2021-04-22 18:56:42 +02:00
LICENSE Update year to 2021 2021-01-02 18:15:13 +01:00
raylib.pc.in Add join_paths and join prefix with include/lib dirs (#1383) 2020-09-25 16:20:49 +02:00
README.md Update README.md 2021-04-27 23:55:05 +02:00
ROADMAP.md Update ROADMAP.md 2021-04-16 11:57:33 +02:00
SPONSORS.md Update SPONSORS.md 2021-04-16 12:52:22 +02:00

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!



GitHub contributors GitHub All Releases GitHub commits since tagged version License

Chat on Discord GitHub stars Twitter Follow Subreddit subscribers

Windows Linux macOS Android WebAssembly

CMakeBuilds Windows Examples Linux 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.

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:

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! :)

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.