Merge branch 'master' of https://github.com/raysan5/raylib into raysan5-master
# Conflicts: # projects/VS2017/examples/core_basic_window.vcxproj # projects/VS2017/examples/core_basic_window_cpp.vcxproj # projects/VS2017/raylib/raylib.vcxproj # src/raylib.h
This commit is contained in:
commit
31e9cfe2a5
112 changed files with 5085 additions and 3833 deletions
|
|
@ -7,6 +7,7 @@ Some people ported raylib to other languages in form of bindings or wrappers to
|
||||||
- [raylib-lua-ffi](https://github.com/raysan5/raylib/issues/693) : raylib **Lua** ffi binding
|
- [raylib-lua-ffi](https://github.com/raysan5/raylib/issues/693) : raylib **Lua** ffi binding
|
||||||
- [raylib-go](https://github.com/gen2brain/raylib-go) : raylib **Go** binding
|
- [raylib-go](https://github.com/gen2brain/raylib-go) : raylib **Go** binding
|
||||||
- [raylib-Nim](https://gitlab.com/define-private-public/raylib-Nim) : raylib **Nim** binding
|
- [raylib-Nim](https://gitlab.com/define-private-public/raylib-Nim) : raylib **Nim** binding
|
||||||
|
- [raylib-cr](https://github.com/AregevDev/raylib-cr) : raylib **Crystal** binding
|
||||||
- [cray](https://gitlab.com/Zatherz/cray) - raylib **Crystal** binding
|
- [cray](https://gitlab.com/Zatherz/cray) - raylib **Crystal** binding
|
||||||
- [Graphics::Raylib](https://metacpan.org/pod/Graphics::Raylib) : raylib **Perl** wrapper
|
- [Graphics::Raylib](https://metacpan.org/pod/Graphics::Raylib) : raylib **Perl** wrapper
|
||||||
- [raylib-pascal](https://github.com/drezgames/raylib-pascal) - raylib **Pascal** binding
|
- [raylib-pascal](https://github.com/drezgames/raylib-pascal) - raylib **Pascal** binding
|
||||||
|
|
@ -19,8 +20,12 @@ Some people ported raylib to other languages in form of bindings or wrappers to
|
||||||
- [raylib-java](https://github.com/XoanaIO/raylib-java) : raylib **Java** binding
|
- [raylib-java](https://github.com/XoanaIO/raylib-java) : raylib **Java** binding
|
||||||
- [raylib-chaiscript](https://github.com/RobLoach/raylib-chaiscript) : raylib **ChaiScript** binding
|
- [raylib-chaiscript](https://github.com/RobLoach/raylib-chaiscript) : raylib **ChaiScript** binding
|
||||||
- [node-raylib](https://github.com/RobLoach/node-raylib) : **Node.js** raylib binding
|
- [node-raylib](https://github.com/RobLoach/node-raylib) : **Node.js** raylib binding
|
||||||
- *[raylib flat-assembler Usage example]()*
|
- [raylib-odin](https://github.com/kevinw/raylib-odin): **Odin** raylib binding
|
||||||
|
- [raylib-factor](https://github.com/Silverbeard00/raylib-factor): **Factor** raylib binding
|
||||||
- *[raylib COBOL Usage example](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib)*
|
- *[raylib COBOL Usage example](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib)*
|
||||||
|
- *raylib flat-assembler Usage example*: not uploaded yet...
|
||||||
|
|
||||||
|
Missing some language? Check the [bindings not yet in this list](https://gist.github.com/raysan5/5764cc5b885183f523fce47f098f3d9b#bindings-not-yet-in-the-official-list) or create a new binding! :)
|
||||||
|
|
||||||
Usually, raylib bindings follow the convention: `raylib-{language}`
|
Usually, raylib bindings follow the convention: `raylib-{language}`
|
||||||
|
|
||||||
|
|
|
||||||
126
CHANGELOG
126
CHANGELOG
|
|
@ -3,6 +3,132 @@ changelog
|
||||||
|
|
||||||
Current Release: raylib 2.0.0 (July 2018)
|
Current Release: raylib 2.0.0 (July 2018)
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
Release: raylib 2.5 (May 2019)
|
||||||
|
-----------------------------------------------
|
||||||
|
KEY CHANGES:
|
||||||
|
- New text management API
|
||||||
|
- Cubemap textures support
|
||||||
|
- Skeletal model animation support
|
||||||
|
- New textures drawing: Quad and N-Patch based rectangles
|
||||||
|
- New drawing shapes available: CircleSector, Ring and RectangleRounded
|
||||||
|
- VR system redesign to allow custom device parameters and distortion shader
|
||||||
|
|
||||||
|
Detailed changes:
|
||||||
|
[build] ...
|
||||||
|
[build] REVIEWED: Notepad++ NppExec scripts
|
||||||
|
[build] REVIEWED: VS2015 and VS2017 projects
|
||||||
|
[build] REVIEWED: Android APK build pipeline
|
||||||
|
|
||||||
|
[core] Converted most #defined values as enum values
|
||||||
|
[core] Complete redesign of RPI input system
|
||||||
|
[core] ADDED: IsWindowResized() - Check if window has been resized
|
||||||
|
[core] ADDED: IsWindowHidden() - Check if window is currently hidden
|
||||||
|
[core] ADDED: UnhideWindow() - Show the window
|
||||||
|
[core] ADDED: HideWindow() - Hide the window
|
||||||
|
[core] ADDED: GetWindowHandle() - Get native window handle
|
||||||
|
[core] ADDED: GetMonitorCount() - Get number of connected monitors
|
||||||
|
[core] ADDED: GetMonitorWidth() - Get primary monitor width
|
||||||
|
[core] ADDED: GetMonitorHeight() - Get primary monitor height
|
||||||
|
[core] ADDED: GetMonitorPhysicalWidth() - Get primary monitor physical width in millimetres
|
||||||
|
[core] ADDED: GetMonitorPhysicalHeight() - Get primary monitor physical height in millimetres
|
||||||
|
[core] ADDED: GetMonitorName() - Get the human-readable, UTF-8 encoded name of the primary monitor
|
||||||
|
[core] ADDED: GetClipboardText() - Get clipboard text content
|
||||||
|
[core] ADDED: SetClipboardText() - Set clipboard text content
|
||||||
|
[core] ADDED: ColorFromHSV() - Returns a Color from HSV values
|
||||||
|
[core] ADDED: FileExists() - Check if file exists
|
||||||
|
[core] ADDED: GetFileNameWithoutExt() - Get filename string without extension (memory should be freed)
|
||||||
|
[core] ADDED: GetDirectoryFiles() - Get filenames in a directory path (memory should be freed)
|
||||||
|
[core] ADDED: ClearDirectoryFiles() - Clear directory files paths buffers (free memory)
|
||||||
|
[core] ADDED: OpenURL() - Open URL with default system browser (if available)
|
||||||
|
[core] ADDED: SetMouseOffset() - Set mouse offset
|
||||||
|
[core] ADDED: SetMouseScale() - Set mouse scaling
|
||||||
|
[core] REMOVED: ShowLogo() - Activate raylib logo at startup (can be done with flags)
|
||||||
|
[shapes] ADDED: DrawCircleSector() - Draw a piece of a circle
|
||||||
|
[shapes] ADDED: DrawCircleSectorLines() - Draw circle sector outline
|
||||||
|
[shapes] ADDED: DrawRing() - Draw ring
|
||||||
|
[shapes] ADDED: DrawRingLines() - Draw ring outline
|
||||||
|
[shapes] ADDED: DrawRectangleRounded() - Draw rectangle with rounded edges
|
||||||
|
[shapes] ADDED: DrawRectangleRoundedLines() - Draw rectangle with rounded edges outline
|
||||||
|
[shapes] ADDED: SetShapesTexture() - Define default texture used to draw shapes
|
||||||
|
[textures] REVIEWED: ExportImage() - Reorder function parameters
|
||||||
|
[textures] REVIEWED: ImageDrawRectangle() - Remove unneeded parameter
|
||||||
|
[textures] ADDED: ExportImageAsCode() - Export image as code file defining an array of bytes
|
||||||
|
[textures] ADDED: LoadTextureCubemap() - Load cubemap from image, multiple image cubemap layouts supported
|
||||||
|
[textures] ADDED: ImageExtractPalette() - Extract color palette from image to maximum size (memory should be freed)
|
||||||
|
[textures] ADDED: ImageDrawRectangleLines() - Draw rectangle lines within an image
|
||||||
|
[textures] ADDED: DrawTextureQuad() - Draw texture quad with tiling and offset parameters
|
||||||
|
[textures] ADDED: DrawTextureNPatch() - Draws a texture (or part of it) that stretches or shrinks nicely
|
||||||
|
[models] REVIEWED: LoadMesh() -> LoadMeshes() - Support multiple meshes loading
|
||||||
|
[models] REVIEWED: LoadMaterial() -> LoadMaterials() - Support multiple materials loading
|
||||||
|
[models] REVIEWED: ExportMesh() - Reorder parameters
|
||||||
|
[models] ADDED: DrawCubeWiresV() - Draw cube wires (Vector version)
|
||||||
|
[models] ADDED: GenMeshPoly() - Generate polygonal mesh
|
||||||
|
[models] ADDED: SetMaterialTexture() - Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...)
|
||||||
|
[models] ADDED: SetModelMeshMaterial() - Set material for a mesh
|
||||||
|
[models] ADDED: LoadModelAnimations() - Load model animations from file
|
||||||
|
[models] ADDED: UpdateModelAnimation() - Update model animation pose
|
||||||
|
[models] ADDED: UnloadModelAnimation() - Unload animation data
|
||||||
|
[models] ADDED: IsModelAnimationValid() - Check model animation skeleton match
|
||||||
|
[rlgl] Improved internal batching mechanism (multibuffering support, triangle texcoords...)
|
||||||
|
[rlgl] REVIEWED: rlPushMatrix()/rlPopMatrix() - Now works like OpenGL 1.1
|
||||||
|
[rlgl] REVIEWED: SetShaderValue() - More generic, now requires uniform type
|
||||||
|
[rlgl] REMOVED: SetShaderValuei() - Can be acoomplished with new SetShaderValue()
|
||||||
|
[rlgl] ADDED: SetShaderValueV() - Set shader uniform value vector
|
||||||
|
[rlgl] ADDED: SetShaderValueTexture() - Set shader uniform value for texture
|
||||||
|
[rlgl] ADDED: BeginScissorMode() - Begin scissor mode (define screen area for following drawing)
|
||||||
|
[rlgl] ADDED: EndScissorMode() - End scissor mode
|
||||||
|
[rlgl] ADDED: SetVrConfiguration() - Set stereo rendering configuration parameters
|
||||||
|
[rlgl] REVIEWED: InitVrSimulator() - No input parameter required, use SetVrConfiguration()
|
||||||
|
[text] REVIEWED: LoadFontEx() - Reorder function parameters
|
||||||
|
[text] REVIEWED: LoadFontData() - Reorder function parameters
|
||||||
|
[text] REVIEWED: GenImageFontAtlas() - Reorder function parameters
|
||||||
|
[text] RENAMED: FormatText() -> TextFormat()
|
||||||
|
[text] RENAMED: SubText() -> TextSubtext()
|
||||||
|
[text] ADDED: LoadFontFromImage() - Load font from Image (XNA style)
|
||||||
|
[text] ADDED: DrawTextRec() - Draw text using font inside rectangle limits
|
||||||
|
[text] ADDED: DrawTextRecEx() - Draw text using font inside rectangle limits with support for text selection
|
||||||
|
[text] ADDED: TextIsEqual() - Check if two text string are equal
|
||||||
|
[text] ADDED: TextLength() - Get text length, checks for '\0' ending
|
||||||
|
[text] ADDED: TextReplace() - Replace text string (memory should be freed!)
|
||||||
|
[text] ADDED: TextInsert() - Insert text in a position (memory should be freed!)
|
||||||
|
[text] ADDED: TextJoin() - Join text strings with delimiter
|
||||||
|
[text] ADDED: TextSplit() - Split text into multiple strings
|
||||||
|
[text] ADDED: TextAppend() - Append text at specific position and move cursor!
|
||||||
|
[text] ADDED: TextFindIndex() - Find first text occurrence within a string
|
||||||
|
[text] ADDED: TextToUpper() - Get upper case version of provided string
|
||||||
|
[text] ADDED: TextToLower() - Get lower case version of provided string
|
||||||
|
[text] ADDED: TextToPascal() - Get Pascal case notation version of provided string
|
||||||
|
[text] ADDED: TextToInteger() - Get integer value from text (negative values not supported)
|
||||||
|
[raudio] ADDED: ExportWave() - Export wave data to file
|
||||||
|
[raudio] ADDED: ExportWaveAsCode() - Export wave sample data to code (.h)
|
||||||
|
[raudio] ADDED: IsAudioStreamPlaying() - Check if audio stream is playing
|
||||||
|
[raudio] ADDED: SetAudioStreamVolume() - Set volume for audio stream (1.0 is max level)
|
||||||
|
[raudio] ADDED: SetAudioStreamPitch() - Set pitch for audio stream (1.0 is base level)
|
||||||
|
[examples] ADDED: core_custom_logging - Custom trace log system
|
||||||
|
[examples] ADDED: core_input_multitouch - Multitouch input example
|
||||||
|
[examples] REVIEWED: core_vr_simulator - HMD device parameters and distortion shader should be provided
|
||||||
|
[examples] ADDED: core_window_scale_letterbox - Windows resizing and letterbox content
|
||||||
|
[examples] ADDED: shapes_rectangle_scaling_mouse - Scale a rectangle with mouse
|
||||||
|
TODO: [examples] ADDED: shapes_draw_circle_sector - Circle sector drawing
|
||||||
|
TODO: [examples] ADDED: shapes_draw_ring - Ring drawing
|
||||||
|
TODO: [examples] ADDED: shapes_draw_rectangle_rounded - Rounded rectangle drawing
|
||||||
|
[examples] ADDED: textures_background_scrolling - Scrolling and parallaz background effect
|
||||||
|
[examples] ADDED: textures_image_npatch - Drawing N-Patch based boxes
|
||||||
|
TODO: [examples] ADDED: textures_sprite_button
|
||||||
|
TODO: [examples] ADDED: textures_sprite_explosion
|
||||||
|
[examples] ADDED: text_draw_inside_rectangle - Drawing text inside a delimited rectangle box
|
||||||
|
[examples] ADDED: models_animation - Animated models loading and animation playing
|
||||||
|
[examples] ADDED: models_obj_viewer - Draw and drop models viewer
|
||||||
|
[examples] ADDED: models_rlgl_solar_system - Solar system simulation using rlgl functionality
|
||||||
|
[examples] ADDED: shaders_palette_switch - Switching color palette on shader
|
||||||
|
[examples] ADDED: shaders_raymarching - Raymarching shader
|
||||||
|
[examples] ADDED: shaders_texture_drawing - Texture drawing on GPU
|
||||||
|
[examples] REVIEWED: audio_raw_stream - Mostly rewritten
|
||||||
|
[games] ADDED: GGJ19 game - Cat vs Roomba
|
||||||
|
[*] Updated external libraries to latest version
|
||||||
|
[*] Multiple bugs corrected (check github issues)
|
||||||
|
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
Release: raylib 2.0 (July 2018)
|
Release: raylib 2.0 (July 2018)
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -225,3 +225,8 @@ Refactored all raylib configuration #defines into a **centralized `config.h` hea
|
||||||
A part of that, lots of new features, like a brand **new font rendering and packaging system** for TTF fonts with **SDF support** (thanks to the amazing STB headers), new functions for **CPU image data manipulation**, new orthographic 3d camera mode, a complete review of `raymath.h` single-file header-only library for better consistency and performance, new examples and way, [way more](https://github.com/raysan5/raylib/blob/master/CHANGELOG).
|
A part of that, lots of new features, like a brand **new font rendering and packaging system** for TTF fonts with **SDF support** (thanks to the amazing STB headers), new functions for **CPU image data manipulation**, new orthographic 3d camera mode, a complete review of `raymath.h` single-file header-only library for better consistency and performance, new examples and way, [way more](https://github.com/raysan5/raylib/blob/master/CHANGELOG).
|
||||||
|
|
||||||
Probably by now, **raylib 2.0 is the simplest and easiest-to-use library to learn (and understand) videogames programming**... but, undoubtly its development has exceeded any initial objective; raylib has become a simple and easy-to-use trully multiplatform portable standalone media library with thousands of possibilities... and that's just the beginning!
|
Probably by now, **raylib 2.0 is the simplest and easiest-to-use library to learn (and understand) videogames programming**... but, undoubtly its development has exceeded any initial objective; raylib has become a simple and easy-to-use trully multiplatform portable standalone media library with thousands of possibilities... and that's just the beginning!
|
||||||
|
|
||||||
|
notes on raylib 2.5
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
SOON.
|
||||||
28
README.md
28
README.md
|
|
@ -4,11 +4,13 @@
|
||||||
|
|
||||||
raylib is highly inspired by Borland BGI graphics lib and by XNA framework.
|
raylib is highly inspired by Borland BGI graphics lib and by XNA framework.
|
||||||
|
|
||||||
raylib could be useful for prototyping, tools development, graphic applications, embedded systems and education.
|
raylib is especially well suited for prototyping, tooling, graphical applications, embedded systems and education.
|
||||||
|
|
||||||
NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming;
|
NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming;
|
||||||
no fancy interface, no visual helpers, no auto-debugging... just coding in the most
|
no fancy interface, no visual helpers, no auto-debugging... just coding in the most
|
||||||
pure spartan-programmers way. Are you ready to learn? Jump to [code examples!](http://www.raylib.com/examples.html)
|
pure spartan-programmers way.
|
||||||
|
|
||||||
|
Ready to learn? Jump to [code examples!](http://www.raylib.com/examples.html)
|
||||||
|
|
||||||
[](https://travis-ci.org/raysan5/raylib)
|
[](https://travis-ci.org/raysan5/raylib)
|
||||||
[](https://ci.appveyor.com/project/raysan5/raylib)
|
[](https://ci.appveyor.com/project/raysan5/raylib)
|
||||||
|
|
@ -18,20 +20,20 @@ pure spartan-programmers way. Are you ready to learn? Jump to [code examples!](h
|
||||||
|
|
||||||
features
|
features
|
||||||
--------
|
--------
|
||||||
- **NO external dependencies**, all required libraries included with raylib
|
- **NO external dependencies**, all required libraries are bundled into raylib
|
||||||
- Multiple platforms supported: **Windows, Linux, MacOS, Android... and many more!**
|
- Multiple platforms supported: **Windows, Linux, MacOS, Android... and many more!**
|
||||||
- Written in plain C code (C99) in PascalCase/camelCase notation
|
- Written in plain C code (C99) in PascalCase/camelCase notation
|
||||||
- Hardware accelerated with OpenGL (**1.1, 2.1, 3.3 or ES 2.0**)
|
- Hardware accelerated with OpenGL (**1.1, 2.1, 3.3 or ES 2.0**)
|
||||||
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h)
|
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h)
|
||||||
- Multiple Fonts formats supported (XNA fonts, AngelCode fonts, TTF)
|
- Multiple Fonts formats supported (XNA fonts, AngelCode fonts, TTF)
|
||||||
- Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
|
- Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
|
||||||
- **Full 3d support** for 3d Shapes, Models, Billboards, Heightmaps and more!
|
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
|
||||||
- Flexible Materials system, supporting classic maps and **PBR maps**
|
- Flexible Materials system, supporting classic maps and **PBR maps**
|
||||||
- Shaders support, including Model shaders and Postprocessing shaders
|
- Custom shaders, including model and postprocessing shaders.
|
||||||
- **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
|
- **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
|
||||||
- Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
|
- Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
|
||||||
- **VR stereo rendering** support with configurable HMD device parameters
|
- **VR stereo rendering** support with configurable HMD device parameters
|
||||||
- Bindings to **Lua** ([raylib-lua](https://github.com/raysan5/raylib-lua)), **Go** ([raylib-go](https://github.com/gen2brain/raylib-go)) and [more](https://github.com/raysan5/raylib/blob/master/CONTRIBUTING.md#raylib-bindings)!
|
- Bindings to [multiple code languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
||||||
|
|
||||||
raylib uses on its [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module the outstanding [GLFW3](http://www.glfw.org/) library, embedded inside raylib in the form of [rglfw](https://github.com/raysan5/raylib/blob/master/src/rglfw.c) module, avoiding that way external dependencies.
|
raylib uses on its [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module the outstanding [GLFW3](http://www.glfw.org/) library, embedded inside raylib in the form of [rglfw](https://github.com/raysan5/raylib/blob/master/src/rglfw.c) module, avoiding that way external dependencies.
|
||||||
|
|
||||||
|
|
@ -46,16 +48,16 @@ raylib uses internally multiple single-file header-only libraries to support mul
|
||||||
build and installation
|
build and installation
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
Binary releases for Windows, Linux and macOS are available at the [Github Releases](https://github.com/raysan5/raylib/releases) page. raylib is also available via multiple package managers on multiple OS distributions. For more info check [raylib Wiki](https://github.com/raysan5/raylib/wiki).
|
Binary releases for Windows, Linux and macOS are available at the [Github Releases page](https://github.com/raysan5/raylib/releases). raylib is also available via multiple package managers on multiple OS distributions. For more info check [raylib Wiki](https://github.com/raysan5/raylib/wiki).
|
||||||
|
|
||||||
To build raylib yourself, check out also the [raylib Wiki](https://github.com/raysan5/raylib/wiki) for detailed instructions.
|
If you wish to build raylib yourself, [the raylib Wiki](https://github.com/raysan5/raylib/wiki) also contains detailed instructions on how to approach that.
|
||||||
|
|
||||||
raylib has been developed using exclusively two tools:
|
raylib has been developed exclusively using two tools:
|
||||||
|
|
||||||
* Notepad++ (text editor) - [http://notepad-plus-plus.org/](http://notepad-plus-plus.org/)
|
* Notepad++ (text editor) - [http://notepad-plus-plus.org](http://notepad-plus-plus.org/)
|
||||||
* MinGW (GCC compiler) - [http://www.mingw.org/](http://www.mingw.org/)
|
* MinGW (GCC compiler) - [http://www.mingw.org](http://www.mingw.org/)
|
||||||
|
|
||||||
Those are the tools recommended to develop with raylib, in fact, those are the tools my students use.
|
Those tools are recommended for raylib development.
|
||||||
|
|
||||||
contact
|
contact
|
||||||
-------
|
-------
|
||||||
|
|
@ -71,7 +73,7 @@ contact
|
||||||
|
|
||||||
If you are using raylib and you enjoy it, please, [let me know][raysan5].
|
If you are using raylib and you enjoy it, please, [let me know][raysan5].
|
||||||
|
|
||||||
If you feel you can help, then, [helpme!](http://www.raylib.com/helpme.html)
|
If you are able to contribute, then please [helpme](http://www.raylib.com/helpme.html)!
|
||||||
|
|
||||||
license
|
license
|
||||||
-------
|
-------
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,10 @@ Here it is a wish-list with features and ideas to improve the library.
|
||||||
Note that [raylib source code](https://github.com/raysan5/raylib/tree/master/src) has some *TODO* marks around code with pending things to review and improve. Check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
|
Note that [raylib source code](https://github.com/raysan5/raylib/tree/master/src) has some *TODO* marks around code with pending things to review and improve. Check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
|
||||||
|
|
||||||
**raylib 2.x**
|
**raylib 2.x**
|
||||||
- [ ] raynet: Network module
|
- [ ] rnet: Network module
|
||||||
- [ ] Support Vulkan API (GRAPHICS_API_VULKAN)
|
- [ ] Support Vulkan API (GRAPHICS_API_VULKAN)
|
||||||
- [ ] Basic CPU/GPU stats sytem (memory, draws, time...)
|
- [ ] Basic CPU/GPU stats sytem (memory, draws, time...)
|
||||||
- [ ] Support Animated models
|
- [x] Support Animated models (2.5)
|
||||||
|
|
||||||
**raylib 1.8**
|
**raylib 1.8**
|
||||||
- [x] Improved Materials system with PBR support
|
- [x] Improved Materials system with PBR support
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ if(${PLATFORM} MATCHES "Android")
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_billboard.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_billboard.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_rlgl_solar_system.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_rlgl_solar_system.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_obj_viewer.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_obj_viewer.c)
|
||||||
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_animation.c)
|
||||||
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_custom_uniform.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_custom_uniform.c)
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_model_shader.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_model_shader.c)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
|
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
|
||||||
#
|
#
|
||||||
# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5)
|
# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5)
|
||||||
#
|
#
|
||||||
# This software is provided "as-is", without any express or implied warranty. In no event
|
# This software is provided "as-is", without any express or implied warranty. In no event
|
||||||
# will the authors be held liable for any damages arising from the use of this software.
|
# will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
|
@ -377,7 +377,7 @@ EXAMPLES = \
|
||||||
core/core_2d_camera \
|
core/core_2d_camera \
|
||||||
core/core_world_screen \
|
core/core_world_screen \
|
||||||
core/core_vr_simulator \
|
core/core_vr_simulator \
|
||||||
core/core_multitouch \
|
core/core_input_multitouch \
|
||||||
shapes/shapes_logo_raylib \
|
shapes/shapes_logo_raylib \
|
||||||
shapes/shapes_basic_shapes \
|
shapes/shapes_basic_shapes \
|
||||||
shapes/shapes_colors_palette \
|
shapes/shapes_colors_palette \
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
* This example has been created using raylib 1.6 (www.raylib.com)
|
* This example has been created using raylib 1.6 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2015-2018 Ramon Santamaria (@raysan5) and James Hofmann (@triplefox)
|
* Copyright (c) 2015-2019 Ramon Santamaria (@raysan5) and James Hofmann (@triplefox)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
87
examples/core/core_input_multitouch.c
Normal file
87
examples/core/core_input_multitouch.c
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [core] example - Input multitouch
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 2.1 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014-2019 Berni and Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
int screenWidth = 800;
|
||||||
|
int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - input multitouch");
|
||||||
|
|
||||||
|
Vector2 ballPosition = { -100.0f, -100.0f };
|
||||||
|
Color ballColor = BEIGE;
|
||||||
|
|
||||||
|
int touchCounter = 0;
|
||||||
|
Vector2 touchPosition;
|
||||||
|
|
||||||
|
SetTargetFPS(60);
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
ballPosition = GetMousePosition();
|
||||||
|
|
||||||
|
ballColor = BEIGE;
|
||||||
|
|
||||||
|
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) ballColor = MAROON;
|
||||||
|
if (IsMouseButtonDown(MOUSE_MIDDLE_BUTTON)) ballColor = LIME;
|
||||||
|
if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE;
|
||||||
|
|
||||||
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) touchCounter = 10;
|
||||||
|
if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) touchCounter = 10;
|
||||||
|
if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) touchCounter = 10;
|
||||||
|
|
||||||
|
if (touchCounter > 0) touchCounter--;
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
// Multitouch
|
||||||
|
for (int i = 0; i < MAX_TOUCH_POINTS; ++i)
|
||||||
|
{
|
||||||
|
touchPosition = GetTouchPosition(i); // Get the touch point
|
||||||
|
|
||||||
|
if ((touchPosition.x >= 0) && (touchPosition.y >= 0)) // Make sure point is not (-1,-1) as this means there is no touch for it
|
||||||
|
{
|
||||||
|
// Draw circle and touch index number
|
||||||
|
DrawCircleV(touchPosition, 34, ORANGE);
|
||||||
|
DrawText(FormatText("%d", i), touchPosition.x - 10, touchPosition.y - 70, 40, BLACK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw the normal mouse location
|
||||||
|
DrawCircleV(ballPosition, 30 + (touchCounter*3), ballColor);
|
||||||
|
|
||||||
|
DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY);
|
||||||
|
DrawText("touch the screen at multiple locations to get multiple balls", 10, 30, 20, DARKGRAY);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
examples/core/core_input_multitouch.png
Normal file
BIN
examples/core/core_input_multitouch.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
|
|
@ -23,7 +23,35 @@ int main()
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - vr simulator");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - vr simulator");
|
||||||
|
|
||||||
// Init VR simulator (Oculus Rift CV1 parameters)
|
// Init VR simulator (Oculus Rift CV1 parameters)
|
||||||
InitVrSimulator(GetVrDeviceInfo(HMD_OCULUS_RIFT_CV1));
|
InitVrSimulator();
|
||||||
|
|
||||||
|
VrDeviceInfo hmd = { 0 }; // VR device parameters (head-mounted-device)
|
||||||
|
|
||||||
|
// Oculus Rift CV1 parameters for simulator
|
||||||
|
hmd.hResolution = 2160; // HMD horizontal resolution in pixels
|
||||||
|
hmd.vResolution = 1200; // HMD vertical resolution in pixels
|
||||||
|
hmd.hScreenSize = 0.133793f; // HMD horizontal size in meters
|
||||||
|
hmd.vScreenSize = 0.0669f; // HMD vertical size in meters
|
||||||
|
hmd.vScreenCenter = 0.04678f; // HMD screen center in meters
|
||||||
|
hmd.eyeToScreenDistance = 0.041f; // HMD distance between eye and display in meters
|
||||||
|
hmd.lensSeparationDistance = 0.07f; // HMD lens separation distance in meters
|
||||||
|
hmd.interpupillaryDistance = 0.07f; // HMD IPD (distance between pupils) in meters
|
||||||
|
|
||||||
|
// NOTE: CV1 uses a Fresnel-hybrid-asymmetric lenses with specific distortion compute shaders.
|
||||||
|
// Following parameters are an approximation to distortion stereo rendering but results differ from actual device.
|
||||||
|
hmd.lensDistortionValues[0] = 1.0f; // HMD lens distortion constant parameter 0
|
||||||
|
hmd.lensDistortionValues[1] = 0.22f; // HMD lens distortion constant parameter 1
|
||||||
|
hmd.lensDistortionValues[2] = 0.24f; // HMD lens distortion constant parameter 2
|
||||||
|
hmd.lensDistortionValues[3] = 0.0f; // HMD lens distortion constant parameter 3
|
||||||
|
hmd.chromaAbCorrection[0] = 0.996f; // HMD chromatic aberration correction parameter 0
|
||||||
|
hmd.chromaAbCorrection[1] = -0.004f; // HMD chromatic aberration correction parameter 1
|
||||||
|
hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2
|
||||||
|
hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3
|
||||||
|
|
||||||
|
// Distortion shader (uses device lens distortion and chroma)
|
||||||
|
Shader distortion = LoadShader(0, "resources/distortion.fs");
|
||||||
|
|
||||||
|
SetVrConfiguration(hmd, distortion); // Set Vr device parameters for stereo rendering
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera;
|
Camera camera;
|
||||||
|
|
@ -77,9 +105,11 @@ int main()
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
CloseVrSimulator(); // Close VR simulator
|
UnloadShader(distortion); // Unload distortion shader
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseVrSimulator(); // Close VR simulator
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
88
examples/core/core_window_scale_letterbox.c
Normal file
88
examples/core/core_window_scale_letterbox.c
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [core] example - window scale letterbox
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Anata and Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#define max(a, b) ((a)>(b)? (a) : (b))
|
||||||
|
#define min(a, b) ((a)<(b)? (a) : (b))
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
const int windowWidth = 800;
|
||||||
|
const int windowHeight = 450;
|
||||||
|
|
||||||
|
// Enable config flags for resizable window and vertical synchro
|
||||||
|
SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT);
|
||||||
|
InitWindow(windowWidth, windowHeight, "raylib [core] example - window scale letterbox");
|
||||||
|
SetWindowMinSize(320, 240);
|
||||||
|
|
||||||
|
int gameScreenWidth = 640;
|
||||||
|
int gameScreenHeight = 480;
|
||||||
|
|
||||||
|
// Render texture initialization
|
||||||
|
RenderTexture2D target = LoadRenderTexture(gameScreenWidth, gameScreenHeight);
|
||||||
|
SetTextureFilter(target.texture, FILTER_BILINEAR); // Texture scale filter to use
|
||||||
|
|
||||||
|
Color colors[10] = { 0 };
|
||||||
|
for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 };
|
||||||
|
|
||||||
|
SetTargetFPS(60);
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while( !WindowShouldClose() ) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Compute required framebuffer scaling
|
||||||
|
float scale = min((float)GetScreenWidth()/gameScreenWidth, (float)GetScreenHeight()/gameScreenHeight);
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_SPACE))
|
||||||
|
{
|
||||||
|
// Recalculate random colors for the bars
|
||||||
|
for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 };
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
ClearBackground(BLACK);
|
||||||
|
|
||||||
|
// Draw everything in the render texture
|
||||||
|
BeginTextureMode(target);
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE); // Clear render texture background color
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; i++) DrawRectangle(0, (gameScreenHeight/10)*i, gameScreenWidth, gameScreenHeight/10, colors[i]);
|
||||||
|
|
||||||
|
DrawText("You can resize the window,\nand see the screen scaling!", 10, 25, 20, WHITE);
|
||||||
|
|
||||||
|
EndTextureMode();
|
||||||
|
|
||||||
|
// Draw RenderTexture2D to window, properly scaled
|
||||||
|
DrawTexturePro(target.texture, (Rectangle){ 0.0f, 0.0f, (float)target.texture.width, (float)-target.texture.height },
|
||||||
|
(Rectangle){ (GetScreenWidth() - ((float)gameScreenWidth*scale))*0.5, (GetScreenHeight() - ((float)gameScreenHeight*scale))*0.5,
|
||||||
|
(float)gameScreenWidth*scale, (float)gameScreenHeight*scale }, (Vector2){ 0, 0 }, 0.0f, WHITE);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
UnloadRenderTexture(target); // Unload render texture
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
examples/core/core_window_scale_letterbox.png
Normal file
BIN
examples/core/core_window_scale_letterbox.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
43
examples/core/resources/distortion.fs
Normal file
43
examples/core/resources/distortion.fs
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
#version 330
|
||||||
|
|
||||||
|
in vec2 fragTexCoord;
|
||||||
|
in vec4 fragColor;
|
||||||
|
out vec4 finalColor;
|
||||||
|
|
||||||
|
uniform sampler2D texture0;
|
||||||
|
uniform vec2 leftLensCenter = vec2(0.288, 0.5);
|
||||||
|
uniform vec2 rightLensCenter = vec2(0.712, 0.5);
|
||||||
|
uniform vec2 leftScreenCenter = vec2(0.25, 0.5);
|
||||||
|
uniform vec2 rightScreenCenter = vec2(0.75, 0.5);
|
||||||
|
uniform vec2 scale = vec2(0.25, 0.45);
|
||||||
|
uniform vec2 scaleIn = vec2(4, 2.2222);
|
||||||
|
uniform vec4 hmdWarpParam = vec4(1, 0.22, 0.24, 0);
|
||||||
|
uniform vec4 chromaAbParam = vec4(0.996, -0.004, 1.014, 0.0);
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter;
|
||||||
|
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter;
|
||||||
|
vec2 theta = (fragTexCoord - lensCenter)*scaleIn;
|
||||||
|
float rSq = theta.x*theta.x + theta.y*theta.y;
|
||||||
|
vec2 theta1 = theta*(hmdWarpParam.x + hmdWarpParam.y*rSq + hmdWarpParam.z*rSq*rSq + hmdWarpParam.w*rSq*rSq*rSq);
|
||||||
|
vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq);
|
||||||
|
vec2 tcBlue = lensCenter + scale*thetaBlue;
|
||||||
|
|
||||||
|
if (any(bvec2(clamp(tcBlue, screenCenter - vec2(0.25, 0.5), screenCenter + vec2(0.25, 0.5)) - tcBlue)))
|
||||||
|
{
|
||||||
|
finalColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float blue = texture(texture0, tcBlue).b;
|
||||||
|
vec2 tcGreen = lensCenter + scale*theta1;
|
||||||
|
float green = texture(texture0, tcGreen).g;
|
||||||
|
|
||||||
|
vec2 thetaRed = theta1*(chromaAbParam.x + chromaAbParam.y*rSq);
|
||||||
|
vec2 tcRed = lensCenter + scale*thetaRed;
|
||||||
|
|
||||||
|
float red = texture(texture0, tcRed).r;
|
||||||
|
finalColor = vec4(red, green, blue, 1.0);
|
||||||
|
}
|
||||||
|
};
|
||||||
101
examples/models/models_animation.c
Normal file
101
examples/models/models_animation.c
Normal file
|
|
@ -0,0 +1,101 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [models] example - Load 3d model with animations and play them
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Ramon Santamaria (@raysan5) and @culacant
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
int screenWidth = 800;
|
||||||
|
int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - model animation");
|
||||||
|
|
||||||
|
// Define the camera to look into our 3d world
|
||||||
|
Camera camera = { 0 };
|
||||||
|
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
|
||||||
|
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||||
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
|
camera.type = CAMERA_PERSPECTIVE; // Camera mode type
|
||||||
|
|
||||||
|
|
||||||
|
Model model = LoadModel("resources/guy/guy.iqm"); // Load the animated model mesh and basic data
|
||||||
|
Texture2D texture = LoadTexture("resources/guy/guytex.png"); // Load model texture and set material
|
||||||
|
SetMaterialTexture(&model.materials[0], MAP_DIFFUSE, texture); // Set model material map texture
|
||||||
|
|
||||||
|
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
|
|
||||||
|
// Load animation data
|
||||||
|
int animsCount = 0;
|
||||||
|
ModelAnimation *anims = LoadModelAnimations("resources/guy/guyanim.iqm", &animsCount);
|
||||||
|
int animFrameCounter = 0;
|
||||||
|
|
||||||
|
SetCameraMode(camera, CAMERA_FREE); // Set free camera mode
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
UpdateCamera(&camera);
|
||||||
|
|
||||||
|
// Play animation when spacebar is held down
|
||||||
|
if (IsKeyDown(KEY_SPACE))
|
||||||
|
{
|
||||||
|
animFrameCounter++;
|
||||||
|
UpdateModelAnimation(model, anims[0], animFrameCounter);
|
||||||
|
if (animFrameCounter >= anims[0].frameCount) animFrameCounter = 0;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
BeginMode3D(camera);
|
||||||
|
|
||||||
|
DrawModelEx(model, position, (Vector3){ 1.0f, 0.0f, 0.0f }, -90.0f, (Vector3){ 1.0f, 1.0f, 1.0f }, WHITE);
|
||||||
|
|
||||||
|
for (int i = 0; i < model.boneCount; i++)
|
||||||
|
{
|
||||||
|
DrawCube(anims[0].framePoses[animFrameCounter][i].translation, 0.2f, 0.2f, 0.2f, RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawGrid(10, 1.0f); // Draw a grid
|
||||||
|
|
||||||
|
EndMode3D();
|
||||||
|
|
||||||
|
DrawText("PRESS SPACE to PLAY MODEL ANIMATION", 10, 10, 20, MAROON);
|
||||||
|
DrawText("(c) Guy IQM 3D model by @culacant", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Unload model animations data
|
||||||
|
for (int i = 0; i < animsCount; i++) UnloadModelAnimation(anims[i]);
|
||||||
|
|
||||||
|
UnloadModel(model); // Unload model
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -31,7 +31,7 @@ int main()
|
||||||
|
|
||||||
// NOTE: By default each cube is mapped to one part of texture atlas
|
// NOTE: By default each cube is mapped to one part of texture atlas
|
||||||
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture
|
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture
|
||||||
model.material.maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||||
|
|
||||||
Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position
|
Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ int main()
|
||||||
Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 8, 16 }); // Generate heightmap mesh (RAM and VRAM)
|
Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 8, 16 }); // Generate heightmap mesh (RAM and VRAM)
|
||||||
Model model = LoadModelFromMesh(mesh); // Load model from generated mesh
|
Model model = LoadModelFromMesh(mesh); // Load model from generated mesh
|
||||||
|
|
||||||
model.material.maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||||
Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Define model position
|
Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Define model position
|
||||||
|
|
||||||
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
|
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "raymath.h"
|
#include "raymath.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#define RLIGHTS_IMPLEMENTATION
|
#define RLIGHTS_IMPLEMENTATION
|
||||||
#include "rlights.h"
|
#include "rlights.h"
|
||||||
|
|
||||||
|
|
@ -34,20 +36,29 @@ int main()
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - pbr material");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - pbr material");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = {{ 4.0f, 4.0f, 4.0f }, { 0.0f, 0.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
Camera camera = { 0 };
|
||||||
|
camera.position = (Vector3){ 4.0f, 4.0f, 4.0f }; // Camera position
|
||||||
|
camera.target = (Vector3){ 0.0f, 0.5f, 0.0f }; // Camera looking at point
|
||||||
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
|
camera.type = CAMERA_PERSPECTIVE; // Camera mode type
|
||||||
|
|
||||||
// Load model and PBR material
|
// Load model and PBR material
|
||||||
Model model = LoadModel("resources/pbr/trooper.obj");
|
Model model = LoadModel("resources/pbr/trooper.obj");
|
||||||
MeshTangents(&model.mesh);
|
|
||||||
model.material = LoadMaterialPBR((Color){ 255, 255, 255, 255 }, 1.0f, 1.0f);
|
// Mesh tangents are generated... and uploaded to GPU
|
||||||
|
// NOTE: New VBO for tangents is generated at default location and also binded to mesh VAO
|
||||||
|
MeshTangents(&model.meshes[0]);
|
||||||
|
|
||||||
|
model.materials[0] = LoadMaterialPBR((Color){ 255, 255, 255, 255 }, 1.0f, 1.0f);
|
||||||
|
|
||||||
// Define lights attributes
|
// Define lights attributes
|
||||||
// NOTE: Shader is passed to every light on creation to define shader bindings internally
|
// NOTE: Shader is passed to every light on creation to define shader bindings internally
|
||||||
Light lights[MAX_LIGHTS] = {
|
Light lights[MAX_LIGHTS] = {
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 0, 255 }, model.material.shader),
|
CreateLight(LIGHT_POINT, (Vector3){ LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 0, 255 }, model.materials[0].shader),
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ 0.0f, LIGHT_HEIGHT, LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 255, 0, 255 }, model.material.shader),
|
CreateLight(LIGHT_POINT, (Vector3){ 0.0f, LIGHT_HEIGHT, LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 255, 0, 255 }, model.materials[0].shader),
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 0, 255, 255 }, model.material.shader),
|
CreateLight(LIGHT_POINT, (Vector3){ -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 0, 255, 255 }, model.materials[0].shader),
|
||||||
CreateLight(LIGHT_DIRECTIONAL, (Vector3){ 0.0f, LIGHT_HEIGHT*2.0f, -LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 255, 255 }, model.material.shader)
|
CreateLight(LIGHT_DIRECTIONAL, (Vector3){ 0.0f, LIGHT_HEIGHT*2.0f, -LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 255, 255 }, model.materials[0].shader)
|
||||||
};
|
};
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
||||||
|
|
@ -64,7 +75,7 @@ int main()
|
||||||
|
|
||||||
// Send to material PBR shader camera view position
|
// Send to material PBR shader camera view position
|
||||||
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };
|
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };
|
||||||
SetShaderValue(model.material.shader, model.material.shader.locs[LOC_VECTOR_VIEW], cameraPos, UNIFORM_VEC3);
|
SetShaderValue(model.materials[0].shader, model.materials[0].shader.locs[LOC_VECTOR_VIEW], cameraPos, UNIFORM_VEC3);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
@ -143,9 +154,13 @@ static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
|
||||||
#define PATH_BRDF_FS "resources/shaders/brdf.fs" // Path to bidirectional reflectance distribution function fragment shader
|
#define PATH_BRDF_FS "resources/shaders/brdf.fs" // Path to bidirectional reflectance distribution function fragment shader
|
||||||
|
|
||||||
Shader shdrCubemap = LoadShader(PATH_CUBEMAP_VS, PATH_CUBEMAP_FS);
|
Shader shdrCubemap = LoadShader(PATH_CUBEMAP_VS, PATH_CUBEMAP_FS);
|
||||||
|
printf("Loaded shader: cubemap\n");
|
||||||
Shader shdrIrradiance = LoadShader(PATH_SKYBOX_VS, PATH_IRRADIANCE_FS);
|
Shader shdrIrradiance = LoadShader(PATH_SKYBOX_VS, PATH_IRRADIANCE_FS);
|
||||||
|
printf("Loaded shader: irradiance\n");
|
||||||
Shader shdrPrefilter = LoadShader(PATH_SKYBOX_VS, PATH_PREFILTER_FS);
|
Shader shdrPrefilter = LoadShader(PATH_SKYBOX_VS, PATH_PREFILTER_FS);
|
||||||
|
printf("Loaded shader: prefilter\n");
|
||||||
Shader shdrBRDF = LoadShader(PATH_BRDF_VS, PATH_BRDF_FS);
|
Shader shdrBRDF = LoadShader(PATH_BRDF_VS, PATH_BRDF_FS);
|
||||||
|
printf("Loaded shader: brdf\n");
|
||||||
|
|
||||||
// Setup required shader locations
|
// Setup required shader locations
|
||||||
SetShaderValue(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), (int[1]){ 0 }, UNIFORM_INT);
|
SetShaderValue(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), (int[1]){ 0 }, UNIFORM_INT);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ int main()
|
||||||
models[7] = LoadModelFromMesh(GenMeshPoly(5, 2.0f));
|
models[7] = LoadModelFromMesh(GenMeshPoly(5, 2.0f));
|
||||||
|
|
||||||
// Set checked texture as default diffuse component for all models material
|
// Set checked texture as default diffuse component for all models material
|
||||||
for (int i = 0; i < NUM_MODELS; i++) models[i].material.maps[MAP_DIFFUSE].texture = texture;
|
for (int i = 0; i < NUM_MODELS; i++) models[i].materials[0].maps[MAP_DIFFUSE].texture = texture;
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = {{ 5.0f, 5.0f, 5.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
Camera camera = {{ 5.0f, 5.0f, 5.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||||
|
|
@ -65,6 +65,17 @@ int main()
|
||||||
{
|
{
|
||||||
currentModel = (currentModel + 1)%NUM_MODELS; // Cycle between the textures
|
currentModel = (currentModel + 1)%NUM_MODELS; // Cycle between the textures
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_RIGHT))
|
||||||
|
{
|
||||||
|
currentModel++;
|
||||||
|
if (currentModel >= NUM_MODELS) currentModel = 0;
|
||||||
|
}
|
||||||
|
else if (IsKeyPressed(KEY_LEFT))
|
||||||
|
{
|
||||||
|
currentModel--;
|
||||||
|
if (currentModel < 0) currentModel = NUM_MODELS - 1;
|
||||||
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ int main()
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = { 0 };
|
Camera camera = { 0 };
|
||||||
camera.position = (Vector3){ 20.0f, 20.0f, 20.0f }; // Camera position
|
camera.position = (Vector3){ 20.0f, 20.0f, 20.0f }; // Camera position
|
||||||
camera.target = (Vector3){ 0.0f, 8.0f, 0.0f }; // Camera looking at point
|
camera.target = (Vector3){ 0.0f, 8.0f, 0.0f }; // Camera looking at point
|
||||||
camera.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target)
|
camera.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
|
|
@ -36,10 +36,10 @@ int main()
|
||||||
|
|
||||||
Model tower = LoadModel("resources/models/turret.obj"); // Load OBJ model
|
Model tower = LoadModel("resources/models/turret.obj"); // Load OBJ model
|
||||||
Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load model texture
|
Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load model texture
|
||||||
tower.material.maps[MAP_DIFFUSE].texture = texture; // Set model diffuse texture
|
tower.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set model diffuse texture
|
||||||
|
|
||||||
Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position
|
Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
BoundingBox towerBBox = MeshBoundingBox(tower.mesh); // Get mesh bounding box
|
BoundingBox towerBBox = MeshBoundingBox(tower.meshes[0]); // Get mesh bounding box
|
||||||
bool hitMeshBBox = false;
|
bool hitMeshBBox = false;
|
||||||
bool hitTriangle = false;
|
bool hitTriangle = false;
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue