Merge pull request #198 from raysan5/develop

Develop branch integration
This commit is contained in:
Ray 2016-11-24 17:26:07 +01:00 committed by GitHub
commit 17f09cb034
87 changed files with 6682 additions and 3952 deletions

View File

@ -11,21 +11,25 @@ NOTE:
It includes some interesting new features and is a stepping stone towards raylib future. It includes some interesting new features and is a stepping stone towards raylib future.
HUGE changes: HUGE changes:
[rlua] LUA BINDING: Complete raylib LUA binding, all raylib functions ported to LUA plus the +60 code examples. [rlua] LUA BINDING: Complete raylib LUA binding, ALL raylib functions ported to LUA plus the +60 code examples.
[audio] COMPLETE REDESIGN: Improved music support and also raw audio data processing and playing. FLAC support added. [audio] COMPLETE REDESIGN: Improved music support and also raw audio data processing and playing, +20 new functions added.
[physac] COMPLETE REWRITE: Improved performance, functionality and simplified usage, moved to own repository and added multiple examples! [physac] COMPLETE REWRITE: Improved performance, functionality and simplified usage, moved to own repository and added multiple examples!
other changes: Other changes:
[core] Corrected issue on OSX with HighDPI display [core] Corrected issue on OSX with HighDPI display
[core] Added flag to allow resizable window [core] Added flag to allow resizable window
[core] Allow no default font loading [core] Allow no default font loading
[core] Corrected old issue with mouse buttons on web [core] Corrected old issue with mouse buttons on web
[core] Improved gamepad support, unified across platforms [core] Improved gamepad support, unified across platforms
[core] Gamepad id functionality: GetGamepadName(), IsGamepadName()
[core] Gamepad buttons/axis checking functionality:
[core] Reviewed Android key inputs system, unified with desktop [core] Reviewed Android key inputs system, unified with desktop
[rlgl] Redesigned lighting shader system [rlgl] Redesigned lighting shader system
[rlgl] Reviewed UpdateVrTracking() and rlglLoadRenderTexture()
[rlgl] Updated standard shader for better performance [rlgl] Updated standard shader for better performance
[rlgl] Support alpha on framebuffer: rlglLoadRenderTexture()
[rlgl] Reviewed UpdateVrTracking() to update camera
[rlgl] Added IsVrSimulator() to check for VR simulator
[shapes] Corrected issue on DrawPolyEx() [shapes] Corrected issue on DrawPolyEx()
[textures] Simplified supported image formats support [textures] Simplified supported image formats support
[textures] Improved text drawing within an image: ImageDrawText() [textures] Improved text drawing within an image: ImageDrawText()
@ -33,17 +37,18 @@ other changes:
[textures] Support textures filtering: SetTextureFilter() [textures] Support textures filtering: SetTextureFilter()
[textures] Support textures wrap modes: SetTextureWrap() [textures] Support textures wrap modes: SetTextureWrap()
[text] Improved TTF spritefont generation: LoadSpriteFontTTF() [text] Improved TTF spritefont generation: LoadSpriteFontTTF()
[text] Improved AngelCode fonts support [text] Improved AngelCode fonts support (unordered chars)
[text] Reviewed spacing formatting
[text] Added TraceLog info on image spritefont loading [text] Added TraceLog info on image spritefont loading
[text] Improved text measurement: MeasureTextEx() [text] Improved text measurement: MeasureTextEx()
[models] Improved OBJ loading flexibility [models] Improved OBJ loading flexibility
[models] Reviewed functions: DrawLine3D(), DrawCircle3D()
[models] Removed function: ResolveCollisionCubicmap() [models] Removed function: ResolveCollisionCubicmap()
[camera] Redesigned camera system and ported to header-only [camera] Redesigned camera system and ported to header-only
[camera] Removed function: UpdateCameraPlayer()
[gestures] Redesigned gestures module to header-only [gestures] Redesigned gestures module to header-only
[audio] Simplified Music loading and playing system [audio] Simplified Music loading and playing system
[audio] Added trace on audio device closing [audio] Added trace on audio device closing
[audio] Reviewed Wave struct for reter flexivility [audio] Reviewed Wave struct, improved flexibility
[audio] Support sound data update: UpdateSound() [audio] Support sound data update: UpdateSound()
[audio] Added support for FLAC audio loading/streaming [audio] Added support for FLAC audio loading/streaming
[raygui] Removed raygui from raylib repo (moved to own repo) [raygui] Removed raygui from raylib repo (moved to own repo)
@ -52,8 +57,8 @@ other changes:
[build] Support shared/dynamic raylib compilation [build] Support shared/dynamic raylib compilation
[*] Updated LibOVR to SDK version 1.8 [*] Updated LibOVR to SDK version 1.8
[*] Updated games to latest raylib version [*] Updated games to latest raylib version
[*] Improved Android support
[*] Improved examples and added new ones [*] Improved examples and added new ones
[*] Improved Android support
----------------------------------------------- -----------------------------------------------
Release: raylib 1.5.0 (18 July 2016) Release: raylib 1.5.0 (18 July 2016)

View File

@ -160,7 +160,9 @@ On November 2016, only 4 months after raylib 1.5, arrives raylib 1.6. This new v
Complete raylib LUA binding. All raylib functions plus the +60 code examples have been ported to LUA, now LUA users can enjoy coding videogames in LUA while using all the internal power of raylib. This addition also open the doors to LUA scripting support for a future raylib-based engine, being able to move game logic (Init, Update, Draw, De-Init) to LUA scripts while keep using raylib functionality. Complete raylib LUA binding. All raylib functions plus the +60 code examples have been ported to LUA, now LUA users can enjoy coding videogames in LUA while using all the internal power of raylib. This addition also open the doors to LUA scripting support for a future raylib-based engine, being able to move game logic (Init, Update, Draw, De-Init) to LUA scripts while keep using raylib functionality.
Completely redesigned audio module. Based on the new direction taken in raylib 1.5, it has been further improved and more functionality added to allow raw audio processing and playing. FLAC file format support has also been added. In the same line, OpenAL Soft backend is now provided as a static library in Windows to allow static linking and get ride of OpenAL32.dll. Now raylib Windows games are completey self-contained, no external libraries required any more! Completely redesigned audio module. Based on the new direction taken in raylib 1.5, it has been further improved and more functionality added (+20 new functions) to allow raw audio processing and streaming. FLAC file format support has also been added. In the same line, OpenAL Soft backend is now provided as a static library in Windows to allow static linking and get ride of OpenAL32.dll. Now raylib Windows games are completey self-contained, no external libraries required any more!
Physac module has been moved to its own repository and it has been improved A LOT, actually, library has been completely rewritten from scratch by @victorfisac, multiple samples have been added together with countless new features to match current standard 2D physic libraries. Results are amazing!
Camera and gestures modules have been reviewed, highly simplified and ported to single-file header-only libraries for easier portability and usage flexibility. Consequently, camera system usage has been simplified in all examples. Camera and gestures modules have been reviewed, highly simplified and ported to single-file header-only libraries for easier portability and usage flexibility. Consequently, camera system usage has been simplified in all examples.
@ -168,8 +170,6 @@ Improved Gamepad support on Windows and Raspberry Pi with the addition of new fu
Improved textures and text functionality, adding new functions for texture filtering control and better TTF/AngelCode fonts loading and generation support. Improved textures and text functionality, adding new functions for texture filtering control and better TTF/AngelCode fonts loading and generation support.
Physac module has been moved to its own repository and it has been improved A LOT, actually, library has been completely rewritten by @victorfisac, multiple samples have been added and countless new features to match current standard 2D physic libraries.
Build system improvement. Added support for raylib dynamic library generation (raylib.dll) for users that prefer dynamic library linking. Also thinking on advance users, it has been added pre-configured Visual Studio C++ 2015 solution with raylib project and C/C++ examples for users that prefer that professional IDE and compiler. Build system improvement. Added support for raylib dynamic library generation (raylib.dll) for users that prefer dynamic library linking. Also thinking on advance users, it has been added pre-configured Visual Studio C++ 2015 solution with raylib project and C/C++ examples for users that prefer that professional IDE and compiler.
New examples, new functions, complete code-base review, multiple bugs corrected... this is raylib 1.6. Enjoy making games. New examples, new functions, complete code-base review, multiple bugs corrected... this is raylib 1.6. Enjoy making games.

View File

@ -2,6 +2,8 @@
# #
# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) # raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten)
# #
# 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
@ -26,6 +28,9 @@
# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() # WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
PLATFORM ?= PLATFORM_DESKTOP PLATFORM ?= PLATFORM_DESKTOP
# define NO to use OpenAL Soft as static library (shared by default)
SHARED_OPENAL ?= YES
# determine PLATFORM_OS in case PLATFORM_DESKTOP selected # determine PLATFORM_OS in case PLATFORM_DESKTOP selected
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows # No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows
@ -62,12 +67,13 @@ endif
# define compiler flags: # define compiler flags:
# -O2 defines optimization level # -O2 defines optimization level
# -s strip unnecessary data from build
# -Wall turns on most, but not all, compiler warnings # -Wall turns on most, but not all, compiler warnings
# -std=c99 use standard C from 1999 revision # -std=c99 use standard C from 1999 revision
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
CFLAGS = -O2 -Wall -std=gnu99 -fgnu89-inline CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline
else else
CFLAGS = -O2 -Wall -std=c99 CFLAGS = -O2 -s -Wall -std=c99
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
@ -151,7 +157,14 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
else else
# 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 -lopengl32 -lopenal32 -lgdi32 LIBS = -lraylib -lglfw3 -lopengl32 -lgdi32
# if static OpenAL Soft required, define the corresponding libs
ifeq ($(SHARED_OPENAL),NO)
LIBS += -lopenal32 -lwinmm
CFLAGS += -Wl,-allow-multiple-definition
else
LIBS += -lopenal32dll
endif
endif endif
endif endif
endif endif
@ -215,6 +228,8 @@ EXAMPLES = \
text_format_text \ text_format_text \
text_font_select \ text_font_select \
text_writing_anim \ text_writing_anim \
text_ttf_loading \
text_bmfont_unordered \
models_geometric_shapes \ models_geometric_shapes \
models_box_collisions \ models_box_collisions \
models_billboard \ models_billboard \
@ -230,6 +245,11 @@ EXAMPLES = \
audio_music_stream \ audio_music_stream \
audio_module_playing \ audio_module_playing \
audio_raw_stream \ audio_raw_stream \
physics_demo \
physics_friction \
physics_movement \
physics_restitution \
physics_shatter \
fix_dylib \ fix_dylib \
@ -400,6 +420,14 @@ text_font_select: text_font_select.c
text_writing_anim: text_writing_anim.c text_writing_anim: text_writing_anim.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [text] example - text ttf loading
text_ttf_loading: text_ttf_loading.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [text] example - text bmfont unordered
text_bmfont_unordered: text_bmfont_unordered.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [models] example - basic geometric 3d shapes # compile [models] example - basic geometric 3d shapes
models_geometric_shapes: models_geometric_shapes.c models_geometric_shapes: models_geometric_shapes.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
@ -464,6 +492,26 @@ 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)
# compile [physac] example - physics demo
physics_demo: physics_demo.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS)
# compile [physac] example - physics friction
physics_friction: physics_friction.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS)
# compile [physac] example - physics movement
physics_movement: physics_movement.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS)
# compile [physac] example - physics restitution
physics_restitution: physics_restitution.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS)
# compile [physac] example - physics shatter
physics_shatter: physics_shatter.c
$(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

@ -30,6 +30,8 @@ int main()
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X
InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)"); InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)");
InitAudioDevice(); // Initialize audio device InitAudioDevice(); // Initialize audio device
@ -49,13 +51,6 @@ int main()
circles[i].speed = (float)GetRandomValue(1, 100)/20000.0f; circles[i].speed = (float)GetRandomValue(1, 100)/20000.0f;
circles[i].color = colors[GetRandomValue(0, 13)]; circles[i].color = colors[GetRandomValue(0, 13)];
} }
// Load postprocessing bloom shader
Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
"resources/shaders/glsl330/bloom.fs");
// Create a RenderTexture2D to be used for render to texture
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
Music xm = LoadMusicStream("resources/audio/mini1111.xm"); Music xm = LoadMusicStream("resources/audio/mini1111.xm");
@ -117,28 +112,17 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(BLACK); ClearBackground(WHITE);
BeginTextureMode(target); // Enable drawing to texture for (int i = MAX_CIRCLES - 1; i >= 0; i--)
{
for (int i = MAX_CIRCLES - 1; i >= 0; i--) DrawCircleV(circles[i].position, circles[i].radius, Fade(circles[i].color, circles[i].alpha));
{ }
DrawCircleV(circles[i].position, circles[i].radius, Fade(circles[i].color, circles[i].alpha));
}
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
BeginShaderMode(shader);
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE);
EndShaderMode();
// Draw time bar // Draw time bar
DrawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, LIGHTGRAY); DrawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, LIGHTGRAY);
DrawRectangle(20, screenHeight - 20 - 12, (int)timePlayed, 12, MAROON); DrawRectangle(20, screenHeight - 20 - 12, (int)timePlayed, 12, MAROON);
DrawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, WHITE); DrawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, GRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -146,9 +130,6 @@ int main()
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadShader(shader); // Unload shader
UnloadRenderTexture(target); // Unload render texture
UnloadMusicStream(xm); // Unload music stream buffers from RAM UnloadMusicStream(xm); // Unload music stream buffers from RAM
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped) CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)

View File

@ -37,13 +37,6 @@ for i = MAX_CIRCLES, 1, -1 do
circles[i].color = colors[GetRandomValue(1, 14)] circles[i].color = colors[GetRandomValue(1, 14)]
end end
-- Load postprocessing bloom shader
local shader = LoadShader("resources/shaders/glsl330/base.vs",
"resources/shaders/glsl330/bloom.fs")
-- Create a RenderTexture2D to be used for render to texture
local target = LoadRenderTexture(screenWidth, screenHeight)
local xm = LoadMusicStream("resources/audio/mini1111.xm") local xm = LoadMusicStream("resources/audio/mini1111.xm")
PlayMusicStream(xm) PlayMusicStream(xm)
@ -83,22 +76,11 @@ while not WindowShouldClose() do -- Detect window close button or ESC key
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
BeginDrawing() BeginDrawing()
ClearBackground(BLACK) ClearBackground(RAYWHITE)
BeginTextureMode(target) -- Enable drawing to texture for i = MAX_CIRCLES, 1, -1 do
DrawCircleV(circles[i].position, circles[i].radius, Fade(circles[i].color, circles[i].alpha))
for i = MAX_CIRCLES, 1, -1 do end
DrawCircleV(circles[i].position, circles[i].radius, Fade(circles[i].color, circles[i].alpha))
end
EndTextureMode() -- End drawing to texture (now we have a texture available for next passes)
BeginShaderMode(shader)
-- NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
DrawTextureRec(target.texture, Rectangle(0, 0, target.texture.width, -target.texture.height), Vector2(0, 0), WHITE)
EndShaderMode()
-- Draw time bar -- Draw time bar
DrawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, LIGHTGRAY) DrawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, LIGHTGRAY)
@ -111,10 +93,7 @@ end
-- De-Initialization -- De-Initialization
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
UnloadShader(shader) -- Unload shader UnloadMusicStream(xm) -- Unload music stream buffers from RAM
UnloadRenderTexture(target) -- Unload render texture
UnloadMusicStream(xm) -- Unload music stream buffers from RAM
CloseAudioDevice() -- Close audio device (music streaming is automatically stopped) CloseAudioDevice() -- Close audio device (music streaming is automatically stopped)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -32,6 +32,8 @@
int main() int main()
{ {
// Initialization
//--------------------------------------------------------------------------------------
unsigned char key; unsigned char key;
InitAudioDevice(); InitAudioDevice();
@ -43,7 +45,9 @@ int main()
PlayMusicStream(music); PlayMusicStream(music);
printf("\nPress s or d to play sounds...\n"); printf("\nPress s or d to play sounds...\n");
//--------------------------------------------------------------------------------------
// Main loop
while (key != KEY_ESCAPE) while (key != KEY_ESCAPE)
{ {
if (kbhit()) key = getch(); if (kbhit()) key = getch();
@ -63,15 +67,15 @@ int main()
UpdateMusicStream(music); UpdateMusicStream(music);
} }
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadSound(fxWav); // Unload sound data UnloadSound(fxWav); // Unload sound data
UnloadSound(fxOgg); // Unload sound data UnloadSound(fxOgg); // Unload sound data
UnloadMusicStream(music); // Unload music stream data UnloadMusicStream(music); // Unload music stream data
CloseAudioDevice(); CloseAudioDevice();
//--------------------------------------------------------------------------------------
printf("\n\nPress ENTER to close...");
getchar();
return 0; return 0;
} }

View File

@ -19,7 +19,7 @@ local screenHeight = 450
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person") InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person")
-- Define the camera to look into our 3d world (position, target, up vector) -- Define the camera to look into our 3d world (position, target, up vector)
local camera = Camera(Vector3(0.0, 10.0, 10.0), Vector3(0.0, 0.0, 0.0), Vector3(0.0, 1.0, 0.0), 60.0) local camera = Camera(Vector3(4.0, 2.0, 4.0), Vector3(0.0, 1.8, 0.0), Vector3(0.0, 1.0, 0.0), 60.0)
-- Generates some random columns -- Generates some random columns
local heights = {} local heights = {}
@ -34,17 +34,16 @@ end
local playerPosition = Vector3(4.0, 2.0, 4.0) -- Define player position local playerPosition = Vector3(4.0, 2.0, 4.0) -- Define player position
SetCameraMode(CameraMode.FIRST_PERSON) -- Set a first person camera mode SetCameraMode(camera, CameraMode.FIRST_PERSON) -- Set a first person camera mode
SetCameraFovy(camera.fovy) -- Set internal camera field-of-view Y
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
-- Main game loop -- Main game loop
while not WindowShouldClose() do -- Detect window close button or ESC key while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update -- Update
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
camera, playerPosition = UpdateCameraPlayer(camera, playerPosition) -- Update camera and player position camera = UpdateCamera(camera) -- Update camera
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
-- Draw -- Draw

View File

@ -18,26 +18,23 @@ InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free")
-- Define the camera to look into our 3d world -- Define the camera to look into our 3d world
local camera = {} local camera = {}
camera.position = Vector3(0.0, 10.0, 10.0) -- Camera position camera.position = Vector3(10.0, 10.0, 10.0) -- Camera position
camera.target = Vector3(0.0, 0.0, 0.0) -- Camera looking at point camera.target = Vector3(0.0, 0.0, 0.0) -- Camera looking at point
camera.up = Vector3(0.0, 1.0, 0.0) -- Camera up vector (rotation towards target) camera.up = Vector3(0.0, 1.0, 0.0) -- Camera up vector (rotation towards target)
camera.fovy = 45.0 -- Camera field-of-view Y camera.fovy = 45.0 -- Camera field-of-view Y
local cubePosition = Vector3(0.0, 0.0, 0.0) local cubePosition = Vector3(0.0, 0.0, 0.0)
SetCameraMode(CameraMode.FREE) -- Set a free camera mode SetCameraMode(camera, CameraMode.FREE) -- Set a free camera mode
SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
SetCameraTarget(camera.target) -- Set internal camera target to match our camera target
SetCameraFovy(camera.fovy) -- Set internal camera field-of-view Y
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
-- Main game loop -- Main game loop
while not WindowShouldClose() do -- Detect window close button or ESC key while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update -- Update
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
camera = UpdateCamera(camera) -- Update internal camera and our camera camera = UpdateCamera(camera) -- Update camera
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
-- Draw -- Draw

View File

@ -30,18 +30,16 @@ local ray = Ray(Vector3(0, 0, 0), Vector3(0, 0, 0)) -- Picking line ray
local collision = false local collision = false
SetCameraMode(CameraMode.FREE) -- Set a free camera mode SetCameraMode(camera, CameraMode.FREE) -- Set a free camera mode
SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
SetCameraFovy(camera.fovy) -- Set internal camera field-of-view Y
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
-- Main game loop -- Main game loop
while not WindowShouldClose() do -- Detect window close button or ESC key while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update -- Update
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
camera = UpdateCamera(camera) -- Update internal camera and our camera camera = UpdateCamera(camera) -- Update camera
if (IsMouseButtonPressed(MOUSE.LEFT_BUTTON)) then if (IsMouseButtonPressed(MOUSE.LEFT_BUTTON)) then
-- NOTE: This function is NOT WORKING properly! -- NOTE: This function is NOT WORKING properly!

View File

@ -23,7 +23,7 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files"); InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files");
int count = 0; int count = 0;
char **droppedFiles; char **droppedFiles = { 0 };
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View File

@ -19,8 +19,8 @@ local screenHeight = 450
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input") InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input")
local ballPosition = Vector2(screenWidth/2, screenHeight/2) local texPs3Pad = LoadTexture("resources/ps3.png")
local gamepadMovement = Vector2(0, 0) local texXboxPad = LoadTexture("resources/xbox.png")
SetTargetFPS(60) -- Set target frames-per-second SetTargetFPS(60) -- Set target frames-per-second
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
@ -29,18 +29,7 @@ SetTargetFPS(60) -- Set target frames-per-second
while not WindowShouldClose() do -- Detect window close button or ESC key while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update -- Update
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
if (IsGamepadAvailable(GAMEPAD.PLAYER1)) then -- ...
gamepadMovement.x = GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_LEFT_X)
gamepadMovement.y = GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_LEFT_Y)
ballPosition.x = ballPosition.x + gamepadMovement.x
ballPosition.y = ballPosition.y - gamepadMovement.y
if (IsGamepadButtonPressed(GAMEPAD.PLAYER1, GAMEPAD.BUTTON_A)) then
ballPosition.x = screenWidth/2
ballPosition.y = screenHeight/2
end
end
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
-- Draw -- Draw
@ -49,9 +38,117 @@ while not WindowShouldClose() do -- Detect window close button or ESC key
ClearBackground(RAYWHITE) ClearBackground(RAYWHITE)
DrawText("move the ball with gamepad", 10, 10, 20, DARKGRAY) if (IsGamepadAvailable(GAMEPAD.PLAYER1)) then
DrawText(string.format("GP1: %s", GetGamepadName(GAMEPAD.PLAYER1)), 10, 10, 10, BLACK)
DrawCircleV(ballPosition, 50, MAROON) if (IsGamepadName(GAMEPAD.PLAYER1, "Xbox 360 Controller")) then
DrawTexture(texXboxPad, 0, 0, DARKGRAY)
-- Draw buttons: xbox home
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_HOME)) then DrawCircle(394, 89, 19, RED) end
-- Draw buttons: basic
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_START)) then DrawCircle(436, 150, 9, RED) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_SELECT)) then DrawCircle(352, 150, 9, RED) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_X)) then DrawCircle(501, 151, 15, BLUE) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_A)) then DrawCircle(536, 187, 15, LIME) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_B)) then DrawCircle(572, 151, 15, MAROON) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_Y)) then DrawCircle(536, 115, 15, GOLD) end
-- Draw buttons: d-pad
DrawRectangle(317, 202, 19, 71, BLACK)
DrawRectangle(293, 228, 69, 19, BLACK)
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_UP)) then DrawRectangle(317, 202, 19, 26, RED) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_DOWN)) then DrawRectangle(317, 202 + 45, 19, 26, RED) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_LEFT)) then DrawRectangle(292, 228, 25, 19, RED) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_RIGHT)) then DrawRectangle(292 + 44, 228, 26, 19, RED) end
-- Draw buttons: left-right back
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_LB)) then DrawCircle(259, 61, 20, RED) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.XBOX_BUTTON_RB)) then DrawCircle(536, 61, 20, RED) end
-- Draw axis: left joystick
DrawCircle(259, 152, 39, BLACK)
DrawCircle(259, 152, 34, LIGHTGRAY)
DrawCircle(259 + (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_LEFT_X)*20),
152 - (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_LEFT_Y)*20), 25, BLACK)
-- Draw axis: right joystick
DrawCircle(461, 237, 38, BLACK)
DrawCircle(461, 237, 33, LIGHTGRAY)
DrawCircle(461 + (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_RIGHT_X)*20),
237 - (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_RIGHT_Y)*20), 25, BLACK)
-- Draw axis: left-right triggers
DrawRectangle(170, 30, 15, 70, GRAY)
DrawRectangle(604, 30, 15, 70, GRAY)
DrawRectangle(170, 30, 15, (((1.0 + GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_LT))/2.0)*70), RED)
DrawRectangle(604, 30, 15, (((1.0 + GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_RT))/2.0)*70), RED)
--DrawText(FormatText("Xbox axis LT: %02.02f", GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_LT)), 10, 40, 10, BLACK)
--DrawText(FormatText("Xbox axis RT: %02.02f", GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_RT)), 10, 60, 10, BLACK)
elseif (IsGamepadName(GAMEPAD.PLAYER1, "PLAYSTATION(R)3 Controller")) then
DrawTexture(texPs3Pad, 0, 0, DARKGRAY)
-- Draw buttons: ps
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_PS)) then DrawCircle(396, 222, 13, RED) end
-- Draw buttons: basic
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_SELECT)) then DrawRectangle(328, 170, 32, 13, RED) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_START)) then DrawTriangle((Vector2){ 436, 168 }, (Vector2){ 436, 185 }, (Vector2){ 464, 177 }, RED) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_TRIANGLE)) then DrawCircle(557, 144, 13, LIME) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_CIRCLE)) then DrawCircle(586, 173, 13, RED) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_CROSS)) then DrawCircle(557, 203, 13, VIOLET) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_SQUARE)) then DrawCircle(527, 173, 13, PINK) end
-- Draw buttons: d-pad
DrawRectangle(225, 132, 24, 84, BLACK)
DrawRectangle(195, 161, 84, 25, BLACK)
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_UP)) then DrawRectangle(225, 132, 24, 29, RED) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_DOWN)) then DrawRectangle(225, 132 + 54, 24, 30, RED) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_LEFT)) then DrawRectangle(195, 161, 30, 25, RED) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_RIGHT)) then DrawRectangle(195 + 54, 161, 30, 25, RED) end
-- Draw buttons: left-right back buttons
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_L1)) then DrawCircle(239, 82, 20, RED) end
if (IsGamepadButtonDown(GAMEPAD.PLAYER1, GAMEPAD.PS3_BUTTON_R1)) then DrawCircle(557, 82, 20, RED) end
-- Draw axis: left joystick
DrawCircle(319, 255, 35, BLACK)
DrawCircle(319, 255, 31, LIGHTGRAY)
DrawCircle(319 + (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.PS3_AXIS_LEFT_X)*20),
255 + (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.PS3_AXIS_LEFT_Y)*20), 25, BLACK)
-- Draw axis: right joystick
DrawCircle(475, 255, 35, BLACK)
DrawCircle(475, 255, 31, LIGHTGRAY)
DrawCircle(475 + (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.PS3_AXIS_RIGHT_X)*20),
255 + (GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.PS3_AXIS_RIGHT_Y)*20), 25, BLACK)
-- Draw axis: left-right triggers
DrawRectangle(169, 48, 15, 70, GRAY)
DrawRectangle(611, 48, 15, 70, GRAY)
DrawRectangle(169, 48, 15, (((1.0 - GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.PS3_AXIS_L2))/2.0)*70), RED)
DrawRectangle(611, 48, 15, (((1.0 - GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.PS3_AXIS_R2))/2.0)*70), RED)
else
DrawText("- GENERIC GAMEPAD -", 280, 180, 20, GRAY)
-- TODO: Draw generic gamepad
end
DrawText(string.format("DETECTED AXIS [%i]:", GetGamepadAxisCount(GAMEPAD.PLAYER1)), 10, 50, 10, MAROON)
for i = 1, GetGamepadAxisCount(GAMEPAD.PLAYER1) do -- Iterate along all the rectangles
DrawText(string.format("AXIS %i: %.02f", i, GetGamepadAxisMovement(GAMEPAD.PLAYER1, i)), 20, 70 + 20*i, 10, DARKGRAY)
end
if (GetGamepadButtonPressed() ~= -1) then DrawText(string.format("DETECTED BUTTON: %i", GetGamepadButtonPressed()), 10, 430, 10, RED)
else DrawText("DETECTED BUTTON: NONE", 10, 430, 10, GRAY) end
else
DrawText("GP1: NOT DETECTED", 10, 10, 10, GRAY)
DrawTexture(texXboxPad, 0, 0, LIGHTGRAY)
end
EndDrawing() EndDrawing()
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
@ -59,5 +156,8 @@ end
-- De-Initialization -- De-Initialization
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
CloseWindow() -- Close window and OpenGL context UnloadTexture(texPs3Pad) -- Unload gamepad texture
UnloadTexture(texXboxPad) -- Unload gamepad texture
CloseWindow() -- Close window and OpenGL context
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View File

@ -47,10 +47,10 @@ int main()
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsVrSimulator()) UpdateCamera(&camera); // Update camera (simulator mode) if (IsVrSimulator()) UpdateCamera(&camera); // Update camera (simulator mode)
else UpdateVrTracking(&camera); // Update camera with device tracking data else if (IsVrDeviceReady()) UpdateVrTracking(&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

View File

@ -23,10 +23,7 @@ local cubePosition = Vector3(0.0, 0.0, 0.0)
local cubeScreenPosition = Vector2(0, 0) local cubeScreenPosition = Vector2(0, 0)
SetCameraMode(CameraMode.FREE) -- Set a free camera mode SetCameraMode(camera, CameraMode.FREE) -- Set a free camera mode
SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
SetCameraTarget(camera.target) -- Set internal camera target to match our camera target
SetCameraFovy(camera.fovy) -- Set internal camera field-of-view Y
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
---------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------
@ -35,7 +32,7 @@ SetTargetFPS(60) -- Set our game to run at 60 frames-per-
while not WindowShouldClose() do -- Detect window close button or ESC key while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update -- Update
------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------
camera = UpdateCamera(camera) -- Update internal camera and our camera camera = UpdateCamera(camera) -- Update camera
-- Calculate cube screen space position (with a little offset to be in top) -- Calculate cube screen space position (with a little offset to be in top)
cubeScreenPosition = GetWorldToScreen(Vector3(cubePosition.x, cubePosition.y + 2.5, cubePosition.z), camera) cubeScreenPosition = GetWorldToScreen(Vector3(cubePosition.x, cubePosition.y + 2.5, cubePosition.z), camera)

View File

@ -22,19 +22,16 @@ local camera = Camera(Vector3(5.0, 4.0, 5.0), Vector3(0.0, 2.0, 0.0), Vector3(0.
local bill = LoadTexture("resources/billboard.png") -- Our texture billboard local bill = LoadTexture("resources/billboard.png") -- Our texture billboard
local billPosition = Vector3(0.0, 2.0, 0.0) -- Position where draw billboard local billPosition = Vector3(0.0, 2.0, 0.0) -- Position where draw billboard
SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode SetCameraMode(camera, CameraMode.ORBITAL) -- Set an orbital camera mode
SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
SetCameraTarget(camera.target) -- Set internal camera target to match our camera target
SetCameraFovy(camera.fovy) -- Set internal camera field-of-view Y
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
-- Main game loop -- Main game loop
while not WindowShouldClose() do -- Detect window close button or ESC key while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update -- Update
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
camera = UpdateCamera(camera) -- Update internal camera and our camera camera = UpdateCamera(camera) -- Update camera
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
-- Draw -- Draw

View File

@ -31,18 +31,16 @@ local mapPosition = Vector3(-16.0, 0.0, -8.0) -- Set model position
UnloadImage(image) -- Unload cubesmap image from RAM, already uploaded to VRAM UnloadImage(image) -- Unload cubesmap image from RAM, already uploaded to VRAM
SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode SetCameraMode(camera, CameraMode.ORBITAL) -- Set an orbital camera mode
SetCameraPosition(camera.position) -- Set internal camera position to match our custom camera position
SetCameraFovy(camera.fovy) -- Set internal camera field-of-view Y
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
-- Main game loop -- Main game loop
while not WindowShouldClose() do -- Detect window close button or ESC key while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update -- Update
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
camera = UpdateCamera(camera) -- Update internal camera and our camera camera = UpdateCamera(camera) -- Update camera
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
-- Draw -- Draw

View File

@ -27,17 +27,16 @@ local mapPosition = Vector3(-8.0, 0.0, -8.0) -- Set model position (d
UnloadImage(image) -- Unload heightmap image from RAM, already uploaded to VRAM UnloadImage(image) -- Unload heightmap image from RAM, already uploaded to VRAM
SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode SetCameraMode(camera, CameraMode.ORBITAL) -- Set an orbital camera mode
SetCameraPosition(camera.position) -- Set internal camera position to match our custom camera position
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
---------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------
-- Main game loop -- Main game loop
while not WindowShouldClose() do -- Detect window close button or ESC key while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update -- Update
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
camera = UpdateCamera(camera) -- Update internal camera and our camera camera = UpdateCamera(camera) -- Update camera
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
-- Draw -- Draw

View File

@ -1,135 +0,0 @@
/*******************************************************************************************
*
* raylib [physac] example - Basic rigidbody
*
* 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)
*
* NOTE:
* Physac requires multi-threading, when InitPhysics() a second thread is created to manage
* physics calculations. To accomplish that, physac uses pthread Win32 library that can be
* found inside raylib/src/external/pthread directory.
*
* Add pthread library when compiling physac example:
* gcc -o $(NAME_PART).exe $(FILE_NAME) $(RAYLIB_DIR)\raylib_icon -L../src/external/pthread/lib \
* -I../src -I../src/external/pthread/include -lraylib -lglfw3 -lopengl32 -lgdi32 -lpthreadGC2 -std=c99 -Wall
*
* Note that pthreadGC2.dll must be also copied to project directory!
*
* Copyright (c) 2016 Victor Fisac and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "physac.h"
#define MOVE_VELOCITY 5
#define JUMP_VELOCITY 30
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [physac] example - basic rigidbody");
InitPhysics((Vector2){ 0.0f, -9.81f/2 }); // Initialize physics module
// Debug variables
bool isDebug = false;
// Create rectangle physic object
PhysicBody rectangle = CreatePhysicBody((Vector2){ screenWidth*0.25f, screenHeight/2 }, 0.0f, (Vector2){ 75, 50 });
rectangle->rigidbody.enabled = true; // Enable physic object rigidbody behaviour
rectangle->rigidbody.applyGravity = true;
rectangle->rigidbody.friction = 0.1f;
rectangle->rigidbody.bounciness = 6.0f;
// Create square physic object
PhysicBody square = CreatePhysicBody((Vector2){ screenWidth*0.75f, screenHeight/2 }, 0.0f, (Vector2){ 50, 50 });
square->rigidbody.enabled = true; // Enable physic object rigidbody behaviour
square->rigidbody.applyGravity = true;
square->rigidbody.friction = 0.1f;
// Create walls physic objects
PhysicBody floor = CreatePhysicBody((Vector2){ screenWidth/2, screenHeight*0.95f }, 0.0f, (Vector2){ screenWidth*0.9f, 100 });
PhysicBody leftWall = CreatePhysicBody((Vector2){ 0.0f, screenHeight/2 }, 0.0f, (Vector2){ screenWidth*0.1f, screenHeight });
PhysicBody rightWall = CreatePhysicBody((Vector2){ screenWidth, screenHeight/2 }, 0.0f, (Vector2){ screenWidth*0.1f, screenHeight });
PhysicBody roof = CreatePhysicBody((Vector2){ screenWidth/2, screenHeight*0.05f }, 0.0f, (Vector2){ screenWidth*0.9f, 100 });
// Create pplatform physic object
PhysicBody platform = CreatePhysicBody((Vector2){ screenWidth/2, screenHeight*0.7f }, 0.0f, (Vector2){ screenWidth*0.25f, 20 });
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// Check rectangle movement inputs
if (IsKeyPressed('W')) rectangle->rigidbody.velocity.y = JUMP_VELOCITY;
if (IsKeyDown('A')) rectangle->rigidbody.velocity.x = -MOVE_VELOCITY;
else if (IsKeyDown('D')) rectangle->rigidbody.velocity.x = MOVE_VELOCITY;
// Check square movement inputs
if (IsKeyDown(KEY_UP) && square->rigidbody.isGrounded) square->rigidbody.velocity.y = JUMP_VELOCITY;
if (IsKeyDown(KEY_LEFT)) square->rigidbody.velocity.x = -MOVE_VELOCITY;
else if (IsKeyDown(KEY_RIGHT)) square->rigidbody.velocity.x = MOVE_VELOCITY;
// Check debug switch input
if (IsKeyPressed('P')) isDebug = !isDebug;
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
// Draw floor, roof and walls rectangles
DrawRectangleRec(TransformToRectangle(floor->transform), DARKGRAY); // Convert transform values to rectangle data type variable
DrawRectangleRec(TransformToRectangle(leftWall->transform), DARKGRAY);
DrawRectangleRec(TransformToRectangle(rightWall->transform), DARKGRAY);
DrawRectangleRec(TransformToRectangle(roof->transform), DARKGRAY);
// Draw middle platform rectangle
DrawRectangleRec(TransformToRectangle(platform->transform), DARKGRAY);
// Draw physic objects
DrawRectangleRec(TransformToRectangle(rectangle->transform), RED);
DrawRectangleRec(TransformToRectangle(square->transform), BLUE);
// Draw collider lines if debug is enabled
if (isDebug)
{
DrawRectangleLines(floor->collider.bounds.x, floor->collider.bounds.y, floor->collider.bounds.width, floor->collider.bounds.height, GREEN);
DrawRectangleLines(leftWall->collider.bounds.x, leftWall->collider.bounds.y, leftWall->collider.bounds.width, leftWall->collider.bounds.height, GREEN);
DrawRectangleLines(rightWall->collider.bounds.x, rightWall->collider.bounds.y, rightWall->collider.bounds.width, rightWall->collider.bounds.height, GREEN);
DrawRectangleLines(roof->collider.bounds.x, roof->collider.bounds.y, roof->collider.bounds.width, roof->collider.bounds.height, GREEN);
DrawRectangleLines(platform->collider.bounds.x, platform->collider.bounds.y, platform->collider.bounds.width, platform->collider.bounds.height, GREEN);
DrawRectangleLines(rectangle->collider.bounds.x, rectangle->collider.bounds.y, rectangle->collider.bounds.width, rectangle->collider.bounds.height, GREEN);
DrawRectangleLines(square->collider.bounds.x, square->collider.bounds.y, square->collider.bounds.width, square->collider.bounds.height, GREEN);
}
// Draw help message
DrawText("Use WASD to move rectangle and ARROWS to move square", screenWidth/2 - MeasureText("Use WASD to move rectangle and ARROWS to move square", 20)/2, screenHeight*0.075f, 20, LIGHTGRAY);
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics (including all loaded objects)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

122
examples/physics_demo.c Normal file
View File

@ -0,0 +1,122 @@
/*******************************************************************************************
*
* Physac - Physics demo
*
* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* The file pthreadGC2.dll is required to run the program; you can find it in 'src\external'
*
* Copyright (c) 2016 Victor Fisac
*
********************************************************************************************/
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "..\src\physac.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics demo");
SetTargetFPS(60);
// Physac logo drawing position
int logoX = screenWidth - MeasureText("Physac", 30) - 10;
int logoY = 15;
// Initialize physics and default physics bodies
InitPhysics();
// Create floor rectangle physics body
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10);
floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
// Create obstacle circle physics body
PhysicsBody circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2, screenHeight/2 }, 45, 10);
circle->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed('R')) // Reset physics input
{
ResetPhysics();
floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10);
floor->enabled = false;
circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2, screenHeight/2 }, 45, 10);
circle->enabled = false;
}
// Physics body creation inputs
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10);
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10);
// Destroy falling physics bodies
int bodiesCount = GetPhysicsBodiesCount();
for (int i = bodiesCount - 1; i >= 0; i--)
{
PhysicsBody body = GetPhysicsBody(i);
if (body != NULL && (body->position.y > screenHeight*2)) DestroyPhysicsBody(body);
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(BLACK);
DrawFPS(screenWidth - 90, screenHeight - 30);
// Draw created physics bodies
bodiesCount = GetPhysicsBodiesCount();
for (int i = 0; i < bodiesCount; i++)
{
PhysicsBody body = GetPhysicsBody(i);
if (body != NULL)
{
int vertexCount = GetPhysicsShapeVerticesCount(i);
for (int j = 0; j < vertexCount; j++)
{
// Get physics bodies shape vertices to draw lines
// Note: GetPhysicsShapeVertex() already calculates rotation transformations
Vector2 vertexA = GetPhysicsShapeVertex(body, j);
int jj = (((j + 1) < vertexCount) ? (j + 1) : 0); // Get next vertex or first to close the shape
Vector2 vertexB = GetPhysicsShapeVertex(body, jj);
DrawLineV(vertexA, vertexB, GREEN); // Draw a line between two vertex positions
}
}
}
DrawText("Left mouse button to create a polygon", 10, 10, 10, WHITE);
DrawText("Right mouse button to create a circle", 10, 25, 10, WHITE);
DrawText("Press 'R' to reset example", 10, 40, 10, WHITE);
DrawText("Physac", logoX, logoY, 30, WHITE);
DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

BIN
examples/physics_demo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -1,193 +0,0 @@
/*******************************************************************************************
*
* raylib [physac] example - Forces
*
* 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)
*
* NOTE:
* Physac requires multi-threading, when InitPhysics() a second thread is created to manage
* physics calculations. To accomplish that, physac uses pthread Win32 library that can be
* found inside raylib/src/external/pthread directory.
*
* Add pthread library when compiling physac example:
* gcc -o $(NAME_PART).exe $(FILE_NAME) $(RAYLIB_DIR)\raylib_icon -L../src/external/pthread/lib \
* -I../src -I../src/external/pthread/include -lraylib -lglfw3 -lopengl32 -lgdi32 -lpthreadGC2 -std=c99 -Wall
*
* Note that pthreadGC2.dll must be also copied to project directory!
*
* Copyright (c) 2016 Victor Fisac and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "physac.h"
#define FORCE_AMOUNT 5.0f
#define FORCE_RADIUS 150
#define LINE_LENGTH 75
#define TRIANGLE_LENGTH 12
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [physac] example - forces");
InitPhysics((Vector2){ 0.0f, -9.81f/2 }); // Initialize physics module
// Global variables
Vector2 mousePosition;
bool isDebug = false;
// Create rectangle physic objects
PhysicBody rectangles[3];
for (int i = 0; i < 3; i++)
{
rectangles[i] = CreatePhysicBody((Vector2){ screenWidth/4*(i+1), (((i % 2) == 0) ? (screenHeight/3) : (screenHeight/1.5f)) }, 0.0f, (Vector2){ 50, 50 });
rectangles[i]->rigidbody.enabled = true; // Enable physic object rigidbody behaviour
rectangles[i]->rigidbody.friction = 0.1f;
}
// Create circles physic objects
// NOTE: when creating circle physic objects, transform.scale must be { 0, 0 } and object radius must be defined in collider.radius and use this value to draw the circle.
PhysicBody circles[3];
for (int i = 0; i < 3; i++)
{
circles[i] = CreatePhysicBody((Vector2){ screenWidth/4*(i+1), (((i % 2) == 0) ? (screenHeight/1.5f) : (screenHeight/4)) }, 0.0f, (Vector2){ 0, 0 });
circles[i]->rigidbody.enabled = true; // Enable physic object rigidbody behaviour
circles[i]->rigidbody.friction = 0.1f;
circles[i]->collider.type = COLLIDER_CIRCLE;
circles[i]->collider.radius = 25;
}
// Create walls physic objects
PhysicBody leftWall = CreatePhysicBody((Vector2){ -25, screenHeight/2 }, 0.0f, (Vector2){ 50, screenHeight });
PhysicBody rightWall = CreatePhysicBody((Vector2){ screenWidth + 25, screenHeight/2 }, 0.0f, (Vector2){ 50, screenHeight });
PhysicBody topWall = CreatePhysicBody((Vector2){ screenWidth/2, -25 }, 0.0f, (Vector2){ screenWidth, 50 });
PhysicBody bottomWall = CreatePhysicBody((Vector2){ screenWidth/2, screenHeight + 25 }, 0.0f, (Vector2){ screenWidth, 50 });
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// Update mouse position value
mousePosition = GetMousePosition();
// Check force input
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ApplyForceAtPosition(mousePosition, FORCE_AMOUNT, FORCE_RADIUS);
// Check reset input
if (IsKeyPressed('R'))
{
// Reset rectangle physic objects positions
for (int i = 0; i < 3; i++)
{
rectangles[i]->transform.position = (Vector2){ screenWidth/4*(i+1) - rectangles[i]->transform.scale.x/2, (((i % 2) == 0) ? (screenHeight/3) : (screenHeight/1.5f)) - rectangles[i]->transform.scale.y/2 };
rectangles[i]->rigidbody.velocity =(Vector2){ 0.0f, 0.0f };
}
// Reset circles physic objects positions
for (int i = 0; i < 3; i++)
{
circles[i]->transform.position = (Vector2){ screenWidth/4*(i+1), (((i % 2) == 0) ? (screenHeight/1.5f) : (screenHeight/4)) };
circles[i]->rigidbody.velocity =(Vector2){ 0.0f, 0.0f };
}
}
// Check debug switch input
if (IsKeyPressed('P')) isDebug = !isDebug;
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
// Draw rectangles
for (int i = 0; i < 3; i++)
{
// Convert transform values to rectangle data type variable
DrawRectangleRec(TransformToRectangle(rectangles[i]->transform), RED);
if (isDebug) DrawRectangleLines(rectangles[i]->collider.bounds.x, rectangles[i]->collider.bounds.y, rectangles[i]->collider.bounds.width, rectangles[i]->collider.bounds.height, GREEN);
// Draw force radius
DrawCircleLines(mousePosition.x, mousePosition.y, FORCE_RADIUS, BLACK);
// Draw direction lines
if (CheckCollisionPointCircle((Vector2){ rectangles[i]->transform.position.x + rectangles[i]->transform.scale.x/2, rectangles[i]->transform.position.y + rectangles[i]->transform.scale.y/2 }, mousePosition, FORCE_RADIUS))
{
Vector2 direction = { rectangles[i]->transform.position.x + rectangles[i]->transform.scale.x/2 - mousePosition.x, rectangles[i]->transform.position.y + rectangles[i]->transform.scale.y/2 - mousePosition.y };
float angle = atan2l(direction.y, direction.x);
// Calculate arrow start and end positions
Vector2 startPosition = { rectangles[i]->transform.position.x + rectangles[i]->transform.scale.x/2, rectangles[i]->transform.position.y + rectangles[i]->transform.scale.y/2 };
Vector2 endPosition = { rectangles[i]->transform.position.x + rectangles[i]->transform.scale.x/2 + (cos(angle)*LINE_LENGTH), rectangles[i]->transform.position.y + rectangles[i]->transform.scale.y/2 + (sin(angle)*LINE_LENGTH) };
// Draw arrow line
DrawLineV(startPosition, endPosition, BLACK);
// Draw arrow triangle
DrawTriangleLines((Vector2){ endPosition.x - cos(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH, endPosition.y - sin(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH },
(Vector2){ endPosition.x + cos(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH, endPosition.y + sin(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH },
(Vector2){ endPosition.x + cos(angle)*LINE_LENGTH/TRIANGLE_LENGTH*2, endPosition.y + sin(angle)*LINE_LENGTH/TRIANGLE_LENGTH*2 }, BLACK);
}
}
// Draw circles
for (int i = 0; i < 3; i++)
{
DrawCircleV(circles[i]->transform.position, circles[i]->collider.radius, BLUE);
if (isDebug) DrawCircleLines(circles[i]->transform.position.x, circles[i]->transform.position.y, circles[i]->collider.radius, GREEN);
// Draw force radius
DrawCircleLines(mousePosition.x, mousePosition.y, FORCE_RADIUS, BLACK);
// Draw direction lines
if (CheckCollisionPointCircle((Vector2){ circles[i]->transform.position.x, circles[i]->transform.position.y }, mousePosition, FORCE_RADIUS))
{
Vector2 direction = { circles[i]->transform.position.x - mousePosition.x, circles[i]->transform.position.y - mousePosition.y };
float angle = atan2l(direction.y, direction.x);
// Calculate arrow start and end positions
Vector2 startPosition = { circles[i]->transform.position.x, circles[i]->transform.position.y };
Vector2 endPosition = { circles[i]->transform.position.x + (cos(angle)*LINE_LENGTH), circles[i]->transform.position.y + (sin(angle)*LINE_LENGTH) };
// Draw arrow line
DrawLineV(startPosition, endPosition, BLACK);
// Draw arrow triangle
DrawTriangleLines((Vector2){ endPosition.x - cos(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH, endPosition.y - sin(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH },
(Vector2){ endPosition.x + cos(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH, endPosition.y + sin(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH },
(Vector2){ endPosition.x + cos(angle)*LINE_LENGTH/TRIANGLE_LENGTH*2, endPosition.y + sin(angle)*LINE_LENGTH/TRIANGLE_LENGTH*2 }, BLACK);
}
}
// Draw help messages
DrawText("Use LEFT MOUSE BUTTON to apply a force", screenWidth/2 - MeasureText("Use LEFT MOUSE BUTTON to apply a force", 20)/2, screenHeight*0.075f, 20, LIGHTGRAY);
DrawText("Use R to reset objects position", screenWidth/2 - MeasureText("Use R to reset objects position", 20)/2, screenHeight*0.875f, 20, GRAY);
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics module
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

136
examples/physics_friction.c Normal file
View File

@ -0,0 +1,136 @@
/*******************************************************************************************
*
* Physac - Physics friction
*
* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* The file pthreadGC2.dll is required to run the program; you can find it in 'src\external'
*
* Copyright (c) 2016 Victor Fisac
*
********************************************************************************************/
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "..\src\physac.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics friction");
SetTargetFPS(60);
// Physac logo drawing position
int logoX = screenWidth - MeasureText("Physac", 30) - 10;
int logoY = 15;
// Initialize physics and default physics bodies
InitPhysics();
// Create floor rectangle physics body
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, screenWidth, 100, 10);
floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
PhysicsBody wall = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight*0.8f }, 10, 80, 10);
wall->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
// Create left ramp physics body
PhysicsBody rectLeft = CreatePhysicsBodyRectangle((Vector2){ 25, screenHeight - 5 }, 250, 250, 10);
rectLeft->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
SetPhysicsBodyRotation(rectLeft, 30*DEG2RAD);
// Create right ramp physics body
PhysicsBody rectRight = CreatePhysicsBodyRectangle((Vector2){ screenWidth - 25, screenHeight - 5 }, 250, 250, 10);
rectRight->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
SetPhysicsBodyRotation(rectRight, 330*DEG2RAD);
// Create dynamic physics bodies
PhysicsBody bodyA = CreatePhysicsBodyRectangle((Vector2){ 35, screenHeight*0.6f }, 40, 40, 10);
bodyA->staticFriction = 0.1f;
bodyA->dynamicFriction = 0.1f;
SetPhysicsBodyRotation(bodyA, 30*DEG2RAD);
PhysicsBody bodyB = CreatePhysicsBodyRectangle((Vector2){ screenWidth - 35, screenHeight*0.6f }, 40, 40, 10);
bodyB->staticFriction = 1;
bodyB->dynamicFriction = 1;
SetPhysicsBodyRotation(bodyB, 330*DEG2RAD);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed('R')) // Reset physics input
{
// Reset dynamic physics bodies position, velocity and rotation
bodyA->position = (Vector2){ 35, screenHeight*0.6f };
bodyA->velocity = (Vector2){ 0, 0 };
bodyA->angularVelocity = 0;
SetPhysicsBodyRotation(bodyA, 30*DEG2RAD);
bodyB->position = (Vector2){ screenWidth - 35, screenHeight*0.6f };
bodyB->velocity = (Vector2){ 0, 0 };
bodyB->angularVelocity = 0;
SetPhysicsBodyRotation(bodyB, 330*DEG2RAD);
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(BLACK);
DrawFPS(screenWidth - 90, screenHeight - 30);
// Draw created physics bodies
int bodiesCount = GetPhysicsBodiesCount();
for (int i = 0; i < bodiesCount; i++)
{
PhysicsBody body = GetPhysicsBody(i);
if (body != NULL)
{
int vertexCount = GetPhysicsShapeVerticesCount(i);
for (int j = 0; j < vertexCount; j++)
{
// Get physics bodies shape vertices to draw lines
// Note: GetPhysicsShapeVertex() already calculates rotation transformations
Vector2 vertexA = GetPhysicsShapeVertex(body, j);
int jj = (((j + 1) < vertexCount) ? (j + 1) : 0); // Get next vertex or first to close the shape
Vector2 vertexB = GetPhysicsShapeVertex(body, jj);
DrawLineV(vertexA, vertexB, GREEN); // Draw a line between two vertex positions
}
}
}
DrawRectangle(0, screenHeight - 49, screenWidth, 49, BLACK);
DrawText("Friction amount", (screenWidth - MeasureText("Friction amount", 30))/2, 75, 30, WHITE);
DrawText("0.1", bodyA->position.x - MeasureText("0.1", 20)/2, bodyA->position.y - 7, 20, WHITE);
DrawText("1", bodyB->position.x - MeasureText("1", 20)/2, bodyB->position.y - 7, 20, WHITE);
DrawText("Press 'R' to reset example", 10, 10, 10, WHITE);
DrawText("Physac", logoX, logoY, 30, WHITE);
DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

122
examples/physics_movement.c Normal file
View File

@ -0,0 +1,122 @@
/*******************************************************************************************
*
* Physac - Physics movement
*
* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* The file pthreadGC2.dll is required to run the program; you can find it in 'src\external'
*
* Copyright (c) 2016 Victor Fisac
*
********************************************************************************************/
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "..\src\physac.h"
#define VELOCITY 0.5f
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics movement");
SetTargetFPS(60);
// Physac logo drawing position
int logoX = screenWidth - MeasureText("Physac", 30) - 10;
int logoY = 15;
// Initialize physics and default physics bodies
InitPhysics();
// Create floor and walls rectangle physics body
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, screenWidth, 100, 10);
PhysicsBody platformLeft = CreatePhysicsBodyRectangle((Vector2){ screenWidth*0.25f, screenHeight*0.6f }, screenWidth*0.25f, 10, 10);
PhysicsBody platformRight = CreatePhysicsBodyRectangle((Vector2){ screenWidth*0.75f, screenHeight*0.6f }, screenWidth*0.25f, 10, 10);
PhysicsBody wallLeft = CreatePhysicsBodyRectangle((Vector2){ -5, screenHeight/2 }, 10, screenHeight, 10);
PhysicsBody wallRight = CreatePhysicsBodyRectangle((Vector2){ screenWidth + 5, screenHeight/2 }, 10, screenHeight, 10);
// Disable dynamics to floor and walls physics bodies
floor->enabled = false;
platformLeft->enabled = false;
platformRight->enabled = false;
wallLeft->enabled = false;
wallRight->enabled = false;
// Create movement physics body
PhysicsBody body = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight/2 }, 50, 50, 1);
body->freezeOrient = true; // Constrain body rotation to avoid little collision torque amounts
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed('R')) // Reset physics input
{
// Reset movement physics body position, velocity and rotation
body->position = (Vector2){ screenWidth/2, screenHeight/2 };
body->velocity = (Vector2){ 0, 0 };
SetPhysicsBodyRotation(body, 0);
}
// Horizontal movement input
if (IsKeyDown(KEY_RIGHT)) body->velocity.x = VELOCITY;
else if (IsKeyDown(KEY_LEFT)) body->velocity.x = -VELOCITY;
// Vertical movement input checking if player physics body is grounded
if (IsKeyDown(KEY_UP) && body->isGrounded) body->velocity.y = -VELOCITY*4;
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(BLACK);
DrawFPS(screenWidth - 90, screenHeight - 30);
// Draw created physics bodies
int bodiesCount = GetPhysicsBodiesCount();
for (int i = 0; i < bodiesCount; i++)
{
PhysicsBody body = GetPhysicsBody(i);
int vertexCount = GetPhysicsShapeVerticesCount(i);
for (int j = 0; j < vertexCount; j++)
{
// Get physics bodies shape vertices to draw lines
// Note: GetPhysicsShapeVertex() already calculates rotation transformations
Vector2 vertexA = GetPhysicsShapeVertex(body, j);
int jj = (((j + 1) < vertexCount) ? (j + 1) : 0); // Get next vertex or first to close the shape
Vector2 vertexB = GetPhysicsShapeVertex(body, jj);
DrawLineV(vertexA, vertexB, GREEN); // Draw a line between two vertex positions
}
}
DrawText("Use 'ARROWS' to move player", 10, 10, 10, WHITE);
DrawText("Press 'R' to reset example", 10, 30, 10, WHITE);
DrawText("Physac", logoX, logoY, 30, WHITE);
DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,115 @@
/*******************************************************************************************
*
* Physac - Physics restitution
*
* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* The file pthreadGC2.dll is required to run the program; you can find it in 'src\external'
*
* Copyright (c) 2016 Victor Fisac
*
********************************************************************************************/
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "..\src\physac.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics restitution");
SetTargetFPS(60);
// Physac logo drawing position
int logoX = screenWidth - MeasureText("Physac", 30) - 10;
int logoY = 15;
// Initialize physics and default physics bodies
InitPhysics();
// Create floor rectangle physics body
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, screenWidth, 100, 10);
floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
floor->restitution = 1;
// Create circles physics body
PhysicsBody circleA = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.25f, screenHeight/2 }, 30, 10);
circleA->restitution = 0;
PhysicsBody circleB = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.5f, screenHeight/2 }, 30, 10);
circleB->restitution = 0.5f;
PhysicsBody circleC = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.75f, screenHeight/2 }, 30, 10);
circleC->restitution = 1;
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed('R')) // Reset physics input
{
// Reset circles physics bodies position and velocity
circleA->position = (Vector2){ screenWidth*0.25f, screenHeight/2 };
circleA->velocity = (Vector2){ 0, 0 };
circleB->position = (Vector2){ screenWidth*0.5f, screenHeight/2 };
circleB->velocity = (Vector2){ 0, 0 };
circleC->position = (Vector2){ screenWidth*0.75f, screenHeight/2 };
circleC->velocity = (Vector2){ 0, 0 };
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(BLACK);
DrawFPS(screenWidth - 90, screenHeight - 30);
// Draw created physics bodies
int bodiesCount = GetPhysicsBodiesCount();
for (int i = 0; i < bodiesCount; i++)
{
PhysicsBody body = GetPhysicsBody(i);
int vertexCount = GetPhysicsShapeVerticesCount(i);
for (int j = 0; j < vertexCount; j++)
{
// Get physics bodies shape vertices to draw lines
// Note: GetPhysicsShapeVertex() already calculates rotation transformations
Vector2 vertexA = GetPhysicsShapeVertex(body, j);
int jj = (((j + 1) < vertexCount) ? (j + 1) : 0); // Get next vertex or first to close the shape
Vector2 vertexB = GetPhysicsShapeVertex(body, jj);
DrawLineV(vertexA, vertexB, GREEN); // Draw a line between two vertex positions
}
}
DrawText("Restitution amount", (screenWidth - MeasureText("Restitution amount", 30))/2, 75, 30, WHITE);
DrawText("0", circleA->position.x - MeasureText("0", 20)/2, circleA->position.y - 7, 20, WHITE);
DrawText("0.5", circleB->position.x - MeasureText("0.5", 20)/2, circleB->position.y - 7, 20, WHITE);
DrawText("1", circleC->position.x - MeasureText("1", 20)/2, circleC->position.y - 7, 20, WHITE);
DrawText("Press 'R' to reset example", 10, 10, 10, WHITE);
DrawText("Physac", logoX, logoY, 30, WHITE);
DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

107
examples/physics_shatter.c Normal file
View File

@ -0,0 +1,107 @@
/*******************************************************************************************
*
* Physac - Body shatter
*
* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* The file pthreadGC2.dll is required to run the program; you can find it in 'src\external'
*
* Copyright (c) 2016 Victor Fisac
*
********************************************************************************************/
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
#include "..\src\physac.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Body shatter");
SetTargetFPS(60);
// Physac logo drawing position
int logoX = screenWidth - MeasureText("Physac", 30) - 10;
int logoY = 15;
// Initialize physics and default physics bodies
InitPhysics();
SetPhysicsGravity(0, 0);
// Create random polygon physics body to shatter
PhysicsBody body = CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed('R')) // Reset physics input
{
ResetPhysics();
// Create random polygon physics body to shatter
body = CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
}
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) // Physics shatter input
{
// Note: some values need to be stored in variables due to asynchronous changes during main thread
int count = GetPhysicsBodiesCount();
for (int i = count - 1; i >= 0; i--)
{
PhysicsBody currentBody = GetPhysicsBody(i);
if (currentBody != NULL) PhysicsShatter(currentBody, GetMousePosition(), 10/currentBody->inverseMass);
}
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(BLACK);
// Draw created physics bodies
int bodiesCount = GetPhysicsBodiesCount();
for (int i = 0; i < bodiesCount; i++)
{
PhysicsBody currentBody = GetPhysicsBody(i);
int vertexCount = GetPhysicsShapeVerticesCount(i);
for (int j = 0; j < vertexCount; j++)
{
// Get physics bodies shape vertices to draw lines
// Note: GetPhysicsShapeVertex() already calculates rotation transformations
Vector2 vertexA = GetPhysicsShapeVertex(currentBody, j);
int jj = (((j + 1) < vertexCount) ? (j + 1) : 0); // Get next vertex or first to close the shape
Vector2 vertexB = GetPhysicsShapeVertex(currentBody, jj);
DrawLineV(vertexA, vertexB, GREEN); // Draw a line between two vertex positions
}
}
DrawText("Left mouse button in polygon area to shatter body\nPress 'R' to reset example", 10, 10, 10, WHITE);
DrawText("Physac", logoX, logoY, 30, WHITE);
DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

View File

@ -0,0 +1,188 @@
info face="PixAntiqua" size=32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=2,2,2,2 spacing=2,2 outline=0
common lineHeight=32 base=27 scaleW=512 scaleH=512 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4
page id=0 file="pixantiqua_0.png"
chars count=184
char id=32 x=9 y=304 width=7 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
char id=33 x=391 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
char id=34 x=240 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
char id=35 x=468 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=36 x=152 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=37 x=176 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=38 x=303 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=39 x=495 y=266 width=8 height=36 xoffset=-3 yoffset=-2 xadvance=5 page=0 chnl=15
char id=40 x=256 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
char id=199 x=432 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=200 x=126 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=201 x=147 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=202 x=288 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=203 x=189 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=204 x=468 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
char id=205 x=486 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
char id=206 x=0 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
char id=207 x=72 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
char id=208 x=329 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=209 x=277 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=210 x=182 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=211 x=26 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=41 x=272 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
char id=42 x=288 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
char id=43 x=414 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=44 x=378 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
char id=45 x=414 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
char id=46 x=443 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
char id=47 x=392 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=48 x=485 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=49 x=450 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
char id=50 x=21 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=51 x=42 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=59 x=456 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
char id=60 x=168 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=61 x=309 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=62 x=336 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=63 x=315 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=64 x=364 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=65 x=390 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=66 x=120 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=67 x=144 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=68 x=168 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=69 x=294 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=52 x=488 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=53 x=63 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=54 x=24 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=55 x=48 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=56 x=72 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=57 x=96 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=58 x=404 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
char id=70 x=252 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=71 x=192 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=72 x=78 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=78 x=78 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=79 x=355 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=80 x=264 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=81 x=381 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=82 x=288 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=83 x=312 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=91 x=144 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
char id=92 x=108 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
char id=93 x=304 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
char id=94 x=34 y=0 width=32 height=36 xoffset=-3 yoffset=-2 xadvance=29 page=0 chnl=15
char id=95 x=231 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=96 x=442 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=97 x=408 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=98 x=432 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=99 x=210 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=84 x=336 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=85 x=360 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=86 x=0 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=87 x=68 y=0 width=30 height=36 xoffset=-3 yoffset=-2 xadvance=27 page=0 chnl=15
char id=88 x=26 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=89 x=384 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=90 x=84 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=100 x=456 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=101 x=480 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=102 x=54 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
char id=103 x=0 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=104 x=24 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=105 x=469 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
char id=106 x=18 y=266 width=16 height=36 xoffset=-8 yoffset=-2 xadvance=8 page=0 chnl=15
char id=107 x=48 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=108 x=417 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
char id=109 x=161 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15
char id=110 x=72 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=111 x=96 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=117 x=192 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=118 x=216 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=119 x=248 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15
char id=120 x=240 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=121 x=264 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=122 x=288 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=123 x=432 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
char id=124 x=365 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
char id=125 x=378 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
char id=126 x=393 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=127 x=132 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15
char id=160 x=0 y=304 width=7 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
char id=161 x=352 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
char id=162 x=351 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=163 x=336 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=165 x=360 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=167 x=384 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=169 x=433 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=170 x=224 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
char id=171 x=105 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=172 x=0 y=0 width=32 height=36 xoffset=-3 yoffset=-2 xadvance=29 page=0 chnl=15
char id=173 x=494 y=38 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
char id=174 x=52 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=175 x=52 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=176 x=126 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
char id=177 x=435 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=178 x=320 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
char id=179 x=336 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
char id=181 x=459 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=112 x=120 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=113 x=144 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=114 x=396 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
char id=115 x=168 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=116 x=36 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
char id=182 x=408 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=183 x=498 y=190 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
char id=185 x=192 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
char id=186 x=208 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
char id=187 x=477 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=191 x=456 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=192 x=407 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=193 x=234 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=194 x=416 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=195 x=156 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=196 x=130 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=197 x=104 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=198 x=190 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15
char id=212 x=0 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=213 x=338 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=214 x=312 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=215 x=357 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=216 x=286 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=217 x=456 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=218 x=480 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=219 x=0 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=220 x=24 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=221 x=48 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=222 x=260 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=223 x=72 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=224 x=96 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=225 x=120 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=226 x=144 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=227 x=168 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=228 x=192 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=229 x=216 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=230 x=219 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15
char id=231 x=372 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=73 x=90 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15
char id=74 x=216 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=75 x=240 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=76 x=273 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=77 x=100 y=0 width=30 height=36 xoffset=-3 yoffset=-2 xadvance=27 page=0 chnl=15
char id=232 x=312 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=233 x=240 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=234 x=264 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=235 x=104 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=236 x=430 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
char id=237 x=482 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
char id=238 x=160 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15
char id=239 x=176 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15
char id=240 x=128 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=241 x=200 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=242 x=224 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=243 x=248 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=244 x=272 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=245 x=296 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=246 x=320 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=247 x=330 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=248 x=208 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15
char id=249 x=344 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=250 x=368 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=251 x=416 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=252 x=440 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=253 x=464 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15
char id=254 x=0 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15
char id=255 x=0 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -7,7 +7,8 @@
* Compile example using: * Compile example using:
* gcc -o $(NAME_PART).exe $(FILE_NAME) $(RAYLIB_DIR)\raylib_icon / * gcc -o $(NAME_PART).exe $(FILE_NAME) $(RAYLIB_DIR)\raylib_icon /
* -I../src -I../src/external/lua/include -L../src/external/lua/lib / * -I../src -I../src/external/lua/include -L../src/external/lua/lib /
* -lraylib -lglfw3 -lopengl32 -lopenal32 -llua53 -lgdi32 -std=c99 * -lraylib -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -llua53 /
* -std=c99 -Wl,-allow-multiple-definition -Wl,--subsystem,windows
* *
* This example has been created using raylib 1.6 (www.raylib.com) * This example has been created using raylib 1.6 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
@ -28,7 +29,7 @@ int main()
InitLuaDevice(); InitLuaDevice();
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// ExecuteLuaFile("core_basic_window.lua"); // OK! ExecuteLuaFile("core_basic_window.lua"); // OK!
// ExecuteLuaFile("core_input_keys.lua"); // OK! // ExecuteLuaFile("core_input_keys.lua"); // OK!
// ExecuteLuaFile("core_input_mouse.lua"); // OK! // ExecuteLuaFile("core_input_mouse.lua"); // OK!
// ExecuteLuaFile("core_mouse_wheel.lua"); // OK! // ExecuteLuaFile("core_mouse_wheel.lua"); // OK!
@ -65,6 +66,8 @@ int main()
// ExecuteLuaFile("text_format_text.lua"); // OK! NOTE: Use lua string.format() instead of raylib FormatText() // ExecuteLuaFile("text_format_text.lua"); // OK! NOTE: Use lua string.format() instead of raylib FormatText()
// ExecuteLuaFile("text_font_select.lua"); // OK! // ExecuteLuaFile("text_font_select.lua"); // OK!
// ExecuteLuaFile("text_writing_anim.lua"); // OK! // ExecuteLuaFile("text_writing_anim.lua"); // OK!
// ExecuteLuaFile("text_ttf_loading.lua"); // ISSUE: Attempt to index a SpriteFont value (local 'font')
// ExecuteLuaFile("text_bmfont_unordered.lua"); // OK!
// ExecuteLuaFile("models_geometric_shapes.lua"); // OK! // ExecuteLuaFile("models_geometric_shapes.lua"); // OK!
// ExecuteLuaFile("models_box_collisions.lua"); // OK! // ExecuteLuaFile("models_box_collisions.lua"); // OK!
// ExecuteLuaFile("models_billboard.lua"); // OK! // ExecuteLuaFile("models_billboard.lua"); // OK!
@ -80,7 +83,7 @@ int main()
// ExecuteLuaFile("audio_music_stream.lua"); // OK! // ExecuteLuaFile("audio_music_stream.lua"); // OK!
// ExecuteLuaFile("audio_module_playing.lua"); // OK! // ExecuteLuaFile("audio_module_playing.lua"); // OK!
// ExecuteLuaFile("audio_raw_stream.lua"); // ERROR: UpdateAudioStream() // ExecuteLuaFile("audio_raw_stream.lua"); // ERROR: UpdateAudioStream()
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseLuaDevice(); // Close Lua device and free resources CloseLuaDevice(); // Close Lua device and free resources

View File

@ -47,15 +47,13 @@ local swirlCenter = { screenWidth/2, screenHeight/2 }
local target = LoadRenderTexture(screenWidth, screenHeight) local target = LoadRenderTexture(screenWidth, screenHeight)
-- Setup orbital camera -- Setup orbital camera
SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode SetCameraMode(camera, CameraMode.ORBITAL) -- Set an orbital camera mode
SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
SetCameraTarget(camera.target) -- Set internal camera target to match our camera target
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
-- Main game loop -- Main game loop
while not WindowShouldClose() do -- Detect window close button or ESC key while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update -- Update
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
local mousePosition = GetMousePosition() local mousePosition = GetMousePosition()
@ -66,7 +64,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC key
-- Send new value to the shader to be used on drawing -- Send new value to the shader to be used on drawing
SetShaderValue(shader, swirlCenterLoc, swirlCenter) SetShaderValue(shader, swirlCenterLoc, swirlCenter)
camera = UpdateCamera(camera) -- Update internal camera and our camera camera = UpdateCamera(camera) -- Update camera
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
-- Draw -- Draw
@ -75,13 +73,13 @@ while not WindowShouldClose() do -- Detect window close button or ESC key
ClearBackground(RAYWHITE) ClearBackground(RAYWHITE)
BeginTextureMode(target) -- Enable drawing to texture BeginTextureMode(target) -- Enable drawing to texture
Begin3dMode(camera) Begin3dMode(camera)
DrawModel(dwarf, position, 2.0, WHITE) -- Draw 3d model with texture DrawModel(dwarf, position, 2.0, WHITE) -- Draw 3d model with texture
DrawGrid(10, 1.0) -- Draw a grid DrawGrid(10, 1.0) -- Draw a grid
End3dMode() End3dMode()

View File

@ -42,7 +42,7 @@ int main()
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
SetCameraMode(camera, CAMERA_FREE); // Set an orbital camera mode SetCameraMode(camera, CAMERA_FREE); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -52,7 +52,7 @@ int main()
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); // Update internal camera and our camera UpdateCamera(&camera); // Update camera
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View File

@ -39,9 +39,7 @@ dwarf.material.texDiffuse = texture -- Bind texture to model
local position = Vector3(0.0, 0.0, 0.0) -- Set model position local position = Vector3(0.0, 0.0, 0.0) -- Set model position
-- Setup orbital camera -- Setup orbital camera
SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode SetCameraMode(camera, CameraMode.ORBITAL) -- Set an orbital camera mode
SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
SetCameraTarget(camera.target) -- Set internal camera target to match our camera target
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
@ -50,7 +48,7 @@ SetTargetFPS(60) -- Set our game to run at 60 frames-pe
while not WindowShouldClose() do -- Detect window close button or ESC key while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update -- Update
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
camera = UpdateCamera(camera) -- Update internal camera and our camera camera = UpdateCamera(camera) -- Update camera
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
-- Draw -- Draw

View File

@ -41,18 +41,16 @@ local shader = LoadShader("resources/shaders/glsl330/base.vs",
local target = LoadRenderTexture(screenWidth, screenHeight) local target = LoadRenderTexture(screenWidth, screenHeight)
-- Setup orbital camera -- Setup orbital camera
SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode SetCameraMode(camera, CameraMode.ORBITAL) -- Set an orbital camera mode
SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
SetCameraTarget(camera.target) -- Set internal camera target to match our camera target
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
-- Main game loop -- Main game loop
while not WindowShouldClose() do -- Detect window close button or ESC key while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update -- Update
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
camera = UpdateCamera(camera) -- Update internal camera and our camera camera = UpdateCamera(camera) -- Update camera
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
-- Draw -- Draw

View File

@ -60,18 +60,16 @@ pointLight.diffuse = Color(100, 100, 255, 255)
pointLight.radius = 3.0 pointLight.radius = 3.0
-- Setup orbital camera -- Setup orbital camera
SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode SetCameraMode(camera, CameraMode.ORBITAL) -- Set an orbital camera mode
SetCameraPosition(camera.position) -- Set internal camera position to match our camera position
SetCameraTarget(camera.target) -- Set internal camera target to match our camera target
SetTargetFPS(60) -- Set our game to run at 60 frames-per-second SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
-- Main game loop -- Main game loop
while not WindowShouldClose() do -- Detect window close button or ESC key while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update -- Update
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
camera = UpdateCamera(camera) -- Update internal camera and our camera camera = UpdateCamera(camera) -- Update camera
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
-- Draw -- Draw

View File

@ -0,0 +1,65 @@
/*******************************************************************************************
*
* raylib [text] example - BMFont unordered chars loading and drawing
*
* This example has been created using raylib 1.4 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2016 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont unordered loading and drawing");
// NOTE: Using chars outside the [32..127] limits!
// NOTE: If a character is not found in the font, it just renders a space
const char msg[256] = "ASCII extended characters:\n¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆ\nÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæ\nçèéêëìíîïðñòóôõö÷øùúûüýþÿ";
// NOTE: Loaded font has an unordered list of characters (chars in the range 32..255)
SpriteFont font = LoadSpriteFont("resources/fonts/pixantiqua.fnt"); // BMFont (AngelCode)
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update variables here...
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Font name: PixAntiqua", 40, 50, 20, GRAY);
DrawText(FormatText("Font base size: %i", font.size), 40, 80, 20, GRAY);
DrawText(FormatText("Font chars number: %i", font.numChars), 40, 110, 20, GRAY);
DrawTextEx(font, msg, (Vector2){ 40, 180 }, font.size, 0, MAROON);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadSpriteFont(font); // AngelCode SpriteFont unloading
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@ -0,0 +1,57 @@
-------------------------------------------------------------------------------------------
--
-- raylib [text] example - BMFont unordered chars loading and drawing
--
-- This example has been created using raylib 1.6 (www.raylib.com)
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
--
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
--
-------------------------------------------------------------------------------------------
-- Initialization
-------------------------------------------------------------------------------------------
local screenWidth = 800
local screenHeight = 450
InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont unordered loading and drawing")
-- NOTE: Using chars outside the [32..127] limits!
-- NOTE: If a character is not found in the font, it just renders a space
local msg = "ASCII extended characters:\n¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆ\nÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæ\nçèéêëìíîïðñòóôõö÷øùúûüýþÿ"
-- NOTE: Loaded font has an unordered list of characters (chars in the range 32..255)
local font = LoadSpriteFont("resources/fonts/pixantiqua.fnt") -- BMFont (AngelCode)
SetTargetFPS(60)
-------------------------------------------------------------------------------------------
-- Main game loop
while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update
---------------------------------------------------------------------------------------
-- TODO: Update variables here...
---------------------------------------------------------------------------------------
-- Draw
---------------------------------------------------------------------------------------
BeginDrawing()
ClearBackground(RAYWHITE)
DrawText("Font name: PixAntiqua", 40, 50, 20, GRAY)
DrawText(string.format("Font base size: %i", font.size), 40, 80, 20, GRAY)
DrawText(string.format("Font chars number: %i", font.numChars), 40, 110, 20, GRAY)
DrawTextEx(font, msg, Vector2(40, 180), font.size, 0, MAROON)
EndDrawing()
---------------------------------------------------------------------------------------
end
-- De-Initialization
-------------------------------------------------------------------------------------------
UnloadSpriteFont(font) -- AngelCode SpriteFont unloading
CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

130
examples/text_ttf_loading.c Normal file
View File

@ -0,0 +1,130 @@
/*******************************************************************************************
*
* raylib [text] example - TTF loading and usage
*
* 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)
*
* Copyright (c) 2015 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - ttf loading");
const char msg[50] = "TTF SpriteFont";
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
// TTF SpriteFont loading with custom generation parameters
SpriteFont font = LoadSpriteFontTTF("resources/fonts/KAISG.ttf", 96, 0, 0);
// Generate mipmap levels to use trilinear filtering
// NOTE: On 2D drawing it won't be noticeable, it looks like FILTER_BILINEAR
GenTextureMipmaps(&font.texture);
float fontSize = font.size;
Vector2 fontPosition = { 40, screenHeight/2 + 50 };
Vector2 textSize;
SetTextureFilter(font.texture, FILTER_POINT);
int currentFontFilter = 0; // FILTER_POINT
int count = 0;
char **droppedFiles;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
fontSize += GetMouseWheelMove()*4.0f;
// Choose font texture filter method
if (IsKeyPressed(KEY_ONE))
{
SetTextureFilter(font.texture, FILTER_POINT);
currentFontFilter = 0;
}
else if (IsKeyPressed(KEY_TWO))
{
SetTextureFilter(font.texture, FILTER_BILINEAR);
currentFontFilter = 1;
}
else if (IsKeyPressed(KEY_THREE))
{
// NOTE: Trilinear filter won't be noticed on 2D drawing
SetTextureFilter(font.texture, FILTER_TRILINEAR);
currentFontFilter = 2;
}
textSize = MeasureTextEx(font, msg, fontSize, 0);
if (IsKeyDown(KEY_LEFT)) fontPosition.x -= 10;
else if (IsKeyDown(KEY_RIGHT)) fontPosition.x += 10;
// Load a dropped TTF file dynamically (at current fontSize)
if (IsFileDropped())
{
droppedFiles = GetDroppedFiles(&count);
if (count == 1) // Only support one ttf file dropped
{
UnloadSpriteFont(font);
font = LoadSpriteFontTTF(droppedFiles[0], fontSize, 0, 0);
ClearDroppedFiles();
}
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Use mouse wheel to change font size", 20, 20, 10, GRAY);
DrawText("Use KEY_RIGHT and KEY_LEFT to move text", 20, 40, 10, GRAY);
DrawText("Use 1, 2, 3 to change texture filter", 20, 60, 10, GRAY);
DrawText("Drop a new TTF font for dynamic loading", 20, 80, 10, DARKGRAY);
DrawTextEx(font, msg, fontPosition, fontSize, 0, BLACK);
// TODO: It seems texSize measurement is not accurate due to chars offsets...
//DrawRectangleLines(fontPosition.x, fontPosition.y, textSize.x, textSize.y, RED);
DrawRectangle(0, screenHeight - 80, screenWidth, 80, LIGHTGRAY);
DrawText(FormatText("Font size: %02.02f", fontSize), 20, screenHeight - 50, 10, DARKGRAY);
DrawText(FormatText("Text size: [%02.02f, %02.02f]", textSize.x, textSize.y), 20, screenHeight - 30, 10, DARKGRAY);
DrawText("CURRENT TEXTURE FILTER:", 250, 400, 20, GRAY);
if (currentFontFilter == 0) DrawText("POINT", 570, 400, 20, BLACK);
else if (currentFontFilter == 1) DrawText("BILINEAR", 570, 400, 20, BLACK);
else if (currentFontFilter == 2) DrawText("TRILINEAR", 570, 400, 20, BLACK);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadSpriteFont(font); // SpriteFont unloading
ClearDroppedFiles(); // Clear internal buffers
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@ -0,0 +1,118 @@
-------------------------------------------------------------------------------------------
--
-- raylib [text] example - TTF loading and usage
--
-- This example has been created using raylib 1.6 (www.raylib.com)
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
--
-- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
--
-------------------------------------------------------------------------------------------
-- Initialization
-------------------------------------------------------------------------------------------
local screenWidth = 800;
local screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - ttf loading")
local msg = "TTF SpriteFont"
-- NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
-- TTF SpriteFont loading with custom generation parameters
local font = LoadSpriteFontTTF("resources/fonts/KAISG.ttf", 96, 0, 0)
-- Generate mipmap levels to use trilinear filtering
-- NOTE: On 2D drawing it won't be noticeable, it looks like FILTER_BILINEAR
--font.texture = GenTextureMipmaps(font.texture) -- ISSUE: attempt to index a SpriteFont value (local 'font')
local fontSize = font.size
local fontPosition = Vector2(40, screenHeight/2 + 50)
local textSize
SetTextureFilter(font.texture, TextureFilter.POINT)
local currentFontFilter = 0 -- Default: FILTER_POINT
local count = 0
local droppedFiles
SetTargetFPS(60)
-------------------------------------------------------------------------------------------
-- Main game loop
while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update
---------------------------------------------------------------------------------------
fontSize = fontSize + GetMouseWheelMove()*4.0
-- Choose font texture filter method
if (IsKeyPressed(KEY.ONE)) then
SetTextureFilter(font.texture, TextureFilter.POINT)
currentFontFilter = 0
elseif (IsKeyPressed(KEY.TWO)) then
SetTextureFilter(font.texture, TextureFilter.BILINEAR)
currentFontFilter = 1
elseif (IsKeyPressed(KEY.THREE)) then
-- NOTE: Trilinear filter won't be noticed on 2D drawing
SetTextureFilter(font.texture, TextureFilter.TRILINEAR)
currentFontFilter = 2
end
textSize = MeasureTextEx(font, msg, fontSize, 0)
if (IsKeyDown(KEY.LEFT)) then fontPosition.x = fontPosition.x - 10
elseif (IsKeyDown(KEY.RIGHT)) then fontPosition.x = fontPosition.x + 10
end
-- Load a dropped TTF file dynamically (at current fontSize)
if (IsFileDropped()) then
droppedFiles = GetDroppedFiles()
count = #droppedFiles
if (count == 1) then -- Only support one ttf file dropped
UnloadSpriteFont(font)
font = LoadSpriteFontTTF(droppedFiles[1], fontSize, 0, 0)
ClearDroppedFiles()
end
end
---------------------------------------------------------------------------------------
-- Draw
---------------------------------------------------------------------------------------
BeginDrawing()
ClearBackground(RAYWHITE)
DrawText("Use mouse wheel to change font size", 20, 20, 10, GRAY)
DrawText("Use KEY_RIGHT and KEY_LEFT to move text", 20, 40, 10, GRAY)
DrawText("Use 1, 2, 3 to change texture filter", 20, 60, 10, GRAY)
DrawText("Drop a new TTF font for dynamic loading", 20, 80, 10, DARKGRAY)
DrawTextEx(font, msg, fontPosition, fontSize, 0, BLACK)
-- TODO: It seems texSize measurement is not accurate due to chars offsets...
--DrawRectangleLines(fontPosition.x, fontPosition.y, textSize.x, textSize.y, RED)
DrawRectangle(0, screenHeight - 80, screenWidth, 80, LIGHTGRAY)
DrawText(string.format("Font size: %02.02f", fontSize), 20, screenHeight - 50, 10, DARKGRAY)
DrawText(string.format("Text size: [%02.02f, %02.02f]", textSize.x, textSize.y), 20, screenHeight - 30, 10, DARKGRAY)
DrawText("CURRENT TEXTURE FILTER:", 250, 400, 20, GRAY)
if (currentFontFilter == 0) then DrawText("POINT", 570, 400, 20, BLACK)
elseif (currentFontFilter == 1) then DrawText("BILINEAR", 570, 400, 20, BLACK)
elseif (currentFontFilter == 2) then DrawText("TRILINEAR", 570, 400, 20, BLACK)
end
EndDrawing()
---------------------------------------------------------------------------------------
end
-- De-Initialization
-------------------------------------------------------------------------------------------
UnloadSpriteFont(font) -- SpriteFont unloading
ClearDroppedFiles() -- Clear internal buffers
CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -112,8 +112,10 @@ 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 -pthread -ldl
endif # on XWindow could require also below libraries, just uncomment
#LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
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
# requires the following packages: # requires the following packages:
@ -124,6 +126,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# 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
endif endif
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# libraries for Raspberry Pi compiling # libraries for Raspberry Pi compiling

View File

@ -117,8 +117,10 @@ 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 -pthread -ldl
endif # on XWindow could require also below libraries, just uncomment
#LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
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
# requires the following packages: # requires the following packages:
@ -129,6 +131,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# 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
endif endif
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# libraries for Raspberry Pi compiling # libraries for Raspberry Pi compiling

View File

@ -117,7 +117,7 @@ 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 -lglfw3 -lGLEW -lGL -lopenal -lm -pthread 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

View File

@ -114,8 +114,10 @@ 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 -pthread -ldl
endif # on XWindow could require also below libraries, just uncomment
#LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
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
# requires the following packages: # requires the following packages:
@ -126,6 +128,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# 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
endif endif
endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# libraries for Raspberry Pi compiling # libraries for Raspberry Pi compiling

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,32 +0,0 @@
cmake_minimum_required (VERSION 3.0)
project (raylib)
SET(PLATFORM_TO_USE "PLATFORM_DESKTOP" CACHE STRING "Platform to compile for")
SET_PROPERTY(CACHE PLATFORM_TO_USE PROPERTY STRINGS PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB)
set(CMAKE_C_FLAGS "-O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces")
IF(${PLATFORM_TO_USE} MATCHES "PLATFORM_DESKTOP")
add_definitions(-DPLATFORM_DESKTOP, -DGRAPHICS_API_OPENGL_33)
include_directories("." "external/" "external/openal_soft/include" "external/glfw3/include")
ENDIF()
IF(${PLATFORM_TO_USE} MATCHES "PLATFORM_RPI")
add_definitions(-DPLATFORM_RPI, -GRAPHICS_API_OPENGL_ES2)
include_directories("." "external/" "/opt/vc/include" "/opt/vc/include/interface/vmcs_host/linux" "/opt/vc/include/interface/vcos/pthreads")
ENDIF()
IF(${PLATFORM_TO_USE} MATCHES "PLATFORM_WEB")
add_definitions(-DPLATFORM_WEB, -GRAPHICS_API_OPENGL_ES2)
include_directories("." "external/" "external/openal_soft/include" "external/glfw3/include")
ENDIF()
file(GLOB SOURCES "*.c" "external/*.c")
add_library(raylib STATIC ${SOURCES})
install(TARGETS raylib DESTINATION ../lib/)

View File

@ -38,6 +38,14 @@ PLATFORM ?= PLATFORM_DESKTOP
# define YES if you want shared/dynamic version of library instead of static (default) # define YES if you want shared/dynamic version of library instead of static (default)
SHARED ?= NO SHARED ?= NO
# define NO to use OpenAL Soft as static library (or shared by default)
SHARED_OPENAL ?= YES
# on PLATFORM_WEB force OpenAL Soft shared library
ifeq ($(PLATFORM),PLATFORM_WEB)
SHARED_OPENAL ?= YES
endif
# determine if the file has root access (only for installing raylib) # determine if the file has root access (only for installing raylib)
# "whoami" prints the name of the user that calls him (so, if it is the root # "whoami" prints the name of the user that calls him (so, if it is the root
# user, "whoami" prints "root"). # user, "whoami" prints "root").
@ -99,11 +107,20 @@ CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces
ifeq ($(SHARED),YES) ifeq ($(SHARED),YES)
CFLAGS += -fPIC CFLAGS += -fPIC
SHAREDFLAG = BUILDING_DLL SHAREDFLAG = BUILDING_DLL
SHAREDLIBS = -Lexternal/glfw3/lib/win32 -Lexternal/openal_soft/lib/win32 -lglfw3 -lopenal32 -lgdi32 SHAREDLIBS = -Lexternal/glfw3/lib/win32 -Lexternal/openal_soft/lib/win32 -lglfw3 -lgdi32
else else
SHAREDFLAG = BUILDING_STATIC SHAREDFLAG = BUILDING_STATIC
endif endif
# if static OpenAL Soft required, define the corresponding flags
ifeq ($(SHARED_OPENAL),NO)
SHAREDLIBS += -lopenal32 -lwinmm
SHAREDOPENALFLAG = AL_LIBTYPE_STATIC
else
SHAREDLIBS += -lopenal32dll
SHAREDOPENALFLAG = SHARED_OPENAL
endif
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes #CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
# define any directories containing required header files # define any directories containing required header files
@ -165,12 +182,17 @@ else
endif endif
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
$(CC) -shared -o $(OUTPUT_PATH)/raylib.dll $(OBJS) $(SHAREDLIBS) -Wl,--out-implib,$(OUTPUT_PATH)/libraylibdll.a $(CC) -shared -o $(OUTPUT_PATH)/raylib.dll $(OBJS) $(SHAREDLIBS) -Wl,--out-implib,$(OUTPUT_PATH)/libraylibdll.a
@echo "raylib dynamic library (raylib.dll) and MSVC required import library (libraylibdll.a) generated!" @echo "raylib dynamic library (raylib.dll) and import library (libraylibdll.a) generated!"
endif endif
else else
# compile raylib static library for desktop platforms. # compile raylib static library for desktop platforms.
ar rcs $(OUTPUT_PATH)/libraylib.a $(OBJS) ar rcs $(OUTPUT_PATH)/libraylib.a $(OBJS)
@echo "libraylib.a generated (static library)!" @echo "libraylib.a generated (static library)!"
ifeq ($(SHARED_OPENAL),NO)
@echo "expected OpenAL Soft static library linking"
else
@echo "expected OpenAL Soft shared library linking"
endif
endif endif
endif endif
@ -202,7 +224,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) $(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

View File

@ -2,18 +2,22 @@
* *
* raylib.audio * raylib.audio
* *
* Basic functions to manage Audio: * This module provides basic functionality to work with audio:
* Manage audio device (init/close) * Manage audio device (init/close)
* Load and Unload audio files * Load and Unload audio files (WAV, OGG, FLAC, XM, MOD)
* Play/Stop/Pause/Resume loaded audio * Play/Stop/Pause/Resume loaded audio
* Manage mixing channels * Manage mixing channels
* Manage raw audio context * Manage raw audio context
* *
* Uses external lib: * External libs:
* OpenAL Soft - Audio device management lib (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
* jar_mod - MOD audio file loading * jar_mod - MOD audio file loading
* dr_flac - FLAC audio file loading
*
* Module Configuration Flags:
* AUDIO_STANDALONE - Use this module as standalone library (independently of raylib)
* *
* Many thanks to Joshua Reisenauer (github: @kd7tck) for the following additions: * Many thanks to Joshua Reisenauer (github: @kd7tck) for the following additions:
* XM audio module support (jar_xm) * XM audio module support (jar_xm)
@ -21,6 +25,7 @@
* Mixing channels support * Mixing channels support
* Raw audio context support * Raw audio context support
* *
*
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-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
@ -44,8 +49,11 @@
#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()
#else #else
#include "raylib.h" #include "raylib.h"
#include "utils.h" // Required for: DecompressData()
// NOTE: Includes Android fopen() function map
#endif #endif
#include "AL/al.h" // OpenAL basic header #include "AL/al.h" // OpenAL basic header
@ -63,13 +71,6 @@
#define AL_FORMAT_STEREO_FLOAT32 0x10011 #define AL_FORMAT_STEREO_FLOAT32 0x10011
#endif #endif
#if defined(AUDIO_STANDALONE)
#include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end()
#else
#include "utils.h" // Required for: DecompressData()
// NOTE: Includes Android fopen() function map
#endif
//#define STB_VORBIS_HEADER_ONLY //#define STB_VORBIS_HEADER_ONLY
#include "external/stb_vorbis.h" // OGG loading functions #include "external/stb_vorbis.h" // OGG loading functions
@ -117,7 +118,7 @@ typedef struct MusicData {
bool loop; // Repeat music after finish (loop) bool loop; // Repeat music after finish (loop)
unsigned int totalSamples; // Total number of samples unsigned int totalSamples; // Total number of samples
unsigned int samplesLeft; // Number of samples left to end unsigned int samplesLeft; // Number of samples left to end
} MusicData, *Music; } MusicData;
#if defined(AUDIO_STANDALONE) #if defined(AUDIO_STANDALONE)
typedef enum { INFO = 0, ERROR, WARNING, DEBUG, OTHER } TraceLogType; typedef enum { INFO = 0, ERROR, WARNING, DEBUG, OTHER } TraceLogType;

View File

@ -2,18 +2,19 @@
* *
* raylib.audio * raylib.audio
* *
* Basic functions to manage Audio: * This module provides basic functionality to work with audio:
* Manage audio device (init/close) * Manage audio device (init/close)
* Load and Unload audio files * Load and Unload audio files (WAV, OGG, FLAC, XM, MOD)
* Play/Stop/Pause/Resume loaded audio * Play/Stop/Pause/Resume loaded audio
* Manage mixing channels * Manage mixing channels
* Manage raw audio context * Manage raw audio context
* *
* Uses external lib: * External libs:
* OpenAL Soft - Audio device management lib (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
* jar_mod - MOD audio file loading * jar_mod - MOD audio file loading
* dr_flac - FLAC audio file loading
* *
* Many thanks to Joshua Reisenauer (github: @kd7tck) for the following additions: * Many thanks to Joshua Reisenauer (github: @kd7tck) for the following additions:
* XM audio module support (jar_xm) * XM audio module support (jar_xm)
@ -21,6 +22,7 @@
* Mixing channels support * Mixing channels support
* Raw audio context support * Raw audio context support
* *
*
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-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
@ -60,12 +62,6 @@
#endif #endif
#endif #endif
// Sound source type
typedef struct Sound {
unsigned int source; // Sound audio source id
unsigned int buffer; // Sound audio buffer id
} Sound;
// Wave type, defines audio wave data // Wave type, defines audio wave data
typedef struct Wave { typedef struct Wave {
unsigned int sampleCount; // Number of samples unsigned int sampleCount; // Number of samples
@ -75,9 +71,16 @@ typedef struct Wave {
void *data; // Buffer data pointer void *data; // Buffer data pointer
} Wave; } Wave;
// Sound source type
typedef struct Sound {
unsigned int source; // OpenAL audio source id
unsigned int buffer; // OpenAL audio buffer id
int format; // OpenAL audio format specifier
} Sound;
// Music type (file streaming from memory) // Music type (file streaming from memory)
// NOTE: Anything longer than ~10 seconds should be streamed // NOTE: Anything longer than ~10 seconds should be streamed
typedef struct Music *Music; typedef struct MusicData *Music;
// Audio stream type // Audio stream type
// NOTE: Useful to create custom audio streams not bound to a specific file // NOTE: Useful to create custom audio streams not bound to a specific file
@ -104,13 +107,16 @@ extern "C" { // Prevents name mangling of functions
// Module Functions Declaration // Module Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
void InitAudioDevice(void); // Initialize audio device and context void InitAudioDevice(void); // Initialize audio device and context
void CloseAudioDevice(void); // Close the audio device and context (and music stream) void CloseAudioDevice(void); // Close the audio device and context
bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully
Sound LoadSound(char *fileName); // Load sound to memory Wave LoadWave(const char *fileName); // Load wave data from file into RAM
Wave LoadWaveEx(float *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from float array data (32bit)
Sound LoadSound(const char *fileName); // Load sound to memory
Sound LoadSoundFromWave(Wave wave); // Load sound to memory from wave data Sound LoadSoundFromWave(Wave wave); // Load sound to memory from wave data
Sound LoadSoundFromRES(const char *rresName, int resId); // Load sound to memory from rRES file (raylib Resource) Sound LoadSoundFromRES(const char *rresName, int resId); // Load sound to memory from rRES file (raylib Resource)
void UpdateSound(Sound sound, void *data, int numSamples); // Update sound buffer with new data void UpdateSound(Sound sound, void *data, int numSamples); // Update sound buffer with new data
void UnloadWave(Wave wave); // Unload wave data
void UnloadSound(Sound sound); // Unload sound void UnloadSound(Sound sound); // Unload sound
void PlaySound(Sound sound); // Play a sound void PlaySound(Sound sound); // Play a sound
void PauseSound(Sound sound); // Pause a sound void PauseSound(Sound sound); // Pause a sound
@ -119,12 +125,15 @@ void StopSound(Sound sound); // Stop playing
bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing
void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level) void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level)
void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level) void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)
void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format
Music LoadMusicStream(char *fileName); // Load music stream from file Wave WaveCopy(Wave wave); // Copy a wave to a new wave
void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range
float *GetWaveData(Wave wave); // Get samples data from wave as a floats array
Music LoadMusicStream(const char *fileName); // Load music stream from file
void UnloadMusicStream(Music music); // Unload music stream void UnloadMusicStream(Music music); // Unload music stream
void PlayMusicStream(Music music); // Start music playing (open stream) void PlayMusicStream(Music music); // Start music playing
void UpdateMusicStream(Music music); // Updates buffers for music streaming void UpdateMusicStream(Music music); // Updates buffers for music streaming
void StopMusicStream(Music music); // Stop music playing (close stream) void StopMusicStream(Music music); // Stop music playing
void PauseMusicStream(Music music); // Pause music playing void PauseMusicStream(Music music); // Pause music playing
void ResumeMusicStream(Music music); // Resume playing paused music void ResumeMusicStream(Music music); // Resume playing paused music
bool IsMusicPlaying(Music music); // Check if music is playing bool IsMusicPlaying(Music music); // Check if music is playing
@ -133,9 +142,9 @@ void SetMusicPitch(Music music, float pitch); // Set pitch for
float GetMusicTimeLength(Music music); // Get music time length (in seconds) float GetMusicTimeLength(Music music); // Get music time length (in seconds)
float GetMusicTimePlayed(Music music); // Get current music time played (in seconds) float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
AudioStream InitAudioStream(unsigned int sampleRate, AudioStream InitAudioStream(unsigned int sampleRate,
unsigned int sampleSize, unsigned int sampleSize,
unsigned int channels); // Init audio stream (to stream audio pcm data) unsigned int channels); // Init audio stream (to stream raw audio pcm data)
void UpdateAudioStream(AudioStream stream, void *data, int numSamples); // Update audio stream buffers with data void UpdateAudioStream(AudioStream stream, void *data, int numSamples); // 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

View File

@ -4,24 +4,25 @@
* *
* Basic functions to manage windows, OpenGL context and input on multiple platforms * Basic functions to manage windows, OpenGL context and input on multiple platforms
* *
* The following platforms are supported: * The following platforms are supported: Windows, Linux, Mac (OSX), Android, Raspberry Pi, HTML5, Oculus Rift CV1
* PLATFORM_DESKTOP - Windows, Linux, Mac (OSX)
* PLATFORM_ANDROID - Only OpenGL ES 2.0 devices
* PLATFORM_RPI - Rapsberry Pi (tested on Raspbian)
* PLATFORM_WEB - Emscripten, HTML5
* Oculus Rift CV1 (with desktop mirror) - View [rlgl] module to enable it
* *
* On PLATFORM_DESKTOP, the external lib GLFW3 (www.glfw.com) is used to manage graphic * External libs:
* device, OpenGL context and input on multiple operating systems (Windows, Linux, OSX). * GLFW3 - Manage graphic device, OpenGL context and inputs on PLATFORM_DESKTOP (Windows, Linux, OSX)
* * raymath - 3D math functionality (Vector3, Matrix, Quaternion)
* On PLATFORM_ANDROID, graphic device is managed by EGL and input system by Android activity. * camera - Multiple 3D camera modes (free, orbital, 1st person, 3rd person)
* * gestures - Gestures system for touch-ready devices (or simulated from mouse inputs)
* On PLATFORM_RPI, graphic device is managed by EGL and input system is coded in raw mode.
* *
* Module Configuration Flags: * Module Configuration Flags:
* PLATFORM_DESKTOP - Windows, Linux, Mac (OSX)
* PLATFORM_ANDROID - Android (only OpenGL ES 2.0 devices), graphic device is managed by EGL and input system by Android activity.
* PLATFORM_RPI - Rapsberry Pi (tested on Raspbian), graphic device is managed by EGL and input system is coded in raw mode.
* PLATFORM_WEB - HTML5 (using emscripten compiler)
* *
* RL_LOAD_DEFAULT_FONT - Use external module functions to load default raylib font (module: text) * RL_LOAD_DEFAULT_FONT - Use external module functions to load default raylib font (module: text)
* *
* NOTE: Oculus Rift CV1 requires PLATFORM_DESKTOP for render mirror - View [rlgl] module to enable it
*
*
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-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
@ -667,7 +668,7 @@ void Begin3dMode(Camera camera)
{ {
rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2) rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2)
if (IsVrDeviceReady()) BeginVrDrawing(); if (IsVrDeviceReady() || IsVrSimulator()) BeginVrDrawing();
rlMatrixMode(RL_PROJECTION); // Switch to projection matrix rlMatrixMode(RL_PROJECTION); // Switch to projection matrix
@ -697,7 +698,7 @@ void End3dMode(void)
{ {
rlglDraw(); // Process internal buffers (update + draw) rlglDraw(); // Process internal buffers (update + draw)
if (IsVrDeviceReady()) EndVrDrawing(); 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
@ -1174,12 +1175,14 @@ bool IsGamepadAvailable(int gamepad)
bool IsGamepadName(int gamepad, const char *name) bool IsGamepadName(int gamepad, const char *name)
{ {
bool result = false; bool result = false;
#if !defined(PLATFORM_ANDROID)
const char *gamepadName = NULL; const char *gamepadName = NULL;
if (gamepadReady[gamepad]) gamepadName = GetGamepadName(gamepad); if (gamepadReady[gamepad]) gamepadName = GetGamepadName(gamepad);
if ((name != NULL) && (gamepadName != NULL)) result = (strcmp(name, gamepadName) == 0); if ((name != NULL) && (gamepadName != NULL)) result = (strcmp(name, gamepadName) == 0);
#endif
return result; return result;
} }
@ -1975,7 +1978,11 @@ static void PollInputEvents(void)
previousMouseWheelY = currentMouseWheelY; previousMouseWheelY = currentMouseWheelY;
currentMouseWheelY = 0; currentMouseWheelY = 0;
#endif
// NOTE: GLFW3 joystick functionality not available in web
// TODO: Support joysticks using emscripten API
#if defined(PLATFORM_DESKTOP)
// Check if gamepads are ready // Check if gamepads are ready
// NOTE: We do it here in case of disconection // NOTE: We do it here in case of disconection
for (int i = 0; i < MAX_GAMEPADS; i++) for (int i = 0; i < MAX_GAMEPADS; i++)

View File

@ -390,7 +390,7 @@ publish, and distribute this file as you see fit.
#define STBI_NO_HDR // RaySan: not required by raylib #define STBI_NO_HDR // RaySan: not required by raylib
#define STBI_NO_SIMD // RaySan: issues when compiling with GCC 4.7.2 //#define STBI_NO_SIMD // RaySan: issues when compiling with GCC 4.7.2
#ifndef STBI_NO_STDIO #ifndef STBI_NO_STDIO
#include <stdio.h> #include <stdio.h>
@ -398,7 +398,7 @@ publish, and distribute this file as you see fit.
// NOTE: Added to work with raylib on Android // NOTE: Added to work with raylib on Android
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
#include "utils.h" // Android fopen function map #include "utils.h" // RaySan: Android fopen function map
#endif #endif
#define STBI_VERSION 1 #define STBI_VERSION 1

View File

@ -4,6 +4,12 @@
* *
* Basic functions to draw 3d shapes and load/draw 3d models (.OBJ) * Basic functions to draw 3d shapes and load/draw 3d models (.OBJ)
* *
* External libs:
* rlgl - raylib OpenGL abstraction layer
*
* Module Configuration Flags:
* ...
*
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-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
@ -34,8 +40,7 @@
#include <string.h> // Required for: strcmp() #include <string.h> // Required for: strcmp()
#include <math.h> // Required for: sin(), cos() #include <math.h> // Required for: sin(), cos()
#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, 2.1, 3.3+ or ES2
#include "raymath.h" // Matrix data type and Matrix functions
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Defines and Macros // Defines and Macros
@ -76,11 +81,11 @@ void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color)
} }
// Draw a circle in 3D world space // Draw a circle in 3D world space
void DrawCircle3D(Vector3 center, float radius, float rotationAngle, Vector3 rotation, Color color) void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color)
{ {
rlPushMatrix(); rlPushMatrix();
rlTranslatef(center.x, center.y, center.z); rlTranslatef(center.x, center.y, center.z);
rlRotatef(rotationAngle, rotation.x, rotation.y, rotation.z); rlRotatef(rotationAngle, rotationAxis.x, rotationAxis.y, rotationAxis.z);
rlBegin(RL_LINES); rlBegin(RL_LINES);
for (int i = 0; i < 360; i += 10) for (int i = 0; i < 360; i += 10)
@ -579,9 +584,9 @@ void DrawLight(Light light)
{ {
DrawSphereWires(light->position, 0.3f*light->intensity, 8, 8, (light->enabled ? light->diffuse : GRAY)); DrawSphereWires(light->position, 0.3f*light->intensity, 8, 8, (light->enabled ? light->diffuse : GRAY));
DrawCircle3D(light->position, light->radius, 0.0f, (Vector3){ 0, 0, 0 }, (light->enabled ? light->diffuse : GRAY)); DrawCircle3D(light->position, light->radius, (Vector3){ 0, 0, 0 }, 0.0f, (light->enabled ? light->diffuse : GRAY));
DrawCircle3D(light->position, light->radius, 90.0f, (Vector3){ 1, 0, 0 }, (light->enabled ? light->diffuse : GRAY)); DrawCircle3D(light->position, light->radius, (Vector3){ 1, 0, 0 }, 90.0f, (light->enabled ? light->diffuse : GRAY));
DrawCircle3D(light->position, light->radius, 90.0f, (Vector3){ 0, 1, 0 }, (light->enabled ? light->diffuse : GRAY)); DrawCircle3D(light->position, light->radius, (Vector3){ 0, 1, 0 },90.0f, (light->enabled ? light->diffuse : GRAY));
} break; } break;
case LIGHT_DIRECTIONAL: case LIGHT_DIRECTIONAL:
{ {
@ -597,7 +602,7 @@ void DrawLight(Light light)
Vector3 dir = VectorSubtract(light->target, light->position); Vector3 dir = VectorSubtract(light->target, light->position);
VectorNormalize(&dir); VectorNormalize(&dir);
DrawCircle3D(light->position, 0.5f, 0.0f, dir, (light->enabled ? light->diffuse : GRAY)); DrawCircle3D(light->position, 0.5f, dir, 0.0f, (light->enabled ? light->diffuse : GRAY));
//DrawCylinderWires(light->position, 0.0f, 0.3f*light->coneAngle/50, 0.6f, 5, (light->enabled ? light->diffuse : GRAY)); //DrawCylinderWires(light->position, 0.0f, 0.3f*light->coneAngle/50, 0.6f, 5, (light->enabled ? light->diffuse : GRAY));
DrawCubeWires(light->target, 0.3f, 0.3f, 0.3f, (light->enabled ? light->diffuse : GRAY)); DrawCubeWires(light->target, 0.3f, 0.3f, 0.3f, (light->enabled ? light->diffuse : GRAY));
@ -1812,6 +1817,7 @@ static Material LoadMTL(const char *fileName)
char buffer[MAX_BUFFER_SIZE]; char buffer[MAX_BUFFER_SIZE];
Vector3 color = { 1.0f, 1.0f, 1.0f }; Vector3 color = { 1.0f, 1.0f, 1.0f };
char mapFileName[128]; char mapFileName[128];
int result = 0;
FILE *mtlFile; FILE *mtlFile;
@ -1896,13 +1902,13 @@ static Material LoadMTL(const char *fileName)
{ {
if (buffer[5] == 'd') // map_Kd string Diffuse color texture map. if (buffer[5] == 'd') // map_Kd string Diffuse color texture map.
{ {
sscanf(buffer, "map_Kd %s", mapFileName); result = sscanf(buffer, "map_Kd %s", mapFileName);
if (mapFileName != NULL) material.texDiffuse = LoadTexture(mapFileName); if (result != EOF) material.texDiffuse = LoadTexture(mapFileName);
} }
else if (buffer[5] == 's') // map_Ks string Specular color texture map. else if (buffer[5] == 's') // map_Ks string Specular color texture map.
{ {
sscanf(buffer, "map_Ks %s", mapFileName); result = sscanf(buffer, "map_Ks %s", mapFileName);
if (mapFileName != NULL) material.texSpecular = LoadTexture(mapFileName); if (result != EOF) material.texSpecular = LoadTexture(mapFileName);
} }
else if (buffer[5] == 'a') // map_Ka string Ambient color texture map. else if (buffer[5] == 'a') // map_Ka string Ambient color texture map.
{ {
@ -1911,13 +1917,13 @@ static Material LoadMTL(const char *fileName)
} break; } break;
case 'B': // map_Bump string Bump texture map. case 'B': // map_Bump string Bump texture map.
{ {
sscanf(buffer, "map_Bump %s", mapFileName); result = sscanf(buffer, "map_Bump %s", mapFileName);
if (mapFileName != NULL) material.texNormal = LoadTexture(mapFileName); if (result != EOF) material.texNormal = LoadTexture(mapFileName);
} break; } break;
case 'b': // map_bump string Bump texture map. case 'b': // map_bump string Bump texture map.
{ {
sscanf(buffer, "map_bump %s", mapFileName); result = sscanf(buffer, "map_bump %s", mapFileName);
if (mapFileName != NULL) material.texNormal = LoadTexture(mapFileName); if (result != EOF) material.texNormal = LoadTexture(mapFileName);
} break; } break;
case 'd': // map_d string Opacity texture map. case 'd': // map_d string Opacity texture map.
{ {
@ -1941,8 +1947,8 @@ static Material LoadMTL(const char *fileName)
} break; } break;
case 'b': // bump string Bump texture map case 'b': // bump string Bump texture map
{ {
sscanf(buffer, "bump %s", mapFileName); result = sscanf(buffer, "bump %s", mapFileName);
if (mapFileName != NULL) material.texNormal = LoadTexture(mapFileName); if (result != EOF) material.texNormal = LoadTexture(mapFileName);
} break; } break;
case 'T': // Tr float Transparency Tr (alpha). Tr is inverse of d case 'T': // Tr float Transparency Tr (alpha). Tr is inverse of d
{ {

File diff suppressed because it is too large Load Diff

View File

@ -6,37 +6,39 @@
* *
* Features: * Features:
* Library written in plain C code (C99) * Library written in plain C code (C99)
* Uses C# 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
* Materials (diffuse, normal, specular) and Lighting (point, directional, spot) support * Materials (diffuse, normal, specular) and Lighting (point, directional, spot) support
* 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 (WAV, OGG, XM, MOD) * 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]
* *
* Used external libs: * External libs:
* GLFW3 (www.glfw.org) for window/context management and input * GLFW3 (www.glfw.org) for window/context management and input [core]
* GLAD for OpenGL extensions loading (3.3 Core profile, only PLATFORM_DESKTOP) * GLAD for OpenGL extensions loading (3.3 Core profile, only PLATFORM_DESKTOP) [rlgl]
* stb_image (Sean Barret) for images loading (JPEG, PNG, BMP, TGA, PSD, GIF, HDR, PIC) * stb_image (Sean Barret) for images loading (JPEG, PNG, BMP, TGA) [textures]
* stb_image_write (Sean Barret) for image writting (PNG) * stb_image_write (Sean Barret) for image writting (PNG) [utils]
* stb_vorbis (Sean Barret) for ogg audio loading * stb_truetype (Sean Barret) for ttf fonts loading [text]
* stb_truetype (Sean Barret) for ttf fonts loading * stb_vorbis (Sean Barret) for ogg audio loading [audio]
* jar_xm (Joshua Reisenauer) for XM audio module loading * jar_xm (Joshua Reisenauer) for XM audio module loading [audio]
* jar_mod (Joshua Reisenauer) for MOD audio module loading * jar_mod (Joshua Reisenauer) for MOD audio module loading [audio]
* OpenAL Soft for audio device/context management * dr_flac (David Reid) for FLAC audio file loading [audio]
* tinfl for data decompression (DEFLATE algorithm) * OpenAL Soft for audio device/context management [audio]
* tinfl for data decompression (DEFLATE algorithm) [utils]
* *
* Some design decisions: * Some design decisions:
* 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 is loaded automatically when InitWindow() * 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 are loaded automatically (internally defined) * If using OpenGL 3.3 or ES2, two default shaders could be loaded automatically (internally defined)
* *
* -- LICENSE -- * -- LICENSE --
* *
@ -305,9 +307,6 @@
#endif #endif
#endif #endif
// byte type
typedef unsigned char byte;
// Vector2 type // Vector2 type
typedef struct Vector2 { typedef struct Vector2 {
float x; float x;
@ -725,7 +724,7 @@ RLAPI float GetGesturePinchAngle(void); // Get gesture pin
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Camera System Functions (Module: camera) // Camera System Functions (Module: camera)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
RLAPI void SetCameraMode(Camera, int mode); // Set camera mode (multiple camera modes available) RLAPI void SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available)
RLAPI void UpdateCamera(Camera *camera); // Update camera position for selected mode RLAPI void UpdateCamera(Camera *camera); // Update camera position for selected mode
RLAPI void SetCameraPanControl(int panKey); // Set camera pan key to combine with mouse movement (free camera) RLAPI void SetCameraPanControl(int panKey); // Set camera pan key to combine with mouse movement (free camera)
@ -803,7 +802,7 @@ RLAPI void ImageColorInvert(Image *image);
RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale
RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100) RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100)
RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255) RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255)
RLAPI void GenTextureMipmaps(Texture2D texture); // Generate GPU mipmaps for a texture RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture
RLAPI void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode RLAPI void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode
RLAPI void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode RLAPI void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode
@ -836,7 +835,7 @@ RLAPI const char *SubText(const char *text, int position, int length);
// Basic 3d Shapes Drawing Functions (Module: models) // Basic 3d Shapes Drawing Functions (Module: models)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space
RLAPI void DrawCircle3D(Vector3 center, float radius, float rotationAngle, Vector3 rotation, Color color); // Draw a circle in 3D world space RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space
RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube
RLAPI void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version) RLAPI void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version)
RLAPI void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires RLAPI void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires
@ -851,7 +850,7 @@ RLAPI void DrawRay(Ray ray, Color color);
RLAPI void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0)) RLAPI void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0))
RLAPI void DrawGizmo(Vector3 position); // Draw simple gizmo RLAPI void DrawGizmo(Vector3 position); // Draw simple gizmo
RLAPI void DrawLight(Light light); // Draw light in 3D world RLAPI void DrawLight(Light light); // Draw light in 3D world
//DrawTorus(), DrawTeapot() are useless... //DrawTorus(), DrawTeapot() could be useful?
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Model 3d Loading and Drawing Functions (Module: models) // Model 3d Loading and Drawing Functions (Module: models)
@ -918,7 +917,7 @@ RLAPI void DestroyLight(Light light); // Des
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
RLAPI void InitVrDevice(int vdDevice); // Init VR device RLAPI void InitVrDevice(int vdDevice); // Init VR device
RLAPI void CloseVrDevice(void); // Close VR device RLAPI void CloseVrDevice(void); // Close VR device
RLAPI bool IsVrDeviceReady(void); // Detect if VR device (or simulator) is ready RLAPI bool IsVrDeviceReady(void); // Detect if VR device is ready
RLAPI bool IsVrSimulator(void); // Detect if VR simulator is running 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)
@ -927,7 +926,7 @@ RLAPI void ToggleVrMode(void); // Enable/Disable VR experienc
// Audio Loading and Playing Functions (Module: audio) // Audio Loading and Playing Functions (Module: audio)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
RLAPI void InitAudioDevice(void); // Initialize audio device and context RLAPI void InitAudioDevice(void); // Initialize audio device and context
RLAPI void CloseAudioDevice(void); // Close the audio device and context (and music stream) RLAPI void CloseAudioDevice(void); // Close the audio device and context
RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully
RLAPI Wave LoadWave(const char *fileName); // Load wave data from file into RAM RLAPI Wave LoadWave(const char *fileName); // Load wave data from file into RAM
@ -951,9 +950,9 @@ RLAPI void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a
RLAPI float *GetWaveData(Wave wave); // Get samples data from wave as a floats array RLAPI float *GetWaveData(Wave wave); // Get samples data from wave as a floats array
RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file
RLAPI void UnloadMusicStream(Music music); // Unload music stream RLAPI void UnloadMusicStream(Music music); // Unload music stream
RLAPI void PlayMusicStream(Music music); // Start music playing (open stream) RLAPI void PlayMusicStream(Music music); // Start music playing
RLAPI void UpdateMusicStream(Music music); // Updates buffers for music streaming RLAPI void UpdateMusicStream(Music music); // Updates buffers for music streaming
RLAPI void StopMusicStream(Music music); // Stop music playing (close stream) RLAPI void StopMusicStream(Music music); // Stop music playing
RLAPI void PauseMusicStream(Music music); // Pause music playing RLAPI void PauseMusicStream(Music music); // Pause music playing
RLAPI void ResumeMusicStream(Music music); // Resume playing paused music RLAPI void ResumeMusicStream(Music music); // Resume playing paused music
RLAPI bool IsMusicPlaying(Music music); // Check if music is playing RLAPI bool IsMusicPlaying(Music music); // Check if music is playing
@ -964,7 +963,7 @@ RLAPI float GetMusicTimePlayed(Music music); // Get cur
RLAPI AudioStream InitAudioStream(unsigned int sampleRate, RLAPI AudioStream InitAudioStream(unsigned int sampleRate,
unsigned int sampleSize, unsigned int sampleSize,
unsigned int channels); // Init audio stream (to stream audio pcm data) unsigned int channels); // Init audio stream (to stream raw audio pcm data)
RLAPI void UpdateAudioStream(AudioStream stream, void *data, int numSamples); // Update audio stream buffers with data RLAPI void UpdateAudioStream(AudioStream stream, void *data, int numSamples); // Update audio stream buffers with data
RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
RLAPI bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill RLAPI bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill

Binary file not shown.

View File

@ -2,11 +2,30 @@
* *
* rlgl - raylib OpenGL abstraction layer * rlgl - raylib OpenGL abstraction layer
* *
* raylib now uses OpenGL 1.1 style functions (rlVertex) that are mapped to selected OpenGL version: * rlgl allows usage of OpenGL 1.1 style functions (rlVertex) that are internally mapped to
* OpenGL 1.1 - Direct map rl* -> gl* * selected OpenGL version (1.1, 2.1, 3.3 Core, ES 2.0).
* OpenGL 2.1 - Vertex data is stored in VBOs, call rlglDraw() to render *
* OpenGL 3.3 - Vertex data is stored in VAOs, call rlglDraw() to render * When chosing an OpenGL version greater than OpenGL 1.1, rlgl stores vertex data on internal
* OpenGL ES 2 - Vertex data is stored in VBOs or VAOs (when available), call rlglDraw() to render * VBO buffers (and VAOs if available). It requires calling 3 functions:
* rlglInit() - Initialize internal buffers and auxiliar resources
* rlglDraw() - Process internal buffers and send required draw calls
* rlglClose() - De-initialize internal buffers data and other auxiliar resources
*
* External libs:
* raymath - 3D math functionality (Vector3, Matrix, Quaternion)
* 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)
* RLGL_NO_STANDARD_SHADER - Avoid standard shader (shader_standard.h) inclusion
* RLGL_NO_DISTORTION_SHADER - Avoid stereo rendering distortion sahder (shader_distortion.h) inclusion
* RLGL_OCULUS_SUPPORT - Enable Oculus Rift CV1 functionality
*
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
* *
@ -1700,15 +1719,15 @@ void rlglUpdateTexture(unsigned int id, int width, int height, int format, void
} }
// Generate mipmap data for selected texture // Generate mipmap data for selected texture
void rlglGenerateMipmaps(Texture2D texture) void rlglGenerateMipmaps(Texture2D *texture)
{ {
glBindTexture(GL_TEXTURE_2D, texture.id); glBindTexture(GL_TEXTURE_2D, texture->id);
// Check if texture is power-of-two (POT) // Check if texture is power-of-two (POT)
bool texIsPOT = false; bool texIsPOT = false;
if (((texture.width > 0) && ((texture.width & (texture.width - 1)) == 0)) && if (((texture->width > 0) && ((texture->width & (texture->width - 1)) == 0)) &&
((texture.height > 0) && ((texture.height & (texture.height - 1)) == 0))) texIsPOT = true; ((texture->height > 0) && ((texture->height & (texture->height - 1)) == 0))) texIsPOT = true;
if ((texIsPOT) || (npotSupported)) if ((texIsPOT) || (npotSupported))
{ {
@ -1718,13 +1737,13 @@ void rlglGenerateMipmaps(Texture2D texture)
// NOTE: data size is reallocated to fit mipmaps data // NOTE: data size is reallocated to fit mipmaps data
// NOTE: CPU mipmap generation only supports RGBA 32bit data // NOTE: CPU mipmap generation only supports RGBA 32bit data
int mipmapCount = GenerateMipmaps(data, texture.width, texture.height); int mipmapCount = GenerateMipmaps(data, texture->width, texture->height);
int size = texture.width*texture.height*4; // RGBA 32bit only int size = texture->width*texture->height*4; // RGBA 32bit only
int offset = size; int offset = size;
int mipWidth = texture.width/2; int mipWidth = texture->width/2;
int mipHeight = texture.height/2; int mipHeight = texture->height/2;
// Load the mipmaps // Load the mipmaps
for (int level = 1; level < mipmapCount; level++) for (int level = 1; level < mipmapCount; level++)
@ -1738,23 +1757,29 @@ void rlglGenerateMipmaps(Texture2D texture)
mipHeight /= 2; mipHeight /= 2;
} }
TraceLog(WARNING, "[TEX ID %i] Mipmaps generated manually on CPU side", texture.id); TraceLog(WARNING, "[TEX ID %i] Mipmaps generated manually on CPU side", texture->id);
// NOTE: Once mipmaps have been generated and data has been uploaded to GPU VRAM, we can discard RAM data // NOTE: Once mipmaps have been generated and data has been uploaded to GPU VRAM, we can discard RAM data
free(data); free(data);
texture->mipmaps = mipmapCount + 1;
#endif #endif
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
//glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorythm: GL_FASTEST, GL_NICEST, GL_DONT_CARE //glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorythm: GL_FASTEST, GL_NICEST, GL_DONT_CARE
glGenerateMipmap(GL_TEXTURE_2D); // Generate mipmaps automatically glGenerateMipmap(GL_TEXTURE_2D); // Generate mipmaps automatically
TraceLog(INFO, "[TEX ID %i] Mipmaps generated automatically", texture.id); TraceLog(INFO, "[TEX ID %i] Mipmaps generated automatically", texture->id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // Activate Trilinear filtering for mipmaps (must be available) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // Activate Trilinear filtering for mipmaps
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
texture->mipmaps = 1 + floor(log2(MAX(texture->width, texture->height)));
#endif #endif
} }
else TraceLog(WARNING, "[TEX ID %i] Mipmaps can not be generated", texture.id); else TraceLog(WARNING, "[TEX ID %i] Mipmaps can not be generated", texture->id);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
} }
@ -2767,13 +2792,13 @@ void CloseVrDevice(void)
// Detect if VR device is available // Detect if VR device is available
bool IsVrDeviceReady(void) bool IsVrDeviceReady(void)
{ {
return (vrDeviceReady || vrSimulator) && vrEnabled; return (vrDeviceReady && vrEnabled);
} }
// Detect if VR simulator is running // Detect if VR simulator is running
bool IsVrSimulator(void) bool IsVrSimulator(void)
{ {
return vrSimulator; return (vrSimulator && vrEnabled);
} }
// Enable/Disable VR experience (device or simulator) // Enable/Disable VR experience (device or simulator)

View File

@ -2,11 +2,27 @@
* *
* rlgl - raylib OpenGL abstraction layer * rlgl - raylib OpenGL abstraction layer
* *
* raylib now uses OpenGL 1.1 style functions (rlVertex) that are mapped to selected OpenGL version: * rlgl allows usage of OpenGL 1.1 style functions (rlVertex) that are internally mapped to
* OpenGL 1.1 - Direct map rl* -> gl* * selected OpenGL version (1.1, 2.1, 3.3 Core, ES 2.0).
* OpenGL 2.1 - Vertex data is stored in VBOs, call rlglDraw() to render *
* OpenGL 3.3 - Vertex data is stored in VAOs, call rlglDraw() to render * When chosing an OpenGL version greater than OpenGL 1.1, rlgl stores vertex data on internal
* OpenGL ES 2 - Vertex data is stored in VBOs or VAOs (when available), call rlglDraw() to render * VBO buffers (and VAOs if available). It requires calling 3 functions:
* rlglInit() - Initialize internal buffers and auxiliar resources
* rlglDraw() - Process internal buffers and send required draw calls
* rlglClose() - De-initialize internal buffers data and other auxiliar resources
*
* External libs:
* raymath - 3D math functionality (Vector3, Matrix, Quaternion)
* 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)
*
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
* *
@ -117,15 +133,14 @@ typedef enum { RL_PROJECTION, RL_MODELVIEW, RL_TEXTURE } MatrixMode;
typedef enum { RL_LINES, RL_TRIANGLES, RL_QUADS } DrawMode; typedef enum { RL_LINES, RL_TRIANGLES, RL_QUADS } DrawMode;
typedef unsigned char byte;
#if defined(RLGL_STANDALONE) #if defined(RLGL_STANDALONE)
#ifndef __cplusplus #ifndef __cplusplus
// Boolean type // Boolean type
typedef enum { false, true } bool; typedef enum { false, true } bool;
#endif #endif
// byte type
typedef unsigned char byte;
// Color type, RGBA (32bit) // Color type, RGBA (32bit)
typedef struct Color { typedef struct Color {
unsigned char r; unsigned char r;
@ -356,7 +371,7 @@ void rlglLoadExtensions(void *loader); // Load OpenGL extensions
unsigned int rlglLoadTexture(void *data, int width, int height, int textureFormat, int mipmapCount); // Load texture in GPU unsigned int rlglLoadTexture(void *data, int width, int height, int textureFormat, int mipmapCount); // Load texture in GPU
RenderTexture2D rlglLoadRenderTexture(int width, int height); // Load a texture to be used for rendering (fbo with color and depth attachments) RenderTexture2D rlglLoadRenderTexture(int width, int height); // Load a texture to be used for rendering (fbo with color and depth attachments)
void rlglUpdateTexture(unsigned int id, int width, int height, int format, void *data); // Update GPU texture with new data void rlglUpdateTexture(unsigned int id, int width, int height, int format, void *data); // Update GPU texture with new data
void rlglGenerateMipmaps(Texture2D texture); // Generate mipmap data for selected texture void rlglGenerateMipmaps(Texture2D *texture); // Generate mipmap data for selected texture
void rlglLoadMesh(Mesh *mesh, bool dynamic); // Upload vertex data into GPU and provided VAO/VBO ids void rlglLoadMesh(Mesh *mesh, bool dynamic); // Upload vertex data into GPU and provided VAO/VBO ids
void rlglUpdateMesh(Mesh mesh, int buffer, int numVertex); // Update vertex data on GPU (upload new data to one buffer) void rlglUpdateMesh(Mesh mesh, int buffer, int numVertex); // Update vertex data on GPU (upload new data to one buffer)
@ -408,7 +423,8 @@ float *MatrixToFloat(Matrix mat);
void InitVrDevice(int vrDevice); // Init VR device void InitVrDevice(int vrDevice); // Init VR device
void CloseVrDevice(void); // Close VR device void CloseVrDevice(void); // Close VR device
bool IsVrDeviceReady(void); // Detect if VR device (or simulator) is ready 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)

View File

@ -1095,14 +1095,14 @@ int lua_IsFileDropped(lua_State* L)
int lua_GetDroppedFiles(lua_State* L) int lua_GetDroppedFiles(lua_State* L)
{ {
int count = 0; int count = 0;
char ** result = GetDroppedFiles(&count); char ** result = GetDroppedFiles(&count);
lua_createtable(L, count, 0); lua_createtable(L, count, 0);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
lua_pushstring(L, result[i]); lua_pushstring(L, result[i]);
lua_rawseti(L, -2, i + 1); lua_rawseti(L, -2, i + 1);
} }
return 1; return 1;
} }
int lua_ClearDroppedFiles(lua_State* L) int lua_ClearDroppedFiles(lua_State* L)
@ -1130,7 +1130,6 @@ int lua_StorageLoadValue(lua_State* L)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// raylib [core] module functions - Input Handling // raylib [core] module functions - Input Handling
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
int lua_IsKeyPressed(lua_State* L) int lua_IsKeyPressed(lua_State* L)
{ {
int arg1 = LuaGetArgument_int(L, 1); int arg1 = LuaGetArgument_int(L, 1);
@ -1185,12 +1184,22 @@ int lua_IsGamepadAvailable(lua_State* L)
return 1; return 1;
} }
int lua_GetGamepadAxisMovement(lua_State* L) int lua_IsGamepadName(lua_State* L)
{ {
int arg1 = LuaGetArgument_int(L, 1); int arg1 = LuaGetArgument_int(L, 1);
int arg2 = LuaGetArgument_int(L, 2); const char * arg2 = LuaGetArgument_string(L, 2);
float result = GetGamepadAxisMovement(arg1, arg2); bool result = IsGamepadName(arg1, arg2);
lua_pushnumber(L, result); lua_pushboolean(L, result);
return 1;
}
int lua_GetGamepadName(lua_State* L)
{
// TODO: Return gamepad name id
int arg1 = LuaGetArgument_int(L, 1);
char * result = GetGamepadName(arg1);
//lua_pushboolean(L, result);
return 1; return 1;
} }
@ -1229,7 +1238,30 @@ int lua_IsGamepadButtonUp(lua_State* L)
lua_pushboolean(L, result); lua_pushboolean(L, result);
return 1; return 1;
} }
#endif
int lua_GetGamepadButtonPressed(lua_State* L)
{
int result = GetGamepadButtonPressed();
lua_pushinteger(L, result);
return 1;
}
int lua_GetGamepadAxisCount(lua_State* L)
{
int arg1 = LuaGetArgument_int(L, 1);
int result = GetGamepadAxisCount(arg1);
lua_pushinteger(L, result);
return 1;
}
int lua_GetGamepadAxisMovement(lua_State* L)
{
int arg1 = LuaGetArgument_int(L, 1);
int arg2 = LuaGetArgument_int(L, 2);
float result = GetGamepadAxisMovement(arg1, arg2);
lua_pushnumber(L, result);
return 1;
}
int lua_IsMouseButtonPressed(lua_State* L) int lua_IsMouseButtonPressed(lua_State* L)
{ {
@ -1419,8 +1451,9 @@ int lua_GetGesturePinchAngle(lua_State* L)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
int lua_SetCameraMode(lua_State* L) int lua_SetCameraMode(lua_State* L)
{ {
int arg1 = LuaGetArgument_int(L, 1); Camera arg1 = LuaGetArgument_Camera(L, 1);
SetCameraMode(arg1); int arg2 = LuaGetArgument_int(L, 2);
SetCameraMode(arg1, arg2);
return 0; return 0;
} }
@ -1432,37 +1465,6 @@ int lua_UpdateCamera(lua_State* L)
return 1; return 1;
} }
int lua_UpdateCameraPlayer(lua_State* L)
{
Camera arg1 = LuaGetArgument_Camera(L, 1);
Vector3 arg2 = LuaGetArgument_Vector3(L, 2);
UpdateCameraPlayer(&arg1, &arg2);
LuaPush_Camera(L, arg1);
LuaPush_Vector3(L, arg2);
return 2;
}
int lua_SetCameraPosition(lua_State* L)
{
Vector3 arg1 = LuaGetArgument_Vector3(L, 1);
SetCameraPosition(arg1);
return 0;
}
int lua_SetCameraTarget(lua_State* L)
{
Vector3 arg1 = LuaGetArgument_Vector3(L, 1);
SetCameraTarget(arg1);
return 0;
}
int lua_SetCameraFovy(lua_State* L)
{
float arg1 = LuaGetArgument_float(L, 1);
SetCameraFovy(arg1);
return 0;
}
int lua_SetCameraPanControl(lua_State* L) int lua_SetCameraPanControl(lua_State* L)
{ {
int arg1 = LuaGetArgument_int(L, 1); int arg1 = LuaGetArgument_int(L, 1);
@ -1496,13 +1498,6 @@ int lua_SetCameraMoveControls(lua_State* L)
return 0; return 0;
} }
int lua_SetCameraMouseSensitivity(lua_State* L)
{
float arg1 = LuaGetArgument_float(L, 1);
SetCameraMouseSensitivity(arg1);
return 0;
}
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// raylib [shapes] module functions - Basic Shapes Drawing // raylib [shapes] module functions - Basic Shapes Drawing
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
@ -1790,6 +1785,8 @@ int lua_LoadImage(lua_State* L)
int lua_LoadImageEx(lua_State* L) int lua_LoadImageEx(lua_State* L)
{ {
// TODO: Image LoadImageEx(Color *pixels, int width, int height);
GET_TABLE(Color, arg1, 1); GET_TABLE(Color, arg1, 1);
int arg2 = LuaGetArgument_int(L, 2); int arg2 = LuaGetArgument_int(L, 2);
int arg3 = LuaGetArgument_int(L, 3); int arg3 = LuaGetArgument_int(L, 3);
@ -1888,6 +1885,8 @@ int lua_UnloadRenderTexture(lua_State* L)
int lua_GetImageData(lua_State* L) int lua_GetImageData(lua_State* L)
{ {
// TODO: Color *GetImageData(Image image);
Image arg1 = LuaGetArgument_Image(L, 1); Image arg1 = LuaGetArgument_Image(L, 1);
Color * result = GetImageData(arg1); Color * result = GetImageData(arg1);
lua_createtable(L, arg1.width*arg1.height, 0); lua_createtable(L, arg1.width*arg1.height, 0);
@ -1908,6 +1907,16 @@ int lua_GetTextureData(lua_State* L)
return 1; return 1;
} }
int lua_UpdateTexture(lua_State* L)
{
// TODO: void UpdateTexture(Texture2D texture, void *pixels);
Texture2D arg1 = LuaGetArgument_Texture2D(L, 1);
void * arg2 = (char *)LuaGetArgument_string(L, 2); // NOTE: Getting (void *) as string?
UpdateTexture(arg1, arg2); // ISSUE: #2 string expected, got table -> GetImageData() returns a table!
return 0;
}
int lua_ImageToPOT(lua_State* L) int lua_ImageToPOT(lua_State* L)
{ {
Image arg1 = LuaGetArgument_Image(L, 1); Image arg1 = LuaGetArgument_Image(L, 1);
@ -2096,15 +2105,24 @@ int lua_ImageColorBrightness(lua_State* L)
int lua_GenTextureMipmaps(lua_State* L) int lua_GenTextureMipmaps(lua_State* L)
{ {
Texture2D arg1 = LuaGetArgument_Texture2D(L, 1); Texture2D arg1 = LuaGetArgument_Texture2D(L, 1);
GenTextureMipmaps(arg1); GenTextureMipmaps(&arg1);
LuaPush_Texture2D(L, arg1);
return 1;
}
int lua_SetTextureFilter(lua_State* L)
{
Texture2D arg1 = LuaGetArgument_Texture2D(L, 1);
int arg2 = LuaGetArgument_int(L, 2);
SetTextureFilter(arg1, arg2);
return 0; return 0;
} }
int lua_UpdateTexture(lua_State* L) int lua_SetTextureWrap(lua_State* L)
{ {
Texture2D arg1 = LuaGetArgument_Texture2D(L, 1); Texture2D arg1 = LuaGetArgument_Texture2D(L, 1);
void * arg2 = (char *)LuaGetArgument_string(L, 2); // NOTE: Getting (void *) as string? int arg2 = LuaGetArgument_int(L, 2);
UpdateTexture(arg1, arg2); // ISSUE: #2 string expected, got table -> GetImageData() returns a table! SetTextureWrap(arg1, arg2);
return 0; return 0;
} }
@ -2178,6 +2196,18 @@ int lua_LoadSpriteFont(lua_State* L)
return 1; return 1;
} }
int lua_LoadSpriteFontTTF(lua_State* L)
{
const char * arg1 = LuaGetArgument_string(L, 1);
int arg2 = LuaGetArgument_int(L, 2);
int arg3 = LuaGetArgument_int(L, 3);
int arg4 = LuaGetArgument_int(L, 4);
//LoadSpriteFontTTF(const char *fileName, int fontSize, int numChars, int *fontChars);
SpriteFont result = LoadSpriteFontTTF(arg1, arg2, arg3, &arg4);
LuaPush_SpriteFont(L, result);
return 1;
}
int lua_UnloadSpriteFont(lua_State* L) int lua_UnloadSpriteFont(lua_State* L)
{ {
SpriteFont arg1 = LuaGetArgument_SpriteFont(L, 1); SpriteFont arg1 = LuaGetArgument_SpriteFont(L, 1);
@ -2255,8 +2285,8 @@ int lua_DrawCircle3D(lua_State* L)
{ {
Vector3 arg1 = LuaGetArgument_Vector3(L, 1); Vector3 arg1 = LuaGetArgument_Vector3(L, 1);
float arg2 = LuaGetArgument_float(L, 2); float arg2 = LuaGetArgument_float(L, 2);
float arg3 = LuaGetArgument_float(L, 3); Vector3 arg3 = LuaGetArgument_Vector3(L, 3);
Vector3 arg4 = LuaGetArgument_Vector3(L, 4); float arg4 = LuaGetArgument_float(L, 4);
Color arg5 = LuaGetArgument_Color(L, 5); Color arg5 = LuaGetArgument_Color(L, 5);
DrawCircle3D(arg1, arg2, arg3, arg4, arg5); DrawCircle3D(arg1, arg2, arg3, arg4, arg5);
return 0; return 0;
@ -2619,18 +2649,6 @@ int lua_CheckCollisionRayBox(lua_State* L)
return 1; return 1;
} }
int lua_ResolveCollisionCubicmap(lua_State* L)
{
Image arg1 = LuaGetArgument_Image(L, 1);
Vector3 arg2 = LuaGetArgument_Vector3(L, 2);
Vector3 arg3 = LuaGetArgument_Vector3(L, 3);
float arg4 = LuaGetArgument_float(L, 4);
Vector3 result = ResolveCollisionCubicmap(arg1, arg2, &arg3, arg4);
LuaPush_Vector3(L, result);
LuaPush_Vector3(L, arg3);
return 2;
}
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// raylib [raymath] module functions - Shaders // raylib [raymath] module functions - Shaders
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
@ -2790,10 +2808,19 @@ int lua_IsVrDeviceReady(lua_State* L)
return 1; return 1;
} }
int lua_IsVrSimulator(lua_State* L)
{
bool result = IsVrSimulator();
lua_pushboolean(L, result);
return 1;
}
int lua_UpdateVrTracking(lua_State* L) int lua_UpdateVrTracking(lua_State* L)
{ {
UpdateVrTracking(); Camera arg1 = LuaGetArgument_Camera(L, 1);
return 0; UpdateVrTracking(&arg1);
LuaPush_Camera(L, arg1);
return 1;
} }
int lua_ToggleVrMode(lua_State* L) int lua_ToggleVrMode(lua_State* L)
@ -2873,6 +2900,8 @@ int lua_LoadSoundFromRES(lua_State* L)
int lua_UpdateSound(lua_State* L) int lua_UpdateSound(lua_State* L)
{ {
// TODO: void UpdateSound(Sound sound, void *data, int numSamples);
Sound arg1 = LuaGetArgument_Sound(L, 1); Sound arg1 = LuaGetArgument_Sound(L, 1);
const char * arg2 = LuaGetArgument_string(L, 2); const char * arg2 = LuaGetArgument_string(L, 2);
int * arg3 = LuaGetArgument_int(L, 3); int * arg3 = LuaGetArgument_int(L, 3);
@ -2952,11 +2981,11 @@ int lua_WaveFormat(lua_State* L)
int arg2 = LuaGetArgument_int(L, 2); int arg2 = LuaGetArgument_int(L, 2);
int arg3 = LuaGetArgument_int(L, 3); int arg3 = LuaGetArgument_int(L, 3);
int arg4 = LuaGetArgument_int(L, 4); int arg4 = LuaGetArgument_int(L, 4);
WaveFormat(arg1, arg2, arg3, arg4); WaveFormat(&arg1, arg2, arg3, arg4);
return 0; return 0;
} }
int lua_LoadMusicStream(lua_State* L) int lua_WaveCopy(lua_State* L)
{ {
Wave arg1 = LuaGetArgument_Wave(L, 1); Wave arg1 = LuaGetArgument_Wave(L, 1);
Wave result = WaveCopy(arg1); Wave result = WaveCopy(arg1);
@ -2969,7 +2998,7 @@ int lua_WaveCrop(lua_State* L)
Wave arg1 = LuaGetArgument_Wave(L, 1); Wave arg1 = LuaGetArgument_Wave(L, 1);
int arg2 = LuaGetArgument_int(L, 2); int arg2 = LuaGetArgument_int(L, 2);
int arg3 = LuaGetArgument_int(L, 3); int arg3 = LuaGetArgument_int(L, 3);
WaveCrop(arg1, arg2, arg3); WaveCrop(&arg1, arg2, arg3);
return 0; return 0;
} }
@ -2978,9 +3007,10 @@ int lua_GetWaveData(lua_State* L)
// TODO: float *GetWaveData(Wave wave); // TODO: float *GetWaveData(Wave wave);
Wave arg1 = LuaGetArgument_Wave(L, 1); Wave arg1 = LuaGetArgument_Wave(L, 1);
float result = GetWaveData(arg1); float * result = GetWaveData(arg1);
LuaPush_float(L, result); //LuaPush_float(L, result);
return 1; //lua_pushnumber(L, result);
return 0;
} }
int lua_LoadMusicStream(lua_State* L) int lua_LoadMusicStream(lua_State* L)
@ -3012,7 +3042,6 @@ int lua_PlayMusicStream(lua_State* L)
return 0; return 0;
} }
int lua_StopMusicStream(lua_State* L) int lua_StopMusicStream(lua_State* L)
{ {
Music arg1 = LuaGetArgument_Music(L, 1); Music arg1 = LuaGetArgument_Music(L, 1);
@ -3093,6 +3122,8 @@ int lua_CloseAudioStream(lua_State* L)
int lua_UpdateAudioStream(lua_State* L) int lua_UpdateAudioStream(lua_State* L)
{ {
// TODO: void UpdateAudioStream(AudioStream stream, void *data, int numSamples);
AudioStream arg1 = LuaGetArgument_AudioStream(L, 1); AudioStream arg1 = LuaGetArgument_AudioStream(L, 1);
void * arg2 = (char *)LuaGetArgument_string(L, 2); void * arg2 = (char *)LuaGetArgument_string(L, 2);
int arg3 = LuaGetArgument_int(L, 3); int arg3 = LuaGetArgument_int(L, 3);
@ -3667,7 +3698,6 @@ static luaL_Reg raylib_functions[] = {
REG(StorageSaveValue) REG(StorageSaveValue)
REG(StorageLoadValue) REG(StorageLoadValue)
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
REG(IsKeyPressed) REG(IsKeyPressed)
REG(IsKeyDown) REG(IsKeyDown)
REG(IsKeyReleased) REG(IsKeyReleased)
@ -3676,12 +3706,15 @@ static luaL_Reg raylib_functions[] = {
REG(SetExitKey) REG(SetExitKey)
REG(IsGamepadAvailable) REG(IsGamepadAvailable)
REG(GetGamepadAxisMovement) REG(IsGamepadName)
REG(GetGamepadName)
REG(IsGamepadButtonPressed) REG(IsGamepadButtonPressed)
REG(IsGamepadButtonDown) REG(IsGamepadButtonDown)
REG(IsGamepadButtonReleased) REG(IsGamepadButtonReleased)
REG(IsGamepadButtonUp) REG(IsGamepadButtonUp)
#endif REG(GetGamepadButtonPressed)
REG(GetGamepadAxisCount)
REG(GetGamepadAxisMovement)
REG(IsMouseButtonPressed) REG(IsMouseButtonPressed)
REG(IsMouseButtonDown) REG(IsMouseButtonDown)
@ -3714,16 +3747,10 @@ static luaL_Reg raylib_functions[] = {
REG(SetCameraMode) REG(SetCameraMode)
REG(UpdateCamera) REG(UpdateCamera)
REG(UpdateCameraPlayer)
REG(SetCameraPosition)
REG(SetCameraTarget)
REG(SetCameraFovy)
REG(SetCameraPanControl) REG(SetCameraPanControl)
REG(SetCameraAltControl) REG(SetCameraAltControl)
REG(SetCameraSmoothZoomControl) REG(SetCameraSmoothZoomControl)
REG(SetCameraMoveControls) REG(SetCameraMoveControls)
REG(SetCameraMouseSensitivity)
REG(DrawPixel) REG(DrawPixel)
REG(DrawPixelV) REG(DrawPixelV)
@ -3766,6 +3793,7 @@ static luaL_Reg raylib_functions[] = {
REG(UnloadRenderTexture) REG(UnloadRenderTexture)
REG(GetImageData) REG(GetImageData)
REG(GetTextureData) REG(GetTextureData)
REG(UpdateTexture)
REG(ImageToPOT) REG(ImageToPOT)
REG(ImageFormat) REG(ImageFormat)
REG(ImageDither) REG(ImageDither)
@ -3786,8 +3814,9 @@ static luaL_Reg raylib_functions[] = {
REG(ImageColorContrast) REG(ImageColorContrast)
REG(ImageColorBrightness) REG(ImageColorBrightness)
REG(GenTextureMipmaps) REG(GenTextureMipmaps)
REG(UpdateTexture) REG(SetTextureFilter)
REG(SetTextureWrap)
REG(DrawTexture) REG(DrawTexture)
REG(DrawTextureV) REG(DrawTextureV)
REG(DrawTextureEx) REG(DrawTextureEx)
@ -3796,6 +3825,7 @@ static luaL_Reg raylib_functions[] = {
REG(GetDefaultFont) REG(GetDefaultFont)
REG(LoadSpriteFont) REG(LoadSpriteFont)
REG(LoadSpriteFontTTF)
REG(UnloadSpriteFont) REG(UnloadSpriteFont)
REG(DrawText) REG(DrawText)
REG(DrawTextEx) REG(DrawTextEx)
@ -3845,7 +3875,6 @@ static luaL_Reg raylib_functions[] = {
REG(CheckCollisionRaySphere) REG(CheckCollisionRaySphere)
REG(CheckCollisionRaySphereEx) REG(CheckCollisionRaySphereEx)
REG(CheckCollisionRayBox) REG(CheckCollisionRayBox)
REG(ResolveCollisionCubicmap)
REG(LoadShader) REG(LoadShader)
REG(UnloadShader) REG(UnloadShader)
@ -3868,6 +3897,7 @@ static luaL_Reg raylib_functions[] = {
REG(InitVrDevice) REG(InitVrDevice)
REG(CloseVrDevice) REG(CloseVrDevice)
REG(IsVrDeviceReady) REG(IsVrDeviceReady)
REG(IsVrSimulator)
REG(UpdateVrTracking) REG(UpdateVrTracking)
REG(ToggleVrMode) REG(ToggleVrMode)
@ -4067,24 +4097,36 @@ RLUADEF void InitLuaDevice(void)
LuaSetEnum("RIGHT_BUTTON", 1); LuaSetEnum("RIGHT_BUTTON", 1);
LuaSetEnum("MIDDLE_BUTTON", 2); LuaSetEnum("MIDDLE_BUTTON", 2);
LuaEndEnum("MOUSE"); LuaEndEnum("MOUSE");
LuaStartEnum(); LuaStartEnum();
LuaSetEnum("PLAYER1", 0); LuaSetEnum("PLAYER1", 0);
LuaSetEnum("PLAYER2", 1); LuaSetEnum("PLAYER2", 1);
LuaSetEnum("PLAYER3", 2); LuaSetEnum("PLAYER3", 2);
LuaSetEnum("PLAYER4", 3); LuaSetEnum("PLAYER4", 3);
LuaSetEnum("PS3_BUTTON_A", 2); LuaSetEnum("PS3_BUTTON_TRIANGLE", 0);
LuaSetEnum("PS3_BUTTON_B", 1); LuaSetEnum("PS3_BUTTON_CIRCLE", 1);
LuaSetEnum("PS3_BUTTON_X", 3); LuaSetEnum("PS3_BUTTON_CROSS", 2);
LuaSetEnum("PS3_BUTTON_Y", 4); LuaSetEnum("PS3_BUTTON_SQUARE", 3);
LuaSetEnum("PS3_BUTTON_R1", 7);
LuaSetEnum("PS3_BUTTON_R2", 5);
LuaSetEnum("PS3_BUTTON_L1", 6); LuaSetEnum("PS3_BUTTON_L1", 6);
LuaSetEnum("PS3_BUTTON_L2", 8); LuaSetEnum("PS3_BUTTON_R1", 7);
LuaSetEnum("PS3_BUTTON_L2", 4);
LuaSetEnum("PS3_BUTTON_R2", 5);
LuaSetEnum("PS3_BUTTON_START", 8);
LuaSetEnum("PS3_BUTTON_SELECT", 9); LuaSetEnum("PS3_BUTTON_SELECT", 9);
LuaSetEnum("PS3_BUTTON_START", 10); LuaSetEnum("PS3_BUTTON_UP", 24);
LuaSetEnum("PS3_BUTTON_RIGHT", 25);
LuaSetEnum("PS3_BUTTON_DOWN", 26);
LuaSetEnum("PS3_BUTTON_LEFT", 27);
LuaSetEnum("PS3_BUTTON_PS", 12);
LuaSetEnum("PS3_AXIS_LEFT_X", 0);
LuaSetEnum("PS3_AXIS_LEFT_Y", 1);
LuaSetEnum("PS3_AXIS_RIGHT_X", 2);
LuaSetEnum("PS3_AXIS_RIGHT_Y", 5);
LuaSetEnum("PS3_AXIS_L2", 3); // [1..-1] (pressure-level)
LuaSetEnum("PS3_AXIS_R2", 4); // [1..-1] (pressure-level)
// Xbox360 USB Controller Buttons
LuaSetEnum("XBOX_BUTTON_A", 0); LuaSetEnum("XBOX_BUTTON_A", 0);
LuaSetEnum("XBOX_BUTTON_B", 1); LuaSetEnum("XBOX_BUTTON_B", 1);
LuaSetEnum("XBOX_BUTTON_X", 2); LuaSetEnum("XBOX_BUTTON_X", 2);
@ -4093,25 +4135,26 @@ RLUADEF void InitLuaDevice(void)
LuaSetEnum("XBOX_BUTTON_RB", 5); LuaSetEnum("XBOX_BUTTON_RB", 5);
LuaSetEnum("XBOX_BUTTON_SELECT", 6); LuaSetEnum("XBOX_BUTTON_SELECT", 6);
LuaSetEnum("XBOX_BUTTON_START", 7); LuaSetEnum("XBOX_BUTTON_START", 7);
#if defined(PLATFORM_RPI)
LuaSetEnum("XBOX_AXIS_DPAD_X", 7);
LuaSetEnum("XBOX_AXIS_DPAD_Y", 6);
LuaSetEnum("XBOX_AXIS_RIGHT_X", 3);
LuaSetEnum("XBOX_AXIS_RIGHT_Y", 4);
LuaSetEnum("XBOX_AXIS_LT", 2);
LuaSetEnum("XBOX_AXIS_RT", 5);
#else
LuaSetEnum("XBOX_BUTTON_UP", 10); LuaSetEnum("XBOX_BUTTON_UP", 10);
LuaSetEnum("XBOX_BUTTON_RIGHT", 11);
LuaSetEnum("XBOX_BUTTON_DOWN", 12); LuaSetEnum("XBOX_BUTTON_DOWN", 12);
LuaSetEnum("XBOX_BUTTON_LEFT", 13); LuaSetEnum("XBOX_BUTTON_LEFT", 13);
LuaSetEnum("XBOX_BUTTON_RIGHT", 11); LuaSetEnum("XBOX_BUTTON_HOME", 8);
LuaSetEnum("XBOX_AXIS_RIGHT_X", 4); #if defined(PLATFORM_RPI)
LuaSetEnum("XBOX_AXIS_RIGHT_Y", 3); LuaSetEnum("XBOX_AXIS_LEFT_X", 0); // [-1..1] (left->right)
LuaSetEnum("XBOX_AXIS_LT_RT", 2); LuaSetEnum("XBOX_AXIS_LEFT_Y", 1); // [-1..1] (up->down)
LuaSetEnum("XBOX_AXIS_RIGHT_X", 3); // [-1..1] (left->right)
LuaSetEnum("XBOX_AXIS_RIGHT_Y", 4); // [-1..1] (up->down)
LuaSetEnum("XBOX_AXIS_LT", 2); // [-1..1] (pressure-level)
LuaSetEnum("XBOX_AXIS_RT", 5); // [-1..1] (pressure-level)
#else
LuaSetEnum("XBOX_AXIS_LEFT_X", 0); // [-1..1] (left->right)
LuaSetEnum("XBOX_AXIS_LEFT_Y", 1); // [1..-1] (up->down)
LuaSetEnum("XBOX_AXIS_RIGHT_X", 2); // [-1..1] (left->right)
LuaSetEnum("XBOX_AXIS_RIGHT_Y", 3); // [1..-1] (up->down)
LuaSetEnum("XBOX_AXIS_LT", 4); // [-1..1] (pressure-level)
LuaSetEnum("XBOX_AXIS_RT", 5); // [-1..1] (pressure-level)
#endif #endif
LuaSetEnum("XBOX_AXIS_LEFT_X", 0);
LuaSetEnum("XBOX_AXIS_LEFT_Y", 1);
LuaEndEnum("GAMEPAD"); LuaEndEnum("GAMEPAD");
lua_pushglobaltable(L); lua_pushglobaltable(L);
@ -4175,6 +4218,15 @@ RLUADEF void InitLuaDevice(void)
LuaSetEnum("DIRECTIONAL", LIGHT_DIRECTIONAL); LuaSetEnum("DIRECTIONAL", LIGHT_DIRECTIONAL);
LuaSetEnum("SPOT", LIGHT_SPOT); LuaSetEnum("SPOT", LIGHT_SPOT);
LuaEndEnum("LightType"); LuaEndEnum("LightType");
LuaStartEnum();
LuaSetEnum("POINT", FILTER_POINT);
LuaSetEnum("BILINEAR", FILTER_BILINEAR);
LuaSetEnum("TRILINEAR", FILTER_TRILINEAR);
LuaSetEnum("ANISOTROPIC_4X", FILTER_ANISOTROPIC_4X);
LuaSetEnum("ANISOTROPIC_8X", FILTER_ANISOTROPIC_8X);
LuaSetEnum("ANISOTROPIC_16X", FILTER_ANISOTROPIC_16X);
LuaEndEnum("TextureFilter");
LuaStartEnum(); LuaStartEnum();
LuaSetEnum("NONE", GESTURE_NONE); LuaSetEnum("NONE", GESTURE_NONE);

View File

@ -4,6 +4,12 @@
* *
* Basic functions to draw 2d Shapes and check collisions * Basic functions to draw 2d Shapes and check collisions
* *
* External libs:
* rlgl - raylib OpenGL abstraction layer
*
* Module Configuration Flags:
* ...
*
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-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
@ -25,11 +31,11 @@
#include "raylib.h" #include "raylib.h"
#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2
#include <stdlib.h> // Required for: abs() #include <stdlib.h> // Required for: abs()
#include <math.h> // Required for: sinf(), cosf(), sqrtf() #include <math.h> // Required for: sinf(), cosf(), sqrtf()
#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Defines and Macros // Defines and Macros
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View File

@ -4,6 +4,12 @@
* *
* Basic functions to load SpriteFonts and draw Text * Basic functions to load SpriteFonts and draw Text
* *
* External libs:
* stb_truetype - Load TTF file and rasterize characters data
*
* Module Configuration Flags:
* ...
*
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-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
@ -33,7 +39,7 @@
#include "utils.h" // Required for: GetExtension(), GetNextPOT() #include "utils.h" // Required for: GetExtension(), GetNextPOT()
// Following libs are used on LoadTTF() // Following libs are used on LoadTTF()
//#define STBTT_STATIC #define STBTT_STATIC // Define stb_truetype functions static to this module
#define STB_TRUETYPE_IMPLEMENTATION #define STB_TRUETYPE_IMPLEMENTATION
#include "external/stb_truetype.h" // Required for: stbtt_BakeFontBitmap() #include "external/stb_truetype.h" // Required for: stbtt_BakeFontBitmap()
@ -869,10 +875,18 @@ static SpriteFont LoadBMFont(const char *fileName)
TraceLog(DEBUG, "[%s] Font texture loading path: %s", fileName, texPath); TraceLog(DEBUG, "[%s] Font texture loading path: %s", fileName, texPath);
Image imFont = LoadImage(texPath); Image imFont = LoadImage(texPath);
if (imFont.format == UNCOMPRESSED_GRAYSCALE)
{
Image imCopy = ImageCopy(imFont);
for (int i = 0; i < imCopy.width*imCopy.height; i++) ((unsigned char *)imCopy.data)[i] = 0xff; // WHITE pixel
if (imFont.format == UNCOMPRESSED_GRAYSCALE) ImageAlphaMask(&imFont, imFont); ImageAlphaMask(&imCopy, imFont);
font.texture = LoadTextureFromImage(imCopy);
font.texture = LoadTextureFromImage(imFont); UnloadImage(imCopy);
}
else font.texture = LoadTextureFromImage(imFont);
font.size = fontSize; font.size = fontSize;
font.numChars = numChars; font.numChars = numChars;

View File

@ -4,9 +4,13 @@
* *
* Basic functions to load and draw Textures (2d) * Basic functions to load and draw Textures (2d)
* *
* Uses external lib: * External libs:
* stb_image - Multiple formats image loading (JPEG, PNG, BMP, TGA, PSD, GIF, PIC) * stb_image - Multiple image formats loading (JPEG, PNG, BMP, TGA, PSD, GIF, PIC)
* NOTE: stb_image has been slightly modified, original library: https://github.com/nothings/stb * NOTE: stb_image has been slightly modified to support Android platform.
* stb_image_resize - Multiple image resize algorythms
*
* Module Configuration Flags:
* ...
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
* *
@ -1512,14 +1516,14 @@ void ImageColorBrightness(Image *image, int brightness)
} }
// Generate GPU mipmaps for a texture // Generate GPU mipmaps for a texture
void GenTextureMipmaps(Texture2D texture) void GenTextureMipmaps(Texture2D *texture)
{ {
#if PLATFORM_WEB #if PLATFORM_WEB
int potWidth = GetNextPOT(texture.width); int potWidth = GetNextPOT(texture->width);
int potHeight = GetNextPOT(texture.height); int potHeight = GetNextPOT(texture->height);
// Check if texture is POT // Check if texture is POT
if ((potWidth != texture.width) || (potHeight != texture.height)) if ((potWidth != texture->width) || (potHeight != texture->height))
{ {
TraceLog(WARNING, "Limited NPOT support, no mipmaps available for NPOT textures"); TraceLog(WARNING, "Limited NPOT support, no mipmaps available for NPOT textures");
} }

View File

@ -2,12 +2,16 @@
* *
* raylib.utils * raylib.utils
* *
* Utils Functions Definitions * Some utility functions
* *
* Uses external libs: * External libs:
* tinfl - zlib DEFLATE algorithm decompression lib * tinfl - zlib DEFLATE algorithm decompression
* stb_image_write - PNG writting functions * stb_image_write - PNG writting functions
* *
* Module Configuration Flags:
* DO_NOT_TRACE_DEBUG_MSGS - Avoid showing DEBUG TraceLog() messages
*
*
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-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
@ -46,7 +50,9 @@
#endif #endif
#include "external/tinfl.c" // Required for: tinfl_decompress_mem_to_mem() #include "external/tinfl.c" // Required for: tinfl_decompress_mem_to_mem()
// NOTE: Deflate algorythm data decompression // NOTE: DEFLATE algorythm data decompression
#define DO_NOT_TRACE_DEBUG_MSGS // Avoid DEBUG messages tracing
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition // Global Variables Definition

View File

@ -2,9 +2,9 @@
* *
* raylib.utils * raylib.utils
* *
* Some utility functions: rRES files data decompression * Some utility functions
* *
* Copyright (c) 2014 Ramon Santamaria (@raysan5) * Copyright (c) 2014-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.
@ -34,8 +34,6 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Some basic Defines // Some basic Defines
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#define DO_NOT_TRACE_DEBUG_MSGS // Use this define to avoid DEBUG tracing
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
#define fopen(name, mode) android_fopen(name, mode) #define fopen(name, mode) android_fopen(name, mode)
#endif #endif

View File

@ -37,14 +37,13 @@ void android_main(struct android_app *app)
InitAudioDevice(); // Initialize audio device InitAudioDevice(); // Initialize audio device
Sound fx = LoadSound("coin.wav"); // Load WAV audio file (placed on assets folder)
Texture2D texture = LoadTexture("raylib_logo.png"); // Load texture (placed on assets folder) Texture2D texture = LoadTexture("raylib_logo.png"); // Load texture (placed on assets folder)
int framesCounter = 0; // Used to count frames Sound fx = LoadSound("coin.wav"); // Load WAV audio file (placed on assets folder)
Music ambient = LoadMusicStream("ambient.ogg"); Music ambient = LoadMusicStream("ambient.ogg");
PlayMusicStream(ambient); PlayMusicStream(ambient);
int framesCounter = 0; // Used to count frames
SetTargetFPS(60); // Not required on Android, already locked to 60 fps SetTargetFPS(60); // Not required on Android, already locked to 60 fps
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View File

@ -6,37 +6,39 @@
* *
* Features: * Features:
* Library written in plain C code (C99) * Library written in plain C code (C99)
* Uses C# 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
* Materials (diffuse, normal, specular) and Lighting (point, directional, spot) support * Materials (diffuse, normal, specular) and Lighting (point, directional, spot) support
* 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 (WAV, OGG, XM, MOD) * 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]
* *
* Used external libs: * External libs:
* GLFW3 (www.glfw.org) for window/context management and input * GLFW3 (www.glfw.org) for window/context management and input [core]
* GLAD for OpenGL extensions loading (3.3 Core profile, only PLATFORM_DESKTOP) * GLAD for OpenGL extensions loading (3.3 Core profile, only PLATFORM_DESKTOP) [rlgl]
* stb_image (Sean Barret) for images loading (JPEG, PNG, BMP, TGA, PSD, GIF, HDR, PIC) * stb_image (Sean Barret) for images loading (JPEG, PNG, BMP, TGA) [textures]
* stb_image_write (Sean Barret) for image writting (PNG) * stb_image_write (Sean Barret) for image writting (PNG) [utils]
* stb_vorbis (Sean Barret) for ogg audio loading * stb_truetype (Sean Barret) for ttf fonts loading [text]
* stb_truetype (Sean Barret) for ttf fonts loading * stb_vorbis (Sean Barret) for ogg audio loading [audio]
* jar_xm (Joshua Reisenauer) for XM audio module loading * jar_xm (Joshua Reisenauer) for XM audio module loading [audio]
* jar_mod (Joshua Reisenauer) for MOD audio module loading * jar_mod (Joshua Reisenauer) for MOD audio module loading [audio]
* OpenAL Soft for audio device/context management * dr_flac (David Reid) for FLAC audio file loading [audio]
* tinfl for data decompression (DEFLATE algorithm) * OpenAL Soft for audio device/context management [audio]
* tinfl for data decompression (DEFLATE algorithm) [utils]
* *
* Some design decisions: * Some design decisions:
* 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 is loaded automatically when InitWindow() * 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 are loaded automatically (internally defined) * If using OpenGL 3.3 or ES2, two default shaders could be loaded automatically (internally defined)
* *
* -- LICENSE -- * -- LICENSE --
* *
@ -77,10 +79,6 @@
#define PLATFORM_DESKTOP #define PLATFORM_DESKTOP
#endif #endif
#if defined(PLATFORM_ANDROID)
typedef struct android_app; // Define android_app struct (android_native_app_glue.h)
#endif
#if defined(_WIN32) && defined(BUILDING_DLL) #if defined(_WIN32) && defined(BUILDING_DLL)
#define RLAPI __declspec(dllexport) // We are building raylib as a Win32 DLL #define RLAPI __declspec(dllexport) // We are building raylib as a Win32 DLL
#elif defined(_WIN32) && defined(RAYLIB_DLL) #elif defined(_WIN32) && defined(RAYLIB_DLL)
@ -93,7 +91,7 @@
// Some basic Defines // Some basic Defines
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#ifndef PI #ifndef PI
#define PI 3.14159265358979323846 #define PI 3.14159265358979323846f
#endif #endif
#define DEG2RAD (PI/180.0f) #define DEG2RAD (PI/180.0f)
@ -101,11 +99,12 @@
// raylib Config Flags // raylib Config Flags
#define FLAG_FULLSCREEN_MODE 1 #define FLAG_FULLSCREEN_MODE 1
#define FLAG_SHOW_LOGO 2 #define FLAG_RESIZABLE_WINDOW 2
#define FLAG_SHOW_MOUSE_CURSOR 4 #define FLAG_SHOW_LOGO 4
#define FLAG_CENTERED_MODE 8 #define FLAG_SHOW_MOUSE_CURSOR 8
#define FLAG_MSAA_4X_HINT 16 #define FLAG_CENTERED_MODE 16
#define FLAG_VSYNC_HINT 32 #define FLAG_MSAA_4X_HINT 32
#define FLAG_VSYNC_HINT 64
// Keyboard Function Keys // Keyboard Function Keys
#define KEY_SPACE 32 #define KEY_SPACE 32
@ -173,15 +172,18 @@
#define KEY_Y 89 #define KEY_Y 89
#define KEY_Z 90 #define KEY_Z 90
#if defined(PLATFORM_ANDROID)
// Android Physical Buttons
#define KEY_BACK 4
#define KEY_MENU 82
#define KEY_VOLUME_UP 24
#define KEY_VOLUME_DOWN 25
#endif
// Mouse Buttons // Mouse Buttons
#define MOUSE_LEFT_BUTTON 0 #define MOUSE_LEFT_BUTTON 0
#if defined(PLATFORM_WEB) #define MOUSE_RIGHT_BUTTON 1
#define MOUSE_RIGHT_BUTTON 2 #define MOUSE_MIDDLE_BUTTON 2
#define MOUSE_MIDDLE_BUTTON 1
#else
#define MOUSE_RIGHT_BUTTON 1
#define MOUSE_MIDDLE_BUTTON 2
#endif
// Touch points registered // Touch points registered
#define MAX_TOUCH_POINTS 2 #define MAX_TOUCH_POINTS 2
@ -189,24 +191,35 @@
// Gamepad Number // Gamepad Number
#define GAMEPAD_PLAYER1 0 #define GAMEPAD_PLAYER1 0
#define GAMEPAD_PLAYER2 1 #define GAMEPAD_PLAYER2 1
#define GAMEPAD_PLAYER3 2 // Not supported #define GAMEPAD_PLAYER3 2
#define GAMEPAD_PLAYER4 3 // Not supported #define GAMEPAD_PLAYER4 3
// Gamepad Buttons // Gamepad Buttons/Axis
// PS3 USB Controller // PS3 USB Controller Buttons
#define GAMEPAD_PS3_BUTTON_A 2 #define GAMEPAD_PS3_BUTTON_TRIANGLE 0
#define GAMEPAD_PS3_BUTTON_B 1 #define GAMEPAD_PS3_BUTTON_CIRCLE 1
#define GAMEPAD_PS3_BUTTON_X 3 #define GAMEPAD_PS3_BUTTON_CROSS 2
#define GAMEPAD_PS3_BUTTON_Y 4 #define GAMEPAD_PS3_BUTTON_SQUARE 3
#define GAMEPAD_PS3_BUTTON_R1 7
#define GAMEPAD_PS3_BUTTON_R2 5
#define GAMEPAD_PS3_BUTTON_L1 6 #define GAMEPAD_PS3_BUTTON_L1 6
#define GAMEPAD_PS3_BUTTON_L2 8 #define GAMEPAD_PS3_BUTTON_R1 7
#define GAMEPAD_PS3_BUTTON_L2 4
#define GAMEPAD_PS3_BUTTON_R2 5
#define GAMEPAD_PS3_BUTTON_START 8
#define GAMEPAD_PS3_BUTTON_SELECT 9 #define GAMEPAD_PS3_BUTTON_SELECT 9
#define GAMEPAD_PS3_BUTTON_START 10 #define GAMEPAD_PS3_BUTTON_UP 24
#define GAMEPAD_PS3_BUTTON_RIGHT 25
#define GAMEPAD_PS3_BUTTON_DOWN 26
#define GAMEPAD_PS3_BUTTON_LEFT 27
#define GAMEPAD_PS3_BUTTON_PS 12
// TODO: Add PS3 d-pad axis // PS3 USB Controller Axis
#define GAMEPAD_PS3_AXIS_LEFT_X 0
#define GAMEPAD_PS3_AXIS_LEFT_Y 1
#define GAMEPAD_PS3_AXIS_RIGHT_X 2
#define GAMEPAD_PS3_AXIS_RIGHT_Y 5
#define GAMEPAD_PS3_AXIS_L2 3 // [1..-1] (pressure-level)
#define GAMEPAD_PS3_AXIS_R2 4 // [1..-1] (pressure-level)
// Xbox360 USB Controller Buttons // Xbox360 USB Controller Buttons
#define GAMEPAD_XBOX_BUTTON_A 0 #define GAMEPAD_XBOX_BUTTON_A 0
@ -217,33 +230,30 @@
#define GAMEPAD_XBOX_BUTTON_RB 5 #define GAMEPAD_XBOX_BUTTON_RB 5
#define GAMEPAD_XBOX_BUTTON_SELECT 6 #define GAMEPAD_XBOX_BUTTON_SELECT 6
#define GAMEPAD_XBOX_BUTTON_START 7 #define GAMEPAD_XBOX_BUTTON_START 7
#define GAMEPAD_XBOX_BUTTON_UP 10
#define GAMEPAD_XBOX_BUTTON_RIGHT 11
#define GAMEPAD_XBOX_BUTTON_DOWN 12
#define GAMEPAD_XBOX_BUTTON_LEFT 13
#define GAMEPAD_XBOX_BUTTON_HOME 8
// Xbox360 USB Controller Axis
// NOTE: For Raspberry Pi, axis must be reconfigured
#if defined(PLATFORM_RPI) #if defined(PLATFORM_RPI)
#define GAMEPAD_XBOX_AXIS_DPAD_X 7 #define GAMEPAD_XBOX_AXIS_LEFT_X 0 // [-1..1] (left->right)
#define GAMEPAD_XBOX_AXIS_DPAD_Y 6 #define GAMEPAD_XBOX_AXIS_LEFT_Y 1 // [-1..1] (up->down)
#define GAMEPAD_XBOX_AXIS_RIGHT_X 3 #define GAMEPAD_XBOX_AXIS_RIGHT_X 3 // [-1..1] (left->right)
#define GAMEPAD_XBOX_AXIS_RIGHT_Y 4 #define GAMEPAD_XBOX_AXIS_RIGHT_Y 4 // [-1..1] (up->down)
#define GAMEPAD_XBOX_AXIS_LT 2 #define GAMEPAD_XBOX_AXIS_LT 2 // [-1..1] (pressure-level)
#define GAMEPAD_XBOX_AXIS_RT 5 #define GAMEPAD_XBOX_AXIS_RT 5 // [-1..1] (pressure-level)
#else #else
#define GAMEPAD_XBOX_BUTTON_UP 10 #define GAMEPAD_XBOX_AXIS_LEFT_X 0 // [-1..1] (left->right)
#define GAMEPAD_XBOX_BUTTON_DOWN 12 #define GAMEPAD_XBOX_AXIS_LEFT_Y 1 // [1..-1] (up->down)
#define GAMEPAD_XBOX_BUTTON_LEFT 13 #define GAMEPAD_XBOX_AXIS_RIGHT_X 2 // [-1..1] (left->right)
#define GAMEPAD_XBOX_BUTTON_RIGHT 11 #define GAMEPAD_XBOX_AXIS_RIGHT_Y 3 // [1..-1] (up->down)
#define GAMEPAD_XBOX_AXIS_RIGHT_X 4 #define GAMEPAD_XBOX_AXIS_LT 4 // [-1..1] (pressure-level)
#define GAMEPAD_XBOX_AXIS_RIGHT_Y 3 #define GAMEPAD_XBOX_AXIS_RT 5 // [-1..1] (pressure-level)
#define GAMEPAD_XBOX_AXIS_LT_RT 2
#endif #endif
#define GAMEPAD_XBOX_AXIS_LEFT_X 0
#define GAMEPAD_XBOX_AXIS_LEFT_Y 1
// Android Physic Buttons
#define ANDROID_BACK 4
#define ANDROID_MENU 82
#define ANDROID_VOLUME_UP 24
#define ANDROID_VOLUME_DOWN 25
// NOTE: MSC C++ compiler does not support compound literals (C99 feature) // NOTE: MSC C++ compiler does not support compound literals (C99 feature)
// Plain structures in C++ (without constructors) can be initialized from { } initializers. // Plain structures in C++ (without constructors) can be initialized from { } initializers.
#ifdef __cplusplus #ifdef __cplusplus
@ -297,9 +307,6 @@
#endif #endif
#endif #endif
// byte type
typedef unsigned char byte;
// Vector2 type // Vector2 type
typedef struct Vector2 { typedef struct Vector2 {
float x; float x;
@ -427,7 +434,9 @@ typedef struct Shader {
// Uniform locations // Uniform locations
int mvpLoc; // ModelView-Projection matrix uniform location point (vertex shader) int mvpLoc; // ModelView-Projection matrix uniform location point (vertex shader)
int tintColorLoc; // Diffuse color uniform location point (fragment shader) int colDiffuseLoc; // Diffuse color uniform location point (fragment shader)
int colAmbientLoc; // Ambient color uniform location point (fragment shader)
int colSpecularLoc; // Specular color uniform location point (fragment shader)
// Texture map locations (generic for any kind of map) // Texture map locations (generic for any kind of map)
int mapTexture0Loc; // Map texture uniform location point (default-texture-unit = 0) int mapTexture0Loc; // Map texture uniform location point (default-texture-unit = 0)
@ -464,7 +473,7 @@ typedef struct LightData {
int type; // Light type: LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT int type; // Light type: LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT
Vector3 position; // Light position Vector3 position; // Light position
Vector3 target; // Light target: LIGHT_DIRECTIONAL and LIGHT_SPOT (cone direction target) Vector3 target; // Light direction: LIGHT_DIRECTIONAL and LIGHT_SPOT (cone direction target)
float radius; // Light attenuation radius light intensity reduced with distance (world distance) float radius; // Light attenuation radius light intensity reduced with distance (world distance)
Color diffuse; // Light diffuse color Color diffuse; // Light diffuse color
@ -482,12 +491,6 @@ typedef struct Ray {
Vector3 direction; // Ray direction Vector3 direction; // Ray direction
} Ray; } Ray;
// Sound source type
typedef struct Sound {
unsigned int source; // OpenAL audio source id
unsigned int buffer; // OpenAL audio buffer id
} Sound;
// Wave type, defines audio wave data // Wave type, defines audio wave data
typedef struct Wave { typedef struct Wave {
unsigned int sampleCount; // Number of samples unsigned int sampleCount; // Number of samples
@ -497,6 +500,13 @@ typedef struct Wave {
void *data; // Buffer data pointer void *data; // Buffer data pointer
} Wave; } Wave;
// Sound source type
typedef struct Sound {
unsigned int source; // OpenAL audio source id
unsigned int buffer; // OpenAL audio buffer id
int format; // OpenAL audio format specifier
} Sound;
// Music type (file streaming from memory) // Music type (file streaming from memory)
// NOTE: Anything longer than ~10 seconds should be streamed // NOTE: Anything longer than ~10 seconds should be streamed
typedef struct MusicData *Music; typedef struct MusicData *Music;
@ -536,6 +546,21 @@ typedef enum {
COMPRESSED_ASTC_8x8_RGBA // 2 bpp COMPRESSED_ASTC_8x8_RGBA // 2 bpp
} TextureFormat; } TextureFormat;
// Texture parameters: filter mode
// NOTE 1: Filtering considers mipmaps if available in the texture
// NOTE 2: Filter is accordingly set for minification and magnification
typedef enum {
FILTER_POINT = 0, // No filter, just pixel aproximation
FILTER_BILINEAR, // Linear filtering
FILTER_TRILINEAR, // Trilinear filtering (linear with mipmaps)
FILTER_ANISOTROPIC_4X, // Anisotropic filtering 4x
FILTER_ANISOTROPIC_8X, // Anisotropic filtering 8x
FILTER_ANISOTROPIC_16X, // Anisotropic filtering 16x
} TextureFilterMode;
// Texture parameters: wrap mode
typedef enum { WRAP_REPEAT = 0, WRAP_CLAMP, WRAP_MIRROR } TextureWrapMode;
// Color blending modes (pre-defined) // Color blending modes (pre-defined)
typedef enum { BLEND_ALPHA = 0, BLEND_ADDITIVE, BLEND_MULTIPLIED } BlendMode; typedef enum { BLEND_ALPHA = 0, BLEND_ADDITIVE, BLEND_MULTIPLIED } BlendMode;
@ -556,7 +581,13 @@ typedef enum {
} Gestures; } Gestures;
// Camera system modes // Camera system modes
typedef enum { CAMERA_CUSTOM = 0, CAMERA_FREE, CAMERA_ORBITAL, CAMERA_FIRST_PERSON, CAMERA_THIRD_PERSON } CameraMode; typedef enum {
CAMERA_CUSTOM = 0,
CAMERA_FREE,
CAMERA_ORBITAL,
CAMERA_FIRST_PERSON,
CAMERA_THIRD_PERSON
} CameraMode;
// Head Mounted Display devices // Head Mounted Display devices
typedef enum { typedef enum {
@ -584,7 +615,7 @@ extern "C" { // Prevents name mangling of functions
// Window and Graphics Device Functions (Module: core) // Window and Graphics Device Functions (Module: core)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
RLAPI void InitWindow(int width, int height, struct android_app *state); // Init Android Activity and OpenGL Graphics RLAPI void InitWindow(int width, int height, void *state); // Init Android Activity and OpenGL Graphics (struct android_app)
#elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB) #elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
RLAPI void InitWindow(int width, int height, const char *title); // Initialize Window and OpenGL Graphics RLAPI void InitWindow(int width, int height, const char *title); // Initialize Window and OpenGL Graphics
#endif #endif
@ -596,11 +627,13 @@ RLAPI void ToggleFullscreen(void); // Fullscreen
RLAPI int GetScreenWidth(void); // Get current screen width RLAPI int GetScreenWidth(void); // Get current screen width
RLAPI int GetScreenHeight(void); // Get current screen height RLAPI int GetScreenHeight(void); // Get current screen height
#if !defined(PLATFORM_ANDROID)
RLAPI void ShowCursor(void); // Shows cursor RLAPI void ShowCursor(void); // Shows cursor
RLAPI void HideCursor(void); // Hides cursor RLAPI void HideCursor(void); // Hides cursor
RLAPI bool IsCursorHidden(void); // Returns true if cursor is not visible RLAPI bool IsCursorHidden(void); // Returns true if cursor is not visible
RLAPI void EnableCursor(void); // Enables cursor RLAPI void EnableCursor(void); // Enables cursor
RLAPI void DisableCursor(void); // Disables cursor RLAPI void DisableCursor(void); // Disables cursor
#endif
RLAPI void ClearBackground(Color color); // Sets Background Color RLAPI void ClearBackground(Color color); // Sets Background Color
RLAPI void BeginDrawing(void); // Setup drawing canvas to start drawing RLAPI void BeginDrawing(void); // Setup drawing canvas to start drawing
@ -643,7 +676,6 @@ RLAPI int StorageLoadValue(int position); // Storage loa
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Input Handling Functions (Module: core) // Input Handling Functions (Module: core)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
RLAPI bool IsKeyPressed(int key); // Detect if a key has been pressed once RLAPI bool IsKeyPressed(int key); // Detect if a key has been pressed once
RLAPI bool IsKeyDown(int key); // Detect if a key is being pressed RLAPI bool IsKeyDown(int key); // Detect if a key is being pressed
RLAPI bool IsKeyReleased(int key); // Detect if a key has been released once RLAPI bool IsKeyReleased(int key); // Detect if a key has been released once
@ -652,12 +684,15 @@ RLAPI int GetKeyPressed(void); // Get latest key
RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC) RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
RLAPI bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available RLAPI bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis RLAPI bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available)
RLAPI const char *GetGamepadName(int gamepad); // Return gamepad internal name id
RLAPI bool IsGamepadButtonPressed(int gamepad, int button); // Detect if a gamepad button has been pressed once RLAPI bool IsGamepadButtonPressed(int gamepad, int button); // Detect if a gamepad button has been pressed once
RLAPI bool IsGamepadButtonDown(int gamepad, int button); // Detect if a gamepad button is being pressed RLAPI bool IsGamepadButtonDown(int gamepad, int button); // Detect if a gamepad button is being pressed
RLAPI bool IsGamepadButtonReleased(int gamepad, int button); // Detect if a gamepad button has been released once RLAPI bool IsGamepadButtonReleased(int gamepad, int button); // Detect if a gamepad button has been released once
RLAPI bool IsGamepadButtonUp(int gamepad, int button); // Detect if a gamepad button is NOT being pressed RLAPI bool IsGamepadButtonUp(int gamepad, int button); // Detect if a gamepad button is NOT being pressed
#endif RLAPI int GetGamepadButtonPressed(void); // Get the last gamepad button pressed
RLAPI int GetGamepadAxisCount(int gamepad); // Return gamepad axis count for a gamepad
RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis
RLAPI bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once RLAPI bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once
RLAPI bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed RLAPI bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed
@ -673,12 +708,6 @@ RLAPI int GetTouchX(void); // Returns touch p
RLAPI int GetTouchY(void); // Returns touch position Y for touch point 0 (relative to screen size) RLAPI int GetTouchY(void); // Returns touch position Y for touch point 0 (relative to screen size)
RLAPI Vector2 GetTouchPosition(int index); // Returns touch position XY for a touch point index (relative to screen size) RLAPI Vector2 GetTouchPosition(int index); // Returns touch position XY for a touch point index (relative to screen size)
#if defined(PLATFORM_ANDROID)
bool IsButtonPressed(int button); // Detect if an android physic button has been pressed
bool IsButtonDown(int button); // Detect if an android physic button is being pressed
bool IsButtonReleased(int button); // Detect if an android physic button has been released
#endif
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Gestures and Touch Handling Functions (Module: gestures) // Gestures and Touch Handling Functions (Module: gestures)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
@ -695,22 +724,15 @@ RLAPI float GetGesturePinchAngle(void); // Get gesture pin
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Camera System Functions (Module: camera) // Camera System Functions (Module: camera)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
RLAPI void SetCameraMode(int mode); // Set camera mode (multiple camera modes available) RLAPI void SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available)
RLAPI void UpdateCamera(Camera *camera); // Update camera (player position is ignored) RLAPI void UpdateCamera(Camera *camera); // Update camera position for selected mode
RLAPI void UpdateCameraPlayer(Camera *camera, Vector3 *position); // Update camera and player position (1st person and 3rd person cameras)
RLAPI void SetCameraPosition(Vector3 position); // Set internal camera position
RLAPI void SetCameraTarget(Vector3 target); // Set internal camera target
RLAPI void SetCameraFovy(float fovy); // Set internal camera field-of-view-y
RLAPI void SetCameraPanControl(int panKey); // Set camera pan key to combine with mouse movement (free camera) RLAPI void SetCameraPanControl(int panKey); // Set camera pan key to combine with mouse movement (free camera)
RLAPI void SetCameraAltControl(int altKey); // Set camera alt key to combine with mouse movement (free camera) RLAPI void SetCameraAltControl(int altKey); // Set camera alt key to combine with mouse movement (free camera)
RLAPI void SetCameraSmoothZoomControl(int szKey); // Set camera smooth zoom key to combine with mouse (free camera) RLAPI void SetCameraSmoothZoomControl(int szKey); // Set camera smooth zoom key to combine with mouse (free camera)
RLAPI void SetCameraMoveControls(int frontKey, int backKey, RLAPI void SetCameraMoveControls(int frontKey, int backKey,
int leftKey, int rightKey, int rightKey, int leftKey,
int upKey, int downKey); // Set camera move controls (1st person and 3rd person cameras) int upKey, int downKey); // Set camera move controls (1st person and 3rd person cameras)
RLAPI void SetCameraMouseSensitivity(float sensitivity); // Set camera mouse sensitivity (1st person and 3rd person cameras)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Basic Shapes Drawing Functions (Module: shapes) // Basic Shapes Drawing Functions (Module: shapes)
@ -759,8 +781,10 @@ RLAPI void UnloadTexture(Texture2D texture);
RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory
RLAPI Color *GetImageData(Image image); // Get pixel data from image as a Color struct array RLAPI Color *GetImageData(Image image); // Get pixel data from image as a Color struct array
RLAPI Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image RLAPI Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image
RLAPI void UpdateTexture(Texture2D texture, void *pixels); // Update GPU texture with new data
RLAPI void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two) RLAPI void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two)
RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image
RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
RLAPI Image ImageCopy(Image image); // Create an image duplicate (useful for transformations) RLAPI Image ImageCopy(Image image); // Create an image duplicate (useful for transformations)
RLAPI void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle RLAPI void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle
@ -778,8 +802,9 @@ RLAPI void ImageColorInvert(Image *image);
RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale
RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100) RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100)
RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255) RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255)
RLAPI void GenTextureMipmaps(Texture2D texture); // Generate GPU mipmaps for a texture RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture
RLAPI void UpdateTexture(Texture2D texture, void *pixels); // Update GPU texture with new data RLAPI void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode
RLAPI void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode
RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D RLAPI void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D
RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2 RLAPI void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2
@ -793,13 +818,14 @@ RLAPI void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle dest
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
RLAPI SpriteFont GetDefaultFont(void); // Get the default SpriteFont RLAPI SpriteFont GetDefaultFont(void); // Get the default SpriteFont
RLAPI SpriteFont LoadSpriteFont(const char *fileName); // Load a SpriteFont image into GPU memory RLAPI SpriteFont LoadSpriteFont(const char *fileName); // Load a SpriteFont image into GPU memory
RLAPI SpriteFont LoadSpriteFontTTF(const char *fileName, int fontSize, int numChars, int *fontChars); // Load a SpriteFont from TTF font with parameters
RLAPI void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory RLAPI void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
RLAPI void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters RLAPI void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters
float fontSize, int spacing, Color tint); float fontSize, int spacing, Color tint);
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
RLAPI Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, int fontSize, int spacing); // Measure string size for SpriteFont RLAPI Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, int spacing); // Measure string size for SpriteFont
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS on top-left corner RLAPI void DrawFPS(int posX, int posY); // Shows current FPS on top-left corner
RLAPI const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed' RLAPI const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed'
@ -809,7 +835,7 @@ RLAPI const char *SubText(const char *text, int position, int length);
// Basic 3d Shapes Drawing Functions (Module: models) // Basic 3d Shapes Drawing Functions (Module: models)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space RLAPI void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space
RLAPI void DrawCircle3D(Vector3 center, float radius, float rotationAngle, Vector3 rotation, Color color); // Draw a circle in 3D world space RLAPI void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color); // Draw a circle in 3D world space
RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube RLAPI void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube
RLAPI void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version) RLAPI void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version)
RLAPI void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires RLAPI void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires
@ -824,7 +850,7 @@ RLAPI void DrawRay(Ray ray, Color color);
RLAPI void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0)) RLAPI void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0))
RLAPI void DrawGizmo(Vector3 position); // Draw simple gizmo RLAPI void DrawGizmo(Vector3 position); // Draw simple gizmo
RLAPI void DrawLight(Light light); // Draw light in 3D world RLAPI void DrawLight(Light light); // Draw light in 3D world
//DrawTorus(), DrawTeapot() are useless... //DrawTorus(), DrawTeapot() could be useful?
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Model 3d Loading and Drawing Functions (Module: models) // Model 3d Loading and Drawing Functions (Module: models)
@ -836,9 +862,7 @@ RLAPI Model LoadHeightmap(Image heightmap, Vector3 size); // Load a
RLAPI Model LoadCubicmap(Image cubicmap); // Load a map image as a 3d model (cubes based) RLAPI Model LoadCubicmap(Image cubicmap); // Load a map image as a 3d model (cubes based)
RLAPI void UnloadModel(Model model); // Unload 3d model from memory RLAPI void UnloadModel(Model model); // Unload 3d model from memory
RLAPI Mesh GenMeshCube(float width, float height, float depth); // Generate mesh: cube RLAPI Material LoadMaterial(const char *fileName); // Load material data (.MTL)
RLAPI Material LoadMaterial(const char *fileName); // Load material data (from file)
RLAPI Material LoadDefaultMaterial(void); // Load default material (uses default models shader) RLAPI Material LoadDefaultMaterial(void); // Load default material (uses default models shader)
RLAPI Material LoadStandardMaterial(void); // Load standard material (uses material attributes and lighting shader) RLAPI Material LoadStandardMaterial(void); // Load standard material (uses material attributes and lighting shader)
RLAPI void UnloadMaterial(Material material); // Unload material textures from VRAM RLAPI void UnloadMaterial(Material material); // Unload material textures from VRAM
@ -859,8 +883,7 @@ RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 centerSphere, float
RLAPI bool CheckCollisionRaySphere(Ray ray, Vector3 spherePosition, float sphereRadius); // Detect collision between ray and sphere RLAPI bool CheckCollisionRaySphere(Ray ray, Vector3 spherePosition, float sphereRadius); // Detect collision between ray and sphere
RLAPI bool CheckCollisionRaySphereEx(Ray ray, Vector3 spherePosition, float sphereRadius, Vector3 *collisionPoint); // Detect collision between ray and sphere with extended parameters and collision point detection RLAPI bool CheckCollisionRaySphereEx(Ray ray, Vector3 spherePosition, float sphereRadius, Vector3 *collisionPoint); // Detect collision between ray and sphere with extended parameters and collision point detection
RLAPI bool CheckCollisionRayBox(Ray ray, BoundingBox box); // Detect collision between ray and box RLAPI bool CheckCollisionRayBox(Ray ray, BoundingBox box); // Detect collision between ray and box
RLAPI Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *playerPosition, float radius); // Detect collision of player radius with cubicmap
// NOTE: Return the normal vector of the impacted surface
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Shaders System Functions (Module: rlgl) // Shaders System Functions (Module: rlgl)
// NOTE: This functions are useless when using OpenGL 1.1 // NOTE: This functions are useless when using OpenGL 1.1
@ -894,20 +917,25 @@ RLAPI void DestroyLight(Light light); // Des
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
RLAPI void InitVrDevice(int vdDevice); // Init VR device RLAPI void InitVrDevice(int vdDevice); // Init VR device
RLAPI void CloseVrDevice(void); // Close VR device RLAPI void CloseVrDevice(void); // Close VR device
RLAPI bool IsVrDeviceReady(void); // Detect if VR device (or simulator) is ready RLAPI bool IsVrDeviceReady(void); // Detect if VR device is ready
RLAPI void UpdateVrTracking(void); // Update VR tracking (position and orientation) 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 ToggleVrMode(void); // Enable/Disable VR experience (device or simulator) RLAPI void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Audio Loading and Playing Functions (Module: audio) // Audio Loading and Playing Functions (Module: audio)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
RLAPI void InitAudioDevice(void); // Initialize audio device and context RLAPI void InitAudioDevice(void); // Initialize audio device and context
RLAPI void CloseAudioDevice(void); // Close the audio device and context (and music stream) RLAPI void CloseAudioDevice(void); // Close the audio device and context
RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully RLAPI bool IsAudioDeviceReady(void); // Check if audio device has been initialized successfully
RLAPI Sound LoadSound(char *fileName); // Load sound to memory RLAPI Wave LoadWave(const char *fileName); // Load wave data from file into RAM
RLAPI Wave LoadWaveEx(float *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from float array data (32bit)
RLAPI Sound LoadSound(const char *fileName); // Load sound to memory
RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound to memory from wave data RLAPI Sound LoadSoundFromWave(Wave wave); // Load sound to memory from wave data
RLAPI Sound LoadSoundFromRES(const char *rresName, int resId); // Load sound to memory from rRES file (raylib Resource) RLAPI Sound LoadSoundFromRES(const char *rresName, int resId); // Load sound to memory from rRES file (raylib Resource)
RLAPI void UpdateSound(Sound sound, void *data, int numSamples); // Update sound buffer with new data
RLAPI void UnloadWave(Wave wave); // Unload wave data
RLAPI void UnloadSound(Sound sound); // Unload sound RLAPI void UnloadSound(Sound sound); // Unload sound
RLAPI void PlaySound(Sound sound); // Play a sound RLAPI void PlaySound(Sound sound); // Play a sound
RLAPI void PauseSound(Sound sound); // Pause a sound RLAPI void PauseSound(Sound sound); // Pause a sound
@ -916,12 +944,15 @@ RLAPI void StopSound(Sound sound); // Stop pl
RLAPI bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing RLAPI bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing
RLAPI void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level) RLAPI void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level)
RLAPI void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level) RLAPI void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)
RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format
RLAPI Music LoadMusicStream(char *fileName); // Load music stream from file RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave
RLAPI void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range
RLAPI float *GetWaveData(Wave wave); // Get samples data from wave as a floats array
RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file
RLAPI void UnloadMusicStream(Music music); // Unload music stream RLAPI void UnloadMusicStream(Music music); // Unload music stream
RLAPI void PlayMusicStream(Music music); // Start music playing (open stream) RLAPI void PlayMusicStream(Music music); // Start music playing
RLAPI void UpdateMusicStream(Music music); // Updates buffers for music streaming RLAPI void UpdateMusicStream(Music music); // Updates buffers for music streaming
RLAPI void StopMusicStream(Music music); // Stop music playing (close stream) RLAPI void StopMusicStream(Music music); // Stop music playing
RLAPI void PauseMusicStream(Music music); // Pause music playing RLAPI void PauseMusicStream(Music music); // Pause music playing
RLAPI void ResumeMusicStream(Music music); // Resume playing paused music RLAPI void ResumeMusicStream(Music music); // Resume playing paused music
RLAPI bool IsMusicPlaying(Music music); // Check if music is playing RLAPI bool IsMusicPlaying(Music music); // Check if music is playing
@ -932,7 +963,7 @@ RLAPI float GetMusicTimePlayed(Music music); // Get cur
RLAPI AudioStream InitAudioStream(unsigned int sampleRate, RLAPI AudioStream InitAudioStream(unsigned int sampleRate,
unsigned int sampleSize, unsigned int sampleSize,
unsigned int channels); // Init audio stream (to stream audio pcm data) unsigned int channels); // Init audio stream (to stream raw audio pcm data)
RLAPI void UpdateAudioStream(AudioStream stream, void *data, int numSamples); // Update audio stream buffers with data RLAPI void UpdateAudioStream(AudioStream stream, void *data, int numSamples); // Update audio stream buffers with data
RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory RLAPI void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
RLAPI bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill RLAPI bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill