mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-07 22:59:17 -05:00
Compare commits
5 Commits
9931ddd27a
...
96fb4851ce
| Author | SHA1 | Date | |
|---|---|---|---|
| 96fb4851ce | |||
| 068978d5b3 | |||
| c1615aaac4 | |||
| b281101001 | |||
| c9b1f2ce54 |
@ -97,17 +97,9 @@ if (${PLATFORM} MATCHES "Android")
|
|||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_basic_lighting.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_basic_lighting.c)
|
||||||
|
|
||||||
elseif (${PLATFORM} MATCHES "Web")
|
elseif (${PLATFORM} MATCHES "Web")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os")
|
set(example_sources) # clear example_sources
|
||||||
# Since WASM is used, ALLOW_MEMORY_GROWTH has no extra overheads
|
list(APPEND example_sources others/web_basic_window.c)
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s WASM=1 -s ASYNCIFY -s ALLOW_MEMORY_GROWTH=1 --shell-file ${CMAKE_SOURCE_DIR}/src/shell.html")
|
list(APPEND example_sources core/core_input_gestures_testbed.c)
|
||||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
|
||||||
|
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/raylib_opengl_interop.c)
|
|
||||||
|
|
||||||
# Remove the -rdynamic flag because otherwise emscripten
|
|
||||||
# does not generate HTML+JS+WASM files, only a non-working
|
|
||||||
# and fat HTML
|
|
||||||
string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}")
|
|
||||||
|
|
||||||
elseif ("${PLATFORM}" STREQUAL "DRM")
|
elseif ("${PLATFORM}" STREQUAL "DRM")
|
||||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
|
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
|
||||||
@ -165,11 +157,35 @@ foreach (example_source ${example_sources})
|
|||||||
string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
|
string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
|
||||||
string(APPEND resources_dir "resources")
|
string(APPEND resources_dir "resources")
|
||||||
|
|
||||||
if (${PLATFORM} MATCHES "Web" AND EXISTS ${resources_dir})
|
if (${PLATFORM} MATCHES "Web")
|
||||||
|
target_compile_options(${example_name} PRIVATE -Os)
|
||||||
|
target_link_options(${example_name} PRIVATE
|
||||||
|
-sALLOW_MEMORY_GROWTH=1
|
||||||
|
-sEXPORTED_RUNTIME_METHODS=[requestFullscreen]
|
||||||
|
-sUSE_GLFW=3
|
||||||
|
--shell-file "${CMAKE_SOURCE_DIR}/src/shell.html"
|
||||||
|
)
|
||||||
|
set_target_properties(${example_name} PROPERTIES SUFFIX ".html")
|
||||||
|
|
||||||
|
if (EXISTS ${resources_dir})
|
||||||
# The local resources path needs to be mapped to /resources virtual path
|
# The local resources path needs to be mapped to /resources virtual path
|
||||||
string(APPEND resources_dir "@resources")
|
string(APPEND resources_dir "@resources")
|
||||||
set_target_properties(${example_name} PROPERTIES LINK_FLAGS "--preload-file ${resources_dir}")
|
set_target_properties(${example_name} PROPERTIES LINK_FLAGS "--preload-file ${resources_dir}")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if(${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_ES3")
|
||||||
|
target_link_options(${example_name} PUBLIC "-sMIN_WEBGL_VERSION=2")
|
||||||
|
target_link_options(${example_name} PUBLIC "-sMAX_WEBGL_VERSION=2")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Checks if OSX and links appropriate frameworks (Only required on MacOS)
|
||||||
|
if (APPLE)
|
||||||
|
target_link_libraries(${example_name} "-framework IOKit")
|
||||||
|
target_link_libraries(${example_name} "-framework Cocoa")
|
||||||
|
target_link_libraries(${example_name} "-framework OpenGL")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endif ()
|
||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
||||||
# Copy all of the resource files to the destination
|
# Copy all of the resource files to the destination
|
||||||
|
|||||||
@ -611,7 +611,7 @@ MODELS = \
|
|||||||
models/models_cubicmap_rendering \
|
models/models_cubicmap_rendering \
|
||||||
models/models_first_person_maze \
|
models/models_first_person_maze \
|
||||||
models/models_geometric_shapes \
|
models/models_geometric_shapes \
|
||||||
models/models_gpu_skinning \
|
models/models_animation_gpu_skinning \
|
||||||
models/models_heightmap_rendering \
|
models/models_heightmap_rendering \
|
||||||
models/models_loading \
|
models/models_loading \
|
||||||
models/models_loading_gltf \
|
models/models_loading_gltf \
|
||||||
|
|||||||
@ -611,7 +611,7 @@ MODELS = \
|
|||||||
models/models_cubicmap_rendering \
|
models/models_cubicmap_rendering \
|
||||||
models/models_first_person_maze \
|
models/models_first_person_maze \
|
||||||
models/models_geometric_shapes \
|
models/models_geometric_shapes \
|
||||||
models/models_gpu_skinning \
|
models/models_animation_gpu_skinning \
|
||||||
models/models_heightmap_rendering \
|
models/models_heightmap_rendering \
|
||||||
models/models_loading \
|
models/models_loading \
|
||||||
models/models_loading_gltf \
|
models/models_loading_gltf \
|
||||||
@ -1063,7 +1063,7 @@ models/models_first_person_maze: models/models_first_person_maze.c
|
|||||||
models/models_geometric_shapes: models/models_geometric_shapes.c
|
models/models_geometric_shapes: models/models_geometric_shapes.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||||
|
|
||||||
models/models_gpu_skinning: models/models_gpu_skinning.c
|
models/models_animation_gpu_skinning: models/models_animation_gpu_skinning.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||||
--preload-file models/resources/models/gltf/greenman.glb@resources/models/gltf/greenman.glb \
|
--preload-file models/resources/models/gltf/greenman.glb@resources/models/gltf/greenman.glb \
|
||||||
--preload-file models/resources/shaders/glsl100/skinning.vs@resources/shaders/glsl100/skinning.vs \
|
--preload-file models/resources/shaders/glsl100/skinning.vs@resources/shaders/glsl100/skinning.vs \
|
||||||
|
|||||||
@ -170,7 +170,7 @@ Examples using raylib models functionality, including models loading/generation
|
|||||||
| [models_heightmap_rendering](models/models_heightmap_rendering.c) | <img src="models/models_heightmap_rendering.png" alt="models_heightmap_rendering" width="80"> | ⭐☆☆☆ | 1.8 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
| [models_heightmap_rendering](models/models_heightmap_rendering.c) | <img src="models/models_heightmap_rendering.png" alt="models_heightmap_rendering" width="80"> | ⭐☆☆☆ | 1.8 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
||||||
| [models_skybox_rendering](models/models_skybox_rendering.c) | <img src="models/models_skybox_rendering.png" alt="models_skybox_rendering" width="80"> | ⭐⭐☆☆ | 1.8 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
| [models_skybox_rendering](models/models_skybox_rendering.c) | <img src="models/models_skybox_rendering.png" alt="models_skybox_rendering" width="80"> | ⭐⭐☆☆ | 1.8 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
|
||||||
| [models_textured_cube](models/models_textured_cube.c) | <img src="models/models_textured_cube.png" alt="models_textured_cube" width="80"> | ⭐⭐☆☆ | 4.5 | 4.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
| [models_textured_cube](models/models_textured_cube.c) | <img src="models/models_textured_cube.png" alt="models_textured_cube" width="80"> | ⭐⭐☆☆ | 4.5 | 4.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
||||||
| [models_gpu_skinning](models/models_gpu_skinning.c) | <img src="models/models_gpu_skinning.png" alt="models_gpu_skinning" width="80"> | ⭐⭐⭐☆ | 4.5 | 4.5 | [Daniel Holden](https://github.com/orangeduck) |
|
| [models_animation_gpu_skinning](models/models_animation_gpu_skinning.c) | <img src="models/models_animation_gpu_skinning.png" alt="models_animation_gpu_skinning" width="80"> | ⭐⭐⭐☆ | 4.5 | 4.5 | [Daniel Holden](https://github.com/orangeduck) |
|
||||||
| [models_bone_socket](models/models_bone_socket.c) | <img src="models/models_bone_socket.png" alt="models_bone_socket" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [iP](https://github.com/ipzaur) |
|
| [models_bone_socket](models/models_bone_socket.c) | <img src="models/models_bone_socket.png" alt="models_bone_socket" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [iP](https://github.com/ipzaur) |
|
||||||
| [models_tesseract_view](models/models_tesseract_view.c) | <img src="models/models_tesseract_view.png" alt="models_tesseract_view" width="80"> | ⭐⭐☆☆ | 5.6-dev | 5.6-dev | [Timothy van der Valk](https://github.com/arceryz) |
|
| [models_tesseract_view](models/models_tesseract_view.c) | <img src="models/models_tesseract_view.png" alt="models_tesseract_view" width="80"> | ⭐⭐☆☆ | 5.6-dev | 5.6-dev | [Timothy van der Valk](https://github.com/arceryz) |
|
||||||
|
|
||||||
|
|||||||
@ -19,56 +19,14 @@
|
|||||||
|
|
||||||
#include <math.h> // Required for the protractor angle graphic drawing
|
#include <math.h> // Required for the protractor angle graphic drawing
|
||||||
|
|
||||||
#if defined(PLATFORM_WEB)
|
|
||||||
#include <emscripten/emscripten.h> // Required for the Web/HTML5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define GESTURE_LOG_SIZE 20
|
#define GESTURE_LOG_SIZE 20
|
||||||
#define MAX_TOUCH_COUNT 32
|
#define MAX_TOUCH_COUNT 32
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
// Global Variables Definition
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
static int screenWidth = 800; // Update depending on web canvas
|
|
||||||
static const int screenHeight = 450;
|
|
||||||
static Vector2 messagePosition = { 160, 7 };
|
|
||||||
|
|
||||||
// Last gesture variables definitions
|
|
||||||
static int lastGesture = 0;
|
|
||||||
static Vector2 lastGesturePosition = { 165, 130 };
|
|
||||||
|
|
||||||
// Gesture log variables definitions
|
|
||||||
// NOTE: The gesture log uses an array (as an inverted circular queue) to store the performed gestures
|
|
||||||
static char gestureLog[GESTURE_LOG_SIZE][12] = { "" };
|
|
||||||
// NOTE: The index for the inverted circular queue (moving from last to first direction, then looping around)
|
|
||||||
static int gestureLogIndex = GESTURE_LOG_SIZE;
|
|
||||||
static int previousGesture = 0;
|
|
||||||
|
|
||||||
// Log mode values:
|
|
||||||
// - 0 shows repeated events
|
|
||||||
// - 1 hides repeated events
|
|
||||||
// - 2 shows repeated events but hide hold events
|
|
||||||
// - 3 hides repeated events and hide hold events
|
|
||||||
static int logMode = 1;
|
|
||||||
|
|
||||||
static Color gestureColor = { 0, 0, 0, 255 };
|
|
||||||
static Rectangle logButton1 = { 53, 7, 48, 26 };
|
|
||||||
static Rectangle logButton2 = { 108, 7, 36, 26 };
|
|
||||||
static Vector2 gestureLogPosition = { 10, 10 };
|
|
||||||
|
|
||||||
// Protractor variables definitions
|
|
||||||
static float angleLength = 90.0f;
|
|
||||||
static float currentAngleDegrees = 0.0f;
|
|
||||||
static Vector2 finalVector = { 0.0f, 0.0f };
|
|
||||||
static char currentAngleStr[7] = "";
|
|
||||||
static Vector2 protractorPosition = { 266.0f, 315.0f };
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module Functions Declaration
|
// Module Functions Declaration
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
static void UpdateDrawFrame(void); // Update and Draw one frame
|
static char const *GetGestureName(int gesture); // Get text string for gesture value
|
||||||
static char const *GetGestureName(int i);
|
static Color GetGestureColor(int gesture); // Get color for gesture value
|
||||||
static Color GetGestureColor(int i);
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
@ -77,34 +35,49 @@ int main(void)
|
|||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures testbed");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures testbed");
|
||||||
|
|
||||||
#if defined(PLATFORM_WEB)
|
Vector2 messagePosition = { 160, 7 };
|
||||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
|
||||||
#else
|
// Last gesture variables definitions
|
||||||
|
int lastGesture = 0;
|
||||||
|
Vector2 lastGesturePosition = { 165, 130 };
|
||||||
|
|
||||||
|
// Gesture log variables definitions
|
||||||
|
// NOTE: The gesture log uses an array (as an inverted circular queue) to store the performed gestures
|
||||||
|
char gestureLog[GESTURE_LOG_SIZE][12] = { "" };
|
||||||
|
// NOTE: The index for the inverted circular queue (moving from last to first direction, then looping around)
|
||||||
|
int gestureLogIndex = GESTURE_LOG_SIZE;
|
||||||
|
int previousGesture = 0;
|
||||||
|
|
||||||
|
// Log mode values:
|
||||||
|
// - 0 shows repeated events
|
||||||
|
// - 1 hides repeated events
|
||||||
|
// - 2 shows repeated events but hide hold events
|
||||||
|
// - 3 hides repeated events and hide hold events
|
||||||
|
int logMode = 1;
|
||||||
|
|
||||||
|
Color gestureColor = { 0, 0, 0, 255 };
|
||||||
|
Rectangle logButton1 = { 53, 7, 48, 26 };
|
||||||
|
Rectangle logButton2 = { 108, 7, 36, 26 };
|
||||||
|
Vector2 gestureLogPosition = { 10, 10 };
|
||||||
|
|
||||||
|
// Protractor variables definitions
|
||||||
|
float angleLength = 90.0f;
|
||||||
|
float currentAngleDegrees = 0.0f;
|
||||||
|
Vector2 finalVector = { 0.0f, 0.0f };
|
||||||
|
char currentAngleStr[7] = "";
|
||||||
|
Vector2 protractorPosition = { 266.0f, 315.0f };
|
||||||
|
|
||||||
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 (!WindowShouldClose()) // Detect window close button or ESC key
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
{
|
||||||
UpdateDrawFrame();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Module Functions Definition
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
static void UpdateDrawFrame(void)
|
|
||||||
{
|
|
||||||
// Update
|
// Update
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Handle common gestures data
|
// Handle common gestures data
|
||||||
@ -125,20 +98,20 @@ static void UpdateDrawFrame(void)
|
|||||||
{
|
{
|
||||||
switch (logMode)
|
switch (logMode)
|
||||||
{
|
{
|
||||||
case 3: logMode=2; break;
|
case 3: logMode = 2; break;
|
||||||
case 2: logMode=3; break;
|
case 2: logMode = 3; break;
|
||||||
case 1: logMode=0; break;
|
case 1: logMode = 0; break;
|
||||||
default: logMode=1; break;
|
default: logMode = 1; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (CheckCollisionPointRec(GetMousePosition(), logButton2))
|
else if (CheckCollisionPointRec(GetMousePosition(), logButton2))
|
||||||
{
|
{
|
||||||
switch (logMode)
|
switch (logMode)
|
||||||
{
|
{
|
||||||
case 3: logMode=1; break;
|
case 3: logMode = 1; break;
|
||||||
case 2: logMode=0; break;
|
case 2: logMode = 0; break;
|
||||||
case 1: logMode=3; break;
|
case 1: logMode = 3; break;
|
||||||
default: logMode=2; break;
|
default: logMode = 2; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,25 +149,18 @@ static void UpdateDrawFrame(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle protractor
|
// Handle protractor
|
||||||
if (currentGesture > 255) // aka Pinch In and Pinch Out
|
if (currentGesture > 255) currentAngleDegrees = currentPitchDegrees; // Pinch In and Pinch Out
|
||||||
{
|
else if (currentGesture > 15) currentAngleDegrees = currentDragDegrees; // Swipe Right, Swipe Left, Swipe Up and Swipe Down
|
||||||
currentAngleDegrees = currentPitchDegrees;
|
else if (currentGesture > 0) currentAngleDegrees = 0.0f; // Tap, Doubletap, Hold and Grab
|
||||||
}
|
|
||||||
else if (currentGesture > 15) // aka Swipe Right, Swipe Left, Swipe Up and Swipe Down
|
|
||||||
{
|
|
||||||
currentAngleDegrees = currentDragDegrees;
|
|
||||||
}
|
|
||||||
else if (currentGesture > 0) // aka Tap, Doubletap, Hold and Grab
|
|
||||||
{
|
|
||||||
currentAngleDegrees = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
float currentAngleRadians = ((currentAngleDegrees +90.0f)*PI/180); // Convert the current angle to Radians
|
float currentAngleRadians = ((currentAngleDegrees + 90.0f)*PI/180); // Convert the current angle to Radians
|
||||||
finalVector = (Vector2){ (angleLength*sinf(currentAngleRadians)) + protractorPosition.x, (angleLength*cosf(currentAngleRadians)) + protractorPosition.y }; // Calculate the final vector for display
|
// Calculate the final vector for display
|
||||||
|
finalVector = (Vector2){ (angleLength*sinf(currentAngleRadians)) + protractorPosition.x,
|
||||||
|
(angleLength*cosf(currentAngleRadians)) + protractorPosition.y };
|
||||||
|
|
||||||
// Handle touch and mouse pointer points
|
// Handle touch and mouse pointer points
|
||||||
Vector2 touchPosition[MAX_TOUCH_COUNT] = { 0 };
|
Vector2 touchPosition[MAX_TOUCH_COUNT] = { 0 };
|
||||||
Vector2 mousePosition = {0, 0};
|
Vector2 mousePosition = { 0 };
|
||||||
if (currentGesture != GESTURE_NONE)
|
if (currentGesture != GESTURE_NONE)
|
||||||
{
|
{
|
||||||
if (touchCount != 0)
|
if (touchCount != 0)
|
||||||
@ -296,11 +262,23 @@ static void UpdateDrawFrame(void)
|
|||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char const *GetGestureName(int i)
|
//----------------------------------------------------------------------------------
|
||||||
|
// Module Functions Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Get text string for gesture value
|
||||||
|
static char const *GetGestureName(int gesture)
|
||||||
{
|
{
|
||||||
switch (i)
|
switch (gesture)
|
||||||
{
|
{
|
||||||
case 0: return "None"; break;
|
case 0: return "None"; break;
|
||||||
case 1: return "Tap"; break;
|
case 1: return "Tap"; break;
|
||||||
@ -317,9 +295,10 @@ static char const *GetGestureName(int i)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Color GetGestureColor(int i)
|
// Get color for gesture value
|
||||||
|
static Color GetGestureColor(int gesture)
|
||||||
{
|
{
|
||||||
switch (i)
|
switch (gesture)
|
||||||
{
|
{
|
||||||
case 0: return BLACK; break;
|
case 0: return BLACK; break;
|
||||||
case 1: return BLUE; break;
|
case 1: return BLUE; break;
|
||||||
|
|||||||
@ -124,7 +124,7 @@ models;models_waving_cubes;★★★☆;2.5;3.7;2019;2025;"Codecat";@codecat
|
|||||||
models;models_heightmap_rendering;★☆☆☆;1.8;3.5;2015;2025;"Ramon Santamaria";@raysan5
|
models;models_heightmap_rendering;★☆☆☆;1.8;3.5;2015;2025;"Ramon Santamaria";@raysan5
|
||||||
models;models_skybox_rendering;★★☆☆;1.8;4.0;2017;2025;"Ramon Santamaria";@raysan5
|
models;models_skybox_rendering;★★☆☆;1.8;4.0;2017;2025;"Ramon Santamaria";@raysan5
|
||||||
models;models_textured_cube;★★☆☆;4.5;4.5;2022;2025;"Ramon Santamaria";@raysan5
|
models;models_textured_cube;★★☆☆;4.5;4.5;2022;2025;"Ramon Santamaria";@raysan5
|
||||||
models;models_gpu_skinning;★★★☆;4.5;4.5;2024;2025;"Daniel Holden";@orangeduck
|
models;models_animation_gpu_skinning;★★★☆;4.5;4.5;2024;2025;"Daniel Holden";@orangeduck
|
||||||
models;models_bone_socket;★★★★;4.5;4.5;2024;2025;"iP";@ipzaur
|
models;models_bone_socket;★★★★;4.5;4.5;2024;2025;"iP";@ipzaur
|
||||||
models;models_tesseract_view;★★☆☆;5.6-dev;5.6-dev;2024;2025;"Timothy van der Valk";@arceryz
|
models;models_tesseract_view;★★☆☆;5.6-dev;5.6-dev;2024;2025;"Timothy van der Valk";@arceryz
|
||||||
shaders;shaders_basic_lighting;★★★★;3.0;4.2;2019;2025;"Chris Camacho";@chriscamacho
|
shaders;shaders_basic_lighting;★★★★;3.0;4.2;2019;2025;"Chris Camacho";@chriscamacho
|
||||||
|
|||||||
@ -36,8 +36,9 @@
|
|||||||
|
|
||||||
10. Have fun!
|
10. Have fun!
|
||||||
|
|
||||||
The following files should be updated when adding a new example, it's planned to create some
|
The following files must be updated when adding a new example,
|
||||||
script to automatize this process but not available yet
|
but it can be automatically done using the raylib provided tool: rexm
|
||||||
|
So, no worries if just the .c/.png are provided when adding the example.
|
||||||
|
|
||||||
- raylib/examples/<category>/<category>_example_name.c
|
- raylib/examples/<category>/<category>_example_name.c
|
||||||
- raylib/examples/<category>/<category>_example_name.png
|
- raylib/examples/<category>/<category>_example_name.png
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [models] example - gpu skinning
|
* raylib [models] example - animation gpu skinning
|
||||||
*
|
*
|
||||||
* Example complexity rating: [★★★☆] 3/4
|
* Example complexity rating: [★★★☆] 3/4
|
||||||
*
|
*
|
||||||
@ -37,7 +37,7 @@ int main(void)
|
|||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - gpu skinning");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - animation gpu skinning");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = { 0 };
|
Camera camera = { 0 };
|
||||||
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [core] example - Basic window (adapted for HTML5 platform)
|
* raylib [others] example - Basic window (adapted for HTML5 platform)
|
||||||
*
|
*
|
||||||
* This example is prepared to compile for PLATFORM_WEB and PLATFORM_DESKTOP
|
* This example is prepared to compile for PLATFORM_WEB and PLATFORM_DESKTOP
|
||||||
* As you will notice, code structure is slightly different to the other examples...
|
* As you will notice, code structure is slightly different to the other examples...
|
||||||
@ -37,7 +37,7 @@ int main()
|
|||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
|
InitWindow(screenWidth, screenHeight, "raylib [others] example - web basic window");
|
||||||
|
|
||||||
#if defined(PLATFORM_WEB)
|
#if defined(PLATFORM_WEB)
|
||||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||||
@ -1,41 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.11) # FetchContent is available in 3.11+
|
|
||||||
project(example)
|
|
||||||
|
|
||||||
# Generate compile_commands.json
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
||||||
|
|
||||||
# Dependencies
|
|
||||||
set(RAYLIB_VERSION 5.5)
|
|
||||||
find_package(raylib ${RAYLIB_VERSION} QUIET) # QUIET or REQUIRED
|
|
||||||
if (NOT raylib_FOUND) # If there's none, fetch and build raylib
|
|
||||||
include(FetchContent)
|
|
||||||
FetchContent_Declare(
|
|
||||||
raylib
|
|
||||||
DOWNLOAD_EXTRACT_TIMESTAMP OFF
|
|
||||||
URL https://github.com/raysan5/raylib/archive/refs/tags/${RAYLIB_VERSION}.tar.gz
|
|
||||||
)
|
|
||||||
FetchContent_GetProperties(raylib)
|
|
||||||
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?
|
|
||||||
set(FETCHCONTENT_QUIET NO)
|
|
||||||
FetchContent_MakeAvailable(raylib)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Our Project
|
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} core_basic_window.c)
|
|
||||||
#set(raylib_VERBOSE 1)
|
|
||||||
target_link_libraries(${PROJECT_NAME} raylib)
|
|
||||||
|
|
||||||
# Web Configurations
|
|
||||||
if (${PLATFORM} STREQUAL "Web")
|
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".html") # Tell Emscripten to build an example.html file.
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY -s GL_ENABLE_GET_PROC_ADDRESS=1")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Checks if OSX and links appropriate frameworks (Only required on MacOS)
|
|
||||||
if (APPLE)
|
|
||||||
target_link_libraries(${PROJECT_NAME} "-framework IOKit")
|
|
||||||
target_link_libraries(${PROJECT_NAME} "-framework Cocoa")
|
|
||||||
target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
|
|
||||||
endif()
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
# raylib CMake Project
|
|
||||||
|
|
||||||
This provides a base project template which builds with [CMake](https://cmake.org).
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
To compile the example, use one of the following dependending on your build target...
|
|
||||||
|
|
||||||
### Desktop
|
|
||||||
|
|
||||||
Use the following to build for desktop:
|
|
||||||
|
|
||||||
``` bash
|
|
||||||
cmake -B build
|
|
||||||
cmake --build build
|
|
||||||
```
|
|
||||||
|
|
||||||
### Web
|
|
||||||
|
|
||||||
Compiling for the web requires the [Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html):
|
|
||||||
|
|
||||||
``` bash
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
emcmake cmake .. -DPLATFORM=Web -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXECUTABLE_SUFFIX=".html"
|
|
||||||
emmake make
|
|
||||||
```
|
|
||||||
@ -55,7 +55,7 @@
|
|||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>models_loading</RootNamespace>
|
<RootNamespace>models_loading</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
<ProjectName>models_gpu_skinning</ProjectName>
|
<ProjectName>models_animation_gpu_skinning</ProjectName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
@ -553,7 +553,7 @@
|
|||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\..\examples\models\models_gpu_skinning.c" />
|
<ClCompile Include="..\..\..\examples\models\models_animation_gpu_skinning.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="..\..\..\examples\examples.rc" />
|
<ResourceCompile Include="..\..\..\examples\examples.rc" />
|
||||||
@ -299,7 +299,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shapes_top_down_lights", "e
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shapes_rectangle_advanced", "examples\shapes_rectangle_advanced.vcxproj", "{FAFEE2F9-24B0-4AF1-B512-433E9590033F}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shapes_rectangle_advanced", "examples\shapes_rectangle_advanced.vcxproj", "{FAFEE2F9-24B0-4AF1-B512-433E9590033F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "models_gpu_skinning", "examples\models_gpu_skinning.vcxproj", "{8245DAD9-D402-4D5C-8F45-32229CD3B263}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "models_animation_gpu_skinning", "examples\models_animation_gpu_skinning.vcxproj", "{8245DAD9-D402-4D5C-8F45-32229CD3B263}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_shadowmap_rendering", "examples\shaders_shadowmap_rendering.vcxproj", "{41BBCC10-6FDE-48A1-B2E0-A0EC6A668629}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_shadowmap_rendering", "examples\shaders_shadowmap_rendering.vcxproj", "{41BBCC10-6FDE-48A1-B2E0-A0EC6A668629}"
|
||||||
EndProject
|
EndProject
|
||||||
|
|||||||
@ -68,14 +68,6 @@ else()
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (${PLATFORM} MATCHES "Web")
|
|
||||||
target_link_options(raylib PUBLIC "-sUSE_GLFW=3" -sEXPORTED_RUNTIME_METHODS=ccall -sASYNCIFY)
|
|
||||||
if(${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_ES3")
|
|
||||||
target_link_options(raylib PUBLIC "-sMIN_WEBGL_VERSION=2")
|
|
||||||
target_link_options(raylib PUBLIC "-sMAX_WEBGL_VERSION=2")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set_target_properties(raylib PROPERTIES
|
set_target_properties(raylib PROPERTIES
|
||||||
PUBLIC_HEADER "${raylib_public_headers}"
|
PUBLIC_HEADER "${raylib_public_headers}"
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
<link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
|
<link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body { font-family: arial; margin: 0; padding: none; }
|
body { font-family: arial; margin: 0; padding: unset; }
|
||||||
|
|
||||||
#header {
|
#header {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
Reference in New Issue
Block a user