Formatting review and examples review
This commit is contained in:
parent
4bceddd4de
commit
2f6230e366
16 changed files with 30 additions and 125 deletions
|
@ -344,12 +344,13 @@ ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_R
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --preload-file resources # specify a resources folder for data compilation
|
||||||
# --source-map-base # allow debugging in browser with source map
|
# --source-map-base # allow debugging in browser with source map
|
||||||
# --shell-file shell.html # define a custom shell .html and output extension
|
# --shell-file shell.html # define a custom shell .html and output extension
|
||||||
|
LDFLAGS += -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sFORCE_FILESYSTEM=1 -sMINIFY_HTML=0
|
||||||
|
|
||||||
|
# Using GLFW3 library (instead of RGFW)
|
||||||
ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
|
ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
|
||||||
LDFLAGS += -sUSE_GLFW=3
|
LDFLAGS += -sUSE_GLFW=3
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LDFLAGS += -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sFORCE_FILESYSTEM=1
|
|
||||||
|
|
||||||
# Build using asyncify
|
# Build using asyncify
|
||||||
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
|
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
|
||||||
LDFLAGS += -sASYNCIFY
|
LDFLAGS += -sASYNCIFY
|
||||||
|
|
|
@ -280,12 +280,13 @@ ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
|
||||||
# --preload-file resources # specify a resources folder for data compilation
|
# --preload-file resources # specify a resources folder for data compilation
|
||||||
# --source-map-base # allow debugging in browser with source map
|
# --source-map-base # allow debugging in browser with source map
|
||||||
# --shell-file shell.html # define a custom shell .html and output extension
|
# --shell-file shell.html # define a custom shell .html and output extension
|
||||||
|
LDFLAGS += -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sFORCE_FILESYSTEM=1 -sEXPORTED_RUNTIME_METHODS=ccall -sMINIFY_HTML=0
|
||||||
|
|
||||||
|
# Using GLFW3 library (instead of RGFW)
|
||||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
LDFLAGS += -sUSE_GLFW=3
|
LDFLAGS += -sUSE_GLFW=3
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LDFLAGS += -sEXPORTED_RUNTIME_METHODS=ccall -s
|
|
||||||
|
|
||||||
# Build using asyncify
|
# Build using asyncify
|
||||||
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
|
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
|
||||||
LDFLAGS += -sASYNCIFY
|
LDFLAGS += -sASYNCIFY
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
@ -46,7 +46,7 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
switch(currentScreen)
|
switch (currentScreen)
|
||||||
{
|
{
|
||||||
case LOGO:
|
case LOGO:
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,83 +0,0 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raylib [core] example - Gamepad information
|
|
||||||
*
|
|
||||||
* NOTE: This example requires a Gamepad connected to the system
|
|
||||||
* Check raylib.h for buttons configuration
|
|
||||||
*
|
|
||||||
* Example originally created with raylib 4.6, last time updated with raylib 4.6
|
|
||||||
*
|
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
||||||
* BSD-like license that allows static linking with closed source software
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad information");
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// TODO: Update your variables here
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
for (int i = 0, y = 5; i < 4; i++) // MAX_GAMEPADS = 4
|
|
||||||
{
|
|
||||||
if (IsGamepadAvailable(i))
|
|
||||||
{
|
|
||||||
DrawText(TextFormat("Gamepad name: %s", GetGamepadName(i)), 10, y, 10, BLACK);
|
|
||||||
y += 11;
|
|
||||||
DrawText(TextFormat("\tAxis count: %d", GetGamepadAxisCount(i)), 10, y, 10, BLACK);
|
|
||||||
y += 11;
|
|
||||||
|
|
||||||
for (int axis = 0; axis < GetGamepadAxisCount(i); axis++)
|
|
||||||
{
|
|
||||||
DrawText(TextFormat("\tAxis %d = %f", axis, GetGamepadAxisMovement(i, axis)), 10, y, 10, BLACK);
|
|
||||||
y += 11;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int button = 0; button < 32; button++)
|
|
||||||
{
|
|
||||||
DrawText(TextFormat("\tButton %d = %d", button, IsGamepadButtonDown(i, button)), 10, y, 10, BLACK);
|
|
||||||
y += 11;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawFPS(GetScreenWidth() - 100, 100);
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
}
|
|
|
@ -42,7 +42,7 @@ int main(void)
|
||||||
// Get the touch point count ( how many fingers are touching the screen )
|
// Get the touch point count ( how many fingers are touching the screen )
|
||||||
int tCount = GetTouchPointCount();
|
int tCount = GetTouchPointCount();
|
||||||
// Clamp touch points available ( set the maximum touch points allowed )
|
// Clamp touch points available ( set the maximum touch points allowed )
|
||||||
if(tCount > MAX_TOUCH_POINTS) tCount = MAX_TOUCH_POINTS;
|
if (tCount > MAX_TOUCH_POINTS) tCount = MAX_TOUCH_POINTS;
|
||||||
// Get touch points positions
|
// Get touch points positions
|
||||||
for (int i = 0; i < tCount; ++i) touchPositions[i] = GetTouchPosition(i);
|
for (int i = 0; i < tCount; ++i) touchPositions[i] = GetTouchPosition(i);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -115,26 +115,10 @@ int main(void)
|
||||||
// Move player according to pressed button
|
// Move player according to pressed button
|
||||||
switch (pressedButton)
|
switch (pressedButton)
|
||||||
{
|
{
|
||||||
case BUTTON_UP:
|
case BUTTON_UP: playerPosition.y -= playerSpeed*GetFrameTime(); break;
|
||||||
{
|
case BUTTON_LEFT: playerPosition.x -= playerSpeed*GetFrameTime(); break;
|
||||||
playerPosition.y -= playerSpeed*GetFrameTime();
|
case BUTTON_RIGHT: playerPosition.x += playerSpeed*GetFrameTime(); break;
|
||||||
break;
|
case BUTTON_DOWN: playerPosition.y += playerSpeed*GetFrameTime(); break;
|
||||||
}
|
|
||||||
case BUTTON_LEFT:
|
|
||||||
{
|
|
||||||
playerPosition.x -= playerSpeed*GetFrameTime();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case BUTTON_RIGHT:
|
|
||||||
{
|
|
||||||
playerPosition.x += playerSpeed*GetFrameTime();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case BUTTON_DOWN:
|
|
||||||
{
|
|
||||||
playerPosition.y += playerSpeed*GetFrameTime();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: break;
|
default: break;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,6 @@ static void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, i
|
||||||
int pressSize = MeasureText("Press", fontSize);
|
int pressSize = MeasureText("Press", fontSize);
|
||||||
int keySize = MeasureText(key, fontSize);
|
int keySize = MeasureText(key, fontSize);
|
||||||
int textSize = MeasureText(text, fontSize);
|
int textSize = MeasureText(text, fontSize);
|
||||||
int totalSize = pressSize + 2*spaceSize + keySize + 2*spaceSize + textSize;
|
|
||||||
int textSizeCurrent = 0;
|
int textSizeCurrent = 0;
|
||||||
|
|
||||||
DrawText("Press", posX, posY, fontSize, color);
|
DrawText("Press", posX, posY, fontSize, color);
|
||||||
|
|
BIN
examples/models/models_gpu_skinning.png
Normal file
BIN
examples/models/models_gpu_skinning.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
|
@ -112,7 +112,7 @@ int main(void)
|
||||||
DrawRectangleLines(30, 400, 310, 30, Fade(DARKBLUE, 0.5f));
|
DrawRectangleLines(30, 400, 310, 30, Fade(DARKBLUE, 0.5f));
|
||||||
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL MODELS", 40, 410, 10, BLUE);
|
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL MODELS", 40, 410, 10, BLUE);
|
||||||
|
|
||||||
switch(currentModel)
|
switch (currentModel)
|
||||||
{
|
{
|
||||||
case 0: DrawText("PLANE", 680, 10, 20, DARKBLUE); break;
|
case 0: DrawText("PLANE", 680, 10, 20, DARKBLUE); break;
|
||||||
case 1: DrawText("CUBE", 680, 10, 20, DARKBLUE); break;
|
case 1: DrawText("CUBE", 680, 10, 20, DARKBLUE); break;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#define MIN_POINTS 1000 // 1 thousand
|
#define MIN_POINTS 1000 // 1 thousand
|
||||||
|
|
||||||
// Generate mesh using points
|
// Generate mesh using points
|
||||||
Mesh GenMeshPoints(int numPoints);
|
static Mesh GenMeshPoints(int numPoints);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
|
@ -56,7 +56,7 @@ int main()
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while(!WindowShouldClose())
|
while (!WindowShouldClose())
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -147,7 +147,7 @@ int main()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a spherical point cloud
|
// Generate a spherical point cloud
|
||||||
Mesh GenMeshPoints(int numPoints)
|
static Mesh GenMeshPoints(int numPoints)
|
||||||
{
|
{
|
||||||
Mesh mesh = {
|
Mesh mesh = {
|
||||||
.triangleCount = 1,
|
.triangleCount = 1,
|
||||||
|
@ -159,9 +159,9 @@ Mesh GenMeshPoints(int numPoints)
|
||||||
// https://en.wikipedia.org/wiki/Spherical_coordinate_system
|
// https://en.wikipedia.org/wiki/Spherical_coordinate_system
|
||||||
for (int i = 0; i < numPoints; i++)
|
for (int i = 0; i < numPoints; i++)
|
||||||
{
|
{
|
||||||
float theta = PI*rand()/RAND_MAX;
|
float theta = ((float)PI*rand())/RAND_MAX;
|
||||||
float phi = 2.0f*PI*rand()/RAND_MAX;
|
float phi = (2.0f*PI*rand())/RAND_MAX;
|
||||||
float r = 10.0f*rand()/RAND_MAX;
|
float r = (10.0f*rand())/RAND_MAX;
|
||||||
|
|
||||||
mesh.vertices[i*3 + 0] = r*sin(theta)*cos(phi);
|
mesh.vertices[i*3 + 0] = r*sin(theta)*cos(phi);
|
||||||
mesh.vertices[i*3 + 1] = r*sin(theta)*sin(phi);
|
mesh.vertices[i*3 + 1] = r*sin(theta)*sin(phi);
|
||||||
|
|
|
@ -74,7 +74,7 @@ int main(void)
|
||||||
|
|
||||||
// Projection from XYZW to XYZ from perspective point (0, 0, 0, 3)
|
// Projection from XYZW to XYZ from perspective point (0, 0, 0, 3)
|
||||||
// NOTE: Trace a ray from (0, 0, 0, 3) > p and continue until W = 0
|
// NOTE: Trace a ray from (0, 0, 0, 3) > p and continue until W = 0
|
||||||
float c = 3/(3 - p.w);
|
float c = 3.0f/(3.0f - p.w);
|
||||||
p.x = c * p.x;
|
p.x = c * p.x;
|
||||||
p.y = c * p.y;
|
p.y = c * p.y;
|
||||||
p.z = c * p.z;
|
p.z = c * p.z;
|
||||||
|
@ -95,7 +95,7 @@ int main(void)
|
||||||
for (int i = 0; i < 16; i++)
|
for (int i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
// Draw spheres to indicate the W value
|
// Draw spheres to indicate the W value
|
||||||
DrawSphere(transformed[i], fabsf(wValues[i]*0.1), RED);
|
DrawSphere(transformed[i], fabsf(wValues[i]*0.1f), RED);
|
||||||
|
|
||||||
for (int j = 0; j < 16; j++)
|
for (int j = 0; j < 16; j++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,7 +51,7 @@ int main(void)
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_SPACE)) angleMode = !angleMode;
|
if (IsKeyPressed(KEY_SPACE)) angleMode = !angleMode;
|
||||||
|
|
||||||
if(angleMode == 0 && IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) v1 = GetMousePosition();
|
if ((angleMode == 0) && IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) v1 = GetMousePosition();
|
||||||
|
|
||||||
if (angleMode == 0)
|
if (angleMode == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -273,7 +273,7 @@ int main(void)
|
||||||
// that represent light positions in default forward rendering
|
// that represent light positions in default forward rendering
|
||||||
BeginMode3D(camera);
|
BeginMode3D(camera);
|
||||||
rlEnableShader(rlGetShaderIdDefault());
|
rlEnableShader(rlGetShaderIdDefault());
|
||||||
for(int i = 0; i < MAX_LIGHTS; i++)
|
for (int i = 0; i < MAX_LIGHTS; i++)
|
||||||
{
|
{
|
||||||
if (lights[i].enabled) DrawSphereEx(lights[i].position, 0.2f, 8, 8, lights[i].color);
|
if (lights[i].enabled) DrawSphereEx(lights[i].position, 0.2f, 8, 8, lights[i].color);
|
||||||
else DrawSphereWires(lights[i].position, 0.2f, 8, 8, ColorAlpha(lights[i].color, 0.3f));
|
else DrawSphereWires(lights[i].position, 0.2f, 8, 8, ColorAlpha(lights[i].color, 0.3f));
|
||||||
|
|
|
@ -24,7 +24,6 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
@ -60,8 +59,6 @@ int main(void)
|
||||||
UnloadImage(imageBlue);
|
UnloadImage(imageBlue);
|
||||||
UnloadImage(backgroundImage);
|
UnloadImage(backgroundImage);
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
|
|
||||||
Rectangle fudesumiRec = {0, 0, fudesumiImage.width, fudesumiImage.height};
|
Rectangle fudesumiRec = {0, 0, fudesumiImage.width, fudesumiImage.height};
|
||||||
|
|
||||||
Rectangle fudesumiPos = {50, 10, fudesumiImage.width*0.8f, fudesumiImage.height*0.8f};
|
Rectangle fudesumiPos = {50, 10, fudesumiImage.width*0.8f, fudesumiImage.height*0.8f};
|
||||||
|
@ -70,11 +67,17 @@ int main(void)
|
||||||
Rectangle bluePos = { 410, 230, fudesumiPos.width / 2, fudesumiPos.height / 2 };
|
Rectangle bluePos = { 410, 230, fudesumiPos.width / 2, fudesumiPos.height / 2 };
|
||||||
Rectangle alphaPos = { 600, 230, fudesumiPos.width / 2, fudesumiPos.height / 2 };
|
Rectangle alphaPos = { 600, 230, fudesumiPos.width / 2, fudesumiPos.height / 2 };
|
||||||
|
|
||||||
|
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
|
||||||
{
|
{
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// TODO...
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
|
@ -88,7 +88,7 @@ int main(void)
|
||||||
DrawRectangleLines(30, 400, 325, 30, Fade(WHITE, 0.5f));
|
DrawRectangleLines(30, 400, 325, 30, Fade(WHITE, 0.5f));
|
||||||
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL TEXTURES", 40, 410, 10, WHITE);
|
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL TEXTURES", 40, 410, 10, WHITE);
|
||||||
|
|
||||||
switch(currentTexture)
|
switch (currentTexture)
|
||||||
{
|
{
|
||||||
case 0: DrawText("VERTICAL GRADIENT", 560, 10, 20, RAYWHITE); break;
|
case 0: DrawText("VERTICAL GRADIENT", 560, 10, 20, RAYWHITE); break;
|
||||||
case 1: DrawText("HORIZONTAL GRADIENT", 540, 10, 20, RAYWHITE); break;
|
case 1: DrawText("HORIZONTAL GRADIENT", 540, 10, 20, RAYWHITE); break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue