Merge pull request #250 from raysan5/develop

Integrate develop branch
This commit is contained in:
Ray
2017-03-26 23:06:17 +02:00
committed by GitHub
113 changed files with 1565 additions and 1212 deletions

13
.gitignore vendored
View File

@ -3,6 +3,8 @@
# Ignore VIM's backup generated files # Ignore VIM's backup generated files
*.swp *.swp
*.swo
*~
# Ignore Android generated files and folders # Ignore Android generated files and folders
src_android/obj/ src_android/obj/
@ -62,6 +64,17 @@ examples/*
# Unignore examples Makefile # Unignore examples Makefile
!examples/Makefile !examples/Makefile
# Ignore all games files
games/*
# Unignore all games dirs
!games/*/
# Unignore all games files with extension
!games/*.c
!games/*.lua
!games/*.png
# Unignore games makefile
!games/makefile
# Ignore files build by xcode # Ignore files build by xcode
*.mode*v* *.mode*v*
*.pbxuser *.pbxuser

View File

@ -34,4 +34,4 @@ contact
* Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5) * Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5)
* Patreon: [https://www.patreon.com/raysan5](https://www.patreon.com/raysan5) * Patreon: [https://www.patreon.com/raysan5](https://www.patreon.com/raysan5)
[raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San" [raysan5]: mailto:ray@raylib.com "Ramon Santamaria - Ray San"

View File

@ -278,4 +278,4 @@ contributing (in some way or another) to make raylib project better. Huge thanks
Please, if I forget someone in this list, excuse me and write me an email to remind me to add you! Please, if I forget someone in this list, excuse me and write me an email to remind me to add you!
[raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San" [raysan5]: mailto:ray@raylib.com "Ramon Santamaria - Ray San"

View File

@ -44,5 +44,5 @@ raylib 1.4
Any feature missing? Do you have a request? [Let me know!][raysan5] Any feature missing? Do you have a request? [Let me know!][raysan5]
[raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San" [raysan5]: mailto:ray@raylib.com "Ramon Santamaria - Ray San"
[isssues]: https://github.com/raysan5/raylib/issues [isssues]: https://github.com/raysan5/raylib/issues

View File

@ -5,7 +5,7 @@
* This example has been created using raylib 1.3.0 (www.raylib.com) * This example has been created using raylib 1.3.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2015 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2015 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/

View File

@ -53,7 +53,7 @@
<div class="content"> <div class="content">
<p>Im working hard on raylib but my resources are quite limited. <p>Im working hard on raylib but my resources are quite limited.
If you enjoy raylib and want to help / contribute, please, <a class="simplelink" href="mailto:raysan@raysanweb.com?subject=Hey! I want to help/contribute!"><strong>let me know</strong></a>.</p> If you enjoy raylib and want to help / contribute, please, <a class="simplelink" href="mailto:ray@raylib.com?subject=Hey! I want to help/contribute!"><strong>let me know</strong></a>.</p>
<br> <br>
<p>The following help is highly appreciated:</p> <p>The following help is highly appreciated:</p>
<br> <br>

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 981 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

View File

@ -108,7 +108,7 @@
- Multiplatform support: Android, Raspberry Pi, HTML5, Oculus Rift CV1<br> - Multiplatform support: Android, Raspberry Pi, HTML5, Oculus Rift CV1<br>
- Custom color palette for fancy visuals on raywhite background<br> - Custom color palette for fancy visuals on raywhite background<br>
- Minimal external dependencies (GLFW3, OpenGL, OpenAL)<br> - Minimal external dependencies (GLFW3, OpenGL, OpenAL)<br>
- Complete binding to Lua: [<a class="simplelink" href="https://github.com/raysan5/raylib/blob/master/src/rlua.h" target="_blank">rlua</a>]<br> - Complete binding to <a class="simplelink" href="https://github.com/raysan5/raylib-lua" target="_blank">Lua</a>, <a class="simplelink" href="https://github.com/gen2brain/raylib-go" target="_blank">Go</a> and Pascal.<br>
</div> </div>
<br> <br>
<a href="images/raylib_architecture.png"><img src="images/raylib_architecture.png" alt="raylib architechture" width="800" height="450"/></a> <a href="images/raylib_architecture.png"><img src="images/raylib_architecture.png" alt="raylib architechture" width="800" height="450"/></a>
@ -120,16 +120,21 @@
<strong>raylib supporters on patreon</strong> <strong>raylib supporters on patreon</strong>
<p>The following people is supporting raylib project on <a class="simplelink" href="https://www.patreon.com/raysan5" target="_blank">patreon</a>. Many thanks to all of them for believing in the project and contributing to it.</p> <p>The following people is supporting raylib project on <a class="simplelink" href="https://www.patreon.com/raysan5" target="_blank">patreon</a>. Many thanks to all of them for believing in the project and contributing to it.</p>
<br> <br>
<p> - Jarrod - 2drealms (<a class="simplelink" href="https://twitter.com/2drealms" target="_blank">@2drealms</a>)</p>
<p> - Kovay Hatfield</p>
<p> - Pau Fernandez (<a class="simplelink" href="https://twitter.com/pauek" target="_blank">@pauek</a>)</p> <p> - Pau Fernandez (<a class="simplelink" href="https://twitter.com/pauek" target="_blank">@pauek</a>)</p>
<p> - Marcelo Paez (<a class="simplelink" href="https://twitter.com/paezao" target="_blank">@paezao</a>)</p> <p> - Chris Johnson</p>
<p> - Joel Davis (<a class="simplelink" href="https://twitter.com/joeld42" target="_blank">@joeld42</a>)</p>
<p> - Charles Nicosia</p>
<p> - Rajasekaran Senthil (<a class="simplelink" href="https://twitter.com/rskgames" target="_blank">@rskgames</a>)</p> <p> - Rajasekaran Senthil (<a class="simplelink" href="https://twitter.com/rskgames" target="_blank">@rskgames</a>)</p>
<p> - Adrian Guerrero</p> <p> - Adrian Guerrero</p>
<p> - Dani Gómez</p> <p> - Dani Gómez</p>
<p> - Marc Agüera</p> <p> - Justin Hamilton</p>
<p> - Sergio Martínez</p> <p> - Antonio Radovcic</p>
<p> - Evan</p> <p> - James W. Bohnke</p>
<p> - Evan Sirchuk</p>
<br> <br>
<p>And a very special thanks to <strong>Ilya Zarembsky</strong> for his generous contribution. Many thanks Ilya! Hope your students enjoy raylib! :D</p> <p>And a very special thanks to <strong>Ilya Zarembsky</strong> (<a class="simplelink" href="https://twitter.com/wly_cdgr" target="_blank">@wly_cdgr</a>) for his generous contribution. Many thanks Ilya! Hope your students are enjoying raylib! :D</p>
</div> </div>
<div class="footer"> <div class="footer">

View File

@ -5,15 +5,15 @@
# NOTE: By default examples are compiled using raylib static library and OpenAL Soft shared library # NOTE: By default examples are compiled using raylib static library and OpenAL Soft shared library
# #
# Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) # Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
# #
# This software is provided "as-is", without any express or implied warranty. In no event # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.
# #
# Permission is granted to anyone to use this software for any purpose, including commercial # Permission is granted to anyone to use this software for any purpose, including commercial
# applications, and to alter it and redistribute it freely, subject to the following restrictions: # applications, and to alter it and redistribute it freely, subject to the following restrictions:
# #
# 1. The origin of this software must not be misrepresented; you must not claim that you # 1. The origin of this software must not be misrepresented; you must not claim that you
# wrote the original software. If you use this software in a product, an acknowledgment # wrote the original software. If you use this software in a product, an acknowledgment
# in the product documentation would be appreciated but is not required. # in the product documentation would be appreciated but is not required.
# #
# 2. Altered source versions must be plainly marked as such, and must not be misrepresented # 2. Altered source versions must be plainly marked as such, and must not be misrepresented
@ -66,21 +66,34 @@ endif
endif endif
# define compiler flags: # define compiler flags:
# -O2 defines optimization level # -O2 defines optimization level
# -s strip unnecessary data from build # -Og enable debugging
# -Wall turns on most, but not all, compiler warnings # -s strip unnecessary data from build
# -std=c99 use standard C from 1999 revision # -Wall turns on most, but not all, compiler warnings
ifeq ($(PLATFORM),PLATFORM_RPI) # -std=c99 defines C language mode (standard C from 1999 revision)
CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline # -std=gnu99 defines C language mode (GNU C from 1999 revision)
else # -fgnu89-inline declaring inline functions support (GCC optimized)
CFLAGS = -O2 -s -Wall -std=c99 # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux to enable timespec and drflac
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
CFLAGS = -O2 -s -Wall -std=c99
endif
ifeq ($(PLATFORM_OS),LINUX)
CFLAGS = -O2 -s -Wall -std=c99 -D_DEFAULT_SOURCE
endif
ifeq ($(PLATFORM_OS),OSX)
CFLAGS = -O2 -s -Wall -std=c99
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
CFLAGS = -O1 -Wall -std=c99 -s USE_GLFW=3 -s ASSERTIONS=1 --preload-file resources CFLAGS = -O1 -Wall -std=c99 -s USE_GLFW=3 -s ASSERTIONS=1 --preload-file resources
#-s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing #-s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
#-s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) #-s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI)
CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline
endif
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes #CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
# define raylib release directory for compiled library # define raylib release directory for compiled library
@ -110,9 +123,7 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif endif
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# add standard directories for GNU/Linux # add standard directories for GNU/Linux
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),WINDOWS)
INCLUDES += -I/usr/local/include/raylib/
else ifeq ($(PLATFORM_OS),WINDOWS)
# external libraries headers # external libraries headers
# GLFW3 # GLFW3
INCLUDES += -I../src/external/glfw3/include INCLUDES += -I../src/external/glfw3/include
@ -207,7 +218,6 @@ EXAMPLES = \
core_3d_camera_first_person \ core_3d_camera_first_person \
core_2d_camera \ core_2d_camera \
core_world_screen \ core_world_screen \
core_oculus_rift \
shapes_logo_raylib \ shapes_logo_raylib \
shapes_basic_shapes \ shapes_basic_shapes \
shapes_colors_palette \ shapes_colors_palette \
@ -327,19 +337,19 @@ core_3d_camera_free: core_3d_camera_free.c
# compile [core] example - 3d camera first person # compile [core] example - 3d camera first person
core_3d_camera_first_person: core_3d_camera_first_person.c core_3d_camera_first_person: core_3d_camera_first_person.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [core] example - 2d camera # compile [core] example - 2d camera
core_2d_camera: core_2d_camera.c core_2d_camera: core_2d_camera.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [core] example - world screen # compile [core] example - world screen
core_world_screen: core_world_screen.c core_world_screen: core_world_screen.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [core] example - oculus rift # compile [core] example - oculus rift
core_oculus_rift: core_oculus_rift.c #core_oculus_rift: core_oculus_rift.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) # $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [shapes] example - raylib logo (with basic shapes) # compile [shapes] example - raylib logo (with basic shapes)
shapes_logo_raylib: shapes_logo_raylib.c shapes_logo_raylib: shapes_logo_raylib.c
@ -376,31 +386,31 @@ textures_srcrec_dstrec: textures_srcrec_dstrec.c
# compile [textures] example - texture to image # compile [textures] example - texture to image
textures_to_image: textures_to_image.c textures_to_image: textures_to_image.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [textures] example - texture raw data # compile [textures] example - texture raw data
textures_raw_data: textures_raw_data.c textures_raw_data: textures_raw_data.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [textures] example - texture formats loading # compile [textures] example - texture formats loading
textures_formats_loading: textures_formats_loading.c textures_formats_loading: textures_formats_loading.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [textures] example - texture particles trail blending # compile [textures] example - texture particles trail blending
textures_particles_trail_blending: textures_particles_trail_blending.c textures_particles_trail_blending: textures_particles_trail_blending.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [textures] example - texture image processing # compile [textures] example - texture image processing
textures_image_processing: textures_image_processing.c textures_image_processing: textures_image_processing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [textures] example - texture image drawing # compile [textures] example - texture image drawing
textures_image_drawing: textures_image_drawing.c textures_image_drawing: textures_image_drawing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [text] example - sprite fonts loading # compile [text] example - sprite fonts loading
text_sprite_fonts: text_sprite_fonts.c text_sprite_fonts: text_sprite_fonts.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [text] example - bmfonts and ttf loading # compile [text] example - bmfonts and ttf loading
text_bmfont_ttf: text_bmfont_ttf.c text_bmfont_ttf: text_bmfont_ttf.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
@ -436,7 +446,7 @@ models_geometric_shapes: models_geometric_shapes.c
# compile [models] example - box collisions # compile [models] example - box collisions
models_box_collisions: models_box_collisions.c models_box_collisions: models_box_collisions.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [models] example - basic window # compile [models] example - basic window
models_planes: models_planes.c models_planes: models_planes.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
@ -464,15 +474,15 @@ models_ray_picking: models_ray_picking.c
# compile [shaders] example - model shader # compile [shaders] example - model shader
shaders_model_shader: shaders_model_shader.c shaders_model_shader: shaders_model_shader.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [shaders] example - shapes texture shader # compile [shaders] example - shapes texture shader
shaders_shapes_textures: shaders_shapes_textures.c shaders_shapes_textures: shaders_shapes_textures.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [shaders] example - custom uniform in shader # compile [shaders] example - custom uniform in shader
shaders_custom_uniform: shaders_custom_uniform.c shaders_custom_uniform: shaders_custom_uniform.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [shaders] example - postprocessing shader # compile [shaders] example - postprocessing shader
shaders_postprocessing: shaders_postprocessing.c shaders_postprocessing: shaders_postprocessing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
@ -497,13 +507,6 @@ audio_module_playing: audio_module_playing.c
audio_raw_stream: audio_raw_stream.c audio_raw_stream: audio_raw_stream.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# Linux Fix to timespect from
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),LINUX)
CFLAGS += -D_POSIX_C_SOURCE=199309L
endif
endif
# compile [physac] example - physics demo # compile [physac] example - physics demo
physics_demo: physics_demo.c physics_demo: physics_demo.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS)
@ -523,7 +526,7 @@ physics_restitution: physics_restitution.c
# compile [physac] example - physics shatter # compile [physac] example - physics shatter
physics_shatter: physics_shatter.c physics_shatter: physics_shatter.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS)
# fix dylib install path name for each executable (MAC) # fix dylib install path name for each executable (MAC)
fix_dylib: fix_dylib:
ifeq ($(PLATFORM_OS),OSX) ifeq ($(PLATFORM_OS),OSX)

View File

@ -29,7 +29,7 @@
#endif #endif
#include "audio.h" #include "audio.h"
#if defined(__linux) #if defined(__linux__)
#include <stdio.h> #include <stdio.h>
#include <termios.h> #include <termios.h>

View File

@ -3,7 +3,12 @@
* raylib [core] example - Oculus Rift CV1 * raylib [core] example - Oculus Rift CV1
* *
* Compile example using: * Compile example using:
* gcc -o $(NAME_PART).exe $(FILE_NAME) -L. -L..\src\external\OculusSDK\LibOVR -lLibOVRRT32_1 -lraylib -lglfw3 -lopengl32 -lgdi32 -std=c99 * gcc -o $(NAME_PART).exe $(FILE_NAME) -I..\src\external -I..\src\external\OculusSDK\LibOVR\Include /
* -L. -L..\src\external\OculusSDK\LibOVR -lLibOVRRT32_1 -lraylib -lglfw3 -lopengl32 -lgdi32 -std=c99 /
* -Wl,-allow-multiple-definition
*
* #define SUPPORT_OCULUS_RIFT_CV1 / RLGL_OCULUS_SUPPORT
* Enable Oculus Rift CV1 functionality
* *
* This example has been created using raylib 1.5 (www.raylib.com) * This example has been created using raylib 1.5 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
@ -14,6 +19,95 @@
#include "raylib.h" #include "raylib.h"
#include "glad.h" // Required for: OpenGL types and functions declarations
#include "raymath.h" // Required for: Vector3, Quaternion and Matrix functionality
#include <string.h> // Required for: memset()
#include <stdlib.h> // Required for: exit()
#include <stdio.h> // required for: vfprintf()
#include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end()
#define RLGL_OCULUS_SUPPORT // Enable Oculus Rift code
#if defined(RLGL_OCULUS_SUPPORT)
#include "OVR_CAPI_GL.h" // Oculus SDK for OpenGL
#endif
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
// ...
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
// TraceLog message types
typedef enum { INFO = 0, ERROR, WARNING, DEBUG, OTHER } TraceLogType;
#if defined(RLGL_OCULUS_SUPPORT)
// Oculus buffer type
typedef struct OculusBuffer {
ovrTextureSwapChain textureChain;
GLuint depthId;
GLuint fboId;
int width;
int height;
} OculusBuffer;
// Oculus mirror texture type
typedef struct OculusMirror {
ovrMirrorTexture texture;
GLuint fboId;
int width;
int height;
} OculusMirror;
// Oculus layer type
typedef struct OculusLayer {
ovrViewScaleDesc viewScaleDesc;
ovrLayerEyeFov eyeLayer; // layer 0
//ovrLayerQuad quadLayer; // TODO: layer 1: '2D' quad for GUI
Matrix eyeProjections[2];
int width;
int height;
} OculusLayer;
#endif
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
#if defined(RLGL_OCULUS_SUPPORT)
// OVR device variables
static ovrSession session; // Oculus session (pointer to ovrHmdStruct)
static ovrHmdDesc hmdDesc; // Oculus device descriptor parameters
static ovrGraphicsLuid luid; // Oculus locally unique identifier for the program (64 bit)
static OculusLayer layer; // Oculus drawing layer (similar to photoshop)
static OculusBuffer buffer; // Oculus internal buffers (texture chain and fbo)
static OculusMirror mirror; // Oculus mirror texture and fbo
static unsigned int frameIndex = 0; // Oculus frames counter, used to discard frames from chain
#endif
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
//----------------------------------------------------------------------------------
#if defined(RLGL_OCULUS_SUPPORT)
static bool InitOculusDevice(void); // Initialize Oculus device (returns true if success)
static void CloseOculusDevice(void); // Close Oculus device
static void UpdateOculusTracking(Camera *camera); // Update Oculus head position-orientation tracking
static void BeginOculusDrawing(void); // Setup Oculus buffers for drawing
static void EndOculusDrawing(void); // Finish Oculus drawing and blit framebuffer to mirror
static OculusBuffer LoadOculusBuffer(ovrSession session, int width, int height); // Load Oculus required buffers
static void UnloadOculusBuffer(ovrSession session, OculusBuffer buffer); // Unload texture required buffers
static OculusMirror LoadOculusMirror(ovrSession session, int width, int height); // Load Oculus mirror buffers
static void UnloadOculusMirror(ovrSession session, OculusMirror mirror); // Unload Oculus mirror buffers
static void BlitOculusMirror(ovrSession session, OculusMirror mirror); // Copy Oculus screen buffer to mirror texture
static OculusLayer InitOculusLayer(ovrSession session); // Init Oculus layer (similar to photoshop)
static Matrix FromOvrMatrix(ovrMatrix4f ovrM); // Convert from Oculus ovrMatrix4f struct to raymath Matrix struct
#endif
static void TraceLog(int msgType, const char *text, ...);
int main() int main()
{ {
// Initialization // Initialization
@ -25,8 +119,9 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [core] example - oculus rift"); InitWindow(screenWidth, screenHeight, "raylib [core] example - oculus rift");
// NOTE: If device is not available, it fallbacks to default device (simulator) bool vrDeviceReady = InitOculusDevice(); // Init VR device Oculus Rift CV1
InitVrDevice(HMD_OCULUS_RIFT_CV1); // Init VR device (Oculus Rift CV1)
if (!vrDeviceReady) InitVrSimulator(HMD_OCULUS_RIFT_CV1); // Init VR simulator if device fails
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera camera; Camera camera;
@ -47,10 +142,10 @@ int main()
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsVrSimulator()) UpdateCamera(&camera); // Update camera (simulator mode) if (!vrDeviceReady) UpdateCamera(&camera); // Update camera (simulator mode)
else if (IsVrDeviceReady()) UpdateVrTracking(&camera); // Update camera with device tracking data else UpdateOculusTracking(&camera); // Update camera with device tracking data
if (IsKeyPressed(KEY_SPACE)) ToggleVrMode(); // Toggle VR mode if (IsKeyPressed(KEY_SPACE)) ToggleVrMode(); // Toggle VR mode
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
@ -58,6 +153,9 @@ int main()
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
if (vrDeviceReady) BeginOculusDrawing();
else BeginVrDrawing();
Begin3dMode(camera); Begin3dMode(camera);
@ -67,6 +165,9 @@ int main()
DrawGrid(40, 1.0f); DrawGrid(40, 1.0f);
End3dMode(); End3dMode();
if (vrDeviceReady) EndOculusDrawing();
else EndVrDrawing();
DrawFPS(10, 10); DrawFPS(10, 10);
@ -76,10 +177,362 @@ int main()
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseVrDevice(); // Close VR device if (vrDeviceReady) CloseOculusDevice();
else CloseVrSimulator();
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }
//----------------------------------------------------------------------------------
// Module specific Functions Definition
//----------------------------------------------------------------------------------
#if defined(RLGL_OCULUS_SUPPORT)
// Set internal projection and modelview matrix depending on eyes tracking data
static void SetStereoView(int eye, Matrix matProjection, Matrix matModelView)
{
Matrix eyeProjection = matProjection;
Matrix eyeModelView = matModelView;
glViewport(layer.eyeLayer.Viewport[eye].Pos.x, layer.eyeLayer.Viewport[eye].Pos.y,
layer.eyeLayer.Viewport[eye].Size.w, layer.eyeLayer.Viewport[eye].Size.h);
Quaternion eyeRenderPose = (Quaternion){ layer.eyeLayer.RenderPose[eye].Orientation.x,
layer.eyeLayer.RenderPose[eye].Orientation.y,
layer.eyeLayer.RenderPose[eye].Orientation.z,
layer.eyeLayer.RenderPose[eye].Orientation.w };
QuaternionInvert(&eyeRenderPose);
Matrix eyeOrientation = QuaternionToMatrix(eyeRenderPose);
Matrix eyeTranslation = MatrixTranslate(-layer.eyeLayer.RenderPose[eye].Position.x,
-layer.eyeLayer.RenderPose[eye].Position.y,
-layer.eyeLayer.RenderPose[eye].Position.z);
Matrix eyeView = MatrixMultiply(eyeTranslation, eyeOrientation); // Matrix containing eye-head movement
eyeModelView = MatrixMultiply(matModelView, eyeView); // Combine internal camera matrix (modelview) wih eye-head movement
eyeProjection = layer.eyeProjections[eye];
}
// Initialize Oculus device (returns true if success)
static bool InitOculusDevice(void)
{
bool oculusReady = false;
ovrResult result = ovr_Initialize(NULL);
if (OVR_FAILURE(result)) TraceLog(WARNING, "OVR: Could not initialize Oculus device");
else
{
result = ovr_Create(&session, &luid);
if (OVR_FAILURE(result))
{
TraceLog(WARNING, "OVR: Could not create Oculus session");
ovr_Shutdown();
}
else
{
hmdDesc = ovr_GetHmdDesc(session);
TraceLog(INFO, "OVR: Product Name: %s", hmdDesc.ProductName);
TraceLog(INFO, "OVR: Manufacturer: %s", hmdDesc.Manufacturer);
TraceLog(INFO, "OVR: Product ID: %i", hmdDesc.ProductId);
TraceLog(INFO, "OVR: Product Type: %i", hmdDesc.Type);
//TraceLog(INFO, "OVR: Serial Number: %s", hmdDesc.SerialNumber);
TraceLog(INFO, "OVR: Resolution: %ix%i", hmdDesc.Resolution.w, hmdDesc.Resolution.h);
// NOTE: Oculus mirror is set to defined screenWidth and screenHeight...
// ...ideally, it should be (hmdDesc.Resolution.w/2, hmdDesc.Resolution.h/2)
// Initialize Oculus Buffers
layer = InitOculusLayer(session);
buffer = LoadOculusBuffer(session, layer.width, layer.height);
mirror = LoadOculusMirror(session, hmdDesc.Resolution.w/2, hmdDesc.Resolution.h/2); // NOTE: hardcoded...
layer.eyeLayer.ColorTexture[0] = buffer.textureChain; //SetOculusLayerTexture(eyeLayer, buffer.textureChain);
// Recenter OVR tracking origin
ovr_RecenterTrackingOrigin(session);
oculusReady = true;
}
}
return oculusReady;
}
// Close Oculus device (and unload buffers)
static void CloseOculusDevice(void)
{
UnloadOculusMirror(session, mirror); // Unload Oculus mirror buffer
UnloadOculusBuffer(session, buffer); // Unload Oculus texture buffers
ovr_Destroy(session); // Free Oculus session data
ovr_Shutdown(); // Close Oculus device connection
}
// Update Oculus head position-orientation tracking
static void UpdateOculusTracking(Camera *camera)
{
frameIndex++;
ovrPosef eyePoses[2];
ovr_GetEyePoses(session, frameIndex, ovrTrue, layer.viewScaleDesc.HmdToEyeOffset, eyePoses, &layer.eyeLayer.SensorSampleTime);
layer.eyeLayer.RenderPose[0] = eyePoses[0];
layer.eyeLayer.RenderPose[1] = eyePoses[1];
// TODO: Update external camera with eyePoses data (position, orientation)
// NOTE: We can simplify to simple camera if we consider IPD and HMD device configuration again later
// it will be useful for the user to draw, lets say, billboards oriented to camera
// Get session status information
ovrSessionStatus sessionStatus;
ovr_GetSessionStatus(session, &sessionStatus);
if (sessionStatus.ShouldQuit) TraceLog(WARNING, "OVR: Session should quit...");
if (sessionStatus.ShouldRecenter) ovr_RecenterTrackingOrigin(session);
//if (sessionStatus.HmdPresent) // HMD is present.
//if (sessionStatus.DisplayLost) // HMD was unplugged or the display driver was manually disabled or encountered a TDR.
//if (sessionStatus.HmdMounted) // HMD is on the user's head.
//if (sessionStatus.IsVisible) // the game or experience has VR focus and is visible in the HMD.
}
// Setup Oculus buffers for drawing
static void BeginOculusDrawing(void)
{
GLuint currentTexId;
int currentIndex;
ovr_GetTextureSwapChainCurrentIndex(session, buffer.textureChain, &currentIndex);
ovr_GetTextureSwapChainBufferGL(session, buffer.textureChain, currentIndex, &currentTexId);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, buffer.fboId);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, currentTexId, 0);
//glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, buffer.depthId, 0); // Already binded
}
// Finish Oculus drawing and blit framebuffer to mirror
static void EndOculusDrawing(void)
{
// Unbind current framebuffer (Oculus buffer)
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
ovr_CommitTextureSwapChain(session, buffer.textureChain);
ovrLayerHeader *layers = &layer.eyeLayer.Header;
ovr_SubmitFrame(session, frameIndex, &layer.viewScaleDesc, &layers, 1);
// Blit mirror texture to back buffer
BlitOculusMirror(session, mirror);
}
// Load Oculus required buffers: texture-swap-chain, fbo, texture-depth
static OculusBuffer LoadOculusBuffer(ovrSession session, int width, int height)
{
OculusBuffer buffer;
buffer.width = width;
buffer.height = height;
// Create OVR texture chain
ovrTextureSwapChainDesc desc = {};
desc.Type = ovrTexture_2D;
desc.ArraySize = 1;
desc.Width = width;
desc.Height = height;
desc.MipLevels = 1;
desc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB; // Requires glEnable(GL_FRAMEBUFFER_SRGB);
desc.SampleCount = 1;
desc.StaticImage = ovrFalse;
ovrResult result = ovr_CreateTextureSwapChainGL(session, &desc, &buffer.textureChain);
if (!OVR_SUCCESS(result)) TraceLog(WARNING, "OVR: Failed to create swap textures buffer");
int textureCount = 0;
ovr_GetTextureSwapChainLength(session, buffer.textureChain, &textureCount);
if (!OVR_SUCCESS(result) || !textureCount) TraceLog(WARNING, "OVR: Unable to count swap chain textures");
for (int i = 0; i < textureCount; ++i)
{
GLuint chainTexId;
ovr_GetTextureSwapChainBufferGL(session, buffer.textureChain, i, &chainTexId);
glBindTexture(GL_TEXTURE_2D, chainTexId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
glBindTexture(GL_TEXTURE_2D, 0);
/*
// Setup framebuffer object (using depth texture)
glGenFramebuffers(1, &buffer.fboId);
glGenTextures(1, &buffer.depthId);
glBindTexture(GL_TEXTURE_2D, buffer.depthId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, buffer.width, buffer.height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
*/
// Setup framebuffer object (using depth renderbuffer)
glGenFramebuffers(1, &buffer.fboId);
glGenRenderbuffers(1, &buffer.depthId);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, buffer.fboId);
glBindRenderbuffer(GL_RENDERBUFFER, buffer.depthId);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, buffer.width, buffer.height);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, buffer.depthId);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
return buffer;
}
// Unload texture required buffers
static void UnloadOculusBuffer(ovrSession session, OculusBuffer buffer)
{
if (buffer.textureChain)
{
ovr_DestroyTextureSwapChain(session, buffer.textureChain);
buffer.textureChain = NULL;
}
if (buffer.depthId != 0) glDeleteTextures(1, &buffer.depthId);
if (buffer.fboId != 0) glDeleteFramebuffers(1, &buffer.fboId);
}
// Load Oculus mirror buffers
static OculusMirror LoadOculusMirror(ovrSession session, int width, int height)
{
OculusMirror mirror;
mirror.width = width;
mirror.height = height;
ovrMirrorTextureDesc mirrorDesc;
memset(&mirrorDesc, 0, sizeof(mirrorDesc));
mirrorDesc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
mirrorDesc.Width = mirror.width;
mirrorDesc.Height = mirror.height;
if (!OVR_SUCCESS(ovr_CreateMirrorTextureGL(session, &mirrorDesc, &mirror.texture))) TraceLog(WARNING, "Could not create mirror texture");
glGenFramebuffers(1, &mirror.fboId);
return mirror;
}
// Unload Oculus mirror buffers
static void UnloadOculusMirror(ovrSession session, OculusMirror mirror)
{
if (mirror.fboId != 0) glDeleteFramebuffers(1, &mirror.fboId);
if (mirror.texture) ovr_DestroyMirrorTexture(session, mirror.texture);
}
// Copy Oculus screen buffer to mirror texture
static void BlitOculusMirror(ovrSession session, OculusMirror mirror)
{
GLuint mirrorTextureId;
ovr_GetMirrorTextureBufferGL(session, mirror.texture, &mirrorTextureId);
glBindFramebuffer(GL_READ_FRAMEBUFFER, mirror.fboId);
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mirrorTextureId, 0);
#if defined(GRAPHICS_API_OPENGL_33)
// NOTE: glBlitFramebuffer() requires extension: GL_EXT_framebuffer_blit (not available in OpenGL ES 2.0)
glBlitFramebuffer(0, 0, mirror.width, mirror.height, 0, mirror.height, mirror.width, 0, GL_COLOR_BUFFER_BIT, GL_NEAREST);
#endif
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
}
// Init Oculus layer (similar to photoshop)
static OculusLayer InitOculusLayer(ovrSession session)
{
OculusLayer layer = { 0 };
layer.viewScaleDesc.HmdSpaceToWorldScaleInMeters = 1.0f;
memset(&layer.eyeLayer, 0, sizeof(ovrLayerEyeFov));
layer.eyeLayer.Header.Type = ovrLayerType_EyeFov;
layer.eyeLayer.Header.Flags = ovrLayerFlag_TextureOriginAtBottomLeft;
ovrEyeRenderDesc eyeRenderDescs[2];
for (int eye = 0; eye < 2; eye++)
{
eyeRenderDescs[eye] = ovr_GetRenderDesc(session, eye, hmdDesc.DefaultEyeFov[eye]);
ovrMatrix4f ovrPerspectiveProjection = ovrMatrix4f_Projection(eyeRenderDescs[eye].Fov, 0.01f, 10000.0f, ovrProjection_None); //ovrProjection_ClipRangeOpenGL);
layer.eyeProjections[eye] = FromOvrMatrix(ovrPerspectiveProjection); // NOTE: struct ovrMatrix4f { float M[4][4] } --> struct Matrix
layer.viewScaleDesc.HmdToEyeOffset[eye] = eyeRenderDescs[eye].HmdToEyeOffset;
layer.eyeLayer.Fov[eye] = eyeRenderDescs[eye].Fov;
ovrSizei eyeSize = ovr_GetFovTextureSize(session, eye, layer.eyeLayer.Fov[eye], 1.0f);
layer.eyeLayer.Viewport[eye].Size = eyeSize;
layer.eyeLayer.Viewport[eye].Pos.x = layer.width;
layer.eyeLayer.Viewport[eye].Pos.y = 0;
layer.height = eyeSize.h; //std::max(renderTargetSize.y, (uint32_t)eyeSize.h);
layer.width += eyeSize.w;
}
return layer;
}
// Convert from Oculus ovrMatrix4f struct to raymath Matrix struct
static Matrix FromOvrMatrix(ovrMatrix4f ovrmat)
{
Matrix rmat;
rmat.m0 = ovrmat.M[0][0];
rmat.m1 = ovrmat.M[1][0];
rmat.m2 = ovrmat.M[2][0];
rmat.m3 = ovrmat.M[3][0];
rmat.m4 = ovrmat.M[0][1];
rmat.m5 = ovrmat.M[1][1];
rmat.m6 = ovrmat.M[2][1];
rmat.m7 = ovrmat.M[3][1];
rmat.m8 = ovrmat.M[0][2];
rmat.m9 = ovrmat.M[1][2];
rmat.m10 = ovrmat.M[2][2];
rmat.m11 = ovrmat.M[3][2];
rmat.m12 = ovrmat.M[0][3];
rmat.m13 = ovrmat.M[1][3];
rmat.m14 = ovrmat.M[2][3];
rmat.m15 = ovrmat.M[3][3];
MatrixTranspose(&rmat);
return rmat;
}
#endif
// Output a trace log message
// NOTE: Expected msgType: (0)Info, (1)Error, (2)Warning
static void TraceLog(int msgType, const char *text, ...)
{
va_list args;
va_start(args, text);
switch (msgType)
{
case INFO: fprintf(stdout, "INFO: "); break;
case ERROR: fprintf(stdout, "ERROR: "); break;
case WARNING: fprintf(stdout, "WARNING: "); break;
case DEBUG: fprintf(stdout, "DEBUG: "); break;
default: break;
}
vfprintf(stdout, text, args);
fprintf(stdout, "\n");
va_end(args);
if (msgType == ERROR) exit(1);
}

View File

@ -5,7 +5,7 @@
* This example has been created using raylib 1.3.0 (www.raylib.com) * This example has been created using raylib 1.3.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2015 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2015 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/

View File

@ -15,7 +15,7 @@
* This game has been created using raylib 1.1 (www.raylib.com) * This game has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/

View File

@ -15,7 +15,7 @@
* This game has been created using raylib 1.1 (www.raylib.com) * This game has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/

View File

@ -15,7 +15,7 @@
* This game has been created using raylib 1.1 (www.raylib.com) * This game has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/

View File

@ -15,7 +15,7 @@
* This game has been created using raylib 1.1 (www.raylib.com) * This game has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/

View File

@ -15,7 +15,7 @@
* This game has been created using raylib 1.1 (www.raylib.com) * This game has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/
@ -338,7 +338,7 @@ int main()
DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE);
// Draw blinking text // Draw blinking text
if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.size, 0, WHITE); if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 0, WHITE);
} break; } break;
case GAMEPLAY: case GAMEPLAY:
@ -388,8 +388,8 @@ int main()
DrawRectangle(20, 20, foodBar, 40, ORANGE); DrawRectangle(20, 20, foodBar, 40, ORANGE);
DrawRectangleLines(20, 20, 400, 40, BLACK); DrawRectangleLines(20, 20, 400, 40, BLACK);
DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE);
DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE);
if (gameraMode) if (gameraMode)
{ {
@ -403,15 +403,15 @@ int main()
// Draw a transparent black rectangle that covers all screen // Draw a transparent black rectangle that covers all screen
DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f));
DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.size*3, -2, MAROON); DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON);
DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.size, -2, GOLD); DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD);
DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.size, -2, GOLD); DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD);
DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE);
DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE);
// Draw blinking text // Draw blinking text
if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.size, -2, LIGHTGRAY); if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY);
} break; } break;
default: break; default: break;
@ -444,4 +444,4 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

@ -15,7 +15,7 @@
* This game has been created using raylib 1.6 (www.raylib.com) * This game has been created using raylib 1.6 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/
@ -354,7 +354,7 @@ int main()
DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE);
// Draw blinking text // Draw blinking text
if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.size, 0, WHITE); if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 0, WHITE);
} break; } break;
case GAMEPLAY: case GAMEPLAY:
@ -404,8 +404,8 @@ int main()
DrawRectangle(20, 20, foodBar, 40, ORANGE); DrawRectangle(20, 20, foodBar, 40, ORANGE);
DrawRectangleLines(20, 20, 400, 40, BLACK); DrawRectangleLines(20, 20, 400, 40, BLACK);
DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE);
DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE);
if (gameraMode) if (gameraMode)
{ {
@ -419,15 +419,15 @@ int main()
// Draw a transparent black rectangle that covers all screen // Draw a transparent black rectangle that covers all screen
DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f));
DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.size*3, -2, MAROON); DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON);
DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.size, -2, GOLD); DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD);
DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.size, -2, GOLD); DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD);
DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE);
DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE);
// Draw blinking text // Draw blinking text
if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.size, -2, LIGHTGRAY); if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY);
} break; } break;
default: break; default: break;
@ -468,4 +468,4 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

@ -15,7 +15,7 @@
* This game has been created using raylib 1.6 (www.raylib.com) * This game has been created using raylib 1.6 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/
@ -379,7 +379,7 @@ int main()
DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE);
// Draw blinking text // Draw blinking text
if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.size, 0, WHITE); if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 0, WHITE);
} break; } break;
case GAMEPLAY: case GAMEPLAY:
@ -429,8 +429,8 @@ int main()
DrawRectangle(20, 20, foodBar, 40, ORANGE); DrawRectangle(20, 20, foodBar, 40, ORANGE);
DrawRectangleLines(20, 20, 400, 40, BLACK); DrawRectangleLines(20, 20, 400, 40, BLACK);
DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE);
DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE);
if (gameraMode) if (gameraMode)
{ {
@ -444,15 +444,15 @@ int main()
// Draw a transparent black rectangle that covers all screen // Draw a transparent black rectangle that covers all screen
DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f));
DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.size*3, -2, MAROON); DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON);
DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.size, -2, GOLD); DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD);
DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.size, -2, GOLD); DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD);
DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE);
DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE);
// Draw blinking text // Draw blinking text
if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.size, -2, LIGHTGRAY); if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY);
} break; } break;
default: break; default: break;
@ -493,4 +493,4 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View File

@ -15,7 +15,7 @@
* This game has been created using raylib 1.6 (www.raylib.com) * This game has been created using raylib 1.6 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/
@ -460,7 +460,7 @@ void UpdateDrawFrame(void)
DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE); DrawTexture(title, screenWidth/2 - title.width/2, screenHeight/2 - title.height/2 - 80, WHITE);
// Draw blinking text // Draw blinking text
if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.size, 1, WHITE); if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER", (Vector2){ screenWidth/2 - 150, 480 }, font.baseSize, 1, WHITE);
} break; } break;
case GAMEPLAY: case GAMEPLAY:
@ -510,8 +510,8 @@ void UpdateDrawFrame(void)
DrawRectangle(20, 20, foodBar, 40, ORANGE); DrawRectangle(20, 20, foodBar, 40, ORANGE);
DrawRectangleLines(20, 20, 400, 40, BLACK); DrawRectangleLines(20, 20, 400, 40, BLACK);
DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ screenWidth - 300, 20 }, font.baseSize, -2, ORANGE);
DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 550, 20 }, font.baseSize, -2, ORANGE);
if (gameraMode) if (gameraMode)
{ {
@ -525,15 +525,15 @@ void UpdateDrawFrame(void)
// Draw a transparent black rectangle that covers all screen // Draw a transparent black rectangle that covers all screen
DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f)); DrawRectangle(0, 0, screenWidth, screenHeight, Fade(BLACK, 0.4f));
DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.size*3, -2, MAROON); DrawTextEx(font, "GAME OVER", (Vector2){ 300, 160 }, font.baseSize*3, -2, MAROON);
DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.size, -2, GOLD); DrawTextEx(font, FormatText("SCORE: %04i", score), (Vector2){ 680, 350 }, font.baseSize, -2, GOLD);
DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.size, -2, GOLD); DrawTextEx(font, FormatText("DISTANCE: %04i", (int)distance), (Vector2){ 290, 350 }, font.baseSize, -2, GOLD);
DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("HISCORE: %04i", hiscore), (Vector2){ 665, 400 }, font.baseSize, -2, ORANGE);
DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.size, -2, ORANGE); DrawTextEx(font, FormatText("HIDISTANCE: %04i", (int)hidistance), (Vector2){ 270, 400 }, font.baseSize, -2, ORANGE);
// Draw blinking text // Draw blinking text
if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.size, -2, LIGHTGRAY); if ((framesCounter/30) % 2) DrawTextEx(font, "PRESS ENTER to REPLAY", (Vector2){ screenWidth/2 - 250, 520 }, font.baseSize, -2, LIGHTGRAY);
} break; } break;
default: break; default: break;
@ -541,4 +541,4 @@ void UpdateDrawFrame(void)
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }

View File

@ -2,7 +2,7 @@
# #
# raylib - makefile to compile Dr.Turtle game # raylib - makefile to compile Dr.Turtle game
# #
# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) # Copyright (c) 2014 Ramon Santamaria (@raysan5)
# #
# This software is provided "as-is", without any express or implied warranty. In no event # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.
@ -66,7 +66,7 @@ endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
CFLAGS = -O2 -Wall -std=gnu99 -fgnu89-inline CFLAGS = -O2 -Wall -std=gnu99 -fgnu89-inline
else else
CFLAGS = -O2 -Wall -std=c99 CFLAGS = -O2 -Wall -std=c99
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
CFLAGS = -O1 -Wall -std=c99 -s USE_GLFW=3 --preload-file resources -s ALLOW_MEMORY_GROWTH=1 --shell-file ../../templates/web_shell/shell.html CFLAGS = -O1 -Wall -std=c99 -s USE_GLFW=3 --preload-file resources -s ALLOW_MEMORY_GROWTH=1 --shell-file ../../templates/web_shell/shell.html
@ -114,7 +114,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -pthread -ldl LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -pthread -ldl
# on XWindow could require also below libraries, just uncomment # on XWindow could require also below libraries, just uncomment
#LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
else else
ifeq ($(PLATFORM_OS),OSX) ifeq ($(PLATFORM_OS),OSX)
# libraries for OS X 10.9 desktop compiling # libraries for OS X 10.9 desktop compiling

View File

@ -9,7 +9,7 @@
* This game has been created using raylib 1.6 (www.raylib.com) * This game has been created using raylib 1.6 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* raylib - Copyright (c) 2015 Ramon Santamaria (Ray San - raysan@raysanweb.com) * raylib - Copyright (c) 2015 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/

View File

@ -4,7 +4,7 @@
# #
# makefile to compile advance game for desktop platforms, Raspberry Pi and HTML5 (emscripten) # makefile to compile advance game for desktop platforms, Raspberry Pi and HTML5 (emscripten)
# #
# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) # Copyright (c) 2014 Ramon Santamaria (@raysan5)
# #
# This software is provided "as-is", without any express or implied warranty. In no event # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.
@ -119,7 +119,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -pthread -ldl LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -pthread -ldl
# on XWindow could require also below libraries, just uncomment # on XWindow could require also below libraries, just uncomment
#LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
else else
ifeq ($(PLATFORM_OS),OSX) ifeq ($(PLATFORM_OS),OSX)
# libraries for OS X 10.9 desktop compiling # libraries for OS X 10.9 desktop compiling

View File

@ -4,7 +4,7 @@
* *
* Level00 Screen Functions Definitions (Init, Update, Draw, Unload) * Level00 Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Level01 Screen Functions Definitions (Init, Update, Draw, Unload) * Level01 Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Level02 Screen Functions Definitions (Init, Update, Draw, Unload) * Level02 Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Level03 Screen Functions Definitions (Init, Update, Draw, Unload) * Level03 Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Level04 Screen Functions Definitions (Init, Update, Draw, Unload) * Level04 Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Level05 Screen Functions Definitions (Init, Update, Draw, Unload) * Level05 Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Level06 Screen Functions Definitions (Init, Update, Draw, Unload) * Level06 Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Level07 Screen Functions Definitions (Init, Update, Draw, Unload) * Level07 Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Level08 Screen Functions Definitions (Init, Update, Draw, Unload) * Level08 Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Level09 Screen Functions Definitions (Init, Update, Draw, Unload) * Level09 Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Level10 Screen Functions Definitions (Init, Update, Draw, Unload) * Level10 Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Logo Screen Functions Definitions (Init, Update, Draw, Unload) * Logo Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Screens Functions Declarations (Init, Update, Draw, Unload) * Screens Functions Declarations (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -10,7 +10,7 @@
* This game has been created using raylib (www.raylib.com) * This game has been created using raylib (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2015 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2015 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/

View File

@ -4,7 +4,7 @@
# #
# makefile to compile advance game for desktop platforms, Raspberry Pi and HTML5 (emscripten) # makefile to compile advance game for desktop platforms, Raspberry Pi and HTML5 (emscripten)
# #
# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) # Copyright (c) 2014 Ramon Santamaria (@raysan5)
# #
# This software is provided "as-is", without any express or implied warranty. In no event # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.
@ -114,14 +114,17 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# libraries for Debian GNU/Linux desktop compiling # libraries for Debian GNU/Linux desktop compiling
# requires the following packages: # requires the following packages:
# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw -lGLEW -lGL -lopenal LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -lpthread -ldl
# on XWindow could require also below libraries, just uncomment
LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
endif endif
ifeq ($(PLATFORM_OS),OSX) ifeq ($(PLATFORM_OS),OSX)
# libraries for OS X 10.9 desktop compiling # libraries for OS X 10.9 desktop compiling
# requires the following packages: # requires the following packages:
# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa
else endif
ifeq ($(PLATFORM_OS),WINDOWS)
# libraries for Windows desktop compiling # libraries for Windows desktop compiling
# NOTE: GLFW3 and OpenAL Soft libraries should be installed # NOTE: GLFW3 and OpenAL Soft libraries should be installed
LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32 LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32

View File

@ -4,7 +4,7 @@
* *
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) * Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -687,7 +687,7 @@ void DrawGameplayScreen(void)
} }
// Draw time left for ritual // Draw time left for ritual
DrawTextEx(font, FormatText("%02.2f", (99.0f - ritualTime)), (Vector2){ 560, 20 }, font.size, 0, WHITE); DrawTextEx(font, FormatText("%02.2f", (99.0f - ritualTime)), (Vector2){ 560, 20 }, font.baseSize, 0, WHITE);
// Draw light energy bar // Draw light energy bar
DrawRectangle(20, 30, 400, 20, GRAY); DrawRectangle(20, 30, 400, 20, GRAY);
@ -703,7 +703,7 @@ void DrawGameplayScreen(void)
// Show message: "You run out of light!!!" if player.lightEnergy <= 0 // Show message: "You run out of light!!!" if player.lightEnergy <= 0
if (player.lightEnergy < 2) if (player.lightEnergy < 2)
{ {
if ((framesCounter/20)%2) DrawTextEx(font, "YOU'RE RUNNING OUT OF LIGHT!", (Vector2){ 20, 60 }, font.size/2, 0, WHITE); if ((framesCounter/20)%2) DrawTextEx(font, "YOU'RE RUNNING OUT OF LIGHT!", (Vector2){ 20, 60 }, font.baseSize/2, 0, WHITE);
} }
} }
else if (!timeOver) // LEVEL_FINISHED else if (!timeOver) // LEVEL_FINISHED
@ -846,4 +846,4 @@ static void EnemyReset(Enemy *enemy)
enemy->speed = (float)GetRandomValue(8, 18)/10.0f; enemy->speed = (float)GetRandomValue(8, 18)/10.0f;
enemy->awakeFramesDelay = GetRandomValue(180, 1200); enemy->awakeFramesDelay = GetRandomValue(180, 1200);
} }
} }

View File

@ -4,7 +4,7 @@
* *
* Logo Screen Functions Definitions (Init, Update, Draw, Unload) * Logo Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Title Screen Functions Definitions (Init, Update, Draw, Unload) * Title Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -85,7 +85,7 @@ void DrawTitleScreen(void)
DrawText("(c) Developed by Ramon Santamaria (@raysan5)", 20, GetScreenHeight() - 40, 20, LIGHTGRAY); DrawText("(c) Developed by Ramon Santamaria (@raysan5)", 20, GetScreenHeight() - 40, 20, LIGHTGRAY);
if ((framesCounter > 180) && ((framesCounter/40)%2)) DrawTextEx(font, "PRESS ENTER to START LIGHTING", (Vector2){ 230, 450 }, font.size, -2, WHITE); if ((framesCounter > 180) && ((framesCounter/40)%2)) DrawTextEx(font, "PRESS ENTER to START LIGHTING", (Vector2){ 230, 450 }, font.baseSize, -2, WHITE);
} }
// Title Screen Unload logic // Title Screen Unload logic
@ -102,4 +102,4 @@ void UnloadTitleScreen(void)
int FinishTitleScreen(void) int FinishTitleScreen(void)
{ {
return finishScreen; return finishScreen;
} }

View File

@ -4,7 +4,7 @@
* *
* Screens Functions Declarations (Init, Update, Draw, Unload) * Screens Functions Declarations (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
# #
# makefile to compile advance game for desktop platforms, Raspberry Pi and HTML5 (emscripten) # makefile to compile advance game for desktop platforms, Raspberry Pi and HTML5 (emscripten)
# #
# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) # Copyright (c) 2014 Ramon Santamaria (@raysan5)
# #
# This software is provided "as-is", without any express or implied warranty. In no event # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.
@ -119,7 +119,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -pthread -ldl LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -pthread -ldl
# on XWindow could require also below libraries, just uncomment # on XWindow could require also below libraries, just uncomment
#LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
else else
ifeq ($(PLATFORM_OS),OSX) ifeq ($(PLATFORM_OS),OSX)
# libraries for OS X 10.9 desktop compiling # libraries for OS X 10.9 desktop compiling

View File

@ -5,7 +5,7 @@
* This show has been created using raylib v1.4 (www.raylib.com) * This show has been created using raylib v1.4 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/
@ -709,11 +709,11 @@ void UpdateDrawOneFrame(void)
{ {
DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x5c5a5aff)); DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x5c5a5aff));
DrawTextEx(fontRomulus, "Open-Close Window", (Vector2){ 48, 230 }, fontRomulus.size*2, 4, GetColor(0x5c5a5aff)); DrawTextEx(fontRomulus, "Open-Close Window", (Vector2){ 48, 230 }, fontRomulus.baseSize*2, 4, GetColor(0x5c5a5aff));
DrawTextEx(fontRomulus, "Manage Drawing Area", (Vector2){ 48, 260 }, fontRomulus.size*2, 4, GetColor(0x5c5a5aff)); DrawTextEx(fontRomulus, "Manage Drawing Area", (Vector2){ 48, 260 }, fontRomulus.baseSize*2, 4, GetColor(0x5c5a5aff));
DrawTextEx(fontRomulus, "Manage Inputs", (Vector2){ 48, 290 }, fontRomulus.size*2, 4, GetColor(0x5c5a5aff)); DrawTextEx(fontRomulus, "Manage Inputs", (Vector2){ 48, 290 }, fontRomulus.baseSize*2, 4, GetColor(0x5c5a5aff));
DrawTextEx(fontRomulus, "Manage Timming", (Vector2){ 48, 320 }, fontRomulus.size*2, 4, GetColor(0x5c5a5aff)); DrawTextEx(fontRomulus, "Manage Timming", (Vector2){ 48, 320 }, fontRomulus.baseSize*2, 4, GetColor(0x5c5a5aff));
DrawTextEx(fontRomulus, "Auxiliar Functions", (Vector2){ 48, 350 }, fontRomulus.size*2, 4, GetColor(0x5c5a5aff)); DrawTextEx(fontRomulus, "Auxiliar Functions", (Vector2){ 48, 350 }, fontRomulus.baseSize*2, 4, GetColor(0x5c5a5aff));
switch (coreWindow) switch (coreWindow)
{ {
@ -739,16 +739,16 @@ void UpdateDrawOneFrame(void)
if (framesCounter > 140) if (framesCounter > 140)
{ {
DrawTextEx(fontMecha, "MOVE ME", (Vector2){ ballPosition.x - 26, ballPosition.y - 20 }, fontMecha.size, 2, BLACK); DrawTextEx(fontMecha, "MOVE ME", (Vector2){ ballPosition.x - 26, ballPosition.y - 20 }, fontMecha.baseSize, 2, BLACK);
DrawTextEx(fontMecha, "[ W A S D ]", (Vector2){ ballPosition.x - 36, ballPosition.y }, fontMecha.size, 2, BLACK); DrawTextEx(fontMecha, "[ W A S D ]", (Vector2){ ballPosition.x - 36, ballPosition.y }, fontMecha.baseSize, 2, BLACK);
} }
} break; } break;
case SHAPES: case SHAPES:
{ {
DrawText("This module give you functions to:", 48, 200, 10, GetColor(0xcd5757ff)); DrawText("This module give you functions to:", 48, 200, 10, GetColor(0xcd5757ff));
DrawTextEx(fontRomulus, "Draw Basic Shapes", (Vector2){ 48, 230 }, fontRomulus.size*2, 4, GetColor(0xcd5757ff)); DrawTextEx(fontRomulus, "Draw Basic Shapes", (Vector2){ 48, 230 }, fontRomulus.baseSize*2, 4, GetColor(0xcd5757ff));
DrawTextEx(fontRomulus, "Basic Collision Detection", (Vector2){ 48, 260 }, fontRomulus.size*2, 4, GetColor(0xcd5757ff)); DrawTextEx(fontRomulus, "Basic Collision Detection", (Vector2){ 48, 260 }, fontRomulus.baseSize*2, 4, GetColor(0xcd5757ff));
DrawCircle(screenWidth/4, 120 + 240, 35, DARKBLUE); DrawCircle(screenWidth/4, 120 + 240, 35, DARKBLUE);
DrawCircleGradient(screenWidth/4, 220 + 240, 60, GREEN, SKYBLUE); DrawCircleGradient(screenWidth/4, 220 + 240, 60, GREEN, SKYBLUE);
@ -769,8 +769,8 @@ void UpdateDrawOneFrame(void)
{ {
DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x60815aff)); DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x60815aff));
DrawTextEx(fontRomulus, "Load Images and Textures", (Vector2){ 48, 230 }, fontRomulus.size*2, 4, GetColor(0x60815aff)); DrawTextEx(fontRomulus, "Load Images and Textures", (Vector2){ 48, 230 }, fontRomulus.baseSize*2, 4, GetColor(0x60815aff));
DrawTextEx(fontRomulus, "Draw Textures", (Vector2){ 48, 260 }, fontRomulus.size*2, 4, GetColor(0x60815aff)); DrawTextEx(fontRomulus, "Draw Textures", (Vector2){ 48, 260 }, fontRomulus.baseSize*2, 4, GetColor(0x60815aff));
DrawRectangle(138, 348, 260, 260, GRAY); DrawRectangle(138, 348, 260, 260, GRAY);
DrawTexturePro(lena, (Rectangle){ 0, 0, lena.width, lena.height }, (Rectangle){ 140 + 128, 350 + 128, lena.width/2*scaleFactor, lena.height/2*scaleFactor }, (Vector2){ lena.width/4*scaleFactor, lena.height/4*scaleFactor }, 0.0f, WHITE); DrawTexturePro(lena, (Rectangle){ 0, 0, lena.width, lena.height }, (Rectangle){ 140 + 128, 350 + 128, lena.width/2*scaleFactor, lena.height/2*scaleFactor }, (Vector2){ lena.width/4*scaleFactor, lena.height/4*scaleFactor }, 0.0f, WHITE);
@ -786,21 +786,21 @@ void UpdateDrawOneFrame(void)
{ {
DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x377764ff)); DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x377764ff));
DrawTextEx(fontRomulus, "Load SpriteFonts", (Vector2){ 48, 230 }, fontRomulus.size*2, 4, GetColor(0x377764ff)); DrawTextEx(fontRomulus, "Load SpriteFonts", (Vector2){ 48, 230 }, fontRomulus.baseSize*2, 4, GetColor(0x377764ff));
DrawTextEx(fontRomulus, "Draw Text", (Vector2){ 48, 260 }, fontRomulus.size*2, 4, GetColor(0x377764ff)); DrawTextEx(fontRomulus, "Draw Text", (Vector2){ 48, 260 }, fontRomulus.baseSize*2, 4, GetColor(0x377764ff));
DrawTextEx(fontRomulus, "Text Formatting", (Vector2){ 48, 290 }, fontRomulus.size*2, 4, GetColor(0x377764ff)); DrawTextEx(fontRomulus, "Text Formatting", (Vector2){ 48, 290 }, fontRomulus.baseSize*2, 4, GetColor(0x377764ff));
DrawTexture(texAlagard, 60, 360, WHITE); DrawTexture(texAlagard, 60, 360, WHITE);
DrawTextEx(fontMechaC, msg1, (Vector2){ 540 + 168, 210 }, fontMechaC.size, -3, WHITE); DrawTextEx(fontMechaC, msg1, (Vector2){ 540 + 168, 210 }, fontMechaC.baseSize, -3, WHITE);
DrawTextEx(fontAlagardC, msg2, (Vector2){ 460 + 140, 260 }, fontAlagardC.size, -2, WHITE); DrawTextEx(fontAlagardC, msg2, (Vector2){ 460 + 140, 260 }, fontAlagardC.baseSize, -2, WHITE);
DrawTextEx(fontJupiterC, msg3, (Vector2){ 640 + 70, 300 }, fontJupiterC.size, 2, WHITE); DrawTextEx(fontJupiterC, msg3, (Vector2){ 640 + 70, 300 }, fontJupiterC.baseSize, 2, WHITE);
DrawTextEx(fontAlagard, "It also includes some...", (Vector2){ 650 + 70, 400 }, fontAlagard.size*2, 2, MAROON); DrawTextEx(fontAlagard, "It also includes some...", (Vector2){ 650 + 70, 400 }, fontAlagard.baseSize*2, 2, MAROON);
DrawTextEx(fontPixelplay, "...free fonts in rBMF format...", (Vector2){ 705 - 26, 450 }, fontPixelplay.size*2, 4, ORANGE); DrawTextEx(fontPixelplay, "...free fonts in rBMF format...", (Vector2){ 705 - 26, 450 }, fontPixelplay.baseSize*2, 4, ORANGE);
DrawTextEx(fontMecha, "...to be used even in...", (Vector2){ 700 + 40, 500 }, fontMecha.size*2, 4, DARKGREEN); DrawTextEx(fontMecha, "...to be used even in...", (Vector2){ 700 + 40, 500 }, fontMecha.baseSize*2, 4, DARKGREEN);
DrawTextEx(fontSetback, "...comercial projects...", (Vector2){ 710, 550 }, fontSetback.size*2, 4, DARKBLUE); DrawTextEx(fontSetback, "...commercial projects...", (Vector2){ 710, 550 }, fontSetback.baseSize*2, 4, DARKBLUE);
DrawTextEx(fontRomulus, "...completely for free!", (Vector2){ 710 + 17, 600 }, fontRomulus.size*2, 3, DARKPURPLE); DrawTextEx(fontRomulus, "...completely for free!", (Vector2){ 710 + 17, 600 }, fontRomulus.baseSize*2, 3, DARKPURPLE);
DrawText("This is a custom font spritesheet, raylib can load it automatically!", 228, 360 + 295, 10, GRAY); DrawText("This is a custom font spritesheet, raylib can load it automatically!", 228, 360 + 295, 10, GRAY);
@ -809,9 +809,9 @@ void UpdateDrawOneFrame(void)
{ {
DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x417794ff)); DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x417794ff));
DrawTextEx(fontRomulus, "Draw Geometric Models", (Vector2){ 48, 230 }, fontRomulus.size*2, 4, GetColor(0x417794ff)); DrawTextEx(fontRomulus, "Draw Geometric Models", (Vector2){ 48, 230 }, fontRomulus.baseSize*2, 4, GetColor(0x417794ff));
DrawTextEx(fontRomulus, "Load 3D Models", (Vector2){ 48, 260 }, fontRomulus.size*2, 4, GetColor(0x417794ff)); DrawTextEx(fontRomulus, "Load 3D Models", (Vector2){ 48, 260 }, fontRomulus.baseSize*2, 4, GetColor(0x417794ff));
DrawTextEx(fontRomulus, "Draw 3D Models", (Vector2){ 48, 290 }, fontRomulus.size*2, 4, GetColor(0x417794ff)); DrawTextEx(fontRomulus, "Draw 3D Models", (Vector2){ 48, 290 }, fontRomulus.baseSize*2, 4, GetColor(0x417794ff));
Begin3dMode(camera); Begin3dMode(camera);
@ -843,8 +843,8 @@ void UpdateDrawOneFrame(void)
{ {
DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x8c7539ff)); DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x8c7539ff));
DrawTextEx(fontRomulus, "Load and Play Sounds", (Vector2){ 48, 230 }, fontRomulus.size*2, 4, GetColor(0x8c7539ff)); DrawTextEx(fontRomulus, "Load and Play Sounds", (Vector2){ 48, 230 }, fontRomulus.baseSize*2, 4, GetColor(0x8c7539ff));
DrawTextEx(fontRomulus, "Play Music (streaming)", (Vector2){ 48, 260 }, fontRomulus.size*2, 4, GetColor(0x8c7539ff)); DrawTextEx(fontRomulus, "Play Music (streaming)", (Vector2){ 48, 260 }, fontRomulus.baseSize*2, 4, GetColor(0x8c7539ff));
DrawText("PRESS SPACE to START PLAYING MUSIC", 135, 350, 20, GRAY); DrawText("PRESS SPACE to START PLAYING MUSIC", 135, 350, 20, GRAY);
DrawRectangle(150, 390, 400, 12, LIGHTGRAY); DrawRectangle(150, 390, 400, 12, LIGHTGRAY);
@ -897,7 +897,7 @@ void UpdateDrawOneFrame(void)
case ENDING: case ENDING:
{ {
// Draw ENDING screen // Draw ENDING screen
DrawTextEx(fontAlagard, "LEARN VIDEOGAMES PROGRAMMING", (Vector2){ screenWidth/2 - MeasureTextEx(fontAlagard, "LEARN VIDEOGAMES PROGRAMMING", fontAlagard.size*4, 4).x/2, 80 }, fontAlagard.size*4, 4, MAROON); DrawTextEx(fontAlagard, "LEARN VIDEOGAMES PROGRAMMING", (Vector2){ screenWidth/2 - MeasureTextEx(fontAlagard, "LEARN VIDEOGAMES PROGRAMMING", fontAlagard.baseSize*4, 4).x/2, 80 }, fontAlagard.baseSize*4, 4, MAROON);
DrawTexture(raylibLogoA, logoPositionX, logoPositionY - 40, WHITE); DrawTexture(raylibLogoA, logoPositionX, logoPositionY - 40, WHITE);
@ -929,4 +929,4 @@ void UpdateDrawOneFrame(void)
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }

View File

@ -4,7 +4,7 @@
# #
# makefile to compile advance game # makefile to compile advance game
# #
# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) # Copyright (c) 2014 Ramon Santamaria (@raysan5)
# #
# This software is provided "as-is", without any express or implied warranty. In no event # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.
@ -116,7 +116,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev # libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -pthread -ldl LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lm -pthread -ldl
# on XWindow could require also below libraries, just uncomment # on XWindow could require also below libraries, just uncomment
#LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
else else
ifeq ($(PLATFORM_OS),OSX) ifeq ($(PLATFORM_OS),OSX)
# libraries for OS X 10.9 desktop compiling # libraries for OS X 10.9 desktop compiling

View File

@ -8,7 +8,7 @@
* This game has been created using raylib (www.raylib.com) * This game has been created using raylib (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
************************************************************************************/ ************************************************************************************/

View File

@ -4,7 +4,7 @@
* *
* Screens Functions Declarations (Init, Update, Draw, Unload) * Screens Functions Declarations (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -8,7 +8,7 @@
* This game has been created using raylib (www.raylib.com) * This game has been created using raylib (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
************************************************************************************/ ************************************************************************************/

View File

@ -4,7 +4,7 @@
* *
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) * Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -362,11 +362,11 @@ void DrawAisle01Screen(void)
if (msgState == 0) if (msgState == 0)
{ {
DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
} }
else if (msgState == 1) else if (msgState == 1)
{ {
DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
} }
@ -374,7 +374,7 @@ void DrawAisle01Screen(void)
{ {
if ((msgCounter/30)%2) if ((msgCounter/30)%2)
{ {
DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE); DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE);
DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f)); DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f));
DrawRectangleRec(picture.bounds, Fade(RED, 0.6f)); DrawRectangleRec(picture.bounds, Fade(RED, 0.6f));
@ -406,4 +406,4 @@ void UnloadAisle01Screen(void)
int FinishAisle01Screen(void) int FinishAisle01Screen(void)
{ {
return finishScreen; return finishScreen;
} }

View File

@ -4,7 +4,7 @@
* *
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) * Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -393,11 +393,11 @@ void DrawAisle02Screen(void)
if (msgState == 0) if (msgState == 0)
{ {
DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
} }
else if (msgState == 1) else if (msgState == 1)
{ {
DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
} }
@ -405,7 +405,7 @@ void DrawAisle02Screen(void)
{ {
if ((msgCounter/30)%2) if ((msgCounter/30)%2)
{ {
DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE); DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE);
DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f)); DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f));
DrawRectangleRec(arc.bounds, Fade(RED, 0.6f)); DrawRectangleRec(arc.bounds, Fade(RED, 0.6f));
@ -441,4 +441,4 @@ void UnloadAisle02Screen(void)
int FinishAisle02Screen(void) int FinishAisle02Screen(void)
{ {
return finishScreen; return finishScreen;
} }

View File

@ -4,7 +4,7 @@
* *
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) * Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -355,11 +355,11 @@ void DrawArmoryScreen(void)
if (msgState == 0) if (msgState == 0)
{ {
DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
} }
else if (msgState == 1) else if (msgState == 1)
{ {
DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
} }
@ -367,7 +367,7 @@ void DrawArmoryScreen(void)
{ {
if ((msgCounter/30)%2) if ((msgCounter/30)%2)
{ {
DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE); DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE);
DrawRectangleRec(blazon01.bounds, Fade(RED, 0.6f)); DrawRectangleRec(blazon01.bounds, Fade(RED, 0.6f));
DrawRectangleRec(blazon02.bounds, Fade(RED, 0.6f)); DrawRectangleRec(blazon02.bounds, Fade(RED, 0.6f));
@ -401,4 +401,4 @@ void UnloadArmoryScreen(void)
int FinishArmoryScreen(void) int FinishArmoryScreen(void)
{ {
return finishScreen; return finishScreen;
} }

View File

@ -4,7 +4,7 @@
* *
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) * Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -285,11 +285,11 @@ void DrawAtticScreen(void)
if (msgState == 0) if (msgState == 0)
{ {
DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
} }
else if (msgState == 1) else if (msgState == 1)
{ {
DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
} }
@ -297,7 +297,7 @@ void DrawAtticScreen(void)
{ {
if ((msgCounter/30)%2) if ((msgCounter/30)%2)
{ {
DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE); DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE);
DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f)); DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f));
DrawRectangleRec(arc.bounds, Fade(RED, 0.6f)); DrawRectangleRec(arc.bounds, Fade(RED, 0.6f));
@ -329,4 +329,4 @@ void UnloadAtticScreen(void)
int FinishAtticScreen(void) int FinishAtticScreen(void)
{ {
return finishScreen; return finishScreen;
} }

View File

@ -4,7 +4,7 @@
* *
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) * Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -334,11 +334,11 @@ void DrawBathroomScreen(void)
if (msgState == 0) if (msgState == 0)
{ {
DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
} }
else if (msgState == 1) else if (msgState == 1)
{ {
DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
} }
@ -346,7 +346,7 @@ void DrawBathroomScreen(void)
{ {
if ((msgCounter/30)%2) if ((msgCounter/30)%2)
{ {
DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE); DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE);
DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f)); DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f));
DrawRectangleRec(mirror.bounds, Fade(RED, 0.6f)); DrawRectangleRec(mirror.bounds, Fade(RED, 0.6f));
@ -380,4 +380,4 @@ void UnloadBathroomScreen(void)
int FinishBathroomScreen(void) int FinishBathroomScreen(void)
{ {
return finishScreen; return finishScreen;
} }

View File

@ -4,7 +4,7 @@
* *
* Ending Screen Functions Definitions (Init, Update, Draw, Unload) * Ending Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -71,8 +71,8 @@ void DrawEndingScreen(void)
{ {
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), DARKGRAY); DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), DARKGRAY);
DrawTextEx(font, "CONGRATULATIONS!", (Vector2){ 50, 160 }, font.size*3, 2, Fade(WHITE, alpha)); DrawTextEx(font, "CONGRATULATIONS!", (Vector2){ 50, 160 }, font.baseSize*3, 2, Fade(WHITE, alpha));
DrawTextEx(font, "SKULLY ESCAPED!", (Vector2){ 100, 300 }, font.size*3, 2, Fade(WHITE, alpha)); DrawTextEx(font, "SKULLY ESCAPED!", (Vector2){ 100, 300 }, font.baseSize*3, 2, Fade(WHITE, alpha));
if ((framesCounter > 180) && ((framesCounter/40)%2)) DrawText("PRESS ENTER or CLICK", 380, 545, 40, BLACK); if ((framesCounter > 180) && ((framesCounter/40)%2)) DrawText("PRESS ENTER or CLICK", 380, 545, 40, BLACK);
} }
@ -87,4 +87,4 @@ void UnloadEndingScreen(void)
int FinishEndingScreen(void) int FinishEndingScreen(void)
{ {
return finishScreen; return finishScreen;
} }

View File

@ -4,7 +4,7 @@
* *
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) * Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -354,11 +354,11 @@ void DrawKitchenScreen(void)
if (msgState == 0) if (msgState == 0)
{ {
DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
} }
else if (msgState == 1) else if (msgState == 1)
{ {
DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
} }
@ -366,7 +366,7 @@ void DrawKitchenScreen(void)
{ {
if ((msgCounter/30)%2) if ((msgCounter/30)%2)
{ {
DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE); DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE);
DrawRectangleRec(closet.bounds, Fade(RED, 0.6f)); DrawRectangleRec(closet.bounds, Fade(RED, 0.6f));
DrawRectangleRec(window.bounds, Fade(RED, 0.6f)); DrawRectangleRec(window.bounds, Fade(RED, 0.6f));
@ -400,4 +400,4 @@ void UnloadKitchenScreen(void)
int FinishKitchenScreen(void) int FinishKitchenScreen(void)
{ {
return finishScreen; return finishScreen;
} }

View File

@ -4,7 +4,7 @@
* *
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) * Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -354,11 +354,11 @@ void DrawLivingroomScreen(void)
if (msgState == 0) if (msgState == 0)
{ {
DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
} }
else if (msgState == 1) else if (msgState == 1)
{ {
DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE); DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK); if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
} }
@ -366,7 +366,7 @@ void DrawLivingroomScreen(void)
{ {
if ((msgCounter/30)%2) if ((msgCounter/30)%2)
{ {
DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE); DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE);
DrawRectangleRec(candle.bounds, Fade(RED, 0.6f)); DrawRectangleRec(candle.bounds, Fade(RED, 0.6f));
DrawRectangleRec(phone.bounds, Fade(RED, 0.6f)); DrawRectangleRec(phone.bounds, Fade(RED, 0.6f));
@ -400,4 +400,4 @@ void UnloadLivingroomScreen(void)
int FinishLivingroomScreen(void) int FinishLivingroomScreen(void)
{ {
return finishScreen; return finishScreen;
} }

View File

@ -4,7 +4,7 @@
* *
* Logo Screen Functions Definitions (Init, Update, Draw, Unload) * Logo Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Logo Screen Functions Definitions (Init, Update, Draw, Unload) * Logo Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Title Screen Functions Definitions (Init, Update, Draw, Unload) * Title Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Screens Functions Declarations (Init, Update, Draw, Unload) * Screens Functions Declarations (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -5,7 +5,7 @@
* This game has been created using raylib 1.6 (www.raylib.com) * This game has been created using raylib 1.6 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/

View File

@ -4,7 +4,7 @@
# #
# makefile to compile advance game for desktop platforms, Raspberry Pi and HTML5 (emscripten) # makefile to compile advance game for desktop platforms, Raspberry Pi and HTML5 (emscripten)
# #
# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) # Copyright (c) 2014 Ramon Santamaria (@raysan5)
# #
# This software is provided "as-is", without any express or implied warranty. In no event # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Ending Screen Functions Definitions (Init, Update, Draw, Unload) * Ending Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -77,12 +77,12 @@ void DrawEndingScreen(void)
if (endingStatus == 1) // Win if (endingStatus == 1) // Win
{ {
DrawTexture(texWin, GetScreenWidth()/2 - texWin.width/2, 90, WHITE); DrawTexture(texWin, GetScreenWidth()/2 - texWin.width/2, 90, WHITE);
DrawTextEx(font, "congrats, you got the wave!", (Vector2){ 200, 335 }, font.size, 0, WHITE); DrawTextEx(font, "congrats, you got the wave!", (Vector2){ 200, 335 }, font.baseSize, 0, WHITE);
} }
else if (endingStatus == 2) // Lose else if (endingStatus == 2) // Lose
{ {
DrawTexture(texLose, GetScreenWidth()/2 - texWin.width/2, 90, WHITE); DrawTexture(texLose, GetScreenWidth()/2 - texWin.width/2, 90, WHITE);
DrawTextEx(font, "it seems you lose the wave...", (Vector2){ 205, 335 }, font.size, 0, WHITE); DrawTextEx(font, "it seems you lose the wave...", (Vector2){ 205, 335 }, font.baseSize, 0, WHITE);
} }
DrawRectangle(0, GetScreenHeight() - 70, 560, 40, Fade(RAYWHITE, 0.8f)); DrawRectangle(0, GetScreenHeight() - 70, 560, 40, Fade(RAYWHITE, 0.8f));
@ -91,7 +91,7 @@ void DrawEndingScreen(void)
DrawText("powered by", GetScreenWidth() - 162, GetScreenHeight() - 190, 20, DARKGRAY); DrawText("powered by", GetScreenWidth() - 162, GetScreenHeight() - 190, 20, DARKGRAY);
DrawTexture(texLogo, GetScreenWidth() - 128 - 34, GetScreenHeight() - 128 - 36, WHITE); DrawTexture(texLogo, GetScreenWidth() - 128 - 34, GetScreenHeight() - 128 - 36, WHITE);
if ((framesCounter > 80) && ((framesCounter/40)%2)) DrawTextEx(font, "mouse click to return", (Vector2){ 300, 464 }, font.size, 0, SKYBLUE); if ((framesCounter > 80) && ((framesCounter/40)%2)) DrawTextEx(font, "mouse click to return", (Vector2){ 300, 464 }, font.baseSize, 0, SKYBLUE);
} }
// Ending Screen Unload logic // Ending Screen Unload logic

View File

@ -4,7 +4,7 @@
* *
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) * Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -399,15 +399,15 @@ void DrawGameplayScreen(void)
DrawTexture(texPlayer, player.position.x - 32, player.position.y - 24, WHITE); DrawTexture(texPlayer, player.position.x - 32, player.position.y - 24, WHITE);
// Draw pause message // Draw pause message
if (pause) DrawTextEx(font, "WAVE PAUSED", (Vector2){ 235, 400 }, font.size*2, 0, WHITE); if (pause) DrawTextEx(font, "WAVE PAUSED", (Vector2){ 235, 400 }, font.baseSize*2, 0, WHITE);
// Draw number of samples // Draw number of samples
//DrawText(FormatText("%05i", collectedSamples), 900, 200, 40, GRAY); //DrawText(FormatText("%05i", collectedSamples), 900, 200, 40, GRAY);
//DrawText(FormatText("%05i", totalSamples), 900, 250, 40, GRAY); //DrawText(FormatText("%05i", totalSamples), 900, 250, 40, GRAY);
DrawTextEx(font, FormatText("%05i / %05i", collectedSamples, totalSamples), (Vector2){810, 170}, font.size, -2, SKYBLUE); DrawTextEx(font, FormatText("%05i / %05i", collectedSamples, totalSamples), (Vector2){810, 170}, font.baseSize, -2, SKYBLUE);
// Draw combo // Draw combo
DrawTextEx(font, FormatText("Combo: %02i [max: %02i]", combo, maxCombo), (Vector2){200, 170}, font.size/2, -2, SKYBLUE); DrawTextEx(font, FormatText("Combo: %02i [max: %02i]", combo, maxCombo), (Vector2){200, 170}, font.baseSize/2, -2, SKYBLUE);
// Draw synchonicity level // Draw synchonicity level
DrawRectangle(99, 622, 395, 32, Fade(RAYWHITE, 0.8f)); DrawRectangle(99, 622, 395, 32, Fade(RAYWHITE, 0.8f));
@ -419,15 +419,15 @@ void DrawGameplayScreen(void)
DrawRectangleLines(99, 622, 395, 32, MAROON); DrawRectangleLines(99, 622, 395, 32, MAROON);
if (synchro == 1.0f) DrawTextEx(font, FormatText("%02i%%", (int)(synchro*100)), (Vector2){99 + 390, 600}, font.size, -2, GREEN); if (synchro == 1.0f) DrawTextEx(font, FormatText("%02i%%", (int)(synchro*100)), (Vector2){99 + 390, 600}, font.baseSize, -2, GREEN);
else DrawTextEx(font, FormatText("%02i%%", (int)(synchro*100)), (Vector2){99 + 390, 600}, font.size, -2, SKYBLUE); else DrawTextEx(font, FormatText("%02i%%", (int)(synchro*100)), (Vector2){99 + 390, 600}, font.baseSize, -2, SKYBLUE);
// Draw time warp coool-down bar // Draw time warp coool-down bar
DrawRectangle(754, 622, 395, 32, Fade(RAYWHITE, 0.8f)); DrawRectangle(754, 622, 395, 32, Fade(RAYWHITE, 0.8f));
DrawRectangle(754, 622, warpCounter, 32, Fade(SKYBLUE, 0.8f)); DrawRectangle(754, 622, warpCounter, 32, Fade(SKYBLUE, 0.8f));
DrawRectangleLines(754, 622, 395, 32, DARKGRAY); DrawRectangleLines(754, 622, 395, 32, DARKGRAY);
//DrawText(FormatText("%02i%%", (int)(synchro*100)), 754 + 410, 628, 20, DARKGRAY); //DrawText(FormatText("%02i%%", (int)(synchro*100)), 754 + 410, 628, 20, DARKGRAY);
DrawTextEx(font, FormatText("%02i%%", (int)((float)warpCounter/395.0f*100.0f)), (Vector2){754 + 390, 600}, font.size, -2, SKYBLUE); DrawTextEx(font, FormatText("%02i%%", (int)((float)warpCounter/395.0f*100.0f)), (Vector2){754 + 390, 600}, font.baseSize, -2, SKYBLUE);
// Draw wave // Draw wave
// NOTE: Old drawing method, replaced by rendertarget // NOTE: Old drawing method, replaced by rendertarget

View File

@ -4,7 +4,7 @@
* *
* Logo Screen Functions Definitions (Init, Update, Draw, Unload) * Logo Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Title Screen Functions Definitions (Init, Update, Draw, Unload) * Title Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -91,7 +91,7 @@ void DrawTitleScreen(void)
DrawText("powered by", GetScreenWidth() - 162, GetScreenHeight() - 190, 20, DARKGRAY); DrawText("powered by", GetScreenWidth() - 162, GetScreenHeight() - 190, 20, DARKGRAY);
DrawTexture(texLogo, GetScreenWidth() - 128 - 34, GetScreenHeight() - 128 - 36, WHITE); DrawTexture(texLogo, GetScreenWidth() - 128 - 34, GetScreenHeight() - 128 - 36, WHITE);
if ((framesCounter > 160) && ((framesCounter/40)%2)) DrawTextEx(font, "mouse click to start", (Vector2){ 325, 500 }, font.size, 0, SKYBLUE); if ((framesCounter > 160) && ((framesCounter/40)%2)) DrawTextEx(font, "mouse click to start", (Vector2){ 325, 500 }, font.baseSize, 0, SKYBLUE);
} }
// Title Screen Unload logic // Title Screen Unload logic

View File

@ -4,7 +4,7 @@
* *
* Screens Functions Declarations (Init, Update, Draw, Unload) * Screens Functions Declarations (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -7,7 +7,7 @@
* The level is actually the wave and the wave is the level! * The level is actually the wave and the wave is the level!
* Be fast! Be smart! Be the best wave collector! * Be fast! Be smart! Be the best wave collector!
* *
* This game has been created using raylib (www.raylib.com) * This game has been created using raylib v1.7 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2017 Ramon Santamaria (@raysan5) * Copyright (c) 2017 Ramon Santamaria (@raysan5)

View File

@ -1,7 +1,7 @@
#****************************************************************************** #******************************************************************************
# #
# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) # raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten)
# #
# Many Thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline. # Many Thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline.
# #
# Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) # Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
@ -153,12 +153,34 @@ endif
# define compiler flags: # define compiler flags:
# -O1 defines optimization level # -O1 defines optimization level
# -Og enable debugging
# -Wall turns on most, but not all, compiler warnings # -Wall turns on most, but not all, compiler warnings
# -std=c99 defines C language mode (standard C from 1999 revision) # -std=c99 defines C language mode (standard C from 1999 revision)
# -std=gnu99 defines C language mode (GNU C from 1999 revision) # -std=gnu99 defines C language mode (GNU C from 1999 revision)
# -fgnu89-inline declaring inline functions support (GCC optimized) # -fgnu89-inline declaring inline functions support (GCC optimized)
# -Wno-missing-braces ignore invalid warning (GCC bug 53119) # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces # -D_DEFAULT_SOURCE use with -std=c99 on Linux to enable timespec and drflac
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),WINDOWS)
CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces
endif
ifeq ($(PLATFORM_OS),LINUX)
CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE
endif
ifeq ($(PLATFORM_OS),OSX)
CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
CFLAGS = -O1 -Wall -std=c99 -s USE_GLFW=3 -s ASSERTIONS=1 --preload-file resources
#-s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
#-s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces
endif
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
# if shared library required, make sure code is compiled as position independent # if shared library required, make sure code is compiled as position independent
ifeq ($(SHARED),YES) ifeq ($(SHARED),YES)
@ -243,7 +265,7 @@ OBJS += external/stb_vorbis.o
# typing 'make' will invoke the default target entry called 'all', # typing 'make' will invoke the default target entry called 'all',
# in this case, the 'default' target entry is raylib # in this case, the 'default' target entry is raylib
all: toolchain raylib all: toolchain raylib
# make standalone Android toolchain # make standalone Android toolchain
toolchain: toolchain:
@ -266,7 +288,7 @@ else
ifeq ($(SHARED),YES) ifeq ($(SHARED),YES)
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
# compile raylib to shared library version for GNU/Linux. # compile raylib to shared library version for GNU/Linux.
# WARNING: you should type "make clean" before doing this target # WARNING: you should type "make clean" before doing this target
$(CC) -shared -o $(OUTPUT_PATH)/libraylib.so $(OBJS) $(CC) -shared -o $(OUTPUT_PATH)/libraylib.so $(OBJS)
@echo "raylib shared library (libraylib.so) generated!" @echo "raylib shared library (libraylib.so) generated!"
endif endif
@ -299,11 +321,11 @@ core.o : core.c raylib.h rlgl.h utils.h raymath.h gestures.h
# compile rlgl module # compile rlgl module
rlgl.o : rlgl.c rlgl.h raymath.h rlgl.o : rlgl.c rlgl.h raymath.h
$(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(GRAPHICS) $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(GRAPHICS)
# compile shapes module # compile shapes module
shapes.o : shapes.c raylib.h rlgl.h shapes.o : shapes.c raylib.h rlgl.h
$(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(SHAREDFLAG) $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(SHAREDFLAG)
# compile textures module # compile textures module
textures.o : textures.c rlgl.h utils.h textures.o : textures.c rlgl.h utils.h
$(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(GRAPHICS) -D$(SHAREDFLAG) $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(GRAPHICS) -D$(SHAREDFLAG)
@ -319,7 +341,7 @@ models.o : models.c raylib.h rlgl.h raymath.h
# compile audio module # compile audio module
audio.o : audio.c raylib.h audio.o : audio.c raylib.h
$(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(SHAREDFLAG) -D$(SHAREDOPENALFLAG) $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(SHAREDFLAG) -D$(SHAREDOPENALFLAG)
# compile stb_vorbis library # compile stb_vorbis library
external/stb_vorbis.o: external/stb_vorbis.c external/stb_vorbis.h external/stb_vorbis.o: external/stb_vorbis.c external/stb_vorbis.h
$(CC) -c -o $@ $< -O1 $(CFLAGS) $(INCLUDES) -D$(PLATFORM) $(CC) -c -o $@ $< -O1 $(CFLAGS) $(INCLUDES) -D$(PLATFORM)

View File

@ -1,26 +1,22 @@
/********************************************************************************************** /**********************************************************************************************
* *
* raylib.audio * raylib.audio - Basic funtionality to work with audio
* *
* This module provides basic functionality to work with audio: * FEATURES:
* Manage audio device (init/close) * - Manage audio device (init/close)
* Load and Unload audio files (WAV, OGG, FLAC, XM, MOD) * - Load and unload audio files
* Play/Stop/Pause/Resume loaded audio * - Format wave data (sample rate, size, channels)
* Manage mixing channels * - Play/Stop/Pause/Resume loaded audio
* Manage raw audio context * - Manage mixing channels
* * - Manage raw audio context
* NOTES:
*
* Only up to two channels supported: MONO and STEREO (for additional channels, use AL_EXT_MCFORMATS)
* Only the following sample sizes supported: 8bit PCM, 16bit PCM, 32-bit float PCM (using AL_EXT_FLOAT32)
* *
* CONFIGURATION: * CONFIGURATION:
* *
* #define AUDIO_STANDALONE * #define AUDIO_STANDALONE
* If defined, the module can be used as standalone library (independently of raylib). * Define to use the module as standalone library (independently of raylib).
* Required types and functions are defined in the same module. * Required types and functions are defined in the same module.
* *
* #define SUPPORT_FILEFORMAT_WAV / SUPPORT_LOAD_WAV / ENABLE_LOAD_WAV * #define SUPPORT_FILEFORMAT_WAV
* #define SUPPORT_FILEFORMAT_OGG * #define SUPPORT_FILEFORMAT_OGG
* #define SUPPORT_FILEFORMAT_XM * #define SUPPORT_FILEFORMAT_XM
* #define SUPPORT_FILEFORMAT_MOD * #define SUPPORT_FILEFORMAT_MOD
@ -28,7 +24,10 @@
* Selected desired fileformats to be supported for loading. Some of those formats are * Selected desired fileformats to be supported for loading. Some of those formats are
* supported by default, to remove support, just comment unrequired #define in this module * supported by default, to remove support, just comment unrequired #define in this module
* *
* #define SUPPORT_RAW_AUDIO_BUFFERS *
* LIMITATIONS:
* Only up to two channels supported: MONO and STEREO (for additional channels, use AL_EXT_MCFORMATS)
* Only the following sample sizes supported: 8bit PCM, 16bit PCM, 32-bit float PCM (using AL_EXT_FLOAT32)
* *
* DEPENDENCIES: * DEPENDENCIES:
* OpenAL Soft - Audio device management (http://kcat.strangesoft.net/openal.html) * OpenAL Soft - Audio device management (http://kcat.strangesoft.net/openal.html)
@ -38,17 +37,16 @@
* dr_flac - FLAC audio file loading * dr_flac - FLAC audio file loading
* *
* CONTRIBUTORS: * CONTRIBUTORS:
* * Joshua Reisenauer (github: @kd7tck):
* Many thanks to Joshua Reisenauer (github: @kd7tck) for the following additions: * - XM audio module support (jar_xm)
* XM audio module support (jar_xm) * - MOD audio module support (jar_mod)
* MOD audio module support (jar_mod) * - Mixing channels support
* Mixing channels support * - Raw audio context support
* Raw audio context support
* *
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -69,6 +67,12 @@
//#define AUDIO_STANDALONE // NOTE: To use the audio module as standalone lib, just uncomment this line //#define AUDIO_STANDALONE // NOTE: To use the audio module as standalone lib, just uncomment this line
// Default configuration flags (supported features)
//-------------------------------------------------
#define SUPPORT_FILEFORMAT_WAV
#define SUPPORT_FILEFORMAT_OGG
//-------------------------------------------------
#if defined(AUDIO_STANDALONE) #if defined(AUDIO_STANDALONE)
#include "audio.h" #include "audio.h"
#include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end() #include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end()
@ -93,18 +97,26 @@
#include <string.h> // Required for: strcmp(), strncmp() #include <string.h> // Required for: strcmp(), strncmp()
#include <stdio.h> // Required for: FILE, fopen(), fclose(), fread() #include <stdio.h> // Required for: FILE, fopen(), fclose(), fread()
//#define STB_VORBIS_HEADER_ONLY #if defined(SUPPORT_FILEFORMAT_OGG)
#include "external/stb_vorbis.h" // OGG loading functions //#define STB_VORBIS_HEADER_ONLY
#include "external/stb_vorbis.h" // OGG loading functions
#endif
#define JAR_XM_IMPLEMENTATION #if defined(SUPPORT_FILEFORMAT_XM)
#include "external/jar_xm.h" // XM loading functions #define JAR_XM_IMPLEMENTATION
#include "external/jar_xm.h" // XM loading functions
#endif
#define JAR_MOD_IMPLEMENTATION #if defined(SUPPORT_FILEFORMAT_MOD)
#include "external/jar_mod.h" // MOD loading functions #define JAR_MOD_IMPLEMENTATION
#include "external/jar_mod.h" // MOD loading functions
#endif
#define DR_FLAC_IMPLEMENTATION #if defined(SUPPORT_FILEFORMAT_FLAC)
#define DR_FLAC_NO_WIN32_IO #define DR_FLAC_IMPLEMENTATION
#include "external/dr_flac.h" // FLAC loading functions #define DR_FLAC_NO_WIN32_IO
#include "external/dr_flac.h" // FLAC loading functions
#endif
#ifdef _MSC_VER #ifdef _MSC_VER
#undef bool #undef bool
@ -139,10 +151,18 @@ typedef enum { MUSIC_AUDIO_OGG = 0, MUSIC_AUDIO_FLAC, MUSIC_MODULE_XM, MUSIC_MOD
// Music type (file streaming from memory) // Music type (file streaming from memory)
typedef struct MusicData { typedef struct MusicData {
MusicContextType ctxType; // Type of music context (OGG, XM, MOD) MusicContextType ctxType; // Type of music context (OGG, XM, MOD)
#if defined(SUPPORT_FILEFORMAT_OGG)
stb_vorbis *ctxOgg; // OGG audio context stb_vorbis *ctxOgg; // OGG audio context
#endif
#if defined(SUPPORT_FILEFORMAT_FLAC)
drflac *ctxFlac; // FLAC audio context drflac *ctxFlac; // FLAC audio context
#endif
#if defined(SUPPORT_FILEFORMAT_XM)
jar_xm_context_t *ctxXm; // XM chiptune context jar_xm_context_t *ctxXm; // XM chiptune context
#endif
#if defined(SUPPORT_FILEFORMAT_MOD)
jar_mod_context_t ctxMod; // MOD chiptune context jar_mod_context_t ctxMod; // MOD chiptune context
#endif
AudioStream stream; // Audio stream (double buffering) AudioStream stream; // Audio stream (double buffering)
@ -163,9 +183,15 @@ typedef enum { INFO = 0, ERROR, WARNING, DEBUG, OTHER } TraceLogType;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module specific Functions Declaration // Module specific Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_WAV)
static Wave LoadWAV(const char *fileName); // Load WAV file static Wave LoadWAV(const char *fileName); // Load WAV file
#endif
#if defined(SUPPORT_FILEFORMAT_OGG)
static Wave LoadOGG(const char *fileName); // Load OGG file static Wave LoadOGG(const char *fileName); // Load OGG file
#endif
#if defined(SUPPORT_FILEFORMAT_FLAC)
static Wave LoadFLAC(const char *fileName); // Load FLAC file static Wave LoadFLAC(const char *fileName); // Load FLAC file
#endif
#if defined(AUDIO_STANDALONE) #if defined(AUDIO_STANDALONE)
const char *GetExtension(const char *fileName); // Get the extension for a filename const char *GetExtension(const char *fileName); // Get the extension for a filename
@ -260,8 +286,13 @@ Wave LoadWave(const char *fileName)
Wave wave = { 0 }; Wave wave = { 0 };
if (strcmp(GetExtension(fileName), "wav") == 0) wave = LoadWAV(fileName); if (strcmp(GetExtension(fileName), "wav") == 0) wave = LoadWAV(fileName);
#if defined(SUPPORT_FILEFORMAT_OGG)
else if (strcmp(GetExtension(fileName), "ogg") == 0) wave = LoadOGG(fileName); else if (strcmp(GetExtension(fileName), "ogg") == 0) wave = LoadOGG(fileName);
#endif
#if defined(SUPPORT_FILEFORMAT_FLAC)
else if (strcmp(GetExtension(fileName), "flac") == 0) wave = LoadFLAC(fileName); else if (strcmp(GetExtension(fileName), "flac") == 0) wave = LoadFLAC(fileName);
#endif
#if !defined(AUDIO_STANDALONE)
else if (strcmp(GetExtension(fileName),"rres") == 0) else if (strcmp(GetExtension(fileName),"rres") == 0)
{ {
RRES rres = LoadResource(fileName, 0); RRES rres = LoadResource(fileName, 0);
@ -273,7 +304,8 @@ Wave LoadWave(const char *fileName)
UnloadResource(rres); UnloadResource(rres);
} }
else TraceLog(WARNING, "[%s] File extension not recognized, it can't be loaded", fileName); #endif
else TraceLog(WARNING, "[%s] Audio fileformat not supported, it can't be loaded", fileName);
return wave; return wave;
} }
@ -663,6 +695,7 @@ Music LoadMusicStream(const char *fileName)
TraceLog(DEBUG, "[%s] OGG memory required: %i", fileName, info.temp_memory_required); TraceLog(DEBUG, "[%s] OGG memory required: %i", fileName, info.temp_memory_required);
} }
} }
#if defined(SUPPORT_FILEFORMAT_FLAC)
else if (strcmp(GetExtension(fileName), "flac") == 0) else if (strcmp(GetExtension(fileName), "flac") == 0)
{ {
music->ctxFlac = drflac_open_file(fileName); music->ctxFlac = drflac_open_file(fileName);
@ -682,6 +715,8 @@ Music LoadMusicStream(const char *fileName)
TraceLog(DEBUG, "[%s] FLAC channels: %i", fileName, music->ctxFlac->channels); TraceLog(DEBUG, "[%s] FLAC channels: %i", fileName, music->ctxFlac->channels);
} }
} }
#endif
#if defined(SUPPORT_FILEFORMAT_XM)
else if (strcmp(GetExtension(fileName), "xm") == 0) else if (strcmp(GetExtension(fileName), "xm") == 0)
{ {
int result = jar_xm_create_context_from_file(&music->ctxXm, 48000, fileName); int result = jar_xm_create_context_from_file(&music->ctxXm, 48000, fileName);
@ -702,6 +737,8 @@ Music LoadMusicStream(const char *fileName)
} }
else TraceLog(WARNING, "[%s] XM file could not be opened", fileName); else TraceLog(WARNING, "[%s] XM file could not be opened", fileName);
} }
#endif
#if defined(SUPPORT_FILEFORMAT_MOD)
else if (strcmp(GetExtension(fileName), "mod") == 0) else if (strcmp(GetExtension(fileName), "mod") == 0)
{ {
jar_mod_init(&music->ctxMod); jar_mod_init(&music->ctxMod);
@ -719,7 +756,8 @@ Music LoadMusicStream(const char *fileName)
} }
else TraceLog(WARNING, "[%s] MOD file could not be opened", fileName); else TraceLog(WARNING, "[%s] MOD file could not be opened", fileName);
} }
else TraceLog(WARNING, "[%s] Music extension not recognized, it can't be loaded", fileName); #endif
else TraceLog(WARNING, "[%s] Audio fileformat not supported, it can't be loaded", fileName);
return music; return music;
} }
@ -730,9 +768,15 @@ void UnloadMusicStream(Music music)
CloseAudioStream(music->stream); CloseAudioStream(music->stream);
if (music->ctxType == MUSIC_AUDIO_OGG) stb_vorbis_close(music->ctxOgg); if (music->ctxType == MUSIC_AUDIO_OGG) stb_vorbis_close(music->ctxOgg);
#if defined(SUPPORT_FILEFORMAT_FLAC)
else if (music->ctxType == MUSIC_AUDIO_FLAC) drflac_free(music->ctxFlac); else if (music->ctxType == MUSIC_AUDIO_FLAC) drflac_free(music->ctxFlac);
#endif
#if defined(SUPPORT_FILEFORMAT_XM)
else if (music->ctxType == MUSIC_MODULE_XM) jar_xm_free_context(music->ctxXm); else if (music->ctxType == MUSIC_MODULE_XM) jar_xm_free_context(music->ctxXm);
#endif
#if defined(SUPPORT_FILEFORMAT_MOD)
else if (music->ctxType == MUSIC_MODULE_MOD) jar_mod_unload(&music->ctxMod); else if (music->ctxType == MUSIC_MODULE_MOD) jar_mod_unload(&music->ctxMod);
#endif
free(music); free(music);
} }
@ -777,8 +821,15 @@ void StopMusicStream(Music music)
switch (music->ctxType) switch (music->ctxType)
{ {
case MUSIC_AUDIO_OGG: stb_vorbis_seek_start(music->ctxOgg); break; case MUSIC_AUDIO_OGG: stb_vorbis_seek_start(music->ctxOgg); break;
#if defined(SUPPORT_FILEFORMAT_FLAC)
case MUSIC_MODULE_FLAC: /* TODO: Restart FLAC context */ break;
#endif
#if defined(SUPPORT_FILEFORMAT_XM)
case MUSIC_MODULE_XM: /* TODO: Restart XM context */ break; case MUSIC_MODULE_XM: /* TODO: Restart XM context */ break;
#endif
#if defined(SUPPORT_FILEFORMAT_MOD)
case MUSIC_MODULE_MOD: jar_mod_seek_start(&music->ctxMod); break; case MUSIC_MODULE_MOD: jar_mod_seek_start(&music->ctxMod); break;
#endif
default: break; default: break;
} }
@ -820,14 +871,20 @@ void UpdateMusicStream(Music music)
int numSamplesOgg = stb_vorbis_get_samples_short_interleaved(music->ctxOgg, music->stream.channels, (short *)pcm, samplesCount*music->stream.channels); int numSamplesOgg = stb_vorbis_get_samples_short_interleaved(music->ctxOgg, music->stream.channels, (short *)pcm, samplesCount*music->stream.channels);
} break; } break;
#if defined(SUPPORT_FILEFORMAT_FLAC)
case MUSIC_AUDIO_FLAC: case MUSIC_AUDIO_FLAC:
{ {
// NOTE: Returns the number of samples to process // NOTE: Returns the number of samples to process
unsigned int numSamplesFlac = (unsigned int)drflac_read_s16(music->ctxFlac, samplesCount*music->stream.channels, (short *)pcm); unsigned int numSamplesFlac = (unsigned int)drflac_read_s16(music->ctxFlac, samplesCount*music->stream.channels, (short *)pcm);
} break; } break;
#endif
#if defined(SUPPORT_FILEFORMAT_XM)
case MUSIC_MODULE_XM: jar_xm_generate_samples_16bit(music->ctxXm, pcm, samplesCount); break; case MUSIC_MODULE_XM: jar_xm_generate_samples_16bit(music->ctxXm, pcm, samplesCount); break;
#endif
#if defined(SUPPORT_FILEFORMAT_MOD)
case MUSIC_MODULE_MOD: jar_mod_fillbuffer(&music->ctxMod, pcm, samplesCount, 0); break; case MUSIC_MODULE_MOD: jar_mod_fillbuffer(&music->ctxMod, pcm, samplesCount, 0); break;
#endif
default: break; default: break;
} }
@ -1066,6 +1123,7 @@ void StopAudioStream(AudioStream stream)
// Module specific Functions Definition // Module specific Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_WAV)
// Load WAV file into Wave structure // Load WAV file into Wave structure
static Wave LoadWAV(const char *fileName) static Wave LoadWAV(const char *fileName)
{ {
@ -1182,7 +1240,9 @@ static Wave LoadWAV(const char *fileName)
return wave; return wave;
} }
#endif
#if defined(SUPPORT_FILEFORMAT_OGG)
// Load OGG file into Wave structure // Load OGG file into Wave structure
// NOTE: Using stb_vorbis library // NOTE: Using stb_vorbis library
static Wave LoadOGG(const char *fileName) static Wave LoadOGG(const char *fileName)
@ -1206,7 +1266,7 @@ static Wave LoadOGG(const char *fileName)
wave.sampleCount = (int)stb_vorbis_stream_length_in_samples(oggFile); wave.sampleCount = (int)stb_vorbis_stream_length_in_samples(oggFile);
float totalSeconds = stb_vorbis_stream_length_in_seconds(oggFile); float totalSeconds = stb_vorbis_stream_length_in_seconds(oggFile);
if (totalSeconds > 10) TraceLog(WARNING, "[%s] Ogg audio lenght is larger than 10 seconds (%f), that's a big file in memory, consider music streaming", fileName, totalSeconds); if (totalSeconds > 10) TraceLog(WARNING, "[%s] Ogg audio length is larger than 10 seconds (%f), that's a big file in memory, consider music streaming", fileName, totalSeconds);
wave.data = (short *)malloc(wave.sampleCount*wave.channels*sizeof(short)); wave.data = (short *)malloc(wave.sampleCount*wave.channels*sizeof(short));
@ -1222,7 +1282,9 @@ static Wave LoadOGG(const char *fileName)
return wave; return wave;
} }
#endif
#if defined(SUPPORT_FILEFORMAT_FLAC)
// Load FLAC file into Wave structure // Load FLAC file into Wave structure
// NOTE: Using dr_flac library // NOTE: Using dr_flac library
static Wave LoadFLAC(const char *fileName) static Wave LoadFLAC(const char *fileName)
@ -1244,6 +1306,7 @@ static Wave LoadFLAC(const char *fileName)
return wave; return wave;
} }
#endif
// Some required functions for audio standalone module version // Some required functions for audio standalone module version
#if defined(AUDIO_STANDALONE) #if defined(AUDIO_STANDALONE)

View File

@ -1,31 +1,37 @@
/********************************************************************************************** /**********************************************************************************************
* *
* raylib.audio * raylib.audio - Basic funtionality to work with audio
* *
* This module provides basic functionality to work with audio: * FEATURES:
* Manage audio device (init/close) * - Manage audio device (init/close)
* Load and Unload audio files (WAV, OGG, FLAC, XM, MOD) * - Load and unload audio files
* Play/Stop/Pause/Resume loaded audio * - Format wave data (sample rate, size, channels)
* Manage mixing channels * - Play/Stop/Pause/Resume loaded audio
* Manage raw audio context * - Manage mixing channels
* - Manage raw audio context
*
* LIMITATIONS:
* Only up to two channels supported: MONO and STEREO (for additional channels, use AL_EXT_MCFORMATS)
* Only the following sample sizes supported: 8bit PCM, 16bit PCM, 32-bit float PCM (using AL_EXT_FLOAT32)
* *
* DEPENDENCIES: * DEPENDENCIES:
* OpenAL Soft - Audio device management (http://kcat.strangesoft.net/openal.html) * OpenAL Soft - Audio device management (http://kcat.strangesoft.net/openal.html)
* stb_vorbis - OGG audio files loading (http://www.nothings.org/stb_vorbis/) * stb_vorbis - OGG audio files loading (http://www.nothings.org/stb_vorbis/)
* jar_xm - XM module file loading * jar_xm - XM module file loading (#define SUPPORT_FILEFORMAT_XM)
* jar_mod - MOD audio file loading * jar_mod - MOD audio file loading (#define SUPPORT_FILEFORMAT_MOD)
* dr_flac - FLAC audio file loading * dr_flac - FLAC audio file loading (#define SUPPORT_FILEFORMAT_FLAC)
* *
* Many thanks to Joshua Reisenauer (github: @kd7tck) for the following additions: * CONTRIBUTORS:
* XM audio module support (jar_xm) * Joshua Reisenauer (github: @kd7tck):
* MOD audio module support (jar_mod) * - XM audio module support (jar_xm)
* Mixing channels support * - MOD audio module support (jar_mod)
* Raw audio context support * - Mixing channels support
* - Raw audio context support
* *
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -148,7 +154,7 @@ float GetMusicTimePlayed(Music music); // Get current m
AudioStream InitAudioStream(unsigned int sampleRate, AudioStream InitAudioStream(unsigned int sampleRate,
unsigned int sampleSize, unsigned int sampleSize,
unsigned int channels); // Init audio stream (to stream raw audio pcm data) unsigned int channels); // Init audio stream (to stream raw audio pcm data)
void UpdateAudioStream(AudioStream stream, void *data, int samplesCount); // Update audio stream buffers with data void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data
void CloseAudioStream(AudioStream stream); // Close audio stream and free memory void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill
void PlayAudioStream(AudioStream stream); // Play audio stream void PlayAudioStream(AudioStream stream); // Play audio stream

View File

@ -1,6 +1,6 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib Camera System - Camera Modes Setup and Control Functions * raylib.camera - Camera system with multiple modes support
* *
* NOTE: Memory footprint of this library is aproximately 52 bytes (global variables) * NOTE: Memory footprint of this library is aproximately 52 bytes (global variables)
* *
@ -22,7 +22,7 @@
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
* *
* Copyright (c) 2015-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2015-2017 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -2,7 +2,14 @@
* *
* raylib.core - Basic functions to manage windows, OpenGL context and input on multiple platforms * raylib.core - Basic functions to manage windows, OpenGL context and input on multiple platforms
* *
* The following platforms are supported: Windows, Linux, Mac (OSX), Android, Raspberry Pi, HTML5, Oculus Rift CV1 * PLATFORMS SUPPORTED:
* - Windows (win32/Win64)
* - Linux (tested on Ubuntu)
* - Mac (OSX)
* - Android (API Level 9 or greater)
* - Raspberry Pi (Raspbian)
* - HTML5 (Chrome, Firefox)
* - Oculus Rift CV1
* *
* CONFIGURATION: * CONFIGURATION:
* *
@ -22,13 +29,15 @@
* Windowing and input system configured for HTML5 (run on browser), code converted from C to asm.js * Windowing and input system configured for HTML5 (run on browser), code converted from C to asm.js
* using emscripten compiler. OpenGL ES 2.0 required for direct translation to WebGL equivalent code. * using emscripten compiler. OpenGL ES 2.0 required for direct translation to WebGL equivalent code.
* *
* #define LOAD_DEFAULT_FONT (defined by default) * #define SUPPORT_DEFAULT_FONT (default)
* Default font is loaded on window initialization to be available for the user to render simple text. * Default font is loaded on window initialization to be available for the user to render simple text.
* NOTE: If enabled, uses external module functions to load default raylib font (module: text) * NOTE: If enabled, uses external module functions to load default raylib font (module: text)
* *
* #define INCLUDE_CAMERA_SYSTEM / SUPPORT_CAMERA_SYSTEM * #define SUPPORT_CAMERA_SYSTEM
* Camera module is included (camera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital
* *
* #define INCLUDE_GESTURES_SYSTEM / SUPPORT_GESTURES_SYSTEM * #define SUPPORT_GESTURES_SYSTEM
* Gestures module is included (gestures.h) to support gestures detection: tap, hold, swipe, drag
* *
* #define SUPPORT_MOUSE_GESTURES * #define SUPPORT_MOUSE_GESTURES
* Mouse gestures are directly mapped like touches and processed by gestures system. * Mouse gestures are directly mapped like touches and processed by gestures system.
@ -42,7 +51,7 @@
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -61,6 +70,14 @@
* *
**********************************************************************************************/ **********************************************************************************************/
// Default configuration flags (supported features)
//-------------------------------------------------
#define SUPPORT_DEFAULT_FONT
#define SUPPORT_MOUSE_GESTURES
#define SUPPORT_CAMERA_SYSTEM
#define SUPPORT_GESTURES_SYSTEM
//-------------------------------------------------
#include "raylib.h" #include "raylib.h"
#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2 #include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2
@ -70,10 +87,12 @@
#define RAYMATH_EXTERN_INLINE // Compile raymath functions as static inline (remember, it's a compiler hint) #define RAYMATH_EXTERN_INLINE // Compile raymath functions as static inline (remember, it's a compiler hint)
#include "raymath.h" // Required for: Vector3 and Matrix functions #include "raymath.h" // Required for: Vector3 and Matrix functions
#define GESTURES_IMPLEMENTATION #if defined(SUPPORT_GESTURES_SYSTEM)
#include "gestures.h" // Gestures detection functionality #define GESTURES_IMPLEMENTATION
#include "gestures.h" // Gestures detection functionality
#endif
#if !defined(PLATFORM_ANDROID) #if defined(SUPPORT_CAMERA_SYSTEM) && !defined(PLATFORM_ANDROID)
#define CAMERA_IMPLEMENTATION #define CAMERA_IMPLEMENTATION
#include "camera.h" // Camera system functionality #include "camera.h" // Camera system functionality
#endif #endif
@ -86,7 +105,7 @@
#include <string.h> // Required for: strcmp() #include <string.h> // Required for: strcmp()
//#include <errno.h> // Macros for reporting and retrieving error conditions through error codes //#include <errno.h> // Macros for reporting and retrieving error conditions through error codes
#if defined __linux || defined(PLATFORM_WEB) #if defined __linux__ || defined(PLATFORM_WEB)
#include <sys/time.h> // Required for: timespec, nanosleep(), select() - POSIX #include <sys/time.h> // Required for: timespec, nanosleep(), select() - POSIX
#elif defined __APPLE__ #elif defined __APPLE__
#include <unistd.h> // Required for: usleep() #include <unistd.h> // Required for: usleep()
@ -96,7 +115,7 @@
//#define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3 //#define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3
#include <GLFW/glfw3.h> // GLFW3 library: Windows, OpenGL context and Input management #include <GLFW/glfw3.h> // GLFW3 library: Windows, OpenGL context and Input management
#ifdef __linux #ifdef __linux__
#define GLFW_EXPOSE_NATIVE_X11 // Linux specific definitions for getting #define GLFW_EXPOSE_NATIVE_X11 // Linux specific definitions for getting
#define GLFW_EXPOSE_NATIVE_GLX // native functions like glfwGetX11Window #define GLFW_EXPOSE_NATIVE_GLX // native functions like glfwGetX11Window
#include <GLFW/glfw3native.h> // which are required for hiding mouse #include <GLFW/glfw3native.h> // which are required for hiding mouse
@ -140,8 +159,6 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Defines and Macros // Defines and Macros
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#define STORAGE_FILENAME "storage.data"
#if defined(PLATFORM_RPI) #if defined(PLATFORM_RPI)
// Old device inputs system // Old device inputs system
#define DEFAULT_KEYBOARD_DEV STDIN_FILENO // Standard input #define DEFAULT_KEYBOARD_DEV STDIN_FILENO // Standard input
@ -161,7 +178,7 @@
#define MAX_GAMEPAD_BUTTONS 32 // Max bumber of buttons supported (per gamepad) #define MAX_GAMEPAD_BUTTONS 32 // Max bumber of buttons supported (per gamepad)
#define MAX_GAMEPAD_AXIS 8 // Max number of axis supported (per gamepad) #define MAX_GAMEPAD_AXIS 8 // Max number of axis supported (per gamepad)
#define LOAD_DEFAULT_FONT // Load default font on window initialization (module: text) #define STORAGE_FILENAME "storage.data"
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
@ -259,7 +276,10 @@ static int lastGamepadButtonPressed = -1; // Register last gamepad button pres
static int gamepadAxisCount = 0; // Register number of available gamepad axis static int gamepadAxisCount = 0; // Register number of available gamepad axis
static Vector2 mousePosition; // Mouse position on screen static Vector2 mousePosition; // Mouse position on screen
#if defined(SUPPORT_GESTURES_SYSTEM)
static Vector2 touchPosition[MAX_TOUCH_POINTS]; // Touch position on screen static Vector2 touchPosition[MAX_TOUCH_POINTS]; // Touch position on screen
#endif
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
static char **dropFilesPath; // Store dropped files paths as strings static char **dropFilesPath; // Store dropped files paths as strings
@ -277,7 +297,7 @@ static bool showLogo = false; // Track if showing logo at init is
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Other Modules Functions Declaration (required by core) // Other Modules Functions Declaration (required by core)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(LOAD_DEFAULT_FONT) #if defined(SUPPORT_DEFAULT_FONT)
extern void LoadDefaultFont(void); // [Module: text] Loads default font on InitWindow() extern void LoadDefaultFont(void); // [Module: text] Loads default font on InitWindow()
extern void UnloadDefaultFont(void); // [Module: text] Unloads default font from GPU memory extern void UnloadDefaultFont(void); // [Module: text] Unloads default font from GPU memory
#endif #endif
@ -359,7 +379,7 @@ void InitWindow(int width, int height, const char *title)
// Init graphics device (display device and OpenGL context) // Init graphics device (display device and OpenGL context)
InitGraphicsDevice(width, height); InitGraphicsDevice(width, height);
#if defined(LOAD_DEFAULT_FONT) #if defined(SUPPORT_DEFAULT_FONT)
// Load default font // Load default font
// NOTE: External function (defined in module: text) // NOTE: External function (defined in module: text)
LoadDefaultFont(); LoadDefaultFont();
@ -471,7 +491,7 @@ void InitWindow(int width, int height, void *state)
// Close Window and Terminate Context // Close Window and Terminate Context
void CloseWindow(void) void CloseWindow(void)
{ {
#if defined(LOAD_DEFAULT_FONT) #if defined(SUPPORT_DEFAULT_FONT)
UnloadDefaultFont(); UnloadDefaultFont();
#endif #endif
@ -621,7 +641,7 @@ int GetScreenHeight(void)
void ShowCursor() void ShowCursor()
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
#ifdef __linux #ifdef __linux__
XUndefineCursor(glfwGetX11Display(), glfwGetX11Window(window)); XUndefineCursor(glfwGetX11Display(), glfwGetX11Window(window));
#else #else
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
@ -634,7 +654,7 @@ void ShowCursor()
void HideCursor() void HideCursor()
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
#ifdef __linux #ifdef __linux__
XColor col; XColor col;
const char nil[] = {0}; const char nil[] = {0};
@ -755,11 +775,8 @@ void End2dMode(void)
void Begin3dMode(Camera camera) void Begin3dMode(Camera camera)
{ {
rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2) rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2)
if (IsVrDeviceReady() || IsVrSimulator()) BeginVrDrawing();
rlMatrixMode(RL_PROJECTION); // Switch to projection matrix rlMatrixMode(RL_PROJECTION); // Switch to projection matrix
rlPushMatrix(); // Save previous matrix, which contains the settings for the 2d ortho projection rlPushMatrix(); // Save previous matrix, which contains the settings for the 2d ortho projection
rlLoadIdentity(); // Reset current matrix (PROJECTION) rlLoadIdentity(); // Reset current matrix (PROJECTION)
@ -786,8 +803,6 @@ void End3dMode(void)
{ {
rlglDraw(); // Process internal buffers (update + draw) rlglDraw(); // Process internal buffers (update + draw)
if (IsVrDeviceReady() || IsVrSimulator()) EndVrDrawing();
rlMatrixMode(RL_PROJECTION); // Switch to projection matrix rlMatrixMode(RL_PROJECTION); // Switch to projection matrix
rlPopMatrix(); // Restore previous matrix (PROJECTION) from matrix stack rlPopMatrix(); // Restore previous matrix (PROJECTION) from matrix stack
@ -2011,7 +2026,7 @@ static double GetTime(void)
// Wait for some milliseconds (stop program execution) // Wait for some milliseconds (stop program execution)
static void Wait(float ms) static void Wait(float ms)
{ {
#define SUPPORT_BUSY_WAIT_LOOP //#define SUPPORT_BUSY_WAIT_LOOP
#if defined(SUPPORT_BUSY_WAIT_LOOP) #if defined(SUPPORT_BUSY_WAIT_LOOP)
double prevTime = GetTime(); double prevTime = GetTime();
double nextTime = 0.0; double nextTime = 0.0;
@ -2021,7 +2036,7 @@ static void Wait(float ms)
#else #else
#if defined _WIN32 #if defined _WIN32
Sleep(ms); Sleep(ms);
#elif defined __linux || defined(PLATFORM_WEB) #elif defined __linux__ || defined(PLATFORM_WEB)
struct timespec req = { 0 }; struct timespec req = { 0 };
time_t sec = (int)(ms/1000.0f); time_t sec = (int)(ms/1000.0f);
ms -= (sec*1000); ms -= (sec*1000);
@ -2069,9 +2084,11 @@ static bool GetMouseButtonStatus(int button)
// Poll (store) all input events // Poll (store) all input events
static void PollInputEvents(void) static void PollInputEvents(void)
{ {
#if defined(SUPPORT_GESTURES_SYSTEM)
// NOTE: Gestures update must be called every frame to reset gestures correctly // NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is just called on an event, not every frame // because ProcessGestureEvent() is just called on an event, not every frame
UpdateGestures(); UpdateGestures();
#endif
// Reset last key pressed registered // Reset last key pressed registered
lastKeyPressed = -1; lastKeyPressed = -1;
@ -2301,8 +2318,7 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int
{ {
currentMouseState[button] = action; currentMouseState[button] = action;
#define ENABLE_MOUSE_GESTURES #if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES)
#if defined(ENABLE_MOUSE_GESTURES)
// Process mouse events as touches to be able to use mouse-gestures // Process mouse events as touches to be able to use mouse-gestures
GestureEvent gestureEvent; GestureEvent gestureEvent;
@ -2333,8 +2349,7 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int
// GLFW3 Cursor Position Callback, runs on mouse move // GLFW3 Cursor Position Callback, runs on mouse move
static void MouseCursorPosCallback(GLFWwindow *window, double x, double y) static void MouseCursorPosCallback(GLFWwindow *window, double x, double y)
{ {
#define ENABLE_MOUSE_GESTURES #if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES)
#if defined(ENABLE_MOUSE_GESTURES)
// Process mouse events as touches to be able to use mouse-gestures // Process mouse events as touches to be able to use mouse-gestures
GestureEvent gestureEvent; GestureEvent gestureEvent;
@ -2464,7 +2479,7 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
// Init graphics device (display device and OpenGL context) // Init graphics device (display device and OpenGL context)
InitGraphicsDevice(screenWidth, screenHeight); InitGraphicsDevice(screenWidth, screenHeight);
#if defined(LOAD_DEFAULT_FONT) #if defined(SUPPORT_DEFAULT_FONT)
// Load default font // Load default font
// NOTE: External function (defined in module: text) // NOTE: External function (defined in module: text)
LoadDefaultFont(); LoadDefaultFont();

View File

@ -122,7 +122,7 @@ EASEDEF float EaseCubicOut(float t, float b, float c, float d) { return (c*((t=t
EASEDEF float EaseCubicInOut(float t, float b, float c, float d) EASEDEF float EaseCubicInOut(float t, float b, float c, float d)
{ {
if ((t/=d/2) < 1) return (c/2*t*t*t + b); if ((t/=d/2) < 1) return (c/2*t*t*t + b);
return (c/2*((t-=2)*t*t + 2) + b); return (c/2*((t-=2)*t*t + 2) + b);
} }
// Quadratic Easing functions // Quadratic Easing functions

View File

@ -1,6 +1,6 @@
/********************************************************************************************** /**********************************************************************************************
* *
* raylib Gestures System - Gestures Processing based on input gesture events (touch/mouse) * raylib.gestures - Gestures system, gestures processing based on input events (touch/mouse)
* *
* NOTE: Memory footprint of this library is aproximately 128 bytes (global variables) * NOTE: Memory footprint of this library is aproximately 128 bytes (global variables)
* *
@ -24,7 +24,7 @@
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -147,7 +147,7 @@ float GetGesturePinchAngle(void); // Get gesture pinch ang
// Functions required to query time on Windows // Functions required to query time on Windows
int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount); int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount);
int __stdcall QueryPerformanceFrequency(unsigned long long int *lpFrequency); int __stdcall QueryPerformanceFrequency(unsigned long long int *lpFrequency);
#elif defined(__linux) #elif defined(__linux__)
#include <sys/time.h> // Required for: timespec #include <sys/time.h> // Required for: timespec
#include <time.h> // Required for: clock_gettime() #include <time.h> // Required for: clock_gettime()
#endif #endif
@ -517,7 +517,7 @@ static double GetCurrentTime(void)
time = (double)currentTime/clockFrequency*1000.0f; // Time in miliseconds time = (double)currentTime/clockFrequency*1000.0f; // Time in miliseconds
#endif #endif
#if defined(__linux) #if defined(__linux__)
// NOTE: Only for Linux-based systems // NOTE: Only for Linux-based systems
struct timespec now; struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);

View File

@ -1,17 +1,19 @@
/********************************************************************************************** /**********************************************************************************************
* *
* raylib.models - Basic functions to draw 3d shapes and 3d models * raylib.models - Basic functions to deal with 3d shapes and 3d models
* *
* CONFIGURATION: * CONFIGURATION:
* *
* #define SUPPORT_FILEFORMAT_OBJ / SUPPORT_LOAD_OBJ * #define SUPPORT_FILEFORMAT_OBJ
* Selected desired fileformats to be supported for loading.
* *
* #define SUPPORT_FILEFORMAT_MTL * #define SUPPORT_FILEFORMAT_MTL
* Selected desired fileformats to be supported for loading.
* *
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -30,6 +32,12 @@
* *
**********************************************************************************************/ **********************************************************************************************/
// Default configuration flags (supported features)
//-------------------------------------------------
#define SUPPORT_FILEFORMAT_OBJ
#define SUPPORT_FILEFORMAT_MTL
//-------------------------------------------------
#include "raylib.h" #include "raylib.h"
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
@ -61,8 +69,12 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module specific Functions Declaration // Module specific Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_OBJ)
static Mesh LoadOBJ(const char *fileName); // Load OBJ mesh data static Mesh LoadOBJ(const char *fileName); // Load OBJ mesh data
#endif
#if defined(SUPPORT_FILEFORMAT_MTL)
static Material LoadMTL(const char *fileName); // Load MTL material data static Material LoadMTL(const char *fileName); // Load MTL material data
#endif
static Mesh GenMeshHeightmap(Image image, Vector3 size); static Mesh GenMeshHeightmap(Image image, Vector3 size);
static Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize); static Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize);
@ -580,8 +592,11 @@ Mesh LoadMesh(const char *fileName)
{ {
Mesh mesh = { 0 }; Mesh mesh = { 0 };
#if defined(SUPPORT_FILEFORMAT_OBJ)
if (strcmp(GetExtension(fileName), "obj") == 0) mesh = LoadOBJ(fileName); if (strcmp(GetExtension(fileName), "obj") == 0) mesh = LoadOBJ(fileName);
else TraceLog(WARNING, "[%s] Mesh extension not recognized, it can't be loaded", fileName); #else
TraceLog(WARNING, "[%s] Mesh fileformat not supported, it can't be loaded", fileName);
#endif
if (mesh.vertexCount == 0) TraceLog(WARNING, "Mesh could not be loaded"); if (mesh.vertexCount == 0) TraceLog(WARNING, "Mesh could not be loaded");
else rlglLoadMesh(&mesh, false); // Upload vertex data to GPU (static mesh) else rlglLoadMesh(&mesh, false); // Upload vertex data to GPU (static mesh)
@ -690,8 +705,11 @@ Material LoadMaterial(const char *fileName)
{ {
Material material = { 0 }; Material material = { 0 };
#if defined(SUPPORT_FILEFORMAT_MTL)
if (strcmp(GetExtension(fileName), "mtl") == 0) material = LoadMTL(fileName); if (strcmp(GetExtension(fileName), "mtl") == 0) material = LoadMTL(fileName);
else TraceLog(WARNING, "[%s] Material extension not recognized, it can't be loaded", fileName); #else
TraceLog(WARNING, "[%s] Material fileformat not supported, it can't be loaded", fileName);
#endif
return material; return material;
} }
@ -1588,6 +1606,7 @@ BoundingBox CalculateBoundingBox(Mesh mesh)
// Module specific Functions Definition // Module specific Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_OBJ)
// Load OBJ mesh data // Load OBJ mesh data
static Mesh LoadOBJ(const char *fileName) static Mesh LoadOBJ(const char *fileName)
{ {
@ -1836,7 +1855,9 @@ static Mesh LoadOBJ(const char *fileName)
return mesh; return mesh;
} }
#endif
#if defined(SUPPORT_FILEFORMAT_MTL)
// Load MTL material data (specs: http://paulbourke.net/dataformats/mtl/) // Load MTL material data (specs: http://paulbourke.net/dataformats/mtl/)
// NOTE: Texture map parameters are not supported // NOTE: Texture map parameters are not supported
static Material LoadMTL(const char *fileName) static Material LoadMTL(const char *fileName)
@ -2000,3 +2021,4 @@ static Material LoadMTL(const char *fileName)
return material; return material;
} }
#endif

View File

@ -249,7 +249,7 @@ PHYSACDEF void ClosePhysics(void);
// Functions required to query time on Windows // Functions required to query time on Windows
int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount); int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount);
int __stdcall QueryPerformanceFrequency(unsigned long long int *lpFrequency); int __stdcall QueryPerformanceFrequency(unsigned long long int *lpFrequency);
#elif defined(__linux) || defined(PLATFORM_WEB) #elif defined(__linux__) || defined(PLATFORM_WEB)
#include <sys/time.h> // Required for: timespec #include <sys/time.h> // Required for: timespec
#include <time.h> // Required for: clock_gettime() #include <time.h> // Required for: clock_gettime()
#include <stdint.h> #include <stdint.h>
@ -277,7 +277,7 @@ PHYSACDEF void ClosePhysics(void);
static unsigned int usedMemory = 0; // Total allocated dynamic memory static unsigned int usedMemory = 0; // Total allocated dynamic memory
static bool physicsThreadEnabled = false; // Physics thread enabled state static bool physicsThreadEnabled = false; // Physics thread enabled state
static double currentTime = 0; // Current time in milliseconds static double currentTime = 0; // Current time in milliseconds
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(__linux) || defined(PLATFORM_WEB) #if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(__linux__) || defined(PLATFORM_WEB)
static double baseTime = 0; // Android and RPI platforms base time static double baseTime = 0; // Android and RPI platforms base time
#endif #endif
static double startTime = 0; // Start time in milliseconds static double startTime = 0; // Start time in milliseconds
@ -1906,7 +1906,7 @@ static double GetCurrentTime(void)
time = (double)((double)currentTime/clockFrequency)*1000; time = (double)((double)currentTime/clockFrequency)*1000;
#endif #endif
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(__linux) || defined(PLATFORM_WEB) #if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(__linux__) || defined(PLATFORM_WEB)
struct timespec ts; struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts); clock_gettime(CLOCK_MONOTONIC, &ts);
uint64_t temp = (uint64_t)ts.tv_sec*1000000000LLU + (uint64_t)ts.tv_nsec; uint64_t temp = (uint64_t)ts.tv_sec*1000000000LLU + (uint64_t)ts.tv_nsec;

View File

@ -1,43 +1,45 @@
/********************************************************************************************** /**********************************************************************************************
* *
* raylib v1.7.0 (www.raylib.com) * raylib v1.7.0
* *
* A simple and easy-to-use library to learn videogames programming * A simple and easy-to-use library to learn videogames programming (www.raylib.com)
* *
* FEATURES: * FEATURES:
* Library written in plain C code (C99) * - Library written in plain C code (C99)
* Uses PascalCase/camelCase notation * - Uses PascalCase/camelCase notation
* Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES 2.0) * - Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES 2.0)
* Unique OpenGL abstraction layer (usable as standalone module): [rlgl] * - Unique OpenGL abstraction layer (usable as standalone module): [rlgl]
* Powerful fonts module with SpriteFonts support (XNA bitmap fonts, AngelCode fonts, TTF) * - Powerful fonts module with SpriteFonts support (XNA bitmap fonts, AngelCode fonts, TTF)
* Multiple textures support, including compressed formats and mipmaps generation * - Multiple textures support, including compressed formats and mipmaps generation
* Basic 3d support for Shapes, Models, Billboards, Heightmaps and Cubicmaps * - Basic 3d support for Shapes, Models, Billboards, Heightmaps and Cubicmaps
* Powerful math module for Vector, Matrix and Quaternion operations: [raymath] * - Powerful math module for Vector, Matrix and Quaternion operations: [raymath]
* Audio loading and playing with streaming support and mixing channels [audio] * - Audio loading and playing with streaming support and mixing channels: [audio]
* VR stereo rendering support with configurable HMD device parameters * - VR stereo rendering support with configurable HMD device parameters
* Multiple platforms support: Windows, Linux, Mac, Android, Raspberry Pi, HTML5 and Oculus Rift CV1 * - Multiple platforms support: Windows, Linux, Mac, Android, Raspberry Pi, HTML5 and Oculus Rift CV1
* Custom color palette for fancy visuals on raywhite background * - Custom color palette for fancy visuals on raywhite background
* Minimal external dependencies (GLFW3, OpenGL, OpenAL) * - Minimal external dependencies (GLFW3, OpenGL, OpenAL)
* Complete binding for Lua [rlua] * - Complete bindings for Lua, Go and Pascal
* *
* NOTES: * NOTES:
* 32bit Colors - All defined color are always RGBA (struct Color is 4 byte) * 32bit Colors - All defined color are always RGBA (struct Color is 4 byte)
* One custom default font could be loaded automatically when InitWindow() [core] * One custom default font could be loaded automatically when InitWindow() [core]
* If using OpenGL 3.3 or ES2, several vertex buffers (VAO/VBO) are created to manage lines-triangles-quads * If using OpenGL 3.3 or ES2, several vertex buffers (VAO/VBO) are created to manage lines-triangles-quads
* If using OpenGL 3.3 or ES2, two default shaders could be loaded automatically (internally defined) * If using OpenGL 3.3 or ES2, two default shaders could be loaded automatically (internally defined)
* *
* DEPENDENCIES: * DEPENDENCIES:
* GLFW3 (www.glfw.org) for window/context management and input [core] * GLFW3 (www.glfw.org) for window/context management and input [core]
* GLAD for OpenGL extensions loading (3.3 Core profile, only PLATFORM_DESKTOP) [rlgl] * GLAD for OpenGL extensions loading (3.3 Core profile, only PLATFORM_DESKTOP) [rlgl]
* stb_image (Sean Barret) for images loading (JPEG, PNG, BMP, TGA) [textures] * OpenAL Soft for audio device/context management [audio]
* stb_image_write (Sean Barret) for image writting (PNG) [utils] *
* stb_truetype (Sean Barret) for ttf fonts loading [text] * OPTIONAL DEPENDENCIES:
* stb_vorbis (Sean Barret) for ogg audio loading [audio] * stb_image (Sean Barret) for images loading (JPEG, PNG, BMP, TGA) [textures]
* jar_xm (Joshua Reisenauer) for XM audio module loading [audio] * stb_image_write (Sean Barret) for image writting (PNG) [utils]
* jar_mod (Joshua Reisenauer) for MOD audio module loading [audio] * stb_truetype (Sean Barret) for ttf fonts loading [text]
* dr_flac (David Reid) for FLAC audio file loading [audio] * stb_vorbis (Sean Barret) for ogg audio loading [audio]
* OpenAL Soft for audio device/context management [audio] * jar_xm (Joshua Reisenauer) for XM audio module loading [audio]
* tinfl for data decompression (DEFLATE algorithm) [utils] * jar_mod (Joshua Reisenauer) for MOD audio module loading [audio]
* dr_flac (David Reid) for FLAC audio file loading [audio]
* tinfl for data decompression (DEFLATE algorithm) [rres]
* *
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
@ -45,7 +47,7 @@
* raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, * raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software: * BSD-like license that allows static linking with closed source software:
* *
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -687,6 +689,7 @@ RLAPI Color Fade(Color color, float alpha); // Color fade-
RLAPI void SetConfigFlags(char flags); // Setup some window configuration flags RLAPI void SetConfigFlags(char flags); // Setup some window configuration flags
RLAPI void ShowLogo(void); // Activates raylib logo at startup (can be done with flags) RLAPI void ShowLogo(void); // Activates raylib logo at startup (can be done with flags)
//RLAPI void TraceLog(int logType, const char *text, ...); // Trace log messages showing (INFO, WARNING, ERROR, DEBUG)
RLAPI bool IsFileDropped(void); // Check if a file have been dropped into window RLAPI bool IsFileDropped(void); // Check if a file have been dropped into window
RLAPI char **GetDroppedFiles(int *count); // Retrieve dropped files into window RLAPI char **GetDroppedFiles(int *count); // Retrieve dropped files into window
@ -764,6 +767,7 @@ RLAPI void DrawPixelV(Vector2 position, Color color);
RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line
RLAPI void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (Vector version) RLAPI void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (Vector version)
RLAPI void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line defining thickness RLAPI void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line defining thickness
RLAPI void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line using cubic-bezier curves in-out
RLAPI void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle RLAPI void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle
RLAPI void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle RLAPI void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle
RLAPI void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version) RLAPI void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version)
@ -943,12 +947,13 @@ RLAPI void EndBlendMode(void); // End
// VR experience Functions (Module: rlgl) // VR experience Functions (Module: rlgl)
// NOTE: This functions are useless when using OpenGL 1.1 // NOTE: This functions are useless when using OpenGL 1.1
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
RLAPI void InitVrDevice(int vdDevice); // Init VR device RLAPI void InitVrSimulator(int vrDevice); // Init VR simulator for selected device
RLAPI void CloseVrDevice(void); // Close VR device RLAPI void CloseVrSimulator(void); // Close VR simulator for current device
RLAPI bool IsVrDeviceReady(void); // Detect if VR device is ready RLAPI bool IsVrSimulatorReady(void); // Detect if VR device is ready
RLAPI bool IsVrSimulator(void); // Detect if VR simulator is running RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera RLAPI void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator)
RLAPI void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator) RLAPI void BeginVrDrawing(void); // Begin VR simulator stereo rendering
RLAPI void EndVrDrawing(void); // End VR simulator stereo rendering
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Audio Loading and Playing Functions (Module: audio) // Audio Loading and Playing Functions (Module: audio)

View File

@ -1,6 +1,6 @@
/********************************************************************************************** /**********************************************************************************************
* *
* raymath v1.0 - Some useful functions to work with Vector3, Matrix and Quaternions * raymath v1.0 - Math functions to work with Vector3, Matrix and Quaternions
* *
* CONFIGURATION: * CONFIGURATION:
* *

View File

@ -2,10 +2,8 @@
* *
* rlgl - raylib OpenGL abstraction layer * rlgl - raylib OpenGL abstraction layer
* *
* DESCRIPTION: * rlgl is a wrapper for multiple OpenGL versions (1.1, 2.1, 3.3 Core, ES 2.0) to
* * pseudo-OpenGL 1.1 style functions (rlVertex, rlTranslate, rlRotate...).
* rlgl allows usage of OpenGL 1.1 style functions (rlVertex) that are internally mapped to
* selected OpenGL version (1.1, 2.1, 3.3 Core, ES 2.0).
* *
* When chosing an OpenGL version greater than OpenGL 1.1, rlgl stores vertex data on internal * When chosing an OpenGL version greater than OpenGL 1.1, rlgl stores vertex data on internal
* VBO buffers (and VAOs if available). It requires calling 3 functions: * VBO buffers (and VAOs if available). It requires calling 3 functions:
@ -16,34 +14,19 @@
* CONFIGURATION: * CONFIGURATION:
* *
* #define GRAPHICS_API_OPENGL_11 * #define GRAPHICS_API_OPENGL_11
* Use OpenGL 1.1 backend
*
* #define GRAPHICS_API_OPENGL_21 * #define GRAPHICS_API_OPENGL_21
* Use OpenGL 2.1 backend
*
* #define GRAPHICS_API_OPENGL_33 * #define GRAPHICS_API_OPENGL_33
* Use OpenGL 3.3 Core profile backend
*
* #define GRAPHICS_API_OPENGL_ES2 * #define GRAPHICS_API_OPENGL_ES2
* Use OpenGL ES 2.0 backend * Use selected OpenGL backend
* *
* #define RLGL_STANDALONE * #define RLGL_STANDALONE
* Use rlgl as standalone library (no raylib dependency) * Use rlgl as standalone library (no raylib dependency)
* *
* #define RLGL_NO_DISTORTION_SHADER * #define SUPPORT_VR_SIMULATION / SUPPORT_STEREO_RENDERING
* Avoid stereo rendering distortion sahder (shader_distortion.h) inclusion * Support VR simulation functionality (stereo rendering)
* *
* #define SUPPORT_SHADER_DEFAULT / ENABLE_SHADER_DEFAULT * #define SUPPORT_DISTORTION_SHADER
* * Include stereo rendering distortion shader (shader_distortion.h)
* #define SUPPORT_SHADER_DISTORTION
*
*
* #define SUPPORT_OCULUS_RIFT_CV1 / RLGL_OCULUS_SUPPORT
* Enable Oculus Rift CV1 functionality
*
* #define SUPPORT_STEREO_RENDERING
*
* #define RLGL_NO_DEFAULT_SHADER
* *
* DEPENDENCIES: * DEPENDENCIES:
* raymath - 3D math functionality (Vector3, Matrix, Quaternion) * raymath - 3D math functionality (Vector3, Matrix, Quaternion)
@ -52,7 +35,7 @@
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -71,6 +54,11 @@
* *
**********************************************************************************************/ **********************************************************************************************/
// Default configuration flags (supported features)
//-------------------------------------------------
#define SUPPORT_VR_SIMULATION
//-------------------------------------------------
#include "rlgl.h" #include "rlgl.h"
#include <stdio.h> // Required for: fopen(), fclose(), fread()... [Used only on LoadText()] #include <stdio.h> // Required for: fopen(), fclose(), fread()... [Used only on LoadText()]
@ -117,21 +105,10 @@
#include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end() [Used only on TraceLog()] #include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end() [Used only on TraceLog()]
#endif #endif
#if !defined(GRAPHICS_API_OPENGL_11) && !defined(RLGL_NO_DISTORTION_SHADER) #if !defined(GRAPHICS_API_OPENGL_11) && defined(SUPPORT_DISTORTION_SHADER)
#include "shader_distortion.h" // Distortion shader to be embedded #include "shader_distortion.h" // Distortion shader to be embedded
#endif #endif
//#define RLGL_OCULUS_SUPPORT // Enable Oculus Rift code
#if defined(RLGL_OCULUS_SUPPORT)
#include "external/OculusSDK/LibOVR/Include/OVR_CAPI_GL.h" // Oculus SDK for OpenGL
#endif
#if defined(RLGL_STANDALONE)
#define OCULUSAPI
#else
#define OCULUSAPI static
#endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Defines and Macros // Defines and Macros
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -187,15 +164,15 @@
#endif #endif
#if defined(GRAPHICS_API_OPENGL_11) #if defined(GRAPHICS_API_OPENGL_11)
#define GL_UNSIGNED_SHORT_5_6_5 0x8363 #define GL_UNSIGNED_SHORT_5_6_5 0x8363
#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
#endif #endif
#if defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_ES2)
#define glClearDepth glClearDepthf #define glClearDepth glClearDepthf
#define GL_READ_FRAMEBUFFER GL_FRAMEBUFFER #define GL_READ_FRAMEBUFFER GL_FRAMEBUFFER
#define GL_DRAW_FRAMEBUFFER GL_FRAMEBUFFER #define GL_DRAW_FRAMEBUFFER GL_FRAMEBUFFER
#endif #endif
// Default vertex attribute names on shader to set location points // Default vertex attribute names on shader to set location points
@ -267,32 +244,6 @@ typedef struct VrStereoConfig {
Matrix eyesViewOffset[2]; // VR stereo rendering eyes view offset matrices Matrix eyesViewOffset[2]; // VR stereo rendering eyes view offset matrices
} VrStereoConfig; } VrStereoConfig;
#if defined(RLGL_OCULUS_SUPPORT)
typedef struct OculusBuffer {
ovrTextureSwapChain textureChain;
GLuint depthId;
GLuint fboId;
int width;
int height;
} OculusBuffer;
typedef struct OculusMirror {
ovrMirrorTexture texture;
GLuint fboId;
int width;
int height;
} OculusMirror;
typedef struct OculusLayer {
ovrViewScaleDesc viewScaleDesc;
ovrLayerEyeFov eyeLayer; // layer 0
//ovrLayerQuad quadLayer; // TODO: layer 1: '2D' quad for GUI
Matrix eyeProjections[2];
int width;
int height;
} OculusLayer;
#endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition // Global Variables Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -305,7 +256,7 @@ static Matrix projection;
static Matrix *currentMatrix; static Matrix *currentMatrix;
static int currentMatrixMode; static int currentMatrixMode;
static DrawMode currentDrawMode; static int currentDrawMode;
static float currentDepth = -1.0f; static float currentDepth = -1.0f;
@ -334,6 +285,13 @@ static bool texCompETC1Supported = false; // ETC1 texture compression support
static bool texCompETC2Supported = false; // ETC2/EAC texture compression support static bool texCompETC2Supported = false; // ETC2/EAC texture compression support
static bool texCompPVRTSupported = false; // PVR texture compression support static bool texCompPVRTSupported = false; // PVR texture compression support
static bool texCompASTCSupported = false; // ASTC texture compression support static bool texCompASTCSupported = false; // ASTC texture compression support
// VR global variables
static VrDeviceInfo hmd; // Current VR device info
static VrStereoConfig vrConfig; // VR stereo configuration for simulator
static bool vrSimulatorReady = false; // VR simulator ready flag
static bool vrStereoRender = false; // VR stereo rendering enabled/disabled flag
// NOTE: This flag is useful to render data over stereo image (i.e. FPS)
#endif #endif
// Extension supported flag: Anisotropic filtering // Extension supported flag: Anisotropic filtering
@ -343,26 +301,6 @@ static float maxAnisotropicLevel = 0.0f; // Maximum anisotropy level supp
// Extension supported flag: Clamp mirror wrap mode // Extension supported flag: Clamp mirror wrap mode
static bool texClampMirrorSupported = false; // Clamp mirror wrap mode supported static bool texClampMirrorSupported = false; // Clamp mirror wrap mode supported
#if defined(RLGL_OCULUS_SUPPORT)
// OVR device variables
static ovrSession session; // Oculus session (pointer to ovrHmdStruct)
static ovrHmdDesc hmdDesc; // Oculus device descriptor parameters
static ovrGraphicsLuid luid; // Oculus locally unique identifier for the program (64 bit)
static OculusLayer layer; // Oculus drawing layer (similar to photoshop)
static OculusBuffer buffer; // Oculus internal buffers (texture chain and fbo)
static OculusMirror mirror; // Oculus mirror texture and fbo
static unsigned int frameIndex = 0; // Oculus frames counter, used to discard frames from chain
#endif
// VR global variables
static VrDeviceInfo hmd; // Current VR device info
static VrStereoConfig vrConfig; // VR stereo configuration for simulator
static bool vrDeviceReady = false; // VR device ready flag
static bool vrSimulator = false; // VR simulator enabled flag
static bool vrEnabled = false; // VR experience enabled (device or simulator)
static bool vrRendering = true; // VR stereo rendering enabled/disabled flag
// NOTE: This flag is useful to render data over stereo image (i.e. FPS)
#if defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_ES2)
// NOTE: VAO functionality is exposed through extensions (OES) // NOTE: VAO functionality is exposed through extensions (OES)
static PFNGLGENVERTEXARRAYSOESPROC glGenVertexArrays; static PFNGLGENVERTEXARRAYSOESPROC glGenVertexArrays;
@ -380,7 +318,7 @@ static int blendMode = 0; // Track current blending mode
// White texture useful for plain color polys (required by shader) // White texture useful for plain color polys (required by shader)
static unsigned int whiteTexture; static unsigned int whiteTexture;
// Default framebuffer size (required by Oculus device) // Default framebuffer size
static int screenWidth; // Default framebuffer width static int screenWidth; // Default framebuffer width
static int screenHeight; // Default framebuffer height static int screenHeight; // Default framebuffer height
@ -397,7 +335,7 @@ static void UnloadDefaultShader(void); // Unload default shader
static void LoadDefaultBuffers(void); // Load default internal buffers (lines, triangles, quads) static void LoadDefaultBuffers(void); // Load default internal buffers (lines, triangles, quads)
static void UpdateDefaultBuffers(void); // Update default internal buffers (VAOs/VBOs) with vertex data static void UpdateDefaultBuffers(void); // Update default internal buffers (VAOs/VBOs) with vertex data
static void DrawDefaultBuffers(int eyesCount); // Draw default internal buffers vertex data static void DrawDefaultBuffers(void); // Draw default internal buffers vertex data
static void UnloadDefaultBuffers(void); // Unload default internal buffers vertex data from CPU and GPU static void UnloadDefaultBuffers(void); // Unload default internal buffers vertex data from CPU and GPU
// Configure stereo rendering (including distortion shader) with HMD device parameters // Configure stereo rendering (including distortion shader) with HMD device parameters
@ -407,26 +345,6 @@ static void SetStereoConfig(VrDeviceInfo info);
static void SetStereoView(int eye, Matrix matProjection, Matrix matModelView); static void SetStereoView(int eye, Matrix matProjection, Matrix matModelView);
#endif #endif
#if defined(RLGL_OCULUS_SUPPORT)
#if !defined(RLGL_STANDALONE)
static bool InitOculusDevice(void); // Initialize Oculus device (returns true if success)
static void CloseOculusDevice(void); // Close Oculus device
static void UpdateOculusTracking(Camera *camera); // Update Oculus head position-orientation tracking
static void BeginOculusDrawing(void); // Setup Oculus buffers for drawing
static void EndOculusDrawing(void); // Finish Oculus drawing and blit framebuffer to mirror
#endif
static OculusBuffer LoadOculusBuffer(ovrSession session, int width, int height); // Load Oculus required buffers
static void UnloadOculusBuffer(ovrSession session, OculusBuffer buffer); // Unload texture required buffers
static OculusMirror LoadOculusMirror(ovrSession session, int width, int height); // Load Oculus mirror buffers
static void UnloadOculusMirror(ovrSession session, OculusMirror mirror); // Unload Oculus mirror buffers
static void BlitOculusMirror(ovrSession session, OculusMirror mirror); // Copy Oculus screen buffer to mirror texture
static OculusLayer InitOculusLayer(ovrSession session); // Init Oculus layer (similar to photoshop)
static Matrix FromOvrMatrix(ovrMatrix4f ovrM); // Convert from Oculus ovrMatrix4f struct to raymath Matrix struct
#endif
#if defined(GRAPHICS_API_OPENGL_11) #if defined(GRAPHICS_API_OPENGL_11)
static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight); static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight);
static Color *GenNextMipmap(Color *srcData, int srcWidth, int srcHeight); static Color *GenNextMipmap(Color *srcData, int srcWidth, int srcHeight);
@ -1352,9 +1270,7 @@ void rlglDraw(void)
// NOTE: Default buffers upload and draw // NOTE: Default buffers upload and draw
UpdateDefaultBuffers(); UpdateDefaultBuffers();
DrawDefaultBuffers(); // NOTE: Stereo rendering is checked inside
if (vrEnabled && vrRendering) DrawDefaultBuffers(2);
else DrawDefaultBuffers(1);
#endif #endif
} }
@ -2018,9 +1934,6 @@ void rlglDrawMesh(Mesh mesh, Material material, Matrix transform)
#endif #endif
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
int eyesCount = 1;
if (vrEnabled) eyesCount = 2;
glUseProgram(material.shader.id); glUseProgram(material.shader.id);
// Upload to shader material.colDiffuse // Upload to shader material.colDiffuse
@ -2153,6 +2066,9 @@ void rlglDrawMesh(Mesh mesh, Material material, Matrix transform)
if (mesh.indices != NULL) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, quads.vboId[3]); if (mesh.indices != NULL) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, quads.vboId[3]);
} }
int eyesCount = 1;
if (vrStereoRender) eyesCount = 2;
for (int eye = 0; eye < eyesCount; eye++) for (int eye = 0; eye < eyesCount; eye++)
{ {
if (eyesCount == 2) SetStereoView(eye, matProjection, matModelView); if (eyesCount == 2) SetStereoView(eye, matProjection, matModelView);
@ -2617,146 +2533,127 @@ void EndBlendMode(void)
BeginBlendMode(BLEND_ALPHA); BeginBlendMode(BLEND_ALPHA);
} }
// Init VR device (or simulator) // Init VR simulator for selected device
// NOTE: If device is not available, it fallbacks to default device (simulator)
// NOTE: It modifies the global variable: VrDeviceInfo hmd // NOTE: It modifies the global variable: VrDeviceInfo hmd
void InitVrDevice(int vrDevice) void InitVrSimulator(int vrDevice)
{ {
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
switch (vrDevice) if (vrDevice == HMD_OCULUS_RIFT_DK2)
{ {
case HMD_DEFAULT_DEVICE: TraceLog(INFO, "Initializing default VR Device (Oculus Rift CV1)"); // Oculus Rift DK2 parameters
case HMD_OCULUS_RIFT_DK2: hmd.hResolution = 1280; // HMD horizontal resolution in pixels
case HMD_OCULUS_RIFT_CV1: hmd.vResolution = 800; // HMD vertical resolution in pixels
{ hmd.hScreenSize = 0.14976f; // HMD horizontal size in meters
#if defined(RLGL_OCULUS_SUPPORT) hmd.vScreenSize = 0.09356f; // HMD vertical size in meters
vrDeviceReady = InitOculusDevice(); hmd.vScreenCenter = 0.04678f; // HMD screen center in meters
#else hmd.eyeToScreenDistance = 0.041f; // HMD distance between eye and display in meters
TraceLog(WARNING, "Oculus Rift not supported by default, recompile raylib with Oculus support"); hmd.lensSeparationDistance = 0.0635f; // HMD lens separation distance in meters
hmd.interpupillaryDistance = 0.064f; // HMD IPD (distance between pupils) in meters
hmd.distortionK[0] = 1.0f; // HMD lens distortion constant parameter 0
hmd.distortionK[1] = 0.22f; // HMD lens distortion constant parameter 1
hmd.distortionK[2] = 0.24f; // HMD lens distortion constant parameter 2
hmd.distortionK[3] = 0.0f; // HMD lens distortion constant parameter 3
hmd.chromaAbCorrection[0] = 0.996f; // HMD chromatic aberration correction parameter 0
hmd.chromaAbCorrection[1] = -0.004f; // HMD chromatic aberration correction parameter 1
hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2
hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3
TraceLog(WARNING, "Initializing VR Simulator (Oculus Rift DK2)");
}
else if ((vrDevice == HMD_DEFAULT_DEVICE) || (vrDevice == HMD_OCULUS_RIFT_CV1))
{
// Oculus Rift CV1 parameters
// NOTE: CV1 represents a complete HMD redesign compared to previous versions,
// new Fresnel-hybrid-asymmetric lenses have been added and, consequently,
// previous parameters (DK2) and distortion shader (DK2) doesn't work any more.
// I just defined a set of parameters for simulator that approximate to CV1 stereo rendering
// but result is not the same obtained with Oculus PC SDK.
hmd.hResolution = 2160; // HMD horizontal resolution in pixels
hmd.vResolution = 1200; // HMD vertical resolution in pixels
hmd.hScreenSize = 0.133793f; // HMD horizontal size in meters
hmd.vScreenSize = 0.0669f; // HMD vertical size in meters
hmd.vScreenCenter = 0.04678f; // HMD screen center in meters
hmd.eyeToScreenDistance = 0.041f; // HMD distance between eye and display in meters
hmd.lensSeparationDistance = 0.07f; // HMD lens separation distance in meters
hmd.interpupillaryDistance = 0.07f; // HMD IPD (distance between pupils) in meters
hmd.distortionK[0] = 1.0f; // HMD lens distortion constant parameter 0
hmd.distortionK[1] = 0.22f; // HMD lens distortion constant parameter 1
hmd.distortionK[2] = 0.24f; // HMD lens distortion constant parameter 2
hmd.distortionK[3] = 0.0f; // HMD lens distortion constant parameter 3
hmd.chromaAbCorrection[0] = 0.996f; // HMD chromatic aberration correction parameter 0
hmd.chromaAbCorrection[1] = -0.004f; // HMD chromatic aberration correction parameter 1
hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2
hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3
TraceLog(WARNING, "Initializing VR Simulator (Oculus Rift CV1)");
}
else
{
TraceLog(WARNING, "VR Simulator doesn't support current device yet,");
TraceLog(WARNING, "using default VR Simulator parameters");
}
// Initialize framebuffer and textures for stereo rendering
// NOTE: screen size should match HMD aspect ratio
vrConfig.stereoFbo = rlglLoadRenderTexture(screenWidth, screenHeight);
#if defined(SUPPORT_DISTORTION_SHADER)
// Load distortion shader (initialized by default with Oculus Rift CV1 parameters)
vrConfig.distortionShader.id = LoadShaderProgram(vDistortionShaderStr, fDistortionShaderStr);
if (vrConfig.distortionShader.id != 0) LoadDefaultShaderLocations(&vrConfig.distortionShader);
#endif #endif
} break;
case HMD_VALVE_HTC_VIVE:
case HMD_SAMSUNG_GEAR_VR:
case HMD_GOOGLE_CARDBOARD:
case HMD_SONY_PLAYSTATION_VR:
case HMD_RAZER_OSVR:
case HMD_FOVE_VR: TraceLog(WARNING, "VR Device not supported");
default: break;
}
if (!vrDeviceReady) SetStereoConfig(hmd);
{
TraceLog(WARNING, "VR Device not found: Initializing VR Simulator (Oculus Rift CV1)");
if (vrDevice == HMD_OCULUS_RIFT_DK2) vrSimulatorReady = true;
{
// Oculus Rift DK2 parameters
hmd.hResolution = 1280; // HMD horizontal resolution in pixels
hmd.vResolution = 800; // HMD vertical resolution in pixels
hmd.hScreenSize = 0.14976f; // HMD horizontal size in meters
hmd.vScreenSize = 0.09356f; // HMD vertical size in meters
hmd.vScreenCenter = 0.04678f; // HMD screen center in meters
hmd.eyeToScreenDistance = 0.041f; // HMD distance between eye and display in meters
hmd.lensSeparationDistance = 0.0635f; // HMD lens separation distance in meters
hmd.interpupillaryDistance = 0.064f; // HMD IPD (distance between pupils) in meters
hmd.distortionK[0] = 1.0f; // HMD lens distortion constant parameter 0
hmd.distortionK[1] = 0.22f; // HMD lens distortion constant parameter 1
hmd.distortionK[2] = 0.24f; // HMD lens distortion constant parameter 2
hmd.distortionK[3] = 0.0f; // HMD lens distortion constant parameter 3
hmd.chromaAbCorrection[0] = 0.996f; // HMD chromatic aberration correction parameter 0
hmd.chromaAbCorrection[1] = -0.004f; // HMD chromatic aberration correction parameter 1
hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2
hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3
}
else if ((vrDevice == HMD_DEFAULT_DEVICE) || (vrDevice == HMD_OCULUS_RIFT_CV1))
{
// Oculus Rift CV1 parameters
// NOTE: CV1 represents a complete HMD redesign compared to previous versions,
// new Fresnel-hybrid-asymmetric lenses have been added and, consequently,
// previous parameters (DK2) and distortion shader (DK2) doesn't work any more.
// I just defined a set of parameters for simulator that approximate to CV1 stereo rendering
// but result is not the same obtained with Oculus PC SDK.
hmd.hResolution = 2160; // HMD horizontal resolution in pixels
hmd.vResolution = 1200; // HMD vertical resolution in pixels
hmd.hScreenSize = 0.133793f; // HMD horizontal size in meters
hmd.vScreenSize = 0.0669f; // HMD vertical size in meters
hmd.vScreenCenter = 0.04678f; // HMD screen center in meters
hmd.eyeToScreenDistance = 0.041f; // HMD distance between eye and display in meters
hmd.lensSeparationDistance = 0.07f; // HMD lens separation distance in meters
hmd.interpupillaryDistance = 0.07f; // HMD IPD (distance between pupils) in meters
hmd.distortionK[0] = 1.0f; // HMD lens distortion constant parameter 0
hmd.distortionK[1] = 0.22f; // HMD lens distortion constant parameter 1
hmd.distortionK[2] = 0.24f; // HMD lens distortion constant parameter 2
hmd.distortionK[3] = 0.0f; // HMD lens distortion constant parameter 3
hmd.chromaAbCorrection[0] = 0.996f; // HMD chromatic aberration correction parameter 0
hmd.chromaAbCorrection[1] = -0.004f; // HMD chromatic aberration correction parameter 1
hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2
hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3
}
// Initialize framebuffer and textures for stereo rendering
// NOTE: screen size should match HMD aspect ratio
vrConfig.stereoFbo = rlglLoadRenderTexture(screenWidth, screenHeight);
// Load distortion shader (initialized by default with Oculus Rift CV1 parameters)
vrConfig.distortionShader.id = LoadShaderProgram(vDistortionShaderStr, fDistortionShaderStr);
if (vrConfig.distortionShader.id != 0) LoadDefaultShaderLocations(&vrConfig.distortionShader);
SetStereoConfig(hmd);
vrSimulator = true;
vrEnabled = true;
}
#endif #endif
#if defined(GRAPHICS_API_OPENGL_11) #if defined(GRAPHICS_API_OPENGL_11)
TraceLog(WARNING, "VR device or simulator not supported on OpenGL 1.1"); TraceLog(WARNING, "VR Simulator not supported on OpenGL 1.1");
#endif #endif
} }
// Close VR device (or simulator) // Close VR simulator for current device
void CloseVrDevice(void) void CloseVrSimulator(void)
{ {
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
#if defined(RLGL_OCULUS_SUPPORT) if (vrSimulatorReady)
if (vrDeviceReady) CloseOculusDevice();
else
#endif
{ {
rlDeleteRenderTextures(vrConfig.stereoFbo); // Unload stereo framebuffer and texture rlDeleteRenderTextures(vrConfig.stereoFbo); // Unload stereo framebuffer and texture
#if defined(SUPPORT_DISTORTION_SHADER)
UnloadShader(vrConfig.distortionShader); // Unload distortion shader UnloadShader(vrConfig.distortionShader); // Unload distortion shader
#endif
} }
#endif #endif
vrDeviceReady = false;
}
// Detect if VR device is available
bool IsVrDeviceReady(void)
{
return (vrDeviceReady && vrEnabled);
} }
// Detect if VR simulator is running // Detect if VR simulator is running
bool IsVrSimulator(void) bool IsVrSimulatorReady(void)
{ {
return (vrSimulator && vrEnabled); #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
return vrSimulatorReady;
#else
return false;
#endif
} }
// Enable/Disable VR experience (device or simulator) // Enable/Disable VR experience (device or simulator)
void ToggleVrMode(void) void ToggleVrMode(void)
{ {
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
if (vrDeviceReady || vrSimulator) vrEnabled = !vrEnabled; vrSimulatorReady = !vrSimulatorReady;
else vrEnabled = false;
if (!vrEnabled) if (!vrSimulatorReady)
{ {
vrStereoRender = false;
// Reset viewport and default projection-modelview matrices // Reset viewport and default projection-modelview matrices
rlViewport(0, 0, screenWidth, screenHeight); rlViewport(0, 0, screenWidth, screenHeight);
projection = MatrixOrtho(0, screenWidth, screenHeight, 0, 0.0f, 1.0f); projection = MatrixOrtho(0, screenWidth, screenHeight, 0, 0.0f, 1.0f);
MatrixTranspose(&projection); MatrixTranspose(&projection);
modelview = MatrixIdentity(); modelview = MatrixIdentity();
} }
else vrStereoRender = true;
#endif #endif
} }
@ -2764,37 +2661,29 @@ void ToggleVrMode(void)
// NOTE: Camera (position, target, up) gets update with head tracking information // NOTE: Camera (position, target, up) gets update with head tracking information
void UpdateVrTracking(Camera *camera) void UpdateVrTracking(Camera *camera)
{ {
#if defined(RLGL_OCULUS_SUPPORT) // TODO: Simulate 1st person camera system
if (vrDeviceReady) UpdateOculusTracking(camera);
#endif
} }
// Begin Oculus drawing configuration // Begin Oculus drawing configuration
void BeginVrDrawing(void) void BeginVrDrawing(void)
{ {
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
#if defined(RLGL_OCULUS_SUPPORT) if (vrSimulatorReady)
if (vrDeviceReady)
{
BeginOculusDrawing();
}
else
#endif
{ {
// Setup framebuffer for stereo rendering // Setup framebuffer for stereo rendering
rlEnableRenderTexture(vrConfig.stereoFbo.id); rlEnableRenderTexture(vrConfig.stereoFbo.id);
// NOTE: If your application is configured to treat the texture as a linear format (e.g. GL_RGBA)
// and performs linear-to-gamma conversion in GLSL or does not care about gamma-correction, then:
// - Require OculusBuffer format to be OVR_FORMAT_R8G8B8A8_UNORM_SRGB
// - Do NOT enable GL_FRAMEBUFFER_SRGB
//glEnable(GL_FRAMEBUFFER_SRGB);
//glViewport(0, 0, buffer.width, buffer.height); // Useful if rendering to separate framebuffers (every eye)
rlClearScreenBuffers(); // Clear current framebuffer(s)
vrStereoRender = true;
} }
// NOTE: If your application is configured to treat the texture as a linear format (e.g. GL_RGBA)
// and performs linear-to-gamma conversion in GLSL or does not care about gamma-correction, then:
// - Require OculusBuffer format to be OVR_FORMAT_R8G8B8A8_UNORM_SRGB
// - Do NOT enable GL_FRAMEBUFFER_SRGB
//glEnable(GL_FRAMEBUFFER_SRGB);
//glViewport(0, 0, buffer.width, buffer.height); // Useful if rendering to separate framebuffers (every eye)
rlClearScreenBuffers(); // Clear current framebuffer(s)
vrRendering = true;
#endif #endif
} }
@ -2802,18 +2691,13 @@ void BeginVrDrawing(void)
void EndVrDrawing(void) void EndVrDrawing(void)
{ {
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
#if defined(RLGL_OCULUS_SUPPORT) if (vrSimulatorReady)
if (vrDeviceReady)
{ {
EndOculusDrawing(); vrStereoRender = false; // Disable stereo render
}
else rlDisableRenderTexture(); // Unbind current framebuffer
#endif
{
// Unbind current framebuffer
rlDisableRenderTexture();
rlClearScreenBuffers(); // Clear current framebuffer rlClearScreenBuffers(); // Clear current framebuffer
// Set viewport to default framebuffer size (screen size) // Set viewport to default framebuffer size (screen size)
rlViewport(0, 0, screenWidth, screenHeight); rlViewport(0, 0, screenWidth, screenHeight);
@ -2825,8 +2709,12 @@ void EndVrDrawing(void)
rlMatrixMode(RL_MODELVIEW); // Enable internal modelview matrix rlMatrixMode(RL_MODELVIEW); // Enable internal modelview matrix
rlLoadIdentity(); // Reset internal modelview matrix rlLoadIdentity(); // Reset internal modelview matrix
#if defined(SUPPORT_DISTORTION_SHADER)
// Draw RenderTexture (stereoFbo) using distortion shader // Draw RenderTexture (stereoFbo) using distortion shader
currentShader = vrConfig.distortionShader; currentShader = vrConfig.distortionShader;
#else
currentShader = GetDefaultShader();
#endif
rlEnableTexture(vrConfig.stereoFbo.texture.id); rlEnableTexture(vrConfig.stereoFbo.texture.id);
@ -2855,15 +2743,21 @@ void EndVrDrawing(void)
rlDisableTexture(); rlDisableTexture();
// Update and draw render texture fbo with distortion to backbuffer
UpdateDefaultBuffers(); UpdateDefaultBuffers();
DrawDefaultBuffers(1); DrawDefaultBuffers();
// Restore defaultShader
currentShader = defaultShader; currentShader = defaultShader;
// Reset viewport and default projection-modelview matrices
rlViewport(0, 0, screenWidth, screenHeight);
projection = MatrixOrtho(0, screenWidth, screenHeight, 0, 0.0f, 1.0f);
MatrixTranspose(&projection);
modelview = MatrixIdentity();
rlDisableDepthTest();
} }
rlDisableDepthTest();
vrRendering = false;
#endif #endif
} }
@ -3405,10 +3299,13 @@ static void UpdateDefaultBuffers(void)
// Draw default internal buffers vertex data // Draw default internal buffers vertex data
// NOTE: We draw in this order: lines, triangles, quads // NOTE: We draw in this order: lines, triangles, quads
static void DrawDefaultBuffers(int eyesCount) static void DrawDefaultBuffers()
{ {
Matrix matProjection = projection; Matrix matProjection = projection;
Matrix matModelView = modelview; Matrix matModelView = modelview;
int eyesCount = 1;
if (vrStereoRender) eyesCount = 2;
for (int eye = 0; eye < eyesCount; eye++) for (int eye = 0; eye < eyesCount; eye++)
{ {
@ -3652,6 +3549,7 @@ static void SetStereoConfig(VrDeviceInfo hmd)
TraceLog(DEBUG, "VR: Distortion Shader: Scale = { %f, %f }", scale[0], scale[1]); TraceLog(DEBUG, "VR: Distortion Shader: Scale = { %f, %f }", scale[0], scale[1]);
TraceLog(DEBUG, "VR: Distortion Shader: ScaleIn = { %f, %f }", scaleIn[0], scaleIn[1]); TraceLog(DEBUG, "VR: Distortion Shader: ScaleIn = { %f, %f }", scaleIn[0], scaleIn[1]);
#if defined(SUPPORT_DISTORTION_SHADER)
// Update distortion shader with lens and distortion-scale parameters // Update distortion shader with lens and distortion-scale parameters
SetShaderValue(vrConfig.distortionShader, GetShaderLocation(vrConfig.distortionShader, "leftLensCenter"), leftLensCenter, 2); SetShaderValue(vrConfig.distortionShader, GetShaderLocation(vrConfig.distortionShader, "leftLensCenter"), leftLensCenter, 2);
SetShaderValue(vrConfig.distortionShader, GetShaderLocation(vrConfig.distortionShader, "rightLensCenter"), rightLensCenter, 2); SetShaderValue(vrConfig.distortionShader, GetShaderLocation(vrConfig.distortionShader, "rightLensCenter"), rightLensCenter, 2);
@ -3662,6 +3560,7 @@ static void SetStereoConfig(VrDeviceInfo hmd)
SetShaderValue(vrConfig.distortionShader, GetShaderLocation(vrConfig.distortionShader, "scaleIn"), scaleIn, 2); SetShaderValue(vrConfig.distortionShader, GetShaderLocation(vrConfig.distortionShader, "scaleIn"), scaleIn, 2);
SetShaderValue(vrConfig.distortionShader, GetShaderLocation(vrConfig.distortionShader, "hmdWarpParam"), hmd.distortionK, 4); SetShaderValue(vrConfig.distortionShader, GetShaderLocation(vrConfig.distortionShader, "hmdWarpParam"), hmd.distortionK, 4);
SetShaderValue(vrConfig.distortionShader, GetShaderLocation(vrConfig.distortionShader, "chromaAbParam"), hmd.chromaAbCorrection, 4); SetShaderValue(vrConfig.distortionShader, GetShaderLocation(vrConfig.distortionShader, "chromaAbParam"), hmd.chromaAbCorrection, 4);
#endif
// Fovy is normally computed with: 2*atan2(hmd.vScreenSize, 2*hmd.eyeToScreenDistance)*RAD2DEG // Fovy is normally computed with: 2*atan2(hmd.vScreenSize, 2*hmd.eyeToScreenDistance)*RAD2DEG
// ...but with lens distortion it is increased (see Oculus SDK Documentation) // ...but with lens distortion it is increased (see Oculus SDK Documentation)
@ -3693,47 +3592,19 @@ static void SetStereoConfig(VrDeviceInfo hmd)
// Set internal projection and modelview matrix depending on eyes tracking data // Set internal projection and modelview matrix depending on eyes tracking data
static void SetStereoView(int eye, Matrix matProjection, Matrix matModelView) static void SetStereoView(int eye, Matrix matProjection, Matrix matModelView)
{ {
if (vrEnabled) Matrix eyeProjection = matProjection;
{ Matrix eyeModelView = matModelView;
Matrix eyeProjection = matProjection;
Matrix eyeModelView = matModelView;
#if defined(RLGL_OCULUS_SUPPORT) // Setup viewport and projection/modelview matrices using tracking data
if (vrDeviceReady) rlViewport(eye*screenWidth/2, 0, screenWidth/2, screenHeight);
{
rlViewport(layer.eyeLayer.Viewport[eye].Pos.x, layer.eyeLayer.Viewport[eye].Pos.y,
layer.eyeLayer.Viewport[eye].Size.w, layer.eyeLayer.Viewport[eye].Size.h);
Quaternion eyeRenderPose = (Quaternion){ layer.eyeLayer.RenderPose[eye].Orientation.x, // Apply view offset to modelview matrix
layer.eyeLayer.RenderPose[eye].Orientation.y, eyeModelView = MatrixMultiply(matModelView, vrConfig.eyesViewOffset[eye]);
layer.eyeLayer.RenderPose[eye].Orientation.z,
layer.eyeLayer.RenderPose[eye].Orientation.w };
QuaternionInvert(&eyeRenderPose);
Matrix eyeOrientation = QuaternionToMatrix(eyeRenderPose);
Matrix eyeTranslation = MatrixTranslate(-layer.eyeLayer.RenderPose[eye].Position.x,
-layer.eyeLayer.RenderPose[eye].Position.y,
-layer.eyeLayer.RenderPose[eye].Position.z);
Matrix eyeView = MatrixMultiply(eyeTranslation, eyeOrientation); // Matrix containing eye-head movement eyeProjection = vrConfig.eyesProjection[eye];
eyeModelView = MatrixMultiply(matModelView, eyeView); // Combine internal camera matrix (modelview) wih eye-head movement
eyeProjection = layer.eyeProjections[eye]; SetMatrixModelview(eyeModelView);
} SetMatrixProjection(eyeProjection);
else
#endif
{
// Setup viewport and projection/modelview matrices using tracking data
rlViewport(eye*screenWidth/2, 0, screenWidth/2, screenHeight);
// Apply view offset to modelview matrix
eyeModelView = MatrixMultiply(matModelView, vrConfig.eyesViewOffset[eye]);
eyeProjection = vrConfig.eyesProjection[eye];
}
SetMatrixModelview(eyeModelView);
SetMatrixProjection(eyeProjection);
}
} }
#endif //defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #endif //defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
@ -3864,304 +3735,6 @@ static Color *GenNextMipmap(Color *srcData, int srcWidth, int srcHeight)
} }
#endif #endif
#if defined(RLGL_OCULUS_SUPPORT)
// Initialize Oculus device (returns true if success)
OCULUSAPI bool InitOculusDevice(void)
{
bool oculusReady = false;
ovrResult result = ovr_Initialize(NULL);
if (OVR_FAILURE(result)) TraceLog(WARNING, "OVR: Could not initialize Oculus device");
else
{
result = ovr_Create(&session, &luid);
if (OVR_FAILURE(result))
{
TraceLog(WARNING, "OVR: Could not create Oculus session");
ovr_Shutdown();
}
else
{
hmdDesc = ovr_GetHmdDesc(session);
TraceLog(INFO, "OVR: Product Name: %s", hmdDesc.ProductName);
TraceLog(INFO, "OVR: Manufacturer: %s", hmdDesc.Manufacturer);
TraceLog(INFO, "OVR: Product ID: %i", hmdDesc.ProductId);
TraceLog(INFO, "OVR: Product Type: %i", hmdDesc.Type);
//TraceLog(INFO, "OVR: Serial Number: %s", hmdDesc.SerialNumber);
TraceLog(INFO, "OVR: Resolution: %ix%i", hmdDesc.Resolution.w, hmdDesc.Resolution.h);
// NOTE: Oculus mirror is set to defined screenWidth and screenHeight...
// ...ideally, it should be (hmdDesc.Resolution.w/2, hmdDesc.Resolution.h/2)
// Initialize Oculus Buffers
layer = InitOculusLayer(session);
buffer = LoadOculusBuffer(session, layer.width, layer.height);
mirror = LoadOculusMirror(session, hmdDesc.Resolution.w/2, hmdDesc.Resolution.h/2); // NOTE: hardcoded...
layer.eyeLayer.ColorTexture[0] = buffer.textureChain; //SetOculusLayerTexture(eyeLayer, buffer.textureChain);
// Recenter OVR tracking origin
ovr_RecenterTrackingOrigin(session);
oculusReady = true;
vrEnabled = true;
}
}
return oculusReady;
}
// Close Oculus device (and unload buffers)
OCULUSAPI void CloseOculusDevice(void)
{
UnloadOculusMirror(session, mirror); // Unload Oculus mirror buffer
UnloadOculusBuffer(session, buffer); // Unload Oculus texture buffers
ovr_Destroy(session); // Free Oculus session data
ovr_Shutdown(); // Close Oculus device connection
}
// Update Oculus head position-orientation tracking
OCULUSAPI void UpdateOculusTracking(Camera *camera)
{
frameIndex++;
ovrPosef eyePoses[2];
ovr_GetEyePoses(session, frameIndex, ovrTrue, layer.viewScaleDesc.HmdToEyeOffset, eyePoses, &layer.eyeLayer.SensorSampleTime);
layer.eyeLayer.RenderPose[0] = eyePoses[0];
layer.eyeLayer.RenderPose[1] = eyePoses[1];
// TODO: Update external camera with eyePoses data (position, orientation)
// NOTE: We can simplify to simple camera if we consider IPD and HMD device configuration again later
// it will be useful for the user to draw, lets say, billboards oriented to camera
// Get session status information
ovrSessionStatus sessionStatus;
ovr_GetSessionStatus(session, &sessionStatus);
if (sessionStatus.ShouldQuit) TraceLog(WARNING, "OVR: Session should quit...");
if (sessionStatus.ShouldRecenter) ovr_RecenterTrackingOrigin(session);
//if (sessionStatus.HmdPresent) // HMD is present.
//if (sessionStatus.DisplayLost) // HMD was unplugged or the display driver was manually disabled or encountered a TDR.
//if (sessionStatus.HmdMounted) // HMD is on the user's head.
//if (sessionStatus.IsVisible) // the game or experience has VR focus and is visible in the HMD.
}
// Setup Oculus buffers for drawing
OCULUSAPI void BeginOculusDrawing(void)
{
GLuint currentTexId;
int currentIndex;
ovr_GetTextureSwapChainCurrentIndex(session, buffer.textureChain, &currentIndex);
ovr_GetTextureSwapChainBufferGL(session, buffer.textureChain, currentIndex, &currentTexId);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, buffer.fboId);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, currentTexId, 0);
//glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, buffer.depthId, 0); // Already binded
}
// Finish Oculus drawing and blit framebuffer to mirror
OCULUSAPI void EndOculusDrawing(void)
{
// Unbind current framebuffer (Oculus buffer)
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
ovr_CommitTextureSwapChain(session, buffer.textureChain);
ovrLayerHeader *layers = &layer.eyeLayer.Header;
ovr_SubmitFrame(session, frameIndex, &layer.viewScaleDesc, &layers, 1);
// Blit mirror texture to back buffer
BlitOculusMirror(session, mirror);
}
// Load Oculus required buffers: texture-swap-chain, fbo, texture-depth
static OculusBuffer LoadOculusBuffer(ovrSession session, int width, int height)
{
OculusBuffer buffer;
buffer.width = width;
buffer.height = height;
// Create OVR texture chain
ovrTextureSwapChainDesc desc = {};
desc.Type = ovrTexture_2D;
desc.ArraySize = 1;
desc.Width = width;
desc.Height = height;
desc.MipLevels = 1;
desc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB; // Requires glEnable(GL_FRAMEBUFFER_SRGB);
desc.SampleCount = 1;
desc.StaticImage = ovrFalse;
ovrResult result = ovr_CreateTextureSwapChainGL(session, &desc, &buffer.textureChain);
if (!OVR_SUCCESS(result)) TraceLog(WARNING, "OVR: Failed to create swap textures buffer");
int textureCount = 0;
ovr_GetTextureSwapChainLength(session, buffer.textureChain, &textureCount);
if (!OVR_SUCCESS(result) || !textureCount) TraceLog(WARNING, "OVR: Unable to count swap chain textures");
for (int i = 0; i < textureCount; ++i)
{
GLuint chainTexId;
ovr_GetTextureSwapChainBufferGL(session, buffer.textureChain, i, &chainTexId);
glBindTexture(GL_TEXTURE_2D, chainTexId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
glBindTexture(GL_TEXTURE_2D, 0);
/*
// Setup framebuffer object (using depth texture)
glGenFramebuffers(1, &buffer.fboId);
glGenTextures(1, &buffer.depthId);
glBindTexture(GL_TEXTURE_2D, buffer.depthId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, buffer.width, buffer.height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
*/
// Setup framebuffer object (using depth renderbuffer)
glGenFramebuffers(1, &buffer.fboId);
glGenRenderbuffers(1, &buffer.depthId);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, buffer.fboId);
glBindRenderbuffer(GL_RENDERBUFFER, buffer.depthId);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, buffer.width, buffer.height);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, buffer.depthId);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
return buffer;
}
// Unload texture required buffers
static void UnloadOculusBuffer(ovrSession session, OculusBuffer buffer)
{
if (buffer.textureChain)
{
ovr_DestroyTextureSwapChain(session, buffer.textureChain);
buffer.textureChain = NULL;
}
if (buffer.depthId != 0) glDeleteTextures(1, &buffer.depthId);
if (buffer.fboId != 0) glDeleteFramebuffers(1, &buffer.fboId);
}
// Load Oculus mirror buffers
static OculusMirror LoadOculusMirror(ovrSession session, int width, int height)
{
OculusMirror mirror;
mirror.width = width;
mirror.height = height;
ovrMirrorTextureDesc mirrorDesc;
memset(&mirrorDesc, 0, sizeof(mirrorDesc));
mirrorDesc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
mirrorDesc.Width = mirror.width;
mirrorDesc.Height = mirror.height;
if (!OVR_SUCCESS(ovr_CreateMirrorTextureGL(session, &mirrorDesc, &mirror.texture))) TraceLog(WARNING, "Could not create mirror texture");
glGenFramebuffers(1, &mirror.fboId);
return mirror;
}
// Unload Oculus mirror buffers
static void UnloadOculusMirror(ovrSession session, OculusMirror mirror)
{
if (mirror.fboId != 0) glDeleteFramebuffers(1, &mirror.fboId);
if (mirror.texture) ovr_DestroyMirrorTexture(session, mirror.texture);
}
// Copy Oculus screen buffer to mirror texture
static void BlitOculusMirror(ovrSession session, OculusMirror mirror)
{
GLuint mirrorTextureId;
ovr_GetMirrorTextureBufferGL(session, mirror.texture, &mirrorTextureId);
glBindFramebuffer(GL_READ_FRAMEBUFFER, mirror.fboId);
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mirrorTextureId, 0);
#if defined(GRAPHICS_API_OPENGL_33)
// NOTE: glBlitFramebuffer() requires extension: GL_EXT_framebuffer_blit (not available in OpenGL ES 2.0)
glBlitFramebuffer(0, 0, mirror.width, mirror.height, 0, mirror.height, mirror.width, 0, GL_COLOR_BUFFER_BIT, GL_NEAREST);
#endif
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
}
// Init Oculus layer (similar to photoshop)
static OculusLayer InitOculusLayer(ovrSession session)
{
OculusLayer layer = { 0 };
layer.viewScaleDesc.HmdSpaceToWorldScaleInMeters = 1.0f;
memset(&layer.eyeLayer, 0, sizeof(ovrLayerEyeFov));
layer.eyeLayer.Header.Type = ovrLayerType_EyeFov;
layer.eyeLayer.Header.Flags = ovrLayerFlag_TextureOriginAtBottomLeft;
ovrEyeRenderDesc eyeRenderDescs[2];
for (int eye = 0; eye < 2; eye++)
{
eyeRenderDescs[eye] = ovr_GetRenderDesc(session, eye, hmdDesc.DefaultEyeFov[eye]);
ovrMatrix4f ovrPerspectiveProjection = ovrMatrix4f_Projection(eyeRenderDescs[eye].Fov, 0.01f, 10000.0f, ovrProjection_None); //ovrProjection_ClipRangeOpenGL);
layer.eyeProjections[eye] = FromOvrMatrix(ovrPerspectiveProjection); // NOTE: struct ovrMatrix4f { float M[4][4] } --> struct Matrix
layer.viewScaleDesc.HmdToEyeOffset[eye] = eyeRenderDescs[eye].HmdToEyeOffset;
layer.eyeLayer.Fov[eye] = eyeRenderDescs[eye].Fov;
ovrSizei eyeSize = ovr_GetFovTextureSize(session, eye, layer.eyeLayer.Fov[eye], 1.0f);
layer.eyeLayer.Viewport[eye].Size = eyeSize;
layer.eyeLayer.Viewport[eye].Pos.x = layer.width;
layer.eyeLayer.Viewport[eye].Pos.y = 0;
layer.height = eyeSize.h; //std::max(renderTargetSize.y, (uint32_t)eyeSize.h);
layer.width += eyeSize.w;
}
return layer;
}
// Convert from Oculus ovrMatrix4f struct to raymath Matrix struct
static Matrix FromOvrMatrix(ovrMatrix4f ovrmat)
{
Matrix rmat;
rmat.m0 = ovrmat.M[0][0];
rmat.m1 = ovrmat.M[1][0];
rmat.m2 = ovrmat.M[2][0];
rmat.m3 = ovrmat.M[3][0];
rmat.m4 = ovrmat.M[0][1];
rmat.m5 = ovrmat.M[1][1];
rmat.m6 = ovrmat.M[2][1];
rmat.m7 = ovrmat.M[3][1];
rmat.m8 = ovrmat.M[0][2];
rmat.m9 = ovrmat.M[1][2];
rmat.m10 = ovrmat.M[2][2];
rmat.m11 = ovrmat.M[3][2];
rmat.m12 = ovrmat.M[0][3];
rmat.m13 = ovrmat.M[1][3];
rmat.m14 = ovrmat.M[2][3];
rmat.m15 = ovrmat.M[3][3];
MatrixTranspose(&rmat);
return rmat;
}
#endif
#if defined(RLGL_STANDALONE) #if defined(RLGL_STANDALONE)
// Output a trace log message // Output a trace log message
// NOTE: Expected msgType: (0)Info, (1)Error, (2)Warning // NOTE: Expected msgType: (0)Info, (1)Error, (2)Warning

View File

@ -2,8 +2,8 @@
* *
* rlgl - raylib OpenGL abstraction layer * rlgl - raylib OpenGL abstraction layer
* *
* rlgl allows usage of OpenGL 1.1 style functions (rlVertex) that are internally mapped to * rlgl is a wrapper for multiple OpenGL versions (1.1, 2.1, 3.3 Core, ES 2.0) to
* selected OpenGL version (1.1, 2.1, 3.3 Core, ES 2.0). * pseudo-OpenGL 1.1 style functions (rlVertex, rlTranslate, rlRotate...).
* *
* When chosing an OpenGL version greater than OpenGL 1.1, rlgl stores vertex data on internal * When chosing an OpenGL version greater than OpenGL 1.1, rlgl stores vertex data on internal
* VBO buffers (and VAOs if available). It requires calling 3 functions: * VBO buffers (and VAOs if available). It requires calling 3 functions:
@ -11,18 +11,29 @@
* rlglDraw() - Process internal buffers and send required draw calls * rlglDraw() - Process internal buffers and send required draw calls
* rlglClose() - De-initialize internal buffers data and other auxiliar resources * rlglClose() - De-initialize internal buffers data and other auxiliar resources
* *
* External libs: * CONFIGURATION:
*
* #define GRAPHICS_API_OPENGL_11
* #define GRAPHICS_API_OPENGL_21
* #define GRAPHICS_API_OPENGL_33
* #define GRAPHICS_API_OPENGL_ES2
* Use selected OpenGL backend
*
* #define RLGL_STANDALONE
* Use rlgl as standalone library (no raylib dependency)
*
* #define SUPPORT_VR_SIMULATION / SUPPORT_STEREO_RENDERING
* Support VR simulation functionality (stereo rendering)
*
* #define SUPPORT_SHADER_DISTORTION
* Include stereo rendering distortion shader (shader_distortion.h)
*
* DEPENDENCIES:
* raymath - 3D math functionality (Vector3, Matrix, Quaternion) * raymath - 3D math functionality (Vector3, Matrix, Quaternion)
* GLAD - OpenGL extensions loading (OpenGL 3.3 Core only) * GLAD - OpenGL extensions loading (OpenGL 3.3 Core only)
* *
* Module Configuration Flags:
* GRAPHICS_API_OPENGL_11 - Use OpenGL 1.1 backend
* GRAPHICS_API_OPENGL_21 - Use OpenGL 2.1 backend
* GRAPHICS_API_OPENGL_33 - Use OpenGL 3.3 Core profile backend
* GRAPHICS_API_OPENGL_ES2 - Use OpenGL ES 2.0 backend
*
* RLGL_STANDALONE - Use rlgl as standalone library (no raylib dependency)
* *
* LICENSE: zlib/libpng
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
* *
@ -124,15 +135,21 @@
#define RL_WRAP_CLAMP 0x812F // GL_CLAMP_TO_EDGE #define RL_WRAP_CLAMP 0x812F // GL_CLAMP_TO_EDGE
#define RL_WRAP_CLAMP_MIRROR 0x8742 // GL_MIRROR_CLAMP_EXT #define RL_WRAP_CLAMP_MIRROR 0x8742 // GL_MIRROR_CLAMP_EXT
// Matrix modes (equivalent to OpenGL)
#define RL_MODELVIEW 0x1700 // GL_MODELVIEW
#define RL_PROJECTION 0x1701 // GL_PROJECTION
#define RL_TEXTURE 0x1702 // GL_TEXTURE
// Primitive assembly draw modes
#define RL_LINES 0x0001 // GL_LINES
#define RL_TRIANGLES 0x0004 // GL_TRIANGLES
#define RL_QUADS 0x0007 // GL_QUADS
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
typedef enum { OPENGL_11 = 1, OPENGL_21, OPENGL_33, OPENGL_ES_20 } GlVersion; typedef enum { OPENGL_11 = 1, OPENGL_21, OPENGL_33, OPENGL_ES_20 } GlVersion;
typedef enum { RL_PROJECTION, RL_MODELVIEW, RL_TEXTURE } MatrixMode;
typedef enum { RL_LINES, RL_TRIANGLES, RL_QUADS } DrawMode;
typedef unsigned char byte; typedef unsigned char byte;
#if defined(RLGL_STANDALONE) #if defined(RLGL_STANDALONE)
@ -399,19 +416,12 @@ void EndBlendMode(void); // End blend
void TraceLog(int msgType, const char *text, ...); void TraceLog(int msgType, const char *text, ...);
float *MatrixToFloat(Matrix mat); float *MatrixToFloat(Matrix mat);
void InitVrDevice(int vrDevice); // Init VR device void InitVrSimulator(int vrDevice); // Init VR simulator for selected device
void CloseVrDevice(void); // Close VR device void CloseVrSimulator(void); // Close VR simulator for current device
bool IsVrDeviceReady(void); // Detect if VR device is ready
bool IsVrSimulator(void); // Detect if VR simulator is running
void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator) void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator)
void BeginVrDrawing(void); // Begin VR stereo rendering
// Oculus Rift API for direct access the device (no simulator) void EndVrDrawing(void); // End VR stereo rendering
bool InitOculusDevice(void); // Initialize Oculus device (returns true if success)
void CloseOculusDevice(void); // Close Oculus device
void UpdateOculusTracking(Camera *camera); // Update Oculus head position-orientation tracking (and camera)
void BeginOculusDrawing(void); // Setup Oculus buffers for drawing
void EndOculusDrawing(void); // Finish Oculus drawing and blit framebuffer to mirror
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1,8 +1,6 @@
/********************************************************************************************** /**********************************************************************************************
* *
* rres - raylib Resource custom format management functions * rres v1.0 - raylib resource (rRES) custom fileformat management functions
*
* Basic functions to load/save rRES resource files
* *
* CONFIGURATION: * CONFIGURATION:
* *

View File

@ -13,7 +13,7 @@
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -57,7 +57,7 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module specific Functions Declaration // Module specific Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// No private (static) functions in this module (.c file) static float EaseCubicInOut(float t, float b, float c, float d); // Cubic easing
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Definition // Module Functions Definition
@ -106,6 +106,13 @@ void DrawLineV(Vector2 startPos, Vector2 endPos, Color color)
// Draw a line defining thickness // Draw a line defining thickness
void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color) void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color)
{ {
if (startPos.x > endPos.x)
{
Vector2 tempPos = startPos;
startPos = endPos;
endPos = tempPos;
}
float dx = endPos.x - startPos.x; float dx = endPos.x - startPos.x;
float dy = endPos.y - startPos.y; float dy = endPos.y - startPos.y;
@ -133,6 +140,27 @@ void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color)
rlDisableTexture(); rlDisableTexture();
} }
// Draw line using cubic-bezier curves in-out
void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color)
{
#define LINE_DIVISIONS 24 // Bezier line divisions
Vector2 previous = startPos;
Vector2 current;
for (int i = 1; i <= LINE_DIVISIONS; i++)
{
// Cubic easing in-out
// NOTE: Easing is calcutated only for y position value
current.y = EaseCubicInOut(i, startPos.y, endPos.y - startPos.y, LINE_DIVISIONS);
current.x = previous.x + (endPos.x - startPos.x)/LINE_DIVISIONS;
DrawLineEx(previous, current, thick, color);
previous = current;
}
}
// Draw a color-filled circle // Draw a color-filled circle
void DrawCircle(int centerX, int centerY, float radius, Color color) void DrawCircle(int centerX, int centerY, float radius, Color color)
{ {
@ -590,3 +618,15 @@ Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2)
return retRec; return retRec;
} }
//----------------------------------------------------------------------------------
// Module specific Functions Definition
//----------------------------------------------------------------------------------
// Cubic easing in-out
// NOTE: Required for DrawLineBezier()
static float EaseCubicInOut(float t, float b, float c, float d)
{
if ((t/=d/2) < 1) return (c/2*t*t*t + b);
return (c/2*((t-=2)*t*t + 2) + b);
}

View File

@ -5,12 +5,11 @@
* CONFIGURATION: * CONFIGURATION:
* *
* #define SUPPORT_FILEFORMAT_FNT * #define SUPPORT_FILEFORMAT_FNT
* #define SUPPORT_FILEFORMAT_TTF / INCLUDE_STB_TRUETYPE * #define SUPPORT_FILEFORMAT_TTF
* #define SUPPORT_FILEFORMAT_IMAGE_FONT
* Selected desired fileformats to be supported for loading. Some of those formats are * Selected desired fileformats to be supported for loading. Some of those formats are
* supported by default, to remove support, just comment unrequired #define in this module * supported by default, to remove support, just comment unrequired #define in this module
* *
* #define INCLUDE_DEFAULT_FONT / SUPPORT_DEFAULT_FONT * #define SUPPORT_DEFAULT_FONT
* *
* DEPENDENCIES: * DEPENDENCIES:
* stb_truetype - Load TTF file and rasterize characters data * stb_truetype - Load TTF file and rasterize characters data
@ -18,7 +17,7 @@
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -37,6 +36,11 @@
* *
**********************************************************************************************/ **********************************************************************************************/
// Default supported features
//-------------------------------------
#define SUPPORT_DEFAULT_FONT
//-------------------------------------
#include "raylib.h" #include "raylib.h"
#include <stdlib.h> // Required for: malloc(), free() #include <stdlib.h> // Required for: malloc(), free()
@ -46,10 +50,12 @@
#include "utils.h" // Required for: GetExtension() #include "utils.h" // Required for: GetExtension()
// Following libs are used on LoadTTF() #if defined(SUPPORT_FILEFORMAT_TTF)
#define STBTT_STATIC // Define stb_truetype functions static to this module // Following libs are used on LoadTTF()
#define STB_TRUETYPE_IMPLEMENTATION #define STBTT_STATIC // Define stb_truetype functions static to this module
#include "external/stb_truetype.h" // Required for: stbtt_BakeFontBitmap() #define STB_TRUETYPE_IMPLEMENTATION
#include "external/stb_truetype.h" // Required for: stbtt_BakeFontBitmap()
#endif
// Rectangle packing functions (not used at the moment) // Rectangle packing functions (not used at the moment)
//#define STB_RECT_PACK_IMPLEMENTATION //#define STB_RECT_PACK_IMPLEMENTATION
@ -61,8 +67,6 @@
#define MAX_FORMATTEXT_LENGTH 64 #define MAX_FORMATTEXT_LENGTH 64
#define MAX_SUBTEXT_LENGTH 64 #define MAX_SUBTEXT_LENGTH 64
#define BIT_CHECK(a,b) ((a) & (1 << (b)))
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -71,8 +75,10 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global variables // Global variables
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_DEFAULT_FONT)
static SpriteFont defaultFont; // Default font provided by raylib static SpriteFont defaultFont; // Default font provided by raylib
// NOTE: defaultFont is loaded on InitWindow and disposed on CloseWindow [module: core] // NOTE: defaultFont is loaded on InitWindow and disposed on CloseWindow [module: core]
#endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Other Modules Functions Declaration (required by text) // Other Modules Functions Declaration (required by text)
@ -86,17 +92,28 @@ static int GetCharIndex(SpriteFont font, int letter);
static SpriteFont LoadImageFont(Image image, Color key, int firstChar); // Load a Image font file (XNA style) static SpriteFont LoadImageFont(Image image, Color key, int firstChar); // Load a Image font file (XNA style)
static SpriteFont LoadRBMF(const char *fileName); // Load a rBMF font file (raylib BitMap Font) static SpriteFont LoadRBMF(const char *fileName); // Load a rBMF font file (raylib BitMap Font)
#if defined(SUPPORT_FILEFORMAT_FNT)
static SpriteFont LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file) static SpriteFont LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file)
#endif
#if defined(SUPPORT_FILEFORMAT_TTF)
static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load spritefont from TTF data static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load spritefont from TTF data
#endif
#if defined(SUPPORT_DEFAULT_FONT)
extern void LoadDefaultFont(void); extern void LoadDefaultFont(void);
extern void UnloadDefaultFont(void); extern void UnloadDefaultFont(void);
#endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Definition // Module Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_DEFAULT_FONT)
// Load raylib default font
extern void LoadDefaultFont(void) extern void LoadDefaultFont(void)
{ {
#define BIT_CHECK(a,b) ((a) & (1 << (b)))
// NOTE: Using UTF8 encoding table for Unicode U+0000..U+00FF Basic Latin + Latin-1 Supplement // NOTE: Using UTF8 encoding table for Unicode U+0000..U+00FF Basic Latin + Latin-1 Supplement
// http://www.utf8-chartable.de/unicode-utf8-table.pl // http://www.utf8-chartable.de/unicode-utf8-table.pl
@ -241,16 +258,23 @@ extern void LoadDefaultFont(void)
TraceLog(INFO, "[TEX ID %i] Default font loaded successfully", defaultFont.texture.id); TraceLog(INFO, "[TEX ID %i] Default font loaded successfully", defaultFont.texture.id);
} }
// Unload raylib default font
extern void UnloadDefaultFont(void) extern void UnloadDefaultFont(void)
{ {
UnloadTexture(defaultFont.texture); UnloadTexture(defaultFont.texture);
free(defaultFont.chars); free(defaultFont.chars);
} }
#endif // SUPPORT_DEFAULT_FONT
// Get the default font, useful to be used with extended parameters // Get the default font, useful to be used with extended parameters
SpriteFont GetDefaultFont() SpriteFont GetDefaultFont()
{ {
#if defined(SUPPORT_DEFAULT_FONT)
return defaultFont; return defaultFont;
#else
SpriteFont font = { 0 };
return font;
#endif
} }
// Load SpriteFont from file into GPU memory (VRAM) // Load SpriteFont from file into GPU memory (VRAM)
@ -265,8 +289,12 @@ SpriteFont LoadSpriteFont(const char *fileName)
// Check file extension // Check file extension
if (strcmp(GetExtension(fileName),"rbmf") == 0) spriteFont = LoadRBMF(fileName); // TODO: DELETE... SOON... if (strcmp(GetExtension(fileName),"rbmf") == 0) spriteFont = LoadRBMF(fileName); // TODO: DELETE... SOON...
#if defined(SUPPORT_FILEFORMAT_TTF)
else if (strcmp(GetExtension(fileName),"ttf") == 0) spriteFont = LoadSpriteFontTTF(fileName, DEFAULT_TTF_FONTSIZE, 0, NULL); else if (strcmp(GetExtension(fileName),"ttf") == 0) spriteFont = LoadSpriteFontTTF(fileName, DEFAULT_TTF_FONTSIZE, 0, NULL);
#endif
#if defined(SUPPORT_FILEFORMAT_FNT)
else if (strcmp(GetExtension(fileName),"fnt") == 0) spriteFont = LoadBMFont(fileName); else if (strcmp(GetExtension(fileName),"fnt") == 0) spriteFont = LoadBMFont(fileName);
#endif
else if (strcmp(GetExtension(fileName),"rres") == 0) else if (strcmp(GetExtension(fileName),"rres") == 0)
{ {
// TODO: Read multiple resource blocks from file (RRES_FONT_IMAGE, RRES_FONT_CHARDATA) // TODO: Read multiple resource blocks from file (RRES_FONT_IMAGE, RRES_FONT_CHARDATA)
@ -317,6 +345,7 @@ SpriteFont LoadSpriteFontTTF(const char *fileName, int fontSize, int charsCount,
{ {
SpriteFont spriteFont = { 0 }; SpriteFont spriteFont = { 0 };
#if defined(SUPPORT_FILEFORMAT_TTF)
if (strcmp(GetExtension(fileName),"ttf") == 0) if (strcmp(GetExtension(fileName),"ttf") == 0)
{ {
if ((fontChars == NULL) || (charsCount == 0)) if ((fontChars == NULL) || (charsCount == 0))
@ -331,6 +360,7 @@ SpriteFont LoadSpriteFontTTF(const char *fileName, int fontSize, int charsCount,
} }
else spriteFont = LoadTTF(fileName, fontSize, charsCount, fontChars); else spriteFont = LoadTTF(fileName, fontSize, charsCount, fontChars);
} }
#endif
if (spriteFont.texture.id == 0) if (spriteFont.texture.id == 0)
{ {
@ -345,7 +375,7 @@ SpriteFont LoadSpriteFontTTF(const char *fileName, int fontSize, int charsCount,
void UnloadSpriteFont(SpriteFont spriteFont) void UnloadSpriteFont(SpriteFont spriteFont)
{ {
// NOTE: Make sure spriteFont is not default font (fallback) // NOTE: Make sure spriteFont is not default font (fallback)
if (spriteFont.texture.id != defaultFont.texture.id) if (spriteFont.texture.id != GetDefaultFont().texture.id)
{ {
UnloadTexture(spriteFont.texture); UnloadTexture(spriteFont.texture);
free(spriteFont.chars); free(spriteFont.chars);
@ -360,7 +390,7 @@ void UnloadSpriteFont(SpriteFont spriteFont)
void DrawText(const char *text, int posX, int posY, int fontSize, Color color) void DrawText(const char *text, int posX, int posY, int fontSize, Color color)
{ {
// Check if default font has been loaded // Check if default font has been loaded
if (defaultFont.texture.id != 0) if (GetDefaultFont().texture.id != 0)
{ {
Vector2 position = { (float)posX, (float)posY }; Vector2 position = { (float)posX, (float)posY };
@ -471,7 +501,7 @@ int MeasureText(const char *text, int fontSize)
Vector2 vec = { 0.0f, 0.0f }; Vector2 vec = { 0.0f, 0.0f };
// Check if default font has been loaded // Check if default font has been loaded
if (defaultFont.texture.id != 0) if (GetDefaultFont().texture.id != 0)
{ {
int defaultFontSize = 10; // Default Font chars height in pixel int defaultFontSize = 10; // Default Font chars height in pixel
if (fontSize < defaultFontSize) fontSize = defaultFontSize; if (fontSize < defaultFontSize) fontSize = defaultFontSize;
@ -826,6 +856,7 @@ static SpriteFont LoadRBMF(const char *fileName)
return spriteFont; return spriteFont;
} }
#if defined(SUPPORT_FILEFORMAT_FNT)
// Load a BMFont file (AngelCode font file) // Load a BMFont file (AngelCode font file)
static SpriteFont LoadBMFont(const char *fileName) static SpriteFont LoadBMFont(const char *fileName)
{ {
@ -943,7 +974,9 @@ static SpriteFont LoadBMFont(const char *fileName)
return font; return font;
} }
#endif
#if defined(SUPPORT_FILEFORMAT_TTF)
// Generate a sprite font from TTF file data (font size required) // Generate a sprite font from TTF file data (font size required)
// TODO: Review texture packing method and generation (use oversampling) // TODO: Review texture packing method and generation (use oversampling)
static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, int *fontChars) static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, int *fontChars)
@ -1035,4 +1068,5 @@ static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, in
free(charData); free(charData);
return font; return font;
} }
#endif

View File

@ -4,24 +4,24 @@
* *
* CONFIGURATION: * CONFIGURATION:
* *
* #define SUPPORT_STB_IMAGE / INCLUDE_STB_IMAGE * #define SUPPORT_FILEFORMAT_BMP
* * #define SUPPORT_FILEFORMAT_PNG
* #define SUPPORT_FILEFORMAT_BMP / SUPPORT_LOAD_BMP
* #define SUPPORT_FILEFORMAT_PNG / SUPPORT_LOAD_PNG
* #define SUPPORT_FILEFORMAT_TGA * #define SUPPORT_FILEFORMAT_TGA
* #define SUPPORT_FILEFORMAT_JPG / ENABLE_LOAD_JPG * #define SUPPORT_FILEFORMAT_JPG
* #define SUPPORT_FILEFORMAT_GIF * #define SUPPORT_FILEFORMAT_GIF
* #define SUPPORT_FILEFORMAT_PSD
* #define SUPPORT_FILEFORMAT_HDR * #define SUPPORT_FILEFORMAT_HDR
* #define SUPPORT_FILEFORMAT_DDS / ENABLE_LOAD_DDS * #define SUPPORT_FILEFORMAT_DDS
* #define SUPPORT_FILEFORMAT_PKM * #define SUPPORT_FILEFORMAT_PKM
* #define SUPPORT_FILEFORMAT_KTX * #define SUPPORT_FILEFORMAT_KTX
* #define SUPPORT_FILEFORMAT_PVR * #define SUPPORT_FILEFORMAT_PVR
* #define SUPPORT_FILEFORMAT_ASTC * #define SUPPORT_FILEFORMAT_ASTC
* Selected desired fileformats to be supported for loading. Some of those formats are * Selecte desired fileformats to be supported for image data loading. Some of those formats are
* supported by default, to remove support, just comment unrequired #define in this module * supported by default, to remove support, just comment unrequired #define in this module
* *
* #define SUPPORT_IMAGE_RESIZE / INCLUDE_STB_IMAGE_RESIZE
* #define SUPPORT_IMAGE_MANIPULATION * #define 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()
* *
* DEPENDENCIES: * DEPENDENCIES:
* stb_image - Multiple image formats loading (JPEG, PNG, BMP, TGA, PSD, GIF, PIC) * stb_image - Multiple image formats loading (JPEG, PNG, BMP, TGA, PSD, GIF, PIC)
@ -31,7 +31,7 @@
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -50,6 +50,12 @@
* *
**********************************************************************************************/ **********************************************************************************************/
// Default configuration flags (supported features)
//-------------------------------------------------
#define SUPPORT_FILEFORMAT_PNG
#define SUPPORT_IMAGE_MANIPULATION
//-------------------------------------------------
#include "raylib.h" #include "raylib.h"
#include <stdlib.h> // Required for: malloc(), free() #include <stdlib.h> // Required for: malloc(), free()
@ -61,23 +67,46 @@
#include "utils.h" // Required for: fopen() Android mapping, TraceLog() #include "utils.h" // Required for: fopen() Android mapping, TraceLog()
// Support only desired texture formats, by default: JPEG, PNG, BMP, TGA // Support only desired texture formats on stb_image
//#define STBI_NO_JPEG // Image format .jpg and .jpeg #if !defined(SUPPORT_FILEFORMAT_BMP)
//#define STBI_NO_PNG #define STBI_NO_BMP
//#define STBI_NO_BMP #endif
//#define STBI_NO_TGA #if !defined(SUPPORT_FILEFORMAT_PNG)
#define STBI_NO_PSD #define STBI_NO_PNG
#define STBI_NO_GIF #endif
#define STBI_NO_HDR #if !defined(SUPPORT_FILEFORMAT_TGA)
#define STBI_NO_TGA
#endif
#if !defined(SUPPORT_FILEFORMAT_JPG)
#define STBI_NO_JPEG // Image format .jpg and .jpeg
#endif
#if !defined(SUPPORT_FILEFORMAT_PSD)
#define STBI_NO_PSD
#endif
#if !defined(SUPPORT_FILEFORMAT_GIF)
#define STBI_NO_GIF
#endif
#if !defined(SUPPORT_FILEFORMAT_HDR)
#define STBI_NO_HDR
#endif
// Image fileformats not supported by default
#define STBI_NO_PIC #define STBI_NO_PIC
#define STBI_NO_PNM // Image format .ppm and .pgm #define STBI_NO_PNM // Image format .ppm and .pgm
#define STB_IMAGE_IMPLEMENTATION
#include "external/stb_image.h" // Required for: stbi_load()
// NOTE: Used to read image data (multiple formats support)
#define STB_IMAGE_RESIZE_IMPLEMENTATION #if (defined(SUPPORT_FILEFORMAT_BMP) || defined(SUPPORT_FILEFORMAT_PNG) || defined(SUPPORT_FILEFORMAT_TGA) || \
#include "external/stb_image_resize.h" // Required for: stbir_resize_uint8() defined(SUPPORT_FILEFORMAT_JPG) || defined(SUPPORT_FILEFORMAT_PSD) || defined(SUPPORT_FILEFORMAT_GIF) || \
// NOTE: Used for image scaling on ImageResize() defined(SUPPORT_FILEFORMAT_HDR))
#define STB_IMAGE_IMPLEMENTATION
#include "external/stb_image.h" // Required for: stbi_load()
// NOTE: Used to read image data (multiple formats support)
#endif
#if defined(SUPPORT_IMAGE_MANIPULATION)
#define STB_IMAGE_RESIZE_IMPLEMENTATION
#include "external/stb_image_resize.h" // Required for: stbir_resize_uint8()
// NOTE: Used for image scaling on ImageResize()
#endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Defines and Macros // Defines and Macros
@ -102,11 +131,21 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module specific Functions Declaration // Module specific Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_DDS)
static Image LoadDDS(const char *fileName); // Load DDS file static Image LoadDDS(const char *fileName); // Load DDS file
#endif
#if defined(SUPPORT_FILEFORMAT_PKM)
static Image LoadPKM(const char *fileName); // Load PKM file static Image LoadPKM(const char *fileName); // Load PKM file
#endif
#if defined(SUPPORT_FILEFORMAT_KTX)
static Image LoadKTX(const char *fileName); // Load KTX file static Image LoadKTX(const char *fileName); // Load KTX file
#endif
#if defined(SUPPORT_FILEFORMAT_PVR)
static Image LoadPVR(const char *fileName); // Load PVR file static Image LoadPVR(const char *fileName); // Load PVR file
#endif
#if defined(SUPPORT_FILEFORMAT_ASTC)
static Image LoadASTC(const char *fileName); // Load ASTC file static Image LoadASTC(const char *fileName); // Load ASTC file
#endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Definition // Module Functions Definition
@ -124,18 +163,21 @@ Image LoadImage(const char *fileName)
image.mipmaps = 0; image.mipmaps = 0;
image.format = 0; image.format = 0;
if ((strcmp(GetExtension(fileName),"png") == 0) || if ((strcmp(GetExtension(fileName),"png") == 0)
(strcmp(GetExtension(fileName),"bmp") == 0) || #if defined(SUPPORT_FILEFORMAT_BMP)
(strcmp(GetExtension(fileName),"tga") == 0) || || (strcmp(GetExtension(fileName),"bmp") == 0)
(strcmp(GetExtension(fileName),"jpg") == 0) #endif
#ifndef STBI_NO_GIF #if defined(SUPPORT_FILEFORMAT_TGA)
|| (strcmp(GetExtension(fileName),"tga") == 0)
#endif
#if defined(SUPPORT_FILEFORMAT_JPG)
|| (strcmp(GetExtension(fileName),"jpg") == 0)
#endif
#if defined(SUPPORT_FILEFORMAT_DDS)
|| (strcmp(GetExtension(fileName),"gif") == 0) || (strcmp(GetExtension(fileName),"gif") == 0)
#endif #endif
#ifndef STBI_NO_PSD #if defined(SUPPORT_FILEFORMAT_PSD)
|| (strcmp(GetExtension(fileName),"psd") == 0) || (strcmp(GetExtension(fileName),"psd") == 0)
#endif
#ifndef STBI_NO_PIC
|| (strcmp(GetExtension(fileName),"pic") == 0)
#endif #endif
) )
{ {
@ -155,11 +197,21 @@ Image LoadImage(const char *fileName)
else if (imgBpp == 3) image.format = UNCOMPRESSED_R8G8B8; else if (imgBpp == 3) image.format = UNCOMPRESSED_R8G8B8;
else if (imgBpp == 4) image.format = UNCOMPRESSED_R8G8B8A8; else if (imgBpp == 4) image.format = UNCOMPRESSED_R8G8B8A8;
} }
#if defined(SUPPORT_FILEFORMAT_DDS)
else if (strcmp(GetExtension(fileName),"dds") == 0) image = LoadDDS(fileName); else if (strcmp(GetExtension(fileName),"dds") == 0) image = LoadDDS(fileName);
#endif
#if defined(SUPPORT_FILEFORMAT_PKM)
else if (strcmp(GetExtension(fileName),"pkm") == 0) image = LoadPKM(fileName); else if (strcmp(GetExtension(fileName),"pkm") == 0) image = LoadPKM(fileName);
#endif
#if defined(SUPPORT_FILEFORMAT_KTX)
else if (strcmp(GetExtension(fileName),"ktx") == 0) image = LoadKTX(fileName); else if (strcmp(GetExtension(fileName),"ktx") == 0) image = LoadKTX(fileName);
#endif
#if defined(SUPPORT_FILEFORMAT_PVR)
else if (strcmp(GetExtension(fileName),"pvr") == 0) image = LoadPVR(fileName); else if (strcmp(GetExtension(fileName),"pvr") == 0) image = LoadPVR(fileName);
#endif
#if defined(SUPPORT_FILEFORMAT_ASTC)
else if (strcmp(GetExtension(fileName),"astc") == 0) image = LoadASTC(fileName); else if (strcmp(GetExtension(fileName),"astc") == 0) image = LoadASTC(fileName);
#endif
else if (strcmp(GetExtension(fileName),"rres") == 0) else if (strcmp(GetExtension(fileName),"rres") == 0)
{ {
RRES rres = LoadResource(fileName, 0); RRES rres = LoadResource(fileName, 0);
@ -171,6 +223,7 @@ Image LoadImage(const char *fileName)
UnloadResource(rres); UnloadResource(rres);
} }
else TraceLog("[%s] Image fileformat not supported", fileName);
if (image.data != NULL) TraceLog(INFO, "[%s] Image loaded successfully (%ix%i)", fileName, image.width, image.height); if (image.data != NULL) TraceLog(INFO, "[%s] Image loaded successfully (%ix%i)", fileName, image.width, image.height);
else TraceLog(WARNING, "[%s] Image could not be loaded", fileName); else TraceLog(WARNING, "[%s] Image could not be loaded", fileName);
@ -664,115 +717,6 @@ void ImageAlphaMask(Image *image, Image alphaMask)
} }
} }
// Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
// NOTE: In case selected bpp do not represent an known 16bit format,
// dithered data is stored in the LSB part of the unsigned short
void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
{
if (image->format >= COMPRESSED_DXT1_RGB)
{
TraceLog(WARNING, "Compressed data formats can not be dithered");
return;
}
if ((rBpp+gBpp+bBpp+aBpp) > 16)
{
TraceLog(WARNING, "Unsupported dithering bpps (%ibpp), only 16bpp or lower modes supported", (rBpp+gBpp+bBpp+aBpp));
}
else
{
Color *pixels = GetImageData(*image);
free(image->data); // free old image data
if ((image->format != UNCOMPRESSED_R8G8B8) && (image->format != UNCOMPRESSED_R8G8B8A8))
{
TraceLog(WARNING, "Image format is already 16bpp or lower, dithering could have no effect");
}
// Define new image format, check if desired bpp match internal known format
if ((rBpp == 5) && (gBpp == 6) && (bBpp == 5) && (aBpp == 0)) image->format = UNCOMPRESSED_R5G6B5;
else if ((rBpp == 5) && (gBpp == 5) && (bBpp == 5) && (aBpp == 1)) image->format = UNCOMPRESSED_R5G5B5A1;
else if ((rBpp == 4) && (gBpp == 4) && (bBpp == 4) && (aBpp == 4)) image->format = UNCOMPRESSED_R4G4B4A4;
else
{
image->format = 0;
TraceLog(WARNING, "Unsupported dithered OpenGL internal format: %ibpp (R%iG%iB%iA%i)", (rBpp+gBpp+bBpp+aBpp), rBpp, gBpp, bBpp, aBpp);
}
// NOTE: We will store the dithered data as unsigned short (16bpp)
image->data = (unsigned short *)malloc(image->width*image->height*sizeof(unsigned short));
Color oldPixel = WHITE;
Color newPixel = WHITE;
int rError, gError, bError;
unsigned short rPixel, gPixel, bPixel, aPixel; // Used for 16bit pixel composition
#define MIN(a,b) (((a)<(b))?(a):(b))
for (int y = 0; y < image->height; y++)
{
for (int x = 0; x < image->width; x++)
{
oldPixel = pixels[y*image->width + x];
// NOTE: New pixel obtained by bits truncate, it would be better to round values (check ImageFormat())
newPixel.r = oldPixel.r >> (8 - rBpp); // R bits
newPixel.g = oldPixel.g >> (8 - gBpp); // G bits
newPixel.b = oldPixel.b >> (8 - bBpp); // B bits
newPixel.a = oldPixel.a >> (8 - aBpp); // A bits (not used on dithering)
// NOTE: Error must be computed between new and old pixel but using same number of bits!
// We want to know how much color precision we have lost...
rError = (int)oldPixel.r - (int)(newPixel.r << (8 - rBpp));
gError = (int)oldPixel.g - (int)(newPixel.g << (8 - gBpp));
bError = (int)oldPixel.b - (int)(newPixel.b << (8 - bBpp));
pixels[y*image->width + x] = newPixel;
// NOTE: Some cases are out of the array and should be ignored
if (x < (image->width - 1))
{
pixels[y*image->width + x+1].r = MIN((int)pixels[y*image->width + x+1].r + (int)((float)rError*7.0f/16), 0xff);
pixels[y*image->width + x+1].g = MIN((int)pixels[y*image->width + x+1].g + (int)((float)gError*7.0f/16), 0xff);
pixels[y*image->width + x+1].b = MIN((int)pixels[y*image->width + x+1].b + (int)((float)bError*7.0f/16), 0xff);
}
if ((x > 0) && (y < (image->height - 1)))
{
pixels[(y+1)*image->width + x-1].r = MIN((int)pixels[(y+1)*image->width + x-1].r + (int)((float)rError*3.0f/16), 0xff);
pixels[(y+1)*image->width + x-1].g = MIN((int)pixels[(y+1)*image->width + x-1].g + (int)((float)gError*3.0f/16), 0xff);
pixels[(y+1)*image->width + x-1].b = MIN((int)pixels[(y+1)*image->width + x-1].b + (int)((float)bError*3.0f/16), 0xff);
}
if (y < (image->height - 1))
{
pixels[(y+1)*image->width + x].r = MIN((int)pixels[(y+1)*image->width + x].r + (int)((float)rError*5.0f/16), 0xff);
pixels[(y+1)*image->width + x].g = MIN((int)pixels[(y+1)*image->width + x].g + (int)((float)gError*5.0f/16), 0xff);
pixels[(y+1)*image->width + x].b = MIN((int)pixels[(y+1)*image->width + x].b + (int)((float)bError*5.0f/16), 0xff);
}
if ((x < (image->width - 1)) && (y < (image->height - 1)))
{
pixels[(y+1)*image->width + x+1].r = MIN((int)pixels[(y+1)*image->width + x+1].r + (int)((float)rError*1.0f/16), 0xff);
pixels[(y+1)*image->width + x+1].g = MIN((int)pixels[(y+1)*image->width + x+1].g + (int)((float)gError*1.0f/16), 0xff);
pixels[(y+1)*image->width + x+1].b = MIN((int)pixels[(y+1)*image->width + x+1].b + (int)((float)bError*1.0f/16), 0xff);
}
rPixel = (unsigned short)newPixel.r;
gPixel = (unsigned short)newPixel.g;
bPixel = (unsigned short)newPixel.b;
aPixel = (unsigned short)newPixel.a;
((unsigned short *)image->data)[y*image->width + x] = (rPixel << (gBpp + bBpp + aBpp)) | (gPixel << (bBpp + aBpp)) | (bPixel << aBpp) | aPixel;
}
}
free(pixels);
}
}
// Convert image to POT (power-of-two) // Convert image to POT (power-of-two)
// NOTE: It could be useful on OpenGL ES 2.0 (RPI, HTML5) // NOTE: It could be useful on OpenGL ES 2.0 (RPI, HTML5)
void ImageToPOT(Image *image, Color fillColor) void ImageToPOT(Image *image, Color fillColor)
@ -818,6 +762,7 @@ void ImageToPOT(Image *image, Color fillColor)
} }
} }
#if defined(SUPPORT_IMAGE_MANIPULATION)
// Copy an image to a new image // Copy an image to a new image
Image ImageCopy(Image image) Image ImageCopy(Image image)
{ {
@ -1203,6 +1148,115 @@ void ImageFlipHorizontal(Image *image)
image->data = processed.data; image->data = processed.data;
} }
// Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
// NOTE: In case selected bpp do not represent an known 16bit format,
// dithered data is stored in the LSB part of the unsigned short
void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
{
if (image->format >= COMPRESSED_DXT1_RGB)
{
TraceLog(WARNING, "Compressed data formats can not be dithered");
return;
}
if ((rBpp+gBpp+bBpp+aBpp) > 16)
{
TraceLog(WARNING, "Unsupported dithering bpps (%ibpp), only 16bpp or lower modes supported", (rBpp+gBpp+bBpp+aBpp));
}
else
{
Color *pixels = GetImageData(*image);
free(image->data); // free old image data
if ((image->format != UNCOMPRESSED_R8G8B8) && (image->format != UNCOMPRESSED_R8G8B8A8))
{
TraceLog(WARNING, "Image format is already 16bpp or lower, dithering could have no effect");
}
// Define new image format, check if desired bpp match internal known format
if ((rBpp == 5) && (gBpp == 6) && (bBpp == 5) && (aBpp == 0)) image->format = UNCOMPRESSED_R5G6B5;
else if ((rBpp == 5) && (gBpp == 5) && (bBpp == 5) && (aBpp == 1)) image->format = UNCOMPRESSED_R5G5B5A1;
else if ((rBpp == 4) && (gBpp == 4) && (bBpp == 4) && (aBpp == 4)) image->format = UNCOMPRESSED_R4G4B4A4;
else
{
image->format = 0;
TraceLog(WARNING, "Unsupported dithered OpenGL internal format: %ibpp (R%iG%iB%iA%i)", (rBpp+gBpp+bBpp+aBpp), rBpp, gBpp, bBpp, aBpp);
}
// NOTE: We will store the dithered data as unsigned short (16bpp)
image->data = (unsigned short *)malloc(image->width*image->height*sizeof(unsigned short));
Color oldPixel = WHITE;
Color newPixel = WHITE;
int rError, gError, bError;
unsigned short rPixel, gPixel, bPixel, aPixel; // Used for 16bit pixel composition
#define MIN(a,b) (((a)<(b))?(a):(b))
for (int y = 0; y < image->height; y++)
{
for (int x = 0; x < image->width; x++)
{
oldPixel = pixels[y*image->width + x];
// NOTE: New pixel obtained by bits truncate, it would be better to round values (check ImageFormat())
newPixel.r = oldPixel.r >> (8 - rBpp); // R bits
newPixel.g = oldPixel.g >> (8 - gBpp); // G bits
newPixel.b = oldPixel.b >> (8 - bBpp); // B bits
newPixel.a = oldPixel.a >> (8 - aBpp); // A bits (not used on dithering)
// NOTE: Error must be computed between new and old pixel but using same number of bits!
// We want to know how much color precision we have lost...
rError = (int)oldPixel.r - (int)(newPixel.r << (8 - rBpp));
gError = (int)oldPixel.g - (int)(newPixel.g << (8 - gBpp));
bError = (int)oldPixel.b - (int)(newPixel.b << (8 - bBpp));
pixels[y*image->width + x] = newPixel;
// NOTE: Some cases are out of the array and should be ignored
if (x < (image->width - 1))
{
pixels[y*image->width + x+1].r = MIN((int)pixels[y*image->width + x+1].r + (int)((float)rError*7.0f/16), 0xff);
pixels[y*image->width + x+1].g = MIN((int)pixels[y*image->width + x+1].g + (int)((float)gError*7.0f/16), 0xff);
pixels[y*image->width + x+1].b = MIN((int)pixels[y*image->width + x+1].b + (int)((float)bError*7.0f/16), 0xff);
}
if ((x > 0) && (y < (image->height - 1)))
{
pixels[(y+1)*image->width + x-1].r = MIN((int)pixels[(y+1)*image->width + x-1].r + (int)((float)rError*3.0f/16), 0xff);
pixels[(y+1)*image->width + x-1].g = MIN((int)pixels[(y+1)*image->width + x-1].g + (int)((float)gError*3.0f/16), 0xff);
pixels[(y+1)*image->width + x-1].b = MIN((int)pixels[(y+1)*image->width + x-1].b + (int)((float)bError*3.0f/16), 0xff);
}
if (y < (image->height - 1))
{
pixels[(y+1)*image->width + x].r = MIN((int)pixels[(y+1)*image->width + x].r + (int)((float)rError*5.0f/16), 0xff);
pixels[(y+1)*image->width + x].g = MIN((int)pixels[(y+1)*image->width + x].g + (int)((float)gError*5.0f/16), 0xff);
pixels[(y+1)*image->width + x].b = MIN((int)pixels[(y+1)*image->width + x].b + (int)((float)bError*5.0f/16), 0xff);
}
if ((x < (image->width - 1)) && (y < (image->height - 1)))
{
pixels[(y+1)*image->width + x+1].r = MIN((int)pixels[(y+1)*image->width + x+1].r + (int)((float)rError*1.0f/16), 0xff);
pixels[(y+1)*image->width + x+1].g = MIN((int)pixels[(y+1)*image->width + x+1].g + (int)((float)gError*1.0f/16), 0xff);
pixels[(y+1)*image->width + x+1].b = MIN((int)pixels[(y+1)*image->width + x+1].b + (int)((float)bError*1.0f/16), 0xff);
}
rPixel = (unsigned short)newPixel.r;
gPixel = (unsigned short)newPixel.g;
bPixel = (unsigned short)newPixel.b;
aPixel = (unsigned short)newPixel.a;
((unsigned short *)image->data)[y*image->width + x] = (rPixel << (gBpp + bBpp + aBpp)) | (gPixel << (bBpp + aBpp)) | (bPixel << aBpp) | aPixel;
}
}
free(pixels);
}
}
// Modify image color: tint // Modify image color: tint
void ImageColorTint(Image *image, Color color) void ImageColorTint(Image *image, Color color)
{ {
@ -1359,6 +1413,7 @@ void ImageColorBrightness(Image *image, int brightness)
image->data = processed.data; image->data = processed.data;
} }
#endif // SUPPORT_IMAGE_MANIPULATION
// Generate GPU mipmaps for a texture // Generate GPU mipmaps for a texture
void GenTextureMipmaps(Texture2D *texture) void GenTextureMipmaps(Texture2D *texture)
@ -1547,6 +1602,7 @@ void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, V
// Module specific Functions Definition // Module specific Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_DDS)
// Loading DDS image data (compressed or uncompressed) // Loading DDS image data (compressed or uncompressed)
static Image LoadDDS(const char *fileName) static Image LoadDDS(const char *fileName)
{ {
@ -1744,7 +1800,9 @@ static Image LoadDDS(const char *fileName)
return image; return image;
} }
#endif
#if defined(SUPPORT_FILEFORMAT_PKM)
// Loading PKM image data (ETC1/ETC2 compression) // Loading PKM image data (ETC1/ETC2 compression)
// NOTE: KTX is the standard Khronos Group compression format (ETC1/ETC2, mipmaps) // NOTE: KTX is the standard Khronos Group compression format (ETC1/ETC2, mipmaps)
// PKM is a much simpler file format used mainly to contain a single ETC1/ETC2 compressed image (no mipmaps) // PKM is a much simpler file format used mainly to contain a single ETC1/ETC2 compressed image (no mipmaps)
@ -1836,7 +1894,9 @@ static Image LoadPKM(const char *fileName)
return image; return image;
} }
#endif
#if defined(SUPPORT_FILEFORMAT_KTX)
// Load KTX compressed image data (ETC1/ETC2 compression) // Load KTX compressed image data (ETC1/ETC2 compression)
static Image LoadKTX(const char *fileName) static Image LoadKTX(const char *fileName)
{ {
@ -1929,7 +1989,9 @@ static Image LoadKTX(const char *fileName)
return image; return image;
} }
#endif
#if defined(SUPPORT_FILEFORMAT_PVR)
// Loading PVR image data (uncompressed or PVRT compression) // Loading PVR image data (uncompressed or PVRT compression)
// NOTE: PVR v2 not supported, use PVR v3 instead // NOTE: PVR v2 not supported, use PVR v3 instead
static Image LoadPVR(const char *fileName) static Image LoadPVR(const char *fileName)
@ -2087,7 +2149,9 @@ static Image LoadPVR(const char *fileName)
return image; return image;
} }
#endif
#if defined(SUPPORT_FILEFORMAT_ASTC)
// Load ASTC compressed image data (ASTC compression) // Load ASTC compressed image data (ASTC compression)
static Image LoadASTC(const char *fileName) static Image LoadASTC(const char *fileName)
{ {
@ -2170,3 +2234,4 @@ static Image LoadASTC(const char *fileName)
return image; return image;
} }
#endif

View File

@ -4,22 +4,28 @@
* *
* CONFIGURATION: * CONFIGURATION:
* *
* #define SUPPORT_SAVE_PNG * #define SUPPORT_SAVE_PNG (defined by default)
* Enable saving PNG fileformat * Support saving image data as PNG fileformat
* NOTE: Requires stb_image_write library * NOTE: Requires stb_image_write library
* *
* #define SUPPORT_SAVE_BMP * #define SUPPORT_SAVE_BMP
* Support saving image data as BMP fileformat
* NOTE: Requires stb_image_write library
* *
* #define DO_NOT_TRACE_DEBUG_MSGS * #define SUPPORT_TRACELOG
* Avoid showing DEBUG TraceLog() messages * Show TraceLog() output messages
* NOTE: By default DEBUG traces not shown
*
* #define SUPPORT_TRACELOG_DEBUG
* Show TraceLog() DEBUG messages
* *
* DEPENDENCIES: * DEPENDENCIES:
* stb_image_write - PNG writting functions * stb_image_write - BMP/PNG writting functions
* *
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -129,18 +135,46 @@ void TraceLog(int msgType, const char *text, ...)
} }
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
#if defined(SUPPORT_SAVE_BMP)
// Creates a BMP image file from an array of pixel data // Creates a BMP image file from an array of pixel data
void SaveBMP(const char *fileName, unsigned char *imgData, int width, int height, int compSize) void SaveBMP(const char *fileName, unsigned char *imgData, int width, int height, int compSize)
{ {
stbi_write_bmp(fileName, width, height, compSize, imgData); stbi_write_bmp(fileName, width, height, compSize, imgData);
} }
#endif
#if defined(SUPPORT_SAVE_PNG)
// Creates a PNG image file from an array of pixel data // Creates a PNG image file from an array of pixel data
void SavePNG(const char *fileName, unsigned char *imgData, int width, int height, int compSize) void SavePNG(const char *fileName, unsigned char *imgData, int width, int height, int compSize)
{ {
stbi_write_png(fileName, width, height, compSize, imgData, width*compSize); stbi_write_png(fileName, width, height, compSize, imgData, width*compSize);
} }
#endif #endif
#endif
// Keep track of memory allocated
// NOTE: mallocType defines the type of data allocated
/*
void RecordMalloc(int mallocType, int mallocSize, const char *msg)
{
// TODO: Investigate how to record memory allocation data...
// Maybe creating my own malloc function...
}
*/
bool IsFileExtension(const char *fileName, const char *ext)
{
return (strcmp(GetExtension(fileName), ext) == 0);
}
// Get the extension for a filename
const char *GetExtension(const char *fileName)
{
const char *dot = strrchr(fileName, '.');
if (!dot || dot == fileName) return "";
return (dot + 1);
}
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
// Initialize asset manager from android app // Initialize asset manager from android app
@ -162,24 +196,6 @@ FILE *android_fopen(const char *fileName, const char *mode)
} }
#endif #endif
// Keep track of memory allocated
// NOTE: mallocType defines the type of data allocated
/*
void RecordMalloc(int mallocType, int mallocSize, const char *msg)
{
// TODO: Investigate how to record memory allocation data...
// Maybe creating my own malloc function...
}
*/
// Get the extension for a filename
const char *GetExtension(const char *fileName)
{
const char *dot = strrchr(fileName, '.');
if (!dot || dot == fileName) return "";
return (dot + 1);
}
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module specific Functions Definition // Module specific Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View File

@ -1,10 +1,11 @@
/********************************************************************************************** /**********************************************************************************************
* *
* raylib.utils * raylib.utils - Some common utility functions
* *
* Some utility functions
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * LICENSE: zlib/libpng
*
* Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -33,6 +34,8 @@
#include "rres.h" #include "rres.h"
#define SUPPORT_SAVE_PNG
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Some basic Defines // Some basic Defines
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -61,9 +64,13 @@ void TraceLog(int msgType, const char *text, ...); // Outputs a trace log messa
const char *GetExtension(const char *fileName); // Returns extension of a filename const char *GetExtension(const char *fileName); // Returns extension of a filename
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
#if defined(SUPPORT_SAVE_BMP)
void SaveBMP(const char *fileName, unsigned char *imgData, int width, int height, int compSize); void SaveBMP(const char *fileName, unsigned char *imgData, int width, int height, int compSize);
#endif
#if defined(SUPPORT_SAVE_PNG)
void SavePNG(const char *fileName, unsigned char *imgData, int width, int height, int compSize); void SavePNG(const char *fileName, unsigned char *imgData, int width, int height, int compSize);
#endif #endif
#endif
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
void InitAssetManager(AAssetManager *manager); // Initialize asset manager from android app void InitAssetManager(AAssetManager *manager); // Initialize asset manager from android app

View File

@ -4,7 +4,7 @@
# #
# makefile to compile advance game for desktop platforms, Raspberry Pi and HTML5 (emscripten) # makefile to compile advance game for desktop platforms, Raspberry Pi and HTML5 (emscripten)
# #
# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) # Copyright (c) 2014 Ramon Santamaria (@raysan5)
# #
# This software is provided "as-is", without any express or implied warranty. In no event # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.

View File

@ -8,7 +8,7 @@
* This game has been created using raylib (www.raylib.com) * This game has been created using raylib (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/

View File

@ -4,7 +4,7 @@
* *
* Ending Screen Functions Definitions (Init, Update, Draw, Unload) * Ending Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) * Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Logo Screen Functions Definitions (Init, Update, Draw, Unload) * Logo Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Options Screen Functions Definitions (Init, Update, Draw, Unload) * Options Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Title Screen Functions Definitions (Init, Update, Draw, Unload) * Title Screen Functions Definitions (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
* *
* Screens Functions Declarations (Init, Update, Draw, Unload) * Screens Functions Declarations (Init, Update, Draw, Unload)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.

View File

@ -8,7 +8,7 @@
* This game has been created using raylib v1.2 (www.raylib.com) * This game has been created using raylib v1.2 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/

View File

@ -4,7 +4,7 @@
# #
# makefile to compile basic game for desktop platforms, Raspberry Pi and HTML5 (emscripten) # makefile to compile basic game for desktop platforms, Raspberry Pi and HTML5 (emscripten)
# #
# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) # Copyright (c) 2014 Ramon Santamaria (@raysan5)
# #
# This software is provided "as-is", without any express or implied warranty. In no event # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.

View File

@ -4,7 +4,7 @@
# #
# makefile to compile basic test for desktop platforms, Raspberry Pi and HTML5 (emscripten) # makefile to compile basic test for desktop platforms, Raspberry Pi and HTML5 (emscripten)
# #
# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) # Copyright (c) 2014 Ramon Santamaria (@raysan5)
# #
# This software is provided "as-is", without any express or implied warranty. In no event # This software is provided "as-is", without any express or implied warranty. In no event
# will the authors be held liable for any damages arising from the use of this software. # will the authors be held liable for any damages arising from the use of this software.

Some files were not shown because too many files have changed in this diff Show More