commit
4a63e5dfb3
26 changed files with 3109 additions and 258 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -143,6 +143,7 @@ install_manifest.txt
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
CTestTestfile.cmake
|
CTestTestfile.cmake
|
||||||
build
|
build
|
||||||
|
!templates/android_project/Makefile
|
||||||
|
|
||||||
# Unignore These makefiles...
|
# Unignore These makefiles...
|
||||||
!examples/CMakeLists.txt
|
!examples/CMakeLists.txt
|
||||||
|
|
|
||||||
87
CHANGELOG
87
CHANGELOG
|
|
@ -1,7 +1,88 @@
|
||||||
changelog
|
changelog
|
||||||
---------
|
---------
|
||||||
|
|
||||||
Current Release: raylib 1.7.0 (20 May 2017)
|
Current Release: raylib 1.8.0 (Oct 2017)
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
Release: raylib 1.8.0 (Oct 2017)
|
||||||
|
-----------------------------------------------
|
||||||
|
NOTE:
|
||||||
|
In this release, multiple parts of the library have been reviewed again for consistency and simplification.
|
||||||
|
It exposes more than 20 new functions in comparison with previous version and it improves overall programming experience.
|
||||||
|
|
||||||
|
BIG CHANGES:
|
||||||
|
- Image generation functions: Gradient, Checked, Noise, Cellular...
|
||||||
|
- Mesh generation functions: Cube, Sphere, Cylinder, Torus, Knot...
|
||||||
|
- New Shaders and Materials systems to support PBR materials
|
||||||
|
- Custom Android toolchain for APK building with simple Makefile
|
||||||
|
- Complete review of raymath functionality (Matrix, Quaternion)
|
||||||
|
- Complete review of rlgl layer functionality
|
||||||
|
|
||||||
|
detailed changes:
|
||||||
|
[rlgl] RENAMED: rlglLoadTexture() to rlLoadTexture()
|
||||||
|
[rlgl] RENAMED: rlglLoadRenderTexture() to rlLoadRenderTexture()
|
||||||
|
[rlgl] RENAMED: rlglUpdateTexture() to rlUpdateTexture()
|
||||||
|
[rlgl] RENAMED: rlglGenerateMipmaps() to rlGenerateMipmaps()
|
||||||
|
[rlgl] RENAMED: rlglReadScreenPixels() to rlReadScreenPixels()
|
||||||
|
[rlgl] RENAMED: rlglReadTexturePixels() to rlReadTexturePixels()
|
||||||
|
[rlgl] RENAMED: rlglLoadMesh() to rlLoadMesh()
|
||||||
|
[rlgl] RENAMED: rlglUpdateMesh() to rlUpdateMesh()
|
||||||
|
[rlgl] RENAMED: rlglDrawMesh() to rlDrawMesh()
|
||||||
|
[rlgl] RENAMED: rlglUnloadMesh() to rlUnloadMesh()
|
||||||
|
[rlgl] RENAMED: rlglUnproject() to rlUnproject()
|
||||||
|
[rlgl] RENAMED: LoadCompressedTexture() to LoadTextureCompressed()
|
||||||
|
[rlgl] RENAMED: GetDefaultTexture() to GetTextureDefault()
|
||||||
|
[rlgl] RENAMED: LoadDefaultShader() to LoadShaderDefault()
|
||||||
|
[rlgl] RENAMED: LoadDefaultShaderLocations() to SetShaderDefaultLocations()
|
||||||
|
[rlgl] RENAMED: UnloadDefaultShader() to UnLoadShaderDefault()
|
||||||
|
// Texture maps generation (PBR)
|
||||||
|
[rlgl] ADDED: rlGenMapCubemap(Texture2D skyHDR, int size); // Generate cubemap texture map from HDR texture
|
||||||
|
[rlgl] ADDED: rlGenMapIrradiance(Texture2D cubemap, int size); // Generate irradiance texture map
|
||||||
|
[rlgl] ADDED: rlGenMapPrefilter(Texture2D cubemap, int size); // Generate prefilter texture map
|
||||||
|
[rlgl] ADDED: rlGenMapBRDF(Texture2D cubemap, int size); // Generate BRDF texture map
|
||||||
|
[core] ADDED: SetWindowTitle()
|
||||||
|
[core] ADDED: GetExtension()
|
||||||
|
[textures] ADDED: SaveImageAs()
|
||||||
|
? [textures] ADDED: DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // Draw a gradient-filled rectangle with custom vertex colors
|
||||||
|
? [textures] ADDED: DrawRectangleT(int posX, int posY, int width, int height, Color color); // Draw rectangle using text character
|
||||||
|
// Image generation functions
|
||||||
|
[textures] ADDED: GenImageGradientV(int width, int height, Color top, Color bottom); // Generate image: vertical gradient
|
||||||
|
[textures] ADDED: GenImageGradientH(int width, int height, Color left, Color right); // Generate image: horizontal gradient
|
||||||
|
[textures] ADDED: GenImageGradientRadial(int width, int height, float density, Color inner, Color outer); // Generate image: radial gradient
|
||||||
|
[textures] ADDED: GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2); // Generate image: checked
|
||||||
|
[textures] ADDED: GenImageWhiteNoise(int width, int height, float factor); // Generate image: white noise
|
||||||
|
[textures] ADDED: GenImagePerlinNoise(int width, int height, float scale); // Generate image: perlin noise
|
||||||
|
[textures] ADDED: GenImageCellular(int width, int height, int tileSize); // Generate image: cellular algorithm. Bigger tileSize means bigger cells
|
||||||
|
// Texture maps generation (PBR)
|
||||||
|
[textures] ADDED: GenTextureCubemap(Shader shader, Texture2D skyHDR, int size); // Generate cubemap texture from HDR texture
|
||||||
|
[textures] ADDED: GenTextureIrradiance(Shader shader, Texture2D cubemap, int size); // Generate irradiance texture using cubemap data
|
||||||
|
[textures] ADDED: GenTexturePrefilter(Shader shader, Texture2D cubemap, int size); // Generate prefilter texture using cubemap data
|
||||||
|
[textures] ADDED: GenTextureBRDF(Shader shader, Texture2D cubemap, int size); // Generate BRDF texture using cubemap data
|
||||||
|
[models] REMOVED: LoadMeshEx()
|
||||||
|
[models] REMOVED: UpdateMesh()
|
||||||
|
[models] REMOVED: LoadHeightmap()
|
||||||
|
[models] REMOVED: LoadCubicmap()
|
||||||
|
[models] RENAMED: LoadDefaultMaterial() to LoadMaterialDefault()
|
||||||
|
// Mesh generation functions
|
||||||
|
[models] ADDED: GenMeshPlane()
|
||||||
|
[models] ADDED: GenMeshCube()
|
||||||
|
[models] ADDED: GenMeshSphere()
|
||||||
|
[models] ADDED: GenMeshHemiSphere(float radius, int rings, int slices); // Generate half-sphere mesh (no bottom cap)
|
||||||
|
[models] ADDED: GenMeshCylinder(float radius, float height, int slices); // Generate cylinder mesh
|
||||||
|
[models] ADDED: GenMeshTorus(float radius, float size, int radSeg, int sides); // Generate torus mesh
|
||||||
|
[models] ADDED: GenMeshKnot(float radius, float size, int radSeg, int sides); // Generate trefoil knot mesh
|
||||||
|
[models] ADDED: GenMeshHeightmap(Image heightmap, Vector3 size); // Generate heightmap mesh from image data
|
||||||
|
[models] ADDED: GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); // Generate cubes-based map mesh from image data
|
||||||
|
|
||||||
|
[raymath] Reviewed full Matrix functionality
|
||||||
|
[raymath] Renamed Vector3 functions for consistency
|
||||||
|
[build] Integrate Android APK building into examples Makefile
|
||||||
|
[example] ADDED:
|
||||||
|
[example] ADDED:
|
||||||
|
[example] ADDED:
|
||||||
|
[github] Moved raylib webpage to own repo: github.com/raysan5/raylib.com
|
||||||
|
[games] Reviewed game: Koala Seasons
|
||||||
|
[*] Updated STB libraries to latest version
|
||||||
|
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
Release: raylib 1.7.0 (20 May 2017)
|
Release: raylib 1.7.0 (20 May 2017)
|
||||||
|
|
@ -36,14 +117,14 @@ other changes:
|
||||||
[rlgl] Removed function: CreateLight(), removed internal lighting system
|
[rlgl] Removed function: CreateLight(), removed internal lighting system
|
||||||
[rlgl] Removed function: DestroyLight(), 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: InitVrDevice(), removed VR device render, using simulator
|
||||||
[rlgl] Removed function: CloseVrDevice(), 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: IsVrDeviceReady(), removed VR device render, using simulator
|
||||||
[rlgl] Removed function: IsVrSimulator(), 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: InitVrSimulator(), init VR simulator for selected device
|
||||||
[rlgl] Added function: CloseVrSimulator(), close VR simulator for current device
|
[rlgl] Added function: CloseVrSimulator(), close VR simulator for current device
|
||||||
[rlgl] Added function: IsVrSimulatorReady(), detect if VR device is ready
|
[rlgl] Added function: IsVrSimulatorReady(), detect if VR device is ready
|
||||||
[rlgl] Added function: BeginVrDrawing(), begin VR simulator stereo rendering
|
[rlgl] Added function: BeginVrDrawing(), begin VR simulator stereo rendering
|
||||||
[rlgl] Added function: EndVrDrawing(), end VR simulator stereo rendering
|
[rlgl] Added function: EndVrDrawing(), end VR simulator stereo rendering
|
||||||
[rlgl] Renamed function: ReadTextFile() to LoadText() and exposed to API
|
[rlgl] Renamed function: ReadTextFile() to LoadText() and exposed to API
|
||||||
[rlgl] Removed internal lighting system and standard shader, moved to example
|
[rlgl] Removed internal lighting system and standard shader, moved to example
|
||||||
[rlgl] Removed Oculus Rift support, moved to oculus_rift example
|
[rlgl] Removed Oculus Rift support, moved to oculus_rift example
|
||||||
|
|
|
||||||
34
CONTRIBUTORS.md
Normal file
34
CONTRIBUTORS.md
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
|
||||||
|
I believe that time is the most valuable resource and the following people have invested part of their time
|
||||||
|
contributing (in some way or another) to make raylib project better. Huge thanks!
|
||||||
|
|
||||||
|
- [Zopokx](https://github.com/Zopokx) for testing the web.
|
||||||
|
- [Elendow](http://www.elendow.com) for testing and helping on web development.
|
||||||
|
- Victor Dual for implementing and testing 3D shapes functions.
|
||||||
|
- Marc Palau for implementing and testing 3D shapes functions and contribute on camera and gestures modules.
|
||||||
|
- Kevin Gato for improving texture internal formats support and helping on raygui development.
|
||||||
|
- Daniel Nicolas for improving texture internal formats support and helping on raygui development.
|
||||||
|
- Marc Agüera for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
|
||||||
|
- Daniel Moreno for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
|
||||||
|
- Daniel Gomez for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
|
||||||
|
- [Sergio Martinez](https://github.com/anidealgift) for helping on raygui development and tools development (raygui_styler).
|
||||||
|
- [Victor Fisac](https://github.com/victorfisac) for developing physics raylib module (physac) and implementing materials and lighting systems... among multiple other improvements and multiple tools and games.
|
||||||
|
- Albert Martos for helping on raygui and porting examples and game-templates to Android and HTML5.
|
||||||
|
- Ian Eito for helping on raygui and porting examples and game-templates to Android and HTML5.
|
||||||
|
- [procedural](https://github.com/procedural) for testing raylib on Linux, correcting some bugs and adding several mouse functions.
|
||||||
|
- [Chris Hemingway](https://github.com/cHemingway) for improving raylib on OSX build system.
|
||||||
|
- [Emanuele Petriglia](https://github.com/LelixSuper) for working on multiple GNU/Linux improvements and developing [TicTacToe](https://github.com/LelixSuper/TicTacToe) raylib game.
|
||||||
|
- [Joshua Reisenauer](https://github.com/kd7tck) for adding audio modules support (XM, MOD) and reviewing audio system.
|
||||||
|
- [Marcelo Paez](https://github.com/paezao) for his help on OSX to solve High DPI display issue. Thanks Marcelo!
|
||||||
|
- [Ghassan Al-Mashareqa](https://github.com/ghassanpl) for his amazing contribution with raylib Lua module, I just work over his code to implement [rlua](https://github.com/raysan5/raylib/blob/master/src/rlua.h)
|
||||||
|
- [Teodor Stoenescu](https://github.com/teodor-stoenescu) for his improvements on OBJ object loading.
|
||||||
|
- [RDR8](https://github.com/RDR8) for helping with Linux build improvements
|
||||||
|
- [Saggi Mizrahi](https://github.com/ficoos) for multiple fixes on Linux and audio system
|
||||||
|
- [Daniel Lemos](https://github.com/xspager) for fixing issues on Linux games building
|
||||||
|
- [Joel Davis](https://github.com/joeld42) for adding raycast picking utilities and a [great example](https://github.com/raysan5/raylib/blob/master/examples/models/models_mesh_picking.c)
|
||||||
|
- [Richard Goodwin](https://github.com/AudioMorphology) for adding RPI touchscreen support
|
||||||
|
- [Milan Nikolic](https://github.com/gen2brain) for adding Android build support with custom standalone toolchain
|
||||||
|
|
||||||
|
** TODO **
|
||||||
|
|
||||||
|
Please, if I forget someone in this list, excuse me and write me an email to remind me to add you!
|
||||||
|
|
@ -8,12 +8,12 @@ The following help is highly appreciated:
|
||||||
|
|
||||||
- C programming - Can you write / review / test / improve the code?
|
- C programming - Can you write / review / test / improve the code?
|
||||||
- Documentation / Tutorials / Example writters - Can you write some tutorial / example?
|
- Documentation / Tutorials / Example writters - Can you write some tutorial / example?
|
||||||
- Web Development - Can you help with the web? Can you setup a forum?
|
- Web Development - Can you help with the web? SEO, style, code writting: https://github.com/raysan5/raylib.com
|
||||||
- Porting to Linux, OSX, RaspberryPi, consoles... - Can you compile and test raylib on another systems?
|
- Porting to Linux, OSX, RaspberryPi, consoles... - Can you compile and test raylib on another systems?
|
||||||
- Testers of current features and multiple systems - Can you find some bug on raylib?
|
- Testers of current features and multiple systems - Can you find some bug on raylib?
|
||||||
|
|
||||||
If you can not help on any of the above points but you still want to contribute in some way... please, consider helping
|
If you can not help on any of the above points but you still want to contribute in some way... please, consider helping
|
||||||
with a small [donation](http://www.raylib.com/helpme.html) or contributing with [raylib patreon](https://www.patreon.com/raysan5). It will really motivate to continue improving this project (and pay some bills… or some coffee).
|
with a small [donation](http://www.raylib.com/helpme.html) or contributing with [raylib patreon](https://www.patreon.com/raysan5). It will really motivate to continue improving this project...
|
||||||
|
|
||||||
raylib philosophy
|
raylib philosophy
|
||||||
------------------
|
------------------
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,14 @@ 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/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!
|
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...)
|
- [ ] Basic GPU stats sytem (memory, draws, time...)
|
||||||
- [ ] Improved custom file-format (.rres) and packaging tool
|
- [ ] 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
|
- [ ] Touch-based camera controls for Android
|
||||||
|
|
||||||
|
**raylib 1.8**
|
||||||
|
- [x] Improved Materials system with PBR support
|
||||||
|
- [x] Procedural image generation functions (spot, gradient, noise...)
|
||||||
|
- [x] Procedural mesh generation functions (cube, sphere...)
|
||||||
|
|
||||||
**raylib 1.7**
|
**raylib 1.7**
|
||||||
- [x] Support configuration flags
|
- [x] Support configuration flags
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
project('raylib', 'c', version: '1.7.0',
|
project('raylib', 'c', version: '1.8.0',
|
||||||
license: 'zlib',
|
license: 'zlib',
|
||||||
meson_version: '>= 0.39.1',
|
meson_version: '>= 0.39.1',
|
||||||
default_options : 'c_std=gnu99')
|
default_options : 'c_std=gnu99')
|
||||||
|
|
|
||||||
Binary file not shown.
15
src/Makefile
15
src/Makefile
|
|
@ -97,14 +97,9 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
||||||
# Android NDK path
|
# Android required path variables
|
||||||
# NOTE: Required for standalone toolchain generation
|
ANDROID_NDK = C:/android-ndk
|
||||||
ANDROID_NDK = $(ANDROID_NDK_HOME)
|
ANDROID_TOOLCHAIN = C:/android_toolchain_arm_api16
|
||||||
|
|
||||||
# Android standalone toolchain path
|
|
||||||
# NOTE: This path is also used if toolchain generation
|
|
||||||
#ANDROID_TOOLCHAIN = $(CURDIR)/toolchain
|
|
||||||
ANDROID_TOOLCHAIN = $(RAYLIB_PATH)/android-toolchain
|
|
||||||
|
|
||||||
# Android architecture: ARM or ARM64
|
# Android architecture: ARM or ARM64
|
||||||
ANDROID_ARCH ?= ARM
|
ANDROID_ARCH ?= ARM
|
||||||
|
|
@ -217,6 +212,10 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
# -s USE_PTHREADS=1 # multithreading support
|
# -s USE_PTHREADS=1 # multithreading support
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
||||||
|
CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
|
||||||
|
endif
|
||||||
|
|
||||||
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
|
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
|
||||||
|
|
||||||
# if shared library required, make sure code is compiled as position independent
|
# if shared library required, make sure code is compiled as position independent
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@
|
||||||
#define SUPPORT_FILEFORMAT_WAV
|
#define SUPPORT_FILEFORMAT_WAV
|
||||||
#define SUPPORT_FILEFORMAT_OGG
|
#define SUPPORT_FILEFORMAT_OGG
|
||||||
#define SUPPORT_FILEFORMAT_XM
|
#define SUPPORT_FILEFORMAT_XM
|
||||||
|
#define SUPPORT_FILEFORMAT_MOD
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
#if defined(AUDIO_STANDALONE)
|
#if defined(AUDIO_STANDALONE)
|
||||||
|
|
|
||||||
18
src/core.c
18
src/core.c
|
|
@ -659,6 +659,14 @@ void SetWindowIcon(Image image)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set title for window (only PLATFORM_DESKTOP)
|
||||||
|
void SetWindowTitle(const char *title)
|
||||||
|
{
|
||||||
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
glfwSetWindowTitle(window, title);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Set window position on screen (windowed mode)
|
// Set window position on screen (windowed mode)
|
||||||
void SetWindowPosition(int x, int y)
|
void SetWindowPosition(int x, int y)
|
||||||
{
|
{
|
||||||
|
|
@ -1152,6 +1160,16 @@ bool IsFileExtension(const char *fileName, const char *ext)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the extension for a filename
|
||||||
|
const char *GetExtension(const char *fileName)
|
||||||
|
{
|
||||||
|
const char *dot = strrchr(fileName, '.');
|
||||||
|
|
||||||
|
if (!dot || dot == fileName) return "";
|
||||||
|
|
||||||
|
return (dot + 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Get directory for a given fileName (with path)
|
// Get directory for a given fileName (with path)
|
||||||
const char *GetDirectoryPath(const char *fileName)
|
const char *GetDirectoryPath(const char *fileName)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
2050
src/external/par_shapes.h
vendored
Normal file
2050
src/external/par_shapes.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -18,5 +18,5 @@ raylib = library('raylib',
|
||||||
source_c,
|
source_c,
|
||||||
dependencies : [ glfw_dep, gl_dep, openal_dep, m_dep, x11_dep],
|
dependencies : [ glfw_dep, gl_dep, openal_dep, m_dep, x11_dep],
|
||||||
install : true,
|
install : true,
|
||||||
version : '1.7.0')
|
version : '1.8.0')
|
||||||
|
|
||||||
|
|
|
||||||
399
src/models.c
399
src/models.c
|
|
@ -10,6 +10,10 @@
|
||||||
* #define SUPPORT_FILEFORMAT_MTL
|
* #define SUPPORT_FILEFORMAT_MTL
|
||||||
* Selected desired fileformats to be supported for loading.
|
* Selected desired fileformats to be supported for loading.
|
||||||
*
|
*
|
||||||
|
* #define SUPPORT_MESH_GENERATION
|
||||||
|
* Support procedural mesh generation functions, uses external par_shapes.h library
|
||||||
|
* NOTE: Some generated meshes DO NOT include generated texture coordinates
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* LICENSE: zlib/libpng
|
* LICENSE: zlib/libpng
|
||||||
*
|
*
|
||||||
|
|
@ -36,6 +40,7 @@
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
#define SUPPORT_FILEFORMAT_OBJ
|
#define SUPPORT_FILEFORMAT_OBJ
|
||||||
#define SUPPORT_FILEFORMAT_MTL
|
#define SUPPORT_FILEFORMAT_MTL
|
||||||
|
#define SUPPORT_MESH_GENERATION
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
@ -51,6 +56,9 @@
|
||||||
|
|
||||||
#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2
|
#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2
|
||||||
|
|
||||||
|
#define PAR_SHAPES_IMPLEMENTATION
|
||||||
|
#include "external/par_shapes.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Defines and Macros
|
// Defines and Macros
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
@ -644,12 +652,142 @@ void UnloadMesh(Mesh *mesh)
|
||||||
rlUnloadMesh(mesh);
|
rlUnloadMesh(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(SUPPORT_MESH_GENERATION)
|
||||||
|
// Generate plane mesh (with subdivisions)
|
||||||
|
Mesh GenMeshPlane(float width, float length, int resX, int resZ)
|
||||||
|
{
|
||||||
|
Mesh mesh = { 0 };
|
||||||
|
|
||||||
|
#define CUSTOM_MESH_GEN_PLANE
|
||||||
|
#if defined(CUSTOM_MESH_GEN_PLANE)
|
||||||
|
resX++;
|
||||||
|
resZ++;
|
||||||
|
|
||||||
|
// Vertices definition
|
||||||
|
int vertexCount = resX*resZ*6; // 6 vertex by quad
|
||||||
|
|
||||||
|
Vector3 vertices[vertexCount];
|
||||||
|
for (int z = 0; z < resZ; z++)
|
||||||
|
{
|
||||||
|
// [-length/2, length/2]
|
||||||
|
float zPos = ((float)z/(resZ - 1) - 0.5f)*length;
|
||||||
|
for (int x = 0; x < resX; x++)
|
||||||
|
{
|
||||||
|
// [-width/2, width/2]
|
||||||
|
float xPos = ((float)x/(resX - 1) - 0.5f)*width;
|
||||||
|
vertices[x + z*resX] = (Vector3){ xPos, 0.0f, zPos };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normals definition
|
||||||
|
Vector3 normals[vertexCount];
|
||||||
|
for (int n = 0; n < vertexCount; n++) normals[n] = (Vector3){ 0.0f, 1.0f, 0.0f }; // Vector3.up;
|
||||||
|
|
||||||
|
// TexCoords definition
|
||||||
|
Vector2 texcoords[vertexCount];
|
||||||
|
for (int v = 0; v < resZ; v++)
|
||||||
|
{
|
||||||
|
for (int u = 0; u < resX; u++)
|
||||||
|
{
|
||||||
|
texcoords[u + v*resX] = (Vector2){ (float)u/(resX - 1), (float)v/(resZ - 1) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Triangles definition (indices)
|
||||||
|
int nbFaces = (resX - 1)*(resZ - 1);
|
||||||
|
int triangles[nbFaces*6];
|
||||||
|
int t = 0;
|
||||||
|
for (int face = 0; face < nbFaces; face++)
|
||||||
|
{
|
||||||
|
// Retrieve lower left corner from face ind
|
||||||
|
int i = face % (resX - 1) + (face/(resZ - 1)*resX);
|
||||||
|
|
||||||
|
triangles[t++] = i + resX;
|
||||||
|
triangles[t++] = i + 1;
|
||||||
|
triangles[t++] = i;
|
||||||
|
|
||||||
|
triangles[t++] = i + resX;
|
||||||
|
triangles[t++] = i + resX + 1;
|
||||||
|
triangles[t++] = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
mesh.vertexCount = vertexCount;
|
||||||
|
mesh.triangleCount = nbFaces*2;
|
||||||
|
mesh.vertices = (float *)malloc(mesh.vertexCount*3*sizeof(float));
|
||||||
|
mesh.texcoords = (float *)malloc(mesh.vertexCount*2*sizeof(float));
|
||||||
|
mesh.normals = (float *)malloc(mesh.vertexCount*3*sizeof(float));
|
||||||
|
mesh.indices = (unsigned short *)malloc(mesh.triangleCount*3*sizeof(unsigned short));
|
||||||
|
|
||||||
|
// Mesh vertices position array
|
||||||
|
for (int i = 0; i < mesh.vertexCount; i++)
|
||||||
|
{
|
||||||
|
mesh.vertices[3*i] = vertices[i].x;
|
||||||
|
mesh.vertices[3*i + 1] = vertices[i].y;
|
||||||
|
mesh.vertices[3*i + 2] = vertices[i].z;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mesh texcoords array
|
||||||
|
for (int i = 0; i < mesh.vertexCount; i++)
|
||||||
|
{
|
||||||
|
mesh.texcoords[2*i] = texcoords[i].x;
|
||||||
|
mesh.texcoords[2*i + 1] = texcoords[i].y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mesh normals array
|
||||||
|
for (int i = 0; i < mesh.vertexCount; i++)
|
||||||
|
{
|
||||||
|
mesh.normals[3*i] = normals[i].x;
|
||||||
|
mesh.normals[3*i + 1] = normals[i].y;
|
||||||
|
mesh.normals[3*i + 2] = normals[i].z;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mesh indices array initialization
|
||||||
|
for (int i = 0; i < mesh.triangleCount*3; i++) mesh.indices[i] = triangles[i];
|
||||||
|
|
||||||
|
#else // Use par_shapes library to generate plane mesh
|
||||||
|
|
||||||
|
par_shapes_mesh *plane = par_shapes_create_plane(resX, resZ); // No normals/texcoords generated!!!
|
||||||
|
par_shapes_scale(plane, width, length, 1.0f);
|
||||||
|
par_shapes_rotate(plane, -PI/2.0f, (float[]){ 1, 0, 0 });
|
||||||
|
par_shapes_translate(plane, -width/2, 0.0f, length/2);
|
||||||
|
|
||||||
|
mesh.vertices = (float *)malloc(plane->ntriangles*3*3*sizeof(float));
|
||||||
|
mesh.texcoords = (float *)malloc(plane->ntriangles*3*2*sizeof(float));
|
||||||
|
mesh.normals = (float *)malloc(plane->ntriangles*3*3*sizeof(float));
|
||||||
|
|
||||||
|
mesh.vertexCount = plane->ntriangles*3;
|
||||||
|
mesh.triangleCount = plane->ntriangles;
|
||||||
|
|
||||||
|
for (int k = 0; k < mesh.vertexCount; k++)
|
||||||
|
{
|
||||||
|
mesh.vertices[k*3] = plane->points[plane->triangles[k]*3];
|
||||||
|
mesh.vertices[k*3 + 1] = plane->points[plane->triangles[k]*3 + 1];
|
||||||
|
mesh.vertices[k*3 + 2] = plane->points[plane->triangles[k]*3 + 2];
|
||||||
|
|
||||||
|
mesh.normals[k*3] = plane->normals[plane->triangles[k]*3];
|
||||||
|
mesh.normals[k*3 + 1] = plane->normals[plane->triangles[k]*3 + 1];
|
||||||
|
mesh.normals[k*3 + 2] = plane->normals[plane->triangles[k]*3 + 2];
|
||||||
|
|
||||||
|
mesh.texcoords[k*2] = plane->tcoords[plane->triangles[k]*2];
|
||||||
|
mesh.texcoords[k*2 + 1] = plane->tcoords[plane->triangles[k]*2 + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
par_shapes_free_mesh(plane);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Upload vertex data to GPU (static mesh)
|
||||||
|
rlLoadMesh(&mesh, false);
|
||||||
|
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
|
|
||||||
// Generated cuboid mesh
|
// Generated cuboid mesh
|
||||||
// NOTE: Vertex data is uploaded to GPU
|
|
||||||
Mesh GenMeshCube(float width, float height, float length)
|
Mesh GenMeshCube(float width, float height, float length)
|
||||||
{
|
{
|
||||||
Mesh mesh = { 0 };
|
Mesh mesh = { 0 };
|
||||||
|
|
||||||
|
#define CUSTOM_MESH_GEN_CUBE
|
||||||
|
#if defined(CUSTOM_MESH_GEN_CUBE)
|
||||||
float vertices[] = {
|
float vertices[] = {
|
||||||
-width/2, -height/2, length/2,
|
-width/2, -height/2, length/2,
|
||||||
width/2, -height/2, length/2,
|
width/2, -height/2, length/2,
|
||||||
|
|
@ -760,6 +898,264 @@ Mesh GenMeshCube(float width, float height, float length)
|
||||||
mesh.vertexCount = 24;
|
mesh.vertexCount = 24;
|
||||||
mesh.triangleCount = 12;
|
mesh.triangleCount = 12;
|
||||||
|
|
||||||
|
#else // Use par_shapes library to generate cube mesh
|
||||||
|
/*
|
||||||
|
// Platonic solids:
|
||||||
|
par_shapes_mesh* par_shapes_create_tetrahedron(); // 4 sides polyhedron (pyramid)
|
||||||
|
par_shapes_mesh* par_shapes_create_cube(); // 6 sides polyhedron (cube)
|
||||||
|
par_shapes_mesh* par_shapes_create_octahedron(); // 8 sides polyhedron (dyamond)
|
||||||
|
par_shapes_mesh* par_shapes_create_dodecahedron(); // 12 sides polyhedron
|
||||||
|
par_shapes_mesh* par_shapes_create_icosahedron(); // 20 sides polyhedron
|
||||||
|
*/
|
||||||
|
// Platonic solid generation: cube (6 sides)
|
||||||
|
// NOTE: No normals/texcoords generated by default
|
||||||
|
par_shapes_mesh *cube = par_shapes_create_cube();
|
||||||
|
cube->tcoords = PAR_MALLOC(float, 2*cube->npoints);
|
||||||
|
for (int i = 0; i < 2*cube->npoints; i++) cube->tcoords[i] = 0.0f;
|
||||||
|
par_shapes_scale(cube, width, height, length);
|
||||||
|
par_shapes_translate(cube, -width/2, 0.0f, -length/2);
|
||||||
|
par_shapes_compute_normals(cube);
|
||||||
|
|
||||||
|
mesh.vertices = (float *)malloc(cube->ntriangles*3*3*sizeof(float));
|
||||||
|
mesh.texcoords = (float *)malloc(cube->ntriangles*3*2*sizeof(float));
|
||||||
|
mesh.normals = (float *)malloc(cube->ntriangles*3*3*sizeof(float));
|
||||||
|
|
||||||
|
mesh.vertexCount = cube->ntriangles*3;
|
||||||
|
mesh.triangleCount = cube->ntriangles;
|
||||||
|
|
||||||
|
for (int k = 0; k < mesh.vertexCount; k++)
|
||||||
|
{
|
||||||
|
mesh.vertices[k*3] = cube->points[cube->triangles[k]*3];
|
||||||
|
mesh.vertices[k*3 + 1] = cube->points[cube->triangles[k]*3 + 1];
|
||||||
|
mesh.vertices[k*3 + 2] = cube->points[cube->triangles[k]*3 + 2];
|
||||||
|
|
||||||
|
mesh.normals[k*3] = cube->normals[cube->triangles[k]*3];
|
||||||
|
mesh.normals[k*3 + 1] = cube->normals[cube->triangles[k]*3 + 1];
|
||||||
|
mesh.normals[k*3 + 2] = cube->normals[cube->triangles[k]*3 + 2];
|
||||||
|
|
||||||
|
mesh.texcoords[k*2] = cube->tcoords[cube->triangles[k]*2];
|
||||||
|
mesh.texcoords[k*2 + 1] = cube->tcoords[cube->triangles[k]*2 + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
par_shapes_free_mesh(cube);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Upload vertex data to GPU (static mesh)
|
||||||
|
rlLoadMesh(&mesh, false);
|
||||||
|
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate sphere mesh (standard sphere)
|
||||||
|
RLAPI Mesh GenMeshSphere(float radius, int rings, int slices)
|
||||||
|
{
|
||||||
|
Mesh mesh = { 0 };
|
||||||
|
|
||||||
|
par_shapes_mesh *sphere = par_shapes_create_parametric_sphere(slices, rings);
|
||||||
|
par_shapes_scale(sphere, radius, radius, radius);
|
||||||
|
// NOTE: Soft normals are computed internally
|
||||||
|
|
||||||
|
mesh.vertices = (float *)malloc(sphere->ntriangles*3*3*sizeof(float));
|
||||||
|
mesh.texcoords = (float *)malloc(sphere->ntriangles*3*2*sizeof(float));
|
||||||
|
mesh.normals = (float *)malloc(sphere->ntriangles*3*3*sizeof(float));
|
||||||
|
|
||||||
|
mesh.vertexCount = sphere->ntriangles*3;
|
||||||
|
mesh.triangleCount = sphere->ntriangles;
|
||||||
|
|
||||||
|
for (int k = 0; k < mesh.vertexCount; k++)
|
||||||
|
{
|
||||||
|
mesh.vertices[k*3] = sphere->points[sphere->triangles[k]*3];
|
||||||
|
mesh.vertices[k*3 + 1] = sphere->points[sphere->triangles[k]*3 + 1];
|
||||||
|
mesh.vertices[k*3 + 2] = sphere->points[sphere->triangles[k]*3 + 2];
|
||||||
|
|
||||||
|
mesh.normals[k*3] = sphere->normals[sphere->triangles[k]*3];
|
||||||
|
mesh.normals[k*3 + 1] = sphere->normals[sphere->triangles[k]*3 + 1];
|
||||||
|
mesh.normals[k*3 + 2] = sphere->normals[sphere->triangles[k]*3 + 2];
|
||||||
|
|
||||||
|
mesh.texcoords[k*2] = sphere->tcoords[sphere->triangles[k]*2];
|
||||||
|
mesh.texcoords[k*2 + 1] = sphere->tcoords[sphere->triangles[k]*2 + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
par_shapes_free_mesh(sphere);
|
||||||
|
|
||||||
|
// Upload vertex data to GPU (static mesh)
|
||||||
|
rlLoadMesh(&mesh, false);
|
||||||
|
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate hemi-sphere mesh (half sphere, no bottom cap)
|
||||||
|
RLAPI Mesh GenMeshHemiSphere(float radius, int rings, int slices)
|
||||||
|
{
|
||||||
|
Mesh mesh = { 0 };
|
||||||
|
|
||||||
|
par_shapes_mesh *sphere = par_shapes_create_hemisphere(slices, rings);
|
||||||
|
par_shapes_scale(sphere, radius, radius, radius);
|
||||||
|
// NOTE: Soft normals are computed internally
|
||||||
|
|
||||||
|
mesh.vertices = (float *)malloc(sphere->ntriangles*3*3*sizeof(float));
|
||||||
|
mesh.texcoords = (float *)malloc(sphere->ntriangles*3*2*sizeof(float));
|
||||||
|
mesh.normals = (float *)malloc(sphere->ntriangles*3*3*sizeof(float));
|
||||||
|
|
||||||
|
mesh.vertexCount = sphere->ntriangles*3;
|
||||||
|
mesh.triangleCount = sphere->ntriangles;
|
||||||
|
|
||||||
|
for (int k = 0; k < mesh.vertexCount; k++)
|
||||||
|
{
|
||||||
|
mesh.vertices[k*3] = sphere->points[sphere->triangles[k]*3];
|
||||||
|
mesh.vertices[k*3 + 1] = sphere->points[sphere->triangles[k]*3 + 1];
|
||||||
|
mesh.vertices[k*3 + 2] = sphere->points[sphere->triangles[k]*3 + 2];
|
||||||
|
|
||||||
|
mesh.normals[k*3] = sphere->normals[sphere->triangles[k]*3];
|
||||||
|
mesh.normals[k*3 + 1] = sphere->normals[sphere->triangles[k]*3 + 1];
|
||||||
|
mesh.normals[k*3 + 2] = sphere->normals[sphere->triangles[k]*3 + 2];
|
||||||
|
|
||||||
|
mesh.texcoords[k*2] = sphere->tcoords[sphere->triangles[k]*2];
|
||||||
|
mesh.texcoords[k*2 + 1] = sphere->tcoords[sphere->triangles[k]*2 + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
par_shapes_free_mesh(sphere);
|
||||||
|
|
||||||
|
// Upload vertex data to GPU (static mesh)
|
||||||
|
rlLoadMesh(&mesh, false);
|
||||||
|
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate cylinder mesh
|
||||||
|
Mesh GenMeshCylinder(float radius, float height, int slices)
|
||||||
|
{
|
||||||
|
Mesh mesh = { 0 };
|
||||||
|
|
||||||
|
// Instance a cylinder that sits on the Z=0 plane using the given tessellation
|
||||||
|
// levels across the UV domain. Think of "slices" like a number of pizza
|
||||||
|
// slices, and "stacks" like a number of stacked rings.
|
||||||
|
// Height and radius are both 1.0, but they can easily be changed with par_shapes_scale
|
||||||
|
par_shapes_mesh *cylinder = par_shapes_create_cylinder(slices, 8);
|
||||||
|
par_shapes_scale(cylinder, radius, radius, height);
|
||||||
|
par_shapes_rotate(cylinder, -PI/2.0f, (float[]){ 1, 0, 0 });
|
||||||
|
|
||||||
|
// Generate an orientable disk shape (top cap)
|
||||||
|
par_shapes_mesh *capTop = par_shapes_create_disk(radius, slices, (float[]){ 0, 0, 0 }, (float[]){ 0, 0, 1 });
|
||||||
|
capTop->tcoords = PAR_MALLOC(float, 2*capTop->npoints);
|
||||||
|
for (int i = 0; i < 2*capTop->npoints; i++) capTop->tcoords[i] = 0.0f;
|
||||||
|
par_shapes_rotate(capTop, -PI/2.0f, (float[]){ 1, 0, 0 });
|
||||||
|
par_shapes_translate(capTop, 0, height, 0);
|
||||||
|
|
||||||
|
// Generate an orientable disk shape (bottom cap)
|
||||||
|
par_shapes_mesh *capBottom = par_shapes_create_disk(radius, slices, (float[]){ 0, 0, 0 }, (float[]){ 0, 0, -1 });
|
||||||
|
capBottom->tcoords = PAR_MALLOC(float, 2*capBottom->npoints);
|
||||||
|
for (int i = 0; i < 2*capBottom->npoints; i++) capBottom->tcoords[i] = 0.95f;
|
||||||
|
par_shapes_rotate(capBottom, PI/2.0f, (float[]){ 1, 0, 0 });
|
||||||
|
|
||||||
|
par_shapes_merge_and_free(cylinder, capTop);
|
||||||
|
par_shapes_merge_and_free(cylinder, capBottom);
|
||||||
|
|
||||||
|
mesh.vertices = (float *)malloc(cylinder->ntriangles*3*3*sizeof(float));
|
||||||
|
mesh.texcoords = (float *)malloc(cylinder->ntriangles*3*2*sizeof(float));
|
||||||
|
mesh.normals = (float *)malloc(cylinder->ntriangles*3*3*sizeof(float));
|
||||||
|
|
||||||
|
mesh.vertexCount = cylinder->ntriangles*3;
|
||||||
|
mesh.triangleCount = cylinder->ntriangles;
|
||||||
|
|
||||||
|
for (int k = 0; k < mesh.vertexCount; k++)
|
||||||
|
{
|
||||||
|
mesh.vertices[k*3] = cylinder->points[cylinder->triangles[k]*3];
|
||||||
|
mesh.vertices[k*3 + 1] = cylinder->points[cylinder->triangles[k]*3 + 1];
|
||||||
|
mesh.vertices[k*3 + 2] = cylinder->points[cylinder->triangles[k]*3 + 2];
|
||||||
|
|
||||||
|
mesh.normals[k*3] = cylinder->normals[cylinder->triangles[k]*3];
|
||||||
|
mesh.normals[k*3 + 1] = cylinder->normals[cylinder->triangles[k]*3 + 1];
|
||||||
|
mesh.normals[k*3 + 2] = cylinder->normals[cylinder->triangles[k]*3 + 2];
|
||||||
|
|
||||||
|
mesh.texcoords[k*2] = cylinder->tcoords[cylinder->triangles[k]*2];
|
||||||
|
mesh.texcoords[k*2 + 1] = cylinder->tcoords[cylinder->triangles[k]*2 + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
par_shapes_free_mesh(cylinder);
|
||||||
|
|
||||||
|
// Upload vertex data to GPU (static mesh)
|
||||||
|
rlLoadMesh(&mesh, false);
|
||||||
|
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate torus mesh
|
||||||
|
Mesh GenMeshTorus(float radius, float size, int radSeg, int sides)
|
||||||
|
{
|
||||||
|
Mesh mesh = { 0 };
|
||||||
|
|
||||||
|
if (radius > 1.0f) radius = 1.0f;
|
||||||
|
else if (radius < 0.1f) radius = 0.1f;
|
||||||
|
|
||||||
|
// Create a donut that sits on the Z=0 plane with the specified inner radius
|
||||||
|
// The outer radius can be controlled with par_shapes_scale
|
||||||
|
par_shapes_mesh *torus = par_shapes_create_torus(radSeg, sides, radius);
|
||||||
|
par_shapes_scale(torus, size/2, size/2, size/2);
|
||||||
|
|
||||||
|
mesh.vertices = (float *)malloc(torus->ntriangles*3*3*sizeof(float));
|
||||||
|
mesh.texcoords = (float *)malloc(torus->ntriangles*3*2*sizeof(float));
|
||||||
|
mesh.normals = (float *)malloc(torus->ntriangles*3*3*sizeof(float));
|
||||||
|
|
||||||
|
mesh.vertexCount = torus->ntriangles*3;
|
||||||
|
mesh.triangleCount = torus->ntriangles;
|
||||||
|
|
||||||
|
for (int k = 0; k < mesh.vertexCount; k++)
|
||||||
|
{
|
||||||
|
mesh.vertices[k*3] = torus->points[torus->triangles[k]*3];
|
||||||
|
mesh.vertices[k*3 + 1] = torus->points[torus->triangles[k]*3 + 1];
|
||||||
|
mesh.vertices[k*3 + 2] = torus->points[torus->triangles[k]*3 + 2];
|
||||||
|
|
||||||
|
mesh.normals[k*3] = torus->normals[torus->triangles[k]*3];
|
||||||
|
mesh.normals[k*3 + 1] = torus->normals[torus->triangles[k]*3 + 1];
|
||||||
|
mesh.normals[k*3 + 2] = torus->normals[torus->triangles[k]*3 + 2];
|
||||||
|
|
||||||
|
mesh.texcoords[k*2] = torus->tcoords[torus->triangles[k]*2];
|
||||||
|
mesh.texcoords[k*2 + 1] = torus->tcoords[torus->triangles[k]*2 + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
par_shapes_free_mesh(torus);
|
||||||
|
|
||||||
|
// Upload vertex data to GPU (static mesh)
|
||||||
|
rlLoadMesh(&mesh, false);
|
||||||
|
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate trefoil knot mesh
|
||||||
|
Mesh GenMeshKnot(float radius, float size, int radSeg, int sides)
|
||||||
|
{
|
||||||
|
Mesh mesh = { 0 };
|
||||||
|
|
||||||
|
if (radius > 3.0f) radius = 3.0f;
|
||||||
|
else if (radius < 0.5f) radius = 0.5f;
|
||||||
|
|
||||||
|
par_shapes_mesh *knot = par_shapes_create_trefoil_knot(radSeg, sides, radius);
|
||||||
|
par_shapes_scale(knot, size, size, size);
|
||||||
|
|
||||||
|
mesh.vertices = (float *)malloc(knot->ntriangles*3*3*sizeof(float));
|
||||||
|
mesh.texcoords = (float *)malloc(knot->ntriangles*3*2*sizeof(float));
|
||||||
|
mesh.normals = (float *)malloc(knot->ntriangles*3*3*sizeof(float));
|
||||||
|
|
||||||
|
mesh.vertexCount = knot->ntriangles*3;
|
||||||
|
mesh.triangleCount = knot->ntriangles;
|
||||||
|
|
||||||
|
for (int k = 0; k < mesh.vertexCount; k++)
|
||||||
|
{
|
||||||
|
mesh.vertices[k*3] = knot->points[knot->triangles[k]*3];
|
||||||
|
mesh.vertices[k*3 + 1] = knot->points[knot->triangles[k]*3 + 1];
|
||||||
|
mesh.vertices[k*3 + 2] = knot->points[knot->triangles[k]*3 + 2];
|
||||||
|
|
||||||
|
mesh.normals[k*3] = knot->normals[knot->triangles[k]*3];
|
||||||
|
mesh.normals[k*3 + 1] = knot->normals[knot->triangles[k]*3 + 1];
|
||||||
|
mesh.normals[k*3 + 2] = knot->normals[knot->triangles[k]*3 + 2];
|
||||||
|
|
||||||
|
mesh.texcoords[k*2] = knot->tcoords[knot->triangles[k]*2];
|
||||||
|
mesh.texcoords[k*2 + 1] = knot->tcoords[knot->triangles[k]*2 + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
par_shapes_free_mesh(knot);
|
||||||
|
|
||||||
// Upload vertex data to GPU (static mesh)
|
// Upload vertex data to GPU (static mesh)
|
||||||
rlLoadMesh(&mesh, false);
|
rlLoadMesh(&mesh, false);
|
||||||
|
|
||||||
|
|
@ -1234,6 +1630,7 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
|
||||||
|
|
||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_MESH_GENERATION
|
||||||
|
|
||||||
// Load material data (from file)
|
// Load material data (from file)
|
||||||
Material LoadMaterial(const char *fileName)
|
Material LoadMaterial(const char *fileName)
|
||||||
|
|
|
||||||
17
src/raylib.h
17
src/raylib.h
|
|
@ -701,6 +701,7 @@ RLAPI bool WindowShouldClose(void); // Check if KE
|
||||||
RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
|
RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
|
||||||
RLAPI void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP)
|
RLAPI void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP)
|
||||||
RLAPI void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP)
|
RLAPI void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP)
|
||||||
|
RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP)
|
||||||
RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
|
RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
|
||||||
RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode)
|
RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode)
|
||||||
RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
|
RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
|
||||||
|
|
@ -759,6 +760,7 @@ RLAPI int GetRandomValue(int min, int max); // Returns a r
|
||||||
|
|
||||||
// Files management functions
|
// Files management functions
|
||||||
RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
|
RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
|
||||||
|
RLAPI const char *GetExtension(const char *fileName); // Get file extension
|
||||||
RLAPI const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path)
|
RLAPI const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path)
|
||||||
RLAPI const char *GetWorkingDirectory(void); // Get current working directory
|
RLAPI const char *GetWorkingDirectory(void); // Get current working directory
|
||||||
RLAPI bool ChangeDirectory(const char *dir); // Change working directory, returns true if success
|
RLAPI bool ChangeDirectory(const char *dir); // Change working directory, returns true if success
|
||||||
|
|
@ -855,8 +857,10 @@ RLAPI void DrawRectangle(int posX, int posY, int width, int height, Color color)
|
||||||
RLAPI void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle
|
RLAPI void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle
|
||||||
RLAPI void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); // Draw a color-filled rectangle with pro parameters
|
RLAPI void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); // Draw a color-filled rectangle with pro parameters
|
||||||
RLAPI void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2); // Draw a gradient-filled rectangle
|
RLAPI void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2); // Draw a gradient-filled rectangle
|
||||||
|
RLAPI void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // Draw a gradient-filled rectangle with custom vertex colors
|
||||||
RLAPI void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version)
|
RLAPI void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version)
|
||||||
RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline
|
RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline
|
||||||
|
RLAPI void DrawRectangleT(int posX, int posY, int width, int height, Color color); // Draw rectangle using text character
|
||||||
RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle
|
RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle
|
||||||
RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline
|
RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline
|
||||||
RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version)
|
RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version)
|
||||||
|
|
@ -952,7 +956,6 @@ RLAPI void DrawFPS(int posX, int posY);
|
||||||
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
|
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
|
RLAPI void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters
|
||||||
float fontSize, int spacing, Color tint);
|
float fontSize, int spacing, Color tint);
|
||||||
RLAPI void DrawRectangleT(int posX, int posY, int width, int height, Color color); // Draw rectangle using text character
|
|
||||||
|
|
||||||
// Text misc. functions
|
// Text misc. functions
|
||||||
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
|
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
|
||||||
|
|
@ -995,12 +998,14 @@ RLAPI void UnloadModel(Model model);
|
||||||
RLAPI Mesh LoadMesh(const char *fileName); // Load mesh from file
|
RLAPI Mesh LoadMesh(const char *fileName); // Load mesh from file
|
||||||
RLAPI void UnloadMesh(Mesh *mesh); // Unload mesh from memory (RAM and/or VRAM)
|
RLAPI void UnloadMesh(Mesh *mesh); // Unload mesh from memory (RAM and/or VRAM)
|
||||||
|
|
||||||
//RLAPI Mesh GenMeshPlane(float width, float length, int resX, int resZ); // Generate plane mesh (with desired subdivisions)
|
// Mesh generation functions
|
||||||
|
RLAPI Mesh GenMeshPlane(float width, float length, int resX, int resZ); // Generate plane mesh (with subdivisions)
|
||||||
RLAPI Mesh GenMeshCube(float width, float height, float length); // Generate cuboid mesh
|
RLAPI Mesh GenMeshCube(float width, float height, float length); // Generate cuboid mesh
|
||||||
//RLAPI Mesh GenMeshSphere(float radius, int rings, int slices); // Generate sphere mesh (standard sphere)
|
RLAPI Mesh GenMeshSphere(float radius, int rings, int slices); // Generate sphere mesh (standard sphere)
|
||||||
//RLAPI Mesh GenMeshCylinder(float radiusTop, float radiusBottom, float height, int slices); // Generate cylinder mesh
|
RLAPI Mesh GenMeshHemiSphere(float radius, int rings, int slices); // Generate half-sphere mesh (no bottom cap)
|
||||||
//RLAPI Mesh GenMeshTorus(float radius1, float radius2, int radSeg, int sides); // Generate torus mesh
|
RLAPI Mesh GenMeshCylinder(float radius, float height, int slices); // Generate cylinder mesh
|
||||||
//RLAPI Mesh GenMeshTube(float radius1, float radius2, float height, int sides); // Generate tube mesh
|
RLAPI Mesh GenMeshTorus(float radius, float size, int radSeg, int sides); // Generate torus mesh
|
||||||
|
RLAPI Mesh GenMeshKnot(float radius, float size, int radSeg, int sides); // Generate trefoil knot mesh
|
||||||
RLAPI Mesh GenMeshHeightmap(Image heightmap, Vector3 size); // Generate heightmap mesh from image data
|
RLAPI Mesh GenMeshHeightmap(Image heightmap, Vector3 size); // Generate heightmap mesh from image data
|
||||||
RLAPI Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); // Generate cubes-based map mesh from image data
|
RLAPI Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); // Generate cubes-based map mesh from image data
|
||||||
|
|
||||||
|
|
|
||||||
12
src/rlgl.c
12
src/rlgl.c
|
|
@ -418,7 +418,6 @@ void rlPushMatrix(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
stack[stackCounter] = *currentMatrix;
|
stack[stackCounter] = *currentMatrix;
|
||||||
rlLoadIdentity();
|
|
||||||
stackCounter++;
|
stackCounter++;
|
||||||
|
|
||||||
if (currentMatrixMode == RL_MODELVIEW) useTempBuffer = true;
|
if (currentMatrixMode == RL_MODELVIEW) useTempBuffer = true;
|
||||||
|
|
@ -814,6 +813,12 @@ void rlEnableTexture(unsigned int id)
|
||||||
if (draws[drawsCounter - 1].textureId != id)
|
if (draws[drawsCounter - 1].textureId != id)
|
||||||
{
|
{
|
||||||
if (draws[drawsCounter - 1].vertexCount > 0) drawsCounter++;
|
if (draws[drawsCounter - 1].vertexCount > 0) drawsCounter++;
|
||||||
|
|
||||||
|
if (drawsCounter >= MAX_DRAWS_BY_TEXTURE)
|
||||||
|
{
|
||||||
|
rlglDraw();
|
||||||
|
drawsCounter = 1;
|
||||||
|
}
|
||||||
|
|
||||||
draws[drawsCounter - 1].textureId = id;
|
draws[drawsCounter - 1].textureId = id;
|
||||||
draws[drawsCounter - 1].vertexCount = 0;
|
draws[drawsCounter - 1].vertexCount = 0;
|
||||||
|
|
@ -2207,7 +2212,6 @@ void *rlReadTexturePixels(Texture2D texture)
|
||||||
// 2 - Create an fbo, activate it, render quad with texture, glReadPixels()
|
// 2 - Create an fbo, activate it, render quad with texture, glReadPixels()
|
||||||
|
|
||||||
#define GET_TEXTURE_FBO_OPTION_1 // It works
|
#define GET_TEXTURE_FBO_OPTION_1 // It works
|
||||||
|
|
||||||
#if defined(GET_TEXTURE_FBO_OPTION_1)
|
#if defined(GET_TEXTURE_FBO_OPTION_1)
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo.id);
|
glBindFramebuffer(GL_FRAMEBUFFER, fbo.id);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
@ -2941,7 +2945,7 @@ void ToggleVrMode(void)
|
||||||
|
|
||||||
// Reset viewport and default projection-modelview matrices
|
// Reset viewport and default projection-modelview matrices
|
||||||
rlViewport(0, 0, screenWidth, screenHeight);
|
rlViewport(0, 0, screenWidth, screenHeight);
|
||||||
projection = MatrixOrtho(0, screenWidth, screenHeight, 0, 0.0f, 1.0f);
|
projection = MatrixOrtho(0.0, screenWidth, screenHeight, 0.0, 0.0, 1.0);
|
||||||
modelview = MatrixIdentity();
|
modelview = MatrixIdentity();
|
||||||
}
|
}
|
||||||
else vrStereoRender = true;
|
else vrStereoRender = true;
|
||||||
|
|
@ -3043,7 +3047,7 @@ void EndVrDrawing(void)
|
||||||
|
|
||||||
// Reset viewport and default projection-modelview matrices
|
// Reset viewport and default projection-modelview matrices
|
||||||
rlViewport(0, 0, screenWidth, screenHeight);
|
rlViewport(0, 0, screenWidth, screenHeight);
|
||||||
projection = MatrixOrtho(0, screenWidth, screenHeight, 0, 0.0f, 1.0f);
|
projection = MatrixOrtho(0.0, screenWidth, screenHeight, 0.0, 0.0, 1.0);
|
||||||
modelview = MatrixIdentity();
|
modelview = MatrixIdentity();
|
||||||
|
|
||||||
rlDisableDepthTest();
|
rlDisableDepthTest();
|
||||||
|
|
|
||||||
115
src/rres.h
115
src/rres.h
|
|
@ -34,6 +34,14 @@
|
||||||
*
|
*
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
References:
|
||||||
|
RIFF file-format: http://www.johnloomis.org/cpe102/asgn/asgn1/riff.html
|
||||||
|
ZIP file-format: https://en.wikipedia.org/wiki/Zip_(file_format)
|
||||||
|
http://www.onicos.com/staff/iz/formats/zip.html
|
||||||
|
XNB file-format: http://xbox.create.msdn.com/en-US/sample/xnb_format
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef RRES_H
|
#ifndef RRES_H
|
||||||
#define RRES_H
|
#define RRES_H
|
||||||
|
|
||||||
|
|
@ -75,6 +83,9 @@
|
||||||
void *data; // Resource data pointer (4 byte)
|
void *data; // Resource data pointer (4 byte)
|
||||||
} RRESData;
|
} RRESData;
|
||||||
|
|
||||||
|
// RRES type (pointer to RRESData array)
|
||||||
|
typedef struct RRESData *RRES; // Resource pointer
|
||||||
|
|
||||||
// RRESData type
|
// RRESData type
|
||||||
typedef enum {
|
typedef enum {
|
||||||
RRES_TYPE_RAW = 0,
|
RRES_TYPE_RAW = 0,
|
||||||
|
|
@ -83,12 +94,25 @@
|
||||||
RRES_TYPE_VERTEX,
|
RRES_TYPE_VERTEX,
|
||||||
RRES_TYPE_TEXT,
|
RRES_TYPE_TEXT,
|
||||||
RRES_TYPE_FONT_IMAGE,
|
RRES_TYPE_FONT_IMAGE,
|
||||||
RRES_TYPE_FONT_CHARDATA, // Character { int value, recX, recY, recWidth, recHeight, offsetX, offsetY, xAdvance }
|
RRES_TYPE_FONT_CHARDATA, // CharInfo { int value, recX, recY, recWidth, recHeight, offsetX, offsetY, xAdvance }
|
||||||
RRES_TYPE_DIRECTORY
|
RRES_TYPE_DIRECTORY
|
||||||
} RRESDataType;
|
} RRESDataType;
|
||||||
|
|
||||||
// RRES type (pointer to RRESData array)
|
// Parameters information depending on resource type
|
||||||
typedef struct RRESData *RRES;
|
|
||||||
|
// RRES_TYPE_RAW params: <custom>
|
||||||
|
// RRES_TYPE_IMAGE params: width, height, mipmaps, format
|
||||||
|
// RRES_TYPE_WAVE params: sampleCount, sampleRate, sampleSize, channels
|
||||||
|
// RRES_TYPE_VERTEX params: vertexCount, vertexType, vertexFormat // Use masks instead?
|
||||||
|
// RRES_TYPE_TEXT params: charsCount, cultureCode
|
||||||
|
// RRES_TYPE_FONT_IMAGE params: width, height, format, mipmaps;
|
||||||
|
// RRES_TYPE_FONT_CHARDATA params: charsCount, baseSize
|
||||||
|
// RRES_TYPE_DIRECTORY params: fileCount, directoryCount
|
||||||
|
|
||||||
|
// SpriteFont = RRES_TYPE_FONT_IMAGE chunk + RRES_TYPE_FONT_DATA chunk
|
||||||
|
// Mesh = multiple RRES_TYPE_VERTEX chunks
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
@ -103,6 +127,54 @@
|
||||||
RRESDEF RRES LoadResource(const char *fileName, int rresId);
|
RRESDEF RRES LoadResource(const char *fileName, int rresId);
|
||||||
RRESDEF void UnloadResource(RRES rres);
|
RRESDEF void UnloadResource(RRES rres);
|
||||||
|
|
||||||
|
/*
|
||||||
|
QUESTION: How to load each type of data from RRES ?
|
||||||
|
|
||||||
|
rres->type == RRES_TYPE_RAW
|
||||||
|
unsigned char data = (unsigned char *)rres[0]->data;
|
||||||
|
|
||||||
|
rres->type == RRES_TYPE_IMAGE
|
||||||
|
Image image;
|
||||||
|
image.data = rres[0]->data; // Be careful, duplicate pointer
|
||||||
|
image.width = rres[0]->param1;
|
||||||
|
image.height = rres[0]->param2;
|
||||||
|
image.mipmaps = rres[0]->param3;
|
||||||
|
image.format = rres[0]->format;
|
||||||
|
|
||||||
|
rres->type == RRES_TYPE_WAVE
|
||||||
|
Wave wave;
|
||||||
|
wave.data = rres[0]->data;
|
||||||
|
wave.sampleCount = rres[0]->param1;
|
||||||
|
wave.sampleRate = rres[0]->param2;
|
||||||
|
wave.sampleSize = rres[0]->param3;
|
||||||
|
wave.channels = rres[0]->param4;
|
||||||
|
|
||||||
|
rres->type == RRES_TYPE_VERTEX (multiple parts)
|
||||||
|
Mesh mesh;
|
||||||
|
mesh.vertexCount = rres[0]->param1;
|
||||||
|
mesh.vertices = (float *)rres[0]->data;
|
||||||
|
mesh.texcoords = (float *)rres[1]->data;
|
||||||
|
mesh.normals = (float *)rres[2]->data;
|
||||||
|
mesh.tangents = (float *)rres[3]->data;
|
||||||
|
mesh.tangents = (unsigned char *)rres[4]->data;
|
||||||
|
|
||||||
|
rres->type == RRES_TYPE_TEXT
|
||||||
|
unsigned char *text = (unsigned char *)rres->data;
|
||||||
|
Shader shader = LoadShaderText(text, rres->param1); Shader LoadShaderText(const char *shdrText, int length);
|
||||||
|
|
||||||
|
rres->type == RRES_TYPE_FONT_IMAGE (multiple parts)
|
||||||
|
rres->type == RRES_TYPE_FONT_CHARDATA
|
||||||
|
SpriteFont font;
|
||||||
|
font.texture = LoadTextureFromImage(image); // rres[0]
|
||||||
|
font.chars = (CharInfo *)rres[1]->data;
|
||||||
|
font.charsCount = rres[1]->param1;
|
||||||
|
font.baseSize = rres[1]->param2;
|
||||||
|
|
||||||
|
rres->type == RRES_TYPE_DIRECTORY
|
||||||
|
unsigned char *fileNames = (unsigned char *)rres[0]->data; // fileNames separed by \n
|
||||||
|
int filesCount = rres[0]->param1;
|
||||||
|
*/
|
||||||
|
|
||||||
#endif // RRES_H
|
#endif // RRES_H
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -169,6 +241,7 @@ typedef enum {
|
||||||
// gzip, zopfli, lzo, zstd // Other compression algorythms...
|
// gzip, zopfli, lzo, zstd // Other compression algorythms...
|
||||||
} RRESCompressionType;
|
} RRESCompressionType;
|
||||||
|
|
||||||
|
// Encryption types
|
||||||
typedef enum {
|
typedef enum {
|
||||||
RRES_CRYPTO_NONE = 0, // No data encryption
|
RRES_CRYPTO_NONE = 0, // No data encryption
|
||||||
RRES_CRYPTO_XOR, // XOR (128 bit) encryption
|
RRES_CRYPTO_XOR, // XOR (128 bit) encryption
|
||||||
|
|
@ -179,6 +252,7 @@ typedef enum {
|
||||||
// twofish, RC5, RC6 // Other encryption algorythm...
|
// twofish, RC5, RC6 // Other encryption algorythm...
|
||||||
} RRESEncryptionType;
|
} RRESEncryptionType;
|
||||||
|
|
||||||
|
// Image/Texture data type
|
||||||
typedef enum {
|
typedef enum {
|
||||||
RRES_IM_UNCOMP_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
|
RRES_IM_UNCOMP_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
|
||||||
RRES_IM_UNCOMP_GRAY_ALPHA, // 16 bpp (2 channels)
|
RRES_IM_UNCOMP_GRAY_ALPHA, // 16 bpp (2 channels)
|
||||||
|
|
@ -201,6 +275,7 @@ typedef enum {
|
||||||
//...
|
//...
|
||||||
} RRESImageFormat;
|
} RRESImageFormat;
|
||||||
|
|
||||||
|
// Vertex data type
|
||||||
typedef enum {
|
typedef enum {
|
||||||
RRES_VERT_POSITION,
|
RRES_VERT_POSITION,
|
||||||
RRES_VERT_TEXCOORD1,
|
RRES_VERT_TEXCOORD1,
|
||||||
|
|
@ -214,6 +289,7 @@ typedef enum {
|
||||||
//...
|
//...
|
||||||
} RRESVertexType;
|
} RRESVertexType;
|
||||||
|
|
||||||
|
// Vertex data format type
|
||||||
typedef enum {
|
typedef enum {
|
||||||
RRES_VERT_BYTE,
|
RRES_VERT_BYTE,
|
||||||
RRES_VERT_SHORT,
|
RRES_VERT_SHORT,
|
||||||
|
|
@ -275,10 +351,10 @@ RRESDEF RRES LoadResource(const char *fileName, int rresId)
|
||||||
// Read resource info and parameters
|
// Read resource info and parameters
|
||||||
fread(&infoHeader, sizeof(RRESInfoHeader), 1, rresFile);
|
fread(&infoHeader, sizeof(RRESInfoHeader), 1, rresFile);
|
||||||
|
|
||||||
rres = (RRES)malloc(sizeof(RRESData)*infoHeader.partsCount);
|
|
||||||
|
|
||||||
if (infoHeader.id == rresId)
|
if (infoHeader.id == rresId)
|
||||||
{
|
{
|
||||||
|
rres = (RRES)malloc(sizeof(RRESData)*infoHeader.partsCount);
|
||||||
|
|
||||||
// Load all required resources parts
|
// Load all required resources parts
|
||||||
for (int k = 0; k < infoHeader.partsCount; k++)
|
for (int k = 0; k < infoHeader.partsCount; k++)
|
||||||
{
|
{
|
||||||
|
|
@ -327,8 +403,11 @@ RRESDEF RRES LoadResource(const char *fileName, int rresId)
|
||||||
return rres;
|
return rres;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unload resource data
|
||||||
RRESDEF void UnloadResource(RRES rres)
|
RRESDEF void UnloadResource(RRES rres)
|
||||||
{
|
{
|
||||||
|
// TODO: When you load resource... how many parts conform it? depends on type? --> Not clear...
|
||||||
|
|
||||||
if (rres[0].data != NULL) free(rres[0].data);
|
if (rres[0].data != NULL) free(rres[0].data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -401,28 +480,4 @@ void TraceLog(int logType, const char *text, ...)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // RAYGUI_IMPLEMENTATION
|
#endif // RRES_IMPLEMENTATION
|
||||||
|
|
||||||
/*
|
|
||||||
Mesh LoadMeshEx(int numVertex, float *vData, float *vtData, float *vnData, Color *cData);
|
|
||||||
Mesh LoadMeshEx(rres.param1, rres.data, rres.data + offset, rres.data + offset*2, rres.data + offset*3);
|
|
||||||
|
|
||||||
Shader LoadShader(const char *vsText, int vsLength);
|
|
||||||
Shader LoadShaderV(rres.data, rres.param1);
|
|
||||||
|
|
||||||
// Parameters information depending on resource type
|
|
||||||
|
|
||||||
// RRES_TYPE_IMAGE params: imgWidth, imgHeight, format, mipmaps;
|
|
||||||
// RRES_TYPE_WAVE params: sampleCount, sampleRate, sampleSize, channels;
|
|
||||||
// RRES_TYPE_FONT_IMAGE params: imgWidth, imgHeight, format, mipmaps;
|
|
||||||
// RRES_TYPE_FONT_DATA params: charsCount, baseSize
|
|
||||||
// RRES_TYPE_VERTEX params: vertexCount, vertexType, vertexFormat // Use masks instead?
|
|
||||||
// RRES_TYPE_TEXT params: charsCount, cultureCode
|
|
||||||
// RRES_TYPE_DIRECTORY params: fileCount, directoryCount
|
|
||||||
|
|
||||||
// SpriteFont = RRES_TYPE_FONT_IMAGE chunk + RRES_TYPE_FONT_DATA chunk
|
|
||||||
// Mesh = multiple RRES_TYPE_VERTEX chunks
|
|
||||||
|
|
||||||
Ref: RIFF file-format: http://www.johnloomis.org/cpe102/asgn/asgn1/riff.html
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
|
||||||
55
src/shapes.c
55
src/shapes.c
|
|
@ -289,6 +289,53 @@ void DrawRectangleGradient(int posX, int posY, int width, int height, Color colo
|
||||||
rlEnd();
|
rlEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw a gradient-filled rectangle
|
||||||
|
void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4)
|
||||||
|
{
|
||||||
|
rlEnableTexture(GetTextureDefault().id); // Default white texture
|
||||||
|
|
||||||
|
rlBegin(RL_QUADS);
|
||||||
|
rlNormal3f(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
rlColor4ub(col1.r, col1.g, col1.b, col1.a);
|
||||||
|
rlTexCoord2f(0.0f, 0.0f);
|
||||||
|
rlVertex2f(rec.x, rec.y);
|
||||||
|
|
||||||
|
rlColor4ub(col2.r, col2.g, col2.b, col2.a);
|
||||||
|
rlTexCoord2f(0.0f, 1.0f);
|
||||||
|
rlVertex2f(rec.x, rec.y + rec.height);
|
||||||
|
|
||||||
|
rlColor4ub(col3.r, col3.g, col3.b, col3.a);
|
||||||
|
rlTexCoord2f(1.0f, 1.0f);
|
||||||
|
rlVertex2f(rec.x + rec.width, rec.y + rec.height);
|
||||||
|
|
||||||
|
rlColor4ub(col4.r, col4.g, col4.b, col4.a);
|
||||||
|
rlTexCoord2f(1.0f, 0.0f);
|
||||||
|
rlVertex2f(rec.x + rec.width, rec.y);
|
||||||
|
rlEnd();
|
||||||
|
|
||||||
|
// Draw rectangle using font texture white character
|
||||||
|
/*
|
||||||
|
rlTexCoord2f((float)GetDefaultFont().chars[95].rec.x/GetDefaultFont().texture.width,
|
||||||
|
(float)GetDefaultFont().chars[95].rec.y/GetDefaultFont().texture.height);
|
||||||
|
rlVertex2f(rec.x, rec.y);
|
||||||
|
|
||||||
|
rlTexCoord2f((float)GetDefaultFont().chars[95].rec.x/GetDefaultFont().texture.width,
|
||||||
|
(float)(GetDefaultFont().chars[95].rec.y + GetDefaultFont().chars[95].rec.height)/GetDefaultFont().texture.height);
|
||||||
|
rlVertex2f(rec.x, rec.y + rec.height);
|
||||||
|
|
||||||
|
rlTexCoord2f((float)(GetDefaultFont().chars[95].rec.x + GetDefaultFont().chars[95].rec.width)/GetDefaultFont().texture.width,
|
||||||
|
(float)(GetDefaultFont().chars[95].rec.y + GetDefaultFont().chars[95].rec.height)/GetDefaultFont().texture.height);
|
||||||
|
rlVertex2f(rec.x + rec.width, rec.y + rec.height);
|
||||||
|
|
||||||
|
rlTexCoord2f((float)(GetDefaultFont().chars[95].rec.x + GetDefaultFont().chars[95].rec.width)/GetDefaultFont().texture.width,
|
||||||
|
(float)GetDefaultFont().chars[95].rec.y/GetDefaultFont().texture.height);
|
||||||
|
rlVertex2f(rec.x + rec.width, rec.y);
|
||||||
|
*/
|
||||||
|
|
||||||
|
rlDisableTexture();
|
||||||
|
}
|
||||||
|
|
||||||
// Draw a color-filled rectangle (Vector version)
|
// Draw a color-filled rectangle (Vector version)
|
||||||
// NOTE: On OpenGL 3.3 and ES2 we use QUADS to avoid drawing order issues (view rlglDraw)
|
// NOTE: On OpenGL 3.3 and ES2 we use QUADS to avoid drawing order issues (view rlglDraw)
|
||||||
void DrawRectangleV(Vector2 position, Vector2 size, Color color)
|
void DrawRectangleV(Vector2 position, Vector2 size, Color color)
|
||||||
|
|
@ -362,6 +409,14 @@ void DrawRectangleLines(int posX, int posY, int width, int height, Color color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw rectangle using text character (char: 127)
|
||||||
|
// NOTE: Useful to avoid changing to default white texture
|
||||||
|
void DrawRectangleT(int posX, int posY, int width, int height, Color color)
|
||||||
|
{
|
||||||
|
DrawTexturePro(GetDefaultFont().texture, GetDefaultFont().chars[95].rec,
|
||||||
|
(Rectangle){ posX, posY, width, height }, (Vector2){ 0, 0 }, 0.0f, color);
|
||||||
|
}
|
||||||
|
|
||||||
// Draw a triangle
|
// Draw a triangle
|
||||||
void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
|
void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -457,14 +457,6 @@ void DrawTextEx(SpriteFont spriteFont, const char *text, Vector2 position, float
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw rectangle using text character (char: 127)
|
|
||||||
// NOTE: Useful to avoid changing to default white texture
|
|
||||||
void DrawRectangleT(int posX, int posY, int width, int height, Color color)
|
|
||||||
{
|
|
||||||
DrawTexturePro(GetDefaultFont().texture, GetDefaultFont().chars[95].rec,
|
|
||||||
(Rectangle){ posX, posY, width, height }, (Vector2){ 0, 0 }, 0.0f, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Formatting of text with variables to 'embed'
|
// Formatting of text with variables to 'embed'
|
||||||
const char *FormatText(const char *text, ...)
|
const char *FormatText(const char *text, ...)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,9 @@
|
||||||
* Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop...
|
* Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop...
|
||||||
* If not defined only three image editing functions supported: ImageFormat(), ImageAlphaMask(), ImageToPOT()
|
* If not defined only three image editing functions supported: ImageFormat(), ImageAlphaMask(), ImageToPOT()
|
||||||
*
|
*
|
||||||
|
* #define SUPPORT_IMAGE_GENERATION
|
||||||
|
* Support proedural image generation functionality (gradient, spot, perlin-noise, cellular)
|
||||||
|
*
|
||||||
* DEPENDENCIES:
|
* DEPENDENCIES:
|
||||||
* stb_image - Multiple image formats loading (JPEG, PNG, BMP, TGA, PSD, GIF, PIC)
|
* stb_image - Multiple image formats loading (JPEG, PNG, BMP, TGA, PSD, GIF, PIC)
|
||||||
* NOTE: stb_image has been slightly modified to support Android platform.
|
* NOTE: stb_image has been slightly modified to support Android platform.
|
||||||
|
|
@ -56,6 +59,7 @@
|
||||||
#define SUPPORT_FILEFORMAT_DDS
|
#define SUPPORT_FILEFORMAT_DDS
|
||||||
#define SUPPORT_FILEFORMAT_HDR
|
#define SUPPORT_FILEFORMAT_HDR
|
||||||
#define SUPPORT_IMAGE_MANIPULATION
|
#define SUPPORT_IMAGE_MANIPULATION
|
||||||
|
#define SUPPORT_IMAGE_GENERATION
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
@ -1064,7 +1068,7 @@ Image ImageTextEx(SpriteFont font, const char *text, float fontSize, int spacing
|
||||||
|
|
||||||
Vector2 imSize = MeasureTextEx(font, text, font.baseSize, spacing);
|
Vector2 imSize = MeasureTextEx(font, text, font.baseSize, spacing);
|
||||||
|
|
||||||
// NOTE: GetTextureData() not available in OpenGL ES
|
// NOTE: glGetTexImage() not available in OpenGL ES
|
||||||
Image imFont = GetTextureData(font.texture);
|
Image imFont = GetTextureData(font.texture);
|
||||||
|
|
||||||
ImageFormat(&imFont, UNCOMPRESSED_R8G8B8A8); // Convert to 32 bit for color tint
|
ImageFormat(&imFont, UNCOMPRESSED_R8G8B8A8); // Convert to 32 bit for color tint
|
||||||
|
|
@ -1447,6 +1451,7 @@ void ImageColorBrightness(Image *image, int brightness)
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_IMAGE_MANIPULATION
|
#endif // SUPPORT_IMAGE_MANIPULATION
|
||||||
|
|
||||||
|
#if defined(SUPPORT_IMAGE_GENERATION)
|
||||||
// Generate image: vertical gradient
|
// Generate image: vertical gradient
|
||||||
Image GenImageGradientV(int width, int height, Color top, Color bottom)
|
Image GenImageGradientV(int width, int height, Color top, Color bottom)
|
||||||
{
|
{
|
||||||
|
|
@ -1647,6 +1652,7 @@ Image GenImageCellular(int width, int height, int tileSize)
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_IMAGE_GENERATION
|
||||||
|
|
||||||
// Generate GPU mipmaps for a texture
|
// Generate GPU mipmaps for a texture
|
||||||
void GenTextureMipmaps(Texture2D *texture)
|
void GenTextureMipmaps(Texture2D *texture)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="1.0" >
|
android:versionName="1.0" >
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="17" />
|
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16" />
|
||||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
||||||
<!--<supports-gl-texture android:name="GL_OES_compressed_ETC1_RGB8_texture" android:required="true"/>-->
|
<!--<supports-gl-texture android:name="GL_OES_compressed_ETC1_RGB8_texture" android:required="true"/>-->
|
||||||
<!-- We do not have Java code. Therefore android:hasCode is set to false. -->
|
<!-- We do not have Java code. Therefore android:hasCode is set to false. -->
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue