commit
949ed3f9f8
17 changed files with 1547 additions and 512 deletions
11
.gitignore
vendored
11
.gitignore
vendored
|
@ -74,7 +74,7 @@ games/*
|
|||
!games/*.lua
|
||||
!games/*.png
|
||||
# Unignore games makefile
|
||||
!games/makefile
|
||||
!games/Makefile
|
||||
|
||||
# Ignore files build by xcode
|
||||
*.mode*v*
|
||||
|
@ -96,8 +96,6 @@ src/libraylib.bc
|
|||
# external libraries DLLs
|
||||
!src/external/glfw3/lib/win32/glfw3.dll
|
||||
!src/external/openal_soft/lib/win32/OpenAL32.dll
|
||||
!src/external/OculusSDK/LibOVR/LibOVRRT32_1.dll
|
||||
!src/external/pthread/lib/pthreadGC2.dll
|
||||
|
||||
# Visual Studio project
|
||||
project/vs2015/*.db
|
||||
|
@ -123,3 +121,10 @@ docs/examples/web/*/*.html
|
|||
!docs/examples/web/shaders/loader.html
|
||||
!docs/examples/web/models/loader.html
|
||||
|
||||
# raylib release libs
|
||||
!release/android/armeabi-v7a/libraylib.a
|
||||
!release/android/armeabi-v7a/libraylib.so
|
||||
!release/linux/libraylib.a
|
||||
!release/linux/libraylib.so
|
||||
!release/rpi/libraylib.a
|
||||
|
||||
|
|
104
CHANGELOG
104
CHANGELOG
|
@ -1,7 +1,103 @@
|
|||
changelog
|
||||
---------
|
||||
|
||||
Current Release: raylib 1.6.0 (20 November 2016)
|
||||
Current Release: raylib 1.7.0 (20 May 2017)
|
||||
|
||||
-----------------------------------------------
|
||||
Release: raylib 1.7.0 (20 May 2017)
|
||||
-----------------------------------------------
|
||||
NOTE:
|
||||
In this new raylib release, multiple parts of the library have been reviewed for consistency and simplification.
|
||||
It exposes almost 300 functions, around 30 new functions in comparison with previous version and, again,
|
||||
it sets a stepping stone towards raylib future.
|
||||
|
||||
BIG changes:
|
||||
- More than 30 new functions added to the library, check list below.
|
||||
- Support of configuration flags on every raylib module, to customize library build.
|
||||
- Improved build system for all supported platforms with a unique Makefile to compile sources.
|
||||
- Complete review of examples and sample games, added new sample material.
|
||||
- Support automatic GIF recording of current window, just pressing Ctrl+F12
|
||||
- Improved library consistency and organization in general.
|
||||
|
||||
other changes:
|
||||
[core] Added function: SetWindowIcon(), to setup icon by code
|
||||
[core] Added function: SetWindowMonitor(), to set current display monitor
|
||||
[core] Added function: SetWindowMinSize(), to set minimum resize size
|
||||
[core] Added function: TakeScreenshot(), made public to API (also launched internally with F12)
|
||||
[core] Added function: GetDirectoryPath(), get directory for a given fileName (with path)
|
||||
[core] Added function: GetWorkingDirectory(), get current working directory
|
||||
[core] Added function: ChangeDirectory(), change working directory
|
||||
[core] Added function: TraceLog(), made public to API
|
||||
[core] Improved timming system to avoid busy wait loop on frame sync: Wait()
|
||||
[core] Added support for gamepad on HTML5 platform
|
||||
[core] Support mouse lock, useful for camera system
|
||||
[core] Review functions description comments
|
||||
[rlgl] Removed function: GetStandardShader(), removed internal standard shader
|
||||
[rlgl] Removed function: CreateLight(), removed internal lighting system
|
||||
[rlgl] Removed function: DestroyLight(), removed internal lighting system
|
||||
[rlgl] Removed function: InitVrDevice(), removed VR device render, using simulator
|
||||
[rlgl] Removed function: CloseVrDevice(), removed VR device render, using simulator
|
||||
[rlgl] Removed function: IsVrDeviceReady(), removed VR device render, using simulator
|
||||
[rlgl] Removed function: IsVrSimulator(), removed VR device render, using simulator
|
||||
[rlgl] Added function: InitVrSimulator(), init VR simulator for selected device
|
||||
[rlgl] Added function: CloseVrSimulator(), close VR simulator for current device
|
||||
[rlgl] Added function: IsVrSimulatorReady(), detect if VR device is ready
|
||||
[rlgl] Added function: BeginVrDrawing(), begin VR simulator stereo rendering
|
||||
[rlgl] Added function: EndVrDrawing(), end VR simulator stereo rendering
|
||||
[rlgl] Renamed function: ReadTextFile() to LoadText() and exposed to API
|
||||
[rlgl] Removed internal lighting system and standard shader, moved to example
|
||||
[rlgl] Removed Oculus Rift support, moved to oculus_rift example
|
||||
[rlgl] Removed VR device support and replaced by VR simulator
|
||||
[shapes] Added function: DrawLineEx(), draw line with QUADS, supports custom line thick
|
||||
[shapes] Added function: DrawLineBezier(), draw a line using cubic-bezier curves in-out
|
||||
[shapes] Added function: DrawRectanglePro(), draw a color-filled rectangle with pro parameters
|
||||
[textures] Removed function: LoadImageFromRES(), redesigning custom RRES fileformat
|
||||
[textures] Removed function: LoadTextureFromRES(), redesigning custom RRES fileformat
|
||||
[textures] Removed function: LoadTextureEx(), use instead Image -> LoadImagePro(), LoadImageEx()
|
||||
[textures] Added function: LoadImagePro()), load image from raw data with parameters
|
||||
[textures] Review TraceLog() message when image file not found
|
||||
[text] Renamed function: LoadSpriteFontTTF() to LoadSpriteFontEx(), for consistency
|
||||
[text] Removed rBMF fileformat support, replaced by .png
|
||||
[text] Refactor SpriteFont struct (better for rres custom fileformat)
|
||||
[text] Renamed some variables for consistency
|
||||
[models] Added function: LoadMesh(), load mesh from file
|
||||
[models] Added function: LoadMeshEx(), load mesh from vertex data
|
||||
[models] Added function: UnloadMesh(), unload mesh from memory (RAM and/or VRAM)
|
||||
[models] Added function: GetCollisionRayMesh(), get collision info between ray and mesh
|
||||
[models] Added function: GetCollisionRayTriangle(), get collision info between ray and triangle
|
||||
[models] Added function: GetCollisionRayGround(), get collision info between ray and ground plane
|
||||
[models] Renamed function: LoadModelEx() to LoadModelFromMesh()
|
||||
[models] Removed function: DrawLight(), removed internal lighting system
|
||||
[models] Renamed function: LoadModelEx() to LoadModelFromMesh() for consistency
|
||||
[models] Removed function: LoadStandardMaterial(), removed internal standard shader
|
||||
[models] Removed function: LoadModelFromRES(), redesigning custom RRES fileformat
|
||||
[models] Renamed multiple variables for consistency
|
||||
[audio] Added function: SetMasterVolume(), define listener volume
|
||||
[audio] Added function: ResumeSound(), resume a paused sound
|
||||
[audio] Added function: SetMusicLoopCount(), set number of repeats for a music
|
||||
[audio] Added function: LoadWaveEx(), load wave from raw audio data
|
||||
[audio] Added function: WaveCrop(), crop wave audio data
|
||||
[audio] Added function: WaveFormat(), format audio data
|
||||
[audio] Removed function: LoadSoundFromRES(), redesigning custom RRES fileformat
|
||||
[audio] Added support for 32bit audio samples
|
||||
[audio] Preliminary support for multichannel, limited to mono and stereo
|
||||
[audio] Make sure buffers are ready for update: UpdateMusicStream()
|
||||
[utils] Replaced function: GetExtension() by IsFileExtension() and made public to API
|
||||
[utils] Unified function: TraceLog() between Android and other platforms
|
||||
[utils] Removed internal function: GetNextPOT(), simplified implementation
|
||||
[raymath] Added function: QuaternionToEuler(), to work with Euler angles
|
||||
[raymath] Added function: QuaternionFromEuler(), to work with Euler angles
|
||||
[raymath] Added multiple Vector2 math functions
|
||||
[build] Integrate Android source building into Makefile
|
||||
[example] Added example: shapes_lines_bezier
|
||||
[example] Added example: text_input_box
|
||||
[github] Moved gh-pages branch to master/docs
|
||||
[github] Moved rlua.h and Lua examples to own repo: raylib-lua
|
||||
[games] Reviewed full games collection
|
||||
[games] New game added to collection: Koala Seasons
|
||||
[*] Reviewed and improved examples collection (new assets)
|
||||
[*] Reorganized library functions, structs, enums
|
||||
[*] Updated STB libraries to latest version
|
||||
|
||||
-----------------------------------------------
|
||||
Release: raylib 1.6.0 (20 November 2016)
|
||||
|
@ -15,7 +111,7 @@ HUGE changes:
|
|||
[audio] COMPLETE REDESIGN: Improved music support and also raw audio data processing and playing, +20 new functions added.
|
||||
[physac] COMPLETE REWRITE: Improved performance, functionality and simplified usage, moved to own repository and added multiple examples!
|
||||
|
||||
Other changes:
|
||||
other changes:
|
||||
|
||||
[core] Corrected issue on OSX with HighDPI display
|
||||
[core] Added flag to allow resizable window
|
||||
|
@ -166,6 +262,7 @@ BIG changes:
|
|||
[physac] NEW MODULE: Basic 2D physics support, use colliders and rigidbodies; apply forces to physic objects.
|
||||
|
||||
other changes:
|
||||
|
||||
[rlgl] Removed GLEW library dependency, now using GLAD
|
||||
[rlgl] Implemented alternative to glGetTexImage() on OpenGL ES
|
||||
[rlgl] Using depth data on batch drawing
|
||||
|
@ -204,7 +301,8 @@ BIG changes:
|
|||
[gestures] NEW MODULE: Gestures system for Android and HTML5 platforms
|
||||
[raygui] NEW MODULE: Set of IMGUI elements for tools development (experimental)
|
||||
|
||||
smaller changes:
|
||||
other changes:
|
||||
|
||||
[rlgl] Added check for OpenGL supported extensions
|
||||
[rlgl] Added function SetBlenMode() to select some predefined blending modes
|
||||
[core] Added support for drop&drag of external files into running program
|
||||
|
|
27
HISTORY.md
27
HISTORY.md
|
@ -147,11 +147,11 @@ notes on raylib 1.6
|
|||
|
||||
On November 2016, only 4 months after raylib 1.5, arrives raylib 1.6. This new version represents another big review of the library and includes some interesting additions. This version conmmemorates raylib 3rd anniversary (raylib 1.0 was published on November 2013) and it is a stepping stone for raylib future. raylib roadmap has been reviewed and redefined to focus on its primary objective: create a simple and easy-to-use library to learn videogames programming. Some of the new features:
|
||||
|
||||
Complete raylib Lua binding. All raylib functions plus the +60 code examples have been ported to Lua, now Lua users can enjoy coding videogames in Lua while using all the internal power of raylib. This addition also open the doors to Lua scripting support for a future raylib-based engine, being able to move game logic (Init, Update, Draw, De-Init) to Lua scripts while keep using raylib functionality.
|
||||
Complete [raylib Lua binding](https://github.com/raysan5/raylib-lua). All raylib functions plus the +60 code examples have been ported to Lua, now Lua users can enjoy coding videogames in Lua while using all the internal power of raylib. This addition also open the doors to Lua scripting support for a future raylib-based engine, being able to move game logic (Init, Update, Draw, De-Init) to Lua scripts while keep using raylib functionality.
|
||||
|
||||
Completely redesigned audio module. Based on the new direction taken in raylib 1.5, it has been further improved and more functionality added (+20 new functions) to allow raw audio processing and streaming. FLAC file format support has also been added. In the same line, OpenAL Soft backend is now provided as a static library in Windows to allow static linking and get ride of OpenAL32.dll. Now raylib Windows games are completey self-contained, no external libraries required any more!
|
||||
Completely redesigned [audio module](https://github.com/raysan5/raylib/blob/develop/src/audio.c). Based on the new direction taken in raylib 1.5, it has been further improved and more functionality added (+20 new functions) to allow raw audio processing and streaming. [FLAC file format support](https://github.com/raysan5/raylib/blob/develop/src/external/dr_flac.h) has also been added. In the same line, [OpenAL Soft](https://github.com/kcat/openal-soft) backend is now provided as a static library in Windows to allow static linking and get ride of OpenAL32.dll. Now raylib Windows games are completey self-contained, no external libraries required any more!
|
||||
|
||||
Physac module has been moved to its own repository and it has been improved A LOT, actually, library has been completely rewritten from scratch by @victorfisac, multiple samples have been added together with countless new features to match current standard 2D physic libraries. Results are amazing!
|
||||
[Physac](https://github.com/victorfisac/Physac) module has been moved to its own repository and it has been improved A LOT, actually, library has been completely rewritten from scratch by [@victorfisac](https://github.com/victorfisac), multiple samples have been added together with countless new features to match current standard 2D physic libraries. Results are amazing!
|
||||
|
||||
Camera and gestures modules have been reviewed, highly simplified and ported to single-file header-only libraries for easier portability and usage flexibility. Consequently, camera system usage has been simplified in all examples.
|
||||
|
||||
|
@ -159,7 +159,26 @@ Improved Gamepad support on Windows and Raspberry Pi with the addition of new fu
|
|||
|
||||
Improved textures and text functionality, adding new functions for texture filtering control and better TTF/AngelCode fonts loading and generation support.
|
||||
|
||||
Build system improvement. Added support for raylib dynamic library generation (raylib.dll) for users that prefer dynamic library linking. Also thinking on advance users, it has been added pre-configured Visual Studio C++ 2015 solution with raylib project and C/C++ examples for users that prefer that professional IDE and compiler.
|
||||
Build system improvement. Added support for raylib dynamic library generation (raylib.dll) for users that prefer dynamic library linking. Also thinking on advance users, it has been added pre-configured [Visual Studio C++ 2015 solution](https://github.com/raysan5/raylib/tree/master/project/vs2015) with raylib project and C/C++ examples for users that prefer that professional IDE and compiler.
|
||||
|
||||
New examples, new functions, complete code-base review, multiple bugs corrected... this is raylib 1.6. Enjoy making games.
|
||||
|
||||
notes on raylib 1.7
|
||||
-------------------
|
||||
|
||||
On May 2017, around 6 month after raylib 1.6, comes another raylib instalment, raylib 1.7. This time library has been improved a lot in terms of consistency and cleanness. As stated in [this patreon article](https://www.patreon.com/posts/raylib-future-7501034), this new raylib version has focused efforts in becoming more simple and easy-to-use to learn videogames programming. Some highlights of this new version are:
|
||||
|
||||
More than 30 new functions added to the library, functions to control Window, utils to work with filenames and extensions, functions to draw lines with custom thick, mesh loading, functions for 3d ray collisions detailed detection, funtions for VR simulation and much more... Just check [CHANGELOG](CHANGELOG) for a detailed list of additions!
|
||||
|
||||
Support of [configuration flags](https://github.com/raysan5/raylib/issues/200) on every raylib module. Advance users can customize raylib just choosing desired features, defining some configuration flags on modules compilation. That way users can control library size and available functionality.
|
||||
|
||||
Improved [build system](https://github.com/raysan5/raylib/blob/master/src/Makefile) for all supported platforms (Windows, Linux, OSX, RPI, Android, HTML5) with a unique Makefile to compile sources. Added support for Android compilation with a custom standalone toolchain and also multiple build compliation flags.
|
||||
|
||||
New [examples](http://www.raylib.com/examples.html) and [sample games](http://www.raylib.com/games.html) added. All samples material has been reviewed, removing useless examples and adding more comprehensive ones; all material has been ported to latest raylib version and tested in multiple platforms. Examples folder structure has been improved and also build systems.
|
||||
|
||||
Improved library consistency and organization in general. Functions and parameters have been renamed, some parts of the library have been cleaned and simplyfied, some functions has been moved to examples (lighting, Oculus Rift CV1 support) towards a more generic library implementation. Lots of hours have been invested in this process...
|
||||
|
||||
Some other features: Gamepad support on HTML5, RPI touch screen support, 32bit audio support, frames timming 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.
|
||||
|
||||
|
|
346
LICENSE.md
346
LICENSE.md
|
@ -27,7 +27,7 @@ applications, and to alter it and redistribute it freely, subject to the followi
|
|||
fonts
|
||||
------
|
||||
|
||||
All rBMF fonts provided with raylib are free to use (freeware) and have been designed by the following people:
|
||||
The following fonts [provided with raylib](https://github.com/raysan5/raylib/tree/develop/examples/text/resources/fonts) are free to use (freeware) and have been designed by the following people:
|
||||
|
||||
* Alpha Beta - Brian Kent (AEnigma)
|
||||
* Setback - Brian Kent (AEnigma)
|
||||
|
@ -37,345 +37,13 @@ All rBMF fonts provided with raylib are free to use (freeware) and have been des
|
|||
* Mecha - Captain Falcon
|
||||
* PixelPlay - Aleksander Shevchuk
|
||||
* PixAntiqua - Gerhard Großmann
|
||||
|
||||
2d art
|
||||
------
|
||||
|
||||
[scarfy spritesheet](https://github.com/raysan5/raylib/blob/develop/examples/textures/resources/scarfy.png) and [fudesumi image](https://github.com/raysan5/raylib/blob/develop/examples/textures/resources/fudesumi.png) have been created by [Eiden Marsal](https://www.artstation.com/artist/marshall_z) and licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
|
||||
|
||||
3d models
|
||||
---------
|
||||
|
||||
dwarf 3d model used in examples is created by David Moreno and licensed as Creative Commons Attribution-NonCommercial 3.0
|
||||
|
||||
Full license provided below:
|
||||
|
||||
Creative Commons Legal Code
|
||||
|
||||
Attribution-NonCommercial 3.0 Unported
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
|
||||
DAMAGES RESULTING FROM ITS USE.
|
||||
|
||||
License
|
||||
|
||||
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
|
||||
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
|
||||
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
|
||||
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
||||
|
||||
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
|
||||
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
|
||||
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
|
||||
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
|
||||
CONDITIONS.
|
||||
|
||||
1. Definitions
|
||||
|
||||
a. "Adaptation" means a work based upon the Work, or upon the Work and
|
||||
other pre-existing works, such as a translation, adaptation,
|
||||
derivative work, arrangement of music or other alterations of a
|
||||
literary or artistic work, or phonogram or performance and includes
|
||||
cinematographic adaptations or any other form in which the Work may be
|
||||
recast, transformed, or adapted including in any form recognizably
|
||||
derived from the original, except that a work that constitutes a
|
||||
Collection will not be considered an Adaptation for the purpose of
|
||||
this License. For the avoidance of doubt, where the Work is a musical
|
||||
work, performance or phonogram, the synchronization of the Work in
|
||||
timed-relation with a moving image ("synching") will be considered an
|
||||
Adaptation for the purpose of this License.
|
||||
b. "Collection" means a collection of literary or artistic works, such as
|
||||
encyclopedias and anthologies, or performances, phonograms or
|
||||
broadcasts, or other works or subject matter other than works listed
|
||||
in Section 1(f) below, which, by reason of the selection and
|
||||
arrangement of their contents, constitute intellectual creations, in
|
||||
which the Work is included in its entirety in unmodified form along
|
||||
with one or more other contributions, each constituting separate and
|
||||
independent works in themselves, which together are assembled into a
|
||||
collective whole. A work that constitutes a Collection will not be
|
||||
considered an Adaptation (as defined above) for the purposes of this
|
||||
License.
|
||||
c. "Distribute" means to make available to the public the original and
|
||||
copies of the Work or Adaptation, as appropriate, through sale or
|
||||
other transfer of ownership.
|
||||
d. "Licensor" means the individual, individuals, entity or entities that
|
||||
offer(s) the Work under the terms of this License.
|
||||
e. "Original Author" means, in the case of a literary or artistic work,
|
||||
the individual, individuals, entity or entities who created the Work
|
||||
or if no individual or entity can be identified, the publisher; and in
|
||||
addition (i) in the case of a performance the actors, singers,
|
||||
musicians, dancers, and other persons who act, sing, deliver, declaim,
|
||||
play in, interpret or otherwise perform literary or artistic works or
|
||||
expressions of folklore; (ii) in the case of a phonogram the producer
|
||||
being the person or legal entity who first fixes the sounds of a
|
||||
performance or other sounds; and, (iii) in the case of broadcasts, the
|
||||
organization that transmits the broadcast.
|
||||
f. "Work" means the literary and/or artistic work offered under the terms
|
||||
of this License including without limitation any production in the
|
||||
literary, scientific and artistic domain, whatever may be the mode or
|
||||
form of its expression including digital form, such as a book,
|
||||
pamphlet and other writing; a lecture, address, sermon or other work
|
||||
of the same nature; a dramatic or dramatico-musical work; a
|
||||
choreographic work or entertainment in dumb show; a musical
|
||||
composition with or without words; a cinematographic work to which are
|
||||
assimilated works expressed by a process analogous to cinematography;
|
||||
a work of drawing, painting, architecture, sculpture, engraving or
|
||||
lithography; a photographic work to which are assimilated works
|
||||
expressed by a process analogous to photography; a work of applied
|
||||
art; an illustration, map, plan, sketch or three-dimensional work
|
||||
relative to geography, topography, architecture or science; a
|
||||
performance; a broadcast; a phonogram; a compilation of data to the
|
||||
extent it is protected as a copyrightable work; or a work performed by
|
||||
a variety or circus performer to the extent it is not otherwise
|
||||
considered a literary or artistic work.
|
||||
g. "You" means an individual or entity exercising rights under this
|
||||
License who has not previously violated the terms of this License with
|
||||
respect to the Work, or who has received express permission from the
|
||||
Licensor to exercise rights under this License despite a previous
|
||||
violation.
|
||||
h. "Publicly Perform" means to perform public recitations of the Work and
|
||||
to communicate to the public those public recitations, by any means or
|
||||
process, including by wire or wireless means or public digital
|
||||
performances; to make available to the public Works in such a way that
|
||||
members of the public may access these Works from a place and at a
|
||||
place individually chosen by them; to perform the Work to the public
|
||||
by any means or process and the communication to the public of the
|
||||
performances of the Work, including by public digital performance; to
|
||||
broadcast and rebroadcast the Work by any means including signs,
|
||||
sounds or images.
|
||||
i. "Reproduce" means to make copies of the Work by any means including
|
||||
without limitation by sound or visual recordings and the right of
|
||||
fixation and reproducing fixations of the Work, including storage of a
|
||||
protected performance or phonogram in digital form or other electronic
|
||||
medium.
|
||||
|
||||
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
|
||||
limit, or restrict any uses free from copyright or rights arising from
|
||||
limitations or exceptions that are provided for in connection with the
|
||||
copyright protection under copyright law or other applicable laws.
|
||||
|
||||
3. License Grant. Subject to the terms and conditions of this License,
|
||||
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
|
||||
perpetual (for the duration of the applicable copyright) license to
|
||||
exercise the rights in the Work as stated below:
|
||||
|
||||
a. to Reproduce the Work, to incorporate the Work into one or more
|
||||
Collections, and to Reproduce the Work as incorporated in the
|
||||
Collections;
|
||||
b. to create and Reproduce Adaptations provided that any such Adaptation,
|
||||
including any translation in any medium, takes reasonable steps to
|
||||
clearly label, demarcate or otherwise identify that changes were made
|
||||
to the original Work. For example, a translation could be marked "The
|
||||
original work was translated from English to Spanish," or a
|
||||
modification could indicate "The original work has been modified.";
|
||||
c. to Distribute and Publicly Perform the Work including as incorporated
|
||||
in Collections; and,
|
||||
d. to Distribute and Publicly Perform Adaptations.
|
||||
|
||||
The above rights may be exercised in all media and formats whether now
|
||||
known or hereafter devised. The above rights include the right to make
|
||||
such modifications as are technically necessary to exercise the rights in
|
||||
other media and formats. Subject to Section 8(f), all rights not expressly
|
||||
granted by Licensor are hereby reserved, including but not limited to the
|
||||
rights set forth in Section 4(d).
|
||||
|
||||
4. Restrictions. The license granted in Section 3 above is expressly made
|
||||
subject to and limited by the following restrictions:
|
||||
|
||||
a. You may Distribute or Publicly Perform the Work only under the terms
|
||||
of this License. You must include a copy of, or the Uniform Resource
|
||||
Identifier (URI) for, this License with every copy of the Work You
|
||||
Distribute or Publicly Perform. You may not offer or impose any terms
|
||||
on the Work that restrict the terms of this License or the ability of
|
||||
the recipient of the Work to exercise the rights granted to that
|
||||
recipient under the terms of the License. You may not sublicense the
|
||||
Work. You must keep intact all notices that refer to this License and
|
||||
to the disclaimer of warranties with every copy of the Work You
|
||||
Distribute or Publicly Perform. When You Distribute or Publicly
|
||||
Perform the Work, You may not impose any effective technological
|
||||
measures on the Work that restrict the ability of a recipient of the
|
||||
Work from You to exercise the rights granted to that recipient under
|
||||
the terms of the License. This Section 4(a) applies to the Work as
|
||||
incorporated in a Collection, but this does not require the Collection
|
||||
apart from the Work itself to be made subject to the terms of this
|
||||
License. If You create a Collection, upon notice from any Licensor You
|
||||
must, to the extent practicable, remove from the Collection any credit
|
||||
as required by Section 4(c), as requested. If You create an
|
||||
Adaptation, upon notice from any Licensor You must, to the extent
|
||||
practicable, remove from the Adaptation any credit as required by
|
||||
Section 4(c), as requested.
|
||||
b. You may not exercise any of the rights granted to You in Section 3
|
||||
above in any manner that is primarily intended for or directed toward
|
||||
commercial advantage or private monetary compensation. The exchange of
|
||||
the Work for other copyrighted works by means of digital file-sharing
|
||||
or otherwise shall not be considered to be intended for or directed
|
||||
toward commercial advantage or private monetary compensation, provided
|
||||
there is no payment of any monetary compensation in connection with
|
||||
the exchange of copyrighted works.
|
||||
c. If You Distribute, or Publicly Perform the Work or any Adaptations or
|
||||
Collections, You must, unless a request has been made pursuant to
|
||||
Section 4(a), keep intact all copyright notices for the Work and
|
||||
provide, reasonable to the medium or means You are utilizing: (i) the
|
||||
name of the Original Author (or pseudonym, if applicable) if supplied,
|
||||
and/or if the Original Author and/or Licensor designate another party
|
||||
or parties (e.g., a sponsor institute, publishing entity, journal) for
|
||||
attribution ("Attribution Parties") in Licensor's copyright notice,
|
||||
terms of service or by other reasonable means, the name of such party
|
||||
or parties; (ii) the title of the Work if supplied; (iii) to the
|
||||
extent reasonably practicable, the URI, if any, that Licensor
|
||||
specifies to be associated with the Work, unless such URI does not
|
||||
refer to the copyright notice or licensing information for the Work;
|
||||
and, (iv) consistent with Section 3(b), in the case of an Adaptation,
|
||||
a credit identifying the use of the Work in the Adaptation (e.g.,
|
||||
"French translation of the Work by Original Author," or "Screenplay
|
||||
based on original Work by Original Author"). The credit required by
|
||||
this Section 4(c) may be implemented in any reasonable manner;
|
||||
provided, however, that in the case of a Adaptation or Collection, at
|
||||
a minimum such credit will appear, if a credit for all contributing
|
||||
authors of the Adaptation or Collection appears, then as part of these
|
||||
credits and in a manner at least as prominent as the credits for the
|
||||
other contributing authors. For the avoidance of doubt, You may only
|
||||
use the credit required by this Section for the purpose of attribution
|
||||
in the manner set out above and, by exercising Your rights under this
|
||||
License, You may not implicitly or explicitly assert or imply any
|
||||
connection with, sponsorship or endorsement by the Original Author,
|
||||
Licensor and/or Attribution Parties, as appropriate, of You or Your
|
||||
use of the Work, without the separate, express prior written
|
||||
permission of the Original Author, Licensor and/or Attribution
|
||||
Parties.
|
||||
d. For the avoidance of doubt:
|
||||
|
||||
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
|
||||
which the right to collect royalties through any statutory or
|
||||
compulsory licensing scheme cannot be waived, the Licensor
|
||||
reserves the exclusive right to collect such royalties for any
|
||||
exercise by You of the rights granted under this License;
|
||||
ii. Waivable Compulsory License Schemes. In those jurisdictions in
|
||||
which the right to collect royalties through any statutory or
|
||||
compulsory licensing scheme can be waived, the Licensor reserves
|
||||
the exclusive right to collect such royalties for any exercise by
|
||||
You of the rights granted under this License if Your exercise of
|
||||
such rights is for a purpose or use which is otherwise than
|
||||
noncommercial as permitted under Section 4(b) and otherwise waives
|
||||
the right to collect royalties through any statutory or compulsory
|
||||
licensing scheme; and,
|
||||
iii. Voluntary License Schemes. The Licensor reserves the right to
|
||||
collect royalties, whether individually or, in the event that the
|
||||
Licensor is a member of a collecting society that administers
|
||||
voluntary licensing schemes, via that society, from any exercise
|
||||
by You of the rights granted under this License that is for a
|
||||
purpose or use which is otherwise than noncommercial as permitted
|
||||
under Section 4(c).
|
||||
e. Except as otherwise agreed in writing by the Licensor or as may be
|
||||
otherwise permitted by applicable law, if You Reproduce, Distribute or
|
||||
Publicly Perform the Work either by itself or as part of any
|
||||
Adaptations or Collections, You must not distort, mutilate, modify or
|
||||
take other derogatory action in relation to the Work which would be
|
||||
prejudicial to the Original Author's honor or reputation. Licensor
|
||||
agrees that in those jurisdictions (e.g. Japan), in which any exercise
|
||||
of the right granted in Section 3(b) of this License (the right to
|
||||
make Adaptations) would be deemed to be a distortion, mutilation,
|
||||
modification or other derogatory action prejudicial to the Original
|
||||
Author's honor and reputation, the Licensor will waive or not assert,
|
||||
as appropriate, this Section, to the fullest extent permitted by the
|
||||
applicable national law, to enable You to reasonably exercise Your
|
||||
right under Section 3(b) of this License (right to make Adaptations)
|
||||
but not otherwise.
|
||||
|
||||
5. Representations, Warranties and Disclaimer
|
||||
|
||||
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
|
||||
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
|
||||
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
|
||||
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
|
||||
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
|
||||
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
|
||||
OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
|
||||
|
||||
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
|
||||
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
|
||||
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
|
||||
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
|
||||
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
7. Termination
|
||||
|
||||
a. This License and the rights granted hereunder will terminate
|
||||
automatically upon any breach by You of the terms of this License.
|
||||
Individuals or entities who have received Adaptations or Collections
|
||||
from You under this License, however, will not have their licenses
|
||||
terminated provided such individuals or entities remain in full
|
||||
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
|
||||
survive any termination of this License.
|
||||
b. Subject to the above terms and conditions, the license granted here is
|
||||
perpetual (for the duration of the applicable copyright in the Work).
|
||||
Notwithstanding the above, Licensor reserves the right to release the
|
||||
Work under different license terms or to stop distributing the Work at
|
||||
any time; provided, however that any such election will not serve to
|
||||
withdraw this License (or any other license that has been, or is
|
||||
required to be, granted under the terms of this License), and this
|
||||
License will continue in full force and effect unless terminated as
|
||||
stated above.
|
||||
|
||||
8. Miscellaneous
|
||||
|
||||
a. Each time You Distribute or Publicly Perform the Work or a Collection,
|
||||
the Licensor offers to the recipient a license to the Work on the same
|
||||
terms and conditions as the license granted to You under this License.
|
||||
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
|
||||
offers to the recipient a license to the original Work on the same
|
||||
terms and conditions as the license granted to You under this License.
|
||||
c. If any provision of this License is invalid or unenforceable under
|
||||
applicable law, it shall not affect the validity or enforceability of
|
||||
the remainder of the terms of this License, and without further action
|
||||
by the parties to this agreement, such provision shall be reformed to
|
||||
the minimum extent necessary to make such provision valid and
|
||||
enforceable.
|
||||
d. No term or provision of this License shall be deemed waived and no
|
||||
breach consented to unless such waiver or consent shall be in writing
|
||||
and signed by the party to be charged with such waiver or consent.
|
||||
e. This License constitutes the entire agreement between the parties with
|
||||
respect to the Work licensed here. There are no understandings,
|
||||
agreements or representations with respect to the Work not specified
|
||||
here. Licensor shall not be bound by any additional provisions that
|
||||
may appear in any communication from You. This License may not be
|
||||
modified without the mutual written agreement of the Licensor and You.
|
||||
f. The rights granted under, and the subject matter referenced, in this
|
||||
License were drafted utilizing the terminology of the Berne Convention
|
||||
for the Protection of Literary and Artistic Works (as amended on
|
||||
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
|
||||
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
|
||||
and the Universal Copyright Convention (as revised on July 24, 1971).
|
||||
These rights and subject matter take effect in the relevant
|
||||
jurisdiction in which the License terms are sought to be enforced
|
||||
according to the corresponding provisions of the implementation of
|
||||
those treaty provisions in the applicable national law. If the
|
||||
standard suite of rights granted under applicable copyright law
|
||||
includes additional rights not granted under this License, such
|
||||
additional rights are deemed to be included in the License; this
|
||||
License is not intended to restrict the license of any rights under
|
||||
applicable law.
|
||||
|
||||
|
||||
Creative Commons Notice
|
||||
|
||||
Creative Commons is not a party to this License, and makes no warranty
|
||||
whatsoever in connection with the Work. Creative Commons will not be
|
||||
liable to You or any party on any legal theory for any damages
|
||||
whatsoever, including without limitation any general, special,
|
||||
incidental or consequential damages arising in connection to this
|
||||
license. Notwithstanding the foregoing two (2) sentences, if Creative
|
||||
Commons has expressly identified itself as the Licensor hereunder, it
|
||||
shall have all rights and obligations of Licensor.
|
||||
|
||||
Except for the limited purpose of indicating to the public that the
|
||||
Work is licensed under the CCPL, Creative Commons does not authorize
|
||||
the use by either party of the trademark "Creative Commons" or any
|
||||
related trademark or logo of Creative Commons without the prior
|
||||
written consent of Creative Commons. Any permitted use will be in
|
||||
compliance with Creative Commons' then-current trademark usage
|
||||
guidelines, as may be published on its website or otherwise made
|
||||
available upon request from time to time. For the avoidance of doubt,
|
||||
this trademark restriction does not form part of the License.
|
||||
|
||||
Creative Commons may be contacted at https://creativecommons.org/.
|
||||
[dwarf 3d model and textures](https://github.com/raysan5/raylib/tree/develop/examples/models/resources/model) have been created by David Moreno and licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
|
||||
|
|
|
@ -37,11 +37,9 @@ multiplatform (Windows, Linux, Mac) window/context and input management (clean,
|
|||
raylib uses on its [audio](https://github.com/raysan5/raylib/blob/master/src/audio.c) module, [OpenAL Soft](http://kcat.strangesoft.net/openal.html) audio library, in multiple flavours,
|
||||
to accomodate to Android, Raspberry Pi and HTML5.
|
||||
|
||||
On Android, raylib uses `native_app_glue module` (provided by Android NDK) and native Android libraries to manage window/context, inputs and activity life cycle.
|
||||
*On Android, `native_app_glue module` (provided by Android NDK) and native Android libraries are used to manage window/context, inputs and activity life cycle.*
|
||||
|
||||
On Raspberry Pi, raylib uses Videocore API and EGL for window/context management and raw inputs reading.
|
||||
|
||||
raylib is licensed under a zlib/libpng license. View [LICENSE](https://github.com/raysan5/raylib/blob/master/LICENSE.md).
|
||||
*On Raspberry Pi, Videocore API and EGL libraries are used for window/context management and raw inputs reading.*
|
||||
|
||||
building
|
||||
--------
|
||||
|
|
71
ROADMAP.md
71
ROADMAP.md
|
@ -1,48 +1,49 @@
|
|||
roadmap
|
||||
-------
|
||||
|
||||
Current version of raylib is quite complete and functional but there is still a lot of things to add and improve.
|
||||
Here it is a wish list of features I would like to add and functions to improve.
|
||||
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 raylib source code has multiple TODO points with pending things to review and improve. Check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
|
||||
Note that [raylib source code](https://github.com/raysan5/raylib/tree/develop/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 1.x
|
||||
**raylib 1.x**
|
||||
- [ ] Improved Materials system with PBR support
|
||||
- [ ] Basic GPU stats sytem (memory, draws, time...)
|
||||
- [ ] Improved custom file-format (.rres) and packaging tool
|
||||
- [ ] Procedural image generation functions (spot, gradient, noise...)
|
||||
- [ ] Procedural mesh generation functions (cube, cone, sphere...)
|
||||
- [ ] Touch-based camera controls for Android
|
||||
|
||||
Basic GPU stats sytem (memory, draws, time...)
|
||||
Improved custom file-format (.rres) and packaging tool
|
||||
Procedural image generation functions (spot, gradient, noise...)
|
||||
Procedural mesh generation functions (cube, cone, sphere...)
|
||||
Touch-based camera controls for Android
|
||||
Gamepad support on HTML5
|
||||
**raylib 1.7**
|
||||
- [x] Support configuration flags
|
||||
- [x] Improved build system for Android
|
||||
- [x] Gamepad support on HTML5
|
||||
|
||||
raylib 1.6
|
||||
**raylib 1.6**
|
||||
- [x] Lua scripting support (raylib Lua wrapper)
|
||||
- [x] Redesigned audio module
|
||||
- [x] Support FLAC file format
|
||||
|
||||
[DONE] Lua scripting support (raylib Lua wrapper)
|
||||
[DONE] Redesigned audio module
|
||||
**raylib 1.5**
|
||||
- [x] Support Oculus Rift CV1 and VR stereo rendering (simulator)
|
||||
- [x] Redesign Shaders/Textures system -> New Materials system
|
||||
- [x] Support lighting: Omni, Directional and Spot lights
|
||||
- [x] Redesign physics module (physac)
|
||||
- [x] Chiptunes audio modules support
|
||||
|
||||
raylib 1.5
|
||||
|
||||
[DONE] Support Oculus Rift CV1 and VR stereo rendering (simulator)
|
||||
[DONE] Redesign Shaders/Textures system -> New Materials system
|
||||
[DONE] Support lighting: Omni, Directional and Spot lights
|
||||
[DONE] Redesign physics module (physac)
|
||||
[DONE] Chiptunes audio modules support
|
||||
|
||||
raylib 1.4
|
||||
|
||||
[DONE] TTF fonts support (using stb_truetype)
|
||||
[DONE] Raycast system for 3D picking (including collisions detection)
|
||||
[DONE] Floyd-Steinberg dithering on 16bit image format conversion
|
||||
[DONE] Basic image manipulation functions (crop, resize, draw...)
|
||||
[DONE] Storage load/save data functionality
|
||||
[DONE] Add Physics module (physac)
|
||||
[DONE] Remove GLEW dependency -> Replaced by GLAD
|
||||
[DONE] Redesign Raspberry PI inputs system
|
||||
[DONE] Redesign gestures module to be multiplatform
|
||||
[DONE] Module raymath as header-only and functions inline
|
||||
[DONE] Add Easings module (easings.h)
|
||||
**raylib 1.4**
|
||||
- [x] TTF fonts support (using stb_truetype)
|
||||
- [x] Raycast system for 3D picking (including collisions detection)
|
||||
- [x] Floyd-Steinberg dithering on 16bit image format conversion
|
||||
- [x] Basic image manipulation functions (crop, resize, draw...)
|
||||
- [x] Storage load/save data functionality
|
||||
- [x] Add Physics module (physac)
|
||||
- [x] Remove GLEW dependency -> Replaced by GLAD
|
||||
- [x] Redesign Raspberry PI inputs system
|
||||
- [x] Redesign gestures module to be multiplatform
|
||||
- [x] Module raymath as header-only and functions inline
|
||||
- [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"
|
||||
[isssues]: https://github.com/raysan5/raylib/issues
|
||||
|
|
|
@ -473,7 +473,7 @@ typedef struct Ray {
|
|||
Vector3 direction; // Ray direction
|
||||
} Ray;
|
||||
|
||||
// Information returned from a raycast
|
||||
// Raycast hit information
|
||||
typedef struct RayHitInfo {
|
||||
bool hit; // Did the ray hit something?
|
||||
float distance; // Distance to nearest hit
|
||||
|
@ -653,12 +653,13 @@ extern "C" { // Prevents name mangling of functions
|
|||
//------------------------------------------------------------------------------------
|
||||
// Window and Graphics Device Functions (Module: core)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Window-related functions
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
RLAPI void InitWindow(int width, int height, void *state); // Initialize Android activity
|
||||
#elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||
RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context
|
||||
#endif
|
||||
|
||||
RLAPI void CloseWindow(void); // Close window and unload OpenGL context
|
||||
RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed
|
||||
RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
|
||||
|
@ -671,6 +672,7 @@ RLAPI int GetScreenWidth(void); // Get current
|
|||
RLAPI int GetScreenHeight(void); // Get current screen height
|
||||
|
||||
#if !defined(PLATFORM_ANDROID)
|
||||
// Cursor-related functions
|
||||
RLAPI void ShowCursor(void); // Shows cursor
|
||||
RLAPI void HideCursor(void); // Hides cursor
|
||||
RLAPI bool IsCursorHidden(void); // Check if cursor is not visible
|
||||
|
@ -678,10 +680,10 @@ RLAPI void EnableCursor(void); // Enables cur
|
|||
RLAPI void DisableCursor(void); // Disables cursor (lock cursor)
|
||||
#endif
|
||||
|
||||
// Drawing-related functions
|
||||
RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color)
|
||||
RLAPI void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing
|
||||
RLAPI void EndDrawing(void); // End canvas drawing and swap buffers (double buffering)
|
||||
|
||||
RLAPI void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera (2D)
|
||||
RLAPI void End2dMode(void); // Ends 2D mode with custom camera
|
||||
RLAPI void Begin3dMode(Camera camera); // Initializes 3D mode with custom camera (3D)
|
||||
|
@ -689,28 +691,33 @@ RLAPI void End3dMode(void); // Ends 3D mod
|
|||
RLAPI void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing
|
||||
RLAPI void EndTextureMode(void); // Ends drawing to render texture
|
||||
|
||||
// Screen-space-related functions
|
||||
RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position
|
||||
RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position
|
||||
RLAPI Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix)
|
||||
|
||||
// Timming-related functions
|
||||
RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum)
|
||||
RLAPI int GetFPS(void); // Returns current FPS
|
||||
RLAPI float GetFrameTime(void); // Returns time in seconds for last frame drawn
|
||||
|
||||
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
||||
// Color-related functions
|
||||
RLAPI int GetHexValue(Color color); // Returns hexadecimal value for a Color
|
||||
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
||||
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||
RLAPI float *ColorToFloat(Color color); // Converts Color to float array and normalizes
|
||||
RLAPI float *VectorToFloat(Vector3 vec); // Converts Vector3 to float array
|
||||
RLAPI float *MatrixToFloat(Matrix mat); // Converts Matrix to float array
|
||||
|
||||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||
|
||||
// Misc. functions
|
||||
RLAPI void ShowLogo(void); // Activate raylib logo at startup (can be done with flags)
|
||||
RLAPI void SetConfigFlags(char flags); // Setup window configuration flags (view FLAGS)
|
||||
RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (INFO, WARNING, ERROR, DEBUG)
|
||||
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png)
|
||||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||
|
||||
|
||||
// Files management functions
|
||||
RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
|
||||
RLAPI const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path)
|
||||
RLAPI const char *GetWorkingDirectory(void); // Get current working directory
|
||||
|
@ -719,12 +726,15 @@ RLAPI bool IsFileDropped(void); // Check if a
|
|||
RLAPI char **GetDroppedFiles(int *count); // Get dropped files names
|
||||
RLAPI void ClearDroppedFiles(void); // Clear dropped files paths buffer
|
||||
|
||||
// Persistent storage management
|
||||
RLAPI void StorageSaveValue(int position, int value); // Save integer value to storage file (to defined position)
|
||||
RLAPI int StorageLoadValue(int position); // Load integer value from storage file (from defined position)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Input Handling Functions (Module: core)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Input-related functions: keyboard
|
||||
RLAPI bool IsKeyPressed(int key); // Detect if a key has been pressed once
|
||||
RLAPI bool IsKeyDown(int key); // Detect if a key is being pressed
|
||||
RLAPI bool IsKeyReleased(int key); // Detect if a key has been released once
|
||||
|
@ -732,6 +742,7 @@ RLAPI bool IsKeyUp(int key); // Detect if a key
|
|||
RLAPI int GetKeyPressed(void); // Get latest key pressed
|
||||
RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
|
||||
|
||||
// Input-related functions: gamepads
|
||||
RLAPI bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
|
||||
RLAPI bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available)
|
||||
RLAPI const char *GetGamepadName(int gamepad); // Return gamepad internal name id
|
||||
|
@ -743,6 +754,7 @@ RLAPI int GetGamepadButtonPressed(void); // Get the last ga
|
|||
RLAPI int GetGamepadAxisCount(int gamepad); // Return gamepad axis count for a gamepad
|
||||
RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis
|
||||
|
||||
// Input-related functions: mouse
|
||||
RLAPI bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once
|
||||
RLAPI bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed
|
||||
RLAPI bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once
|
||||
|
@ -753,6 +765,7 @@ RLAPI Vector2 GetMousePosition(void); // Returns mouse p
|
|||
RLAPI void SetMousePosition(Vector2 position); // Set mouse position XY
|
||||
RLAPI int GetMouseWheelMove(void); // Returns mouse wheel movement Y
|
||||
|
||||
// Input-related functions: touch
|
||||
RLAPI int GetTouchX(void); // Returns touch position X for touch point 0 (relative to screen size)
|
||||
RLAPI int GetTouchY(void); // Returns touch position Y for touch point 0 (relative to screen size)
|
||||
RLAPI Vector2 GetTouchPosition(int index); // Returns touch position XY for a touch point index (relative to screen size)
|
||||
|
@ -786,6 +799,8 @@ RLAPI void SetCameraMoveControls(int frontKey, int backKey,
|
|||
//------------------------------------------------------------------------------------
|
||||
// Basic Shapes Drawing Functions (Module: shapes)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Basic shapes drawing functions
|
||||
RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel
|
||||
RLAPI void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version)
|
||||
RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line
|
||||
|
@ -808,6 +823,7 @@ RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Col
|
|||
RLAPI void DrawPolyEx(Vector2 *points, int numPoints, Color color); // Draw a closed polygon defined by points
|
||||
RLAPI void DrawPolyExLines(Vector2 *points, int numPoints, Color color); // Draw polygon lines
|
||||
|
||||
// Basic shapes collision detection functions
|
||||
RLAPI bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles
|
||||
RLAPI bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles
|
||||
RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle
|
||||
|
@ -819,6 +835,8 @@ RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Ve
|
|||
//------------------------------------------------------------------------------------
|
||||
// Texture Loading and Drawing Functions (Module: textures)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Image/Texture2D data loading/unloading functions
|
||||
RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM)
|
||||
RLAPI Image LoadImageEx(Color *pixels, int width, int height); // Load image from Color array data (RGBA - 32bit)
|
||||
RLAPI Image LoadImagePro(void *data, int width, int height, int format); // Load image from raw data with parameters
|
||||
|
@ -832,6 +850,8 @@ RLAPI void UnloadRenderTexture(RenderTexture2D target);
|
|||
RLAPI Color *GetImageData(Image image); // Get pixel data from image as a Color struct array
|
||||
RLAPI Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image
|
||||
RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data
|
||||
|
||||
// Image manipulation functions
|
||||
RLAPI void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two)
|
||||
RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
|
||||
RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image
|
||||
|
@ -853,10 +873,13 @@ RLAPI void ImageColorInvert(Image *image);
|
|||
RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale
|
||||
RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100)
|
||||
RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255)
|
||||
|
||||
// Texture2D configuration functions
|
||||
RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture
|
||||
RLAPI void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode
|
||||
RLAPI void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode
|
||||
|
||||
// Texture2D drawing functions
|
||||
RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D
|
||||
RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2
|
||||
RLAPI void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters
|
||||
|
@ -867,24 +890,30 @@ RLAPI void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle dest
|
|||
//------------------------------------------------------------------------------------
|
||||
// Font Loading and Text Drawing Functions (Module: text)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// SpriteFont loading/unloading functions
|
||||
RLAPI SpriteFont GetDefaultFont(void); // Get the default SpriteFont
|
||||
RLAPI SpriteFont LoadSpriteFont(const char *fileName); // Load SpriteFont from file into GPU memory (VRAM)
|
||||
RLAPI SpriteFont LoadSpriteFontEx(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load SpriteFont from file with extended parameters
|
||||
RLAPI void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory (VRAM)
|
||||
|
||||
// Text drawing functions
|
||||
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
||||
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
|
||||
RLAPI void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters
|
||||
float fontSize, int spacing, Color tint);
|
||||
|
||||
// Text misc. functions
|
||||
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
|
||||
RLAPI Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, int spacing); // Measure string size for SpriteFont
|
||||
|
||||
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
||||
RLAPI const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed'
|
||||
RLAPI const char *SubText(const char *text, int position, int length); // Get a piece of a text string
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Basic 3d Shapes Drawing Functions (Module: models)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Basic geometric 3D shapes drawing functions
|
||||
RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space
|
||||
RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space
|
||||
RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube
|
||||
|
@ -905,6 +934,8 @@ RLAPI void DrawGizmo(Vector3 position);
|
|||
//------------------------------------------------------------------------------------
|
||||
// Model 3d Loading and Drawing Functions (Module: models)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Model loading/unloading functions
|
||||
RLAPI Mesh LoadMesh(const char *fileName); // Load mesh from file
|
||||
RLAPI Mesh LoadMeshEx(int numVertex, float *vData, float *vtData, float *vnData, Color *cData); // Load mesh from vertex data
|
||||
RLAPI Model LoadModel(const char *fileName); // Load model from file
|
||||
|
@ -914,10 +945,12 @@ RLAPI Model LoadCubicmap(Image cubicmap);
|
|||
RLAPI void UnloadMesh(Mesh *mesh); // Unload mesh from memory (RAM and/or VRAM)
|
||||
RLAPI void UnloadModel(Model model); // Unload model from memory (RAM and/or VRAM)
|
||||
|
||||
// Material loading/unloading functions
|
||||
RLAPI Material LoadMaterial(const char *fileName); // Load material from file
|
||||
RLAPI Material LoadDefaultMaterial(void); // Load default material (uses default models shader)
|
||||
RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM)
|
||||
|
||||
// Model drawing functions
|
||||
RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
|
||||
RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis,
|
||||
float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters
|
||||
|
@ -925,11 +958,11 @@ RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint
|
|||
RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis,
|
||||
float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters
|
||||
RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)
|
||||
|
||||
RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture
|
||||
RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec,
|
||||
Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec
|
||||
|
||||
// Collision detection functions
|
||||
RLAPI BoundingBox CalculateBoundingBox(Mesh mesh); // Calculate mesh bounding box limits
|
||||
RLAPI bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres
|
||||
RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes
|
||||
|
@ -946,6 +979,8 @@ RLAPI RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight);
|
|||
// Shaders System Functions (Module: rlgl)
|
||||
// NOTE: This functions are useless when using OpenGL 1.1
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Shader loading/unloading functions
|
||||
RLAPI char *LoadText(const char *fileName); // Load chars array from text file
|
||||
RLAPI Shader LoadShader(char *vsFileName, char *fsFileName); // Load shader from files and bind default locations
|
||||
RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM)
|
||||
|
@ -953,39 +988,40 @@ RLAPI void UnloadShader(Shader shader); // Unl
|
|||
RLAPI Shader GetDefaultShader(void); // Get default shader
|
||||
RLAPI Texture2D GetDefaultTexture(void); // Get default texture
|
||||
|
||||
// Shader configuration functions
|
||||
RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
||||
RLAPI void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
|
||||
RLAPI void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
||||
RLAPI void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
||||
|
||||
RLAPI void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
|
||||
RLAPI void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
|
||||
|
||||
// Shading begin/end functions
|
||||
RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
||||
RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader)
|
||||
RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
|
||||
RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// VR experience Functions (Module: rlgl)
|
||||
// NOTE: This functions are useless when using OpenGL 1.1
|
||||
//------------------------------------------------------------------------------------
|
||||
// VR control functions
|
||||
RLAPI void InitVrSimulator(int vrDevice); // Init VR simulator for selected device
|
||||
RLAPI void CloseVrSimulator(void); // Close VR simulator for current device
|
||||
RLAPI bool IsVrSimulatorReady(void); // Detect if VR device is ready
|
||||
RLAPI bool IsVrSimulatorReady(void); // Detect if VR simulator is ready
|
||||
RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
|
||||
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator)
|
||||
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience
|
||||
RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering
|
||||
RLAPI void EndVrDrawing(void); // End VR simulator stereo rendering
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Audio Loading and Playing Functions (Module: audio)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Audio device management functions
|
||||
RLAPI void InitAudioDevice(void); // Initialize audio device and context
|
||||
RLAPI void CloseAudioDevice(void); // Close the audio device and context
|
||||
RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully
|
||||
RLAPI void SetMasterVolume(float volume); // Set master volume (listener)
|
||||
|
||||
// Wave/Sound loading/unloading functions
|
||||
RLAPI Wave LoadWave(const char *fileName); // Load wave data from file
|
||||
RLAPI Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data
|
||||
RLAPI Sound LoadSound(const char *fileName); // Load sound from file
|
||||
|
@ -993,6 +1029,8 @@ RLAPI Sound LoadSoundFromWave(Wave wave); // Load so
|
|||
RLAPI void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data
|
||||
RLAPI void UnloadWave(Wave wave); // Unload wave data
|
||||
RLAPI void UnloadSound(Sound sound); // Unload sound
|
||||
|
||||
// Wave/Sound management functions
|
||||
RLAPI void PlaySound(Sound sound); // Play a sound
|
||||
RLAPI void PauseSound(Sound sound); // Pause a sound
|
||||
RLAPI void ResumeSound(Sound sound); // Resume a paused sound
|
||||
|
@ -1004,6 +1042,8 @@ RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels);
|
|||
RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave
|
||||
RLAPI void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range
|
||||
RLAPI float *GetWaveData(Wave wave); // Get samples data from wave as a floats array
|
||||
|
||||
// Music management functions
|
||||
RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file
|
||||
RLAPI void UnloadMusicStream(Music music); // Unload music stream
|
||||
RLAPI void PlayMusicStream(Music music); // Start music playing
|
||||
|
@ -1018,8 +1058,8 @@ RLAPI void SetMusicLoopCount(Music music, float count); // Set mus
|
|||
RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
||||
RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
|
||||
|
||||
RLAPI AudioStream InitAudioStream(unsigned int sampleRate,
|
||||
unsigned int sampleSize,
|
||||
// AudioStream management functions
|
||||
RLAPI AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize,
|
||||
unsigned int channels); // Init audio stream (to stream raw audio pcm data)
|
||||
RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data
|
||||
RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
|
||||
|
|
Binary file not shown.
|
@ -473,7 +473,7 @@ typedef struct Ray {
|
|||
Vector3 direction; // Ray direction
|
||||
} Ray;
|
||||
|
||||
// Information returned from a raycast
|
||||
// Raycast hit information
|
||||
typedef struct RayHitInfo {
|
||||
bool hit; // Did the ray hit something?
|
||||
float distance; // Distance to nearest hit
|
||||
|
@ -653,12 +653,13 @@ extern "C" { // Prevents name mangling of functions
|
|||
//------------------------------------------------------------------------------------
|
||||
// Window and Graphics Device Functions (Module: core)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Window-related functions
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
RLAPI void InitWindow(int width, int height, void *state); // Initialize Android activity
|
||||
#elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||
RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context
|
||||
#endif
|
||||
|
||||
RLAPI void CloseWindow(void); // Close window and unload OpenGL context
|
||||
RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed
|
||||
RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
|
||||
|
@ -671,6 +672,7 @@ RLAPI int GetScreenWidth(void); // Get current
|
|||
RLAPI int GetScreenHeight(void); // Get current screen height
|
||||
|
||||
#if !defined(PLATFORM_ANDROID)
|
||||
// Cursor-related functions
|
||||
RLAPI void ShowCursor(void); // Shows cursor
|
||||
RLAPI void HideCursor(void); // Hides cursor
|
||||
RLAPI bool IsCursorHidden(void); // Check if cursor is not visible
|
||||
|
@ -678,10 +680,10 @@ RLAPI void EnableCursor(void); // Enables cur
|
|||
RLAPI void DisableCursor(void); // Disables cursor (lock cursor)
|
||||
#endif
|
||||
|
||||
// Drawing-related functions
|
||||
RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color)
|
||||
RLAPI void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing
|
||||
RLAPI void EndDrawing(void); // End canvas drawing and swap buffers (double buffering)
|
||||
|
||||
RLAPI void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera (2D)
|
||||
RLAPI void End2dMode(void); // Ends 2D mode with custom camera
|
||||
RLAPI void Begin3dMode(Camera camera); // Initializes 3D mode with custom camera (3D)
|
||||
|
@ -689,28 +691,33 @@ RLAPI void End3dMode(void); // Ends 3D mod
|
|||
RLAPI void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing
|
||||
RLAPI void EndTextureMode(void); // Ends drawing to render texture
|
||||
|
||||
// Screen-space-related functions
|
||||
RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position
|
||||
RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position
|
||||
RLAPI Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix)
|
||||
|
||||
// Timming-related functions
|
||||
RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum)
|
||||
RLAPI int GetFPS(void); // Returns current FPS
|
||||
RLAPI float GetFrameTime(void); // Returns time in seconds for last frame drawn
|
||||
|
||||
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
||||
// Color-related functions
|
||||
RLAPI int GetHexValue(Color color); // Returns hexadecimal value for a Color
|
||||
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
||||
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||
RLAPI float *ColorToFloat(Color color); // Converts Color to float array and normalizes
|
||||
RLAPI float *VectorToFloat(Vector3 vec); // Converts Vector3 to float array
|
||||
RLAPI float *MatrixToFloat(Matrix mat); // Converts Matrix to float array
|
||||
|
||||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||
|
||||
// Misc. functions
|
||||
RLAPI void ShowLogo(void); // Activate raylib logo at startup (can be done with flags)
|
||||
RLAPI void SetConfigFlags(char flags); // Setup window configuration flags (view FLAGS)
|
||||
RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (INFO, WARNING, ERROR, DEBUG)
|
||||
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png)
|
||||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||
|
||||
|
||||
// Files management functions
|
||||
RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
|
||||
RLAPI const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path)
|
||||
RLAPI const char *GetWorkingDirectory(void); // Get current working directory
|
||||
|
@ -719,12 +726,15 @@ RLAPI bool IsFileDropped(void); // Check if a
|
|||
RLAPI char **GetDroppedFiles(int *count); // Get dropped files names
|
||||
RLAPI void ClearDroppedFiles(void); // Clear dropped files paths buffer
|
||||
|
||||
// Persistent storage management
|
||||
RLAPI void StorageSaveValue(int position, int value); // Save integer value to storage file (to defined position)
|
||||
RLAPI int StorageLoadValue(int position); // Load integer value from storage file (from defined position)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Input Handling Functions (Module: core)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Input-related functions: keyboard
|
||||
RLAPI bool IsKeyPressed(int key); // Detect if a key has been pressed once
|
||||
RLAPI bool IsKeyDown(int key); // Detect if a key is being pressed
|
||||
RLAPI bool IsKeyReleased(int key); // Detect if a key has been released once
|
||||
|
@ -732,6 +742,7 @@ RLAPI bool IsKeyUp(int key); // Detect if a key
|
|||
RLAPI int GetKeyPressed(void); // Get latest key pressed
|
||||
RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
|
||||
|
||||
// Input-related functions: gamepads
|
||||
RLAPI bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
|
||||
RLAPI bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available)
|
||||
RLAPI const char *GetGamepadName(int gamepad); // Return gamepad internal name id
|
||||
|
@ -743,6 +754,7 @@ RLAPI int GetGamepadButtonPressed(void); // Get the last ga
|
|||
RLAPI int GetGamepadAxisCount(int gamepad); // Return gamepad axis count for a gamepad
|
||||
RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis
|
||||
|
||||
// Input-related functions: mouse
|
||||
RLAPI bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once
|
||||
RLAPI bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed
|
||||
RLAPI bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once
|
||||
|
@ -753,6 +765,7 @@ RLAPI Vector2 GetMousePosition(void); // Returns mouse p
|
|||
RLAPI void SetMousePosition(Vector2 position); // Set mouse position XY
|
||||
RLAPI int GetMouseWheelMove(void); // Returns mouse wheel movement Y
|
||||
|
||||
// Input-related functions: touch
|
||||
RLAPI int GetTouchX(void); // Returns touch position X for touch point 0 (relative to screen size)
|
||||
RLAPI int GetTouchY(void); // Returns touch position Y for touch point 0 (relative to screen size)
|
||||
RLAPI Vector2 GetTouchPosition(int index); // Returns touch position XY for a touch point index (relative to screen size)
|
||||
|
@ -786,6 +799,8 @@ RLAPI void SetCameraMoveControls(int frontKey, int backKey,
|
|||
//------------------------------------------------------------------------------------
|
||||
// Basic Shapes Drawing Functions (Module: shapes)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Basic shapes drawing functions
|
||||
RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel
|
||||
RLAPI void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version)
|
||||
RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line
|
||||
|
@ -808,6 +823,7 @@ RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Col
|
|||
RLAPI void DrawPolyEx(Vector2 *points, int numPoints, Color color); // Draw a closed polygon defined by points
|
||||
RLAPI void DrawPolyExLines(Vector2 *points, int numPoints, Color color); // Draw polygon lines
|
||||
|
||||
// Basic shapes collision detection functions
|
||||
RLAPI bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles
|
||||
RLAPI bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles
|
||||
RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle
|
||||
|
@ -819,6 +835,8 @@ RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Ve
|
|||
//------------------------------------------------------------------------------------
|
||||
// Texture Loading and Drawing Functions (Module: textures)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Image/Texture2D data loading/unloading functions
|
||||
RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM)
|
||||
RLAPI Image LoadImageEx(Color *pixels, int width, int height); // Load image from Color array data (RGBA - 32bit)
|
||||
RLAPI Image LoadImagePro(void *data, int width, int height, int format); // Load image from raw data with parameters
|
||||
|
@ -832,6 +850,8 @@ RLAPI void UnloadRenderTexture(RenderTexture2D target);
|
|||
RLAPI Color *GetImageData(Image image); // Get pixel data from image as a Color struct array
|
||||
RLAPI Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image
|
||||
RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data
|
||||
|
||||
// Image manipulation functions
|
||||
RLAPI void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two)
|
||||
RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
|
||||
RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image
|
||||
|
@ -853,10 +873,13 @@ RLAPI void ImageColorInvert(Image *image);
|
|||
RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale
|
||||
RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100)
|
||||
RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255)
|
||||
|
||||
// Texture2D configuration functions
|
||||
RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture
|
||||
RLAPI void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode
|
||||
RLAPI void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode
|
||||
|
||||
// Texture2D drawing functions
|
||||
RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D
|
||||
RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2
|
||||
RLAPI void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters
|
||||
|
@ -867,24 +890,30 @@ RLAPI void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle dest
|
|||
//------------------------------------------------------------------------------------
|
||||
// Font Loading and Text Drawing Functions (Module: text)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// SpriteFont loading/unloading functions
|
||||
RLAPI SpriteFont GetDefaultFont(void); // Get the default SpriteFont
|
||||
RLAPI SpriteFont LoadSpriteFont(const char *fileName); // Load SpriteFont from file into GPU memory (VRAM)
|
||||
RLAPI SpriteFont LoadSpriteFontEx(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load SpriteFont from file with extended parameters
|
||||
RLAPI void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory (VRAM)
|
||||
|
||||
// Text drawing functions
|
||||
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
||||
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
|
||||
RLAPI void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters
|
||||
float fontSize, int spacing, Color tint);
|
||||
|
||||
// Text misc. functions
|
||||
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
|
||||
RLAPI Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, int spacing); // Measure string size for SpriteFont
|
||||
|
||||
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
||||
RLAPI const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed'
|
||||
RLAPI const char *SubText(const char *text, int position, int length); // Get a piece of a text string
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Basic 3d Shapes Drawing Functions (Module: models)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Basic geometric 3D shapes drawing functions
|
||||
RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space
|
||||
RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space
|
||||
RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube
|
||||
|
@ -905,6 +934,8 @@ RLAPI void DrawGizmo(Vector3 position);
|
|||
//------------------------------------------------------------------------------------
|
||||
// Model 3d Loading and Drawing Functions (Module: models)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Model loading/unloading functions
|
||||
RLAPI Mesh LoadMesh(const char *fileName); // Load mesh from file
|
||||
RLAPI Mesh LoadMeshEx(int numVertex, float *vData, float *vtData, float *vnData, Color *cData); // Load mesh from vertex data
|
||||
RLAPI Model LoadModel(const char *fileName); // Load model from file
|
||||
|
@ -914,10 +945,12 @@ RLAPI Model LoadCubicmap(Image cubicmap);
|
|||
RLAPI void UnloadMesh(Mesh *mesh); // Unload mesh from memory (RAM and/or VRAM)
|
||||
RLAPI void UnloadModel(Model model); // Unload model from memory (RAM and/or VRAM)
|
||||
|
||||
// Material loading/unloading functions
|
||||
RLAPI Material LoadMaterial(const char *fileName); // Load material from file
|
||||
RLAPI Material LoadDefaultMaterial(void); // Load default material (uses default models shader)
|
||||
RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM)
|
||||
|
||||
// Model drawing functions
|
||||
RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
|
||||
RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis,
|
||||
float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters
|
||||
|
@ -925,11 +958,11 @@ RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint
|
|||
RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis,
|
||||
float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters
|
||||
RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)
|
||||
|
||||
RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture
|
||||
RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec,
|
||||
Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec
|
||||
|
||||
// Collision detection functions
|
||||
RLAPI BoundingBox CalculateBoundingBox(Mesh mesh); // Calculate mesh bounding box limits
|
||||
RLAPI bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres
|
||||
RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes
|
||||
|
@ -946,6 +979,8 @@ RLAPI RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight);
|
|||
// Shaders System Functions (Module: rlgl)
|
||||
// NOTE: This functions are useless when using OpenGL 1.1
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Shader loading/unloading functions
|
||||
RLAPI char *LoadText(const char *fileName); // Load chars array from text file
|
||||
RLAPI Shader LoadShader(char *vsFileName, char *fsFileName); // Load shader from files and bind default locations
|
||||
RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM)
|
||||
|
@ -953,39 +988,40 @@ RLAPI void UnloadShader(Shader shader); // Unl
|
|||
RLAPI Shader GetDefaultShader(void); // Get default shader
|
||||
RLAPI Texture2D GetDefaultTexture(void); // Get default texture
|
||||
|
||||
// Shader configuration functions
|
||||
RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
||||
RLAPI void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
|
||||
RLAPI void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
||||
RLAPI void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
||||
|
||||
RLAPI void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
|
||||
RLAPI void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
|
||||
|
||||
// Shading begin/end functions
|
||||
RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
||||
RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader)
|
||||
RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
|
||||
RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// VR experience Functions (Module: rlgl)
|
||||
// NOTE: This functions are useless when using OpenGL 1.1
|
||||
//------------------------------------------------------------------------------------
|
||||
// VR control functions
|
||||
RLAPI void InitVrSimulator(int vrDevice); // Init VR simulator for selected device
|
||||
RLAPI void CloseVrSimulator(void); // Close VR simulator for current device
|
||||
RLAPI bool IsVrSimulatorReady(void); // Detect if VR device is ready
|
||||
RLAPI bool IsVrSimulatorReady(void); // Detect if VR simulator is ready
|
||||
RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
|
||||
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator)
|
||||
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience
|
||||
RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering
|
||||
RLAPI void EndVrDrawing(void); // End VR simulator stereo rendering
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Audio Loading and Playing Functions (Module: audio)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Audio device management functions
|
||||
RLAPI void InitAudioDevice(void); // Initialize audio device and context
|
||||
RLAPI void CloseAudioDevice(void); // Close the audio device and context
|
||||
RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully
|
||||
RLAPI void SetMasterVolume(float volume); // Set master volume (listener)
|
||||
|
||||
// Wave/Sound loading/unloading functions
|
||||
RLAPI Wave LoadWave(const char *fileName); // Load wave data from file
|
||||
RLAPI Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data
|
||||
RLAPI Sound LoadSound(const char *fileName); // Load sound from file
|
||||
|
@ -993,6 +1029,8 @@ RLAPI Sound LoadSoundFromWave(Wave wave); // Load so
|
|||
RLAPI void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data
|
||||
RLAPI void UnloadWave(Wave wave); // Unload wave data
|
||||
RLAPI void UnloadSound(Sound sound); // Unload sound
|
||||
|
||||
// Wave/Sound management functions
|
||||
RLAPI void PlaySound(Sound sound); // Play a sound
|
||||
RLAPI void PauseSound(Sound sound); // Pause a sound
|
||||
RLAPI void ResumeSound(Sound sound); // Resume a paused sound
|
||||
|
@ -1004,6 +1042,8 @@ RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels);
|
|||
RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave
|
||||
RLAPI void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range
|
||||
RLAPI float *GetWaveData(Wave wave); // Get samples data from wave as a floats array
|
||||
|
||||
// Music management functions
|
||||
RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file
|
||||
RLAPI void UnloadMusicStream(Music music); // Unload music stream
|
||||
RLAPI void PlayMusicStream(Music music); // Start music playing
|
||||
|
@ -1018,8 +1058,8 @@ RLAPI void SetMusicLoopCount(Music music, float count); // Set mus
|
|||
RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
||||
RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
|
||||
|
||||
RLAPI AudioStream InitAudioStream(unsigned int sampleRate,
|
||||
unsigned int sampleSize,
|
||||
// AudioStream management functions
|
||||
RLAPI AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize,
|
||||
unsigned int channels); // Init audio stream (to stream raw audio pcm data)
|
||||
RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data
|
||||
RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
|
||||
|
|
|
@ -473,7 +473,7 @@ typedef struct Ray {
|
|||
Vector3 direction; // Ray direction
|
||||
} Ray;
|
||||
|
||||
// Information returned from a raycast
|
||||
// Raycast hit information
|
||||
typedef struct RayHitInfo {
|
||||
bool hit; // Did the ray hit something?
|
||||
float distance; // Distance to nearest hit
|
||||
|
@ -653,12 +653,13 @@ extern "C" { // Prevents name mangling of functions
|
|||
//------------------------------------------------------------------------------------
|
||||
// Window and Graphics Device Functions (Module: core)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Window-related functions
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
RLAPI void InitWindow(int width, int height, void *state); // Initialize Android activity
|
||||
#elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||
RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context
|
||||
#endif
|
||||
|
||||
RLAPI void CloseWindow(void); // Close window and unload OpenGL context
|
||||
RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed
|
||||
RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
|
||||
|
@ -671,6 +672,7 @@ RLAPI int GetScreenWidth(void); // Get current
|
|||
RLAPI int GetScreenHeight(void); // Get current screen height
|
||||
|
||||
#if !defined(PLATFORM_ANDROID)
|
||||
// Cursor-related functions
|
||||
RLAPI void ShowCursor(void); // Shows cursor
|
||||
RLAPI void HideCursor(void); // Hides cursor
|
||||
RLAPI bool IsCursorHidden(void); // Check if cursor is not visible
|
||||
|
@ -678,10 +680,10 @@ RLAPI void EnableCursor(void); // Enables cur
|
|||
RLAPI void DisableCursor(void); // Disables cursor (lock cursor)
|
||||
#endif
|
||||
|
||||
// Drawing-related functions
|
||||
RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color)
|
||||
RLAPI void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing
|
||||
RLAPI void EndDrawing(void); // End canvas drawing and swap buffers (double buffering)
|
||||
|
||||
RLAPI void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera (2D)
|
||||
RLAPI void End2dMode(void); // Ends 2D mode with custom camera
|
||||
RLAPI void Begin3dMode(Camera camera); // Initializes 3D mode with custom camera (3D)
|
||||
|
@ -689,28 +691,33 @@ RLAPI void End3dMode(void); // Ends 3D mod
|
|||
RLAPI void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing
|
||||
RLAPI void EndTextureMode(void); // Ends drawing to render texture
|
||||
|
||||
// Screen-space-related functions
|
||||
RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position
|
||||
RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position
|
||||
RLAPI Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix)
|
||||
|
||||
// Timming-related functions
|
||||
RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum)
|
||||
RLAPI int GetFPS(void); // Returns current FPS
|
||||
RLAPI float GetFrameTime(void); // Returns time in seconds for last frame drawn
|
||||
|
||||
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
||||
// Color-related functions
|
||||
RLAPI int GetHexValue(Color color); // Returns hexadecimal value for a Color
|
||||
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
||||
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||
RLAPI float *ColorToFloat(Color color); // Converts Color to float array and normalizes
|
||||
RLAPI float *VectorToFloat(Vector3 vec); // Converts Vector3 to float array
|
||||
RLAPI float *MatrixToFloat(Matrix mat); // Converts Matrix to float array
|
||||
|
||||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||
|
||||
// Misc. functions
|
||||
RLAPI void ShowLogo(void); // Activate raylib logo at startup (can be done with flags)
|
||||
RLAPI void SetConfigFlags(char flags); // Setup window configuration flags (view FLAGS)
|
||||
RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (INFO, WARNING, ERROR, DEBUG)
|
||||
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png)
|
||||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||
|
||||
|
||||
// Files management functions
|
||||
RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
|
||||
RLAPI const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path)
|
||||
RLAPI const char *GetWorkingDirectory(void); // Get current working directory
|
||||
|
@ -719,12 +726,15 @@ RLAPI bool IsFileDropped(void); // Check if a
|
|||
RLAPI char **GetDroppedFiles(int *count); // Get dropped files names
|
||||
RLAPI void ClearDroppedFiles(void); // Clear dropped files paths buffer
|
||||
|
||||
// Persistent storage management
|
||||
RLAPI void StorageSaveValue(int position, int value); // Save integer value to storage file (to defined position)
|
||||
RLAPI int StorageLoadValue(int position); // Load integer value from storage file (from defined position)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Input Handling Functions (Module: core)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Input-related functions: keyboard
|
||||
RLAPI bool IsKeyPressed(int key); // Detect if a key has been pressed once
|
||||
RLAPI bool IsKeyDown(int key); // Detect if a key is being pressed
|
||||
RLAPI bool IsKeyReleased(int key); // Detect if a key has been released once
|
||||
|
@ -732,6 +742,7 @@ RLAPI bool IsKeyUp(int key); // Detect if a key
|
|||
RLAPI int GetKeyPressed(void); // Get latest key pressed
|
||||
RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
|
||||
|
||||
// Input-related functions: gamepads
|
||||
RLAPI bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
|
||||
RLAPI bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available)
|
||||
RLAPI const char *GetGamepadName(int gamepad); // Return gamepad internal name id
|
||||
|
@ -743,6 +754,7 @@ RLAPI int GetGamepadButtonPressed(void); // Get the last ga
|
|||
RLAPI int GetGamepadAxisCount(int gamepad); // Return gamepad axis count for a gamepad
|
||||
RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis
|
||||
|
||||
// Input-related functions: mouse
|
||||
RLAPI bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once
|
||||
RLAPI bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed
|
||||
RLAPI bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once
|
||||
|
@ -753,6 +765,7 @@ RLAPI Vector2 GetMousePosition(void); // Returns mouse p
|
|||
RLAPI void SetMousePosition(Vector2 position); // Set mouse position XY
|
||||
RLAPI int GetMouseWheelMove(void); // Returns mouse wheel movement Y
|
||||
|
||||
// Input-related functions: touch
|
||||
RLAPI int GetTouchX(void); // Returns touch position X for touch point 0 (relative to screen size)
|
||||
RLAPI int GetTouchY(void); // Returns touch position Y for touch point 0 (relative to screen size)
|
||||
RLAPI Vector2 GetTouchPosition(int index); // Returns touch position XY for a touch point index (relative to screen size)
|
||||
|
@ -786,6 +799,8 @@ RLAPI void SetCameraMoveControls(int frontKey, int backKey,
|
|||
//------------------------------------------------------------------------------------
|
||||
// Basic Shapes Drawing Functions (Module: shapes)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Basic shapes drawing functions
|
||||
RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel
|
||||
RLAPI void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version)
|
||||
RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line
|
||||
|
@ -808,6 +823,7 @@ RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Col
|
|||
RLAPI void DrawPolyEx(Vector2 *points, int numPoints, Color color); // Draw a closed polygon defined by points
|
||||
RLAPI void DrawPolyExLines(Vector2 *points, int numPoints, Color color); // Draw polygon lines
|
||||
|
||||
// Basic shapes collision detection functions
|
||||
RLAPI bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles
|
||||
RLAPI bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles
|
||||
RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle
|
||||
|
@ -819,6 +835,8 @@ RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Ve
|
|||
//------------------------------------------------------------------------------------
|
||||
// Texture Loading and Drawing Functions (Module: textures)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Image/Texture2D data loading/unloading functions
|
||||
RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM)
|
||||
RLAPI Image LoadImageEx(Color *pixels, int width, int height); // Load image from Color array data (RGBA - 32bit)
|
||||
RLAPI Image LoadImagePro(void *data, int width, int height, int format); // Load image from raw data with parameters
|
||||
|
@ -832,6 +850,8 @@ RLAPI void UnloadRenderTexture(RenderTexture2D target);
|
|||
RLAPI Color *GetImageData(Image image); // Get pixel data from image as a Color struct array
|
||||
RLAPI Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image
|
||||
RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data
|
||||
|
||||
// Image manipulation functions
|
||||
RLAPI void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two)
|
||||
RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
|
||||
RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image
|
||||
|
@ -853,10 +873,13 @@ RLAPI void ImageColorInvert(Image *image);
|
|||
RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale
|
||||
RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100)
|
||||
RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255)
|
||||
|
||||
// Texture2D configuration functions
|
||||
RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture
|
||||
RLAPI void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode
|
||||
RLAPI void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode
|
||||
|
||||
// Texture2D drawing functions
|
||||
RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D
|
||||
RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2
|
||||
RLAPI void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters
|
||||
|
@ -867,24 +890,30 @@ RLAPI void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle dest
|
|||
//------------------------------------------------------------------------------------
|
||||
// Font Loading and Text Drawing Functions (Module: text)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// SpriteFont loading/unloading functions
|
||||
RLAPI SpriteFont GetDefaultFont(void); // Get the default SpriteFont
|
||||
RLAPI SpriteFont LoadSpriteFont(const char *fileName); // Load SpriteFont from file into GPU memory (VRAM)
|
||||
RLAPI SpriteFont LoadSpriteFontEx(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load SpriteFont from file with extended parameters
|
||||
RLAPI void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory (VRAM)
|
||||
|
||||
// Text drawing functions
|
||||
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
||||
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
|
||||
RLAPI void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters
|
||||
float fontSize, int spacing, Color tint);
|
||||
|
||||
// Text misc. functions
|
||||
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
|
||||
RLAPI Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, int spacing); // Measure string size for SpriteFont
|
||||
|
||||
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
||||
RLAPI const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed'
|
||||
RLAPI const char *SubText(const char *text, int position, int length); // Get a piece of a text string
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Basic 3d Shapes Drawing Functions (Module: models)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Basic geometric 3D shapes drawing functions
|
||||
RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space
|
||||
RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space
|
||||
RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube
|
||||
|
@ -905,6 +934,8 @@ RLAPI void DrawGizmo(Vector3 position);
|
|||
//------------------------------------------------------------------------------------
|
||||
// Model 3d Loading and Drawing Functions (Module: models)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Model loading/unloading functions
|
||||
RLAPI Mesh LoadMesh(const char *fileName); // Load mesh from file
|
||||
RLAPI Mesh LoadMeshEx(int numVertex, float *vData, float *vtData, float *vnData, Color *cData); // Load mesh from vertex data
|
||||
RLAPI Model LoadModel(const char *fileName); // Load model from file
|
||||
|
@ -914,10 +945,12 @@ RLAPI Model LoadCubicmap(Image cubicmap);
|
|||
RLAPI void UnloadMesh(Mesh *mesh); // Unload mesh from memory (RAM and/or VRAM)
|
||||
RLAPI void UnloadModel(Model model); // Unload model from memory (RAM and/or VRAM)
|
||||
|
||||
// Material loading/unloading functions
|
||||
RLAPI Material LoadMaterial(const char *fileName); // Load material from file
|
||||
RLAPI Material LoadDefaultMaterial(void); // Load default material (uses default models shader)
|
||||
RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM)
|
||||
|
||||
// Model drawing functions
|
||||
RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
|
||||
RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis,
|
||||
float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters
|
||||
|
@ -925,11 +958,11 @@ RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint
|
|||
RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis,
|
||||
float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters
|
||||
RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)
|
||||
|
||||
RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture
|
||||
RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec,
|
||||
Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec
|
||||
|
||||
// Collision detection functions
|
||||
RLAPI BoundingBox CalculateBoundingBox(Mesh mesh); // Calculate mesh bounding box limits
|
||||
RLAPI bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres
|
||||
RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes
|
||||
|
@ -946,6 +979,8 @@ RLAPI RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight);
|
|||
// Shaders System Functions (Module: rlgl)
|
||||
// NOTE: This functions are useless when using OpenGL 1.1
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Shader loading/unloading functions
|
||||
RLAPI char *LoadText(const char *fileName); // Load chars array from text file
|
||||
RLAPI Shader LoadShader(char *vsFileName, char *fsFileName); // Load shader from files and bind default locations
|
||||
RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM)
|
||||
|
@ -953,39 +988,40 @@ RLAPI void UnloadShader(Shader shader); // Unl
|
|||
RLAPI Shader GetDefaultShader(void); // Get default shader
|
||||
RLAPI Texture2D GetDefaultTexture(void); // Get default texture
|
||||
|
||||
// Shader configuration functions
|
||||
RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
||||
RLAPI void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
|
||||
RLAPI void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
||||
RLAPI void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
||||
|
||||
RLAPI void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
|
||||
RLAPI void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
|
||||
|
||||
// Shading begin/end functions
|
||||
RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
||||
RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader)
|
||||
RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
|
||||
RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// VR experience Functions (Module: rlgl)
|
||||
// NOTE: This functions are useless when using OpenGL 1.1
|
||||
//------------------------------------------------------------------------------------
|
||||
// VR control functions
|
||||
RLAPI void InitVrSimulator(int vrDevice); // Init VR simulator for selected device
|
||||
RLAPI void CloseVrSimulator(void); // Close VR simulator for current device
|
||||
RLAPI bool IsVrSimulatorReady(void); // Detect if VR device is ready
|
||||
RLAPI bool IsVrSimulatorReady(void); // Detect if VR simulator is ready
|
||||
RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
|
||||
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator)
|
||||
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience
|
||||
RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering
|
||||
RLAPI void EndVrDrawing(void); // End VR simulator stereo rendering
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Audio Loading and Playing Functions (Module: audio)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Audio device management functions
|
||||
RLAPI void InitAudioDevice(void); // Initialize audio device and context
|
||||
RLAPI void CloseAudioDevice(void); // Close the audio device and context
|
||||
RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully
|
||||
RLAPI void SetMasterVolume(float volume); // Set master volume (listener)
|
||||
|
||||
// Wave/Sound loading/unloading functions
|
||||
RLAPI Wave LoadWave(const char *fileName); // Load wave data from file
|
||||
RLAPI Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data
|
||||
RLAPI Sound LoadSound(const char *fileName); // Load sound from file
|
||||
|
@ -993,6 +1029,8 @@ RLAPI Sound LoadSoundFromWave(Wave wave); // Load so
|
|||
RLAPI void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data
|
||||
RLAPI void UnloadWave(Wave wave); // Unload wave data
|
||||
RLAPI void UnloadSound(Sound sound); // Unload sound
|
||||
|
||||
// Wave/Sound management functions
|
||||
RLAPI void PlaySound(Sound sound); // Play a sound
|
||||
RLAPI void PauseSound(Sound sound); // Pause a sound
|
||||
RLAPI void ResumeSound(Sound sound); // Resume a paused sound
|
||||
|
@ -1004,6 +1042,8 @@ RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels);
|
|||
RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave
|
||||
RLAPI void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range
|
||||
RLAPI float *GetWaveData(Wave wave); // Get samples data from wave as a floats array
|
||||
|
||||
// Music management functions
|
||||
RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file
|
||||
RLAPI void UnloadMusicStream(Music music); // Unload music stream
|
||||
RLAPI void PlayMusicStream(Music music); // Start music playing
|
||||
|
@ -1018,8 +1058,8 @@ RLAPI void SetMusicLoopCount(Music music, float count); // Set mus
|
|||
RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
||||
RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
|
||||
|
||||
RLAPI AudioStream InitAudioStream(unsigned int sampleRate,
|
||||
unsigned int sampleSize,
|
||||
// AudioStream management functions
|
||||
RLAPI AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize,
|
||||
unsigned int channels); // Init audio stream (to stream raw audio pcm data)
|
||||
RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data
|
||||
RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
|
||||
|
|
|
@ -473,7 +473,7 @@ typedef struct Ray {
|
|||
Vector3 direction; // Ray direction
|
||||
} Ray;
|
||||
|
||||
// Information returned from a raycast
|
||||
// Raycast hit information
|
||||
typedef struct RayHitInfo {
|
||||
bool hit; // Did the ray hit something?
|
||||
float distance; // Distance to nearest hit
|
||||
|
@ -653,12 +653,13 @@ extern "C" { // Prevents name mangling of functions
|
|||
//------------------------------------------------------------------------------------
|
||||
// Window and Graphics Device Functions (Module: core)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Window-related functions
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
RLAPI void InitWindow(int width, int height, void *state); // Initialize Android activity
|
||||
#elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||
RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context
|
||||
#endif
|
||||
|
||||
RLAPI void CloseWindow(void); // Close window and unload OpenGL context
|
||||
RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed
|
||||
RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
|
||||
|
@ -671,6 +672,7 @@ RLAPI int GetScreenWidth(void); // Get current
|
|||
RLAPI int GetScreenHeight(void); // Get current screen height
|
||||
|
||||
#if !defined(PLATFORM_ANDROID)
|
||||
// Cursor-related functions
|
||||
RLAPI void ShowCursor(void); // Shows cursor
|
||||
RLAPI void HideCursor(void); // Hides cursor
|
||||
RLAPI bool IsCursorHidden(void); // Check if cursor is not visible
|
||||
|
@ -678,10 +680,10 @@ RLAPI void EnableCursor(void); // Enables cur
|
|||
RLAPI void DisableCursor(void); // Disables cursor (lock cursor)
|
||||
#endif
|
||||
|
||||
// Drawing-related functions
|
||||
RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color)
|
||||
RLAPI void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing
|
||||
RLAPI void EndDrawing(void); // End canvas drawing and swap buffers (double buffering)
|
||||
|
||||
RLAPI void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera (2D)
|
||||
RLAPI void End2dMode(void); // Ends 2D mode with custom camera
|
||||
RLAPI void Begin3dMode(Camera camera); // Initializes 3D mode with custom camera (3D)
|
||||
|
@ -689,28 +691,33 @@ RLAPI void End3dMode(void); // Ends 3D mod
|
|||
RLAPI void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing
|
||||
RLAPI void EndTextureMode(void); // Ends drawing to render texture
|
||||
|
||||
// Screen-space-related functions
|
||||
RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position
|
||||
RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position
|
||||
RLAPI Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix)
|
||||
|
||||
// Timming-related functions
|
||||
RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum)
|
||||
RLAPI int GetFPS(void); // Returns current FPS
|
||||
RLAPI float GetFrameTime(void); // Returns time in seconds for last frame drawn
|
||||
|
||||
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
||||
// Color-related functions
|
||||
RLAPI int GetHexValue(Color color); // Returns hexadecimal value for a Color
|
||||
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
||||
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||
RLAPI float *ColorToFloat(Color color); // Converts Color to float array and normalizes
|
||||
RLAPI float *VectorToFloat(Vector3 vec); // Converts Vector3 to float array
|
||||
RLAPI float *MatrixToFloat(Matrix mat); // Converts Matrix to float array
|
||||
|
||||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||
|
||||
// Misc. functions
|
||||
RLAPI void ShowLogo(void); // Activate raylib logo at startup (can be done with flags)
|
||||
RLAPI void SetConfigFlags(char flags); // Setup window configuration flags (view FLAGS)
|
||||
RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (INFO, WARNING, ERROR, DEBUG)
|
||||
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png)
|
||||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||
|
||||
|
||||
// Files management functions
|
||||
RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
|
||||
RLAPI const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path)
|
||||
RLAPI const char *GetWorkingDirectory(void); // Get current working directory
|
||||
|
@ -719,12 +726,15 @@ RLAPI bool IsFileDropped(void); // Check if a
|
|||
RLAPI char **GetDroppedFiles(int *count); // Get dropped files names
|
||||
RLAPI void ClearDroppedFiles(void); // Clear dropped files paths buffer
|
||||
|
||||
// Persistent storage management
|
||||
RLAPI void StorageSaveValue(int position, int value); // Save integer value to storage file (to defined position)
|
||||
RLAPI int StorageLoadValue(int position); // Load integer value from storage file (from defined position)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Input Handling Functions (Module: core)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Input-related functions: keyboard
|
||||
RLAPI bool IsKeyPressed(int key); // Detect if a key has been pressed once
|
||||
RLAPI bool IsKeyDown(int key); // Detect if a key is being pressed
|
||||
RLAPI bool IsKeyReleased(int key); // Detect if a key has been released once
|
||||
|
@ -732,6 +742,7 @@ RLAPI bool IsKeyUp(int key); // Detect if a key
|
|||
RLAPI int GetKeyPressed(void); // Get latest key pressed
|
||||
RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
|
||||
|
||||
// Input-related functions: gamepads
|
||||
RLAPI bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
|
||||
RLAPI bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available)
|
||||
RLAPI const char *GetGamepadName(int gamepad); // Return gamepad internal name id
|
||||
|
@ -743,6 +754,7 @@ RLAPI int GetGamepadButtonPressed(void); // Get the last ga
|
|||
RLAPI int GetGamepadAxisCount(int gamepad); // Return gamepad axis count for a gamepad
|
||||
RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis
|
||||
|
||||
// Input-related functions: mouse
|
||||
RLAPI bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once
|
||||
RLAPI bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed
|
||||
RLAPI bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once
|
||||
|
@ -753,6 +765,7 @@ RLAPI Vector2 GetMousePosition(void); // Returns mouse p
|
|||
RLAPI void SetMousePosition(Vector2 position); // Set mouse position XY
|
||||
RLAPI int GetMouseWheelMove(void); // Returns mouse wheel movement Y
|
||||
|
||||
// Input-related functions: touch
|
||||
RLAPI int GetTouchX(void); // Returns touch position X for touch point 0 (relative to screen size)
|
||||
RLAPI int GetTouchY(void); // Returns touch position Y for touch point 0 (relative to screen size)
|
||||
RLAPI Vector2 GetTouchPosition(int index); // Returns touch position XY for a touch point index (relative to screen size)
|
||||
|
@ -786,6 +799,8 @@ RLAPI void SetCameraMoveControls(int frontKey, int backKey,
|
|||
//------------------------------------------------------------------------------------
|
||||
// Basic Shapes Drawing Functions (Module: shapes)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Basic shapes drawing functions
|
||||
RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel
|
||||
RLAPI void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version)
|
||||
RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line
|
||||
|
@ -808,6 +823,7 @@ RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Col
|
|||
RLAPI void DrawPolyEx(Vector2 *points, int numPoints, Color color); // Draw a closed polygon defined by points
|
||||
RLAPI void DrawPolyExLines(Vector2 *points, int numPoints, Color color); // Draw polygon lines
|
||||
|
||||
// Basic shapes collision detection functions
|
||||
RLAPI bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles
|
||||
RLAPI bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles
|
||||
RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle
|
||||
|
@ -819,6 +835,8 @@ RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Ve
|
|||
//------------------------------------------------------------------------------------
|
||||
// Texture Loading and Drawing Functions (Module: textures)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Image/Texture2D data loading/unloading functions
|
||||
RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM)
|
||||
RLAPI Image LoadImageEx(Color *pixels, int width, int height); // Load image from Color array data (RGBA - 32bit)
|
||||
RLAPI Image LoadImagePro(void *data, int width, int height, int format); // Load image from raw data with parameters
|
||||
|
@ -832,6 +850,8 @@ RLAPI void UnloadRenderTexture(RenderTexture2D target);
|
|||
RLAPI Color *GetImageData(Image image); // Get pixel data from image as a Color struct array
|
||||
RLAPI Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image
|
||||
RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data
|
||||
|
||||
// Image manipulation functions
|
||||
RLAPI void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two)
|
||||
RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
|
||||
RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image
|
||||
|
@ -853,10 +873,13 @@ RLAPI void ImageColorInvert(Image *image);
|
|||
RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale
|
||||
RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100)
|
||||
RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255)
|
||||
|
||||
// Texture2D configuration functions
|
||||
RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture
|
||||
RLAPI void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode
|
||||
RLAPI void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode
|
||||
|
||||
// Texture2D drawing functions
|
||||
RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D
|
||||
RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2
|
||||
RLAPI void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters
|
||||
|
@ -867,24 +890,30 @@ RLAPI void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle dest
|
|||
//------------------------------------------------------------------------------------
|
||||
// Font Loading and Text Drawing Functions (Module: text)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// SpriteFont loading/unloading functions
|
||||
RLAPI SpriteFont GetDefaultFont(void); // Get the default SpriteFont
|
||||
RLAPI SpriteFont LoadSpriteFont(const char *fileName); // Load SpriteFont from file into GPU memory (VRAM)
|
||||
RLAPI SpriteFont LoadSpriteFontEx(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load SpriteFont from file with extended parameters
|
||||
RLAPI void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory (VRAM)
|
||||
|
||||
// Text drawing functions
|
||||
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
||||
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
|
||||
RLAPI void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters
|
||||
float fontSize, int spacing, Color tint);
|
||||
|
||||
// Text misc. functions
|
||||
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
|
||||
RLAPI Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, int spacing); // Measure string size for SpriteFont
|
||||
|
||||
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
||||
RLAPI const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed'
|
||||
RLAPI const char *SubText(const char *text, int position, int length); // Get a piece of a text string
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Basic 3d Shapes Drawing Functions (Module: models)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Basic geometric 3D shapes drawing functions
|
||||
RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space
|
||||
RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space
|
||||
RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube
|
||||
|
@ -905,6 +934,8 @@ RLAPI void DrawGizmo(Vector3 position);
|
|||
//------------------------------------------------------------------------------------
|
||||
// Model 3d Loading and Drawing Functions (Module: models)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Model loading/unloading functions
|
||||
RLAPI Mesh LoadMesh(const char *fileName); // Load mesh from file
|
||||
RLAPI Mesh LoadMeshEx(int numVertex, float *vData, float *vtData, float *vnData, Color *cData); // Load mesh from vertex data
|
||||
RLAPI Model LoadModel(const char *fileName); // Load model from file
|
||||
|
@ -914,10 +945,12 @@ RLAPI Model LoadCubicmap(Image cubicmap);
|
|||
RLAPI void UnloadMesh(Mesh *mesh); // Unload mesh from memory (RAM and/or VRAM)
|
||||
RLAPI void UnloadModel(Model model); // Unload model from memory (RAM and/or VRAM)
|
||||
|
||||
// Material loading/unloading functions
|
||||
RLAPI Material LoadMaterial(const char *fileName); // Load material from file
|
||||
RLAPI Material LoadDefaultMaterial(void); // Load default material (uses default models shader)
|
||||
RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM)
|
||||
|
||||
// Model drawing functions
|
||||
RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
|
||||
RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis,
|
||||
float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters
|
||||
|
@ -925,11 +958,11 @@ RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint
|
|||
RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis,
|
||||
float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters
|
||||
RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)
|
||||
|
||||
RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture
|
||||
RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec,
|
||||
Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec
|
||||
|
||||
// Collision detection functions
|
||||
RLAPI BoundingBox CalculateBoundingBox(Mesh mesh); // Calculate mesh bounding box limits
|
||||
RLAPI bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres
|
||||
RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes
|
||||
|
@ -946,6 +979,8 @@ RLAPI RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight);
|
|||
// Shaders System Functions (Module: rlgl)
|
||||
// NOTE: This functions are useless when using OpenGL 1.1
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Shader loading/unloading functions
|
||||
RLAPI char *LoadText(const char *fileName); // Load chars array from text file
|
||||
RLAPI Shader LoadShader(char *vsFileName, char *fsFileName); // Load shader from files and bind default locations
|
||||
RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM)
|
||||
|
@ -953,39 +988,40 @@ RLAPI void UnloadShader(Shader shader); // Unl
|
|||
RLAPI Shader GetDefaultShader(void); // Get default shader
|
||||
RLAPI Texture2D GetDefaultTexture(void); // Get default texture
|
||||
|
||||
// Shader configuration functions
|
||||
RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
||||
RLAPI void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
|
||||
RLAPI void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
||||
RLAPI void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
||||
|
||||
RLAPI void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
|
||||
RLAPI void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
|
||||
|
||||
// Shading begin/end functions
|
||||
RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
||||
RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader)
|
||||
RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
|
||||
RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// VR experience Functions (Module: rlgl)
|
||||
// NOTE: This functions are useless when using OpenGL 1.1
|
||||
//------------------------------------------------------------------------------------
|
||||
// VR control functions
|
||||
RLAPI void InitVrSimulator(int vrDevice); // Init VR simulator for selected device
|
||||
RLAPI void CloseVrSimulator(void); // Close VR simulator for current device
|
||||
RLAPI bool IsVrSimulatorReady(void); // Detect if VR device is ready
|
||||
RLAPI bool IsVrSimulatorReady(void); // Detect if VR simulator is ready
|
||||
RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
|
||||
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator)
|
||||
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience
|
||||
RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering
|
||||
RLAPI void EndVrDrawing(void); // End VR simulator stereo rendering
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Audio Loading and Playing Functions (Module: audio)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Audio device management functions
|
||||
RLAPI void InitAudioDevice(void); // Initialize audio device and context
|
||||
RLAPI void CloseAudioDevice(void); // Close the audio device and context
|
||||
RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully
|
||||
RLAPI void SetMasterVolume(float volume); // Set master volume (listener)
|
||||
|
||||
// Wave/Sound loading/unloading functions
|
||||
RLAPI Wave LoadWave(const char *fileName); // Load wave data from file
|
||||
RLAPI Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data
|
||||
RLAPI Sound LoadSound(const char *fileName); // Load sound from file
|
||||
|
@ -993,6 +1029,8 @@ RLAPI Sound LoadSoundFromWave(Wave wave); // Load so
|
|||
RLAPI void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data
|
||||
RLAPI void UnloadWave(Wave wave); // Unload wave data
|
||||
RLAPI void UnloadSound(Sound sound); // Unload sound
|
||||
|
||||
// Wave/Sound management functions
|
||||
RLAPI void PlaySound(Sound sound); // Play a sound
|
||||
RLAPI void PauseSound(Sound sound); // Pause a sound
|
||||
RLAPI void ResumeSound(Sound sound); // Resume a paused sound
|
||||
|
@ -1004,6 +1042,8 @@ RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels);
|
|||
RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave
|
||||
RLAPI void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range
|
||||
RLAPI float *GetWaveData(Wave wave); // Get samples data from wave as a floats array
|
||||
|
||||
// Music management functions
|
||||
RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file
|
||||
RLAPI void UnloadMusicStream(Music music); // Unload music stream
|
||||
RLAPI void PlayMusicStream(Music music); // Start music playing
|
||||
|
@ -1018,8 +1058,8 @@ RLAPI void SetMusicLoopCount(Music music, float count); // Set mus
|
|||
RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
||||
RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
|
||||
|
||||
RLAPI AudioStream InitAudioStream(unsigned int sampleRate,
|
||||
unsigned int sampleSize,
|
||||
// AudioStream management functions
|
||||
RLAPI AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize,
|
||||
unsigned int channels); // Init audio stream (to stream raw audio pcm data)
|
||||
RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data
|
||||
RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
|
||||
|
|
|
@ -473,7 +473,7 @@ typedef struct Ray {
|
|||
Vector3 direction; // Ray direction
|
||||
} Ray;
|
||||
|
||||
// Information returned from a raycast
|
||||
// Raycast hit information
|
||||
typedef struct RayHitInfo {
|
||||
bool hit; // Did the ray hit something?
|
||||
float distance; // Distance to nearest hit
|
||||
|
@ -653,12 +653,13 @@ extern "C" { // Prevents name mangling of functions
|
|||
//------------------------------------------------------------------------------------
|
||||
// Window and Graphics Device Functions (Module: core)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Window-related functions
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
RLAPI void InitWindow(int width, int height, void *state); // Initialize Android activity
|
||||
#elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||
RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context
|
||||
#endif
|
||||
|
||||
RLAPI void CloseWindow(void); // Close window and unload OpenGL context
|
||||
RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed
|
||||
RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
|
||||
|
@ -671,6 +672,7 @@ RLAPI int GetScreenWidth(void); // Get current
|
|||
RLAPI int GetScreenHeight(void); // Get current screen height
|
||||
|
||||
#if !defined(PLATFORM_ANDROID)
|
||||
// Cursor-related functions
|
||||
RLAPI void ShowCursor(void); // Shows cursor
|
||||
RLAPI void HideCursor(void); // Hides cursor
|
||||
RLAPI bool IsCursorHidden(void); // Check if cursor is not visible
|
||||
|
@ -678,10 +680,10 @@ RLAPI void EnableCursor(void); // Enables cur
|
|||
RLAPI void DisableCursor(void); // Disables cursor (lock cursor)
|
||||
#endif
|
||||
|
||||
// Drawing-related functions
|
||||
RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color)
|
||||
RLAPI void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing
|
||||
RLAPI void EndDrawing(void); // End canvas drawing and swap buffers (double buffering)
|
||||
|
||||
RLAPI void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera (2D)
|
||||
RLAPI void End2dMode(void); // Ends 2D mode with custom camera
|
||||
RLAPI void Begin3dMode(Camera camera); // Initializes 3D mode with custom camera (3D)
|
||||
|
@ -689,28 +691,33 @@ RLAPI void End3dMode(void); // Ends 3D mod
|
|||
RLAPI void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing
|
||||
RLAPI void EndTextureMode(void); // Ends drawing to render texture
|
||||
|
||||
// Screen-space-related functions
|
||||
RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position
|
||||
RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position
|
||||
RLAPI Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix)
|
||||
|
||||
// Timming-related functions
|
||||
RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum)
|
||||
RLAPI int GetFPS(void); // Returns current FPS
|
||||
RLAPI float GetFrameTime(void); // Returns time in seconds for last frame drawn
|
||||
|
||||
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
||||
// Color-related functions
|
||||
RLAPI int GetHexValue(Color color); // Returns hexadecimal value for a Color
|
||||
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
||||
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||
RLAPI float *ColorToFloat(Color color); // Converts Color to float array and normalizes
|
||||
RLAPI float *VectorToFloat(Vector3 vec); // Converts Vector3 to float array
|
||||
RLAPI float *MatrixToFloat(Matrix mat); // Converts Matrix to float array
|
||||
|
||||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||
|
||||
// Misc. functions
|
||||
RLAPI void ShowLogo(void); // Activate raylib logo at startup (can be done with flags)
|
||||
RLAPI void SetConfigFlags(char flags); // Setup window configuration flags (view FLAGS)
|
||||
RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (INFO, WARNING, ERROR, DEBUG)
|
||||
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png)
|
||||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||
|
||||
|
||||
// Files management functions
|
||||
RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
|
||||
RLAPI const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path)
|
||||
RLAPI const char *GetWorkingDirectory(void); // Get current working directory
|
||||
|
@ -719,12 +726,15 @@ RLAPI bool IsFileDropped(void); // Check if a
|
|||
RLAPI char **GetDroppedFiles(int *count); // Get dropped files names
|
||||
RLAPI void ClearDroppedFiles(void); // Clear dropped files paths buffer
|
||||
|
||||
// Persistent storage management
|
||||
RLAPI void StorageSaveValue(int position, int value); // Save integer value to storage file (to defined position)
|
||||
RLAPI int StorageLoadValue(int position); // Load integer value from storage file (from defined position)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Input Handling Functions (Module: core)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Input-related functions: keyboard
|
||||
RLAPI bool IsKeyPressed(int key); // Detect if a key has been pressed once
|
||||
RLAPI bool IsKeyDown(int key); // Detect if a key is being pressed
|
||||
RLAPI bool IsKeyReleased(int key); // Detect if a key has been released once
|
||||
|
@ -732,6 +742,7 @@ RLAPI bool IsKeyUp(int key); // Detect if a key
|
|||
RLAPI int GetKeyPressed(void); // Get latest key pressed
|
||||
RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
|
||||
|
||||
// Input-related functions: gamepads
|
||||
RLAPI bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
|
||||
RLAPI bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available)
|
||||
RLAPI const char *GetGamepadName(int gamepad); // Return gamepad internal name id
|
||||
|
@ -743,6 +754,7 @@ RLAPI int GetGamepadButtonPressed(void); // Get the last ga
|
|||
RLAPI int GetGamepadAxisCount(int gamepad); // Return gamepad axis count for a gamepad
|
||||
RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis
|
||||
|
||||
// Input-related functions: mouse
|
||||
RLAPI bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once
|
||||
RLAPI bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed
|
||||
RLAPI bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once
|
||||
|
@ -753,6 +765,7 @@ RLAPI Vector2 GetMousePosition(void); // Returns mouse p
|
|||
RLAPI void SetMousePosition(Vector2 position); // Set mouse position XY
|
||||
RLAPI int GetMouseWheelMove(void); // Returns mouse wheel movement Y
|
||||
|
||||
// Input-related functions: touch
|
||||
RLAPI int GetTouchX(void); // Returns touch position X for touch point 0 (relative to screen size)
|
||||
RLAPI int GetTouchY(void); // Returns touch position Y for touch point 0 (relative to screen size)
|
||||
RLAPI Vector2 GetTouchPosition(int index); // Returns touch position XY for a touch point index (relative to screen size)
|
||||
|
@ -786,6 +799,8 @@ RLAPI void SetCameraMoveControls(int frontKey, int backKey,
|
|||
//------------------------------------------------------------------------------------
|
||||
// Basic Shapes Drawing Functions (Module: shapes)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Basic shapes drawing functions
|
||||
RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel
|
||||
RLAPI void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version)
|
||||
RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line
|
||||
|
@ -808,6 +823,7 @@ RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Col
|
|||
RLAPI void DrawPolyEx(Vector2 *points, int numPoints, Color color); // Draw a closed polygon defined by points
|
||||
RLAPI void DrawPolyExLines(Vector2 *points, int numPoints, Color color); // Draw polygon lines
|
||||
|
||||
// Basic shapes collision detection functions
|
||||
RLAPI bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles
|
||||
RLAPI bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles
|
||||
RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle
|
||||
|
@ -819,6 +835,8 @@ RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Ve
|
|||
//------------------------------------------------------------------------------------
|
||||
// Texture Loading and Drawing Functions (Module: textures)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Image/Texture2D data loading/unloading functions
|
||||
RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM)
|
||||
RLAPI Image LoadImageEx(Color *pixels, int width, int height); // Load image from Color array data (RGBA - 32bit)
|
||||
RLAPI Image LoadImagePro(void *data, int width, int height, int format); // Load image from raw data with parameters
|
||||
|
@ -832,6 +850,8 @@ RLAPI void UnloadRenderTexture(RenderTexture2D target);
|
|||
RLAPI Color *GetImageData(Image image); // Get pixel data from image as a Color struct array
|
||||
RLAPI Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image
|
||||
RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data
|
||||
|
||||
// Image manipulation functions
|
||||
RLAPI void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two)
|
||||
RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
|
||||
RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image
|
||||
|
@ -853,10 +873,13 @@ RLAPI void ImageColorInvert(Image *image);
|
|||
RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale
|
||||
RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100)
|
||||
RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255)
|
||||
|
||||
// Texture2D configuration functions
|
||||
RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture
|
||||
RLAPI void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode
|
||||
RLAPI void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode
|
||||
|
||||
// Texture2D drawing functions
|
||||
RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D
|
||||
RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2
|
||||
RLAPI void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters
|
||||
|
@ -867,24 +890,30 @@ RLAPI void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle dest
|
|||
//------------------------------------------------------------------------------------
|
||||
// Font Loading and Text Drawing Functions (Module: text)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// SpriteFont loading/unloading functions
|
||||
RLAPI SpriteFont GetDefaultFont(void); // Get the default SpriteFont
|
||||
RLAPI SpriteFont LoadSpriteFont(const char *fileName); // Load SpriteFont from file into GPU memory (VRAM)
|
||||
RLAPI SpriteFont LoadSpriteFontEx(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load SpriteFont from file with extended parameters
|
||||
RLAPI void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory (VRAM)
|
||||
|
||||
// Text drawing functions
|
||||
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
||||
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
|
||||
RLAPI void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters
|
||||
float fontSize, int spacing, Color tint);
|
||||
|
||||
// Text misc. functions
|
||||
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
|
||||
RLAPI Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, int spacing); // Measure string size for SpriteFont
|
||||
|
||||
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
||||
RLAPI const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed'
|
||||
RLAPI const char *SubText(const char *text, int position, int length); // Get a piece of a text string
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Basic 3d Shapes Drawing Functions (Module: models)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Basic geometric 3D shapes drawing functions
|
||||
RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space
|
||||
RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space
|
||||
RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube
|
||||
|
@ -905,6 +934,8 @@ RLAPI void DrawGizmo(Vector3 position);
|
|||
//------------------------------------------------------------------------------------
|
||||
// Model 3d Loading and Drawing Functions (Module: models)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Model loading/unloading functions
|
||||
RLAPI Mesh LoadMesh(const char *fileName); // Load mesh from file
|
||||
RLAPI Mesh LoadMeshEx(int numVertex, float *vData, float *vtData, float *vnData, Color *cData); // Load mesh from vertex data
|
||||
RLAPI Model LoadModel(const char *fileName); // Load model from file
|
||||
|
@ -914,10 +945,12 @@ RLAPI Model LoadCubicmap(Image cubicmap);
|
|||
RLAPI void UnloadMesh(Mesh *mesh); // Unload mesh from memory (RAM and/or VRAM)
|
||||
RLAPI void UnloadModel(Model model); // Unload model from memory (RAM and/or VRAM)
|
||||
|
||||
// Material loading/unloading functions
|
||||
RLAPI Material LoadMaterial(const char *fileName); // Load material from file
|
||||
RLAPI Material LoadDefaultMaterial(void); // Load default material (uses default models shader)
|
||||
RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM)
|
||||
|
||||
// Model drawing functions
|
||||
RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
|
||||
RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis,
|
||||
float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters
|
||||
|
@ -925,11 +958,11 @@ RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint
|
|||
RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis,
|
||||
float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters
|
||||
RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)
|
||||
|
||||
RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture
|
||||
RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec,
|
||||
Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec
|
||||
|
||||
// Collision detection functions
|
||||
RLAPI BoundingBox CalculateBoundingBox(Mesh mesh); // Calculate mesh bounding box limits
|
||||
RLAPI bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres
|
||||
RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes
|
||||
|
@ -946,6 +979,8 @@ RLAPI RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight);
|
|||
// Shaders System Functions (Module: rlgl)
|
||||
// NOTE: This functions are useless when using OpenGL 1.1
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Shader loading/unloading functions
|
||||
RLAPI char *LoadText(const char *fileName); // Load chars array from text file
|
||||
RLAPI Shader LoadShader(char *vsFileName, char *fsFileName); // Load shader from files and bind default locations
|
||||
RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM)
|
||||
|
@ -953,39 +988,40 @@ RLAPI void UnloadShader(Shader shader); // Unl
|
|||
RLAPI Shader GetDefaultShader(void); // Get default shader
|
||||
RLAPI Texture2D GetDefaultTexture(void); // Get default texture
|
||||
|
||||
// Shader configuration functions
|
||||
RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
||||
RLAPI void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
|
||||
RLAPI void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
||||
RLAPI void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
||||
|
||||
RLAPI void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
|
||||
RLAPI void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
|
||||
|
||||
// Shading begin/end functions
|
||||
RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
||||
RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader)
|
||||
RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
|
||||
RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// VR experience Functions (Module: rlgl)
|
||||
// NOTE: This functions are useless when using OpenGL 1.1
|
||||
//------------------------------------------------------------------------------------
|
||||
// VR control functions
|
||||
RLAPI void InitVrSimulator(int vrDevice); // Init VR simulator for selected device
|
||||
RLAPI void CloseVrSimulator(void); // Close VR simulator for current device
|
||||
RLAPI bool IsVrSimulatorReady(void); // Detect if VR device is ready
|
||||
RLAPI bool IsVrSimulatorReady(void); // Detect if VR simulator is ready
|
||||
RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
|
||||
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator)
|
||||
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience
|
||||
RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering
|
||||
RLAPI void EndVrDrawing(void); // End VR simulator stereo rendering
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Audio Loading and Playing Functions (Module: audio)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Audio device management functions
|
||||
RLAPI void InitAudioDevice(void); // Initialize audio device and context
|
||||
RLAPI void CloseAudioDevice(void); // Close the audio device and context
|
||||
RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully
|
||||
RLAPI void SetMasterVolume(float volume); // Set master volume (listener)
|
||||
|
||||
// Wave/Sound loading/unloading functions
|
||||
RLAPI Wave LoadWave(const char *fileName); // Load wave data from file
|
||||
RLAPI Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data
|
||||
RLAPI Sound LoadSound(const char *fileName); // Load sound from file
|
||||
|
@ -993,6 +1029,8 @@ RLAPI Sound LoadSoundFromWave(Wave wave); // Load so
|
|||
RLAPI void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data
|
||||
RLAPI void UnloadWave(Wave wave); // Unload wave data
|
||||
RLAPI void UnloadSound(Sound sound); // Unload sound
|
||||
|
||||
// Wave/Sound management functions
|
||||
RLAPI void PlaySound(Sound sound); // Play a sound
|
||||
RLAPI void PauseSound(Sound sound); // Pause a sound
|
||||
RLAPI void ResumeSound(Sound sound); // Resume a paused sound
|
||||
|
@ -1004,6 +1042,8 @@ RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels);
|
|||
RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave
|
||||
RLAPI void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range
|
||||
RLAPI float *GetWaveData(Wave wave); // Get samples data from wave as a floats array
|
||||
|
||||
// Music management functions
|
||||
RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file
|
||||
RLAPI void UnloadMusicStream(Music music); // Unload music stream
|
||||
RLAPI void PlayMusicStream(Music music); // Start music playing
|
||||
|
@ -1018,8 +1058,8 @@ RLAPI void SetMusicLoopCount(Music music, float count); // Set mus
|
|||
RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
||||
RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
|
||||
|
||||
RLAPI AudioStream InitAudioStream(unsigned int sampleRate,
|
||||
unsigned int sampleSize,
|
||||
// AudioStream management functions
|
||||
RLAPI AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize,
|
||||
unsigned int channels); // Init audio stream (to stream raw audio pcm data)
|
||||
RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data
|
||||
RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
|
||||
|
|
Binary file not shown.
|
@ -473,7 +473,7 @@ typedef struct Ray {
|
|||
Vector3 direction; // Ray direction
|
||||
} Ray;
|
||||
|
||||
// Information returned from a raycast
|
||||
// Raycast hit information
|
||||
typedef struct RayHitInfo {
|
||||
bool hit; // Did the ray hit something?
|
||||
float distance; // Distance to nearest hit
|
||||
|
@ -653,12 +653,13 @@ extern "C" { // Prevents name mangling of functions
|
|||
//------------------------------------------------------------------------------------
|
||||
// Window and Graphics Device Functions (Module: core)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Window-related functions
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
RLAPI void InitWindow(int width, int height, void *state); // Initialize Android activity
|
||||
#elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||
RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context
|
||||
#endif
|
||||
|
||||
RLAPI void CloseWindow(void); // Close window and unload OpenGL context
|
||||
RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed
|
||||
RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
|
||||
|
@ -671,6 +672,7 @@ RLAPI int GetScreenWidth(void); // Get current
|
|||
RLAPI int GetScreenHeight(void); // Get current screen height
|
||||
|
||||
#if !defined(PLATFORM_ANDROID)
|
||||
// Cursor-related functions
|
||||
RLAPI void ShowCursor(void); // Shows cursor
|
||||
RLAPI void HideCursor(void); // Hides cursor
|
||||
RLAPI bool IsCursorHidden(void); // Check if cursor is not visible
|
||||
|
@ -678,10 +680,10 @@ RLAPI void EnableCursor(void); // Enables cur
|
|||
RLAPI void DisableCursor(void); // Disables cursor (lock cursor)
|
||||
#endif
|
||||
|
||||
// Drawing-related functions
|
||||
RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color)
|
||||
RLAPI void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing
|
||||
RLAPI void EndDrawing(void); // End canvas drawing and swap buffers (double buffering)
|
||||
|
||||
RLAPI void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera (2D)
|
||||
RLAPI void End2dMode(void); // Ends 2D mode with custom camera
|
||||
RLAPI void Begin3dMode(Camera camera); // Initializes 3D mode with custom camera (3D)
|
||||
|
@ -689,28 +691,33 @@ RLAPI void End3dMode(void); // Ends 3D mod
|
|||
RLAPI void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing
|
||||
RLAPI void EndTextureMode(void); // Ends drawing to render texture
|
||||
|
||||
// Screen-space-related functions
|
||||
RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position
|
||||
RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position
|
||||
RLAPI Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix)
|
||||
|
||||
// Timming-related functions
|
||||
RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum)
|
||||
RLAPI int GetFPS(void); // Returns current FPS
|
||||
RLAPI float GetFrameTime(void); // Returns time in seconds for last frame drawn
|
||||
|
||||
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
||||
// Color-related functions
|
||||
RLAPI int GetHexValue(Color color); // Returns hexadecimal value for a Color
|
||||
RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
||||
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||
RLAPI float *ColorToFloat(Color color); // Converts Color to float array and normalizes
|
||||
RLAPI float *VectorToFloat(Vector3 vec); // Converts Vector3 to float array
|
||||
RLAPI float *MatrixToFloat(Matrix mat); // Converts Matrix to float array
|
||||
|
||||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||
|
||||
// Misc. functions
|
||||
RLAPI void ShowLogo(void); // Activate raylib logo at startup (can be done with flags)
|
||||
RLAPI void SetConfigFlags(char flags); // Setup window configuration flags (view FLAGS)
|
||||
RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (INFO, WARNING, ERROR, DEBUG)
|
||||
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png)
|
||||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||
|
||||
|
||||
// Files management functions
|
||||
RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
|
||||
RLAPI const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path)
|
||||
RLAPI const char *GetWorkingDirectory(void); // Get current working directory
|
||||
|
@ -719,12 +726,15 @@ RLAPI bool IsFileDropped(void); // Check if a
|
|||
RLAPI char **GetDroppedFiles(int *count); // Get dropped files names
|
||||
RLAPI void ClearDroppedFiles(void); // Clear dropped files paths buffer
|
||||
|
||||
// Persistent storage management
|
||||
RLAPI void StorageSaveValue(int position, int value); // Save integer value to storage file (to defined position)
|
||||
RLAPI int StorageLoadValue(int position); // Load integer value from storage file (from defined position)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Input Handling Functions (Module: core)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Input-related functions: keyboard
|
||||
RLAPI bool IsKeyPressed(int key); // Detect if a key has been pressed once
|
||||
RLAPI bool IsKeyDown(int key); // Detect if a key is being pressed
|
||||
RLAPI bool IsKeyReleased(int key); // Detect if a key has been released once
|
||||
|
@ -732,6 +742,7 @@ RLAPI bool IsKeyUp(int key); // Detect if a key
|
|||
RLAPI int GetKeyPressed(void); // Get latest key pressed
|
||||
RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
|
||||
|
||||
// Input-related functions: gamepads
|
||||
RLAPI bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
|
||||
RLAPI bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available)
|
||||
RLAPI const char *GetGamepadName(int gamepad); // Return gamepad internal name id
|
||||
|
@ -743,6 +754,7 @@ RLAPI int GetGamepadButtonPressed(void); // Get the last ga
|
|||
RLAPI int GetGamepadAxisCount(int gamepad); // Return gamepad axis count for a gamepad
|
||||
RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis
|
||||
|
||||
// Input-related functions: mouse
|
||||
RLAPI bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once
|
||||
RLAPI bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed
|
||||
RLAPI bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once
|
||||
|
@ -753,6 +765,7 @@ RLAPI Vector2 GetMousePosition(void); // Returns mouse p
|
|||
RLAPI void SetMousePosition(Vector2 position); // Set mouse position XY
|
||||
RLAPI int GetMouseWheelMove(void); // Returns mouse wheel movement Y
|
||||
|
||||
// Input-related functions: touch
|
||||
RLAPI int GetTouchX(void); // Returns touch position X for touch point 0 (relative to screen size)
|
||||
RLAPI int GetTouchY(void); // Returns touch position Y for touch point 0 (relative to screen size)
|
||||
RLAPI Vector2 GetTouchPosition(int index); // Returns touch position XY for a touch point index (relative to screen size)
|
||||
|
@ -786,6 +799,8 @@ RLAPI void SetCameraMoveControls(int frontKey, int backKey,
|
|||
//------------------------------------------------------------------------------------
|
||||
// Basic Shapes Drawing Functions (Module: shapes)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Basic shapes drawing functions
|
||||
RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel
|
||||
RLAPI void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version)
|
||||
RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line
|
||||
|
@ -808,6 +823,7 @@ RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Col
|
|||
RLAPI void DrawPolyEx(Vector2 *points, int numPoints, Color color); // Draw a closed polygon defined by points
|
||||
RLAPI void DrawPolyExLines(Vector2 *points, int numPoints, Color color); // Draw polygon lines
|
||||
|
||||
// Basic shapes collision detection functions
|
||||
RLAPI bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles
|
||||
RLAPI bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles
|
||||
RLAPI bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle
|
||||
|
@ -819,6 +835,8 @@ RLAPI bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Ve
|
|||
//------------------------------------------------------------------------------------
|
||||
// Texture Loading and Drawing Functions (Module: textures)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Image/Texture2D data loading/unloading functions
|
||||
RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM)
|
||||
RLAPI Image LoadImageEx(Color *pixels, int width, int height); // Load image from Color array data (RGBA - 32bit)
|
||||
RLAPI Image LoadImagePro(void *data, int width, int height, int format); // Load image from raw data with parameters
|
||||
|
@ -832,6 +850,8 @@ RLAPI void UnloadRenderTexture(RenderTexture2D target);
|
|||
RLAPI Color *GetImageData(Image image); // Get pixel data from image as a Color struct array
|
||||
RLAPI Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image
|
||||
RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data
|
||||
|
||||
// Image manipulation functions
|
||||
RLAPI void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two)
|
||||
RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
|
||||
RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image
|
||||
|
@ -853,10 +873,13 @@ RLAPI void ImageColorInvert(Image *image);
|
|||
RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale
|
||||
RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100)
|
||||
RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255)
|
||||
|
||||
// Texture2D configuration functions
|
||||
RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture
|
||||
RLAPI void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode
|
||||
RLAPI void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode
|
||||
|
||||
// Texture2D drawing functions
|
||||
RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D
|
||||
RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2
|
||||
RLAPI void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters
|
||||
|
@ -867,24 +890,30 @@ RLAPI void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle dest
|
|||
//------------------------------------------------------------------------------------
|
||||
// Font Loading and Text Drawing Functions (Module: text)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// SpriteFont loading/unloading functions
|
||||
RLAPI SpriteFont GetDefaultFont(void); // Get the default SpriteFont
|
||||
RLAPI SpriteFont LoadSpriteFont(const char *fileName); // Load SpriteFont from file into GPU memory (VRAM)
|
||||
RLAPI SpriteFont LoadSpriteFontEx(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load SpriteFont from file with extended parameters
|
||||
RLAPI void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory (VRAM)
|
||||
|
||||
// Text drawing functions
|
||||
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
||||
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
|
||||
RLAPI void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters
|
||||
float fontSize, int spacing, Color tint);
|
||||
|
||||
// Text misc. functions
|
||||
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
|
||||
RLAPI Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, int spacing); // Measure string size for SpriteFont
|
||||
|
||||
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
||||
RLAPI const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed'
|
||||
RLAPI const char *SubText(const char *text, int position, int length); // Get a piece of a text string
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Basic 3d Shapes Drawing Functions (Module: models)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Basic geometric 3D shapes drawing functions
|
||||
RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space
|
||||
RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space
|
||||
RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube
|
||||
|
@ -905,6 +934,8 @@ RLAPI void DrawGizmo(Vector3 position);
|
|||
//------------------------------------------------------------------------------------
|
||||
// Model 3d Loading and Drawing Functions (Module: models)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Model loading/unloading functions
|
||||
RLAPI Mesh LoadMesh(const char *fileName); // Load mesh from file
|
||||
RLAPI Mesh LoadMeshEx(int numVertex, float *vData, float *vtData, float *vnData, Color *cData); // Load mesh from vertex data
|
||||
RLAPI Model LoadModel(const char *fileName); // Load model from file
|
||||
|
@ -914,10 +945,12 @@ RLAPI Model LoadCubicmap(Image cubicmap);
|
|||
RLAPI void UnloadMesh(Mesh *mesh); // Unload mesh from memory (RAM and/or VRAM)
|
||||
RLAPI void UnloadModel(Model model); // Unload model from memory (RAM and/or VRAM)
|
||||
|
||||
// Material loading/unloading functions
|
||||
RLAPI Material LoadMaterial(const char *fileName); // Load material from file
|
||||
RLAPI Material LoadDefaultMaterial(void); // Load default material (uses default models shader)
|
||||
RLAPI void UnloadMaterial(Material material); // Unload material from GPU memory (VRAM)
|
||||
|
||||
// Model drawing functions
|
||||
RLAPI void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
|
||||
RLAPI void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis,
|
||||
float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters
|
||||
|
@ -925,11 +958,11 @@ RLAPI void DrawModelWires(Model model, Vector3 position, float scale, Color tint
|
|||
RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis,
|
||||
float rotationAngle, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters
|
||||
RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)
|
||||
|
||||
RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture
|
||||
RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec,
|
||||
Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec
|
||||
|
||||
// Collision detection functions
|
||||
RLAPI BoundingBox CalculateBoundingBox(Mesh mesh); // Calculate mesh bounding box limits
|
||||
RLAPI bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres
|
||||
RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes
|
||||
|
@ -946,6 +979,8 @@ RLAPI RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight);
|
|||
// Shaders System Functions (Module: rlgl)
|
||||
// NOTE: This functions are useless when using OpenGL 1.1
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Shader loading/unloading functions
|
||||
RLAPI char *LoadText(const char *fileName); // Load chars array from text file
|
||||
RLAPI Shader LoadShader(char *vsFileName, char *fsFileName); // Load shader from files and bind default locations
|
||||
RLAPI void UnloadShader(Shader shader); // Unload shader from GPU memory (VRAM)
|
||||
|
@ -953,39 +988,40 @@ RLAPI void UnloadShader(Shader shader); // Unl
|
|||
RLAPI Shader GetDefaultShader(void); // Get default shader
|
||||
RLAPI Texture2D GetDefaultTexture(void); // Get default texture
|
||||
|
||||
// Shader configuration functions
|
||||
RLAPI int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
||||
RLAPI void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
|
||||
RLAPI void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
||||
RLAPI void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
||||
|
||||
RLAPI void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
|
||||
RLAPI void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
|
||||
|
||||
// Shading begin/end functions
|
||||
RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
||||
RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader)
|
||||
RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
|
||||
RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// VR experience Functions (Module: rlgl)
|
||||
// NOTE: This functions are useless when using OpenGL 1.1
|
||||
//------------------------------------------------------------------------------------
|
||||
// VR control functions
|
||||
RLAPI void InitVrSimulator(int vrDevice); // Init VR simulator for selected device
|
||||
RLAPI void CloseVrSimulator(void); // Close VR simulator for current device
|
||||
RLAPI bool IsVrSimulatorReady(void); // Detect if VR device is ready
|
||||
RLAPI bool IsVrSimulatorReady(void); // Detect if VR simulator is ready
|
||||
RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
|
||||
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator)
|
||||
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience
|
||||
RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering
|
||||
RLAPI void EndVrDrawing(void); // End VR simulator stereo rendering
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Audio Loading and Playing Functions (Module: audio)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Audio device management functions
|
||||
RLAPI void InitAudioDevice(void); // Initialize audio device and context
|
||||
RLAPI void CloseAudioDevice(void); // Close the audio device and context
|
||||
RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully
|
||||
RLAPI void SetMasterVolume(float volume); // Set master volume (listener)
|
||||
|
||||
// Wave/Sound loading/unloading functions
|
||||
RLAPI Wave LoadWave(const char *fileName); // Load wave data from file
|
||||
RLAPI Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data
|
||||
RLAPI Sound LoadSound(const char *fileName); // Load sound from file
|
||||
|
@ -993,6 +1029,8 @@ RLAPI Sound LoadSoundFromWave(Wave wave); // Load so
|
|||
RLAPI void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data
|
||||
RLAPI void UnloadWave(Wave wave); // Unload wave data
|
||||
RLAPI void UnloadSound(Sound sound); // Unload sound
|
||||
|
||||
// Wave/Sound management functions
|
||||
RLAPI void PlaySound(Sound sound); // Play a sound
|
||||
RLAPI void PauseSound(Sound sound); // Pause a sound
|
||||
RLAPI void ResumeSound(Sound sound); // Resume a paused sound
|
||||
|
@ -1004,6 +1042,8 @@ RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels);
|
|||
RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave
|
||||
RLAPI void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range
|
||||
RLAPI float *GetWaveData(Wave wave); // Get samples data from wave as a floats array
|
||||
|
||||
// Music management functions
|
||||
RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file
|
||||
RLAPI void UnloadMusicStream(Music music); // Unload music stream
|
||||
RLAPI void PlayMusicStream(Music music); // Start music playing
|
||||
|
@ -1018,8 +1058,8 @@ RLAPI void SetMusicLoopCount(Music music, float count); // Set mus
|
|||
RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
||||
RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
|
||||
|
||||
RLAPI AudioStream InitAudioStream(unsigned int sampleRate,
|
||||
unsigned int sampleSize,
|
||||
// AudioStream management functions
|
||||
RLAPI AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize,
|
||||
unsigned int channels); // Init audio stream (to stream raw audio pcm data)
|
||||
RLAPI void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data
|
||||
RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
|
||||
|
|
|
@ -232,11 +232,7 @@ endif
|
|||
INCLUDES = -I. -Iexternal
|
||||
|
||||
# OpenAL Soft library
|
||||
ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
||||
INCLUDES += -Iandroid/jni/include/AL
|
||||
else
|
||||
INCLUDES += -Iexternal/openal_soft/include
|
||||
endif
|
||||
INCLUDES += -Iexternal/openal_soft/include
|
||||
|
||||
# define any directories containing required header files
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
|
@ -257,7 +253,7 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
|||
# Android required libraries
|
||||
INCLUDES += -I$(ANDROID_TOOLCHAIN)/sysroot/usr/include
|
||||
# Include android_native_app_glue.h
|
||||
INCLUDES += -Iandroid/jni/include
|
||||
INCLUDES += -Iexternal/android/native_app_glue
|
||||
#INCLUDES += -I$(ANDROID_NDK)/sources/android/native_app_glue
|
||||
endif
|
||||
|
||||
|
|
87
src/core.c
87
src/core.c
|
@ -44,6 +44,9 @@
|
|||
* #define SUPPORT_BUSY_WAIT_LOOP
|
||||
* Use busy wait loop for timming sync, if not defined, a high-resolution timer is setup and used
|
||||
*
|
||||
* #define SUPPORT_GIF_RECORDING
|
||||
* Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
* GLFW3 - Manage graphic device, OpenGL context and inputs on PLATFORM_DESKTOP (Windows, Linux, OSX)
|
||||
* raymath - 3D math functionality (Vector3, Matrix, Quaternion)
|
||||
|
@ -79,6 +82,7 @@
|
|||
#define SUPPORT_CAMERA_SYSTEM
|
||||
#define SUPPORT_GESTURES_SYSTEM
|
||||
#define SUPPORT_BUSY_WAIT_LOOP
|
||||
#define SUPPORT_GIF_RECORDING
|
||||
//-------------------------------------------------
|
||||
|
||||
#include "raylib.h"
|
||||
|
@ -97,7 +101,12 @@
|
|||
|
||||
#if defined(SUPPORT_CAMERA_SYSTEM) && !defined(PLATFORM_ANDROID)
|
||||
#define CAMERA_IMPLEMENTATION
|
||||
#include "camera.h" // Camera system functionality
|
||||
#include "camera.h" // Camera system functionality
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_GIF_RECORDING)
|
||||
#define GIF_IMPLEMENTATION
|
||||
#include "external/gif.h" // Support GIF recording
|
||||
#endif
|
||||
|
||||
#include <stdio.h> // Standard input / output lib
|
||||
|
@ -318,6 +327,12 @@ static double targetTime = 0.0; // Desired time for one frame, if 0
|
|||
static char configFlags = 0; // Configuration flags (bit based)
|
||||
static bool showLogo = false; // Track if showing logo at init is enabled
|
||||
|
||||
#if defined(SUPPORT_GIF_RECORDING)
|
||||
static GifWriter gifWriter;
|
||||
static int gifFramesCounter = 0;
|
||||
static bool gifRecording = false;
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Other Modules Functions Declaration (required by core)
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -520,6 +535,14 @@ void InitWindow(int width, int height, void *state)
|
|||
// Close window and unload OpenGL context
|
||||
void CloseWindow(void)
|
||||
{
|
||||
#if defined(SUPPORT_GIF_RECORDING)
|
||||
if (gifRecording)
|
||||
{
|
||||
GifEnd(&gifWriter);
|
||||
gifRecording = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_DEFAULT_FONT)
|
||||
UnloadDefaultFont();
|
||||
#endif
|
||||
|
@ -770,6 +793,35 @@ void EndDrawing(void)
|
|||
{
|
||||
rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2)
|
||||
|
||||
#if defined(SUPPORT_GIF_RECORDING)
|
||||
|
||||
#define GIF_RECORD_FRAMERATE 10
|
||||
|
||||
if (gifRecording)
|
||||
{
|
||||
gifFramesCounter++;
|
||||
|
||||
// NOTE: We record one gif frame every 10 game frames
|
||||
if ((gifFramesCounter%GIF_RECORD_FRAMERATE) == 0)
|
||||
{
|
||||
// Get image data for the current frame (from backbuffer)
|
||||
// NOTE: This process is very slow... :(
|
||||
unsigned char *screenData = rlglReadScreenPixels(screenWidth, screenHeight);
|
||||
GifWriteFrame(&gifWriter, screenData, screenWidth, screenHeight, 10, 8, false);
|
||||
|
||||
free(screenData); // Free image data
|
||||
}
|
||||
|
||||
if (((gifFramesCounter/15)%2) == 1)
|
||||
{
|
||||
DrawCircle(30, screenHeight - 20, 10, RED);
|
||||
DrawText("RECORDING", 50, screenHeight - 25, 10, MAROON);
|
||||
}
|
||||
|
||||
rlglDraw(); // Draw RECORDING message
|
||||
}
|
||||
#endif
|
||||
|
||||
SwapBuffers(); // Copy back buffer to front buffer
|
||||
PollInputEvents(); // Poll user events
|
||||
|
||||
|
@ -2397,10 +2449,37 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
|
|||
#if defined(PLATFORM_DESKTOP)
|
||||
else if (key == GLFW_KEY_F12 && action == GLFW_PRESS)
|
||||
{
|
||||
TakeScreenshot(FormatText("screenshot%03i.png", screenshotCounter));
|
||||
screenshotCounter++;
|
||||
#if defined(SUPPORT_GIF_RECORDING)
|
||||
if (mods == GLFW_MOD_CONTROL)
|
||||
{
|
||||
if (gifRecording)
|
||||
{
|
||||
GifEnd(&gifWriter);
|
||||
gifRecording = false;
|
||||
|
||||
TraceLog(INFO, "End animated GIF recording");
|
||||
}
|
||||
else
|
||||
{
|
||||
gifRecording = true;
|
||||
gifFramesCounter = 0;
|
||||
|
||||
// NOTE: delay represents the time between frames in the gif, if we capture a gif frame every
|
||||
// 10 game frames and each frame trakes 16.6ms (60fps), delay between gif frames should be ~16.6*10.
|
||||
GifBegin(&gifWriter, FormatText("screenrec%03i.gif", screenshotCounter), screenWidth, screenHeight, (int)(GetFrameTime()*10.0f), 8, false);
|
||||
screenshotCounter++;
|
||||
|
||||
TraceLog(INFO, "Begin animated GIF recording: %s", FormatText("screenrec%03i.gif", screenshotCounter));
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif // SUPPORT_GIF_RECORDING
|
||||
{
|
||||
TakeScreenshot(FormatText("screenshot%03i.png", screenshotCounter));
|
||||
screenshotCounter++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // PLATFORM_DESKTOP
|
||||
else
|
||||
{
|
||||
currentKeyState[key] = action;
|
||||
|
|
931
src/external/gif.h
vendored
Normal file
931
src/external/gif.h
vendored
Normal file
|
@ -0,0 +1,931 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* gif.h by Charlie Tangora [ctangora -at- gmail -dot- com]
|
||||
* adapted to C99 and reformatted by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* This file offers a simple, very limited way to create animated GIFs directly in code.
|
||||
*
|
||||
* Those looking for particular cleverness are likely to be disappointed; it's pretty
|
||||
* much a straight-ahead implementation of the GIF format with optional Floyd-Steinberg
|
||||
* dithering. (It does at least use delta encoding - only the changed portions of each
|
||||
* frame are saved.)
|
||||
*
|
||||
* So resulting files are often quite large. The hope is that it will be handy nonetheless
|
||||
* as a quick and easily-integrated way for programs to spit out animations.
|
||||
*
|
||||
* Only RGBA8 is currently supported as an input format. (The alpha is ignored.)
|
||||
*
|
||||
* CONFIGURATION:
|
||||
*
|
||||
* #define GIF_IMPLEMENTATION
|
||||
* Generates the implementation of the library into the included file.
|
||||
* If not defined, the library is in header only mode and can be included in other headers
|
||||
* or source files without problems. But only ONE file should hold the implementation.
|
||||
*
|
||||
* USAGE:
|
||||
* 1) Create a GifWriter struct. Pass it to GifBegin() to initialize and write the header.
|
||||
* 2) Pass subsequent frames to GifWriteFrame().
|
||||
* 3) Finally, call GifEnd() to close the file handle and free memory.
|
||||
*
|
||||
*
|
||||
* LICENSE: public domain (www.unlicense.org)
|
||||
*
|
||||
* This is free and unencumbered software released into the public domain.
|
||||
* Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||
* software, either in source code form or as a compiled binary, for any purpose,
|
||||
* commercial or non-commercial, and by any means.
|
||||
*
|
||||
* In jurisdictions that recognize copyright laws, the author or authors of this
|
||||
* software dedicate any and all copyright interest in the software to the public
|
||||
* domain. We make this dedication for the benefit of the public at large and to
|
||||
* the detriment of our heirs and successors. We intend this dedication to be an
|
||||
* overt act of relinquishment in perpetuity of all present and future rights to
|
||||
* this software under copyright law.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#ifndef GIF_H
|
||||
#define GIF_H
|
||||
|
||||
#include <stdio.h> // Required for: FILE
|
||||
#include <stdint.h> // Required for for integer typedefs
|
||||
|
||||
//#define GIF_STATIC
|
||||
#ifdef GIF_STATIC
|
||||
#define GIFDEF static // Functions just visible to module including this file
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
#define GIFDEF extern "C" // Functions visible from other files (no name mangling of functions in C++)
|
||||
#else
|
||||
#define GIFDEF extern // Functions visible from other files
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Defines and Macros
|
||||
//----------------------------------------------------------------------------------
|
||||
//#define MAX_RESOURCES_SUPPORTED 256
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
typedef struct GifWriter {
|
||||
FILE *f;
|
||||
uint8_t *oldImage;
|
||||
bool firstFrame;
|
||||
} GifWriter;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global variables
|
||||
//----------------------------------------------------------------------------------
|
||||
//...
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// NOTE: By default use bitDepth = 8, dither = false
|
||||
GIFDEF bool GifBegin(GifWriter *writer, const char *filename, uint32_t width, uint32_t height, uint32_t delay, int32_t bitDepth, bool dither);
|
||||
GIFDEF bool GifWriteFrame(GifWriter *writer, const uint8_t *image, uint32_t width, uint32_t height, uint32_t delay, int bitDepth, bool dither);
|
||||
GIFDEF bool GifEnd(GifWriter *writer);
|
||||
|
||||
#endif // GIF_H
|
||||
|
||||
|
||||
/***********************************************************************************
|
||||
*
|
||||
* GIF IMPLEMENTATION
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#if defined(GIF_IMPLEMENTATION)
|
||||
|
||||
#include <stdio.h> // Required for: FILE, fopen(), fclose()
|
||||
#include <string.h> // Required for: memcpy()
|
||||
#include <stdint.h> // Required for for integer typedefs
|
||||
|
||||
// Define these macros to hook into a custom memory allocator.
|
||||
// GIF_TEMP_MALLOC and GIF_TEMP_FREE will only be called in stack fashion - frees in the reverse order of mallocs
|
||||
// and any temp memory allocated by a function will be freed before it exits.
|
||||
#if !defined(GIF_TEMP_MALLOC)
|
||||
#include <stdlib.h>
|
||||
|
||||
#define GIF_TEMP_MALLOC malloc
|
||||
#define GIF_TEMP_FREE free
|
||||
#endif
|
||||
|
||||
// Check if custom malloc/free functions defined, if not, using standard ones
|
||||
// GIF_MALLOC and GIF_FREE are used only by GifBegin and GifEnd respectively,
|
||||
// to allocate a buffer the size of the image, which is used to find changed pixels for delta-encoding.
|
||||
#if !defined(GIF_MALLOC)
|
||||
#include <stdlib.h> // Required for: malloc(), free()
|
||||
|
||||
#define GIF_MALLOC(size) malloc(size)
|
||||
#define GIF_FREE(ptr) free(ptr)
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Defines and Macros
|
||||
//----------------------------------------------------------------------------------
|
||||
#define GIFMIN(a, b) (((a)<(b))?(a):(b))
|
||||
#define GIFMAX(a, b) (((a)>(b))?(a):(b))
|
||||
#define GIFABS(x) ((x)<0?-(x):(x))
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
//Gif palette structure
|
||||
typedef struct GifPalette {
|
||||
int bitDepth;
|
||||
|
||||
uint8_t r[256];
|
||||
uint8_t g[256];
|
||||
uint8_t b[256];
|
||||
|
||||
// k-d tree over RGB space, organized in heap fashion
|
||||
// i.e. left child of node i is node i*2, right child is node i*2 + 1
|
||||
// nodes 256-511 are implicitly the leaves, containing a color
|
||||
uint8_t treeSplitElt[255];
|
||||
uint8_t treeSplit[255];
|
||||
} GifPalette;
|
||||
|
||||
|
||||
// Simple structure to write out the LZW-compressed
|
||||
// portion of the imageone bit at a time
|
||||
typedef struct GifBitStatus {
|
||||
uint8_t bitIndex; // how many bits in the partial byte written so far
|
||||
uint8_t byte; // current partial byte
|
||||
|
||||
uint32_t chunkIndex;
|
||||
uint8_t chunk[256]; // bytes are written in here until we have 256 of them, then written to the file
|
||||
} GifBitStatus;
|
||||
|
||||
// The LZW dictionary is a 256-ary tree constructed
|
||||
// as the file is encoded, this is one node
|
||||
typedef struct GifLzwNode {
|
||||
uint16_t m_next[256];
|
||||
} GifLzwNode;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
const int kGifTransIndex = 0;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module specific Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
static void GifGetClosestPaletteColor(GifPalette *pPal, int r, int g, int b, int *bestInd, int *bestDiff, int treeRoot);
|
||||
static void GifSwapPixels(uint8_t *image, int pixA, int pixB);
|
||||
static int GifPartition(uint8_t *image, const int left, const int right, const int elt, int pivotIndex);
|
||||
static void GifPartitionByMedian(uint8_t *image, int left, int right, int com, int neededCenter);
|
||||
static void GifSplitPalette(uint8_t *image, int numPixels, int firstElt, int lastElt, int splitElt, int splitDist, int treeNode, bool buildForDither, GifPalette *pal);
|
||||
static int GifPickChangedPixels(const uint8_t *lastFrame, uint8_t *frame, int numPixels);
|
||||
static void GifMakePalette(const uint8_t *lastFrame, const uint8_t *nextFrame, uint32_t width, uint32_t height, int bitDepth, bool buildForDither, GifPalette *pPal);
|
||||
static void GifDitherImage(const uint8_t *lastFrame, const uint8_t *nextFrame, uint8_t *outFrame, uint32_t width, uint32_t height, GifPalette *pPal);
|
||||
static void GifThresholdImage(const uint8_t *lastFrame, const uint8_t *nextFrame, uint8_t *outFrame, uint32_t width, uint32_t height, GifPalette *pPal);
|
||||
static void GifWriteBit(GifBitStatus *stat, uint32_t bit);
|
||||
static void GifWriteChunk(FILE *f, GifBitStatus *stat);
|
||||
static void GifWriteCode(FILE *f, GifBitStatus *stat, uint32_t code, uint32_t length);
|
||||
static void GifWritePalette(const GifPalette *pPal, FILE *f);
|
||||
static void GifWriteLzwImage(FILE *f, uint8_t *image, uint32_t left, uint32_t top, uint32_t width, uint32_t height, uint32_t delay, GifPalette *pPal);
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Creates a gif file.
|
||||
// The input GIFWriter is assumed to be uninitialized.
|
||||
// The delay value is the time between frames in hundredths of a second - note that not all viewers pay much attention to this value.
|
||||
GIFDEF bool GifBegin(GifWriter *writer, const char *filename, uint32_t width, uint32_t height, uint32_t delay, int32_t bitDepth, bool dither)
|
||||
{
|
||||
#if _MSC_VER >= 1400
|
||||
writer->f = 0;
|
||||
fopen_s(&writer->f, filename, "wb");
|
||||
#else
|
||||
writer->f = fopen(filename, "wb");
|
||||
#endif
|
||||
if (!writer->f) return false;
|
||||
|
||||
writer->firstFrame = true;
|
||||
|
||||
// allocate
|
||||
writer->oldImage = (uint8_t*)GIF_MALLOC(width*height*4);
|
||||
|
||||
fputs("GIF89a", writer->f);
|
||||
|
||||
// screen descriptor
|
||||
fputc(width & 0xff, writer->f);
|
||||
fputc((width >> 8) & 0xff, writer->f);
|
||||
fputc(height & 0xff, writer->f);
|
||||
fputc((height >> 8) & 0xff, writer->f);
|
||||
|
||||
fputc(0xf0, writer->f); // there is an unsorted global color table of 2 entries
|
||||
fputc(0, writer->f); // background color
|
||||
fputc(0, writer->f); // pixels are square (we need to specify this because it's 1989)
|
||||
|
||||
// now the "global" palette (really just a dummy palette)
|
||||
// color 0: black
|
||||
fputc(0, writer->f);
|
||||
fputc(0, writer->f);
|
||||
fputc(0, writer->f);
|
||||
// color 1: also black
|
||||
fputc(0, writer->f);
|
||||
fputc(0, writer->f);
|
||||
fputc(0, writer->f);
|
||||
|
||||
if (delay != 0)
|
||||
{
|
||||
// animation header
|
||||
fputc(0x21, writer->f); // extension
|
||||
fputc(0xff, writer->f); // application specific
|
||||
fputc(11, writer->f); // length 11
|
||||
fputs("NETSCAPE2.0", writer->f); // yes, really
|
||||
fputc(3, writer->f); // 3 bytes of NETSCAPE2.0 data
|
||||
|
||||
fputc(1, writer->f); // JUST BECAUSE
|
||||
fputc(0, writer->f); // loop infinitely (byte 0)
|
||||
fputc(0, writer->f); // loop infinitely (byte 1)
|
||||
|
||||
fputc(0, writer->f); // block terminator
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Writes out a new frame to a GIF in progress.
|
||||
// The GIFWriter should have been created by GIFBegin.
|
||||
// AFAIK, it is legal to use different bit depths for different frames of an image -
|
||||
// this may be handy to save bits in animations that don't change much.
|
||||
GIFDEF bool GifWriteFrame(GifWriter *writer, const uint8_t *image, uint32_t width, uint32_t height, uint32_t delay, int bitDepth, bool dither)
|
||||
{
|
||||
if (!writer->f) return false;
|
||||
|
||||
const uint8_t *oldImage = writer->firstFrame? NULL : writer->oldImage;
|
||||
writer->firstFrame = false;
|
||||
|
||||
GifPalette pal;
|
||||
GifMakePalette((dither? NULL : oldImage), image, width, height, bitDepth, dither, &pal);
|
||||
|
||||
if (dither)
|
||||
GifDitherImage(oldImage, image, writer->oldImage, width, height, &pal);
|
||||
else
|
||||
GifThresholdImage(oldImage, image, writer->oldImage, width, height, &pal);
|
||||
|
||||
GifWriteLzwImage(writer->f, writer->oldImage, 0, 0, width, height, delay, &pal);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Writes the EOF code, closes the file handle, and frees temp memory used by a GIF.
|
||||
// Many if not most viewers will still display a GIF properly if the EOF code is missing,
|
||||
// but it's still a good idea to write it out.
|
||||
GIFDEF bool GifEnd(GifWriter *writer)
|
||||
{
|
||||
if (!writer->f) return false;
|
||||
|
||||
fputc(0x3b, writer->f); // end of file
|
||||
fclose(writer->f);
|
||||
GIF_FREE(writer->oldImage);
|
||||
|
||||
writer->f = NULL;
|
||||
writer->oldImage = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module specific Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
// walks the k-d tree to pick the palette entry for a desired color.
|
||||
// Takes as in/out parameters the current best color and its error -
|
||||
// only changes them if it finds a better color in its subtree.
|
||||
// this is the major hotspot in the code at the moment.
|
||||
static void GifGetClosestPaletteColor(GifPalette *pPal, int r, int g, int b, int *bestInd, int *bestDiff, int treeRoot)
|
||||
{
|
||||
// base case, reached the bottom of the tree
|
||||
if (treeRoot > (1<<pPal->bitDepth)-1)
|
||||
{
|
||||
int ind = treeRoot-(1<<pPal->bitDepth);
|
||||
if (ind == kGifTransIndex) return;
|
||||
|
||||
// check whether this color is better than the current winner
|
||||
int r_err = r - ((int32_t)pPal->r[ind]);
|
||||
int g_err = g - ((int32_t)pPal->g[ind]);
|
||||
int b_err = b - ((int32_t)pPal->b[ind]);
|
||||
int diff = GIFABS(r_err)+GIFABS(g_err)+GIFABS(b_err);
|
||||
|
||||
if (diff < *bestDiff)
|
||||
{
|
||||
*bestInd = ind;
|
||||
*bestDiff = diff;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// take the appropriate color (r, g, or b) for this node of the k-d tree
|
||||
int comps[3]; comps[0] = r; comps[1] = g; comps[2] = b;
|
||||
int splitComp = comps[pPal->treeSplitElt[treeRoot]];
|
||||
|
||||
int splitPos = pPal->treeSplit[treeRoot];
|
||||
if (splitPos > splitComp)
|
||||
{
|
||||
// check the left subtree
|
||||
GifGetClosestPaletteColor(pPal, r, g, b, bestInd, bestDiff, treeRoot*2);
|
||||
|
||||
if (*bestDiff > (splitPos - splitComp))
|
||||
{
|
||||
// cannot prove there's not a better value in the right subtree, check that too
|
||||
GifGetClosestPaletteColor(pPal, r, g, b, bestInd, bestDiff, treeRoot*2 + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GifGetClosestPaletteColor(pPal, r, g, b, bestInd, bestDiff, treeRoot*2 + 1);
|
||||
|
||||
if (*bestDiff > splitComp - splitPos)
|
||||
{
|
||||
GifGetClosestPaletteColor(pPal, r, g, b, bestInd, bestDiff, treeRoot*2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void GifSwapPixels(uint8_t *image, int pixA, int pixB)
|
||||
{
|
||||
uint8_t rA = image[pixA*4];
|
||||
uint8_t gA = image[pixA*4 + 1];
|
||||
uint8_t bA = image[pixA*4+2];
|
||||
uint8_t aA = image[pixA*4+3];
|
||||
|
||||
uint8_t rB = image[pixB*4];
|
||||
uint8_t gB = image[pixB*4 + 1];
|
||||
uint8_t bB = image[pixB*4+2];
|
||||
uint8_t aB = image[pixA*4+3];
|
||||
|
||||
image[pixA*4] = rB;
|
||||
image[pixA*4 + 1] = gB;
|
||||
image[pixA*4+2] = bB;
|
||||
image[pixA*4+3] = aB;
|
||||
|
||||
image[pixB*4] = rA;
|
||||
image[pixB*4 + 1] = gA;
|
||||
image[pixB*4+2] = bA;
|
||||
image[pixB*4+3] = aA;
|
||||
}
|
||||
|
||||
// just the partition operation from quicksort
|
||||
static int GifPartition(uint8_t *image, const int left, const int right, const int elt, int pivotIndex)
|
||||
{
|
||||
const int pivotValue = image[(pivotIndex)*4+elt];
|
||||
GifSwapPixels(image, pivotIndex, right-1);
|
||||
int storeIndex = left;
|
||||
bool split = 0;
|
||||
for (int ii=left; ii<right-1; ++ii)
|
||||
{
|
||||
int arrayVal = image[ii*4+elt];
|
||||
if (arrayVal < pivotValue)
|
||||
{
|
||||
GifSwapPixels(image, ii, storeIndex);
|
||||
++storeIndex;
|
||||
}
|
||||
else if (arrayVal == pivotValue)
|
||||
{
|
||||
if (split)
|
||||
{
|
||||
GifSwapPixels(image, ii, storeIndex);
|
||||
++storeIndex;
|
||||
}
|
||||
split = !split;
|
||||
}
|
||||
}
|
||||
GifSwapPixels(image, storeIndex, right-1);
|
||||
return storeIndex;
|
||||
}
|
||||
|
||||
// Perform an incomplete sort, finding all elements above and below the desired median
|
||||
static void GifPartitionByMedian(uint8_t *image, int left, int right, int com, int neededCenter)
|
||||
{
|
||||
if (left < right-1)
|
||||
{
|
||||
int pivotIndex = left + (right-left)/2;
|
||||
|
||||
pivotIndex = GifPartition(image, left, right, com, pivotIndex);
|
||||
|
||||
// Only "sort" the section of the array that contains the median
|
||||
if (pivotIndex > neededCenter)
|
||||
GifPartitionByMedian(image, left, pivotIndex, com, neededCenter);
|
||||
|
||||
if (pivotIndex < neededCenter)
|
||||
GifPartitionByMedian(image, pivotIndex + 1, right, com, neededCenter);
|
||||
}
|
||||
}
|
||||
|
||||
// Builds a palette by creating a balanced k-d tree of all pixels in the image
|
||||
static void GifSplitPalette(uint8_t *image, int numPixels, int firstElt, int lastElt, int splitElt, int splitDist,
|
||||
int treeNode, bool buildForDither, GifPalette *pal)
|
||||
{
|
||||
if (lastElt <= firstElt || numPixels == 0)
|
||||
return;
|
||||
|
||||
// base case, bottom of the tree
|
||||
if (lastElt == firstElt + 1)
|
||||
{
|
||||
if (buildForDither)
|
||||
{
|
||||
// Dithering needs at least one color as dark as anything
|
||||
// in the image and at least one brightest color -
|
||||
// otherwise it builds up error and produces strange artifacts
|
||||
if (firstElt == 1)
|
||||
{
|
||||
// special case: the darkest color in the image
|
||||
uint32_t r=255, g=255, b=255;
|
||||
for (int ii=0; ii<numPixels; ++ii)
|
||||
{
|
||||
r = GIFMIN(r, image[ii*4+0]);
|
||||
g = GIFMIN(g, image[ii*4 + 1]);
|
||||
b = GIFMIN(b, image[ii*4+2]);
|
||||
}
|
||||
|
||||
pal->r[firstElt] = r;
|
||||
pal->g[firstElt] = g;
|
||||
pal->b[firstElt] = b;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (firstElt == (1 << pal->bitDepth)-1)
|
||||
{
|
||||
// special case: the lightest color in the image
|
||||
uint32_t r=0, g=0, b=0;
|
||||
for (int ii=0; ii<numPixels; ++ii)
|
||||
{
|
||||
r = GIFMAX(r, image[ii*4+0]);
|
||||
g = GIFMAX(g, image[ii*4 + 1]);
|
||||
b = GIFMAX(b, image[ii*4+2]);
|
||||
}
|
||||
|
||||
pal->r[firstElt] = r;
|
||||
pal->g[firstElt] = g;
|
||||
pal->b[firstElt] = b;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise, take the average of all colors in this subcube
|
||||
uint64_t r=0, g=0, b=0;
|
||||
for (int ii=0; ii<numPixels; ++ii)
|
||||
{
|
||||
r += image[ii*4+0];
|
||||
g += image[ii*4 + 1];
|
||||
b += image[ii*4+2];
|
||||
}
|
||||
|
||||
r += numPixels / 2; // round to nearest
|
||||
g += numPixels / 2;
|
||||
b += numPixels / 2;
|
||||
|
||||
r /= numPixels;
|
||||
g /= numPixels;
|
||||
b /= numPixels;
|
||||
|
||||
pal->r[firstElt] = (uint8_t)r;
|
||||
pal->g[firstElt] = (uint8_t)g;
|
||||
pal->b[firstElt] = (uint8_t)b;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the axis with the largest range
|
||||
int minR = 255, maxR = 0;
|
||||
int minG = 255, maxG = 0;
|
||||
int minB = 255, maxB = 0;
|
||||
for (int ii=0; ii<numPixels; ++ii)
|
||||
{
|
||||
int r = image[ii*4+0];
|
||||
int g = image[ii*4 + 1];
|
||||
int b = image[ii*4+2];
|
||||
|
||||
if (r > maxR) maxR = r;
|
||||
if (r < minR) minR = r;
|
||||
|
||||
if (g > maxG) maxG = g;
|
||||
if (g < minG) minG = g;
|
||||
|
||||
if (b > maxB) maxB = b;
|
||||
if (b < minB) minB = b;
|
||||
}
|
||||
|
||||
int rRange = maxR - minR;
|
||||
int gRange = maxG - minG;
|
||||
int bRange = maxB - minB;
|
||||
|
||||
// and split along that axis. (incidentally, this means this isn't a "proper" k-d tree but I don't know what else to call it)
|
||||
int splitCom = 1;
|
||||
if (bRange > gRange) splitCom = 2;
|
||||
if (rRange > bRange && rRange > gRange) splitCom = 0;
|
||||
|
||||
int subPixelsA = numPixels *(splitElt - firstElt) / (lastElt - firstElt);
|
||||
int subPixelsB = numPixels-subPixelsA;
|
||||
|
||||
GifPartitionByMedian(image, 0, numPixels, splitCom, subPixelsA);
|
||||
|
||||
pal->treeSplitElt[treeNode] = splitCom;
|
||||
pal->treeSplit[treeNode] = image[subPixelsA*4+splitCom];
|
||||
|
||||
GifSplitPalette(image, subPixelsA, firstElt, splitElt, splitElt-splitDist, splitDist/2, treeNode*2, buildForDither, pal);
|
||||
GifSplitPalette(image+subPixelsA*4, subPixelsB, splitElt, lastElt, splitElt+splitDist, splitDist/2, treeNode*2 + 1, buildForDither, pal);
|
||||
}
|
||||
|
||||
// Finds all pixels that have changed from the previous image and
|
||||
// moves them to the fromt of th buffer.
|
||||
// This allows us to build a palette optimized for the colors of the
|
||||
// changed pixels only.
|
||||
static int GifPickChangedPixels(const uint8_t *lastFrame, uint8_t *frame, int numPixels)
|
||||
{
|
||||
int numChanged = 0;
|
||||
uint8_t *writeIter = frame;
|
||||
|
||||
for (int ii=0; ii<numPixels; ++ii)
|
||||
{
|
||||
if (lastFrame[0] != frame[0] ||
|
||||
lastFrame[1] != frame[1] ||
|
||||
lastFrame[2] != frame[2])
|
||||
{
|
||||
writeIter[0] = frame[0];
|
||||
writeIter[1] = frame[1];
|
||||
writeIter[2] = frame[2];
|
||||
++numChanged;
|
||||
writeIter += 4;
|
||||
}
|
||||
lastFrame += 4;
|
||||
frame += 4;
|
||||
}
|
||||
|
||||
return numChanged;
|
||||
}
|
||||
|
||||
// Creates a palette by placing all the image pixels in a k-d tree and then averaging the blocks at the bottom.
|
||||
// This is known as the "modified median split" technique
|
||||
static void GifMakePalette(const uint8_t *lastFrame, const uint8_t *nextFrame, uint32_t width, uint32_t height, int bitDepth, bool buildForDither, GifPalette *pPal)
|
||||
{
|
||||
pPal->bitDepth = bitDepth;
|
||||
|
||||
// SplitPalette is destructive (it sorts the pixels by color) so
|
||||
// we must create a copy of the image for it to destroy
|
||||
int imageSize = width*height*4*sizeof(uint8_t);
|
||||
uint8_t *destroyableImage = (uint8_t*)GIF_TEMP_MALLOC(imageSize);
|
||||
memcpy(destroyableImage, nextFrame, imageSize);
|
||||
|
||||
int numPixels = width*height;
|
||||
if (lastFrame)
|
||||
numPixels = GifPickChangedPixels(lastFrame, destroyableImage, numPixels);
|
||||
|
||||
const int lastElt = 1 << bitDepth;
|
||||
const int splitElt = lastElt/2;
|
||||
const int splitDist = splitElt/2;
|
||||
|
||||
GifSplitPalette(destroyableImage, numPixels, 1, lastElt, splitElt, splitDist, 1, buildForDither, pPal);
|
||||
|
||||
GIF_TEMP_FREE(destroyableImage);
|
||||
|
||||
// add the bottom node for the transparency index
|
||||
pPal->treeSplit[1 << (bitDepth-1)] = 0;
|
||||
pPal->treeSplitElt[1 << (bitDepth-1)] = 0;
|
||||
|
||||
pPal->r[0] = pPal->g[0] = pPal->b[0] = 0;
|
||||
}
|
||||
|
||||
// Implements Floyd-Steinberg dithering, writes palette value to alpha
|
||||
static void GifDitherImage(const uint8_t *lastFrame, const uint8_t *nextFrame, uint8_t *outFrame, uint32_t width, uint32_t height, GifPalette *pPal)
|
||||
{
|
||||
int numPixels = width*height;
|
||||
|
||||
// quantPixels initially holds color*256 for all pixels
|
||||
// The extra 8 bits of precision allow for sub-single-color error values
|
||||
// to be propagated
|
||||
int32_t *quantPixels = (int32_t*)GIF_TEMP_MALLOC(sizeof(int32_t)*numPixels*4);
|
||||
|
||||
for (int ii=0; ii<numPixels*4; ++ii)
|
||||
{
|
||||
uint8_t pix = nextFrame[ii];
|
||||
int32_t pix16 = (int32_t)pix*256;
|
||||
quantPixels[ii] = pix16;
|
||||
}
|
||||
|
||||
for (uint32_t yy=0; yy<height; ++yy)
|
||||
{
|
||||
for (uint32_t xx=0; xx<width; ++xx)
|
||||
{
|
||||
int32_t *nextPix = quantPixels + 4*(yy*width+xx);
|
||||
const uint8_t *lastPix = lastFrame? lastFrame + 4*(yy*width+xx) : NULL;
|
||||
|
||||
// Compute the colors we want (rounding to nearest)
|
||||
int32_t rr = (nextPix[0] + 127) / 256;
|
||||
int32_t gg = (nextPix[1] + 127) / 256;
|
||||
int32_t bb = (nextPix[2] + 127) / 256;
|
||||
|
||||
// if it happens that we want the color from last frame, then just write out
|
||||
// a transparent pixel
|
||||
if (lastFrame &&
|
||||
lastPix[0] == rr &&
|
||||
lastPix[1] == gg &&
|
||||
lastPix[2] == bb)
|
||||
{
|
||||
nextPix[0] = rr;
|
||||
nextPix[1] = gg;
|
||||
nextPix[2] = bb;
|
||||
nextPix[3] = kGifTransIndex;
|
||||
continue;
|
||||
}
|
||||
|
||||
int32_t bestDiff = 1000000;
|
||||
int32_t bestInd = kGifTransIndex;
|
||||
|
||||
// Search the palete
|
||||
GifGetClosestPaletteColor(pPal, rr, gg, bb, &bestInd, &bestDiff, 1);
|
||||
|
||||
// Write the result to the temp buffer
|
||||
int32_t r_err = nextPix[0] - (int32_t)(pPal->r[bestInd])*256;
|
||||
int32_t g_err = nextPix[1] - (int32_t)(pPal->g[bestInd])*256;
|
||||
int32_t b_err = nextPix[2] - (int32_t)(pPal->b[bestInd])*256;
|
||||
|
||||
nextPix[0] = pPal->r[bestInd];
|
||||
nextPix[1] = pPal->g[bestInd];
|
||||
nextPix[2] = pPal->b[bestInd];
|
||||
nextPix[3] = bestInd;
|
||||
|
||||
// Propagate the error to the four adjacent locations
|
||||
// that we haven't touched yet
|
||||
int quantloc_7 = (yy*width+xx + 1);
|
||||
int quantloc_3 = (yy*width+width+xx-1);
|
||||
int quantloc_5 = (yy*width+width+xx);
|
||||
int quantloc_1 = (yy*width+width+xx + 1);
|
||||
|
||||
if (quantloc_7 < numPixels)
|
||||
{
|
||||
int32_t *pix7 = quantPixels+4*quantloc_7;
|
||||
pix7[0] += GIFMAX(-pix7[0], r_err*7 / 16);
|
||||
pix7[1] += GIFMAX(-pix7[1], g_err*7 / 16);
|
||||
pix7[2] += GIFMAX(-pix7[2], b_err*7 / 16);
|
||||
}
|
||||
|
||||
if (quantloc_3 < numPixels)
|
||||
{
|
||||
int32_t *pix3 = quantPixels+4*quantloc_3;
|
||||
pix3[0] += GIFMAX(-pix3[0], r_err*3 / 16);
|
||||
pix3[1] += GIFMAX(-pix3[1], g_err*3 / 16);
|
||||
pix3[2] += GIFMAX(-pix3[2], b_err*3 / 16);
|
||||
}
|
||||
|
||||
if (quantloc_5 < numPixels)
|
||||
{
|
||||
int32_t *pix5 = quantPixels+4*quantloc_5;
|
||||
pix5[0] += GIFMAX(-pix5[0], r_err*5 / 16);
|
||||
pix5[1] += GIFMAX(-pix5[1], g_err*5 / 16);
|
||||
pix5[2] += GIFMAX(-pix5[2], b_err*5 / 16);
|
||||
}
|
||||
|
||||
if (quantloc_1 < numPixels)
|
||||
{
|
||||
int32_t *pix1 = quantPixels+4*quantloc_1;
|
||||
pix1[0] += GIFMAX(-pix1[0], r_err / 16);
|
||||
pix1[1] += GIFMAX(-pix1[1], g_err / 16);
|
||||
pix1[2] += GIFMAX(-pix1[2], b_err / 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copy the palettized result to the output buffer
|
||||
for (int ii=0; ii<numPixels*4; ++ii)
|
||||
{
|
||||
outFrame[ii] = quantPixels[ii];
|
||||
}
|
||||
|
||||
GIF_TEMP_FREE(quantPixels);
|
||||
}
|
||||
|
||||
// Picks palette colors for the image using simple thresholding, no dithering
|
||||
static void GifThresholdImage(const uint8_t *lastFrame, const uint8_t *nextFrame, uint8_t *outFrame, uint32_t width, uint32_t height, GifPalette *pPal)
|
||||
{
|
||||
uint32_t numPixels = width*height;
|
||||
for (uint32_t ii=0; ii<numPixels; ++ii)
|
||||
{
|
||||
// if a previous color is available, and it matches the current color,
|
||||
// set the pixel to transparent
|
||||
if (lastFrame &&
|
||||
lastFrame[0] == nextFrame[0] &&
|
||||
lastFrame[1] == nextFrame[1] &&
|
||||
lastFrame[2] == nextFrame[2])
|
||||
{
|
||||
outFrame[0] = lastFrame[0];
|
||||
outFrame[1] = lastFrame[1];
|
||||
outFrame[2] = lastFrame[2];
|
||||
outFrame[3] = kGifTransIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
// palettize the pixel
|
||||
int32_t bestDiff = 1000000;
|
||||
int32_t bestInd = 1;
|
||||
GifGetClosestPaletteColor(pPal, nextFrame[0], nextFrame[1], nextFrame[2], &bestInd, &bestDiff, 1);
|
||||
|
||||
// Write the resulting color to the output buffer
|
||||
outFrame[0] = pPal->r[bestInd];
|
||||
outFrame[1] = pPal->g[bestInd];
|
||||
outFrame[2] = pPal->b[bestInd];
|
||||
outFrame[3] = bestInd;
|
||||
}
|
||||
|
||||
if (lastFrame) lastFrame += 4;
|
||||
outFrame += 4;
|
||||
nextFrame += 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// insert a single bit
|
||||
static void GifWriteBit(GifBitStatus *stat, uint32_t bit)
|
||||
{
|
||||
bit = bit & 1;
|
||||
bit = bit << stat->bitIndex;
|
||||
stat->byte |= bit;
|
||||
|
||||
++stat->bitIndex;
|
||||
if (stat->bitIndex > 7)
|
||||
{
|
||||
// move the newly-finished byte to the chunk buffer
|
||||
stat->chunk[stat->chunkIndex++] = stat->byte;
|
||||
// and start a new byte
|
||||
stat->bitIndex = 0;
|
||||
stat->byte = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// write all bytes so far to the file
|
||||
static void GifWriteChunk(FILE *f, GifBitStatus *stat)
|
||||
{
|
||||
fputc(stat->chunkIndex, f);
|
||||
fwrite(stat->chunk, 1, stat->chunkIndex, f);
|
||||
|
||||
stat->bitIndex = 0;
|
||||
stat->byte = 0;
|
||||
stat->chunkIndex = 0;
|
||||
}
|
||||
|
||||
static void GifWriteCode(FILE *f, GifBitStatus *stat, uint32_t code, uint32_t length)
|
||||
{
|
||||
for (uint32_t ii=0; ii<length; ++ii)
|
||||
{
|
||||
GifWriteBit(stat, code);
|
||||
code = code >> 1;
|
||||
|
||||
if (stat->chunkIndex == 255)
|
||||
{
|
||||
GifWriteChunk(f, stat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// write a 256-color (8-bit) image palette to the file
|
||||
static void GifWritePalette(const GifPalette *pPal, FILE *f)
|
||||
{
|
||||
fputc(0, f); // first color: transparency
|
||||
fputc(0, f);
|
||||
fputc(0, f);
|
||||
|
||||
for (int ii=1; ii<(1 << pPal->bitDepth); ++ii)
|
||||
{
|
||||
uint32_t r = pPal->r[ii];
|
||||
uint32_t g = pPal->g[ii];
|
||||
uint32_t b = pPal->b[ii];
|
||||
|
||||
fputc(r, f);
|
||||
fputc(g, f);
|
||||
fputc(b, f);
|
||||
}
|
||||
}
|
||||
|
||||
// write the image header, LZW-compress and write out the image
|
||||
static void GifWriteLzwImage(FILE *f, uint8_t *image, uint32_t left, uint32_t top, uint32_t width, uint32_t height, uint32_t delay, GifPalette *pPal)
|
||||
{
|
||||
// graphics control extension
|
||||
fputc(0x21, f);
|
||||
fputc(0xf9, f);
|
||||
fputc(0x04, f);
|
||||
fputc(0x05, f); // leave prev frame in place, this frame has transparency
|
||||
fputc(delay & 0xff, f);
|
||||
fputc((delay >> 8) & 0xff, f);
|
||||
fputc(kGifTransIndex, f); // transparent color index
|
||||
fputc(0, f);
|
||||
|
||||
fputc(0x2c, f); // image descriptor block
|
||||
|
||||
fputc(left & 0xff, f); // corner of image in canvas space
|
||||
fputc((left >> 8) & 0xff, f);
|
||||
fputc(top & 0xff, f);
|
||||
fputc((top >> 8) & 0xff, f);
|
||||
|
||||
fputc(width & 0xff, f); // width and height of image
|
||||
fputc((width >> 8) & 0xff, f);
|
||||
fputc(height & 0xff, f);
|
||||
fputc((height >> 8) & 0xff, f);
|
||||
|
||||
//fputc(0, f); // no local color table, no transparency
|
||||
//fputc(0x80, f); // no local color table, but transparency
|
||||
|
||||
fputc(0x80 + pPal->bitDepth-1, f); // local color table present, 2 ^ bitDepth entries
|
||||
GifWritePalette(pPal, f);
|
||||
|
||||
const int minCodeSize = pPal->bitDepth;
|
||||
const uint32_t clearCode = 1 << pPal->bitDepth;
|
||||
|
||||
fputc(minCodeSize, f); // min code size 8 bits
|
||||
|
||||
GifLzwNode *codetree = (GifLzwNode *)GIF_TEMP_MALLOC(sizeof(GifLzwNode)*4096);
|
||||
|
||||
memset(codetree, 0, sizeof(GifLzwNode)*4096);
|
||||
int32_t curCode = -1;
|
||||
uint32_t codeSize = minCodeSize + 1;
|
||||
uint32_t maxCode = clearCode + 1;
|
||||
|
||||
GifBitStatus stat;
|
||||
stat.byte = 0;
|
||||
stat.bitIndex = 0;
|
||||
stat.chunkIndex = 0;
|
||||
|
||||
GifWriteCode(f, &stat, clearCode, codeSize); // start with a fresh LZW dictionary
|
||||
|
||||
for (uint32_t yy=0; yy<height; ++yy)
|
||||
{
|
||||
for (uint32_t xx=0; xx<width; ++xx)
|
||||
{
|
||||
uint8_t nextValue = image[(yy*width+xx)*4+3];
|
||||
|
||||
// "loser mode" - no compression, every single code is followed immediately by a clear
|
||||
//WriteCode(f, stat, nextValue, codeSize);
|
||||
//WriteCode(f, stat, 256, codeSize);
|
||||
|
||||
if (curCode < 0)
|
||||
{
|
||||
// first value in a new run
|
||||
curCode = nextValue;
|
||||
}
|
||||
else if (codetree[curCode].m_next[nextValue])
|
||||
{
|
||||
// current run already in the dictionary
|
||||
curCode = codetree[curCode].m_next[nextValue];
|
||||
}
|
||||
else
|
||||
{
|
||||
// finish the current run, write a code
|
||||
GifWriteCode(f, &stat, curCode, codeSize);
|
||||
|
||||
// insert the new run into the dictionary
|
||||
codetree[curCode].m_next[nextValue] = ++maxCode;
|
||||
|
||||
if (maxCode >= (1ul << codeSize))
|
||||
{
|
||||
// dictionary entry count has broken a size barrier,
|
||||
// we need more bits for codes
|
||||
codeSize++;
|
||||
}
|
||||
if (maxCode == 4095)
|
||||
{
|
||||
// the dictionary is full, clear it out and begin anew
|
||||
GifWriteCode(f, &stat, clearCode, codeSize); // clear tree
|
||||
|
||||
memset(codetree, 0, sizeof(GifLzwNode)*4096);
|
||||
curCode = -1;
|
||||
codeSize = minCodeSize + 1;
|
||||
maxCode = clearCode + 1;
|
||||
}
|
||||
|
||||
curCode = nextValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// compression footer
|
||||
GifWriteCode(f, &stat, curCode, codeSize);
|
||||
GifWriteCode(f, &stat, clearCode, codeSize);
|
||||
GifWriteCode(f, &stat, clearCode + 1, minCodeSize + 1);
|
||||
|
||||
// write out the last partial chunk
|
||||
while (stat.bitIndex) GifWriteBit(&stat, 0);
|
||||
if (stat.chunkIndex) GifWriteChunk(f, &stat);
|
||||
|
||||
fputc(0, f); // image block terminator
|
||||
|
||||
GIF_TEMP_FREE(codetree);
|
||||
}
|
||||
|
||||
#endif // GIF_IMPLEMENTATION
|
Loading…
Add table
Add a link
Reference in a new issue