update from master
This commit is contained in:
commit
957876ab7c
4
.github/workflows/linux.yml
vendored
4
.github/workflows/linux.yml
vendored
|
|
@ -55,7 +55,7 @@ jobs:
|
|||
- name: Build Library
|
||||
run: |
|
||||
cd src
|
||||
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CFLAGS="-m32"
|
||||
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CFLAGS="-m32" -B
|
||||
# make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
||||
cd ..
|
||||
if: matrix.bits == 32
|
||||
|
|
@ -63,7 +63,7 @@ jobs:
|
|||
- name: Build Library
|
||||
run: |
|
||||
cd src
|
||||
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib"
|
||||
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
||||
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
||||
cd ..
|
||||
if: matrix.bits == 64
|
||||
|
|
|
|||
4
.github/workflows/macos.yml
vendored
4
.github/workflows/macos.yml
vendored
|
|
@ -40,12 +40,12 @@ jobs:
|
|||
run: |
|
||||
cd src
|
||||
clang --version
|
||||
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION"
|
||||
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION" -B
|
||||
# make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC RAYLIB_LIB_NAME=raylib_x86_64 CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION"
|
||||
# make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=STATIC RAYLIB_LIB_NAME=raylib_arm64 CFLAGS="-target arm64-apple-macos11 -DGL_SILENCE_DEPRECATION" -B
|
||||
# lipo -create -output ../build/${{ env.RELEASE_NAME }}/lib/libraylib.a libraylib_x86_64.a libraylib_arm64.a
|
||||
make clean
|
||||
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION"
|
||||
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION" -B
|
||||
# make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED RAYLIB_LIB_NAME=raylib_x86_64 CFLAGS="-target x86_64-apple-macos10.12 -DGL_SILENCE_DEPRECATION" -B
|
||||
# make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED RAYLIB_LIB_NAME=raylib_arm64 CFLAGS="-target i686-apple-macos -DGL_SILENCE_DEPRECATION" -B
|
||||
# lipo -create -output ../build/${{ env.RELEASE_NAME }}/lib/libraylib.3.1.0.dylib libraylib_x86_64.3.1.0.dylib libraylib_arm64.3.1.0.dylib
|
||||
|
|
|
|||
2
.github/workflows/webassembly.yml
vendored
2
.github/workflows/webassembly.yml
vendored
|
|
@ -43,7 +43,7 @@ jobs:
|
|||
run: |
|
||||
cd src
|
||||
emcc -v
|
||||
make PLATFORM=PLATFORM_WEB EMSDK_PATH="D:/a/raylib/raylib/emsdk-cache/emsdk-master" RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib"
|
||||
make PLATFORM=PLATFORM_WEB EMSDK_PATH="D:/a/raylib/raylib/emsdk-cache/emsdk-master" RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
|
||||
cd ..
|
||||
|
||||
- name: Generate Artifacts
|
||||
|
|
|
|||
|
|
@ -94,12 +94,13 @@ Some people ported raylib to other languages in form of bindings or wrappers to
|
|||
| raylib-smallBasic | 3.1-dev | [SmallBASIC](https://github.com/smallbasic/SmallBASIC) | https://github.com/smallbasic/smallbasic.plugins/tree/master/raylib |
|
||||
| raylib-ats2 | 3.0 | [ATS2](http://www.ats-lang.org/) | https://github.com/mephistopheles-8/raylib-ats2 |
|
||||
| raylib-beef | 3.0 | [Beef](https://www.beeflang.org/) | https://github.com/M0n7y5/raylib-beef |
|
||||
| raylib-swift | 3.5 | [Swift](https://swift.org/) | https://github.com/conifer-dev/raylib-swift |
|
||||
| raylib-swift | 3.7 | [Swift](https://swift.org/) | https://github.com/STREGAsGate/Raylib |
|
||||
| raylib-never | 3.0 | [Never](https://github.com/never-lang/never) | https://github.com/never-lang/raylib-never |
|
||||
| hb-raylib | 3.5 | [Harbour](https://harbour.github.io) | https://github.com/MarcosLeonardoMendezGerencir/hb-raylib |
|
||||
| Relib | 3.5 | [ReCT](https://github.com/RedCubeDev-ByteSpace/ReCT) | https://github.com/RedCubeDev-ByteSpace/Relib |
|
||||
| rayex | 3.7 | [elixir](https://elixir-lang.org/) | https://github.com/shiryel/rayex |
|
||||
| raylib.cbl | 2.0 | [COBOL](https://en.wikipedia.org/wiki/COBOL) | *[code examples](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib)* |
|
||||
| kaylib | 3.7 | [Kotlin/native](https://kotlinlang.org) | https://github.com/electronstudio/kaylib |
|
||||
|
||||
### Utility Wrapers
|
||||
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ endif()
|
|||
option(INCLUDE_EVERYTHING "Include everything disabled by default (for CI usage" OFF)
|
||||
set(OFF ${INCLUDE_EVERYTHING} CACHE INTERNAL "Replace any OFF by default with \${OFF} to have it covered by this option")
|
||||
|
||||
# core.c
|
||||
cmake_dependent_option(SUPPORT_CAMERA_SYSTEM "Provide camera module (camera.h) with multiple predefined cameras: free, 1st/3rd person, orbital" ON CUSTOMIZE_BUILD ON)
|
||||
cmake_dependent_option(SUPPORT_GESTURES_SYSTEM "Gestures module is included (gestures.h) to support gestures detection: tap, hold, swipe, drag" ON CUSTOMIZE_BUILD ON)
|
||||
# rcore.c
|
||||
cmake_dependent_option(SUPPORT_CAMERA_SYSTEM "Provide camera module (rcamera.h) with multiple predefined cameras: free, 1st/3rd person, orbital" ON CUSTOMIZE_BUILD ON)
|
||||
cmake_dependent_option(SUPPORT_GESTURES_SYSTEM "Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag" ON CUSTOMIZE_BUILD ON)
|
||||
cmake_dependent_option(SUPPORT_MOUSE_GESTURES "Mouse gestures are directly mapped like touches and processed by gestures system" ON CUSTOMIZE_BUILD ON)
|
||||
cmake_dependent_option(SUPPORT_SSH_KEYBOARD_RPI "Reconfigure standard input to receive key inputs, works with SSH connection" OFF CUSTOMIZE_BUILD OFF)
|
||||
cmake_dependent_option(SUPPORT_DEFAULT_FONT "Default font is loaded on window initialization to be available for the user to render simple text. If enabled, uses external module functions to load default raylib font (module: text)" ON CUSTOMIZE_BUILD ON)
|
||||
|
|
@ -41,10 +41,10 @@ cmake_dependent_option(SUPPORT_WINMM_HIGHRES_TIMER "Setting a higher resolution
|
|||
cmake_dependent_option(SUPPORT_DATA_STORAGE "Support for persistent data storage" ON CUSTOMIZE_BUILD ON)
|
||||
cmake_dependent_option(SUPPORT_COMPRESSION_API "Support for compression API" ON CUSTOMIZE_BUILD ON)
|
||||
|
||||
# shapes.c
|
||||
# rshapes.c
|
||||
cmake_dependent_option(SUPPORT_QUADS_DRAW_MODE "Use QUADS instead of TRIANGLES for drawing when possible. Some lines-based shapes could still use lines" ON CUSTOMIZE_BUILD ON)
|
||||
|
||||
# textures.c
|
||||
# rtextures.c
|
||||
cmake_dependent_option(SUPPORT_IMAGE_EXPORT "Support image exporting to file" ON CUSTOMIZE_BUILD ON)
|
||||
cmake_dependent_option(SUPPORT_IMAGE_GENERATION "Support procedural image generation functionality (gradient, spot, perlin-noise, cellular)" ON CUSTOMIZE_BUILD ON)
|
||||
cmake_dependent_option(SUPPORT_IMAGE_MANIPULATION "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()" ON CUSTOMIZE_BUILD ON)
|
||||
|
|
@ -61,12 +61,12 @@ cmake_dependent_option(SUPPORT_FILEFORMAT_PSD "Support loading PSD as textures"
|
|||
cmake_dependent_option(SUPPORT_FILEFORMAT_PKM "Support loading PKM as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
||||
cmake_dependent_option(SUPPORT_FILEFORMAT_PVR "Support loading PVR as textures" ${OFF} CUSTOMIZE_BUILD OFF)
|
||||
|
||||
# text.c
|
||||
# rtext.c
|
||||
cmake_dependent_option(SUPPORT_FILEFORMAT_FNT "Support loading fonts in FNT format" ON CUSTOMIZE_BUILD ON)
|
||||
cmake_dependent_option(SUPPORT_FILEFORMAT_TTF "Support loading font in TTF/OTF format" ON CUSTOMIZE_BUILD ON)
|
||||
cmake_dependent_option(SUPPORT_TEXT_MANIPULATION "Support text manipulation functions" ON CUSTOMIZE_BUILD ON)
|
||||
|
||||
# models.c
|
||||
# rmodels.c
|
||||
cmake_dependent_option(SUPPORT_MESH_GENERATION "Support procedural mesh generation functions, uses external par_shapes.h library. NOTE: Some generated meshes DO NOT include generated texture coordinates" ON CUSTOMIZE_BUILD ON)
|
||||
cmake_dependent_option(SUPPORT_FILEFORMAT_OBJ "Support loading OBJ file format" ON CUSTOMIZE_BUILD ON)
|
||||
cmake_dependent_option(SUPPORT_FILEFORMAT_MTL "Support loading MTL file format" ON CUSTOMIZE_BUILD ON)
|
||||
|
|
|
|||
10
HISTORY.md
10
HISTORY.md
|
|
@ -33,7 +33,7 @@ Lots of code changes and lot of testing have concluded in this amazing new rayli
|
|||
notes on raylib 1.2
|
||||
-------------------
|
||||
|
||||
On September 2014, after 5 month of raylib 1.1 release, it comes raylib 1.2. Again, this version presents a complete internal redesign of [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module to support two new platforms: [Android](http://www.android.com/) and [Raspberry Pi](http://www.raspberrypi.org/).
|
||||
On September 2014, after 5 month of raylib 1.1 release, it comes raylib 1.2. Again, this version presents a complete internal redesign of [core](https://github.com/raysan5/raylib/blob/master/src/rcore.c) module to support two new platforms: [Android](http://www.android.com/) and [Raspberry Pi](http://www.raspberrypi.org/).
|
||||
|
||||
It's been some month of really hard work to accomodate raylib to those new platforms while keeping it easy for the users. On Android, raylib manages internally the activity cicle, as well as the inputs; on Raspberry Pi, a complete raw input system has been written from scratch.
|
||||
|
||||
|
|
@ -54,9 +54,9 @@ On September 2015, after 1 year of raylib 1.2 release, arrives raylib 1.3. This
|
|||
|
||||
- Textures module has grown to support most of the internal texture formats available in OpenGL (RGB565, RGB888, RGBA5551, RGBA4444, etc.), including compressed texture formats (DXT, ETC1, ETC2, ASTC, PVRT); raylib 1.3 can load .dds, .pkm, .ktx, .astc and .pvr files.
|
||||
|
||||
- A brand new [camera](https://github.com/raysan5/raylib/blob/master/src/camera.c) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person). Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_first_person.c).
|
||||
- A brand new [camera](https://github.com/raysan5/raylib/blob/master/src/rcamera.c) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person). Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_first_person.c).
|
||||
|
||||
- New [gestures](https://github.com/raysan5/raylib/blob/master/src/gestures.h) module simplifies gestures detection on Android and HTML5 programs.
|
||||
- New [gestures](https://github.com/raysan5/raylib/blob/master/src/rgestures.h) module simplifies gestures detection on Android and HTML5 programs.
|
||||
|
||||
- [raygui](https://github.com/raysan5/raylib/blob/master/src/raygui.h), the new immediate-mode GUI module offers a set of functions to create simple user interfaces, primary intended for tools development. It's still in experimental state but already fully functional.
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ On February 2016, after 4 months of raylib 1.3 release, it comes raylib 1.4. For
|
|||
|
||||
- [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h) module has been reviewed; some bugs have been solved and the module has been converted to a header-only file for easier portability, optionally, functions can also be used as inline.
|
||||
|
||||
- [gestures](https://github.com/raysan5/raylib/blob/master/src/gestures.c) module has redesigned and simplified, now it can process touch events from any source, including mouse. This way, gestures system can be used on any platform providing an unified way to work with inputs and allowing the user to create multiplatform games with only one source code.
|
||||
- [gestures](https://github.com/raysan5/raylib/blob/master/src/rgestures.c) module has redesigned and simplified, now it can process touch events from any source, including mouse. This way, gestures system can be used on any platform providing an unified way to work with inputs and allowing the user to create multiplatform games with only one source code.
|
||||
|
||||
- Raspberry Pi input system has been redesigned to better read raw inputs using generic Linux event handlers (keyboard:`stdin`, mouse:`/dev/input/mouse0`, gamepad:`/dev/input/js0`). Gamepad support has also been added (experimental).
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ On July 2016, after 5 months of raylib 1.4 release, arrives raylib 1.5. This new
|
|||
|
||||
- Audio chiptunese support and mixing channels: Added support for module audio music (.xm, .mod) loading and playing. Multiple mixing channels are now also supported. All this features thanks to the amazing work of @kd7tck.
|
||||
|
||||
Other additions include a [2D camera system](https://github.com/raysan5/raylib/blob/master/examples/core_2d_camera.c), render textures for offline render (and most comprehensive [postprocessing](https://github.com/raysan5/raylib/blob/master/examples/shaders_postprocessing.c)) or support for legacy OpenGL 2.1 on desktop platforms.
|
||||
Other additions include a [2D camera system](https://github.com/raysan5/raylib/blob/master/examples/core_2d_rcamera.c), render textures for offline render (and most comprehensive [postprocessing](https://github.com/raysan5/raylib/blob/master/examples/shaders_postprocessing.c)) or support for legacy OpenGL 2.1 on desktop platforms.
|
||||
|
||||
This new version is so massive that is difficult to list all the improvements, most of raylib modules have been reviewed and [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) module has been completely redesigned to accomodate to new material-lighting systems and stereo rendering. You can check [CHANGELOG](https://github.com/raysan5/raylib/blob/master/CHANGELOG) file for a more detailed list of changes.
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ if (${PLATFORM} MATCHES "Desktop")
|
|||
endif ()
|
||||
elseif (WIN32)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
set(LIBS_PRIVATE ${LIBS_PRIVATE} winmm)
|
||||
find_package(OpenGL QUIET)
|
||||
set(LIBS_PRIVATE ${OPENGL_LIBRARIES} winmm)
|
||||
else ()
|
||||
find_library(pthread NAMES pthread)
|
||||
find_package(OpenGL QUIET)
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ if (${PLATFORM} MATCHES "Android")
|
|||
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}/models/models_first_person_maze.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_magicavoxel_loading.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)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
# Define required raylib variables
|
||||
PROJECT_NAME ?= raylib_examples
|
||||
RAYLIB_VERSION ?= 3.8.0
|
||||
RAYLIB_VERSION ?= 4.0.0
|
||||
RAYLIB_PATH ?= ..
|
||||
|
||||
# Define default options
|
||||
|
|
@ -185,6 +185,12 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
|||
MAKE = mingw32-make
|
||||
endif
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
||||
MAKE = mingw32-make
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
MAKE = mingw32-make
|
||||
endif
|
||||
|
||||
# Define compiler flags:
|
||||
# -O1 defines optimization level
|
||||
|
|
@ -229,32 +235,6 @@ endif
|
|||
ifeq ($(PLATFORM),PLATFORM_DRM)
|
||||
CFLAGS += -std=gnu99 -DEGL_NO_X11
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
# -Os # size optimization
|
||||
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
||||
# -s USE_GLFW=3 # Use glfw3 library (context/input management)
|
||||
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
|
||||
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
|
||||
# -s USE_PTHREADS=1 # multithreading support
|
||||
# -s WASM=0 # disable Web Assembly, emitted by default
|
||||
# -s ASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
|
||||
# -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data
|
||||
# -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off)
|
||||
# --profiling # include information for code profiling
|
||||
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
||||
# --preload-file resources # specify a resources folder for data compilation
|
||||
# --source-map-base # allow debugging in browser with source map
|
||||
CFLAGS += -s USE_GLFW=3 -s ASYNCIFY -s TOTAL_MEMORY=67108864 -s FORCE_FILESYSTEM=1 --preload-file $(dir $<)resources@resources
|
||||
|
||||
# NOTE: Simple raylib examples are compiled to be interpreter with asyncify, that way,
|
||||
# we can compile same code for ALL platforms with no change required, but, working on bigger
|
||||
# projects, code needs to be refactored to avoid a blocking while() loop, moving Update and Draw
|
||||
# logic to a self contained function: UpdateDrawFrame(), check core_basic_window_web.c for reference.
|
||||
|
||||
# Define a custom shell .html and output extension
|
||||
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
||||
EXT = .html
|
||||
endif
|
||||
|
||||
# Define include paths for required headers
|
||||
# NOTE: Some external/extras libraries could be required (stb, physac, easings...)
|
||||
|
|
@ -303,7 +283,32 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
|||
LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
# -Os # size optimization
|
||||
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
||||
# -s USE_GLFW=3 # Use glfw3 library (context/input management)
|
||||
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
|
||||
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB)
|
||||
# -s USE_PTHREADS=1 # multithreading support
|
||||
# -s WASM=0 # disable Web Assembly, emitted by default
|
||||
# -s ASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS
|
||||
# -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data
|
||||
# -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off)
|
||||
# --profiling # include information for code profiling
|
||||
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
||||
# --preload-file resources # specify a resources folder for data compilation
|
||||
# --source-map-base # allow debugging in browser with source map
|
||||
LDFLAGS += -s USE_GLFW=3 -s ASYNCIFY -s TOTAL_MEMORY=67108864 -s FORCE_FILESYSTEM=1 --preload-file $(dir $<)resources@resources
|
||||
|
||||
# NOTE: Simple raylib examples are compiled to be interpreter with asyncify, that way,
|
||||
# we can compile same code for ALL platforms with no change required, but, working on bigger
|
||||
# projects, code needs to be refactored to avoid a blocking while() loop, moving Update and Draw
|
||||
# logic to a self contained function: UpdateDrawFrame(), check core_basic_window_web.c for reference.
|
||||
|
||||
# Define a custom shell .html and output extension
|
||||
LDFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
||||
EXT = .html
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||
LDFLAGS += -L/opt/vc/lib
|
||||
endif
|
||||
|
|
@ -466,7 +471,8 @@ MODELS = \
|
|||
models/models_skybox \
|
||||
models/models_yaw_pitch_roll \
|
||||
models/models_heightmap \
|
||||
models/models_waving_cubes
|
||||
models/models_waving_cubes \
|
||||
models/models_magicavoxel_loading
|
||||
|
||||
SHADERS = \
|
||||
shaders/shaders_model_shader \
|
||||
|
|
|
|||
151
examples/models/models_magicavoxel_loading.c
Normal file
151
examples/models/models_magicavoxel_loading.c
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [models] example - magicavoxel loader and viewer
|
||||
*
|
||||
* This example has been created using raylib 3.8 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Example contributed by Johann Nadalutti
|
||||
*
|
||||
* Copyright (c) 2021 Johann Nadalutti
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
#include "raymath.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// VOX Files to load and view
|
||||
|
||||
#define NUM_VOX_FILES 3
|
||||
|
||||
const char* szVoxFiles[] = {
|
||||
"resources/vox/chr_knight.vox",
|
||||
"resources/vox/chr_sword.vox",
|
||||
"resources/vox/monu9.vox"
|
||||
};
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - magicavoxel loading");
|
||||
|
||||
// Load MagicaVoxel files
|
||||
Model models[NUM_VOX_FILES] = { 0 };
|
||||
|
||||
for (int i = 0; i < NUM_VOX_FILES; i++)
|
||||
{
|
||||
// Load MagicaVoxel File and build model
|
||||
double t0, t1;
|
||||
t0 = GetTime() * 1000.0;
|
||||
|
||||
models[i] = LoadModel(szVoxFiles[i]);
|
||||
|
||||
t1 = GetTime() * 1000.0;
|
||||
TraceLog(LOG_INFO, TextFormat("Vox <%s> loaded in %f ms", GetFileName(szVoxFiles[i]), t1 - t0));
|
||||
|
||||
//Compute model's center matrix
|
||||
BoundingBox bb = GetModelBoundingBox(models[i]);
|
||||
Vector3 center;
|
||||
center.x = bb.min.x + (((bb.max.x - bb.min.x) / 2));
|
||||
center.z = bb.min.z + (((bb.max.z - bb.min.z) / 2));
|
||||
|
||||
Matrix matP = MatrixTranslate(-center.x, 0, -center.z);
|
||||
models[i].transform = matP;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = { { 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||
|
||||
// Model drawing position
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
int currentModel = 0;
|
||||
|
||||
|
||||
|
||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set a orbital 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); // Update internal camera and our camera
|
||||
|
||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||
{
|
||||
currentModel = (currentModel + 1) % NUM_VOX_FILES; // Cycle between models
|
||||
}
|
||||
|
||||
if (IsKeyPressed(KEY_RIGHT))
|
||||
{
|
||||
currentModel++;
|
||||
if (currentModel >= NUM_VOX_FILES) currentModel = 0;
|
||||
}
|
||||
else if (IsKeyPressed(KEY_LEFT))
|
||||
{
|
||||
currentModel--;
|
||||
if (currentModel < 0) currentModel = NUM_VOX_FILES - 1;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
//Display model
|
||||
BeginMode3D(camera);
|
||||
|
||||
Vector3 rotAxis = { 1,0,0 };
|
||||
Vector3 scale = { 1,1,1 };
|
||||
|
||||
|
||||
DrawModelEx(models[currentModel], position, rotAxis, 0, scale, WHITE);
|
||||
//DrawModelWiresEx(models[currentModel], position, rotAxis, -90.0f, scale, BLACK);
|
||||
|
||||
DrawGrid(10, 1.0);
|
||||
|
||||
EndMode3D();
|
||||
|
||||
//Display debug infos
|
||||
DrawRectangle(30, 400, 310, 30, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines(30, 400, 310, 30, Fade(DARKBLUE, 0.5f));
|
||||
DrawText("MOUSE LEFT BUTTON to CYCLE VOX MODELS", 40, 410, 10, BLUE);
|
||||
|
||||
DrawText(GetFileName(szVoxFiles[currentModel]), 100, 10, 20, DARKBLUE);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Unload models data (GPU VRAM)
|
||||
for (int i = 0; i < NUM_VOX_FILES; i++) UnloadModel(models[i]);
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BIN
examples/models/resources/vox/chr_knight.vox
Normal file
BIN
examples/models/resources/vox/chr_knight.vox
Normal file
Binary file not shown.
BIN
examples/models/resources/vox/chr_sword.vox
Normal file
BIN
examples/models/resources/vox/chr_sword.vox
Normal file
Binary file not shown.
BIN
examples/models/resources/vox/monu9.vox
Normal file
BIN
examples/models/resources/vox/monu9.vox
Normal file
Binary file not shown.
|
|
@ -18,11 +18,11 @@ cmd /c del /F libraylib.a
|
|||
:: > Compile raylib modules
|
||||
:: ------------------------------
|
||||
gcc -O2 -c rglfw.c -Wall -I. -Iexternal/glfw/include
|
||||
gcc -O2 -c core.c -std=c99 -Wall -Iexternal/glfw/include -DPLATFORM_DESKTOP -D%GRAPHICS_API%
|
||||
gcc -O2 -c shapes.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||
gcc -O2 -c textures.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||
gcc -O2 -c text.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||
gcc -O2 -c models.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||
gcc -O2 -c rcore.c -std=c99 -Wall -Iexternal/glfw/include -DPLATFORM_DESKTOP -D%GRAPHICS_API%
|
||||
gcc -O2 -c rshapes.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||
gcc -O2 -c rtextures.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||
gcc -O2 -c rtext.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||
gcc -O2 -c rmodels.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||
gcc -O2 -c raudio.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||
gcc -O2 -c utils.c -std=c99 -Wall -DPLATFORM_DESKTOP
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
387
projects/VS2019/examples/models_mesh_magicavoxel_loading.vcxproj
Normal file
387
projects/VS2019/examples/models_mesh_magicavoxel_loading.vcxproj
Normal file
|
|
@ -0,0 +1,387 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug.DLL|Win32">
|
||||
<Configuration>Debug.DLL</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug.DLL|x64">
|
||||
<Configuration>Debug.DLL</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release.DLL|Win32">
|
||||
<Configuration>Release.DLL</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release.DLL|x64">
|
||||
<Configuration>Release.DLL</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{2F1B955B-275E-4D8E-8864-06FEC44D7912}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>models_mesh_magicavoxel_loading</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>models_mesh_magicavoxel_loading</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|Win32'">
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\examples\models</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|x64'">
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\examples\models</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\examples\models</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\examples\models</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|Win32'">
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\examples\models</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\examples\models</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\examples\models</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|x64'">
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)..\..\examples\models</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<CompileAs>CompileAsC</CompileAs>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<CompileAs>CompileAsC</CompileAs>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<CompileAs>CompileAsC</CompileAs>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"</Command>
|
||||
<Message>Copy Debug DLL to output directory</Message>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<CompileAs>CompileAsC</CompileAs>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"</Command>
|
||||
<Message>Copy Debug DLL to output directory</Message>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<CompileAs>CompileAsC</CompileAs>
|
||||
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<CompileAs>CompileAsC</CompileAs>
|
||||
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<CompileAs>CompileAsC</CompileAs>
|
||||
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"</Command>
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>
|
||||
<Message>Copy Release DLL to output directory</Message>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<CompileAs>CompileAsC</CompileAs>
|
||||
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)"</Command>
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent>
|
||||
<Message>Copy Release DLL to output directory</Message>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\raylib\raylib.vcxproj">
|
||||
<Project>{e89d61ac-55de-4482-afd4-df7242ebc859}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\examples\models\models_magicavoxel_loading.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -275,6 +275,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rlgl_standalone", "examples
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_split_screen", "examples\core_split_screen.vcxproj", "{946A1700-C7AA-46F0-AEF2-67C98B5722AC}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "models_mesh_magicavoxel_loading", "examples\models_mesh_magicavoxel_loading.vcxproj", "{2F1B955B-275E-4D8E-8864-06FEC44D7912}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug.DLL|x64 = Debug.DLL|x64
|
||||
|
|
@ -2283,6 +2285,22 @@ Global
|
|||
{946A1700-C7AA-46F0-AEF2-67C98B5722AC}.Release|x64.Build.0 = Release|x64
|
||||
{946A1700-C7AA-46F0-AEF2-67C98B5722AC}.Release|x86.ActiveCfg = Release|Win32
|
||||
{946A1700-C7AA-46F0-AEF2-67C98B5722AC}.Release|x86.Build.0 = Release|Win32
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Debug.DLL|x64.Build.0 = Debug.DLL|x64
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Debug|x64.Build.0 = Debug|x64
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Debug|x86.Build.0 = Debug|Win32
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Release.DLL|x64.ActiveCfg = Release.DLL|x64
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Release.DLL|x64.Build.0 = Release.DLL|x64
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Release.DLL|x86.Build.0 = Release.DLL|Win32
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Release|x64.ActiveCfg = Release|x64
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Release|x64.Build.0 = Release|x64
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Release|x86.ActiveCfg = Release|Win32
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -2422,6 +2440,7 @@ Global
|
|||
{6237BEDE-BAAA-4A06-9C5E-8089BAA14C8B} = {E9D708A5-9C1F-4B84-A795-C5F191801762}
|
||||
{C8765523-58F8-4C8E-9914-693396F6F0FF} = {E9D708A5-9C1F-4B84-A795-C5F191801762}
|
||||
{946A1700-C7AA-46F0-AEF2-67C98B5722AC} = {6C82BAAE-BDDF-457D-8FA8-7E2490B07035}
|
||||
{2F1B955B-275E-4D8E-8864-06FEC44D7912} = {AF5BEC5C-1F2B-4DA8-B12D-D09FE569237C}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {E926C768-6307-4423-A1EC-57E95B1FAB29}
|
||||
|
|
|
|||
|
|
@ -303,16 +303,16 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\src\raudio.c" />
|
||||
<ClCompile Include="..\..\..\src\core.c" />
|
||||
<ClCompile Include="..\..\..\src\models.c" />
|
||||
<ClCompile Include="..\..\..\src\rcore.c" />
|
||||
<ClCompile Include="..\..\..\src\rmodels.c" />
|
||||
<ClCompile Include="..\..\..\src\rglfw.c" />
|
||||
<ClCompile Include="..\..\..\src\shapes.c" />
|
||||
<ClCompile Include="..\..\..\src\text.c" />
|
||||
<ClCompile Include="..\..\..\src\textures.c" />
|
||||
<ClCompile Include="..\..\..\src\rshapes.c" />
|
||||
<ClCompile Include="..\..\..\src\rtext.c" />
|
||||
<ClCompile Include="..\..\..\src\rtextures.c" />
|
||||
<ClCompile Include="..\..\..\src\utils.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\src\camera.h" />
|
||||
<ClInclude Include="..\..\..\src\rcamera.h" />
|
||||
<ClInclude Include="..\..\..\src\config.h" />
|
||||
<ClInclude Include="..\..\..\src\external\glad.h" />
|
||||
<ClInclude Include="..\..\..\src\external\jar_mod.h" />
|
||||
|
|
@ -324,7 +324,7 @@
|
|||
<ClInclude Include="..\..\..\src\external\stb_rect_pack.h" />
|
||||
<ClInclude Include="..\..\..\src\external\stb_truetype.h" />
|
||||
<ClInclude Include="..\..\..\src\external\stb_vorbis.h" />
|
||||
<ClInclude Include="..\..\..\src\gestures.h" />
|
||||
<ClInclude Include="..\..\..\src\rgestures.h" />
|
||||
<ClInclude Include="..\..\..\src\raylib.h" />
|
||||
<ClInclude Include="..\..\..\src\raymath.h" />
|
||||
<ClInclude Include="..\..\..\src\rlgl.h" />
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ if [ ! -d "$TEMP_DIR" ]; then
|
|||
mkdir -p $TEMP_DIR
|
||||
cd $TEMP_DIR
|
||||
RAYLIB_DEFINES="-D_DEFAULT_SOURCE -DPLATFORM_DESKTOP -DGRAPHICS_API_OPENGL_33"
|
||||
RAYLIB_C_FILES="$RAYLIB_SRC/core.c $RAYLIB_SRC/shapes.c $RAYLIB_SRC/textures.c $RAYLIB_SRC/text.c $RAYLIB_SRC/models.c $RAYLIB_SRC/utils.c $RAYLIB_SRC/raudio.c $RAYLIB_SRC/rglfw.c"
|
||||
RAYLIB_C_FILES="$RAYLIB_SRC/rcore.c $RAYLIB_SRC/rshapes.c $RAYLIB_SRC/rtextures.c $RAYLIB_SRC/rtext.c $RAYLIB_SRC/rmodels.c $RAYLIB_SRC/utils.c $RAYLIB_SRC/raudio.c $RAYLIB_SRC/rglfw.c"
|
||||
RAYLIB_INCLUDE_FLAGS="-I$RAYLIB_SRC -I$RAYLIB_SRC/external/glfw/include"
|
||||
|
||||
if [ -n "$REALLY_QUIET" ]; then
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ if [ ! -d "$TEMP_DIR" ]; then
|
|||
mkdir -p $TEMP_DIR
|
||||
cd $TEMP_DIR
|
||||
RAYLIB_DEFINES="-D_DEFAULT_SOURCE -DPLATFORM_DESKTOP -DGRAPHICS_API_OPENGL_33"
|
||||
RAYLIB_C_FILES="$RAYLIB_SRC/core.c $RAYLIB_SRC/shapes.c $RAYLIB_SRC/textures.c $RAYLIB_SRC/text.c $RAYLIB_SRC/models.c $RAYLIB_SRC/utils.c $RAYLIB_SRC/raudio.c"
|
||||
RAYLIB_C_FILES="$RAYLIB_SRC/rcore.c $RAYLIB_SRC/rshapes.c $RAYLIB_SRC/rtextures.c $RAYLIB_SRC/rtext.c $RAYLIB_SRC/rmodels.c $RAYLIB_SRC/utils.c $RAYLIB_SRC/raudio.c"
|
||||
RAYLIB_INCLUDE_FLAGS="-I$RAYLIB_SRC -I$RAYLIB_SRC/external/glfw/include"
|
||||
|
||||
if [ -n "$REALLY_QUIET" ]; then
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ if [ ! -d "$TEMP_DIR" ]; then
|
|||
mkdir -p $TEMP_DIR
|
||||
cd $TEMP_DIR
|
||||
RAYLIB_DEFINES="-D_DEFAULT_SOURCE -DPLATFORM_RPI -DGRAPHICS_API_OPENGL_ES2"
|
||||
RAYLIB_C_FILES="$RAYLIB_SRC/core.c $RAYLIB_SRC/shapes.c $RAYLIB_SRC/textures.c $RAYLIB_SRC/text.c $RAYLIB_SRC/models.c $RAYLIB_SRC/utils.c $RAYLIB_SRC/raudio.c"
|
||||
RAYLIB_C_FILES="$RAYLIB_SRC/rcore.c $RAYLIB_SRC/rshapes.c $RAYLIB_SRC/rtextures.c $RAYLIB_SRC/rtext.c $RAYLIB_SRC/rmodels.c $RAYLIB_SRC/utils.c $RAYLIB_SRC/raudio.c"
|
||||
RAYLIB_INCLUDE_FLAGS="-I$RAYLIB_SRC -I/opt/vc/include"
|
||||
|
||||
if [ -n "$REALLY_QUIET" ]; then
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ IF NOT EXIST !TEMP_DIR!\ (
|
|||
cd !TEMP_DIR!
|
||||
REM Raylib's src folder
|
||||
set "RAYLIB_DEFINES=/D_DEFAULT_SOURCE /DPLATFORM_DESKTOP /DGRAPHICS_API_OPENGL_33"
|
||||
set RAYLIB_C_FILES="!RAYLIB_SRC!\core.c" "!RAYLIB_SRC!\shapes.c" "!RAYLIB_SRC!\textures.c" "!RAYLIB_SRC!\text.c" "!RAYLIB_SRC!\models.c" "!RAYLIB_SRC!\utils.c" "!RAYLIB_SRC!\raudio.c" "!RAYLIB_SRC!\rglfw.c"
|
||||
set RAYLIB_C_FILES="!RAYLIB_SRC!\rcore.c" "!RAYLIB_SRC!\rshapes.c" "!RAYLIB_SRC!\rtextures.c" "!RAYLIB_SRC!\rtext.c" "!RAYLIB_SRC!\rmodels.c" "!RAYLIB_SRC!\utils.c" "!RAYLIB_SRC!\raudio.c" "!RAYLIB_SRC!\rglfw.c"
|
||||
set RAYLIB_INCLUDE_FLAGS=/I"!RAYLIB_SRC!" /I"!RAYLIB_SRC!\external\glfw\include"
|
||||
|
||||
IF DEFINED REALLY_QUIET (
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ set(raylib_public_headers
|
|||
|
||||
# Sources to be compiled
|
||||
set(raylib_sources
|
||||
core.c
|
||||
models.c
|
||||
shapes.c
|
||||
text.c
|
||||
textures.c
|
||||
rcore.c
|
||||
rmodels.c
|
||||
rshapes.c
|
||||
rtext.c
|
||||
rtextures.c
|
||||
utils.c
|
||||
)
|
||||
|
||||
|
|
|
|||
54
src/Makefile
54
src/Makefile
|
|
@ -80,7 +80,6 @@ RAYLIB_MODULE_RAYGUI_PATH ?= $(RAYLIB_SRC_PATH)/../../raygui/src
|
|||
RAYLIB_MODULE_PHYSAC_PATH ?= $(RAYLIB_SRC_PATH)/extras
|
||||
|
||||
# Use external GLFW library instead of rglfw module
|
||||
# TODO: Review usage of examples on Linux.
|
||||
USE_EXTERNAL_GLFW ?= FALSE
|
||||
|
||||
# Use Wayland display server protocol on Linux desktop
|
||||
|
|
@ -186,16 +185,16 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
|||
ANDROID_SYSROOT ?= $(ANDROID_TOOLCHAIN)/sysroot
|
||||
|
||||
ifeq ($(ANDROID_ARCH),arm)
|
||||
ANDROID_ARCH_NAME = armeabi-v7a
|
||||
ANDROID_COMPILER_ARCH = armv7a
|
||||
endif
|
||||
ifeq ($(ANDROID_ARCH),arm64)
|
||||
ANDROID_ARCH_NAME = arm64-v8a
|
||||
ANDROID_COMPILER_ARCH = aarch64
|
||||
endif
|
||||
ifeq ($(ANDROID_ARCH),x86)
|
||||
ANDROID_ARCH_NAME = i686
|
||||
ANDROID_COMPILER_ARCH = i686
|
||||
endif
|
||||
ifeq ($(ANDROID_ARCH),x86_64)
|
||||
ANDROID_ARCH_NAME = x86_64
|
||||
ANDROID_COMPILER_ARCH = x86_64
|
||||
endif
|
||||
|
||||
endif
|
||||
|
|
@ -255,21 +254,13 @@ endif
|
|||
ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
||||
# Android toolchain (must be provided for desired architecture and compiler)
|
||||
ifeq ($(ANDROID_ARCH),arm)
|
||||
CC = $(ANDROID_TOOLCHAIN)/bin/armv7a-linux-androideabi$(ANDROID_API_VERSION)-clang
|
||||
AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar
|
||||
CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-androideabi$(ANDROID_API_VERSION)-clang
|
||||
endif
|
||||
ifeq ($(ANDROID_ARCH),arm64)
|
||||
CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android$(ANDROID_API_VERSION)-clang
|
||||
AR = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-ar
|
||||
endif
|
||||
ifeq ($(ANDROID_ARCH),x86)
|
||||
CC = $(ANDROID_TOOLCHAIN)/bin/i686-linux-android$(ANDROID_API_VERSION)-clang
|
||||
AR = $(ANDROID_TOOLCHAIN)/bin/i686-linux-android-ar
|
||||
endif
|
||||
ifeq ($(ANDROID_ARCH),x86_64)
|
||||
CC = $(ANDROID_TOOLCHAIN)/bin/x86_64-linux-android$(ANDROID_API_VERSION)-clang
|
||||
AR = $(ANDROID_TOOLCHAIN)/bin/x86_64-linux-android-ar
|
||||
CC = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_COMPILER_ARCH)-linux-android$(ANDROID_API_VERSION)-clang
|
||||
endif
|
||||
# It seems from Android NDK r22 onwards we need to use llvm-ar
|
||||
AR = $(ANDROID_TOOLCHAIN)/bin/llvm-ar
|
||||
endif
|
||||
|
||||
# Define compiler flags:
|
||||
|
|
@ -322,7 +313,7 @@ endif
|
|||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
# -Os # size optimization
|
||||
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
||||
# -s USE_GLFW=3 # Use glfw3 library (context/input management)
|
||||
# -s USE_GLFW=3 # Use glfw3 library (context/input management) -> Only for linker!
|
||||
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL!
|
||||
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
|
||||
# -s USE_PTHREADS=1 # multithreading support
|
||||
|
|
@ -331,7 +322,6 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
|||
# --profiling # include information for code profiling
|
||||
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
||||
# --preload-file resources # specify a resources folder for data compilation
|
||||
CFLAGS += -s USE_GLFW=3
|
||||
ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
|
||||
CFLAGS += -s ASSERTIONS=1 --profiling
|
||||
endif
|
||||
|
|
@ -452,10 +442,10 @@ endif
|
|||
# OBJS = $(patsubst %.c, %.o, $(wildcard *.c))
|
||||
|
||||
# Define object required on compilation
|
||||
OBJS = core.o \
|
||||
shapes.o \
|
||||
textures.o \
|
||||
text.o \
|
||||
OBJS = rcore.o \
|
||||
rshapes.o \
|
||||
rtextures.o \
|
||||
rtext.o \
|
||||
utils.o
|
||||
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
|
|
@ -464,7 +454,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
|||
endif
|
||||
endif
|
||||
ifeq ($(RAYLIB_MODULE_MODELS),TRUE)
|
||||
OBJS += models.o
|
||||
OBJS += rmodels.o
|
||||
endif
|
||||
ifeq ($(RAYLIB_MODULE_AUDIO),TRUE)
|
||||
OBJS += raudio.o
|
||||
|
|
@ -509,7 +499,7 @@ else
|
|||
endif
|
||||
ifeq ($(PLATFORM_OS),OSX)
|
||||
$(CC) -dynamiclib -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib $(OBJS) $(LDFLAGS) -compatibility_version $(RAYLIB_API_VERSION) -current_version $(RAYLIB_VERSION) -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
|
||||
install_name_tool -id "lib$(RAYLIB_LIB_NAME).$(VERSION).dylib" $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib
|
||||
install_name_tool -id "@rpath/lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).dylib" $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib
|
||||
@echo "raylib shared library generated (lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib)!"
|
||||
cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib lib$(RAYLIB_LIB_NAME).$(RAYLIB_API_VERSION).dylib
|
||||
cd $(RAYLIB_RELEASE_PATH) && ln -fs lib$(RAYLIB_LIB_NAME).$(RAYLIB_VERSION).dylib lib$(RAYLIB_LIB_NAME).dylib
|
||||
|
|
@ -558,7 +548,7 @@ endif
|
|||
# Compile all modules with their prerequisites
|
||||
|
||||
# Compile core module
|
||||
core.o : core.c raylib.h rlgl.h utils.h raymath.h camera.h gestures.h
|
||||
rcore.o : rcore.c raylib.h rlgl.h utils.h raymath.h rcamera.h rgestures.h
|
||||
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
|
||||
|
||||
# Compile rglfw module
|
||||
|
|
@ -566,15 +556,15 @@ rglfw.o : rglfw.c
|
|||
$(CC) $(GLFW_OSX) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
|
||||
|
||||
# Compile shapes module
|
||||
shapes.o : shapes.c raylib.h rlgl.h
|
||||
rshapes.o : rshapes.c raylib.h rlgl.h
|
||||
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
|
||||
|
||||
# Compile textures module
|
||||
textures.o : textures.c raylib.h rlgl.h utils.h
|
||||
rtextures.o : rtextures.c raylib.h rlgl.h utils.h
|
||||
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
|
||||
|
||||
# Compile text module
|
||||
text.o : text.c raylib.h utils.h
|
||||
rtext.o : rtext.c raylib.h utils.h
|
||||
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
|
||||
|
||||
# Compile utils module
|
||||
|
|
@ -582,7 +572,7 @@ utils.o : utils.c utils.h
|
|||
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM)
|
||||
|
||||
# Compile models module
|
||||
models.o : models.c raylib.h rlgl.h raymath.h
|
||||
rmodels.o : rmodels.c raylib.h rlgl.h raymath.h
|
||||
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS)
|
||||
|
||||
# Compile audio module
|
||||
|
|
@ -617,7 +607,7 @@ android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c
|
|||
# for our -L and -I specification to simplify management of the raylib source package.
|
||||
# Customize these locations if you like but don't forget to pass them to make
|
||||
# for compilation and enable runtime linking with -rpath, LD_LIBRARY_PATH, or ldconfig.
|
||||
# Hint: add -L$(RAYLIB_INSTALL_PATH) -I$(RAYLIB_H_INSTALL_PATH) to your own makefiles.
|
||||
# HINT: Add -L$(RAYLIB_INSTALL_PATH) -I$(RAYLIB_H_INSTALL_PATH) to your own makefiles.
|
||||
# See below and ../examples/Makefile for more information.
|
||||
# TODO: Add other platforms. Remove sudo requirement, i.e. add USER mode.
|
||||
|
||||
|
|
@ -661,7 +651,7 @@ else
|
|||
endif
|
||||
|
||||
# Remove raylib dev files installed on the system
|
||||
# TODO: see 'install' target.
|
||||
# NOTE: see 'install' target.
|
||||
uninstall :
|
||||
ifeq ($(ROOT),root)
|
||||
# WARNING: You are root, about to delete items from $(RAYLIB_INSTALL_PATH).
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@
|
|||
//------------------------------------------------------------------------------------
|
||||
// Module: core - Configuration Flags
|
||||
//------------------------------------------------------------------------------------
|
||||
// Camera module is included (camera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital
|
||||
// Camera module is included (rcamera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital
|
||||
#define SUPPORT_CAMERA_SYSTEM 1
|
||||
// Gestures module is included (gestures.h) to support gestures detection: tap, hold, swipe, drag
|
||||
// Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag
|
||||
#define SUPPORT_GESTURES_SYSTEM 1
|
||||
// Mouse gestures are directly mapped like touches and processed by gestures system
|
||||
#define SUPPORT_MOUSE_GESTURES 1
|
||||
|
|
@ -73,7 +73,7 @@
|
|||
#define MAX_GAMEPADS 4 // Max number of gamepads supported
|
||||
#define MAX_GAMEPAD_AXIS 8 // Max number of axis supported (per gamepad)
|
||||
#define MAX_GAMEPAD_BUTTONS 32 // Max bumber of buttons supported (per gamepad)
|
||||
#define MAX_TOUCH_POINTS 10 // Maximum number of touch points supported
|
||||
#define MAX_TOUCH_POINTS 8 // Maximum number of touch points supported
|
||||
#define MAX_KEY_PRESSED_QUEUE 16 // Max number of characters in the key input queue
|
||||
|
||||
#define STORAGE_DATA_FILE "storage.data" // Automatic storage filename
|
||||
|
|
@ -182,6 +182,7 @@
|
|||
#define SUPPORT_FILEFORMAT_MTL 1
|
||||
#define SUPPORT_FILEFORMAT_IQM 1
|
||||
#define SUPPORT_FILEFORMAT_GLTF 1
|
||||
#define SUPPORT_FILEFORMAT_VOX 1
|
||||
// Support procedural mesh generation functions, uses external par_shapes.h library
|
||||
// NOTE: Some generated meshes DO NOT include generated texture coordinates
|
||||
#define SUPPORT_MESH_GENERATION 1
|
||||
|
|
|
|||
1272
src/external/glfw/src/mappings.h
vendored
1272
src/external/glfw/src/mappings.h
vendored
File diff suppressed because it is too large
Load Diff
744
src/external/vox_loader.h
vendored
Normal file
744
src/external/vox_loader.h
vendored
Normal file
|
|
@ -0,0 +1,744 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2021 Johann Nadalutti.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
vox_loader - v1.01
|
||||
no warranty implied; use at your own risk
|
||||
|
||||
Do this:
|
||||
#define VOX_LOADER_INCLUDE__H
|
||||
before you include this file in* one* C or C++ file to create the implementation.
|
||||
|
||||
// i.e. it should look like this:
|
||||
#include ...
|
||||
#include ...
|
||||
#include ...
|
||||
#define VOX_LOADER_INCLUDE__H
|
||||
#include "vox_loader.h"
|
||||
|
||||
revision history:
|
||||
1.00 (2021-09-03) first released version
|
||||
1.01 (2021-09-07) Support custom memory allocators
|
||||
Removed Raylib dependencies
|
||||
Changed Vox_LoadFileName to Vox_LoadFromMemory
|
||||
1.02 (2021-09-10) @raysan5: Reviewed some formating
|
||||
|
||||
*/
|
||||
|
||||
#ifndef VOX_LOADER_H
|
||||
#define VOX_LOADER_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Allow custom memory allocators
|
||||
#ifndef VOX_MALLOC
|
||||
#define VOX_MALLOC RL_MALLOC
|
||||
#endif
|
||||
#ifndef VOX_CALLOC
|
||||
#define VOX_CALLOC RL_CALLOC
|
||||
#endif
|
||||
#ifndef VOX_REALLOC
|
||||
#define VOX_REALLOC RL_REALLOC
|
||||
#endif
|
||||
#ifndef VOX_FREE
|
||||
#define VOX_FREE RL_FREE
|
||||
#endif
|
||||
|
||||
#define VOX_SUCCESS (0)
|
||||
#define VOX_ERROR_FILE_NOT_FOUND (-1)
|
||||
#define VOX_ERROR_INVALID_FORMAT (-2)
|
||||
#define VOX_ERROR_FILE_VERSION_TOO_OLD (-3)
|
||||
|
||||
// VoxColor, 4 components, R8G8B8A8 (32bit)
|
||||
typedef struct {
|
||||
unsigned char r, g, b, a;
|
||||
} VoxColor;
|
||||
|
||||
// VoxVector3, 3 components
|
||||
typedef struct {
|
||||
float x, y, z;
|
||||
} VoxVector3;
|
||||
|
||||
typedef struct {
|
||||
int* array;
|
||||
int used, size;
|
||||
} ArrayInt;
|
||||
|
||||
typedef struct {
|
||||
VoxVector3* array;
|
||||
int used, size;
|
||||
} ArrayVector3;
|
||||
|
||||
typedef struct {
|
||||
VoxColor* array;
|
||||
int used, size;
|
||||
} ArrayColor;
|
||||
|
||||
typedef struct {
|
||||
unsigned short* array;
|
||||
int used, size;
|
||||
} ArrayUShort;
|
||||
|
||||
// A chunk that contain voxels
|
||||
typedef struct {
|
||||
unsigned char* m_array; //If Sparse != null
|
||||
int arraySize; //Size for m_array in bytes (DEBUG ONLY)
|
||||
} CubeChunk3D;
|
||||
|
||||
// Array for voxels
|
||||
// Array is divised into chunks of CHUNKSIZE*CHUNKSIZE*CHUNKSIZE voxels size
|
||||
typedef struct {
|
||||
// Array size in voxels
|
||||
int sizeX;
|
||||
int sizeY;
|
||||
int sizeZ;
|
||||
|
||||
// Chunks size into array (array is divised into chunks)
|
||||
int chunksSizeX;
|
||||
int chunksSizeY;
|
||||
int chunksSizeZ;
|
||||
|
||||
// Chunks array
|
||||
CubeChunk3D* m_arrayChunks;
|
||||
int arrayChunksSize; // Size for m_arrayChunks in bytes (DEBUG ONLY)
|
||||
|
||||
int ChunkFlattenOffset;
|
||||
int chunksAllocated;
|
||||
int chunksTotal;
|
||||
|
||||
// Arrays for mesh build
|
||||
ArrayVector3 vertices;
|
||||
ArrayUShort indices;
|
||||
ArrayColor colors;
|
||||
|
||||
//Palette for voxels
|
||||
VoxColor palette[256];
|
||||
|
||||
} VoxArray3D;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" { // Prevents name mangling of functions
|
||||
#endif
|
||||
|
||||
// Functions
|
||||
int Vox_LoadFromMemory(const unsigned char* pvoxData, unsigned int voxDataSize, VoxArray3D* pvoxarray);
|
||||
void Vox_FreeArrays(VoxArray3D* voxarray);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // VOX_LOADER_H
|
||||
//// end header file /////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Implementation
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef VOX_LOADER_IMPLEMENTATION
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ArrayInt helper
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void initArrayInt(ArrayInt* a, int initialSize)
|
||||
{
|
||||
a->array = VOX_MALLOC(initialSize * sizeof(int));
|
||||
a->used = 0;
|
||||
a->size = initialSize;
|
||||
}
|
||||
|
||||
static void insertArrayInt(ArrayInt* a, int element)
|
||||
{
|
||||
if (a->used == a->size)
|
||||
{
|
||||
a->size *= 2;
|
||||
a->array = VOX_REALLOC(a->array, a->size * sizeof(int));
|
||||
}
|
||||
|
||||
a->array[a->used++] = element;
|
||||
}
|
||||
|
||||
static void freeArrayInt(ArrayInt* a)
|
||||
{
|
||||
VOX_FREE(a->array);
|
||||
a->array = NULL;
|
||||
a->used = a->size = 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ArrayUShort helper
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void initArrayUShort(ArrayUShort* a, int initialSize)
|
||||
{
|
||||
a->array = VOX_MALLOC(initialSize * sizeof(unsigned short));
|
||||
a->used = 0;
|
||||
a->size = initialSize;
|
||||
}
|
||||
|
||||
static void insertArrayUShort(ArrayUShort* a, unsigned short element)
|
||||
{
|
||||
if (a->used == a->size)
|
||||
{
|
||||
a->size *= 2;
|
||||
a->array = VOX_REALLOC(a->array, a->size * sizeof(unsigned short));
|
||||
}
|
||||
a->array[a->used++] = element;
|
||||
}
|
||||
|
||||
static void freeArrayUShort(ArrayUShort* a)
|
||||
{
|
||||
VOX_FREE(a->array);
|
||||
a->array = NULL;
|
||||
a->used = a->size = 0;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ArrayVector3 helper
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void initArrayVector3(ArrayVector3* a, int initialSize)
|
||||
{
|
||||
a->array = VOX_MALLOC(initialSize * sizeof(VoxVector3));
|
||||
a->used = 0;
|
||||
a->size = initialSize;
|
||||
}
|
||||
|
||||
static void insertArrayVector3(ArrayVector3* a, VoxVector3 element)
|
||||
{
|
||||
if (a->used == a->size)
|
||||
{
|
||||
a->size *= 2;
|
||||
a->array = VOX_REALLOC(a->array, a->size * sizeof(VoxVector3));
|
||||
}
|
||||
a->array[a->used++] = element;
|
||||
}
|
||||
|
||||
static void freeArrayVector3(ArrayVector3* a)
|
||||
{
|
||||
VOX_FREE(a->array);
|
||||
a->array = NULL;
|
||||
a->used = a->size = 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ArrayColor helper
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void initArrayColor(ArrayColor* a, int initialSize)
|
||||
{
|
||||
a->array = VOX_MALLOC(initialSize * sizeof(VoxColor));
|
||||
a->used = 0;
|
||||
a->size = initialSize;
|
||||
}
|
||||
|
||||
static void insertArrayColor(ArrayColor* a, VoxColor element)
|
||||
{
|
||||
if (a->used == a->size)
|
||||
{
|
||||
a->size *= 2;
|
||||
a->array = VOX_REALLOC(a->array, a->size * sizeof(VoxColor));
|
||||
}
|
||||
a->array[a->used++] = element;
|
||||
}
|
||||
|
||||
static void freeArrayColor(ArrayColor* a)
|
||||
{
|
||||
VOX_FREE(a->array);
|
||||
a->array = NULL;
|
||||
a->used = a->size = 0;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Vox Loader
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define CHUNKSIZE 16 // chunk size (CHUNKSIZE*CHUNKSIZE*CHUNKSIZE) in voxels
|
||||
#define CHUNKSIZE_OPSHIFT 4 // 1<<4=16 -> Warning depend of CHUNKSIZE
|
||||
#define CHUNK_FLATTENOFFSET_OPSHIFT 8 // Warning depend of CHUNKSIZE
|
||||
|
||||
//
|
||||
// used right handed system and CCW face
|
||||
//
|
||||
// indexes for voxelcoords, per face orientation
|
||||
//
|
||||
|
||||
//# Y
|
||||
//# |
|
||||
//# o----X
|
||||
//# /
|
||||
//# Z 2------------3
|
||||
//# /| /|
|
||||
//# 6------------7 |
|
||||
//# | | | |
|
||||
//# |0 ----------|- 1
|
||||
//# |/ |/
|
||||
//# 4------------5
|
||||
|
||||
//
|
||||
// CCW
|
||||
const int fv[6][4] = {
|
||||
{0, 2, 6, 4 }, //-X
|
||||
{5, 7, 3, 1 }, //+X
|
||||
{0, 4, 5, 1 }, //-y
|
||||
{6, 2, 3, 7 }, //+y
|
||||
{1, 3, 2, 0 }, //-Z
|
||||
{4, 6, 7, 5 } //+Z
|
||||
};
|
||||
|
||||
const VoxVector3 SolidVertex[] = {
|
||||
{0, 0, 0}, //0
|
||||
{1, 0, 0}, //1
|
||||
{0, 1, 0}, //2
|
||||
{1, 1, 0}, //3
|
||||
{0, 0, 1}, //4
|
||||
{1, 0, 1}, //5
|
||||
{0, 1, 1}, //6
|
||||
{1, 1, 1} //7
|
||||
};
|
||||
|
||||
// Allocated VoxArray3D size
|
||||
static void Vox_AllocArray(VoxArray3D* pvoxarray, int _sx, int _sy, int _sz)
|
||||
{
|
||||
int sx = _sx + ((CHUNKSIZE - (_sx % CHUNKSIZE)) % CHUNKSIZE);
|
||||
int sy = _sy + ((CHUNKSIZE - (_sy % CHUNKSIZE)) % CHUNKSIZE);
|
||||
int sz = _sz + ((CHUNKSIZE - (_sz % CHUNKSIZE)) % CHUNKSIZE);
|
||||
|
||||
int chx = sx >> CHUNKSIZE_OPSHIFT; //Chunks Count in X
|
||||
int chy = sy >> CHUNKSIZE_OPSHIFT; //Chunks Count in Y
|
||||
int chz = sz >> CHUNKSIZE_OPSHIFT; //Chunks Count in Z
|
||||
|
||||
//VoxArray3D* parray = (VoxArray3D*)VOX_MALLOC(sizeof(VoxArray3D));
|
||||
pvoxarray->sizeX = sx;
|
||||
pvoxarray->sizeY = sy;
|
||||
pvoxarray->sizeZ = sz;
|
||||
|
||||
pvoxarray->chunksSizeX = chx;
|
||||
pvoxarray->chunksSizeY = chy;
|
||||
pvoxarray->chunksSizeZ = chz;
|
||||
|
||||
pvoxarray->ChunkFlattenOffset = (chy * chz); //m_arrayChunks[(x * (sy*sz)) + (z * sy) + y]
|
||||
|
||||
// Alloc chunks array
|
||||
int size = sizeof(CubeChunk3D) * chx * chy * chz;
|
||||
pvoxarray->m_arrayChunks = VOX_MALLOC(size);
|
||||
pvoxarray->arrayChunksSize = size;
|
||||
|
||||
// Init chunks array
|
||||
size = chx * chy * chz;
|
||||
pvoxarray->chunksTotal = size;
|
||||
pvoxarray->chunksAllocated = 0;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
pvoxarray->m_arrayChunks[i].m_array = 0;
|
||||
pvoxarray->m_arrayChunks[i].arraySize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Set voxel ID from its position into VoxArray3D
|
||||
static void Vox_SetVoxel(VoxArray3D* pvoxarray, int x, int y, int z, unsigned char id)
|
||||
{
|
||||
// Get chunk from array pos
|
||||
int chX = x >> CHUNKSIZE_OPSHIFT; //x / CHUNKSIZE;
|
||||
int chY = y >> CHUNKSIZE_OPSHIFT; //y / CHUNKSIZE;
|
||||
int chZ = z >> CHUNKSIZE_OPSHIFT; //z / CHUNKSIZE;
|
||||
int offset = (chX * pvoxarray->ChunkFlattenOffset) + (chZ * pvoxarray->chunksSizeY) + chY;
|
||||
|
||||
//if (offset > voxarray->arrayChunksSize)
|
||||
//{
|
||||
// TraceLog(LOG_ERROR, "Out of array");
|
||||
//}
|
||||
|
||||
CubeChunk3D* chunk = &pvoxarray->m_arrayChunks[offset];
|
||||
|
||||
// Set Chunk
|
||||
chX = x - (chX << CHUNKSIZE_OPSHIFT); //x - (bx * CHUNKSIZE);
|
||||
chY = y - (chY << CHUNKSIZE_OPSHIFT); //y - (by * CHUNKSIZE);
|
||||
chZ = z - (chZ << CHUNKSIZE_OPSHIFT); //z - (bz * CHUNKSIZE);
|
||||
|
||||
if (chunk->m_array == 0)
|
||||
{
|
||||
int size = CHUNKSIZE * CHUNKSIZE * CHUNKSIZE;
|
||||
chunk->m_array = VOX_MALLOC(size);
|
||||
chunk->arraySize = size;
|
||||
memset(chunk->m_array, 0, size);
|
||||
|
||||
pvoxarray->chunksAllocated++;
|
||||
}
|
||||
|
||||
offset = (chX << CHUNK_FLATTENOFFSET_OPSHIFT) + (chZ << CHUNKSIZE_OPSHIFT) + chY;
|
||||
|
||||
//if (offset > chunk->arraySize)
|
||||
//{
|
||||
// TraceLog(LOG_ERROR, "Out of array");
|
||||
//}
|
||||
|
||||
chunk->m_array[offset] = id;
|
||||
}
|
||||
|
||||
// Get voxel ID from its position into VoxArray3D
|
||||
static unsigned char Vox_GetVoxel(VoxArray3D* pvoxarray, int x, int y, int z)
|
||||
{
|
||||
if (x < 0 || y < 0 || z < 0) return 0;
|
||||
|
||||
if (x >= pvoxarray->sizeX || y >= pvoxarray->sizeY || z >= pvoxarray->sizeZ) return 0;
|
||||
|
||||
// Get chunk from array pos
|
||||
int chX = x >> CHUNKSIZE_OPSHIFT; //x / CHUNKSIZE;
|
||||
int chY = y >> CHUNKSIZE_OPSHIFT; //y / CHUNKSIZE;
|
||||
int chZ = z >> CHUNKSIZE_OPSHIFT; //z / CHUNKSIZE;
|
||||
int offset = (chX * pvoxarray->ChunkFlattenOffset) + (chZ * pvoxarray->chunksSizeY) + chY;
|
||||
|
||||
//if (offset > voxarray->arrayChunksSize)
|
||||
//{
|
||||
// TraceLog(LOG_ERROR, "Out of array");
|
||||
//}
|
||||
|
||||
CubeChunk3D* chunk = &pvoxarray->m_arrayChunks[offset];
|
||||
|
||||
// Set Chunk
|
||||
chX = x - (chX << CHUNKSIZE_OPSHIFT); //x - (bx * CHUNKSIZE);
|
||||
chY = y - (chY << CHUNKSIZE_OPSHIFT); //y - (by * CHUNKSIZE);
|
||||
chZ = z - (chZ << CHUNKSIZE_OPSHIFT); //z - (bz * CHUNKSIZE);
|
||||
|
||||
if (chunk->m_array == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
offset = (chX << CHUNK_FLATTENOFFSET_OPSHIFT) + (chZ << CHUNKSIZE_OPSHIFT) + chY;
|
||||
|
||||
//if (offset > chunk->arraySize)
|
||||
//{
|
||||
// TraceLog(LOG_ERROR, "Out of array");
|
||||
//}
|
||||
return chunk->m_array[offset];
|
||||
|
||||
}
|
||||
|
||||
// Calc visibles faces from a voxel position
|
||||
static unsigned char Vox_CalcFacesVisible(VoxArray3D* pvoxArray, int cx, int cy, int cz)
|
||||
{
|
||||
unsigned char idXm1 = Vox_GetVoxel(pvoxArray, cx - 1, cy, cz);
|
||||
unsigned char idXp1 = Vox_GetVoxel(pvoxArray, cx + 1, cy, cz);
|
||||
|
||||
unsigned char idYm1 = Vox_GetVoxel(pvoxArray, cx, cy - 1, cz);
|
||||
unsigned char idYp1 = Vox_GetVoxel(pvoxArray, cx, cy + 1, cz);
|
||||
|
||||
unsigned char idZm1 = Vox_GetVoxel(pvoxArray, cx, cy, cz - 1);
|
||||
unsigned char idZp1 = Vox_GetVoxel(pvoxArray, cx, cy, cz + 1);
|
||||
|
||||
unsigned char byVFMask = 0;
|
||||
|
||||
//#-x
|
||||
if (idXm1 == 0) byVFMask |= (1 << 0);
|
||||
|
||||
//#+x
|
||||
if (idXp1 == 0) byVFMask |= (1 << 1);
|
||||
|
||||
//#-y
|
||||
if (idYm1 == 0) byVFMask |= (1 << 2);
|
||||
|
||||
//#+y
|
||||
if (idYp1 == 0) byVFMask |= (1 << 3);
|
||||
|
||||
//#-z
|
||||
if (idZm1 == 0) byVFMask |= (1 << 4);
|
||||
|
||||
//#+z
|
||||
if (idZp1 == 0) byVFMask |= (1 << 5);
|
||||
|
||||
return byVFMask;
|
||||
}
|
||||
|
||||
// Get a vertex position from a voxel's corner
|
||||
static VoxVector3 Vox_GetVertexPosition(int _wcx, int _wcy, int _wcz, int _nNumVertex)
|
||||
{
|
||||
float scale = 0.25;
|
||||
|
||||
VoxVector3 vtx = SolidVertex[_nNumVertex];
|
||||
vtx.x = (vtx.x + _wcx) * scale;
|
||||
vtx.y = (vtx.y + _wcy) * scale;
|
||||
vtx.z = (vtx.z + _wcz) * scale;
|
||||
|
||||
return vtx;
|
||||
}
|
||||
|
||||
// Build a voxel vertices/colors/indices
|
||||
static void Vox_Build_Voxel(VoxArray3D* pvoxArray, int x, int y, int z, int matID)
|
||||
{
|
||||
unsigned char byVFMask = Vox_CalcFacesVisible(pvoxArray, x, y, z);
|
||||
|
||||
if (byVFMask == 0) return;
|
||||
|
||||
int i, j;
|
||||
VoxVector3 vertComputed[8];
|
||||
int bVertexComputed[8];
|
||||
memset(vertComputed, 0, sizeof(vertComputed));
|
||||
memset(bVertexComputed, 0, sizeof(bVertexComputed));
|
||||
|
||||
//For each Cube's faces
|
||||
for (i = 0; i < 6; i++) // 6 faces
|
||||
{
|
||||
if ((byVFMask & (1 << i)) != 0) //If face is visible
|
||||
{
|
||||
for (j = 0; j < 4; j++) // 4 corners
|
||||
{
|
||||
int nNumVertex = fv[i][j]; //Face,Corner
|
||||
if (bVertexComputed[nNumVertex] == 0) //if never calc
|
||||
{
|
||||
bVertexComputed[nNumVertex] = 1;
|
||||
vertComputed[nNumVertex] = Vox_GetVertexPosition(x, y, z, nNumVertex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Add face
|
||||
for (i = 0; i < 6; i++)// 6 faces
|
||||
{
|
||||
if ((byVFMask & (1 << i)) == 0)
|
||||
continue; //Face invisible
|
||||
|
||||
int v0 = fv[i][0]; //Face, Corner
|
||||
int v1 = fv[i][1]; //Face, Corner
|
||||
int v2 = fv[i][2]; //Face, Corner
|
||||
int v3 = fv[i][3]; //Face, Corner
|
||||
|
||||
//Arrays
|
||||
int idx = pvoxArray->vertices.used;
|
||||
insertArrayVector3(&pvoxArray->vertices, vertComputed[v0]);
|
||||
insertArrayVector3(&pvoxArray->vertices, vertComputed[v1]);
|
||||
insertArrayVector3(&pvoxArray->vertices, vertComputed[v2]);
|
||||
insertArrayVector3(&pvoxArray->vertices, vertComputed[v3]);
|
||||
|
||||
VoxColor col = pvoxArray->palette[matID];
|
||||
|
||||
insertArrayColor(&pvoxArray->colors, col);
|
||||
insertArrayColor(&pvoxArray->colors, col);
|
||||
insertArrayColor(&pvoxArray->colors, col);
|
||||
insertArrayColor(&pvoxArray->colors, col);
|
||||
|
||||
|
||||
//v0 - v1 - v2, v0 - v2 - v3
|
||||
insertArrayUShort(&pvoxArray->indices, idx + 0);
|
||||
insertArrayUShort(&pvoxArray->indices, idx + 2);
|
||||
insertArrayUShort(&pvoxArray->indices, idx + 1);
|
||||
|
||||
insertArrayUShort(&pvoxArray->indices, idx + 0);
|
||||
insertArrayUShort(&pvoxArray->indices, idx + 3);
|
||||
insertArrayUShort(&pvoxArray->indices, idx + 2);
|
||||
}
|
||||
}
|
||||
|
||||
// MagicaVoxel *.vox file format Loader
|
||||
int Vox_LoadFromMemory(const unsigned char* pvoxData, unsigned int voxDataSize, VoxArray3D* pvoxarray)
|
||||
{
|
||||
//////////////////////////////////////////////////
|
||||
//Read VOX file
|
||||
//4 bytes: magic number ('V' 'O' 'X' 'space' )
|
||||
//4 bytes: version number (current version is 150 )
|
||||
|
||||
unsigned long signature;
|
||||
|
||||
unsigned char* fileData = pvoxData;
|
||||
|
||||
unsigned char* fileDataPtr = fileData;
|
||||
unsigned char* endfileDataPtr = fileData + voxDataSize;
|
||||
|
||||
signature = *((unsigned long *)fileDataPtr);
|
||||
fileDataPtr += sizeof(unsigned long);
|
||||
|
||||
if (signature != 0x20584F56) //56 4F 58 20
|
||||
{
|
||||
return VOX_ERROR_INVALID_FORMAT; //"Not an MagicaVoxel File format"
|
||||
}
|
||||
|
||||
unsigned long version;
|
||||
|
||||
version = *((unsigned long*)fileDataPtr);
|
||||
fileDataPtr += sizeof(unsigned long);
|
||||
|
||||
if (version < 150)
|
||||
{
|
||||
return VOX_ERROR_FILE_VERSION_TOO_OLD; //"MagicaVoxel version too old"
|
||||
}
|
||||
|
||||
|
||||
// header
|
||||
//4 bytes: chunk id
|
||||
//4 bytes: size of chunk contents (n)
|
||||
//4 bytes: total size of children chunks(m)
|
||||
|
||||
//// chunk content
|
||||
//n bytes: chunk contents
|
||||
|
||||
//// children chunks : m bytes
|
||||
//{ child chunk 0 }
|
||||
//{ child chunk 1 }
|
||||
unsigned long sizeX, sizeY, sizeZ;
|
||||
sizeX = sizeY = sizeZ = 0;
|
||||
unsigned long numVoxels = 0;
|
||||
int offsetX, offsetY, offsetZ;
|
||||
offsetX = offsetY = offsetZ = 0;
|
||||
|
||||
while (fileDataPtr < endfileDataPtr)
|
||||
{
|
||||
char szChunkName[5];
|
||||
memcpy(szChunkName, fileDataPtr, 4);
|
||||
szChunkName[4] = 0;
|
||||
fileDataPtr += 4;
|
||||
|
||||
unsigned long chunkSize = *((unsigned long*)fileDataPtr);
|
||||
fileDataPtr += sizeof(unsigned long);
|
||||
|
||||
unsigned long chunkTotalChildSize = *((unsigned long*)fileDataPtr);
|
||||
fileDataPtr += sizeof(unsigned long);
|
||||
|
||||
if (strcmp(szChunkName, "SIZE") == 0)
|
||||
{
|
||||
//(4 bytes x 3 : x, y, z )
|
||||
sizeX = *((unsigned long*)fileDataPtr);
|
||||
fileDataPtr += sizeof(unsigned long);
|
||||
|
||||
sizeY = *((unsigned long*)fileDataPtr);
|
||||
fileDataPtr += sizeof(unsigned long);
|
||||
|
||||
sizeZ = *((unsigned long*)fileDataPtr);
|
||||
fileDataPtr += sizeof(unsigned long);
|
||||
|
||||
//Alloc vox array
|
||||
Vox_AllocArray(pvoxarray, sizeX, sizeZ, sizeY); //Reverse Y<>Z for left to right handed system
|
||||
}
|
||||
else if (strcmp(szChunkName, "XYZI") == 0)
|
||||
{
|
||||
unsigned char vx, vy, vz, vi;
|
||||
|
||||
//(numVoxels : 4 bytes )
|
||||
//(each voxel: 1 byte x 4 : x, y, z, colorIndex ) x numVoxels
|
||||
numVoxels = *((unsigned long*)fileDataPtr);
|
||||
fileDataPtr += sizeof(unsigned long);
|
||||
|
||||
while (numVoxels > 0)
|
||||
{
|
||||
vx = *((unsigned char*)fileDataPtr++);
|
||||
vy = *((unsigned char*)fileDataPtr++);
|
||||
vz = *((unsigned char*)fileDataPtr++);
|
||||
vi = *((unsigned char*)fileDataPtr++);
|
||||
|
||||
Vox_SetVoxel(pvoxarray, vx, vz, pvoxarray->sizeZ-vy-1, vi); //Reverse Y<>Z for left to right handed system
|
||||
|
||||
numVoxels--;
|
||||
}
|
||||
}
|
||||
else if (strcmp(szChunkName, "RGBA") == 0)
|
||||
{
|
||||
VoxColor col;
|
||||
|
||||
//(each pixel: 1 byte x 4 : r, g, b, a ) x 256
|
||||
for (int i = 0; i < 256 - 1; i++)
|
||||
{
|
||||
col.r = *((unsigned char*)fileDataPtr++);
|
||||
col.g = *((unsigned char*)fileDataPtr++);
|
||||
col.b = *((unsigned char*)fileDataPtr++);
|
||||
col.a = *((unsigned char*)fileDataPtr++);
|
||||
|
||||
pvoxarray->palette[i + 1] = col;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
fileDataPtr += chunkSize;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// Building Mesh
|
||||
// TODO compute globals indices array
|
||||
|
||||
// Init Arrays
|
||||
initArrayVector3(&pvoxarray->vertices, 3 * 1024);
|
||||
initArrayUShort(&pvoxarray->indices, 3 * 1024);
|
||||
initArrayColor(&pvoxarray->colors, 3 * 1024);
|
||||
|
||||
// Create vertices and indices buffers
|
||||
int x, y, z;
|
||||
|
||||
for (x = 0; x <= pvoxarray->sizeX; x++)
|
||||
{
|
||||
for (z = 0; z <= pvoxarray->sizeZ; z++)
|
||||
{
|
||||
for (y = 0; y <= pvoxarray->sizeY; y++)
|
||||
{
|
||||
unsigned char matID = Vox_GetVoxel(pvoxarray, x, y, z);
|
||||
if (matID != 0)
|
||||
Vox_Build_Voxel(pvoxarray, x, y, z, matID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return VOX_SUCCESS;
|
||||
}
|
||||
|
||||
void Vox_FreeArrays(VoxArray3D* voxarray)
|
||||
{
|
||||
// Free chunks
|
||||
if (voxarray->m_arrayChunks != 0)
|
||||
{
|
||||
for (int i = 0; i < voxarray->chunksTotal; i++)
|
||||
{
|
||||
CubeChunk3D* chunk = &voxarray->m_arrayChunks[i];
|
||||
if (chunk->m_array != 0)
|
||||
{
|
||||
chunk->arraySize = 0;
|
||||
VOX_FREE(chunk->m_array);
|
||||
}
|
||||
}
|
||||
|
||||
VOX_FREE(voxarray->m_arrayChunks);
|
||||
voxarray->m_arrayChunks = 0;
|
||||
voxarray->arrayChunksSize = 0;
|
||||
|
||||
voxarray->chunksSizeX = voxarray->chunksSizeY = voxarray->chunksSizeZ = 0;
|
||||
voxarray->chunksTotal = 0;
|
||||
voxarray->chunksAllocated = 0;
|
||||
voxarray->ChunkFlattenOffset = 0;
|
||||
voxarray->sizeX = voxarray->sizeY = voxarray->sizeZ = 0;
|
||||
}
|
||||
|
||||
// Free arrays
|
||||
freeArrayVector3(&voxarray->vertices);
|
||||
freeArrayUShort(&voxarray->indices);
|
||||
freeArrayColor(&voxarray->colors);
|
||||
}
|
||||
|
||||
#endif //VOX_LOADER_IMPLEMENTATION
|
||||
|
|
@ -220,14 +220,20 @@
|
|||
int format; // Data format (PixelFormat type)
|
||||
} Texture2D;
|
||||
|
||||
// Font character info
|
||||
typedef struct GlyphInfo GlyphInfo;
|
||||
// GlyphInfo, font characters glyphs info
|
||||
typedef struct GlyphInfo {
|
||||
int value; // Character value (Unicode)
|
||||
int offsetX; // Character offset X when drawing
|
||||
int offsetY; // Character offset Y when drawing
|
||||
int advanceX; // Character advance position X
|
||||
Image image; // Character image data
|
||||
} GlyphInfo;
|
||||
|
||||
// TODO: Font type is very coupled to raylib, mostly required by GuiLoadStyle()
|
||||
// It should be redesigned to be provided by user
|
||||
typedef struct Font {
|
||||
int baseSize; // Base size (default chars height)
|
||||
int charsCount; // Number of characters
|
||||
int glyphCount; // Number of characters
|
||||
Texture2D texture; // Characters texture atlas
|
||||
Rectangle *recs; // Characters rectangles in texture
|
||||
GlyphInfo *chars; // Characters info data
|
||||
|
|
@ -406,7 +412,7 @@ typedef enum {
|
|||
extern "C" { // Prevents name mangling of functions
|
||||
#endif
|
||||
|
||||
// State modification functions
|
||||
// Global gui state control functions
|
||||
RAYGUIDEF void GuiEnable(void); // Enable gui controls (global state)
|
||||
RAYGUIDEF void GuiDisable(void); // Disable gui controls (global state)
|
||||
RAYGUIDEF void GuiLock(void); // Lock gui controls (global state)
|
||||
|
|
@ -1076,7 +1082,7 @@ static unsigned int guiIcons[RICON_MAX_ICONS*RICON_DATA_ELEMENTS] = {
|
|||
|
||||
// TODO: Avoid animations and time-based states
|
||||
// Functions using it: GuiTextBox(), GuiValueBox(), GuiTextBoxMulti()
|
||||
#define TEXTEDIT_CURSOR_BLINK_FRAMES 20 // Text edit controls cursor blink timming
|
||||
//#define TEXTEDIT_CURSOR_BLINK_FRAMES 20 // Text edit controls cursor blink timming
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
|
|
@ -1147,14 +1153,14 @@ static Font GetFontDefault(void); // -- GuiLoadStyleDe
|
|||
static Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing); // -- GetTextWidth(), GuiTextBoxMulti()
|
||||
static void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // -- GuiDrawText()
|
||||
|
||||
static Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCount); // -- GuiLoadStyle()
|
||||
static Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int glyphCount); // -- GuiLoadStyle()
|
||||
static char *LoadFileText(const char *fileName); // -- GuiLoadStyle()
|
||||
static const char *GetDirectoryPath(const char *filePath); // -- GuiLoadStyle()
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
// raylib functions already implemented in raygui
|
||||
//-------------------------------------------------------------------------------
|
||||
static Color GetColor(unsigned int hexValue); // Returns a Color struct from hexadecimal value
|
||||
static Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value
|
||||
static int ColorToInt(Color color); // Returns hexadecimal value for a Color
|
||||
static Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||
static bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if point is inside rectangle
|
||||
|
|
@ -1594,7 +1600,7 @@ bool GuiImageButtonEx(Rectangle bounds, const char *text, Texture2D texture, Rec
|
|||
//--------------------------------------------------------------------
|
||||
GuiDrawRectangle(bounds, GuiGetStyle(BUTTON, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(BUTTON, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(BUTTON, BASE + (state*3))), guiAlpha));
|
||||
|
||||
if (text != NULL) GuiDrawText(text, GetTextBounds(BUTTON, bounds), GuiGetStyle(BUTTON, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(BUTTON, TEXT + (state*3))), guiAlpha));
|
||||
GuiDrawText(text, GetTextBounds(BUTTON, bounds), GuiGetStyle(BUTTON, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(BUTTON, TEXT + (state*3))), guiAlpha));
|
||||
if (texture.id > 0) DrawTextureRec(texture, texSource, RAYGUI_CLITERAL(Vector2){ bounds.x + bounds.width/2 - texSource.width/2, bounds.y + bounds.height/2 - texSource.height/2 }, Fade(GetColor(GuiGetStyle(BUTTON, TEXT + (state*3))), guiAlpha));
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
|
@ -1654,12 +1660,12 @@ int GuiToggleGroup(Rectangle bounds, const char *text, int active)
|
|||
|
||||
// Get substrings items from text (items pointers)
|
||||
int rows[TOGGLEGROUP_MAX_ELEMENTS] = { 0 };
|
||||
int itemsCount = 0;
|
||||
const char **items = GuiTextSplit(text, &itemsCount, rows);
|
||||
int itemCount = 0;
|
||||
const char **items = GuiTextSplit(text, &itemCount, rows);
|
||||
|
||||
int prevRow = rows[0];
|
||||
|
||||
for (int i = 0; i < itemsCount; i++)
|
||||
for (int i = 0; i < itemCount; i++)
|
||||
{
|
||||
if (prevRow != rows[i])
|
||||
{
|
||||
|
|
@ -1730,7 +1736,7 @@ bool GuiCheckBox(Rectangle bounds, const char *text, bool checked)
|
|||
GuiDrawRectangle(check, 0, BLANK, Fade(GetColor(GuiGetStyle(CHECKBOX, TEXT + state*3)), guiAlpha));
|
||||
}
|
||||
|
||||
if (text != NULL) GuiDrawText(text, textBounds, (GuiGetStyle(CHECKBOX, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha));
|
||||
GuiDrawText(text, textBounds, (GuiGetStyle(CHECKBOX, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha));
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
return checked;
|
||||
|
|
@ -1747,15 +1753,15 @@ int GuiComboBox(Rectangle bounds, const char *text, int active)
|
|||
(float)bounds.y, (float)GuiGetStyle(COMBOBOX, COMBO_BUTTON_WIDTH), (float)bounds.height };
|
||||
|
||||
// Get substrings items from text (items pointers, lengths and count)
|
||||
int itemsCount = 0;
|
||||
const char **items = GuiTextSplit(text, &itemsCount, NULL);
|
||||
int itemCount = 0;
|
||||
const char **items = GuiTextSplit(text, &itemCount, NULL);
|
||||
|
||||
if (active < 0) active = 0;
|
||||
else if (active > itemsCount - 1) active = itemsCount - 1;
|
||||
else if (active > itemCount - 1) active = itemCount - 1;
|
||||
|
||||
// Update control
|
||||
//--------------------------------------------------------------------
|
||||
if ((state != GUI_STATE_DISABLED) && !guiLocked && (itemsCount > 1))
|
||||
if ((state != GUI_STATE_DISABLED) && !guiLocked && (itemCount > 1))
|
||||
{
|
||||
Vector2 mousePoint = GetMousePosition();
|
||||
|
||||
|
|
@ -1765,7 +1771,7 @@ int GuiComboBox(Rectangle bounds, const char *text, int active)
|
|||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||
{
|
||||
active += 1;
|
||||
if (active >= itemsCount) active = 0;
|
||||
if (active >= itemCount) active = 0;
|
||||
}
|
||||
|
||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = GUI_STATE_PRESSED;
|
||||
|
|
@ -1787,7 +1793,7 @@ int GuiComboBox(Rectangle bounds, const char *text, int active)
|
|||
GuiSetStyle(BUTTON, BORDER_WIDTH, 1);
|
||||
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER);
|
||||
|
||||
GuiButton(selector, TextFormat("%i/%i", active + 1, itemsCount));
|
||||
GuiButton(selector, TextFormat("%i/%i", active + 1, itemCount));
|
||||
|
||||
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, tempTextAlign);
|
||||
GuiSetStyle(BUTTON, BORDER_WIDTH, tempBorderWidth);
|
||||
|
|
@ -1805,11 +1811,11 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo
|
|||
int itemFocused = -1;
|
||||
|
||||
// Get substrings items from text (items pointers, lengths and count)
|
||||
int itemsCount = 0;
|
||||
const char **items = GuiTextSplit(text, &itemsCount, NULL);
|
||||
int itemCount = 0;
|
||||
const char **items = GuiTextSplit(text, &itemCount, NULL);
|
||||
|
||||
Rectangle boundsOpen = bounds;
|
||||
boundsOpen.height = (itemsCount + 1)*(bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_PADDING));
|
||||
boundsOpen.height = (itemCount + 1)*(bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_PADDING));
|
||||
|
||||
Rectangle itemBounds = bounds;
|
||||
|
||||
|
|
@ -1817,7 +1823,7 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo
|
|||
|
||||
// Update control
|
||||
//--------------------------------------------------------------------
|
||||
if ((state != GUI_STATE_DISABLED) && !guiLocked && (itemsCount > 1))
|
||||
if ((state != GUI_STATE_DISABLED) && !guiLocked && (itemCount > 1))
|
||||
{
|
||||
Vector2 mousePoint = GetMousePosition();
|
||||
|
||||
|
|
@ -1835,7 +1841,7 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo
|
|||
if (CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true;
|
||||
|
||||
// Check focused and selected item
|
||||
for (int i = 0; i < itemsCount; i++)
|
||||
for (int i = 0; i < itemCount; i++)
|
||||
{
|
||||
// Update item rectangle y position for next item
|
||||
itemBounds.y += (bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_PADDING));
|
||||
|
|
@ -1879,7 +1885,7 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo
|
|||
if (editMode)
|
||||
{
|
||||
// Draw visible items
|
||||
for (int i = 0; i < itemsCount; i++)
|
||||
for (int i = 0; i < itemCount; i++)
|
||||
{
|
||||
// Update item rectangle y position for next item
|
||||
itemBounds.y += (bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_PADDING));
|
||||
|
|
@ -1913,19 +1919,16 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo
|
|||
}
|
||||
|
||||
// Text Box control, updates input text
|
||||
// NOTE 1: Requires static variables: framesCounter
|
||||
// NOTE 2: Returns if KEY_ENTER pressed (useful for data validation)
|
||||
bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
||||
{
|
||||
static int framesCounter = 0; // Blinking cursor counter
|
||||
|
||||
GuiControlState state = guiState;
|
||||
bool pressed = false;
|
||||
|
||||
Rectangle cursor = {
|
||||
bounds.x + GuiGetStyle(TEXTBOX, TEXT_PADDING) + GetTextWidth(text) + 2,
|
||||
bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE),
|
||||
1,
|
||||
4,
|
||||
(float)GuiGetStyle(DEFAULT, TEXT_SIZE)*2
|
||||
};
|
||||
|
||||
|
|
@ -1938,7 +1941,6 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||
if (editMode)
|
||||
{
|
||||
state = GUI_STATE_PRESSED;
|
||||
framesCounter++;
|
||||
|
||||
int key = GetCharPressed(); // Returns codepoint as Unicode
|
||||
int keyCount = (int)strlen(text);
|
||||
|
|
@ -1950,10 +1952,10 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||
|
||||
if ((GetTextWidth(text) < (maxWidth - GuiGetStyle(DEFAULT, TEXT_SIZE))) && (key >= 32))
|
||||
{
|
||||
int byteLength = 0;
|
||||
const char *textUTF8 = CodepointToUTF8(key, &byteLength);
|
||||
int byteSize = 0;
|
||||
const char *textUTF8 = CodepointToUTF8(key, &byteSize);
|
||||
|
||||
for (int i = 0; i < byteLength; i++)
|
||||
for (int i = 0; i < byteSize; i++)
|
||||
{
|
||||
text[keyCount] = textUTF8[i];
|
||||
keyCount++;
|
||||
|
|
@ -1970,13 +1972,6 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||
{
|
||||
keyCount--;
|
||||
text[keyCount] = '\0';
|
||||
framesCounter = 0;
|
||||
if (keyCount < 0) keyCount = 0;
|
||||
}
|
||||
else if (IsKeyDown(KEY_BACKSPACE))
|
||||
{
|
||||
if ((framesCounter > TEXTEDIT_CURSOR_BLINK_FRAMES) && (framesCounter%2) == 0) keyCount--;
|
||||
text[keyCount] = '\0';
|
||||
if (keyCount < 0) keyCount = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1996,8 +1991,6 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (pressed) framesCounter = 0;
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
|
|
@ -2006,9 +1999,6 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||
if (state == GUI_STATE_PRESSED)
|
||||
{
|
||||
GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_PRESSED)), guiAlpha));
|
||||
|
||||
// Draw blinking cursor
|
||||
if (editMode && ((framesCounter/20)%2 == 0)) GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER_COLOR_PRESSED)), guiAlpha));
|
||||
}
|
||||
else if (state == GUI_STATE_DISABLED)
|
||||
{
|
||||
|
|
@ -2017,6 +2007,9 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||
else GuiDrawRectangle(bounds, 1, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), BLANK);
|
||||
|
||||
GuiDrawText(text, GetTextBounds(TEXTBOX, bounds), GuiGetStyle(TEXTBOX, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha));
|
||||
|
||||
// Draw cursor
|
||||
if (editMode) GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER_COLOR_PRESSED)), guiAlpha));
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
return pressed;
|
||||
|
|
@ -2090,7 +2083,7 @@ bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, in
|
|||
GuiSetStyle(BUTTON, BORDER_WIDTH, tempBorderWidth);
|
||||
|
||||
// Draw text label if provided
|
||||
if (text != NULL) GuiDrawText(text, textBounds, (GuiGetStyle(SPINNER, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha));
|
||||
GuiDrawText(text, textBounds, (GuiGetStyle(SPINNER, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha));
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
*value = tempValue;
|
||||
|
|
@ -2098,15 +2091,13 @@ bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, in
|
|||
}
|
||||
|
||||
// Value Box control, updates input text with numbers
|
||||
// NOTE: Requires static variables: framesCounter
|
||||
// NOTE: Requires static variables: frameCounter
|
||||
bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode)
|
||||
{
|
||||
#if !defined(VALUEBOX_MAX_CHARS)
|
||||
#define VALUEBOX_MAX_CHARS 32
|
||||
#endif
|
||||
|
||||
static int framesCounter = 0; // Blinking cursor counter
|
||||
|
||||
GuiControlState state = guiState;
|
||||
bool pressed = false;
|
||||
|
||||
|
|
@ -2135,8 +2126,6 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i
|
|||
{
|
||||
state = GUI_STATE_PRESSED;
|
||||
|
||||
framesCounter++;
|
||||
|
||||
int keyCount = (int)strlen(textValue);
|
||||
|
||||
// Only allow keys in range [48..57]
|
||||
|
|
@ -2161,14 +2150,6 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i
|
|||
{
|
||||
keyCount--;
|
||||
textValue[keyCount] = '\0';
|
||||
framesCounter = 0;
|
||||
if (keyCount < 0) keyCount = 0;
|
||||
valueHasChanged = true;
|
||||
}
|
||||
else if (IsKeyDown(KEY_BACKSPACE))
|
||||
{
|
||||
if ((framesCounter > TEXTEDIT_CURSOR_BLINK_FRAMES) && (framesCounter%2) == 0) keyCount--;
|
||||
textValue[keyCount] = '\0';
|
||||
if (keyCount < 0) keyCount = 0;
|
||||
valueHasChanged = true;
|
||||
}
|
||||
|
|
@ -2189,8 +2170,6 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i
|
|||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (pressed) framesCounter = 0;
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
|
|
@ -2204,16 +2183,16 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i
|
|||
GuiDrawRectangle(bounds, GuiGetStyle(VALUEBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(VALUEBOX, BORDER + (state*3))), guiAlpha), baseColor);
|
||||
GuiDrawText(textValue, GetTextBounds(VALUEBOX, bounds), GUI_TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(VALUEBOX, TEXT + (state*3))), guiAlpha));
|
||||
|
||||
// Draw blinking cursor
|
||||
if ((state == GUI_STATE_PRESSED) && (editMode && ((framesCounter/20)%2 == 0)))
|
||||
// Draw cursor
|
||||
if (editMode)
|
||||
{
|
||||
// NOTE: ValueBox internal text is always centered
|
||||
Rectangle cursor = { bounds.x + GetTextWidth(textValue)/2 + bounds.width/2 + 2, bounds.y + 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), 1, bounds.height - 4*GuiGetStyle(VALUEBOX, BORDER_WIDTH) };
|
||||
Rectangle cursor = { bounds.x + GetTextWidth(textValue)/2 + bounds.width/2 + 2, bounds.y + 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), 4, bounds.height - 4*GuiGetStyle(VALUEBOX, BORDER_WIDTH) };
|
||||
GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(VALUEBOX, BORDER_COLOR_PRESSED)), guiAlpha));
|
||||
}
|
||||
|
||||
// Draw text label if provided
|
||||
if (text != NULL) GuiDrawText(text, textBounds, (GuiGetStyle(VALUEBOX, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha));
|
||||
GuiDrawText(text, textBounds, (GuiGetStyle(VALUEBOX, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha));
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
return pressed;
|
||||
|
|
@ -2222,8 +2201,6 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i
|
|||
// Text Box control with multiple lines
|
||||
bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
|
||||
{
|
||||
static int framesCounter = 0; // Blinking cursor counter
|
||||
|
||||
GuiControlState state = guiState;
|
||||
bool pressed = false;
|
||||
|
||||
|
|
@ -2235,10 +2212,9 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||
};
|
||||
|
||||
// Cursor position, [x, y] values should be updated
|
||||
Rectangle cursor = { 0, 0, 1, (float)GuiGetStyle(DEFAULT, TEXT_SIZE) + 2 };
|
||||
Rectangle cursor = { 0, -1, 4, (float)GuiGetStyle(DEFAULT, TEXT_SIZE) + 2 };
|
||||
|
||||
int textWidth = 0;
|
||||
int currentLine = 0;
|
||||
float scaleFactor = (float)GuiGetStyle(DEFAULT, TEXT_SIZE)/(float)guiFont.baseSize; // Character rectangle scaling factor
|
||||
|
||||
// Update control
|
||||
//--------------------------------------------------------------------
|
||||
|
|
@ -2249,76 +2225,51 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||
if (editMode)
|
||||
{
|
||||
state = GUI_STATE_PRESSED;
|
||||
framesCounter++;
|
||||
|
||||
int character = GetCharPressed();
|
||||
int keyCount = (int)strlen(text);
|
||||
// We get an Unicode codepoint
|
||||
int codepoint = GetCharPressed();
|
||||
int textLength = (int)strlen(text); // Length in bytes (UTF-8 string)
|
||||
|
||||
// Introduce characters
|
||||
if (keyCount < (textSize - 1))
|
||||
{
|
||||
Vector2 textSize = MeasureTextEx(guiFont, text, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
|
||||
|
||||
if (textSize.y < (textAreaBounds.height - GuiGetStyle(DEFAULT, TEXT_SIZE)))
|
||||
if (textLength < (textSize - 1))
|
||||
{
|
||||
if (IsKeyPressed(KEY_ENTER))
|
||||
{
|
||||
text[keyCount] = '\n';
|
||||
keyCount++;
|
||||
text[textLength] = '\n';
|
||||
textLength++;
|
||||
}
|
||||
else if (((character >= 32) && (character < 255))) // TODO: Support Unicode inputs
|
||||
else if (codepoint >= 32)
|
||||
{
|
||||
text[keyCount] = (char)character;
|
||||
keyCount++;
|
||||
}
|
||||
// Supports Unicode inputs -> Encoded to UTF-8
|
||||
int charUTF8Length = 0;
|
||||
const char *charEncoded = CodepointToUTF8(codepoint, &charUTF8Length);
|
||||
memcpy(text + textLength, charEncoded, charUTF8Length);
|
||||
textLength += charUTF8Length;
|
||||
}
|
||||
}
|
||||
|
||||
// Delete characters
|
||||
if (keyCount > 0)
|
||||
if (textLength > 0)
|
||||
{
|
||||
if (IsKeyPressed(KEY_BACKSPACE))
|
||||
{
|
||||
keyCount--;
|
||||
text[keyCount] = '\0';
|
||||
framesCounter = 0;
|
||||
|
||||
if (keyCount < 0) keyCount = 0;
|
||||
}
|
||||
else if (IsKeyDown(KEY_BACKSPACE))
|
||||
if ((unsigned char)text[textLength - 1] < 127)
|
||||
{
|
||||
if ((framesCounter > TEXTEDIT_CURSOR_BLINK_FRAMES) && (framesCounter%2) == 0) keyCount--;
|
||||
text[keyCount] = '\0';
|
||||
|
||||
if (keyCount < 0) keyCount = 0;
|
||||
// Remove ASCII equivalent character (1 byte)
|
||||
textLength--;
|
||||
text[textLength] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate cursor position considering text
|
||||
char oneCharText[2] = { 0 };
|
||||
int lastBreakingPos = -1;
|
||||
|
||||
for (int i = 0; i < keyCount && currentLine < keyCount; i++)
|
||||
else
|
||||
{
|
||||
oneCharText[0] = text[i];
|
||||
textWidth += (GetTextWidth(oneCharText) + GuiGetStyle(DEFAULT, TEXT_SPACING));
|
||||
// Remove latest UTF-8 unicode character introduced (n bytes)
|
||||
int charUTF8Length = 0;
|
||||
while (((unsigned char)text[textLength - 1 - charUTF8Length] & 0b01000000) == 0) charUTF8Length++;
|
||||
|
||||
if (text[i] == ' ' || text[i] == '\n') lastBreakingPos = i;
|
||||
|
||||
if ( text[i] == '\n' || textWidth >= textAreaBounds.width)
|
||||
{
|
||||
currentLine++;
|
||||
textWidth = 0;
|
||||
|
||||
if (lastBreakingPos > 0) i = lastBreakingPos;
|
||||
else textWidth += (GetTextWidth(oneCharText) + GuiGetStyle(DEFAULT, TEXT_SPACING));
|
||||
|
||||
lastBreakingPos = -1;
|
||||
textLength -= (charUTF8Length + 1);
|
||||
text[textLength] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cursor.x = bounds.x + GuiGetStyle(TEXTBOX, BORDER_WIDTH) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING) + textWidth - GuiGetStyle(DEFAULT, TEXT_SPACING);
|
||||
cursor.y = bounds.y + GuiGetStyle(TEXTBOX, BORDER_WIDTH) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING)/2 + ((GuiGetStyle(DEFAULT, TEXT_SIZE) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING))*currentLine);
|
||||
|
||||
// Exit edit mode
|
||||
if (!CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true;
|
||||
|
|
@ -2331,8 +2282,6 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (pressed) framesCounter = 0; // Reset blinking cursor
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
|
|
@ -2341,9 +2290,6 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||
if (state == GUI_STATE_PRESSED)
|
||||
{
|
||||
GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_PRESSED)), guiAlpha));
|
||||
|
||||
// Draw blinking cursor
|
||||
if (editMode && ((framesCounter/20)%2 == 0)) GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER_COLOR_PRESSED)), guiAlpha));
|
||||
}
|
||||
else if (state == GUI_STATE_DISABLED)
|
||||
{
|
||||
|
|
@ -2351,9 +2297,76 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||
}
|
||||
else GuiDrawRectangle(bounds, 1, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), BLANK);
|
||||
|
||||
// TODO: Review to support boxed text with word-wrap
|
||||
//DrawTextBoxed(guiFont, text, textAreaBounds, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING), true, Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha));
|
||||
DrawTextEx(guiFont, text, (Vector2){ textAreaBounds.x, textAreaBounds.y }, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING), Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha));
|
||||
int wrapMode = 1; // 0-No wrap, 1-Char wrap, 2-Word wrap
|
||||
Vector2 cursorPos = { textAreaBounds.x, textAreaBounds.y };
|
||||
|
||||
//int lastSpacePos = 0;
|
||||
//int lastSpaceWidth = 0;
|
||||
//int lastSpaceCursorPos = 0;
|
||||
|
||||
for (int i = 0, codepointLength = 0; text[i] != '\0'; i += codepointLength)
|
||||
{
|
||||
int codepoint = GetCodepoint(text + i, &codepointLength);
|
||||
int index = GetGlyphIndex(guiFont, codepoint); // If requested codepoint is not found, we get '?' (0x3f) -> TODO: review that case!
|
||||
Rectangle atlasRec = guiFont.recs[index];
|
||||
GlyphInfo glyphInfo = guiFont.glyphs[index]; // Glyph measures
|
||||
|
||||
if ((codepointLength == 1) && (codepoint == '\n'))
|
||||
{
|
||||
cursorPos.y += (guiFont.baseSize*scaleFactor + GuiGetStyle(TEXTBOX, TEXT_LINES_PADDING)); // Line feed
|
||||
cursorPos.x = textAreaBounds.x; // Carriage return
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wrapMode == 1)
|
||||
{
|
||||
int glyphWidth = 0;
|
||||
if (glyphInfo.advanceX != 0) glyphWidth += glyphInfo.advanceX;
|
||||
else glyphWidth += (atlasRec.width + glyphInfo.offsetX);
|
||||
|
||||
// Jump line if the end of the text box area has been reached
|
||||
if ((cursorPos.x + (glyphWidth*scaleFactor)) > (textAreaBounds.x + textAreaBounds.width))
|
||||
{
|
||||
cursorPos.y += (guiFont.baseSize*scaleFactor + GuiGetStyle(TEXTBOX, TEXT_LINES_PADDING)); // Line feed
|
||||
cursorPos.x = textAreaBounds.x; // Carriage return
|
||||
}
|
||||
}
|
||||
else if (wrapMode == 2)
|
||||
{
|
||||
/*
|
||||
if ((codepointLength == 1) && (codepoint == ' '))
|
||||
{
|
||||
lastSpacePos = i;
|
||||
lastSpaceWidth = 0;
|
||||
lastSpaceCursorPos = cursorPos.x;
|
||||
}
|
||||
|
||||
// Jump line if last word reaches end of text box area
|
||||
if ((lastSpaceCursorPos + lastSpaceWidth) > (textAreaBounds.x + textAreaBounds.width))
|
||||
{
|
||||
cursorPos.y += 12; // Line feed
|
||||
cursorPos.x = textAreaBounds.x; // Carriage return
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// Draw current character glyph
|
||||
DrawTextCodepoint(guiFont, codepoint, cursorPos, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha));
|
||||
|
||||
int glyphWidth = 0;
|
||||
if (glyphInfo.advanceX != 0) glyphWidth += glyphInfo.advanceX;
|
||||
else glyphWidth += (atlasRec.width + glyphInfo.offsetX);
|
||||
|
||||
cursorPos.x += (glyphWidth*scaleFactor + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
|
||||
//if (i > lastSpacePos) lastSpaceWidth += (atlasRec.width + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
|
||||
}
|
||||
}
|
||||
|
||||
cursor.x = cursorPos.x;
|
||||
cursor.y = cursorPos.y;
|
||||
|
||||
// Draw cursor position considering text glyphs
|
||||
if (editMode) GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER_COLOR_PRESSED)), guiAlpha));
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
return pressed;
|
||||
|
|
@ -2698,12 +2711,12 @@ int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
|
|||
// List View control
|
||||
int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int active)
|
||||
{
|
||||
int itemsCount = 0;
|
||||
int itemCount = 0;
|
||||
const char **items = NULL;
|
||||
|
||||
if (text != NULL) items = GuiTextSplit(text, &itemsCount, NULL);
|
||||
if (text != NULL) items = GuiTextSplit(text, &itemCount, NULL);
|
||||
|
||||
return GuiListViewEx(bounds, items, itemsCount, NULL, scrollIndex, active);
|
||||
return GuiListViewEx(bounds, items, itemCount, NULL, scrollIndex, active);
|
||||
}
|
||||
|
||||
// List View control with extended parameters
|
||||
|
|
@ -3096,12 +3109,12 @@ int GuiMessageBox(Rectangle bounds, const char *title, const char *message, cons
|
|||
|
||||
int clicked = -1; // Returns clicked button from buttons list, 0 refers to closed window button
|
||||
|
||||
int buttonsCount = 0;
|
||||
const char **buttonsText = GuiTextSplit(buttons, &buttonsCount, NULL);
|
||||
int buttonCount = 0;
|
||||
const char **buttonsText = GuiTextSplit(buttons, &buttonCount, NULL);
|
||||
Rectangle buttonBounds = { 0 };
|
||||
buttonBounds.x = bounds.x + MESSAGEBOX_BUTTON_PADDING;
|
||||
buttonBounds.y = bounds.y + bounds.height - MESSAGEBOX_BUTTON_HEIGHT - MESSAGEBOX_BUTTON_PADDING;
|
||||
buttonBounds.width = (bounds.width - MESSAGEBOX_BUTTON_PADDING*(buttonsCount + 1))/buttonsCount;
|
||||
buttonBounds.width = (bounds.width - MESSAGEBOX_BUTTON_PADDING*(buttonCount + 1))/buttonCount;
|
||||
buttonBounds.height = MESSAGEBOX_BUTTON_HEIGHT;
|
||||
|
||||
Vector2 textSize = MeasureTextEx(guiFont, message, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), 1);
|
||||
|
|
@ -3124,7 +3137,7 @@ int GuiMessageBox(Rectangle bounds, const char *title, const char *message, cons
|
|||
prevTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
|
||||
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER);
|
||||
|
||||
for (int i = 0; i < buttonsCount; i++)
|
||||
for (int i = 0; i < buttonCount; i++)
|
||||
{
|
||||
if (GuiButton(buttonBounds, buttonsText[i])) clicked = i + 1;
|
||||
buttonBounds.x += (buttonBounds.width + MESSAGEBOX_BUTTON_PADDING);
|
||||
|
|
@ -3151,12 +3164,12 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co
|
|||
|
||||
int btnIndex = -1;
|
||||
|
||||
int buttonsCount = 0;
|
||||
const char **buttonsText = GuiTextSplit(buttons, &buttonsCount, NULL);
|
||||
int buttonCount = 0;
|
||||
const char **buttonsText = GuiTextSplit(buttons, &buttonCount, NULL);
|
||||
Rectangle buttonBounds = { 0 };
|
||||
buttonBounds.x = bounds.x + TEXTINPUTBOX_BUTTON_PADDING;
|
||||
buttonBounds.y = bounds.y + bounds.height - TEXTINPUTBOX_BUTTON_HEIGHT - TEXTINPUTBOX_BUTTON_PADDING;
|
||||
buttonBounds.width = (bounds.width - TEXTINPUTBOX_BUTTON_PADDING*(buttonsCount + 1))/buttonsCount;
|
||||
buttonBounds.width = (bounds.width - TEXTINPUTBOX_BUTTON_PADDING*(buttonCount + 1))/buttonCount;
|
||||
buttonBounds.height = TEXTINPUTBOX_BUTTON_HEIGHT;
|
||||
|
||||
int messageInputHeight = (int)bounds.height - WINDOW_STATUSBAR_HEIGHT - GuiGetStyle(STATUSBAR, BORDER_WIDTH) - TEXTINPUTBOX_BUTTON_HEIGHT - 2*TEXTINPUTBOX_BUTTON_PADDING;
|
||||
|
|
@ -3198,7 +3211,7 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co
|
|||
int prevBtnTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
|
||||
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER);
|
||||
|
||||
for (int i = 0; i < buttonsCount; i++)
|
||||
for (int i = 0; i < buttonCount; i++)
|
||||
{
|
||||
if (GuiButton(buttonBounds, buttonsText[i])) btnIndex = i + 1;
|
||||
buttonBounds.x += (buttonBounds.width + MESSAGEBOX_BUTTON_PADDING);
|
||||
|
|
@ -3322,20 +3335,20 @@ void GuiLoadStyle(const char *fileName)
|
|||
char *charValues = LoadFileText(charmapFileName);
|
||||
if (charValues != NULL)
|
||||
{
|
||||
int charsCount = 0;
|
||||
const char **chars = TextSplit(charValues, '\n', &charsCount);
|
||||
int glyphCount = 0;
|
||||
const char **chars = TextSplit(charValues, '\n', &glyphCount);
|
||||
|
||||
int *values = (int *)RAYGUI_MALLOC(charsCount*sizeof(int));
|
||||
for (int i = 0; i < charsCount; i++) values[i] = TextToInteger(chars[i]);
|
||||
int *values = (int *)RAYGUI_MALLOC(glyphCount*sizeof(int));
|
||||
for (int i = 0; i < glyphCount; i++) values[i] = TextToInteger(chars[i]);
|
||||
|
||||
font = LoadFontEx(TextFormat("%s/%s", GetDirectoryPath(fileName), fontFileName), fontSize, values, charsCount);
|
||||
font = LoadFontEx(TextFormat("%s/%s", GetDirectoryPath(fileName), fontFileName), fontSize, values, glyphCount);
|
||||
|
||||
RAYGUI_FREE(values);
|
||||
}
|
||||
}
|
||||
else font = LoadFontEx(TextFormat("%s/%s", GetDirectoryPath(fileName), fontFileName), fontSize, NULL, 0);
|
||||
|
||||
if ((font.texture.id > 0) && (font.charsCount > 0)) GuiSetFont(font);
|
||||
if ((font.texture.id > 0) && (font.glyphCount > 0)) GuiSetFont(font);
|
||||
|
||||
} break;
|
||||
default: break;
|
||||
|
|
@ -3358,12 +3371,12 @@ void GuiLoadStyle(const char *fileName)
|
|||
char signature[5] = "";
|
||||
short version = 0;
|
||||
short reserved = 0;
|
||||
int propertiesCount = 0;
|
||||
int propertyCount = 0;
|
||||
|
||||
fread(signature, 1, 4, rgsFile);
|
||||
fread(&version, 1, sizeof(short), rgsFile);
|
||||
fread(&reserved, 1, sizeof(short), rgsFile);
|
||||
fread(&propertiesCount, 1, sizeof(int), rgsFile);
|
||||
fread(&propertyCount, 1, sizeof(int), rgsFile);
|
||||
|
||||
if ((signature[0] == 'r') &&
|
||||
(signature[1] == 'G') &&
|
||||
|
|
@ -3374,7 +3387,7 @@ void GuiLoadStyle(const char *fileName)
|
|||
short propertyId = 0;
|
||||
int propertyValue = 0;
|
||||
|
||||
for (int i = 0; i < propertiesCount; i++)
|
||||
for (int i = 0; i < propertyCount; i++)
|
||||
{
|
||||
fread(&controlId, 1, sizeof(short), rgsFile);
|
||||
fread(&propertyId, 1, sizeof(short), rgsFile);
|
||||
|
|
@ -3405,7 +3418,7 @@ void GuiLoadStyle(const char *fileName)
|
|||
Rectangle whiteRec = { 0 };
|
||||
|
||||
fread(&font.baseSize, 1, sizeof(int), rgsFile);
|
||||
fread(&font.charsCount, 1, sizeof(int), rgsFile);
|
||||
fread(&font.glyphCount, 1, sizeof(int), rgsFile);
|
||||
fread(&fontType, 1, sizeof(int), rgsFile);
|
||||
|
||||
// Load font white rectangle
|
||||
|
|
@ -3432,17 +3445,17 @@ void GuiLoadStyle(const char *fileName)
|
|||
}
|
||||
|
||||
// Load font recs data
|
||||
font.recs = (Rectangle *)RAYGUI_CALLOC(font.charsCount, sizeof(Rectangle));
|
||||
for (int i = 0; i < font.charsCount; i++) fread(&font.recs[i], 1, sizeof(Rectangle), rgsFile);
|
||||
font.recs = (Rectangle *)RAYGUI_CALLOC(font.glyphCount, sizeof(Rectangle));
|
||||
for (int i = 0; i < font.glyphCount; i++) fread(&font.recs[i], 1, sizeof(Rectangle), rgsFile);
|
||||
|
||||
// Load font chars info data
|
||||
font.chars = (GlyphInfo *)RAYGUI_CALLOC(font.charsCount, sizeof(GlyphInfo));
|
||||
for (int i = 0; i < font.charsCount; i++)
|
||||
font.glyphs = (GlyphInfo *)RAYGUI_CALLOC(font.glyphCount, sizeof(GlyphInfo));
|
||||
for (int i = 0; i < font.glyphCount; i++)
|
||||
{
|
||||
fread(&font.chars[i].value, 1, sizeof(int), rgsFile);
|
||||
fread(&font.chars[i].offsetX, 1, sizeof(int), rgsFile);
|
||||
fread(&font.chars[i].offsetY, 1, sizeof(int), rgsFile);
|
||||
fread(&font.chars[i].advanceX, 1, sizeof(int), rgsFile);
|
||||
fread(&font.glyphs[i].value, 1, sizeof(int), rgsFile);
|
||||
fread(&font.glyphs[i].offsetX, 1, sizeof(int), rgsFile);
|
||||
fread(&font.glyphs[i].offsetY, 1, sizeof(int), rgsFile);
|
||||
fread(&font.glyphs[i].advanceX, 1, sizeof(int), rgsFile);
|
||||
}
|
||||
|
||||
GuiSetFont(font);
|
||||
|
|
@ -3572,7 +3585,7 @@ unsigned int *GuiGetIcons(void) { return guiIcons; }
|
|||
|
||||
// Load raygui icons file (.rgi)
|
||||
// NOTE: In case nameIds are required, they can be requested with loadIconsName,
|
||||
// they are returned as a guiIconsName[iconsCount][RICON_MAX_NAME_LENGTH],
|
||||
// they are returned as a guiIconsName[iconCount][RICON_MAX_NAME_LENGTH],
|
||||
// guiIconsName[]][] memory should be manually freed!
|
||||
char **GuiLoadIcons(const char *fileName, bool loadIconsName)
|
||||
{
|
||||
|
|
@ -3609,14 +3622,14 @@ char **GuiLoadIcons(const char *fileName, bool loadIconsName)
|
|||
char signature[5] = "";
|
||||
short version = 0;
|
||||
short reserved = 0;
|
||||
short iconsCount = 0;
|
||||
short iconsSize = 0;
|
||||
short iconCount = 0;
|
||||
short iconSize = 0;
|
||||
|
||||
fread(signature, 1, 4, rgiFile);
|
||||
fread(&version, 1, sizeof(short), rgiFile);
|
||||
fread(&reserved, 1, sizeof(short), rgiFile);
|
||||
fread(&iconsCount, 1, sizeof(short), rgiFile);
|
||||
fread(&iconsSize, 1, sizeof(short), rgiFile);
|
||||
fread(&iconCount, 1, sizeof(short), rgiFile);
|
||||
fread(&iconSize, 1, sizeof(short), rgiFile);
|
||||
|
||||
if ((signature[0] == 'r') &&
|
||||
(signature[1] == 'G') &&
|
||||
|
|
@ -3625,17 +3638,17 @@ char **GuiLoadIcons(const char *fileName, bool loadIconsName)
|
|||
{
|
||||
if (loadIconsName)
|
||||
{
|
||||
guiIconsName = (char **)RAYGUI_MALLOC(iconsCount*sizeof(char **));
|
||||
for (int i = 0; i < iconsCount; i++)
|
||||
guiIconsName = (char **)RAYGUI_MALLOC(iconCount*sizeof(char **));
|
||||
for (int i = 0; i < iconCount; i++)
|
||||
{
|
||||
guiIconsName[i] = (char *)RAYGUI_MALLOC(RICON_MAX_NAME_LENGTH);
|
||||
fread(guiIconsName[i], RICON_MAX_NAME_LENGTH, 1, rgiFile);
|
||||
}
|
||||
}
|
||||
else fseek(rgiFile, iconsCount*RICON_MAX_NAME_LENGTH, SEEK_CUR);
|
||||
else fseek(rgiFile, iconCount*RICON_MAX_NAME_LENGTH, SEEK_CUR);
|
||||
|
||||
// Read icons data directly over guiIcons data array
|
||||
fread(guiIcons, iconsCount*(iconsSize*iconsSize/32), sizeof(unsigned int), rgiFile);
|
||||
fread(guiIcons, iconCount*(iconSize*iconSize/32), sizeof(unsigned int), rgiFile);
|
||||
}
|
||||
|
||||
fclose(rgiFile);
|
||||
|
|
@ -4061,7 +4074,7 @@ static Vector3 ConvertHSVtoRGB(Vector3 hsv)
|
|||
|
||||
#if defined(RAYGUI_STANDALONE)
|
||||
// Returns a Color struct from hexadecimal value
|
||||
static Color GetColor(unsigned int hexValue)
|
||||
static Color GetColor(int hexValue)
|
||||
{
|
||||
Color color;
|
||||
|
||||
|
|
@ -4186,29 +4199,29 @@ static int TextToInteger(const char *text)
|
|||
return value*sign;
|
||||
}
|
||||
|
||||
// Encode codepoint into UTF-8 text (char array length returned as parameter)
|
||||
static const char *CodepointToUTF8(int codepoint, int *byteLength)
|
||||
// Encode codepoint into UTF-8 text (char array size returned as parameter)
|
||||
static const char *CodepointToUTF8(int codepoint, int *byteSize)
|
||||
{
|
||||
static char utf8[6] = { 0 };
|
||||
int length = 0;
|
||||
int size = 0;
|
||||
|
||||
if (codepoint <= 0x7f)
|
||||
{
|
||||
utf8[0] = (char)codepoint;
|
||||
length = 1;
|
||||
size = 1;
|
||||
}
|
||||
else if (codepoint <= 0x7ff)
|
||||
{
|
||||
utf8[0] = (char)(((codepoint >> 6) & 0x1f) | 0xc0);
|
||||
utf8[1] = (char)((codepoint & 0x3f) | 0x80);
|
||||
length = 2;
|
||||
size = 2;
|
||||
}
|
||||
else if (codepoint <= 0xffff)
|
||||
{
|
||||
utf8[0] = (char)(((codepoint >> 12) & 0x0f) | 0xe0);
|
||||
utf8[1] = (char)(((codepoint >> 6) & 0x3f) | 0x80);
|
||||
utf8[2] = (char)((codepoint & 0x3f) | 0x80);
|
||||
length = 3;
|
||||
size = 3;
|
||||
}
|
||||
else if (codepoint <= 0x10ffff)
|
||||
{
|
||||
|
|
@ -4216,10 +4229,10 @@ static const char *CodepointToUTF8(int codepoint, int *byteLength)
|
|||
utf8[1] = (char)(((codepoint >> 12) & 0x3f) | 0x80);
|
||||
utf8[2] = (char)(((codepoint >> 6) & 0x3f) | 0x80);
|
||||
utf8[3] = (char)((codepoint & 0x3f) | 0x80);
|
||||
length = 4;
|
||||
size = 4;
|
||||
}
|
||||
|
||||
*byteLength = length;
|
||||
*byteSize = size;
|
||||
|
||||
return utf8;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,10 +155,6 @@ typedef int socklen_t;
|
|||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#ifndef INVALID_SOCKET
|
||||
#define INVALID_SOCKET ~(0)
|
||||
#endif
|
||||
|
||||
#ifndef __USE_W32_SOCKETS
|
||||
#define closesocket close
|
||||
#define SOCKET int
|
||||
|
|
@ -166,6 +162,10 @@ typedef int socklen_t;
|
|||
#define SOCKET_ERROR -1
|
||||
#endif
|
||||
|
||||
#ifndef INVALID_SOCKET
|
||||
#define INVALID_SOCKET ~(0)
|
||||
#endif
|
||||
|
||||
#ifdef __USE_W32_SOCKETS
|
||||
#ifndef EINTR
|
||||
#define EINTR WSAEINTR
|
||||
|
|
|
|||
25
src/raudio.c
25
src/raudio.c
|
|
@ -26,8 +26,9 @@
|
|||
* supported by default, to remove support, just comment unrequired #define in this module
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
* miniaudio.h - Audio device management lib (https://github.com/dr-soft/miniaudio)
|
||||
* miniaudio.h - Audio device management lib (https://github.com/mackron/miniaudio)
|
||||
* stb_vorbis.h - Ogg audio files loading (http://www.nothings.org/stb_vorbis/)
|
||||
* dr_wav.h - WAV audio files loading (http://github.com/mackron/dr_libs)
|
||||
* dr_mp3.h - MP3 audio file loading (https://github.com/mackron/dr_libs)
|
||||
* dr_flac.h - FLAC audio file loading (https://github.com/mackron/dr_libs)
|
||||
* jar_xm.h - XM module file loading
|
||||
|
|
@ -1655,6 +1656,28 @@ void StopMusicStream(Music music)
|
|||
}
|
||||
}
|
||||
|
||||
// Seek music to a certain position (in seconds)
|
||||
void SeekMusicStream(Music music, float position)
|
||||
{
|
||||
unsigned int positionInFrames = (unsigned int)(position * music.stream.sampleRate);
|
||||
switch (music.ctxType)
|
||||
{
|
||||
#if defined(SUPPORT_FILEFORMAT_WAV)
|
||||
case MUSIC_AUDIO_WAV: drwav_seek_to_pcm_frame((drwav *)music.ctxData, positionInFrames); break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_OGG)
|
||||
case MUSIC_AUDIO_OGG: stb_vorbis_seek_frame((stb_vorbis *)music.ctxData, positionInFrames); break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
||||
case MUSIC_AUDIO_FLAC: drflac_seek_to_pcm_frame((drflac *)music.ctxData, positionInFrames); break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_MP3)
|
||||
case MUSIC_AUDIO_MP3: drmp3_seek_to_pcm_frame((drmp3 *)music.ctxData, positionInFrames); break;
|
||||
#endif
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
// Update (re-fill) music buffers if data already processed
|
||||
void UpdateMusicStream(Music music)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ void UpdateMusicStream(Music music); // Updates buffe
|
|||
void StopMusicStream(Music music); // Stop music playing
|
||||
void PauseMusicStream(Music music); // Pause music playing
|
||||
void ResumeMusicStream(Music music); // Resume playing paused music
|
||||
void SeekMusicStream(Music music, float position); // Seek music to a position (in seconds)
|
||||
void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level)
|
||||
void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level)
|
||||
float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
||||
|
|
|
|||
17
src/raylib.h
17
src/raylib.h
|
|
@ -841,7 +841,7 @@ typedef enum {
|
|||
BLEND_CUSTOM // Belnd textures using custom src/dst factors (use rlSetBlendMode())
|
||||
} BlendMode;
|
||||
|
||||
// Gestures
|
||||
// Gesture
|
||||
// NOTE: It could be used as flags to enable only some gestures
|
||||
typedef enum {
|
||||
GESTURE_NONE = 0, // No gesture
|
||||
|
|
@ -1009,6 +1009,7 @@ RLAPI double GetTime(void); // Get elapsed
|
|||
|
||||
// Misc. functions
|
||||
RLAPI int GetRandomValue(int min, int max); // Get a random value between min and max (both included)
|
||||
RLAPI void SetRandomSeed(unsigned int seed); // Set the seed for the random number generator
|
||||
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (filename extension defines format)
|
||||
RLAPI void SetConfigFlags(unsigned int flags); // Setup init configuration flags (view FLAGS)
|
||||
|
||||
|
|
@ -1104,14 +1105,16 @@ RLAPI void SetMouseCursor(int cursor); // Set mouse curso
|
|||
RLAPI int GetTouchX(void); // Get touch position X for touch point 0 (relative to screen size)
|
||||
RLAPI int GetTouchY(void); // Get touch position Y for touch point 0 (relative to screen size)
|
||||
RLAPI Vector2 GetTouchPosition(int index); // Get touch position XY for a touch point index (relative to screen size)
|
||||
RLAPI int GetTouchPointId(int index); // Get touch point identifier for given index
|
||||
RLAPI int GetTouchPointCount(void); // Get number of touch points
|
||||
RLAPI int GetTouchEvent(void); // Get last touch event registered
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Gestures and Touch Handling Functions (Module: gestures)
|
||||
// Gestures and Touch Handling Functions (Module: rgestures)
|
||||
//------------------------------------------------------------------------------------
|
||||
RLAPI void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags
|
||||
RLAPI bool IsGestureDetected(int gesture); // Check if a gesture have been detected
|
||||
RLAPI int GetGestureDetected(void); // Get latest detected gesture
|
||||
RLAPI int GetTouchPointCount(void); // Get touch points count
|
||||
RLAPI float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds
|
||||
RLAPI Vector2 GetGestureDragVector(void); // Get gesture drag vector
|
||||
RLAPI float GetGestureDragAngle(void); // Get gesture drag angle
|
||||
|
|
@ -1119,7 +1122,7 @@ RLAPI Vector2 GetGesturePinchVector(void); // Get gesture pinch del
|
|||
RLAPI float GetGesturePinchAngle(void); // Get gesture pinch angle
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Camera System Functions (Module: camera)
|
||||
// Camera System Functions (Module: rcamera)
|
||||
//------------------------------------------------------------------------------------
|
||||
RLAPI void SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available)
|
||||
RLAPI void UpdateCamera(Camera *camera); // Update camera position for selected mode
|
||||
|
|
@ -1372,6 +1375,7 @@ RLAPI void DrawCubeV(Vector3 position, Vector3 size, Color color);
|
|||
RLAPI void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires
|
||||
RLAPI void DrawCubeWiresV(Vector3 position, Vector3 size, Color color); // Draw cube wires (Vector version)
|
||||
RLAPI void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color); // Draw cube textured
|
||||
RLAPI void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color); // Draw cube with a region of a texture
|
||||
RLAPI void DrawSphere(Vector3 centerPos, float radius, Color color); // Draw sphere
|
||||
RLAPI void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere with extended parameters
|
||||
RLAPI void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere wires
|
||||
|
|
@ -1400,7 +1404,7 @@ RLAPI void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis,
|
|||
RLAPI void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires)
|
||||
RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 position, float size, Color tint); // Draw a billboard texture
|
||||
RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Color tint); // Draw a billboard texture defined by source
|
||||
RLAPI void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Vector2 origin, float rotation, Color tint); // Draw a billboard texture defined by source and rotation
|
||||
RLAPI void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint); // Draw a billboard texture defined by source and rotation
|
||||
|
||||
// Mesh management functions
|
||||
RLAPI void UploadMesh(Mesh *mesh, bool dynamic); // Upload mesh vertex data in GPU and provide VAO/VBO ids
|
||||
|
|
@ -1434,7 +1438,7 @@ RLAPI void SetMaterialTexture(Material *material, int mapType, Texture2D texture
|
|||
RLAPI void SetModelMeshMaterial(Model *model, int meshId, int materialId); // Set material for a mesh
|
||||
|
||||
// Model animations loading/unloading functions
|
||||
RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, int *animCount); // Load model animations from file
|
||||
RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, unsigned int *animCount); // Load model animations from file
|
||||
RLAPI void UpdateModelAnimation(Model model, ModelAnimation anim, int frame); // Update model animation pose
|
||||
RLAPI void UnloadModelAnimation(ModelAnimation anim); // Unload animation data
|
||||
RLAPI void UnloadModelAnimations(ModelAnimation* animations, unsigned int count); // Unload animation array data
|
||||
|
|
@ -1499,6 +1503,7 @@ RLAPI void UpdateMusicStream(Music music); // Updates
|
|||
RLAPI void StopMusicStream(Music music); // Stop music playing
|
||||
RLAPI void PauseMusicStream(Music music); // Pause music playing
|
||||
RLAPI void ResumeMusicStream(Music music); // Resume playing paused music
|
||||
RLAPI void SeekMusicStream(Music music, float position); // Seek music to a position (in seconds)
|
||||
RLAPI void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level)
|
||||
RLAPI void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level)
|
||||
RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@
|
|||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
#if !defined(RL_VECTOR2_TYPE)
|
||||
// Vector2 type
|
||||
typedef struct Vector2 {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib.camera - Camera system with multiple modes support
|
||||
* rcamera - Basic camera system for multiple camera modes
|
||||
*
|
||||
* NOTE: Memory footprint of this library is aproximately 52 bytes (global variables)
|
||||
*
|
||||
|
|
@ -41,8 +41,8 @@
|
|||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#ifndef CAMERA_H
|
||||
#define CAMERA_H
|
||||
#ifndef RCAMERA_H
|
||||
#define RCAMERA_H
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Defines and Macros
|
||||
|
|
@ -204,6 +204,7 @@ typedef struct {
|
|||
float targetDistance; // Camera distance from position to target
|
||||
float playerEyesPosition; // Player eyes position from ground (in meters)
|
||||
Vector2 angle; // Camera angle in plane XZ
|
||||
Vector2 previousMousePosition; // Previous mouse position
|
||||
|
||||
// Camera movement control keys
|
||||
int moveControl[6]; // Move controls (CAMERA_FIRST_PERSON)
|
||||
|
|
@ -220,6 +221,7 @@ static CameraData CAMERA = { // Global CAMERA state context
|
|||
.targetDistance = 0,
|
||||
.playerEyesPosition = 1.85f,
|
||||
.angle = { 0 },
|
||||
.previousMousePosition = { 0 },
|
||||
.moveControl = { 'W', 'S', 'D', 'A', 'E', 'Q' },
|
||||
.smoothZoomControl = 341, // raylib: KEY_LEFT_CONTROL
|
||||
.altControl = 342, // raylib: KEY_LEFT_ALT
|
||||
|
|
@ -263,6 +265,8 @@ void SetCameraMode(Camera camera, int mode)
|
|||
|
||||
CAMERA.playerEyesPosition = camera.position.y; // Init player eyes position to camera Y position
|
||||
|
||||
CAMERA.previousMousePosition = GetMousePosition(); // Init mouse position
|
||||
|
||||
// Lock cursor for first person and third person cameras
|
||||
if ((mode == CAMERA_FIRST_PERSON) || (mode == CAMERA_THIRD_PERSON)) DisableCursor();
|
||||
else EnableCursor();
|
||||
|
|
@ -279,7 +283,6 @@ void SetCameraMode(Camera camera, int mode)
|
|||
void UpdateCamera(Camera *camera)
|
||||
{
|
||||
static int swingCounter = 0; // Used for 1st person swinging movement
|
||||
static Vector2 previousMousePosition = { 0.0f, 0.0f };
|
||||
|
||||
// TODO: Compute CAMERA.targetDistance and CAMERA.angle here (?)
|
||||
|
||||
|
|
@ -302,10 +305,10 @@ void UpdateCamera(Camera *camera)
|
|||
|
||||
if (CAMERA.mode != CAMERA_CUSTOM)
|
||||
{
|
||||
mousePositionDelta.x = mousePosition.x - previousMousePosition.x;
|
||||
mousePositionDelta.y = mousePosition.y - previousMousePosition.y;
|
||||
mousePositionDelta.x = mousePosition.x - CAMERA.previousMousePosition.x;
|
||||
mousePositionDelta.y = mousePosition.y - CAMERA.previousMousePosition.y;
|
||||
|
||||
previousMousePosition = mousePosition;
|
||||
CAMERA.previousMousePosition = mousePosition;
|
||||
}
|
||||
|
||||
// Support for multiple automatic camera modes
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* raylib.core - Basic functions to manage windows, OpenGL context and input on multiple platforms
|
||||
* rcore - Basic functions to manage windows, OpenGL context and input on multiple platforms
|
||||
*
|
||||
* PLATFORMS SUPPORTED:
|
||||
* - PLATFORM_DESKTOP: Windows (Win32, Win64)
|
||||
|
|
@ -39,10 +39,10 @@
|
|||
* NOTE: If enabled, uses external module functions to load default raylib font (module: text)
|
||||
*
|
||||
* #define SUPPORT_CAMERA_SYSTEM
|
||||
* Camera module is included (camera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital
|
||||
* Camera module is included (rcamera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital
|
||||
*
|
||||
* #define SUPPORT_GESTURES_SYSTEM
|
||||
* Gestures module is included (gestures.h) to support gestures detection: tap, hold, swipe, drag
|
||||
* Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag
|
||||
*
|
||||
* #define SUPPORT_MOUSE_GESTURES
|
||||
* Mouse gestures are directly mapped like touches and processed by gestures system.
|
||||
|
|
@ -129,12 +129,12 @@
|
|||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#define GESTURES_IMPLEMENTATION
|
||||
#include "gestures.h" // Gestures detection functionality
|
||||
#include "rgestures.h" // Gestures detection functionality
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_CAMERA_SYSTEM)
|
||||
#define CAMERA_IMPLEMENTATION
|
||||
#include "camera.h" // Camera system functionality
|
||||
#include "rcamera.h" // Camera system functionality
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_GIF_RECORDING)
|
||||
|
|
@ -298,7 +298,7 @@
|
|||
#define MAX_GAMEPAD_BUTTONS 32 // Maximum number of buttons supported (per gamepad)
|
||||
#endif
|
||||
#ifndef MAX_TOUCH_POINTS
|
||||
#define MAX_TOUCH_POINTS 10 // Maximum number of touch points supported
|
||||
#define MAX_TOUCH_POINTS 8 // Maximum number of touch points supported
|
||||
#endif
|
||||
#ifndef MAX_KEY_PRESSED_QUEUE
|
||||
#define MAX_KEY_PRESSED_QUEUE 16 // Maximum number of keys in the key input queue
|
||||
|
|
@ -443,6 +443,8 @@ typedef struct CoreData {
|
|||
#endif
|
||||
} Mouse;
|
||||
struct {
|
||||
int pointCount; // Number of touch points active
|
||||
int pointId[MAX_TOUCH_POINTS]; // Point identifiers
|
||||
Vector2 position[MAX_TOUCH_POINTS]; // Touch position on screen
|
||||
char currentTouchState[MAX_TOUCH_POINTS]; // Registers current touch state
|
||||
char previousTouchState[MAX_TOUCH_POINTS]; // Registers previous touch state
|
||||
|
|
@ -454,10 +456,10 @@ typedef struct CoreData {
|
|||
char currentButtonState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Current gamepad buttons state
|
||||
char previousButtonState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Previous gamepad buttons state
|
||||
float axisState[MAX_GAMEPADS][MAX_GAMEPAD_AXIS]; // Gamepad axis state
|
||||
#if defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
|
||||
#if defined(PLATFORM_RPI) || defined(PLATFORM_DRM) || defined(PLATFORM_WEB)
|
||||
pthread_t threadId; // Gamepad reading thread id
|
||||
int streamId[MAX_GAMEPADS]; // Gamepad device file descriptor
|
||||
char name[64]; // Gamepad name holder
|
||||
char name[MAX_GAMEPADS][64]; // Gamepad name holder
|
||||
#endif
|
||||
} Gamepad;
|
||||
} Input;
|
||||
|
|
@ -1079,7 +1081,7 @@ bool IsWindowMaximized(void)
|
|||
bool IsWindowFocused(void)
|
||||
{
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
||||
return ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) == 0); // TODO!
|
||||
return ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) == 0);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
|
|
@ -2667,6 +2669,12 @@ int GetRandomValue(int min, int max)
|
|||
return (rand()%(abs(max - min) + 1) + min);
|
||||
}
|
||||
|
||||
// Set the seed for the random number generator
|
||||
void SetRandomSeed(unsigned int seed)
|
||||
{
|
||||
srand(seed);
|
||||
}
|
||||
|
||||
// Check if the file exists
|
||||
bool FileExists(const char *fileName)
|
||||
{
|
||||
|
|
@ -3271,8 +3279,11 @@ const char *GetGamepadName(int gamepad)
|
|||
else return NULL;
|
||||
#endif
|
||||
#if defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
|
||||
if (CORE.Input.Gamepad.ready[gamepad]) ioctl(CORE.Input.Gamepad.streamId[gamepad], JSIOCGNAME(64), &CORE.Input.Gamepad.name);
|
||||
return CORE.Input.Gamepad.name;
|
||||
if (CORE.Input.Gamepad.ready[gamepad]) ioctl(CORE.Input.Gamepad.streamId[gamepad], JSIOCGNAME(64), &CORE.Input.Gamepad.name[gamepad]);
|
||||
return CORE.Input.Gamepad.name[gamepad];
|
||||
#endif
|
||||
#if defined(PLATFORM_WEB)
|
||||
return CORE.Input.Gamepad.name[gamepad];
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -3564,6 +3575,22 @@ Vector2 GetTouchPosition(int index)
|
|||
return position;
|
||||
}
|
||||
|
||||
// Get touch point identifier for given index
|
||||
int GetTouchPointId(int index)
|
||||
{
|
||||
int id = -1;
|
||||
|
||||
if (index < MAX_TOUCH_POINTS) id = CORE.Input.Touch.pointId[index];
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
// Get number of touch points
|
||||
int GetTouchPointCount(void)
|
||||
{
|
||||
return CORE.Input.Touch.pointCount;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module specific Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
@ -4848,7 +4875,9 @@ static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent *
|
|||
// NOTE: Window resizing not allowed by default
|
||||
static void WindowSizeCallback(GLFWwindow *window, int width, int height)
|
||||
{
|
||||
SetupViewport(width, height); // Reset viewport and projection matrix for new size
|
||||
// Reset viewport and projection matrix for new size
|
||||
SetupViewport(width, height);
|
||||
|
||||
CORE.Window.currentFbo.width = width;
|
||||
CORE.Window.currentFbo.height = height;
|
||||
CORE.Window.resizedLastFrame = true;
|
||||
|
|
@ -4858,8 +4887,8 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height)
|
|||
// Set current screen size
|
||||
CORE.Window.screen.width = width;
|
||||
CORE.Window.screen.height = height;
|
||||
// NOTE: Postprocessing texture is not scaled to new size
|
||||
|
||||
// NOTE: Postprocessing texture is not scaled to new size
|
||||
}
|
||||
|
||||
// GLFW3 WindowIconify Callback, runs when window is minimized/restored
|
||||
|
|
@ -4997,18 +5026,18 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int
|
|||
// but future releases may add more actions (i.e. GLFW_REPEAT)
|
||||
CORE.Input.Mouse.currentButtonState[button] = action;
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES)
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) // PLATFORM_DESKTOP
|
||||
// Process mouse events as touches to be able to use mouse-gestures
|
||||
GestureEvent gestureEvent = { 0 };
|
||||
|
||||
// Register touch actions
|
||||
if ((CORE.Input.Mouse.currentButtonState[button] == 1) && (CORE.Input.Mouse.previousButtonState[button] == 0)) gestureEvent.touchAction = TOUCH_DOWN;
|
||||
else if ((CORE.Input.Mouse.currentButtonState[button] == 0) && (CORE.Input.Mouse.previousButtonState[button] == 1)) gestureEvent.touchAction = TOUCH_UP;
|
||||
if ((CORE.Input.Mouse.currentButtonState[button] == 1) && (CORE.Input.Mouse.previousButtonState[button] == 0)) gestureEvent.touchAction = TOUCH_ACTION_DOWN;
|
||||
else if ((CORE.Input.Mouse.currentButtonState[button] == 0) && (CORE.Input.Mouse.previousButtonState[button] == 1)) gestureEvent.touchAction = TOUCH_ACTION_UP;
|
||||
|
||||
// NOTE: TOUCH_MOVE event is registered in MouseCursorPosCallback()
|
||||
// NOTE: TOUCH_ACTION_MOVE event is registered in MouseCursorPosCallback()
|
||||
|
||||
// Assign a pointer ID
|
||||
gestureEvent.pointerId[0] = 0;
|
||||
gestureEvent.pointId[0] = 0;
|
||||
|
||||
// Register touch points count
|
||||
gestureEvent.pointCount = 1;
|
||||
|
|
@ -5032,14 +5061,14 @@ static void MouseCursorPosCallback(GLFWwindow *window, double x, double y)
|
|||
CORE.Input.Mouse.currentPosition.y = (float)y;
|
||||
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES)
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) // PLATFORM_DESKTOP
|
||||
// Process mouse events as touches to be able to use mouse-gestures
|
||||
GestureEvent gestureEvent = { 0 };
|
||||
|
||||
gestureEvent.touchAction = TOUCH_MOVE;
|
||||
gestureEvent.touchAction = TOUCH_ACTION_MOVE;
|
||||
|
||||
// Assign a pointer ID
|
||||
gestureEvent.pointerId[0] = 0;
|
||||
gestureEvent.pointId[0] = 0;
|
||||
|
||||
// Register touch points count
|
||||
gestureEvent.pointCount = 1;
|
||||
|
|
@ -5272,63 +5301,47 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
|
|||
return 0;
|
||||
}
|
||||
|
||||
CORE.Input.Touch.position[0].x = AMotionEvent_getX(event, 0);
|
||||
CORE.Input.Touch.position[0].y = AMotionEvent_getY(event, 0);
|
||||
// Register touch points count
|
||||
CORE.Input.Touch.pointCount = AMotionEvent_getPointerCount(event);
|
||||
|
||||
unsigned int touchCount = AMotionEvent_getPointerCount(event);
|
||||
for (int i = 1; i < touchCount && i < MAX_TOUCH_POINTS; i++)
|
||||
for (int i = 0; (i < CORE.Input.Touch.pointCount) && (i < MAX_TOUCH_POINTS); i++)
|
||||
{
|
||||
CORE.Input.Touch.position[i].x = AMotionEvent_getX(event, i);
|
||||
CORE.Input.Touch.position[i].y = AMotionEvent_getY(event, i);
|
||||
// Register touch points id
|
||||
CORE.Input.Touch.pointId[i] = AMotionEvent_getPointerId(event, i);
|
||||
|
||||
// Register touch points position
|
||||
CORE.Input.Touch.position[i] = (Vector2){ AMotionEvent_getX(event, i), AMotionEvent_getY(event, i) };
|
||||
|
||||
// Normalize CORE.Input.Touch.position[x] for screenWidth and screenHeight
|
||||
CORE.Input.Touch.position[i].x /= (float)GetScreenWidth();
|
||||
CORE.Input.Touch.position[i].y /= (float)GetScreenHeight();
|
||||
}
|
||||
|
||||
int32_t action = AMotionEvent_getAction(event);
|
||||
unsigned int flags = action & AMOTION_EVENT_ACTION_MASK;
|
||||
|
||||
if (flags == AMOTION_EVENT_ACTION_DOWN || flags == AMOTION_EVENT_ACTION_MOVE)
|
||||
{
|
||||
CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 1;
|
||||
}
|
||||
else if (flags == AMOTION_EVENT_ACTION_UP)
|
||||
{
|
||||
CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 0;
|
||||
}
|
||||
if (flags == AMOTION_EVENT_ACTION_DOWN || flags == AMOTION_EVENT_ACTION_MOVE) CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 1;
|
||||
else if (flags == AMOTION_EVENT_ACTION_UP) CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 0;
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM) // PLATFORM_ANDROID
|
||||
GestureEvent gestureEvent = { 0 };
|
||||
|
||||
gestureEvent.pointCount = CORE.Input.Touch.pointCount;
|
||||
|
||||
// Register touch actions
|
||||
if (flags == AMOTION_EVENT_ACTION_DOWN) gestureEvent.touchAction = TOUCH_DOWN;
|
||||
else if (flags == AMOTION_EVENT_ACTION_UP) gestureEvent.touchAction = TOUCH_UP;
|
||||
else if (flags == AMOTION_EVENT_ACTION_MOVE) gestureEvent.touchAction = TOUCH_MOVE;
|
||||
if (flags == AMOTION_EVENT_ACTION_DOWN) gestureEvent.touchAction = TOUCH_ACTION_DOWN;
|
||||
else if (flags == AMOTION_EVENT_ACTION_UP) gestureEvent.touchAction = TOUCH_ACTION_UP;
|
||||
else if (flags == AMOTION_EVENT_ACTION_MOVE) gestureEvent.touchAction = TOUCH_ACTION_MOVE;
|
||||
else if (flags == AMOTION_EVENT_ACTION_CANCEL) gestureEvent.touchAction = TOUCH_ACTION_CANCEL;
|
||||
|
||||
// Register touch points count
|
||||
// NOTE: Documentation says pointerCount is Always >= 1,
|
||||
// but in practice it can be 0 or over a million
|
||||
gestureEvent.pointCount = AMotionEvent_getPointerCount(event);
|
||||
|
||||
// Only enable gestures for 1-3 touch points
|
||||
if ((gestureEvent.pointCount > 0) && (gestureEvent.pointCount < 4))
|
||||
for (int i = 0; (i < gestureEvent.pointCount) && (i < MAX_TOUCH_POINTS); i++)
|
||||
{
|
||||
// Register touch points id
|
||||
// NOTE: Only two points registered
|
||||
gestureEvent.pointerId[0] = AMotionEvent_getPointerId(event, 0);
|
||||
gestureEvent.pointerId[1] = AMotionEvent_getPointerId(event, 1);
|
||||
|
||||
// Register touch points position
|
||||
gestureEvent.position[0] = (Vector2){ AMotionEvent_getX(event, 0), AMotionEvent_getY(event, 0) };
|
||||
gestureEvent.position[1] = (Vector2){ AMotionEvent_getX(event, 1), AMotionEvent_getY(event, 1) };
|
||||
|
||||
// Normalize gestureEvent.position[x] for screenWidth and screenHeight
|
||||
gestureEvent.position[0].x /= (float)GetScreenWidth();
|
||||
gestureEvent.position[0].y /= (float)GetScreenHeight();
|
||||
|
||||
gestureEvent.position[1].x /= (float)GetScreenWidth();
|
||||
gestureEvent.position[1].y /= (float)GetScreenHeight();
|
||||
gestureEvent.pointId[i] = CORE.Input.Touch.pointId[i];
|
||||
gestureEvent.position[i] = CORE.Input.Touch.position[i];
|
||||
}
|
||||
|
||||
// Gesture data is sent to gestures system for processing
|
||||
ProcessGestureEvent(gestureEvent);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
@ -5346,64 +5359,51 @@ static EM_BOOL EmscriptenMouseCallback(int eventType, const EmscriptenMouseEvent
|
|||
// Register touch input events
|
||||
static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData)
|
||||
{
|
||||
for (int i = 0; i < touchEvent->numTouches; i++)
|
||||
{
|
||||
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) CORE.Input.Touch.currentTouchState[i] = 1;
|
||||
else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) CORE.Input.Touch.currentTouchState[i] = 0;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
GestureEvent gestureEvent = { 0 };
|
||||
|
||||
// Register touch actions
|
||||
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) gestureEvent.touchAction = TOUCH_DOWN;
|
||||
else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) gestureEvent.touchAction = TOUCH_UP;
|
||||
else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) gestureEvent.touchAction = TOUCH_MOVE;
|
||||
|
||||
// Register touch points count
|
||||
gestureEvent.pointCount = touchEvent->numTouches;
|
||||
CORE.Input.Touch.pointCount = touchEvent->numTouches;
|
||||
|
||||
// Register touch points id
|
||||
gestureEvent.pointerId[0] = touchEvent->touches[0].identifier;
|
||||
gestureEvent.pointerId[1] = touchEvent->touches[1].identifier;
|
||||
|
||||
// Register touch points position
|
||||
// NOTE: Only two points registered
|
||||
gestureEvent.position[0] = (Vector2){ touchEvent->touches[0].targetX, touchEvent->touches[0].targetY };
|
||||
gestureEvent.position[1] = (Vector2){ touchEvent->touches[1].targetX, touchEvent->touches[1].targetY };
|
||||
|
||||
double canvasWidth, canvasHeight;
|
||||
double canvasWidth = 0.0;
|
||||
double canvasHeight = 0.0;
|
||||
// NOTE: emscripten_get_canvas_element_size() returns canvas.width and canvas.height but
|
||||
// we are looking for actual CSS size: canvas.style.width and canvas.style.height
|
||||
//EMSCRIPTEN_RESULT res = emscripten_get_canvas_element_size("#canvas", &canvasWidth, &canvasHeight);
|
||||
emscripten_get_element_css_size("#canvas", &canvasWidth, &canvasHeight);
|
||||
|
||||
// Normalize gestureEvent.position[x] for CORE.Window.screen.width and CORE.Window.screen.height
|
||||
gestureEvent.position[0].x *= ((float)GetScreenWidth()/(float)canvasWidth);
|
||||
gestureEvent.position[0].y *= ((float)GetScreenHeight()/(float)canvasHeight);
|
||||
gestureEvent.position[1].x *= ((float)GetScreenWidth()/(float)canvasWidth);
|
||||
gestureEvent.position[1].y *= ((float)GetScreenHeight()/(float)canvasHeight);
|
||||
for (int i = 0; (i < CORE.Input.Touch.pointCount) && (i < MAX_TOUCH_POINTS); i++)
|
||||
{
|
||||
// Register touch points id
|
||||
CORE.Input.Touch.pointId[i] = touchEvent->touches[i].identifier;
|
||||
|
||||
CORE.Input.Touch.position[0] = gestureEvent.position[0];
|
||||
CORE.Input.Touch.position[1] = gestureEvent.position[1];
|
||||
// Register touch points position
|
||||
CORE.Input.Touch.position[i] = (Vector2){ touchEvent->touches[i].targetX, touchEvent->touches[i].targetY };
|
||||
|
||||
// Normalize gestureEvent.position[x] for CORE.Window.screen.width and CORE.Window.screen.height
|
||||
CORE.Input.Touch.position[i].x *= ((float)GetScreenWidth()/(float)canvasWidth);
|
||||
CORE.Input.Touch.position[i].y *= ((float)GetScreenHeight()/(float)canvasHeight);
|
||||
|
||||
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) CORE.Input.Touch.currentTouchState[i] = 1;
|
||||
else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) CORE.Input.Touch.currentTouchState[i] = 0;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM) // PLATFORM_WEB
|
||||
GestureEvent gestureEvent = { 0 };
|
||||
|
||||
gestureEvent.pointCount = CORE.Input.Touch.pointCount;
|
||||
|
||||
// Register touch actions
|
||||
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) gestureEvent.touchAction = TOUCH_ACTION_DOWN;
|
||||
else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) gestureEvent.touchAction = TOUCH_ACTION_UP;
|
||||
else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) gestureEvent.touchAction = TOUCH_ACTION_MOVE;
|
||||
else if (eventType == EMSCRIPTEN_EVENT_TOUCHCANCEL) gestureEvent.touchAction = TOUCH_ACTION_CANCEL;
|
||||
|
||||
for (int i = 0; (i < gestureEvent.pointCount) && (i < MAX_TOUCH_POINTS); i++)
|
||||
{
|
||||
gestureEvent.pointId[i] = CORE.Input.Touch.pointId[i];
|
||||
gestureEvent.position[i] = CORE.Input.Touch.position[i];
|
||||
}
|
||||
|
||||
// Gesture data is sent to gestures system for processing
|
||||
ProcessGestureEvent(gestureEvent);
|
||||
#else
|
||||
// Support only simple touch position
|
||||
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART)
|
||||
{
|
||||
// Get first touch position
|
||||
CORE.Input.Touch.position[0] = (Vector2){ touchEvent->touches[0].targetX, touchEvent->touches[0].targetY };
|
||||
|
||||
double canvasWidth, canvasHeight;
|
||||
//EMSCRIPTEN_RESULT res = emscripten_get_canvas_element_size("#canvas", &canvasWidth, &canvasHeight);
|
||||
emscripten_get_element_css_size("#canvas", &canvasWidth, &canvasHeight);
|
||||
|
||||
// Normalize gestureEvent.position[x] for screenWidth and screenHeight
|
||||
CORE.Input.Touch.position[0].x *= ((float)GetScreenWidth()/(float)canvasWidth);
|
||||
CORE.Input.Touch.position[0].y *= ((float)GetScreenHeight()/(float)canvasHeight);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
|
|
@ -5421,7 +5421,11 @@ static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadE
|
|||
for (int i = 0; i < gamepadEvent->numButtons; ++i) TRACELOGD("Button %d: Digital: %d, Analog: %g", i, gamepadEvent->digitalButton[i], gamepadEvent->analogButton[i]);
|
||||
*/
|
||||
|
||||
if ((gamepadEvent->connected) && (gamepadEvent->index < MAX_GAMEPADS)) CORE.Input.Gamepad.ready[gamepadEvent->index] = true;
|
||||
if ((gamepadEvent->connected) && (gamepadEvent->index < MAX_GAMEPADS))
|
||||
{
|
||||
CORE.Input.Gamepad.ready[gamepadEvent->index] = true;
|
||||
sprintf(CORE.Input.Gamepad.name[gamepadEvent->index],"%s",gamepadEvent->id);
|
||||
}
|
||||
else CORE.Input.Gamepad.ready[gamepadEvent->index] = false;
|
||||
|
||||
// TODO: Test gamepadEvent->index
|
||||
|
|
@ -5923,8 +5927,8 @@ static void *EventThread(void *arg)
|
|||
struct input_event event = { 0 };
|
||||
InputEventWorker *worker = (InputEventWorker *)arg;
|
||||
|
||||
int touchAction = -1;
|
||||
bool gestureUpdate = false;
|
||||
int touchAction = -1; // 0-TOUCH_ACTION_UP, 1-TOUCH_ACTION_DOWN, 2-TOUCH_ACTION_MOVE
|
||||
bool gestureUpdate = false; // Flag to note gestures require to update
|
||||
|
||||
while (!CORE.Window.shouldClose)
|
||||
{
|
||||
|
|
@ -5939,10 +5943,8 @@ static void *EventThread(void *arg)
|
|||
CORE.Input.Mouse.currentPosition.x += event.value;
|
||||
CORE.Input.Touch.position[0].x = CORE.Input.Mouse.currentPosition.x;
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
touchAction = TOUCH_MOVE;
|
||||
touchAction = 2; // TOUCH_ACTION_MOVE
|
||||
gestureUpdate = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (event.code == REL_Y)
|
||||
|
|
@ -5950,10 +5952,8 @@ static void *EventThread(void *arg)
|
|||
CORE.Input.Mouse.currentPosition.y += event.value;
|
||||
CORE.Input.Touch.position[0].y = CORE.Input.Mouse.currentPosition.y;
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
touchAction = TOUCH_MOVE;
|
||||
touchAction = 2; // TOUCH_ACTION_MOVE
|
||||
gestureUpdate = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (event.code == REL_WHEEL) CORE.Input.Mouse.currentWheelMove += event.value;
|
||||
|
|
@ -5968,10 +5968,8 @@ static void *EventThread(void *arg)
|
|||
CORE.Input.Mouse.currentPosition.x = (event.value - worker->absRange.x)*CORE.Window.screen.width/worker->absRange.width; // Scale acording to absRange
|
||||
CORE.Input.Touch.position[0].x = (event.value - worker->absRange.x)*CORE.Window.screen.width/worker->absRange.width; // Scale acording to absRange
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
touchAction = TOUCH_MOVE;
|
||||
touchAction = 2; // TOUCH_ACTION_MOVE
|
||||
gestureUpdate = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (event.code == ABS_Y)
|
||||
|
|
@ -5979,10 +5977,8 @@ static void *EventThread(void *arg)
|
|||
CORE.Input.Mouse.currentPosition.y = (event.value - worker->absRange.y)*CORE.Window.screen.height/worker->absRange.height; // Scale acording to absRange
|
||||
CORE.Input.Touch.position[0].y = (event.value - worker->absRange.y)*CORE.Window.screen.height/worker->absRange.height; // Scale acording to absRange
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
touchAction = TOUCH_MOVE;
|
||||
touchAction = 2; // TOUCH_ACTION_MOVE
|
||||
gestureUpdate = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Multitouch movement
|
||||
|
|
@ -6017,20 +6013,16 @@ static void *EventThread(void *arg)
|
|||
{
|
||||
CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_BUTTON_LEFT] = 0;
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
touchAction = TOUCH_UP;
|
||||
touchAction = 0; // TOUCH_ACTION_UP
|
||||
gestureUpdate = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (event.value && !previousMouseLeftButtonState)
|
||||
{
|
||||
CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_BUTTON_LEFT] = 1;
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
touchAction = TOUCH_DOWN;
|
||||
touchAction = 1; // TOUCH_ACTION_DOWN
|
||||
gestureUpdate = true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -6044,11 +6036,9 @@ static void *EventThread(void *arg)
|
|||
{
|
||||
CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_BUTTON_LEFT] = event.value;
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
if (event.value > 0) touchAction = TOUCH_DOWN;
|
||||
else touchAction = TOUCH_UP;
|
||||
if (event.value > 0) touchAction = 1; // TOUCH_ACTION_DOWN
|
||||
else touchAction = 0; // TOUCH_ACTION_UP
|
||||
gestureUpdate = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (event.code == BTN_RIGHT) CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_BUTTON_RIGHT] = event.value;
|
||||
|
|
@ -6069,7 +6059,7 @@ static void *EventThread(void *arg)
|
|||
if (CORE.Input.Mouse.currentPosition.y > CORE.Window.screen.height/CORE.Input.Mouse.scale.y) CORE.Input.Mouse.currentPosition.y = CORE.Window.screen.height/CORE.Input.Mouse.scale.y;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM) // PLATFORM_RPI, PLATFORM_DRM
|
||||
if (gestureUpdate)
|
||||
{
|
||||
GestureEvent gestureEvent = { 0 };
|
||||
|
|
@ -6082,10 +6072,10 @@ static void *EventThread(void *arg)
|
|||
if (CORE.Input.Touch.position[2].x >= 0) gestureEvent.pointCount++;
|
||||
if (CORE.Input.Touch.position[3].x >= 0) gestureEvent.pointCount++;
|
||||
|
||||
gestureEvent.pointerId[0] = 0;
|
||||
gestureEvent.pointerId[1] = 1;
|
||||
gestureEvent.pointerId[2] = 2;
|
||||
gestureEvent.pointerId[3] = 3;
|
||||
gestureEvent.pointId[0] = 0;
|
||||
gestureEvent.pointId[1] = 1;
|
||||
gestureEvent.pointId[2] = 2;
|
||||
gestureEvent.pointId[3] = 3;
|
||||
|
||||
gestureEvent.position[0] = CORE.Input.Touch.position[0];
|
||||
gestureEvent.position[1] = CORE.Input.Touch.position[1];
|
||||
|
|
@ -6627,7 +6617,7 @@ static void PlayAutomationEvent(unsigned int frame)
|
|||
{
|
||||
CORE.Input.Gamepad.axisState[events[i].params[0]][events[i].params[1]] = ((float)events[i].params[2]/32768.0f);
|
||||
} break;
|
||||
case INPUT_GESTURE: GESTURES.current = events[i].params[0]; break; // param[0]: gesture (enum Gesture) -> gestures.h: GESTURES.current
|
||||
case INPUT_GESTURE: GESTURES.current = events[i].params[0]; break; // param[0]: gesture (enum Gesture) -> rgestures.h: GESTURES.current
|
||||
|
||||
// Window events
|
||||
case WINDOW_CLOSE: CORE.Window.shouldClose = true; break;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* raylib.gestures - Gestures system, gestures processing based on input events (touch/mouse)
|
||||
* rgestures - Gestures system, gestures processing based on input events (touch/mouse)
|
||||
*
|
||||
* NOTE: Memory footprint of this library is aproximately 128 bytes (global variables)
|
||||
*
|
||||
|
|
@ -43,8 +43,8 @@
|
|||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#ifndef GESTURES_H
|
||||
#define GESTURES_H
|
||||
#ifndef RGESTURES_H
|
||||
#define RGESTURES_H
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979323846
|
||||
|
|
@ -53,24 +53,30 @@
|
|||
//----------------------------------------------------------------------------------
|
||||
// Defines and Macros
|
||||
//----------------------------------------------------------------------------------
|
||||
//...
|
||||
#ifndef MAX_TOUCH_POINTS
|
||||
#define MAX_TOUCH_POINTS 8 // Maximum number of touch points supported
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
// NOTE: Below types are required for GESTURES_STANDALONE usage
|
||||
//----------------------------------------------------------------------------------
|
||||
#if defined(GESTURES_STANDALONE)
|
||||
#ifndef __cplusplus
|
||||
// Boolean type
|
||||
typedef enum { false, true } bool;
|
||||
#if defined(__STDC__) && __STDC_VERSION__ >= 199901L
|
||||
#include <stdbool.h>
|
||||
#elif !defined(__cplusplus) && !defined(bool) && !defined(RL_BOOL_TYPE)
|
||||
typedef enum bool { false, true } bool;
|
||||
#endif
|
||||
|
||||
#if !defined(RL_VECTOR2_TYPE)
|
||||
// Vector2 type
|
||||
typedef struct Vector2 {
|
||||
float x;
|
||||
float y;
|
||||
} Vector2;
|
||||
#endif
|
||||
|
||||
#if defined(GESTURES_STANDALONE)
|
||||
// Gestures type
|
||||
// NOTE: It could be used as flags to enable only some gestures
|
||||
typedef enum {
|
||||
|
|
@ -85,18 +91,22 @@
|
|||
GESTURE_SWIPE_DOWN = 128,
|
||||
GESTURE_PINCH_IN = 256,
|
||||
GESTURE_PINCH_OUT = 512
|
||||
} Gestures;
|
||||
} Gesture;
|
||||
#endif
|
||||
|
||||
typedef enum { TOUCH_UP, TOUCH_DOWN, TOUCH_MOVE } TouchAction;
|
||||
typedef enum {
|
||||
TOUCH_ACTION_UP = 0,
|
||||
TOUCH_ACTION_DOWN,
|
||||
TOUCH_ACTION_MOVE,
|
||||
TOUCH_ACTION_CANCEL
|
||||
} TouchAction;
|
||||
|
||||
// Gesture event
|
||||
// NOTE: MAX_TOUCH_POINTS fixed to 4
|
||||
typedef struct {
|
||||
int touchAction;
|
||||
int pointCount;
|
||||
int pointerId[4];
|
||||
Vector2 position[4];
|
||||
int pointId[MAX_TOUCH_POINTS];
|
||||
Vector2 position[MAX_TOUCH_POINTS];
|
||||
} GestureEvent;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
@ -114,11 +124,12 @@ extern "C" { // Prevents name mangling of functions
|
|||
|
||||
void ProcessGestureEvent(GestureEvent event); // Process gesture event and translate it into gestures
|
||||
void UpdateGestures(void); // Update gestures detected (must be called every frame)
|
||||
|
||||
#if defined(GESTURES_STANDALONE)
|
||||
void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags
|
||||
bool IsGestureDetected(int gesture); // Check if a gesture have been detected
|
||||
int GetGestureDetected(void); // Get latest detected gesture
|
||||
int GetTouchPointCount(void); // Get touch points count
|
||||
|
||||
float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds
|
||||
Vector2 GetGestureDragVector(void); // Get gesture drag vector
|
||||
float GetGestureDragAngle(void); // Get gesture drag angle
|
||||
|
|
@ -193,7 +204,7 @@ typedef struct {
|
|||
Vector2 downDragPosition; // Touch drag position
|
||||
Vector2 moveDownPositionA; // First touch down position on move
|
||||
Vector2 moveDownPositionB; // Second touch down position on move
|
||||
int tapCounter; // TAP counter (one tap implies TOUCH_DOWN and TOUCH_UP actions)
|
||||
int tapCounter; // TAP counter (one tap implies TOUCH_ACTION_DOWN and TOUCH_ACTION_UP actions)
|
||||
} Touch;
|
||||
struct {
|
||||
bool resetRequired; // HOLD reset to get first touch point again
|
||||
|
|
@ -228,12 +239,9 @@ static GesturesData GESTURES = {
|
|||
//----------------------------------------------------------------------------------
|
||||
// Module specific Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
#if defined(GESTURES_STANDALONE)
|
||||
// Some required math functions provided by raymath.h
|
||||
static float Vector2Angle(Vector2 initialPosition, Vector2 finalPosition);
|
||||
static float Vector2Distance(Vector2 v1, Vector2 v2);
|
||||
#endif
|
||||
static double GetCurrentTime(void);
|
||||
static float rgVector2Angle(Vector2 initialPosition, Vector2 finalPosition);
|
||||
static float rgVector2Distance(Vector2 v1, Vector2 v2);
|
||||
static double rgGetCurrentTime(void);
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition
|
||||
|
|
@ -258,14 +266,14 @@ void ProcessGestureEvent(GestureEvent event)
|
|||
// Reset required variables
|
||||
GESTURES.Touch.pointCount = event.pointCount; // Required on UpdateGestures()
|
||||
|
||||
if (GESTURES.Touch.pointCount < 2)
|
||||
if (GESTURES.Touch.pointCount == 1) // One touch point
|
||||
{
|
||||
if (event.touchAction == TOUCH_DOWN)
|
||||
if (event.touchAction == TOUCH_ACTION_DOWN)
|
||||
{
|
||||
GESTURES.Touch.tapCounter++; // Tap counter
|
||||
|
||||
// Detect GESTURE_DOUBLE_TAP
|
||||
if ((GESTURES.current == GESTURE_NONE) && (GESTURES.Touch.tapCounter >= 2) && ((GetCurrentTime() - GESTURES.Touch.eventTime) < TAP_TIMEOUT) && (Vector2Distance(GESTURES.Touch.downPositionA, event.position[0]) < DOUBLETAP_RANGE))
|
||||
if ((GESTURES.current == GESTURE_NONE) && (GESTURES.Touch.tapCounter >= 2) && ((rgGetCurrentTime() - GESTURES.Touch.eventTime) < TAP_TIMEOUT) && (rgVector2Distance(GESTURES.Touch.downPositionA, event.position[0]) < DOUBLETAP_RANGE))
|
||||
{
|
||||
GESTURES.current = GESTURE_DOUBLETAP;
|
||||
GESTURES.Touch.tapCounter = 0;
|
||||
|
|
@ -280,27 +288,27 @@ void ProcessGestureEvent(GestureEvent event)
|
|||
GESTURES.Touch.downDragPosition = event.position[0];
|
||||
|
||||
GESTURES.Touch.upPosition = GESTURES.Touch.downPositionA;
|
||||
GESTURES.Touch.eventTime = GetCurrentTime();
|
||||
GESTURES.Touch.eventTime = rgGetCurrentTime();
|
||||
|
||||
GESTURES.Touch.firstId = event.pointerId[0];
|
||||
GESTURES.Touch.firstId = event.pointId[0];
|
||||
|
||||
GESTURES.Drag.vector = (Vector2){ 0.0f, 0.0f };
|
||||
}
|
||||
else if (event.touchAction == TOUCH_UP)
|
||||
else if (event.touchAction == TOUCH_ACTION_UP)
|
||||
{
|
||||
if (GESTURES.current == GESTURE_DRAG) GESTURES.Touch.upPosition = event.position[0];
|
||||
|
||||
// NOTE: GESTURES.Drag.intensity dependend on the resolution of the screen
|
||||
GESTURES.Drag.distance = Vector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition);
|
||||
GESTURES.Drag.intensity = GESTURES.Drag.distance/(float)((GetCurrentTime() - GESTURES.Swipe.timeDuration));
|
||||
GESTURES.Drag.distance = rgVector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition);
|
||||
GESTURES.Drag.intensity = GESTURES.Drag.distance/(float)((rgGetCurrentTime() - GESTURES.Swipe.timeDuration));
|
||||
|
||||
GESTURES.Swipe.start = false;
|
||||
|
||||
// Detect GESTURE_SWIPE
|
||||
if ((GESTURES.Drag.intensity > FORCE_TO_SWIPE) && (GESTURES.Touch.firstId == event.pointerId[0]))
|
||||
if ((GESTURES.Drag.intensity > FORCE_TO_SWIPE) && (GESTURES.Touch.firstId == event.pointId[0]))
|
||||
{
|
||||
// NOTE: Angle should be inverted in Y
|
||||
GESTURES.Drag.angle = 360.0f - Vector2Angle(GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition);
|
||||
GESTURES.Drag.angle = 360.0f - rgVector2Angle(GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition);
|
||||
|
||||
if ((GESTURES.Drag.angle < 30) || (GESTURES.Drag.angle > 330)) GESTURES.current = GESTURE_SWIPE_RIGHT; // Right
|
||||
else if ((GESTURES.Drag.angle > 30) && (GESTURES.Drag.angle < 120)) GESTURES.current = GESTURE_SWIPE_UP; // Up
|
||||
|
|
@ -320,13 +328,13 @@ void ProcessGestureEvent(GestureEvent event)
|
|||
GESTURES.Touch.downDragPosition = (Vector2){ 0.0f, 0.0f };
|
||||
GESTURES.Touch.pointCount = 0;
|
||||
}
|
||||
else if (event.touchAction == TOUCH_MOVE)
|
||||
else if (event.touchAction == TOUCH_ACTION_MOVE)
|
||||
{
|
||||
if (GESTURES.current == GESTURE_DRAG) GESTURES.Touch.eventTime = GetCurrentTime();
|
||||
if (GESTURES.current == GESTURE_DRAG) GESTURES.Touch.eventTime = rgGetCurrentTime();
|
||||
|
||||
if (!GESTURES.Swipe.start)
|
||||
{
|
||||
GESTURES.Swipe.timeDuration = GetCurrentTime();
|
||||
GESTURES.Swipe.timeDuration = rgGetCurrentTime();
|
||||
GESTURES.Swipe.start = true;
|
||||
}
|
||||
|
||||
|
|
@ -339,9 +347,9 @@ void ProcessGestureEvent(GestureEvent event)
|
|||
GESTURES.Hold.resetRequired = false;
|
||||
|
||||
// Detect GESTURE_DRAG
|
||||
if (Vector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.moveDownPositionA) >= MINIMUM_DRAG)
|
||||
if (rgVector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.moveDownPositionA) >= MINIMUM_DRAG)
|
||||
{
|
||||
GESTURES.Touch.eventTime = GetCurrentTime();
|
||||
GESTURES.Touch.eventTime = rgGetCurrentTime();
|
||||
GESTURES.current = GESTURE_DRAG;
|
||||
}
|
||||
}
|
||||
|
|
@ -350,24 +358,24 @@ void ProcessGestureEvent(GestureEvent event)
|
|||
GESTURES.Drag.vector.y = GESTURES.Touch.moveDownPositionA.y - GESTURES.Touch.downDragPosition.y;
|
||||
}
|
||||
}
|
||||
else // Two touch points
|
||||
else if (GESTURES.Touch.pointCount == 2) // Two touch points
|
||||
{
|
||||
if (event.touchAction == TOUCH_DOWN)
|
||||
if (event.touchAction == TOUCH_ACTION_DOWN)
|
||||
{
|
||||
GESTURES.Touch.downPositionA = event.position[0];
|
||||
GESTURES.Touch.downPositionB = event.position[1];
|
||||
|
||||
//GESTURES.Pinch.distance = Vector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.downPositionB);
|
||||
//GESTURES.Pinch.distance = rgVector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.downPositionB);
|
||||
|
||||
GESTURES.Pinch.vector.x = GESTURES.Touch.downPositionB.x - GESTURES.Touch.downPositionA.x;
|
||||
GESTURES.Pinch.vector.y = GESTURES.Touch.downPositionB.y - GESTURES.Touch.downPositionA.y;
|
||||
|
||||
GESTURES.current = GESTURE_HOLD;
|
||||
GESTURES.Hold.timeDuration = GetCurrentTime();
|
||||
GESTURES.Hold.timeDuration = rgGetCurrentTime();
|
||||
}
|
||||
else if (event.touchAction == TOUCH_MOVE)
|
||||
else if (event.touchAction == TOUCH_ACTION_MOVE)
|
||||
{
|
||||
GESTURES.Pinch.distance = Vector2Distance(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB);
|
||||
GESTURES.Pinch.distance = rgVector2Distance(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB);
|
||||
|
||||
GESTURES.Touch.downPositionA = GESTURES.Touch.moveDownPositionA;
|
||||
GESTURES.Touch.downPositionB = GESTURES.Touch.moveDownPositionB;
|
||||
|
|
@ -378,21 +386,21 @@ void ProcessGestureEvent(GestureEvent event)
|
|||
GESTURES.Pinch.vector.x = GESTURES.Touch.moveDownPositionB.x - GESTURES.Touch.moveDownPositionA.x;
|
||||
GESTURES.Pinch.vector.y = GESTURES.Touch.moveDownPositionB.y - GESTURES.Touch.moveDownPositionA.y;
|
||||
|
||||
if ((Vector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.moveDownPositionA) >= MINIMUM_PINCH) || (Vector2Distance(GESTURES.Touch.downPositionB, GESTURES.Touch.moveDownPositionB) >= MINIMUM_PINCH))
|
||||
if ((rgVector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.moveDownPositionA) >= MINIMUM_PINCH) || (rgVector2Distance(GESTURES.Touch.downPositionB, GESTURES.Touch.moveDownPositionB) >= MINIMUM_PINCH))
|
||||
{
|
||||
if ((Vector2Distance(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB) - GESTURES.Pinch.distance) < 0) GESTURES.current = GESTURE_PINCH_IN;
|
||||
if ((rgVector2Distance(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB) - GESTURES.Pinch.distance) < 0) GESTURES.current = GESTURE_PINCH_IN;
|
||||
else GESTURES.current = GESTURE_PINCH_OUT;
|
||||
}
|
||||
else
|
||||
{
|
||||
GESTURES.current = GESTURE_HOLD;
|
||||
GESTURES.Hold.timeDuration = GetCurrentTime();
|
||||
GESTURES.Hold.timeDuration = rgGetCurrentTime();
|
||||
}
|
||||
|
||||
// NOTE: Angle should be inverted in Y
|
||||
GESTURES.Pinch.angle = 360.0f - Vector2Angle(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB);
|
||||
GESTURES.Pinch.angle = 360.0f - rgVector2Angle(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB);
|
||||
}
|
||||
else if (event.touchAction == TOUCH_UP)
|
||||
else if (event.touchAction == TOUCH_ACTION_UP)
|
||||
{
|
||||
GESTURES.Pinch.distance = 0.0f;
|
||||
GESTURES.Pinch.angle = 0.0f;
|
||||
|
|
@ -402,6 +410,10 @@ void ProcessGestureEvent(GestureEvent event)
|
|||
GESTURES.current = GESTURE_NONE;
|
||||
}
|
||||
}
|
||||
else if (GESTURES.Touch.pointCount > 2) // More than two touch points
|
||||
{
|
||||
// TODO.
|
||||
}
|
||||
}
|
||||
|
||||
// Update gestures detected (must be called every frame)
|
||||
|
|
@ -413,13 +425,13 @@ void UpdateGestures(void)
|
|||
if (((GESTURES.current == GESTURE_TAP) || (GESTURES.current == GESTURE_DOUBLETAP)) && (GESTURES.Touch.pointCount < 2))
|
||||
{
|
||||
GESTURES.current = GESTURE_HOLD;
|
||||
GESTURES.Hold.timeDuration = GetCurrentTime();
|
||||
GESTURES.Hold.timeDuration = rgGetCurrentTime();
|
||||
}
|
||||
|
||||
if (((GetCurrentTime() - GESTURES.Touch.eventTime) > TAP_TIMEOUT) && (GESTURES.current == GESTURE_DRAG) && (GESTURES.Touch.pointCount < 2))
|
||||
if (((rgGetCurrentTime() - GESTURES.Touch.eventTime) > TAP_TIMEOUT) && (GESTURES.current == GESTURE_DRAG) && (GESTURES.Touch.pointCount < 2))
|
||||
{
|
||||
GESTURES.current = GESTURE_HOLD;
|
||||
GESTURES.Hold.timeDuration = GetCurrentTime();
|
||||
GESTURES.Hold.timeDuration = rgGetCurrentTime();
|
||||
GESTURES.Hold.resetRequired = true;
|
||||
}
|
||||
|
||||
|
|
@ -430,14 +442,6 @@ void UpdateGestures(void)
|
|||
}
|
||||
}
|
||||
|
||||
// Get number of touch points
|
||||
int GetTouchPointCount(void)
|
||||
{
|
||||
// NOTE: point count is calculated when ProcessGestureEvent(GestureEvent event) is called
|
||||
|
||||
return GESTURES.Touch.pointCount;
|
||||
}
|
||||
|
||||
// Get latest detected gesture
|
||||
int GetGestureDetected(void)
|
||||
{
|
||||
|
|
@ -452,7 +456,7 @@ float GetGestureHoldDuration(void)
|
|||
|
||||
double time = 0.0;
|
||||
|
||||
if (GESTURES.current == GESTURE_HOLD) time = GetCurrentTime() - GESTURES.Hold.timeDuration;
|
||||
if (GESTURES.current == GESTURE_HOLD) time = rgGetCurrentTime() - GESTURES.Hold.timeDuration;
|
||||
|
||||
return (float)time;
|
||||
}
|
||||
|
|
@ -460,7 +464,7 @@ float GetGestureHoldDuration(void)
|
|||
// Get drag vector (between initial touch point to current)
|
||||
Vector2 GetGestureDragVector(void)
|
||||
{
|
||||
// NOTE: drag vector is calculated on one touch points TOUCH_MOVE
|
||||
// NOTE: drag vector is calculated on one touch points TOUCH_ACTION_MOVE
|
||||
|
||||
return GESTURES.Drag.vector;
|
||||
}
|
||||
|
|
@ -469,7 +473,7 @@ Vector2 GetGestureDragVector(void)
|
|||
// NOTE: Angle in degrees, horizontal-right is 0, counterclock-wise
|
||||
float GetGestureDragAngle(void)
|
||||
{
|
||||
// NOTE: drag angle is calculated on one touch points TOUCH_UP
|
||||
// NOTE: drag angle is calculated on one touch points TOUCH_ACTION_UP
|
||||
|
||||
return GESTURES.Drag.angle;
|
||||
}
|
||||
|
|
@ -477,8 +481,7 @@ float GetGestureDragAngle(void)
|
|||
// Get distance between two pinch points
|
||||
Vector2 GetGesturePinchVector(void)
|
||||
{
|
||||
// NOTE: The position values used for GESTURES.Pinch.distance are not modified like the position values of [core.c]-->GetTouchPosition(int index)
|
||||
// NOTE: pinch distance is calculated on two touch points TOUCH_MOVE
|
||||
// NOTE: Pinch distance is calculated on two touch points TOUCH_ACTION_MOVE
|
||||
|
||||
return GESTURES.Pinch.vector;
|
||||
}
|
||||
|
|
@ -487,7 +490,7 @@ Vector2 GetGesturePinchVector(void)
|
|||
// NOTE: Angle in degrees, horizontal-right is 0, counterclock-wise
|
||||
float GetGesturePinchAngle(void)
|
||||
{
|
||||
// NOTE: pinch angle is calculated on two touch points TOUCH_MOVE
|
||||
// NOTE: pinch angle is calculated on two touch points TOUCH_ACTION_MOVE
|
||||
|
||||
return GESTURES.Pinch.angle;
|
||||
}
|
||||
|
|
@ -495,9 +498,8 @@ float GetGesturePinchAngle(void)
|
|||
//----------------------------------------------------------------------------------
|
||||
// Module specific Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
#if defined(GESTURES_STANDALONE)
|
||||
// Get angle from two-points vector with X-axis
|
||||
static float Vector2Angle(Vector2 v1, Vector2 v2)
|
||||
static float rgVector2Angle(Vector2 v1, Vector2 v2)
|
||||
{
|
||||
float angle = atan2f(v2.y - v1.y, v2.x - v1.x)*(180.0f/PI);
|
||||
|
||||
|
|
@ -507,7 +509,7 @@ static float Vector2Angle(Vector2 v1, Vector2 v2)
|
|||
}
|
||||
|
||||
// Calculate distance between two Vector2
|
||||
static float Vector2Distance(Vector2 v1, Vector2 v2)
|
||||
static float rgVector2Distance(Vector2 v1, Vector2 v2)
|
||||
{
|
||||
float result;
|
||||
|
||||
|
|
@ -518,10 +520,9 @@ static float Vector2Distance(Vector2 v1, Vector2 v2)
|
|||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Time measure returned are milliseconds
|
||||
static double GetCurrentTime(void)
|
||||
static double rgGetCurrentTime(void)
|
||||
{
|
||||
double time = 0;
|
||||
|
||||
|
|
@ -3028,8 +3028,6 @@ void *rlReadTexturePixels(unsigned int id, int width, int height, int format)
|
|||
// NOTE: This behaviour could be conditioned by graphic driver...
|
||||
unsigned int fboId = rlLoadFramebuffer(width, height);
|
||||
|
||||
// TODO: Create depth texture/renderbuffer for fbo?
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fboId);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* raylib.models - Basic functions to deal with 3d shapes and 3d models
|
||||
* rmodels - Basic functions to draw 3d shapes and load and draw 3d models
|
||||
*
|
||||
* CONFIGURATION:
|
||||
*
|
||||
|
|
@ -8,6 +8,8 @@
|
|||
* #define SUPPORT_FILEFORMAT_MTL
|
||||
* #define SUPPORT_FILEFORMAT_IQM
|
||||
* #define SUPPORT_FILEFORMAT_GLTF
|
||||
* #define SUPPORT_FILEFORMAT_VOX
|
||||
*
|
||||
* Selected desired fileformats to be supported for model data loading.
|
||||
*
|
||||
* #define SUPPORT_MESH_GENERATION
|
||||
|
|
@ -68,7 +70,16 @@
|
|||
|
||||
#define CGLTF_IMPLEMENTATION
|
||||
#include "external/cgltf.h" // glTF file format loading
|
||||
#include "external/stb_image.h" // glTF texture images loading
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_VOX)
|
||||
#define VOX_MALLOC RL_MALLOC
|
||||
#define VOX_CALLOC RL_CALLOC
|
||||
#define VOX_REALLOC RL_REALLOC
|
||||
#define VOX_FREE RL_FREE
|
||||
|
||||
#define VOX_LOADER_IMPLEMENTATION
|
||||
#include "external/vox_loader.h" // vox file format loading (MagikaVoxel)
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_MESH_GENERATION)
|
||||
|
|
@ -117,11 +128,11 @@ static Model LoadOBJ(const char *fileName); // Load OBJ mesh data
|
|||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_IQM)
|
||||
static Model LoadIQM(const char *fileName); // Load IQM mesh data
|
||||
static ModelAnimation *LoadIQMModelAnimations(const char *fileName, int *animCount); // Load IQM animation data
|
||||
static ModelAnimation *LoadIQMModelAnimations(const char *fileName, unsigned int *animCount); // Load IQM animation data
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_GLTF)
|
||||
static Model LoadGLTF(const char *fileName); // Load GLTF mesh data
|
||||
static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCount); // Load GLTF animation data
|
||||
static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, unsigned int *animCount); // Load GLTF animation data
|
||||
static void LoadGLTFMaterial(Model *model, const char *fileName, const cgltf_data *data);
|
||||
static void LoadGLTFMesh(cgltf_data *data, cgltf_node *node, Model *outModel, Matrix currentTransform, int *primitiveIndex, const char *fileName);
|
||||
static void LoadGLTFNode(cgltf_data *data, cgltf_node *node, Model *outModel, Matrix currentTransform, int *primitiveIndex, const char *fileName);
|
||||
|
|
@ -132,6 +143,9 @@ static bool ReadGLTFValue(cgltf_accessor *acc, unsigned int index, void *variabl
|
|||
static void *ReadGLTFValuesAs(cgltf_accessor *acc, cgltf_component_type type, bool adjustOnDownCasting);
|
||||
static Matrix GetNodeTransformationMatrix(cgltf_node *node, Matrix current);
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_VOX)
|
||||
static Model LoadVOX(const char *filename); // Load VOX mesh data
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition
|
||||
|
|
@ -450,6 +464,157 @@ void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float hei
|
|||
rlSetTexture(0);
|
||||
}
|
||||
|
||||
void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color)
|
||||
{
|
||||
float x = position.x;
|
||||
float y = position.y;
|
||||
float z = position.z;
|
||||
float texture_width = (float)texture.width;
|
||||
float texture_height = (float)texture.height;
|
||||
|
||||
rlCheckRenderBatchLimit(36);
|
||||
|
||||
rlSetTexture(texture.id);
|
||||
|
||||
rlBegin(RL_QUADS);
|
||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||
|
||||
// Front Face
|
||||
{
|
||||
// Normal Pointing Towards Viewer
|
||||
rlNormal3f(0.0f, 0.0f, 1.0f);
|
||||
|
||||
// Bottom Left Of The Texture and Quad
|
||||
rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
|
||||
rlVertex3f(x - width/2, y - height/2, z + length/2);
|
||||
|
||||
// Bottom Right Of The Texture and Quad
|
||||
rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
|
||||
rlVertex3f(x + width/2, y - height/2, z + length/2);
|
||||
|
||||
// Top Right Of The Texture and Quad
|
||||
rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
|
||||
rlVertex3f(x + width/2, y + height/2, z + length/2);
|
||||
|
||||
// Top Left Of The Texture and Quad
|
||||
rlTexCoord2f(source.x / texture_width, source.y / texture_height);
|
||||
rlVertex3f(x - width/2, y + height/2, z + length/2);
|
||||
}
|
||||
|
||||
// Back Face
|
||||
{
|
||||
// Normal Pointing Away From Viewer
|
||||
rlNormal3f(0.0f, 0.0f, - 1.0f);
|
||||
|
||||
// Bottom Right Of The Texture and Quad
|
||||
rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
|
||||
rlVertex3f(x - width/2, y - height/2, z - length/2);
|
||||
|
||||
// Top Right Of The Texture and Quad
|
||||
rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
|
||||
rlVertex3f(x - width/2, y + height/2, z - length/2);
|
||||
|
||||
// Top Left Of The Texture and Quad
|
||||
rlTexCoord2f(source.x / texture_width, source.y / texture_height);
|
||||
rlVertex3f(x + width/2, y + height/2, z - length/2);
|
||||
|
||||
// Bottom Left Of The Texture and Quad
|
||||
rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
|
||||
rlVertex3f(x + width/2, y - height/2, z - length/2);
|
||||
}
|
||||
|
||||
// Top Face
|
||||
{
|
||||
// Normal Pointing Up
|
||||
rlNormal3f(0.0f, 1.0f, 0.0f);
|
||||
|
||||
// Top Left Of The Texture and Quad
|
||||
rlTexCoord2f(source.x / texture_width, source.y / texture_height);
|
||||
rlVertex3f(x - width/2, y + height/2, z - length/2);
|
||||
|
||||
// Bottom Left Of The Texture and Quad
|
||||
rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
|
||||
rlVertex3f(x - width/2, y + height/2, z + length/2);
|
||||
|
||||
// Bottom Right Of The Texture and Quad
|
||||
rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
|
||||
rlVertex3f(x + width/2, y + height/2, z + length/2);
|
||||
|
||||
// Top Right Of The Texture and Quad
|
||||
rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
|
||||
rlVertex3f(x + width/2, y + height/2, z - length/2);
|
||||
}
|
||||
|
||||
// Bottom Face
|
||||
{
|
||||
// Normal Pointing Down
|
||||
rlNormal3f(0.0f, - 1.0f, 0.0f);
|
||||
|
||||
// Top Right Of The Texture and Quad
|
||||
rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
|
||||
rlVertex3f(x - width/2, y - height/2, z - length/2);
|
||||
|
||||
// Top Left Of The Texture and Quad
|
||||
rlTexCoord2f(source.x / texture_width, source.y / texture_height);
|
||||
rlVertex3f(x + width/2, y - height/2, z - length/2);
|
||||
|
||||
// Bottom Left Of The Texture and Quad
|
||||
rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
|
||||
rlVertex3f(x + width/2, y - height/2, z + length/2);
|
||||
|
||||
// Bottom Right Of The Texture and Quad
|
||||
rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
|
||||
rlVertex3f(x - width/2, y - height/2, z + length/2);
|
||||
}
|
||||
|
||||
// Right face
|
||||
{
|
||||
// Normal Pointing Right
|
||||
rlNormal3f(1.0f, 0.0f, 0.0f);
|
||||
|
||||
// Bottom Right Of The Texture and Quad
|
||||
rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
|
||||
rlVertex3f(x + width/2, y - height/2, z - length/2);
|
||||
|
||||
// Top Right Of The Texture and Quad
|
||||
rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
|
||||
rlVertex3f(x + width/2, y + height/2, z - length/2);
|
||||
|
||||
// Top Left Of The Texture and Quad
|
||||
rlTexCoord2f(source.x / texture_width, source.y / texture_height);
|
||||
rlVertex3f(x + width/2, y + height/2, z + length/2);
|
||||
|
||||
// Bottom Left Of The Texture and Quad
|
||||
rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
|
||||
rlVertex3f(x + width/2, y - height/2, z + length/2);
|
||||
}
|
||||
|
||||
// Left Face
|
||||
{
|
||||
// Normal Pointing Left
|
||||
rlNormal3f( - 1.0f, 0.0f, 0.0f);
|
||||
|
||||
// Bottom Left Of The Texture and Quad
|
||||
rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
|
||||
rlVertex3f(x - width/2, y - height/2, z - length/2);
|
||||
|
||||
// Bottom Right Of The Texture and Quad
|
||||
rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
|
||||
rlVertex3f(x - width/2, y - height/2, z + length/2);
|
||||
|
||||
// Top Right Of The Texture and Quad
|
||||
rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
|
||||
rlVertex3f(x - width/2, y + height/2, z + length/2);
|
||||
|
||||
// Top Left Of The Texture and Quad
|
||||
rlTexCoord2f(source.x / texture_width, source.y / texture_height);
|
||||
rlVertex3f(x - width/2, y + height/2, z - length/2);
|
||||
}
|
||||
rlEnd();
|
||||
|
||||
rlSetTexture(0);
|
||||
}
|
||||
|
||||
// Draw sphere
|
||||
void DrawSphere(Vector3 centerPos, float radius, Color color)
|
||||
{
|
||||
|
|
@ -719,6 +884,9 @@ Model LoadModel(const char *fileName)
|
|||
#if defined(SUPPORT_FILEFORMAT_GLTF)
|
||||
if (IsFileExtension(fileName, ".gltf;.glb")) model = LoadGLTF(fileName);
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_VOX)
|
||||
if (IsFileExtension(fileName, ".vox")) model = LoadVOX(fileName);
|
||||
#endif
|
||||
|
||||
// Make sure model transform is set to identity matrix!
|
||||
model.transform = MatrixIdentity();
|
||||
|
|
@ -1591,7 +1759,7 @@ void SetModelMeshMaterial(Model *model, int meshId, int materialId)
|
|||
}
|
||||
|
||||
// Load model animations from file
|
||||
ModelAnimation *LoadModelAnimations(const char *fileName, int *animCount)
|
||||
ModelAnimation *LoadModelAnimations(const char *fileName, unsigned int *animCount)
|
||||
{
|
||||
ModelAnimation *animations = NULL;
|
||||
|
||||
|
|
@ -3169,10 +3337,13 @@ void DrawBillboard(Camera camera, Texture2D texture, Vector3 position, float siz
|
|||
// Draw a billboard (part of a texture defined by a rectangle)
|
||||
void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Color tint)
|
||||
{
|
||||
DrawBillboardPro(camera, texture, source, position, size, Vector2Zero(), 0.0f, tint);
|
||||
// NOTE: Billboard locked on axis-Y
|
||||
Vector3 up = { 0.0f, 1.0f, 0.0f };
|
||||
|
||||
DrawBillboardPro(camera, texture, source, position, up, size, Vector2Zero(), 0.0f, tint);
|
||||
}
|
||||
|
||||
void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Vector2 origin, float rotation, Color tint)
|
||||
void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint)
|
||||
{
|
||||
// NOTE: Billboard size will maintain source rectangle aspect ratio, size will represent billboard width
|
||||
Vector2 sizeRatio = { size.y, size.x*(float)source.height/source.width };
|
||||
|
|
@ -3182,9 +3353,6 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
|
|||
Vector3 right = { matView.m0, matView.m4, matView.m8 };
|
||||
//Vector3 up = { matView.m1, matView.m5, matView.m9 };
|
||||
|
||||
// NOTE: Billboard locked on axis-Y
|
||||
Vector3 up = { 0.0f, 1.0f, 0.0f };
|
||||
|
||||
Vector3 rightScaled = Vector3Scale(right, sizeRatio.x/2);
|
||||
Vector3 upScaled = Vector3Scale(up, sizeRatio.y/2);
|
||||
|
||||
|
|
@ -3634,15 +3802,24 @@ static Model LoadOBJ(const char *fileName)
|
|||
model.meshMaterial = (int *)RL_CALLOC(model.meshCount, sizeof(int));
|
||||
|
||||
// Count the faces for each material
|
||||
int *matFaces = RL_CALLOC(materialCount, sizeof(int));
|
||||
int *matFaces = RL_CALLOC(model.meshCount, sizeof(int));
|
||||
|
||||
// iff no materials are present use all faces on one mesh
|
||||
if (materialCount > 0)
|
||||
{
|
||||
for (int fi = 0; fi< attrib.num_faces; fi++)
|
||||
{
|
||||
tinyobj_vertex_index_t face = attrib.faces[fi];
|
||||
//tinyobj_vertex_index_t face = attrib.faces[fi];
|
||||
int idx = attrib.material_ids[fi];
|
||||
matFaces[idx]++;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
matFaces[0] = attrib.num_faces;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
// Create the material meshes
|
||||
|
||||
|
|
@ -4135,7 +4312,7 @@ static Model LoadIQM(const char *fileName)
|
|||
}
|
||||
|
||||
// Load IQM animation data
|
||||
static ModelAnimation* LoadIQMModelAnimations(const char *fileName, int *animCount)
|
||||
static ModelAnimation* LoadIQMModelAnimations(const char *fileName, unsigned int *animCount)
|
||||
{
|
||||
#define IQM_MAGIC "INTERQUAKEMODEL" // IQM file magic number
|
||||
#define IQM_VERSION 2 // only IQM version 2 supported
|
||||
|
|
@ -4445,16 +4622,9 @@ static Image LoadImageFromCgltfImage(cgltf_image *image, const char *texPath, Co
|
|||
int size = 0;
|
||||
unsigned char *data = DecodeBase64(image->uri + i + 1, &size);
|
||||
|
||||
int width, height;
|
||||
unsigned char *raw = stbi_load_from_memory(data, size, &width, &height, NULL, 4);
|
||||
rimage = LoadImageFromMemory(".png", data, size);
|
||||
RL_FREE(data);
|
||||
|
||||
rimage.data = raw;
|
||||
rimage.width = width;
|
||||
rimage.height = height;
|
||||
rimage.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
|
||||
rimage.mipmaps = 1;
|
||||
|
||||
// TODO: Tint shouldn't be applied here!
|
||||
ImageColorTint(&rimage, tint);
|
||||
}
|
||||
|
|
@ -4479,16 +4649,9 @@ static Image LoadImageFromCgltfImage(cgltf_image *image, const char *texPath, Co
|
|||
n += stride;
|
||||
}
|
||||
|
||||
int width, height;
|
||||
unsigned char *raw = stbi_load_from_memory(data, (int)image->buffer_view->size, &width, &height, NULL, 4);
|
||||
rimage = LoadImageFromMemory(".png", data, (int)image->buffer_view->size);
|
||||
RL_FREE(data);
|
||||
|
||||
rimage.data = raw;
|
||||
rimage.width = width;
|
||||
rimage.height = height;
|
||||
rimage.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
|
||||
rimage.mipmaps = 1;
|
||||
|
||||
// TODO: Tint shouldn't be applied here!
|
||||
ImageColorTint(&rimage, tint);
|
||||
}
|
||||
|
|
@ -5142,7 +5305,7 @@ static void BindGLTFPrimitiveToBones(Model *model, cgltf_node *node, const cgltf
|
|||
}
|
||||
|
||||
// LoadGLTF loads in animation data from given filename
|
||||
static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCount)
|
||||
static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, unsigned int *animCount)
|
||||
{
|
||||
/***********************************************************************************
|
||||
|
||||
|
|
@ -5177,7 +5340,7 @@ static ModelAnimation *LoadGLTFModelAnimations(const char *fileName, int *animCo
|
|||
result = cgltf_load_buffers(&options, data, fileName);
|
||||
if (result != cgltf_result_success) TRACELOG(LOG_WARNING, "MODEL: [%s] unable to load glTF animations data", fileName);
|
||||
animations = RL_MALLOC(data->animations_count*sizeof(ModelAnimation));
|
||||
*animCount = (int)data->animations_count;
|
||||
*animCount = (unsigned int)data->animations_count;
|
||||
|
||||
for (unsigned int a = 0; a < data->animations_count; a++)
|
||||
{
|
||||
|
|
@ -5671,3 +5834,108 @@ static void GetGLTFPrimitiveCount(cgltf_node *node, int *outCount)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_VOX)
|
||||
// Load VOX (MagicaVoxel) mesh data
|
||||
static Model LoadVOX(const char *fileName)
|
||||
{
|
||||
Model model = { 0 };
|
||||
int nbvertices = 0;
|
||||
int meshescount = 0;
|
||||
unsigned int readed = 0;
|
||||
unsigned char* fileData;
|
||||
|
||||
//Read vox file into buffer
|
||||
fileData = LoadFileData(fileName, &readed);
|
||||
if (fileData == 0)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load VOX file", fileName);
|
||||
return model;
|
||||
}
|
||||
|
||||
//Read and build voxarray description
|
||||
VoxArray3D voxarray = { 0 };
|
||||
int ret = Vox_LoadFromMemory(fileData, readed, &voxarray);
|
||||
|
||||
if (ret != VOX_SUCCESS)
|
||||
{
|
||||
// Error
|
||||
UnloadFileData(fileData);
|
||||
|
||||
TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load VOX data", fileName);
|
||||
return model;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Success: Compute meshes count
|
||||
nbvertices = voxarray.vertices.used;
|
||||
meshescount = 1 + (nbvertices/65536);
|
||||
|
||||
TRACELOG(LOG_INFO, "MODEL: [%s] VOX data loaded successfully : %i vertices/%i meshes", fileName, nbvertices, meshescount);
|
||||
}
|
||||
|
||||
// Build models from meshes
|
||||
model.transform = MatrixIdentity();
|
||||
|
||||
model.meshCount = meshescount;
|
||||
model.meshes = (Mesh *)MemAlloc(model.meshCount*sizeof(Mesh));
|
||||
|
||||
model.meshMaterial = (int *)MemAlloc(model.meshCount*sizeof(int));
|
||||
|
||||
model.materialCount = 1;
|
||||
model.materials = (Material *)MemAlloc(model.materialCount*sizeof(Material));
|
||||
model.materials[0] = LoadMaterialDefault();
|
||||
|
||||
// Init model meshes
|
||||
int verticesRemain = voxarray.vertices.used;
|
||||
int verticesMax = 65532; // 5461 voxels x 12 vertices per voxel -> 65532 (must be inf 65536)
|
||||
|
||||
Vector3 *pvertices = voxarray.vertices.array; // 6*4 = 12 vertices per voxel
|
||||
Color *pcolors = voxarray.colors.array;
|
||||
unsigned short *pindices = voxarray.indices.array; // 5461*6*6 = 196596 indices max per mesh
|
||||
|
||||
int size = 0;
|
||||
|
||||
for (int idxMesh = 0; idxMesh < meshescount; idxMesh++)
|
||||
{
|
||||
Mesh *pmesh = &model.meshes[idxMesh];
|
||||
memset(pmesh, 0, sizeof(Mesh));
|
||||
|
||||
// Copy vertices
|
||||
pmesh->vertexCount = (int)fmin(verticesMax, verticesRemain);
|
||||
|
||||
size = pmesh->vertexCount*sizeof(float)*3;
|
||||
pmesh->vertices = MemAlloc(size);
|
||||
memcpy(pmesh->vertices, pvertices, size);
|
||||
|
||||
// Copy indices
|
||||
// TODO: Compute globals indices array
|
||||
size = voxarray.indices.used * sizeof(unsigned short);
|
||||
pmesh->indices = MemAlloc(size);
|
||||
memcpy(pmesh->indices, pindices, size);
|
||||
|
||||
pmesh->triangleCount = (pmesh->vertexCount/4)*2;
|
||||
|
||||
// Copy colors
|
||||
size = pmesh->vertexCount*sizeof(Color);
|
||||
pmesh->colors = MemAlloc(size);
|
||||
memcpy(pmesh->colors, pcolors, size);
|
||||
|
||||
// First material index
|
||||
model.meshMaterial[idxMesh] = 0;
|
||||
|
||||
// Upload mesh data to GPU
|
||||
UploadMesh(pmesh, false);
|
||||
|
||||
verticesRemain -= verticesMax;
|
||||
pvertices += verticesMax;
|
||||
pcolors += verticesMax;
|
||||
}
|
||||
|
||||
//Free buffers
|
||||
Vox_FreeArrays(&voxarray);
|
||||
UnloadFileData(fileData);
|
||||
|
||||
return model;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* raylib.shapes - Basic functions to draw 2d Shapes and check collisions
|
||||
* rshapes - Basic functions to draw 2d shapes and check collisions
|
||||
*
|
||||
* CONFIGURATION:
|
||||
*
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* raylib.text - Basic functions to load Fonts and draw Text
|
||||
* rtext - Basic functions to load fonts and draw text
|
||||
*
|
||||
* CONFIGURATION:
|
||||
*
|
||||
|
|
@ -267,7 +267,7 @@ extern void LoadFontDefault(void)
|
|||
|
||||
defaultFont.baseSize = (int)defaultFont.recs[0].height;
|
||||
|
||||
TRACELOG(LOG_INFO, "FONT: [ID %i] Default font texture loaded successfully", defaultFont.texture.id);
|
||||
TRACELOG(LOG_INFO, "FONT: Default font loaded successfully (%i glyphs)", defaultFont.glyphCount);
|
||||
}
|
||||
|
||||
// Unload raylib default font
|
||||
|
|
@ -512,6 +512,8 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int
|
|||
}
|
||||
|
||||
UnloadImage(atlas);
|
||||
|
||||
// TRACELOG(LOG_INFO, "FONT: Font loaded successfully (%i glyphs)", font.glyphCount);
|
||||
}
|
||||
else font = GetFontDefault();
|
||||
}
|
||||
|
|
@ -1523,9 +1525,8 @@ int GetCodepointCount(const char *text)
|
|||
// Get next codepoint in a UTF-8 encoded text, scanning until '\0' is found
|
||||
// When a invalid UTF-8 byte is encountered we exit as soon as possible and a '?'(0x3f) codepoint is returned
|
||||
// Total number of bytes processed are returned as a parameter
|
||||
// NOTE: the standard says U+FFFD should be returned in case of errors
|
||||
// NOTE: The standard says U+FFFD should be returned in case of errors
|
||||
// but that character is not supported by the default font in raylib
|
||||
// TODO: Optimize this code for speed!!
|
||||
int GetCodepoint(const char *text, int *bytesProcessed)
|
||||
{
|
||||
/*
|
||||
|
|
@ -1782,7 +1783,7 @@ static Font LoadBMFont(const char *fileName)
|
|||
font = GetFontDefault();
|
||||
TRACELOG(LOG_WARNING, "FONT: [%s] Failed to load texture, reverted to default font", fileName);
|
||||
}
|
||||
else TRACELOG(LOG_INFO, "FONT: [%s] Font loaded successfully", fileName);
|
||||
else TRACELOG(LOG_INFO, "FONT: [%s] Font loaded successfully (%i glyphs)", fileName, font.glyphCount);
|
||||
|
||||
return font;
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* raylib.textures - Basic functions to load and draw Textures (2d)
|
||||
* rtextures - Basic functions to load and draw textures
|
||||
*
|
||||
* CONFIGURATION:
|
||||
*
|
||||
|
|
@ -269,8 +269,8 @@ Image LoadImageAnim(const char *fileName, int *frames)
|
|||
if (fileData != NULL)
|
||||
{
|
||||
int comp = 0;
|
||||
int **delays = NULL;
|
||||
image.data = stbi_load_gif_from_memory(fileData, dataSize, delays, &image.width, &image.height, &frameCount, &comp, 4);
|
||||
int *delays = NULL;
|
||||
image.data = stbi_load_gif_from_memory(fileData, dataSize, &delays, &image.width, &image.height, &frameCount, &comp, 4);
|
||||
|
||||
image.mipmaps = 1;
|
||||
image.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
|
||||
|
|
@ -871,8 +871,6 @@ Image ImageFromImage(Image image, Rectangle rec)
|
|||
|
||||
int bytesPerPixel = GetPixelDataSize(1, 1, image.format);
|
||||
|
||||
// TODO: Check rec is valid?
|
||||
|
||||
result.width = (int)rec.width;
|
||||
result.height = (int)rec.height;
|
||||
result.data = RL_CALLOC((int)(rec.width*rec.height)*bytesPerPixel, 1);
|
||||
|
|
@ -192,7 +192,8 @@ jwE50AGjLCVuS8Yt4H7OgZLKK5EKOsLviEWJSL/+0uMi7gLUSBseYwqEbXvSHCec1CJvZPyHCmYQffaB
|
|||
<script type='text/javascript'>
|
||||
function saveFileFromMEMFSToDisk(memoryFSname, localFSname) // This can be called by C/C++ code
|
||||
{
|
||||
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
||||
var isSafari = false; // Not supported, navigator.userAgent access is being restricted
|
||||
//var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
||||
var data = FS.readFile(memoryFSname);
|
||||
var blob;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user