example resize fixes
This commit is contained in:
parent
e4993c5557
commit
48f9c9c8ff
32 changed files with 323 additions and 234 deletions
|
@ -1,6 +1,6 @@
|
||||||
# - Try to find raylib
|
# - Try to find raylib
|
||||||
# Options:
|
# Options:
|
||||||
# raylib_USE_STATIC_LIBS - OFF by default
|
# raylib_USE_STATIC_LIBS - ON by default
|
||||||
# raylib_VERBOSE - OFF by default
|
# raylib_VERBOSE - OFF by default
|
||||||
# Once done, this defines a raylib target that can be passed to
|
# Once done, this defines a raylib target that can be passed to
|
||||||
# target_link_libraries as well as following variables:
|
# target_link_libraries as well as following variables:
|
||||||
|
@ -11,6 +11,9 @@
|
||||||
# raylib_LDFLAGS - The linker flags needed with raylib
|
# raylib_LDFLAGS - The linker flags needed with raylib
|
||||||
# raylib_DEFINITIONS - Compiler switches required for using raylib
|
# raylib_DEFINITIONS - Compiler switches required for using raylib
|
||||||
|
|
||||||
|
option(raylib_USE_STATIC_LIBS "Use static libs" ON)
|
||||||
|
option(raylib_VERBOSE "Use static libs" OFF)
|
||||||
|
|
||||||
if (NOT TARGET raylib)
|
if (NOT TARGET raylib)
|
||||||
set(XPREFIX PC_RAYLIB)
|
set(XPREFIX PC_RAYLIB)
|
||||||
|
|
||||||
|
@ -25,23 +28,22 @@ if (NOT TARGET raylib)
|
||||||
|
|
||||||
find_path(raylib_INCLUDE_DIR
|
find_path(raylib_INCLUDE_DIR
|
||||||
NAMES raylib.h
|
NAMES raylib.h
|
||||||
HINTS ${${XPREFIX}_INCLUDE_DIRS}
|
HINTS ${${XPREFIX}_INCLUDE_DIRS} ${raylib_DIR}/../../../include/
|
||||||
)
|
)
|
||||||
|
|
||||||
set(RAYLIB_NAMES raylib)
|
|
||||||
|
|
||||||
if (raylib_USE_STATIC_LIBS)
|
if (raylib_USE_STATIC_LIBS)
|
||||||
set(RAYLIB_NAMES libraylib.a raylib.lib ${RAYLIB_NAMES})
|
set(RAYLIB_NAMES libraylib.a raylib.lib)
|
||||||
endif()
|
else ()
|
||||||
|
set(RAYLIB_NAMES raylib)
|
||||||
|
endif ()
|
||||||
|
|
||||||
find_library(raylib_LIBRARY
|
find_library(raylib_LIBRARY
|
||||||
NAMES ${RAYLIB_NAMES}
|
NAMES ${RAYLIB_NAMES}
|
||||||
HINTS ${${XPREFIX}_LIBRARY_DIRS}
|
HINTS ${${XPREFIX}_LIBRARY_DIRS} ${raylib_DIR}/../../
|
||||||
)
|
)
|
||||||
|
|
||||||
set(raylib_LIBRARIES ${raylib_LIBRARY})
|
set(raylib_LIBRARIES ${raylib_LIBRARY})
|
||||||
set(raylib_LIBRARY_DIRS ${${XPREFIX}_LIBRARY_DIRS})
|
|
||||||
set(raylib_LIBRARY_DIR ${raylib_LIBRARY_DIRS})
|
|
||||||
set(raylib_INCLUDE_DIRS ${raylib_INCLUDE_DIR})
|
set(raylib_INCLUDE_DIRS ${raylib_INCLUDE_DIR})
|
||||||
set(raylib_LDFLAGS ${${XPREFIX}_LDFLAGS})
|
set(raylib_LDFLAGS ${${XPREFIX}_LDFLAGS})
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ int main(void)
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText("PRESS SPACE to PLAY MODEL ANIMATION", 10, 10, 20, MAROON);
|
DrawText("PRESS SPACE to PLAY MODEL ANIMATION", 10, 10, 20, MAROON);
|
||||||
DrawText("(c) Guy IQM 3D model by @culacant", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
DrawText("(c) Guy IQM 3D model by @culacant", GetScreenWidth() - 200, GetScreenHeight() - 20, 10, GRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -111,7 +111,7 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText("Move player with arrow keys to collide", 220, 40, 20, GRAY);
|
DrawText("Move player with arrow keys to collide", GetScreenWidth()/2 - 220, 40, 20, GRAY);
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,8 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawTexture(texture, screenWidth - texture.width - 20, 20, WHITE);
|
DrawTexture(texture, GetScreenWidth() - texture.width - 20, 20, WHITE);
|
||||||
DrawRectangleLines(screenWidth - texture.width - 20, 20, texture.width, texture.height, GREEN);
|
DrawRectangleLines(GetScreenWidth() - texture.width - 20, 20, texture.width, texture.height, GREEN);
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ int main(void)
|
||||||
DrawText("Drag & drop model to load mesh/texture.", 10, GetScreenHeight() - 20, 10, DARKGRAY);
|
DrawText("Drag & drop model to load mesh/texture.", 10, GetScreenHeight() - 20, 10, DARKGRAY);
|
||||||
if (selected) DrawText("MODEL SELECTED", GetScreenWidth() - 110, 10, 10, GREEN);
|
if (selected) DrawText("MODEL SELECTED", GetScreenWidth() - 110, 10, 10, GREEN);
|
||||||
|
|
||||||
DrawText("(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
DrawText("(c) Castle 3D model by Alberto Cano", GetScreenWidth() - 200, GetScreenHeight() - 20, 10, GRAY);
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
|
|
@ -182,11 +182,11 @@ int main(void)
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
// Display info
|
// Display info
|
||||||
DrawRectangle(10, 400, 340, 60, Fade(SKYBLUE, 0.5f));
|
DrawRectangle(10, GetScreenHeight() - 50, 340, 60, Fade(SKYBLUE, 0.5f));
|
||||||
DrawRectangleLines(10, 400, 340, 60, Fade(DARKBLUE, 0.5f));
|
DrawRectangleLines(10, GetScreenHeight() - 50, 340, 60, Fade(DARKBLUE, 0.5f));
|
||||||
DrawText("MOUSE LEFT BUTTON to CYCLE VOX MODELS", 40, 410, 10, BLUE);
|
DrawText("MOUSE LEFT BUTTON to CYCLE VOX MODELS", 40, GetScreenHeight() - 50 + 10, 10, BLUE);
|
||||||
DrawText("MOUSE MIDDLE BUTTON to ZOOM OR ROTATE CAMERA", 40, 420, 10, BLUE);
|
DrawText("MOUSE MIDDLE BUTTON to ZOOM OR ROTATE CAMERA", 40, GetScreenHeight() - 50 + 20, 10, BLUE);
|
||||||
DrawText("UP-DOWN-LEFT-RIGHT KEYS to MOVE CAMERA", 40, 430, 10, BLUE);
|
DrawText("UP-DOWN-LEFT-RIGHT KEYS to MOVE CAMERA", 40, GetScreenHeight() - 50 + 30, 10, BLUE);
|
||||||
DrawText(TextFormat("File: %s", GetFileName(voxFileNames[currentModel])), 10, 10, 20, GRAY);
|
DrawText(TextFormat("File: %s", GetFileName(voxFileNames[currentModel])), 10, 10, 20, GRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
|
@ -110,21 +110,21 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawRectangle(30, 400, 310, 30, Fade(SKYBLUE, 0.5f));
|
DrawRectangle(30, GetScreenHeight() - 50, 310, 30, Fade(SKYBLUE, 0.5f));
|
||||||
DrawRectangleLines(30, 400, 310, 30, Fade(DARKBLUE, 0.5f));
|
DrawRectangleLines(30, GetScreenHeight() - 50, 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, GetScreenHeight() - 50 + 10, 10, BLUE);
|
||||||
|
|
||||||
switch (currentModel)
|
switch (currentModel)
|
||||||
{
|
{
|
||||||
case 0: DrawText("PLANE", 680, 10, 20, DARKBLUE); break;
|
case 0: DrawText("PLANE", GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
|
||||||
case 1: DrawText("CUBE", 680, 10, 20, DARKBLUE); break;
|
case 1: DrawText("CUBE", GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
|
||||||
case 2: DrawText("SPHERE", 680, 10, 20, DARKBLUE); break;
|
case 2: DrawText("SPHERE", GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
|
||||||
case 3: DrawText("HEMISPHERE", 640, 10, 20, DARKBLUE); break;
|
case 3: DrawText("HEMISPHERE", GetScreenWidth() - 160, 10, 20, DARKBLUE); break;
|
||||||
case 4: DrawText("CYLINDER", 680, 10, 20, DARKBLUE); break;
|
case 4: DrawText("CYLINDER", GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
|
||||||
case 5: DrawText("TORUS", 680, 10, 20, DARKBLUE); break;
|
case 5: DrawText("TORUS", GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
|
||||||
case 6: DrawText("KNOT", 680, 10, 20, DARKBLUE); break;
|
case 6: DrawText("KNOT", GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
|
||||||
case 7: DrawText("POLY", 680, 10, 20, DARKBLUE); break;
|
case 7: DrawText("POLY", GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
|
||||||
case 8: DrawText("Custom (triangle)", 580, 10, 20, DARKBLUE); break;
|
case 8: DrawText("Custom (triangle)", GetScreenWidth() - 220, 10, 20, DARKBLUE); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -226,9 +226,9 @@ int main(void)
|
||||||
DrawText(TextFormat("Barycenter: %3.2f %3.2f %3.2f", bary.x, bary.y, bary.z), 10, ypos + 45, 10, BLACK);
|
DrawText(TextFormat("Barycenter: %3.2f %3.2f %3.2f", bary.x, bary.y, bary.z), 10, ypos + 45, 10, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawText("Right click mouse to toggle camera controls", 10, 430, 10, GRAY);
|
DrawText("Right click mouse to toggle camera controls", 10, GetScreenHeight() - 20, 10, GRAY);
|
||||||
|
|
||||||
DrawText("(c) Turret 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
DrawText("(c) Turret 3D model by Alberto Cano", GetScreenWidth() - 200, GetScreenHeight() - 20, 10, GRAY);
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ int main()
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
// Draw UI text
|
// Draw UI text
|
||||||
DrawText(TextFormat("Point Count: %d", numPoints), 20, screenHeight - 50, 40, WHITE);
|
DrawText(TextFormat("Point Count: %d", numPoints), 20, GetScreenHeight() - 50, 40, WHITE);
|
||||||
DrawText("Up - increase points", 20, 70, 20, WHITE);
|
DrawText("Up - increase points", 20, 70, 20, WHITE);
|
||||||
DrawText("Down - decrease points", 20, 100, 20, WHITE);
|
DrawText("Down - decrease points", 20, 100, 20, WHITE);
|
||||||
DrawText("Space - drawing function", 20, 130, 20, WHITE);
|
DrawText("Space - drawing function", 20, 130, 20, WHITE);
|
||||||
|
|
|
@ -112,7 +112,7 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText("EARTH ORBITING AROUND THE SUN!", 400, 10, 20, MAROON);
|
DrawText("EARTH ORBITING AROUND THE SUN!", GetScreenWidth() - 400, 10, 20, MAROON);
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
|
@ -101,13 +101,13 @@ int main(void)
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
// Draw controls info
|
// Draw controls info
|
||||||
DrawRectangle(30, 370, 260, 70, Fade(GREEN, 0.5f));
|
DrawRectangle(30, GetScreenHeight() - 80, 260, 70, Fade(GREEN, 0.5f));
|
||||||
DrawRectangleLines(30, 370, 260, 70, Fade(DARKGREEN, 0.5f));
|
DrawRectangleLines(30, GetScreenHeight() - 80, 260, 70, Fade(DARKGREEN, 0.5f));
|
||||||
DrawText("Pitch controlled with: KEY_UP / KEY_DOWN", 40, 380, 10, DARKGRAY);
|
DrawText("Pitch controlled with: KEY_UP / KEY_DOWN", 40, GetScreenHeight() - 70, 10, DARKGRAY);
|
||||||
DrawText("Roll controlled with: KEY_LEFT / KEY_RIGHT", 40, 400, 10, DARKGRAY);
|
DrawText("Roll controlled with: KEY_LEFT / KEY_RIGHT", 40, GetScreenHeight() - 50, 10, DARKGRAY);
|
||||||
DrawText("Yaw controlled with: KEY_A / KEY_S", 40, 420, 10, DARKGRAY);
|
DrawText("Yaw controlled with: KEY_A / KEY_S", 40, GetScreenHeight() - 30, 10, DARKGRAY);
|
||||||
|
|
||||||
DrawText("(c) WWI Plane Model created by GiaHanLam", screenWidth - 240, screenHeight - 20, 10, DARKGRAY);
|
DrawText("(c) WWI Plane Model created by GiaHanLam", GetScreenWidth() - 240, GetScreenHeight() - 20, 10, DARKGRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -12,19 +12,15 @@ uniform vec4 colDiffuse;
|
||||||
|
|
||||||
// NOTE: Add your custom variables here
|
// NOTE: Add your custom variables here
|
||||||
|
|
||||||
// NOTE: Render size values should be passed from code
|
|
||||||
const float renderWidth = 800.0;
|
|
||||||
const float renderHeight = 450.0;
|
|
||||||
|
|
||||||
float radius = 250.0;
|
float radius = 250.0;
|
||||||
float angle = 0.8;
|
float angle = 0.8;
|
||||||
|
|
||||||
|
uniform vec2 size = { 800.0, 450.0 };
|
||||||
uniform vec2 center;
|
uniform vec2 center;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 texSize = vec2(renderWidth, renderHeight);
|
vec2 tc = fragTexCoord*size;
|
||||||
vec2 tc = fragTexCoord*texSize;
|
|
||||||
tc -= center;
|
tc -= center;
|
||||||
|
|
||||||
float dist = length(tc);
|
float dist = length(tc);
|
||||||
|
@ -40,7 +36,7 @@ void main()
|
||||||
}
|
}
|
||||||
|
|
||||||
tc += center;
|
tc += center;
|
||||||
vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;;
|
vec4 color = texture2D(texture0, tc/size)*colDiffuse*fragColor;;
|
||||||
|
|
||||||
gl_FragColor = vec4(color.rgb, 1.0);
|
gl_FragColor = vec4(color.rgb, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,19 +10,15 @@ uniform vec4 colDiffuse;
|
||||||
|
|
||||||
// NOTE: Add your custom variables here
|
// NOTE: Add your custom variables here
|
||||||
|
|
||||||
// NOTE: Render size values should be passed from code
|
|
||||||
const float renderWidth = 800;
|
|
||||||
const float renderHeight = 450;
|
|
||||||
|
|
||||||
float radius = 250.0;
|
float radius = 250.0;
|
||||||
float angle = 0.8;
|
float angle = 0.8;
|
||||||
|
|
||||||
|
uniform vec2 size = vec2(800.0, 450.0);
|
||||||
uniform vec2 center;
|
uniform vec2 center;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 texSize = vec2(renderWidth, renderHeight);
|
vec2 tc = fragTexCoord*size;
|
||||||
vec2 tc = fragTexCoord*texSize;
|
|
||||||
tc -= center;
|
tc -= center;
|
||||||
|
|
||||||
float dist = length(tc);
|
float dist = length(tc);
|
||||||
|
@ -38,7 +34,7 @@ void main()
|
||||||
}
|
}
|
||||||
|
|
||||||
tc += center;
|
tc += center;
|
||||||
vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;;
|
vec4 color = texture2D(texture0, tc/size)*colDiffuse*fragColor;;
|
||||||
|
|
||||||
gl_FragColor = vec4(color.rgb, 1.0);;
|
gl_FragColor = vec4(color.rgb, 1.0);;
|
||||||
}
|
}
|
|
@ -13,19 +13,15 @@ out vec4 finalColor;
|
||||||
|
|
||||||
// NOTE: Add your custom variables here
|
// NOTE: Add your custom variables here
|
||||||
|
|
||||||
// NOTE: Render size values should be passed from code
|
|
||||||
const float renderWidth = 800;
|
|
||||||
const float renderHeight = 450;
|
|
||||||
|
|
||||||
float radius = 250.0;
|
float radius = 250.0;
|
||||||
float angle = 0.8;
|
float angle = 0.8;
|
||||||
|
|
||||||
|
uniform vec2 size = vec2(800.0, 450.0);
|
||||||
uniform vec2 center = vec2(200.0, 200.0);
|
uniform vec2 center = vec2(200.0, 200.0);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 texSize = vec2(renderWidth, renderHeight);
|
vec2 tc = fragTexCoord*size;
|
||||||
vec2 tc = fragTexCoord*texSize;
|
|
||||||
tc -= center;
|
tc -= center;
|
||||||
|
|
||||||
float dist = length(tc);
|
float dist = length(tc);
|
||||||
|
@ -41,7 +37,7 @@ void main()
|
||||||
}
|
}
|
||||||
|
|
||||||
tc += center;
|
tc += center;
|
||||||
vec4 color = texture(texture0, tc/texSize)*colDiffuse*fragColor;;
|
vec4 color = texture(texture0, tc/size)*colDiffuse*fragColor;;
|
||||||
|
|
||||||
finalColor = vec4(color.rgb, 1.0);;
|
finalColor = vec4(color.rgb, 1.0);;
|
||||||
}
|
}
|
|
@ -253,7 +253,7 @@ int main()
|
||||||
|
|
||||||
DrawText("Toggle lights: [1][2][3][4]", 10, 40, 20, LIGHTGRAY);
|
DrawText("Toggle lights: [1][2][3][4]", 10, 40, 20, LIGHTGRAY);
|
||||||
|
|
||||||
DrawText("(c) Old Rusty Car model by Renafox (https://skfb.ly/LxRy)", screenWidth - 320, screenHeight - 20, 10, LIGHTGRAY);
|
DrawText("(c) Old Rusty Car model by Renafox (https://skfb.ly/LxRy)", GetScreenWidth() - 320, GetScreenHeight() - 20, 10, LIGHTGRAY);
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,10 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
int screenHeight = 450;
|
||||||
|
float swirlSize[2] = { (float)screenWidth, (float)screenHeight };
|
||||||
|
float swirlCenter[2] = { (float)screenWidth/2, (float)screenHeight/2 };
|
||||||
|
|
||||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
|
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
|
||||||
|
|
||||||
|
@ -62,12 +64,11 @@ int main(void)
|
||||||
|
|
||||||
// Get variable (uniform) location on the shader to connect with the program
|
// Get variable (uniform) location on the shader to connect with the program
|
||||||
// NOTE: If uniform variable could not be found in the shader, function returns -1
|
// NOTE: If uniform variable could not be found in the shader, function returns -1
|
||||||
|
int swirlSizeLoc = GetShaderLocation(shader, "size");
|
||||||
int swirlCenterLoc = GetShaderLocation(shader, "center");
|
int swirlCenterLoc = GetShaderLocation(shader, "center");
|
||||||
|
|
||||||
float swirlCenter[2] = { (float)screenWidth/2, (float)screenHeight/2 };
|
|
||||||
|
|
||||||
// Create a RenderTexture2D to be used for render to texture
|
// Create a RenderTexture2D to be used for render to texture
|
||||||
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
|
RenderTexture2D 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
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
@ -75,15 +76,24 @@ int main(void)
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
{
|
||||||
|
screenWidth = GetScreenWidth();
|
||||||
|
screenHeight = GetScreenHeight();
|
||||||
|
// Create a RenderTexture2D to be used for render to texture
|
||||||
|
UnloadRenderTexture(target);
|
||||||
|
target = LoadRenderTexture(screenWidth, screenHeight);
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
UpdateCamera(&camera, CAMERA_ORBITAL);
|
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||||
|
|
||||||
Vector2 mousePosition = GetMousePosition();
|
Vector2 mousePosition = GetMousePosition();
|
||||||
|
|
||||||
|
swirlSize[0] = screenWidth;
|
||||||
|
swirlSize[1] = screenHeight;
|
||||||
|
SetShaderValue(shader, swirlSizeLoc, swirlSize, SHADER_UNIFORM_VEC2);
|
||||||
|
|
||||||
swirlCenter[0] = mousePosition.x;
|
swirlCenter[0] = mousePosition.x;
|
||||||
swirlCenter[1] = screenHeight - mousePosition.y;
|
swirlCenter[1] = screenHeight - mousePosition.y;
|
||||||
|
|
||||||
// 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, SHADER_UNIFORM_VEC2);
|
SetShaderValue(shader, swirlCenterLoc, swirlCenter, SHADER_UNIFORM_VEC2);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -98,7 +108,7 @@ int main(void)
|
||||||
DrawGrid(10, 1.0f); // Draw a grid
|
DrawGrid(10, 1.0f); // Draw a grid
|
||||||
EndMode3D(); // End 3d mode drawing, returns to orthographic 2d mode
|
EndMode3D(); // End 3d mode drawing, returns to orthographic 2d mode
|
||||||
|
|
||||||
DrawText("TEXT DRAWN IN RENDER TEXTURE", 200, 10, 30, RED);
|
DrawText("TEXT DRAWN IN RENDER TEXTURE", screenWidth - 600, 10, 30, RED);
|
||||||
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
|
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
|
||||||
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
@ -107,7 +117,7 @@ int main(void)
|
||||||
// Enable shader using the custom uniform
|
// Enable shader using the custom uniform
|
||||||
BeginShaderMode(shader);
|
BeginShaderMode(shader);
|
||||||
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
||||||
DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)screenWidth, (float)-screenHeight }, (Vector2){ 0, 0 }, WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
// Draw some 2d text over drawn texture
|
// Draw some 2d text over drawn texture
|
||||||
|
|
|
@ -51,9 +51,6 @@ int main(void)
|
||||||
int mouseLoc = GetShaderLocation(shader, "mouse");
|
int mouseLoc = GetShaderLocation(shader, "mouse");
|
||||||
int timeLoc = GetShaderLocation(shader, "time");
|
int timeLoc = GetShaderLocation(shader, "time");
|
||||||
|
|
||||||
float resolution[2] = { (float)screenWidth, (float)screenHeight };
|
|
||||||
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
|
|
||||||
|
|
||||||
float totalTime = 0.0f;
|
float totalTime = 0.0f;
|
||||||
bool shaderAutoReloading = false;
|
bool shaderAutoReloading = false;
|
||||||
|
|
||||||
|
@ -65,6 +62,9 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
float resolution[2] = { (float)GetScreenWidth(), (float)GetScreenHeight() };
|
||||||
|
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
|
||||||
|
|
||||||
totalTime += GetFrameTime();
|
totalTime += GetFrameTime();
|
||||||
Vector2 mouse = GetMousePosition();
|
Vector2 mouse = GetMousePosition();
|
||||||
float mousePos[2] = { mouse.x, mouse.y };
|
float mousePos[2] = { mouse.x, mouse.y };
|
||||||
|
@ -113,14 +113,14 @@ int main(void)
|
||||||
|
|
||||||
// We only draw a white full-screen rectangle, frame is generated in shader
|
// We only draw a white full-screen rectangle, frame is generated in shader
|
||||||
BeginShaderMode(shader);
|
BeginShaderMode(shader);
|
||||||
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
DrawText(TextFormat("PRESS [A] to TOGGLE SHADER AUTOLOADING: %s",
|
DrawText(TextFormat("PRESS [A] to TOGGLE SHADER AUTOLOADING: %s",
|
||||||
shaderAutoReloading? "AUTO" : "MANUAL"), 10, 10, 10, shaderAutoReloading? RED : BLACK);
|
shaderAutoReloading? "AUTO" : "MANUAL"), 10, 10, 10, shaderAutoReloading? RED : BLACK);
|
||||||
if (!shaderAutoReloading) DrawText("MOUSE CLICK to SHADER RE-LOADING", 10, 30, 10, BLACK);
|
if (!shaderAutoReloading) DrawText("MOUSE CLICK to SHADER RE-LOADING", 10, 30, 10, BLACK);
|
||||||
|
|
||||||
DrawText(TextFormat("Shader last modification: %s", asctime(localtime(&fragShaderFileModTime))), 10, 430, 10, BLACK);
|
DrawText(TextFormat("Shader last modification: %s", asctime(localtime(&fragShaderFileModTime))), 10, GetScreenHeight() - 20, 10, BLACK);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -69,12 +69,6 @@ int main(void)
|
||||||
marchLocs.camDir = GetShaderLocation(shdrRaymarch, "camDir");
|
marchLocs.camDir = GetShaderLocation(shdrRaymarch, "camDir");
|
||||||
marchLocs.screenCenter = GetShaderLocation(shdrRaymarch, "screenCenter");
|
marchLocs.screenCenter = GetShaderLocation(shdrRaymarch, "screenCenter");
|
||||||
|
|
||||||
// Transfer screenCenter position to shader. Which is used to calculate ray direction.
|
|
||||||
Vector2 screenCenter = {.x = screenWidth/2.0f, .y = screenHeight/2.0f};
|
|
||||||
SetShaderValue(shdrRaymarch, marchLocs.screenCenter , &screenCenter , SHADER_UNIFORM_VEC2);
|
|
||||||
|
|
||||||
// Use Customized function to create writable depth texture buffer
|
|
||||||
RenderTexture2D target = LoadRenderTextureDepthTex(screenWidth, screenHeight);
|
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = {
|
Camera camera = {
|
||||||
|
@ -87,6 +81,7 @@ int main(void)
|
||||||
|
|
||||||
// Camera FOV is pre-calculated in the camera Distance.
|
// Camera FOV is pre-calculated in the camera Distance.
|
||||||
float camDist = 1.0f/(tanf(camera.fovy*0.5f*DEG2RAD));
|
float camDist = 1.0f/(tanf(camera.fovy*0.5f*DEG2RAD));
|
||||||
|
RenderTexture2D 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
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
@ -96,6 +91,14 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
// Use Customized function to create writable depth texture buffer
|
||||||
|
// Transfer screenCenter position to shader. Which is used to calculate ray direction.
|
||||||
|
UnloadRenderTexture(target);
|
||||||
|
target = LoadRenderTextureDepthTex(GetScreenWidth(), GetScreenHeight());
|
||||||
|
Vector2 screenCenter = {.x = GetScreenWidth()/2.0f, .y = GetScreenHeight()/2.0f};
|
||||||
|
SetShaderValue(shdrRaymarch, marchLocs.screenCenter , &screenCenter , SHADER_UNIFORM_VEC2);
|
||||||
|
|
||||||
|
|
||||||
UpdateCamera(&camera, CAMERA_ORBITAL);
|
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||||
|
|
||||||
// Update Camera Postion in the ray march shader.
|
// Update Camera Postion in the ray march shader.
|
||||||
|
@ -115,7 +118,7 @@ int main(void)
|
||||||
// Raymarch Scene
|
// Raymarch Scene
|
||||||
rlEnableDepthTest(); //Manually enable Depth Test to handle multiple rendering methods.
|
rlEnableDepthTest(); //Manually enable Depth Test to handle multiple rendering methods.
|
||||||
BeginShaderMode(shdrRaymarch);
|
BeginShaderMode(shdrRaymarch);
|
||||||
DrawRectangleRec((Rectangle){0,0, (float)screenWidth, (float)screenHeight},WHITE);
|
DrawRectangleRec((Rectangle){0,0, (float)GetScreenWidth(), (float)GetScreenHeight()},WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
// Rasterize Scene
|
// Rasterize Scene
|
||||||
|
@ -134,7 +137,7 @@ int main(void)
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
DrawTextureRec(target.texture, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, (Vector2) { 0, 0 }, WHITE);
|
DrawTextureRec(target.texture, (Rectangle) { 0, 0, (float)GetScreenWidth(), (float)-GetScreenHeight() }, (Vector2) { 0, 0 }, WHITE);
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -88,7 +88,7 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText("(c) Watermill 3D model by Alberto Cano", screenWidth - 210, screenHeight - 20, 10, GRAY);
|
DrawText("(c) Watermill 3D model by Alberto Cano", GetScreenWidth() - 210, GetScreenHeight() - 20, 10, GRAY);
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,8 @@ int main(void)
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
UnloadRenderTexture(target);
|
||||||
|
target = LoadRenderTexture(GetScreenWidth(), GetScreenHeight());
|
||||||
BeginTextureMode(target); // Enable drawing to texture
|
BeginTextureMode(target); // Enable drawing to texture
|
||||||
ClearBackground(RAYWHITE); // Clear texture background
|
ClearBackground(RAYWHITE); // Clear texture background
|
||||||
|
|
||||||
|
@ -148,17 +150,17 @@ int main(void)
|
||||||
// Render generated texture using selected postprocessing shader
|
// Render generated texture using selected postprocessing shader
|
||||||
BeginShaderMode(shaders[currentShader]);
|
BeginShaderMode(shaders[currentShader]);
|
||||||
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
||||||
DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)GetScreenWidth(), (float)-GetScreenHeight() }, (Vector2){0, 0}, WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
// Draw 2d shapes and text over drawn texture
|
// Draw 2d shapes and text over drawn texture
|
||||||
DrawRectangle(0, 9, 580, 30, Fade(LIGHTGRAY, 0.7f));
|
DrawRectangle(0, 9, 580, 30, Fade(LIGHTGRAY, 0.7f));
|
||||||
|
|
||||||
DrawText("(c) Church 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
DrawText("(c) Church 3D model by Alberto Cano", GetScreenWidth() - 200, GetScreenHeight() - 20, 10, GRAY);
|
||||||
DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, BLACK);
|
DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, BLACK);
|
||||||
DrawText(postproShaderText[currentShader], 330, 15, 20, RED);
|
DrawText(postproShaderText[currentShader], 330, 15, 20, RED);
|
||||||
DrawText("< >", 540, 10, 30, DARKBLUE);
|
DrawText("< >", 540, 10, 30, DARKBLUE);
|
||||||
DrawFPS(700, 15);
|
DrawFPS(GetScreenWidth() - 100, 15);
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ int main(void)
|
||||||
DrawText("Rounded rectangle", rec.x - 20, rec.y - 35, 10, DARKGRAY);
|
DrawText("Rounded rectangle", rec.x - 20, rec.y - 35, 10, DARKGRAY);
|
||||||
|
|
||||||
// Flip Y axis to match shader coordinate system
|
// Flip Y axis to match shader coordinate system
|
||||||
rec.y = screenHeight - rec.y - rec.height;
|
rec.y = GetScreenHeight() - rec.y - rec.height;
|
||||||
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
|
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
|
||||||
|
|
||||||
// Only rectangle color
|
// Only rectangle color
|
||||||
|
@ -121,7 +121,7 @@ int main(void)
|
||||||
SetShaderValue(shader, roundedRectangle.borderColorLoc, (float[]) { 0.0f, 0.0f, 0.0f, 0.0f }, SHADER_UNIFORM_VEC4);
|
SetShaderValue(shader, roundedRectangle.borderColorLoc, (float[]) { 0.0f, 0.0f, 0.0f, 0.0f }, SHADER_UNIFORM_VEC4);
|
||||||
|
|
||||||
BeginShaderMode(shader);
|
BeginShaderMode(shader);
|
||||||
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ int main(void)
|
||||||
DrawRectangleLines(rec.x - 20, rec.y - 20, rec.width + 40, rec.height + 40, DARKGRAY);
|
DrawRectangleLines(rec.x - 20, rec.y - 20, rec.width + 40, rec.height + 40, DARKGRAY);
|
||||||
DrawText("Rounded rectangle shadow", rec.x - 20, rec.y - 35, 10, DARKGRAY);
|
DrawText("Rounded rectangle shadow", rec.x - 20, rec.y - 35, 10, DARKGRAY);
|
||||||
|
|
||||||
rec.y = screenHeight - rec.y - rec.height;
|
rec.y = GetScreenHeight() - rec.y - rec.height;
|
||||||
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
|
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
|
||||||
|
|
||||||
// Only shadow color
|
// Only shadow color
|
||||||
|
@ -140,7 +140,7 @@ int main(void)
|
||||||
SetShaderValue(shader, roundedRectangle.borderColorLoc, (float[]) { 0.0f, 0.0f, 0.0f, 0.0f }, SHADER_UNIFORM_VEC4);
|
SetShaderValue(shader, roundedRectangle.borderColorLoc, (float[]) { 0.0f, 0.0f, 0.0f, 0.0f }, SHADER_UNIFORM_VEC4);
|
||||||
|
|
||||||
BeginShaderMode(shader);
|
BeginShaderMode(shader);
|
||||||
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ int main(void)
|
||||||
DrawRectangleLines(rec.x - 20, rec.y - 20, rec.width + 40, rec.height + 40, DARKGRAY);
|
DrawRectangleLines(rec.x - 20, rec.y - 20, rec.width + 40, rec.height + 40, DARKGRAY);
|
||||||
DrawText("Rounded rectangle border", rec.x - 20, rec.y - 35, 10, DARKGRAY);
|
DrawText("Rounded rectangle border", rec.x - 20, rec.y - 35, 10, DARKGRAY);
|
||||||
|
|
||||||
rec.y = screenHeight - rec.y - rec.height;
|
rec.y = GetScreenHeight() - rec.y - rec.height;
|
||||||
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
|
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
|
||||||
|
|
||||||
// Only border color
|
// Only border color
|
||||||
|
@ -159,17 +159,17 @@ int main(void)
|
||||||
SetShaderValue(shader, roundedRectangle.borderColorLoc, (float[]) { borderColor.r/255.0f, borderColor.g/255.0f, borderColor.b/255.0f, borderColor.a/255.0f }, SHADER_UNIFORM_VEC4);
|
SetShaderValue(shader, roundedRectangle.borderColorLoc, (float[]) { borderColor.r/255.0f, borderColor.g/255.0f, borderColor.b/255.0f, borderColor.a/255.0f }, SHADER_UNIFORM_VEC4);
|
||||||
|
|
||||||
BeginShaderMode(shader);
|
BeginShaderMode(shader);
|
||||||
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Draw one more rectangle with all three colors
|
// Draw one more rectangle with all three colors
|
||||||
rec = (Rectangle){ 240, 80, 500, 300 };
|
rec = (Rectangle){ 240, 80, GetScreenWidth() - 300, GetScreenHeight() - 150 };
|
||||||
DrawRectangleLines(rec.x - 30, rec.y - 30, rec.width + 60, rec.height + 60, DARKGRAY);
|
DrawRectangleLines(rec.x - 30, rec.y - 30, rec.width + 60, rec.height + 60, DARKGRAY);
|
||||||
DrawText("Rectangle with all three combined", rec.x - 30, rec.y - 45, 10, DARKGRAY);
|
DrawText("Rectangle with all three combined", rec.x - 30, rec.y - 45, 10, DARKGRAY);
|
||||||
|
|
||||||
rec.y = screenHeight - rec.y - rec.height;
|
rec.y = GetScreenHeight() - rec.y - rec.height;
|
||||||
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
|
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
|
||||||
|
|
||||||
// All three colors
|
// All three colors
|
||||||
|
@ -178,10 +178,10 @@ int main(void)
|
||||||
SetShaderValue(shader, roundedRectangle.borderColorLoc, (float[]) { borderColor.r/255.0f, borderColor.g/255.0f, borderColor.b/255.0f, borderColor.a/255.0f }, SHADER_UNIFORM_VEC4);
|
SetShaderValue(shader, roundedRectangle.borderColorLoc, (float[]) { borderColor.r/255.0f, borderColor.g/255.0f, borderColor.b/255.0f, borderColor.a/255.0f }, SHADER_UNIFORM_VEC4);
|
||||||
|
|
||||||
BeginShaderMode(shader);
|
BeginShaderMode(shader);
|
||||||
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
DrawText("(c) Rounded rectangle SDF by Iñigo Quilez. MIT License.", screenWidth - 300, screenHeight - 20, 10, BLACK);
|
DrawText("(c) Rounded rectangle SDF by Iñigo Quilez. MIT License.", GetScreenWidth() - 300, GetScreenHeight() - 20, 10, BLACK);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -176,7 +176,7 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText("Shadows in raylib using the shadowmapping algorithm!", screenWidth - 320, screenHeight - 20, 10, GRAY);
|
DrawText("Shadows in raylib using the shadowmapping algorithm!", GetScreenWidth() - 320, GetScreenHeight() - 20, 10, GRAY);
|
||||||
DrawText("Use the arrow keys to rotate the light!", 10, 10, 30, RED);
|
DrawText("Use the arrow keys to rotate the light!", 10, 10, 30, RED);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
|
@ -85,7 +85,7 @@ int main(void)
|
||||||
for (int n = 0; n < MAX_STARS; n++) ResetStar(&stars[n]);
|
for (int n = 0; n < MAX_STARS; n++) ResetStar(&stars[n]);
|
||||||
|
|
||||||
// Progress all the stars on, so they don't all start in the centre
|
// Progress all the stars on, so they don't all start in the centre
|
||||||
for (int m = 0; m < screenWidth/2.0; m++)
|
for (int m = 0; m < GetScreenWidth()/2.0; m++)
|
||||||
{
|
{
|
||||||
for (int n = 0; n < MAX_STARS; n++) UpdateStar(&stars[n]);
|
for (int n = 0; n < MAX_STARS; n++) UpdateStar(&stars[n]);
|
||||||
}
|
}
|
||||||
|
@ -124,8 +124,8 @@ int main(void)
|
||||||
// and initialize the shader locations
|
// and initialize the shader locations
|
||||||
for (int i = 0; i < MAX_SPOTS; i++)
|
for (int i = 0; i < MAX_SPOTS; i++)
|
||||||
{
|
{
|
||||||
spots[i].position.x = (float)GetRandomValue(64, screenWidth - 64);
|
spots[i].position.x = (float)GetRandomValue(64, GetScreenWidth() - 64);
|
||||||
spots[i].position.y = (float)GetRandomValue(64, screenHeight - 64);
|
spots[i].position.y = (float)GetRandomValue(64, GetScreenHeight() - 64);
|
||||||
spots[i].speed = (Vector2){ 0, 0 };
|
spots[i].speed = (Vector2){ 0, 0 };
|
||||||
|
|
||||||
while ((fabs(spots[i].speed.x) + fabs(spots[i].speed.y)) < 2)
|
while ((fabs(spots[i].speed.x) + fabs(spots[i].speed.y)) < 2)
|
||||||
|
@ -152,6 +152,9 @@ int main(void)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
frameCounter++;
|
frameCounter++;
|
||||||
|
|
||||||
|
sw = (float)GetScreenWidth();
|
||||||
|
SetShaderValue(shdrSpot, wLoc, &sw, SHADER_UNIFORM_FLOAT);
|
||||||
|
|
||||||
// Move the stars, resetting them if the go offscreen
|
// Move the stars, resetting them if the go offscreen
|
||||||
for (int n = 0; n < MAX_STARS; n++) UpdateStar(&stars[n]);
|
for (int n = 0; n < MAX_STARS; n++) UpdateStar(&stars[n]);
|
||||||
|
|
||||||
|
@ -162,7 +165,7 @@ int main(void)
|
||||||
{
|
{
|
||||||
Vector2 mp = GetMousePosition();
|
Vector2 mp = GetMousePosition();
|
||||||
spots[i].position.x = mp.x;
|
spots[i].position.x = mp.x;
|
||||||
spots[i].position.y = screenHeight - mp.y;
|
spots[i].position.y = GetScreenHeight() - mp.y;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -170,9 +173,9 @@ int main(void)
|
||||||
spots[i].position.y += spots[i].speed.y;
|
spots[i].position.y += spots[i].speed.y;
|
||||||
|
|
||||||
if (spots[i].position.x < 64) spots[i].speed.x = -spots[i].speed.x;
|
if (spots[i].position.x < 64) spots[i].speed.x = -spots[i].speed.x;
|
||||||
if (spots[i].position.x > (screenWidth - 64)) spots[i].speed.x = -spots[i].speed.x;
|
if (spots[i].position.x > (GetScreenWidth() - 64)) spots[i].speed.x = -spots[i].speed.x;
|
||||||
if (spots[i].position.y < 64) spots[i].speed.y = -spots[i].speed.y;
|
if (spots[i].position.y < 64) spots[i].speed.y = -spots[i].speed.y;
|
||||||
if (spots[i].position.y > (screenHeight - 64)) spots[i].speed.y = -spots[i].speed.y;
|
if (spots[i].position.y > (GetScreenHeight() - 64)) spots[i].speed.y = -spots[i].speed.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetShaderValue(shdrSpot, spots[i].positionLoc, &spots[i].position.x, SHADER_UNIFORM_VEC2);
|
SetShaderValue(shdrSpot, spots[i].positionLoc, &spots[i].position.x, SHADER_UNIFORM_VEC2);
|
||||||
|
@ -194,8 +197,8 @@ int main(void)
|
||||||
for (int i = 0; i < 16; i++)
|
for (int i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
DrawTexture(texRay,
|
DrawTexture(texRay,
|
||||||
(int)((screenWidth/2.0f) + cos((frameCounter + i*8)/51.45f)*(screenWidth/2.2f) - 32),
|
(int)((GetScreenWidth()/2.0f) + cos((frameCounter + i*8)/51.45f)*(GetScreenWidth()/2.2f) - 32),
|
||||||
(int)((screenHeight/2.0f) + sin((frameCounter + i*8)/17.87f)*(screenHeight/4.2f)), WHITE);
|
(int)((GetScreenHeight()/2.0f) + sin((frameCounter + i*8)/17.87f)*(GetScreenHeight()/4.2f)), WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw spot lights
|
// Draw spot lights
|
||||||
|
@ -204,14 +207,14 @@ int main(void)
|
||||||
// a render texture of the full screen used to do screen
|
// a render texture of the full screen used to do screen
|
||||||
// scaling (slight adjustment to shader would be required
|
// scaling (slight adjustment to shader would be required
|
||||||
// to actually pay attention to the colour!)
|
// to actually pay attention to the colour!)
|
||||||
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
DrawText("Move the mouse!", 10, 30, 20, GREEN);
|
DrawText("Move the mouse!", 10, 30, 20, GREEN);
|
||||||
DrawText("Pitch Black", (int)(screenWidth*0.2f), screenHeight/2, 20, GREEN);
|
DrawText("Pitch Black", (int)(GetScreenWidth()*0.2f), GetScreenHeight()/2, 20, GREEN);
|
||||||
DrawText("Dark", (int)(screenWidth*.66f), screenHeight/2, 20, GREEN);
|
DrawText("Dark", (int)(GetScreenWidth()*.66f), GetScreenHeight()/2, 20, GREEN);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -75,6 +75,8 @@ int main(void)
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
UnloadRenderTexture(target);
|
||||||
|
target = LoadRenderTextureDepthTex(GetScreenWidth(), GetScreenHeight());
|
||||||
// Draw into our custom render texture (framebuffer)
|
// Draw into our custom render texture (framebuffer)
|
||||||
BeginTextureMode(target);
|
BeginTextureMode(target);
|
||||||
ClearBackground(WHITE);
|
ClearBackground(WHITE);
|
||||||
|
@ -94,7 +96,7 @@ int main(void)
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
DrawTextureRec(target.texture, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, (Vector2) { 0, 0 }, WHITE);
|
DrawTextureRec(target.texture, (Rectangle) { 0, 0, (float)GetScreenWidth(), (float)-GetScreenHeight() }, (Vector2) { 0, 0 }, WHITE);
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -67,7 +67,7 @@ int main(void)
|
||||||
DrawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, GetScreenHeight() - 25, 20, LIGHTGRAY);
|
DrawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, GetScreenHeight() - 25, 20, LIGHTGRAY);
|
||||||
|
|
||||||
// On pause, we draw a blinking message
|
// On pause, we draw a blinking message
|
||||||
if (pause && ((framesCounter/30)%2)) DrawText("PAUSED", 350, 200, 30, GRAY);
|
if (pause && ((framesCounter/30)%2)) DrawText("PAUSED", (GetScreenWidth() - 100)/2, (GetScreenHeight()- 50)/2, 30, GRAY);
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ int main(void)
|
||||||
if (state == 0) // Move ball position X with easing
|
if (state == 0) // Move ball position X with easing
|
||||||
{
|
{
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
ballPositionX = (int)EaseElasticOut((float)framesCounter, -100, screenWidth/2.0f + 100, 120);
|
ballPositionX = (int)EaseElasticOut((float)framesCounter, -100, GetScreenWidth()/2.0f + 100, 120);
|
||||||
|
|
||||||
if (framesCounter >= 120)
|
if (framesCounter >= 120)
|
||||||
{
|
{
|
||||||
|
@ -99,10 +99,10 @@ int main(void)
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
if (state >= 2) DrawRectangle(0, 0, screenWidth, screenHeight, GREEN);
|
if (state >= 2) DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GREEN);
|
||||||
DrawCircle(ballPositionX, 200, (float)ballRadius, Fade(RED, 1.0f - ballAlpha));
|
DrawCircle(ballPositionX, 200, (float)ballRadius, Fade(RED, 1.0f - ballAlpha));
|
||||||
|
|
||||||
if (state == 3) DrawText("PRESS [ENTER] TO PLAY AGAIN!", 240, 200, 20, BLACK);
|
if (state == 3) DrawText("PRESS [ENTER] TO PLAY AGAIN!", GetScreenWidth()/2 - 140, (GetScreenHeight()/2 - 10), 20, BLACK);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -46,6 +46,11 @@ int main(void)
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
{
|
||||||
|
scleraLeftPosition.x = GetScreenWidth()/2.0f - 100.0f;
|
||||||
|
scleraLeftPosition.y = GetScreenHeight()/2.0f;
|
||||||
|
scleraRightPosition.x = GetScreenWidth()/2.0f + 100.0f;
|
||||||
|
scleraRightPosition.y = GetScreenHeight()/2.0f;
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
irisLeftPosition = GetMousePosition();
|
irisLeftPosition = GetMousePosition();
|
||||||
|
|
|
@ -44,11 +44,11 @@ int main(void)
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
DrawRectangle(screenWidth/2 - 128, screenHeight/2 - 128, 256, 256, BLACK);
|
DrawRectangle(GetScreenWidth()/2 - 128, GetScreenHeight()/2 - 128, 256, 256, BLACK);
|
||||||
DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, RAYWHITE);
|
DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, RAYWHITE);
|
||||||
DrawText("raylib", screenWidth/2 - 44, screenHeight/2 + 48, 50, BLACK);
|
DrawText("raylib", GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, BLACK);
|
||||||
|
|
||||||
DrawText("this is NOT a texture!", 350, 370, 10, GRAY);
|
DrawText("this is NOT a texture!", GetScreenWidth()/2 - 50, GetScreenHeight()/2 + 145, 10, GRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -48,6 +48,9 @@ int main(void)
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
{
|
||||||
|
logoPositionX = GetScreenWidth()/2 - 128;
|
||||||
|
logoPositionY = GetScreenHeight()/2 - 128;
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (state == 0) // State 0: Small box blinking
|
if (state == 0) // State 0: Small box blinking
|
||||||
|
@ -151,7 +154,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
else if (state == 4)
|
else if (state == 4)
|
||||||
{
|
{
|
||||||
DrawText("[R] REPLAY", 340, 200, 20, GRAY);
|
DrawText("[R] REPLAY", GetScreenWidth()/2 - 60, GetScreenHeight()/2 - 25, 20, GRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
|
@ -415,23 +415,23 @@ int main(void)
|
||||||
quads += TextLength(text)*2*layers;
|
quads += TextLength(text)*2*layers;
|
||||||
char *tmp = (char *)TextFormat("%2i layer(s) | %s camera | %4i quads (%4i verts)", layers, spin? "ORBITAL" : "FREE", quads, quads*4);
|
char *tmp = (char *)TextFormat("%2i layer(s) | %s camera | %4i quads (%4i verts)", layers, spin? "ORBITAL" : "FREE", quads, quads*4);
|
||||||
int width = MeasureText(tmp, 10);
|
int width = MeasureText(tmp, 10);
|
||||||
DrawText(tmp, screenWidth - 20 - width, 10, 10, DARKGREEN);
|
DrawText(tmp, GetScreenWidth() - 20 - width, 10, 10, DARKGREEN);
|
||||||
|
|
||||||
tmp = "[Home]/[End] to add/remove 3D text layers";
|
tmp = "[Home]/[End] to add/remove 3D text layers";
|
||||||
width = MeasureText(tmp, 10);
|
width = MeasureText(tmp, 10);
|
||||||
DrawText(tmp, screenWidth - 20 - width, 25, 10, DARKGRAY);
|
DrawText(tmp, GetScreenWidth() - 20 - width, 25, 10, DARKGRAY);
|
||||||
|
|
||||||
tmp = "[Insert]/[Delete] to increase/decrease distance between layers";
|
tmp = "[Insert]/[Delete] to increase/decrease distance between layers";
|
||||||
width = MeasureText(tmp, 10);
|
width = MeasureText(tmp, 10);
|
||||||
DrawText(tmp, screenWidth - 20 - width, 40, 10, DARKGRAY);
|
DrawText(tmp, GetScreenWidth() - 20 - width, 40, 10, DARKGRAY);
|
||||||
|
|
||||||
tmp = "click the [CUBE] for a random color";
|
tmp = "click the [CUBE] for a random color";
|
||||||
width = MeasureText(tmp, 10);
|
width = MeasureText(tmp, 10);
|
||||||
DrawText(tmp, screenWidth - 20 - width, 55, 10, DARKGRAY);
|
DrawText(tmp, GetScreenWidth() - 20 - width, 55, 10, DARKGRAY);
|
||||||
|
|
||||||
tmp = "[Tab] to toggle multicolor mode";
|
tmp = "[Tab] to toggle multicolor mode";
|
||||||
width = MeasureText(tmp, 10);
|
width = MeasureText(tmp, 10);
|
||||||
DrawText(tmp, screenWidth - 20 - width, 70, 10, DARKGRAY);
|
DrawText(tmp, GetScreenWidth() - 20 - width, 70, 10, DARKGRAY);
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
168
src/external/RGFW.h
vendored
168
src/external/RGFW.h
vendored
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* RGFW 1.6-dev
|
* RGFW 1.6
|
||||||
*
|
*
|
||||||
* Copyright (C) 2022-25 ColleagueRiley
|
* Copyright (C) 2022-25 ColleagueRiley
|
||||||
*
|
*
|
||||||
|
@ -168,16 +168,16 @@ int main() {
|
||||||
#pragma comment(lib, "user32")
|
#pragma comment(lib, "user32")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef RGFW_UNUSED
|
|
||||||
#define RGFW_UNUSED(x) (void)(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef RGFW_USERPTR
|
#ifndef RGFW_USERPTR
|
||||||
#define RGFW_USERPTR NULL
|
#define RGFW_USERPTR NULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef RGFW_UNUSED
|
||||||
|
#define RGFW_UNUSED(x) (void)(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef RGFW_ROUND
|
#ifndef RGFW_ROUND
|
||||||
#define RGFW_ROUND(x) (int)((x) >= 0 ? (x) + 0.5f : (x) - 0.5f)
|
#define RGFW_ROUND(x) (int)((x) >= 0 ? (x) + 0.5f : (x) - 0.5f)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef RGFW_ALLOC
|
#ifndef RGFW_ALLOC
|
||||||
|
@ -191,6 +191,11 @@ int main() {
|
||||||
#define RGFW_FREE free
|
#define RGFW_FREE free
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef RGFW_ASSERT
|
||||||
|
#include <assert.h>
|
||||||
|
#define RGFW_ASSERT assert
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef RGFW_MEMCPY
|
#ifndef RGFW_MEMCPY
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -619,7 +624,7 @@ typedef struct RGFW_window_src {
|
||||||
HWND window; /*!< source window */
|
HWND window; /*!< source window */
|
||||||
HDC hdc; /*!< source HDC */
|
HDC hdc; /*!< source HDC */
|
||||||
u32 hOffset; /*!< height offset for window */
|
u32 hOffset; /*!< height offset for window */
|
||||||
HICON hIcon; /*!< source window icon */
|
HICON hIconSmall, hIconBig; /*!< source window icons */
|
||||||
#if (defined(RGFW_OPENGL)) && !defined(RGFW_OSMESA) && !defined(RGFW_EGL)
|
#if (defined(RGFW_OPENGL)) && !defined(RGFW_OSMESA) && !defined(RGFW_EGL)
|
||||||
HGLRC ctx; /*!< source graphics context */
|
HGLRC ctx; /*!< source graphics context */
|
||||||
#elif defined(RGFW_OSMESA)
|
#elif defined(RGFW_OSMESA)
|
||||||
|
@ -654,8 +659,8 @@ typedef struct RGFW_window_src {
|
||||||
|
|
||||||
#if defined(RGFW_OSMESA) || defined(RGFW_BUFFER)
|
#if defined(RGFW_OSMESA) || defined(RGFW_BUFFER)
|
||||||
XImage* bitmap;
|
XImage* bitmap;
|
||||||
GC gc;
|
|
||||||
#endif
|
#endif
|
||||||
|
GC gc;
|
||||||
char* clipboard; /* for writing to the clipboard selection */
|
char* clipboard; /* for writing to the clipboard selection */
|
||||||
size_t clipboard_len;
|
size_t clipboard_len;
|
||||||
#endif /* RGFW_X11 */
|
#endif /* RGFW_X11 */
|
||||||
|
@ -910,7 +915,14 @@ RGFWDEF RGFW_bool RGFW_window_setIcon(RGFW_window* win, /*!< source window */
|
||||||
u8* icon /*!< icon bitmap */,
|
u8* icon /*!< icon bitmap */,
|
||||||
RGFW_area a /*!< width and height of the bitmap*/,
|
RGFW_area a /*!< width and height of the bitmap*/,
|
||||||
i32 channels /*!< how many channels the bitmap has (rgb : 3, rgba : 4) */
|
i32 channels /*!< how many channels the bitmap has (rgb : 3, rgba : 4) */
|
||||||
); /*!< image MAY be resized by default */
|
); /*!< image MAY be resized by default, set both the taskbar and window icon */
|
||||||
|
|
||||||
|
typedef RGFW_ENUM(u8, RGFW_icon) {
|
||||||
|
RGFW_iconTaskbar = RGFW_BIT(0),
|
||||||
|
RGFW_iconWindow = RGFW_BIT(1),
|
||||||
|
RGFW_iconBoth = RGFW_iconTaskbar | RGFW_iconWindow
|
||||||
|
};
|
||||||
|
RGFWDEF RGFW_bool RGFW_window_setIconEx(RGFW_window* win, u8* icon, RGFW_area a, i32 channels, u8 type);
|
||||||
|
|
||||||
/*!< sets mouse to RGFW_mouse icon (loaded from a bitmap struct) */
|
/*!< sets mouse to RGFW_mouse icon (loaded from a bitmap struct) */
|
||||||
RGFWDEF void RGFW_window_setMouse(RGFW_window* win, RGFW_mouse* mouse);
|
RGFWDEF void RGFW_window_setMouse(RGFW_window* win, RGFW_mouse* mouse);
|
||||||
|
@ -1371,11 +1383,6 @@ RGFW_bool RGFW_useWaylandBool = 1;
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef RGFW_ASSERT
|
|
||||||
#include <assert.h>
|
|
||||||
#define RGFW_ASSERT assert
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char* RGFW_clipboard_data;
|
char* RGFW_clipboard_data;
|
||||||
void RGFW_clipboard_switch(char* newstr) {
|
void RGFW_clipboard_switch(char* newstr) {
|
||||||
if (RGFW_clipboard_data != NULL)
|
if (RGFW_clipboard_data != NULL)
|
||||||
|
@ -1733,6 +1740,8 @@ no more event call back defines
|
||||||
#define RGFW_MOUSE_LEFT RGFW_BIT(28) /* if mouse left the window */
|
#define RGFW_MOUSE_LEFT RGFW_BIT(28) /* if mouse left the window */
|
||||||
#define RGFW_WINDOW_ALLOC RGFW_BIT(29) /* if window was allocated by RGFW */
|
#define RGFW_WINDOW_ALLOC RGFW_BIT(29) /* if window was allocated by RGFW */
|
||||||
#define RGFW_BUFFER_ALLOC RGFW_BIT(30) /* if window.buffer was allocated by RGFW */
|
#define RGFW_BUFFER_ALLOC RGFW_BIT(30) /* if window.buffer was allocated by RGFW */
|
||||||
|
#define RGFW_WINDOW_INIT RGFW_BIT(31) /* if window.buffer was allocated by RGFW */
|
||||||
|
|
||||||
|
|
||||||
RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, RGFW_windowFlags flags) {
|
RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, RGFW_windowFlags flags) {
|
||||||
RGFW_window* win = (RGFW_window*)RGFW_ALLOC(sizeof(RGFW_window));
|
RGFW_window* win = (RGFW_window*)RGFW_ALLOC(sizeof(RGFW_window));
|
||||||
|
@ -1777,15 +1786,20 @@ void RGFW_window_basic_init(RGFW_window* win, RGFW_rect rect, RGFW_windowFlags f
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!(win->_flags & RGFW_WINDOW_ALLOC)) win->_flags = 0;
|
||||||
|
|
||||||
/* set and init the new window's data */
|
/* set and init the new window's data */
|
||||||
win->r = rect;
|
win->r = rect;
|
||||||
win->event.inFocus = 1;
|
win->event.inFocus = 1;
|
||||||
win->event.droppedFilesCount = 0;
|
win->event.droppedFilesCount = 0;
|
||||||
win->_flags = flags;
|
win->_flags |= flags;
|
||||||
win->event.keyMod = 0;
|
win->event.keyMod = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RGFW_window_setFlags(RGFW_window* win, RGFW_windowFlags flags) {
|
void RGFW_window_setFlags(RGFW_window* win, RGFW_windowFlags flags) {
|
||||||
|
RGFW_windowFlags cmpFlags = win->_flags;
|
||||||
|
if (win->_flags & RGFW_WINDOW_INIT) cmpFlags = win->_flags;
|
||||||
|
|
||||||
#ifndef RGFW_NO_MONITOR
|
#ifndef RGFW_NO_MONITOR
|
||||||
if (flags & RGFW_windowScaleToMonitor) RGFW_window_scaleToMonitor(win);
|
if (flags & RGFW_windowScaleToMonitor) RGFW_window_scaleToMonitor(win);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1796,15 +1810,16 @@ void RGFW_window_setFlags(RGFW_window* win, RGFW_windowFlags flags) {
|
||||||
if (flags & RGFW_windowNoBorder) RGFW_window_setBorder(win, 0);
|
if (flags & RGFW_windowNoBorder) RGFW_window_setBorder(win, 0);
|
||||||
else RGFW_window_setBorder(win, 1);
|
else RGFW_window_setBorder(win, 1);
|
||||||
if (flags & RGFW_windowFullscreen) RGFW_window_setFullscreen(win, RGFW_TRUE);
|
if (flags & RGFW_windowFullscreen) RGFW_window_setFullscreen(win, RGFW_TRUE);
|
||||||
else if (win->_flags & RGFW_windowFullscreen) RGFW_window_setFullscreen(win, 0);
|
else if (cmpFlags & RGFW_windowFullscreen) RGFW_window_setFullscreen(win, 0);
|
||||||
if (flags & RGFW_windowMaximize) RGFW_window_maximize(win);
|
if (flags & RGFW_windowMaximize) RGFW_window_maximize(win);
|
||||||
else if (win->_flags & RGFW_windowMaximize) RGFW_window_restore(win);
|
else if (cmpFlags & RGFW_windowMaximize) RGFW_window_restore(win);
|
||||||
if (flags & RGFW_windowHideMouse) RGFW_window_showMouse(win, 0);
|
if (flags & RGFW_windowHideMouse) RGFW_window_showMouse(win, 0);
|
||||||
else if (win->_flags & RGFW_windowHideMouse) RGFW_window_showMouse(win, 1);
|
else if (cmpFlags & RGFW_windowHideMouse) RGFW_window_showMouse(win, 1);
|
||||||
if (flags & RGFW_windowCocoaCHDirToRes) RGFW_moveToMacOSResourceDir();
|
if (flags & RGFW_windowCocoaCHDirToRes) RGFW_moveToMacOSResourceDir();
|
||||||
if (flags & RGFW_windowFloating) RGFW_window_setFloating(win, 1);
|
if (flags & RGFW_windowFloating) RGFW_window_setFloating(win, 1);
|
||||||
else if (win->_flags & RGFW_windowFloating) RGFW_window_setFloating(win, 0);
|
else if (cmpFlags & RGFW_windowFloating) RGFW_window_setFloating(win, 0);
|
||||||
|
|
||||||
|
if (!(win->_flags & RGFW_WINDOW_INIT)) win->_flags |= RGFW_WINDOW_INIT;
|
||||||
win->_flags = flags;
|
win->_flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1950,6 +1965,10 @@ void RGFW_window_moveToMonitor(RGFW_window* win, RGFW_monitor m) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
RGFW_bool RGFW_window_setIcon(RGFW_window* win, u8* icon, RGFW_area a, i32 channels) {
|
||||||
|
return RGFW_window_setIconEx(win, icon, a, channels, RGFW_iconBoth);
|
||||||
|
}
|
||||||
|
|
||||||
RGFWDEF void RGFW_captureCursor(RGFW_window* win, RGFW_rect);
|
RGFWDEF void RGFW_captureCursor(RGFW_window* win, RGFW_rect);
|
||||||
RGFWDEF void RGFW_releaseCursor(RGFW_window* win);
|
RGFWDEF void RGFW_releaseCursor(RGFW_window* win);
|
||||||
|
|
||||||
|
@ -3310,8 +3329,6 @@ void RGFW_window_initBufferPtr(RGFW_window* win, u8* buffer, RGFW_area area) {
|
||||||
32, ZPixmap, 0, NULL, area.w, area.h,
|
32, ZPixmap, 0, NULL, area.w, area.h,
|
||||||
32, 0
|
32, 0
|
||||||
);
|
);
|
||||||
|
|
||||||
win->src.gc = XCreateGC(win->src.display, win->src.window, 0, NULL);
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef RGFW_WAYLAND
|
#ifdef RGFW_WAYLAND
|
||||||
wayland:
|
wayland:
|
||||||
|
@ -3556,6 +3573,8 @@ RGFW_window* RGFW_createWindowPtr(const char* name, RGFW_rect rect, RGFW_windowF
|
||||||
|
|
||||||
XFreeColors(win->src.display, cmap, NULL, 0, 0);
|
XFreeColors(win->src.display, cmap, NULL, 0, 0);
|
||||||
|
|
||||||
|
win->src.gc = XCreateGC(win->src.display, win->src.window, 0, NULL);
|
||||||
|
|
||||||
#if defined(RGFW_OPENGL) && !defined(RGFW_EGL)
|
#if defined(RGFW_OPENGL) && !defined(RGFW_EGL)
|
||||||
XFree(vi);
|
XFree(vi);
|
||||||
#endif
|
#endif
|
||||||
|
@ -4704,12 +4723,19 @@ void RGFW_window_setMousePassthrough(RGFW_window* win, RGFW_bool passthrough) {
|
||||||
|
|
||||||
#endif /* RGFW_NO_PASSTHROUGH */
|
#endif /* RGFW_NO_PASSTHROUGH */
|
||||||
|
|
||||||
RGFW_bool RGFW_window_setIcon(RGFW_window* win, u8* icon, RGFW_area a, i32 channels) {
|
RGFW_bool RGFW_window_setIconEx(RGFW_window* win, u8* icon, RGFW_area a, i32 channels, u8 type) {
|
||||||
RGFW_ASSERT(win != NULL); RGFW_ASSERT(icon != NULL);
|
RGFW_ASSERT(win != NULL);
|
||||||
RGFW_ASSERT(channels == 3 || channels == 4);
|
|
||||||
RGFW_GOTO_WAYLAND(0);
|
RGFW_GOTO_WAYLAND(0);
|
||||||
#ifdef RGFW_X11
|
#ifdef RGFW_X11
|
||||||
RGFW_LOAD_ATOM(_NET_WM_ICON);
|
RGFW_LOAD_ATOM(_NET_WM_ICON);
|
||||||
|
if (icon == NULL || (channels != 3 && channels != 4)) {
|
||||||
|
RGFW_bool res = (RGFW_bool)XChangeProperty(
|
||||||
|
win->src.display, win->src.window, _NET_WM_ICON, XA_CARDINAL, 32,
|
||||||
|
PropModeReplace, (u8*)NULL, 0
|
||||||
|
);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
i32 count = 2 + (a.w * a.h);
|
i32 count = 2 + (a.w * a.h);
|
||||||
|
|
||||||
unsigned long* data = (unsigned long*) RGFW_ALLOC(count * sizeof(unsigned long));
|
unsigned long* data = (unsigned long*) RGFW_ALLOC(count * sizeof(unsigned long));
|
||||||
|
@ -4731,13 +4757,31 @@ RGFW_bool RGFW_window_setIcon(RGFW_window* win, u8* icon, RGFW_area a, i32 chann
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RGFW_bool res = (RGFW_bool)XChangeProperty(
|
RGFW_bool res = RGFW_TRUE;
|
||||||
|
if (type & RGFW_iconTaskbar) {
|
||||||
|
res = (RGFW_bool)XChangeProperty(
|
||||||
win->src.display, win->src.window, _NET_WM_ICON, XA_CARDINAL, 32,
|
win->src.display, win->src.window, _NET_WM_ICON, XA_CARDINAL, 32,
|
||||||
PropModeReplace, (u8*)data, count
|
PropModeReplace, (u8*)data, count
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type & RGFW_iconWindow) {
|
||||||
|
XWMHints wm_hints;
|
||||||
|
wm_hints.flags = IconPixmapHint;
|
||||||
|
|
||||||
|
int depth = DefaultDepth(win->src.display, DefaultScreen(win->src.display));
|
||||||
|
XImage *image = XCreateImage(win->src.display, DefaultVisual(win->src.display, DefaultScreen(win->src.display)),
|
||||||
|
depth, ZPixmap, 0, (char *)target, a.w, a.h, 32, 0);
|
||||||
|
|
||||||
|
wm_hints.icon_pixmap = XCreatePixmap(win->src.display, win->src.window, a.w, a.h, depth);
|
||||||
|
XPutImage(win->src.display, wm_hints.icon_pixmap, win->src.gc, image, 0, 0, 0, 0, a.w, a.h);
|
||||||
|
image->data = NULL;
|
||||||
|
XDestroyImage(image);
|
||||||
|
|
||||||
|
XSetWMHints(win->src.display, win->src.window, &wm_hints);
|
||||||
|
}
|
||||||
|
|
||||||
RGFW_FREE(data);
|
RGFW_FREE(data);
|
||||||
|
|
||||||
XFlush(win->src.display);
|
XFlush(win->src.display);
|
||||||
return RGFW_BOOL(res);
|
return RGFW_BOOL(res);
|
||||||
#endif
|
#endif
|
||||||
|
@ -5185,7 +5229,7 @@ RGFW_monitor RGFW_XCreateMonitor(i32 screen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RGFW_monitor* RGFW_getMonitors(void) {
|
RGFW_monitor* RGFW_getMonitors(void) {
|
||||||
RGFW_monitor monitors[7];
|
static RGFW_monitor monitors[7];
|
||||||
|
|
||||||
RGFW_GOTO_WAYLAND(1);
|
RGFW_GOTO_WAYLAND(1);
|
||||||
#ifdef RGFW_X11
|
#ifdef RGFW_X11
|
||||||
|
@ -5421,11 +5465,11 @@ void RGFW_window_close(RGFW_window* win) {
|
||||||
if ((win->_flags & RGFW_BUFFER_ALLOC))
|
if ((win->_flags & RGFW_BUFFER_ALLOC))
|
||||||
RGFW_FREE(win->buffer);
|
RGFW_FREE(win->buffer);
|
||||||
XDestroyImage((XImage*) win->src.bitmap);
|
XDestroyImage((XImage*) win->src.bitmap);
|
||||||
XFreeGC(win->src.display, win->src.gc);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (win->src.display) {
|
if (win->src.display) {
|
||||||
|
XFreeGC(win->src.display, win->src.gc);
|
||||||
#if defined(RGFW_OPENGL) && !defined(RGFW_EGL)
|
#if defined(RGFW_OPENGL) && !defined(RGFW_EGL)
|
||||||
glXDestroyContext(win->src.display, win->src.ctx);
|
glXDestroyContext(win->src.display, win->src.ctx);
|
||||||
#endif
|
#endif
|
||||||
|
@ -5755,10 +5799,6 @@ LRESULT CALLBACK WndProcW(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
RGFW_windowMoveCallback(win, win->r);
|
RGFW_windowMoveCallback(win, win->r);
|
||||||
return DefWindowProcW(hWnd, message, wParam, lParam);
|
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||||
case WM_SIZE: {
|
case WM_SIZE: {
|
||||||
RECT clientRect;
|
|
||||||
GetClientRect(hWnd, &clientRect);
|
|
||||||
i32 offset = (windowRect.bottom - windowRect.top) - (clientRect.bottom - clientRect.top);
|
|
||||||
|
|
||||||
if (win->src.aspectRatio.w != 0 && win->src.aspectRatio.h != 0) {
|
if (win->src.aspectRatio.w != 0 && win->src.aspectRatio.h != 0) {
|
||||||
double aspectRatio = (double)win->src.aspectRatio.w / win->src.aspectRatio.h;
|
double aspectRatio = (double)win->src.aspectRatio.w / win->src.aspectRatio.h;
|
||||||
|
|
||||||
|
@ -5768,7 +5808,7 @@ LRESULT CALLBACK WndProcW(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
int newWidth = (int)(height * aspectRatio);
|
int newWidth = (int)(height * aspectRatio);
|
||||||
|
|
||||||
if (win->r.w > windowRect.right - windowRect.left ||
|
if (win->r.w > windowRect.right - windowRect.left ||
|
||||||
win->r.h > (windowRect.bottom - windowRect.top) - offset)
|
win->r.h > (i32)((windowRect.bottom - windowRect.top) - win->src.hOffset))
|
||||||
{
|
{
|
||||||
if (newHeight > height) windowRect.right = windowRect.left + newWidth;
|
if (newHeight > height) windowRect.right = windowRect.left + newWidth;
|
||||||
else windowRect.bottom = windowRect.top + newHeight;
|
else windowRect.bottom = windowRect.top + newHeight;
|
||||||
|
@ -5778,10 +5818,11 @@ LRESULT CALLBACK WndProcW(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
RGFW_window_resize(win, RGFW_AREA((windowRect.right - windowRect.left),
|
RGFW_window_resize(win, RGFW_AREA((windowRect.right - windowRect.left),
|
||||||
(windowRect.bottom - windowRect.top) - offset));
|
(windowRect.bottom - windowRect.top) - win->src.hOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
win->r.w = windowRect.right - windowRect.left;
|
win->r.w = windowRect.right - windowRect.left;
|
||||||
win->r.h = (windowRect.bottom - windowRect.top) - offset;
|
win->r.h = (windowRect.bottom - windowRect.top) - win->src.hOffset;
|
||||||
win->_flags &= ~RGFW_EVENT_PASSED;
|
win->_flags &= ~RGFW_EVENT_PASSED;
|
||||||
win->event.type = RGFW_windowResized;
|
win->event.type = RGFW_windowResized;
|
||||||
RGFW_windowResizeCallback(win, win->r);
|
RGFW_windowResizeCallback(win, win->r);
|
||||||
|
@ -5800,6 +5841,11 @@ LRESULT CALLBACK WndProcW(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
mmi->ptMaxTrackSize.x = win->src.maxSize.w;
|
mmi->ptMaxTrackSize.x = win->src.maxSize.w;
|
||||||
mmi->ptMaxTrackSize.y = win->src.maxSize.h;
|
mmi->ptMaxTrackSize.y = win->src.maxSize.h;
|
||||||
return DefWindowProcW(hWnd, message, wParam, lParam);
|
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||||
|
case WM_PAINT: {
|
||||||
|
win->event.type = RGFW_windowRefresh;
|
||||||
|
RGFW_windowRefreshCallback(win);
|
||||||
|
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||||
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
return DefWindowProcW(hWnd, message, wParam, lParam);
|
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||||
|
@ -6003,7 +6049,7 @@ RGFW_window* RGFW_createWindowPtr(const char* name, RGFW_rect rect, RGFW_windowF
|
||||||
|
|
||||||
RGFW_window_basic_init(win, rect, flags);
|
RGFW_window_basic_init(win, rect, flags);
|
||||||
|
|
||||||
win->src.hIcon = NULL;
|
win->src.hIconSmall = win->src.hIconBig = NULL;
|
||||||
win->src.maxSize = RGFW_AREA(0, 0);
|
win->src.maxSize = RGFW_AREA(0, 0);
|
||||||
win->src.minSize = RGFW_AREA(0, 0);
|
win->src.minSize = RGFW_AREA(0, 0);
|
||||||
win->src.aspectRatio = RGFW_AREA(0, 0);
|
win->src.aspectRatio = RGFW_AREA(0, 0);
|
||||||
|
@ -6029,9 +6075,8 @@ RGFW_window* RGFW_createWindowPtr(const char* name, RGFW_rect rect, RGFW_windowF
|
||||||
Class.cbClsExtra = sizeof(RGFW_window*);
|
Class.cbClsExtra = sizeof(RGFW_window*);
|
||||||
|
|
||||||
Class.hIcon = (HICON)LoadImageA(GetModuleHandleW(NULL), "RGFW_ICON", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
|
Class.hIcon = (HICON)LoadImageA(GetModuleHandleW(NULL), "RGFW_ICON", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
|
||||||
if (Class.hIcon == NULL) {
|
if (Class.hIcon == NULL)
|
||||||
Class.hIcon = (HICON)LoadImageA(NULL, (LPCSTR)IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
|
Class.hIcon = (HICON)LoadImageA(NULL, (LPCSTR)IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
|
||||||
}
|
|
||||||
|
|
||||||
RegisterClassW(&Class);
|
RegisterClassW(&Class);
|
||||||
|
|
||||||
|
@ -6467,7 +6512,7 @@ RGFW_event* RGFW_window_checkEvent(RGFW_window* win) {
|
||||||
|
|
||||||
if (win->event.type == RGFW_quit) return &win->event;
|
if (win->event.type == RGFW_quit) return &win->event;
|
||||||
|
|
||||||
if ((win->event.type == RGFW_windowMoved || win->event.type == RGFW_windowResized)
|
if ((win->event.type == RGFW_windowMoved || win->event.type == RGFW_windowResized || win->event.type == RGFW_windowRefresh)
|
||||||
&& !(win->_flags & RGFW_EVENT_PASSED))
|
&& !(win->_flags & RGFW_EVENT_PASSED))
|
||||||
{
|
{
|
||||||
win->_flags |= RGFW_EVENT_PASSED;
|
win->_flags |= RGFW_EVENT_PASSED;
|
||||||
|
@ -6552,11 +6597,6 @@ RGFW_event* RGFW_window_checkEvent(RGFW_window* win) {
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case WM_PAINT:
|
|
||||||
win->event.type = RGFW_windowRefresh;
|
|
||||||
RGFW_windowRefreshCallback(win);
|
|
||||||
break;
|
|
||||||
|
|
||||||
#if(_WIN32_WINNT >= 0x0600)
|
#if(_WIN32_WINNT >= 0x0600)
|
||||||
case WM_DWMCOMPOSITIONCHANGED:
|
case WM_DWMCOMPOSITIONCHANGED:
|
||||||
case WM_DWMCOLORIZATIONCOLORCHANGED:
|
case WM_DWMCOLORIZATIONCOLORCHANGED:
|
||||||
|
@ -6977,7 +7017,6 @@ RGFW_bool RGFW_monitor_requestMode(RGFW_monitor mon, RGFW_monitorMode mode, RGFW
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HICON RGFW_loadHandleImage(u8* src, RGFW_area a, BOOL icon) {
|
HICON RGFW_loadHandleImage(u8* src, RGFW_area a, BOOL icon) {
|
||||||
BITMAPV5HEADER bi;
|
BITMAPV5HEADER bi;
|
||||||
ZeroMemory(&bi, sizeof(bi));
|
ZeroMemory(&bi, sizeof(bi));
|
||||||
|
@ -7084,7 +7123,8 @@ void RGFW_window_close(RGFW_window* win) {
|
||||||
ReleaseDC(win->src.window, win->src.hdc); /*!< delete device context */
|
ReleaseDC(win->src.window, win->src.hdc); /*!< delete device context */
|
||||||
DestroyWindow(win->src.window); /*!< delete window */
|
DestroyWindow(win->src.window); /*!< delete window */
|
||||||
|
|
||||||
if (win->src.hIcon) DestroyIcon(win->src.hIcon);
|
if (win->src.hIconSmall) DestroyIcon(win->src.hIconSmall);
|
||||||
|
if (win->src.hIconBig) DestroyIcon(win->src.hIconBig);
|
||||||
|
|
||||||
if (win == RGFW_root) {
|
if (win == RGFW_root) {
|
||||||
#ifndef RGFW_NO_XINPUT
|
#ifndef RGFW_NO_XINPUT
|
||||||
|
@ -7167,14 +7207,31 @@ void RGFW_window_setMousePassthrough(RGFW_window* win, RGFW_bool passthrough) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RGFW_bool RGFW_window_setIcon(RGFW_window* win, u8* src, RGFW_area a, i32 channels) {
|
RGFW_bool RGFW_window_setIconEx(RGFW_window* win, u8* src, RGFW_area a, i32 channels, u8 type) {
|
||||||
RGFW_ASSERT(win != NULL);
|
RGFW_ASSERT(win != NULL);
|
||||||
#ifndef RGFW_WIN95
|
#ifndef RGFW_WIN95
|
||||||
RGFW_UNUSED(channels);
|
RGFW_UNUSED(channels);
|
||||||
if (win->src.hIcon) DestroyIcon(win->src.hIcon);
|
|
||||||
|
|
||||||
win->src.hIcon = RGFW_loadHandleImage(src, a, TRUE);
|
if (win->src.hIconSmall && (type & RGFW_iconWindow)) DestroyIcon(win->src.hIconSmall);
|
||||||
SetClassLongPtrA(win->src.window, GCLP_HICON, (LPARAM) win->src.hIcon);
|
if (win->src.hIconBig && (type & RGFW_iconTaskbar)) DestroyIcon(win->src.hIconBig);
|
||||||
|
|
||||||
|
if (src == NULL) {
|
||||||
|
HICON defaultIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
|
if (type & RGFW_iconWindow)
|
||||||
|
SendMessage(win->src.window, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)defaultIcon);
|
||||||
|
if (type & RGFW_iconTaskbar)
|
||||||
|
SendMessage(win->src.window, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)defaultIcon);
|
||||||
|
return RGFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type & RGFW_iconWindow) {
|
||||||
|
win->src.hIconSmall = RGFW_loadHandleImage(src, a, TRUE);
|
||||||
|
SendMessage(win->src.window, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)win->src.hIconSmall);
|
||||||
|
}
|
||||||
|
if (type & RGFW_iconTaskbar) {
|
||||||
|
win->src.hIconBig = RGFW_loadHandleImage(src, a, TRUE);
|
||||||
|
SendMessage(win->src.window, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)win->src.hIconBig);
|
||||||
|
}
|
||||||
return RGFW_TRUE;
|
return RGFW_TRUE;
|
||||||
#else
|
#else
|
||||||
RGFW_UNUSED(src);
|
RGFW_UNUSED(src);
|
||||||
|
@ -7208,7 +7265,6 @@ RGFW_ssize_t RGFW_readClipboardPtr(char* str, size_t strCapacity) {
|
||||||
textLen = 0;
|
textLen = 0;
|
||||||
|
|
||||||
if (str != NULL && textLen) {
|
if (str != NULL && textLen) {
|
||||||
|
|
||||||
if (textLen > 1)
|
if (textLen > 1)
|
||||||
wcstombs(str, wstr, (textLen) );
|
wcstombs(str, wstr, (textLen) );
|
||||||
|
|
||||||
|
@ -8906,8 +8962,14 @@ void RGFW_window_setMaxSize(RGFW_window* win, RGFW_area a) {
|
||||||
((id)win->src.window, sel_registerName("setMaxSize:"), (NSSize){a.w, a.h});
|
((id)win->src.window, sel_registerName("setMaxSize:"), (NSSize){a.w, a.h});
|
||||||
}
|
}
|
||||||
|
|
||||||
RGFW_bool RGFW_window_setIcon(RGFW_window* win, u8* data, RGFW_area area, i32 channels) {
|
RGFW_bool RGFW_window_setIconEx(RGFW_window* win, u8* data, RGFW_area area, i32 channels, u8 type) {
|
||||||
RGFW_ASSERT(win != NULL);
|
RGFW_ASSERT(win != NULL);
|
||||||
|
RGFW_UNUSED(type);
|
||||||
|
|
||||||
|
if (data == NULL) {
|
||||||
|
objc_msgSend_void_id(NSApp, sel_registerName("setApplicationIconImage:"), NULL);
|
||||||
|
return RGFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* code by EimaMei */
|
/* code by EimaMei */
|
||||||
// Make a bitmap representation, then copy the loaded image into it.
|
// Make a bitmap representation, then copy the loaded image into it.
|
||||||
|
@ -10261,7 +10323,7 @@ void RGFW_window_minimize(RGFW_window* win) { RGFW_UNUSED(win); }
|
||||||
void RGFW_window_restore(RGFW_window* win) { RGFW_UNUSED(win); }
|
void RGFW_window_restore(RGFW_window* win) { RGFW_UNUSED(win); }
|
||||||
void RGFW_window_setFloating(RGFW_window* win, RGFW_bool floating) { RGFW_UNUSED(win); RGFW_UNUSED(floating); }
|
void RGFW_window_setFloating(RGFW_window* win, RGFW_bool floating) { RGFW_UNUSED(win); RGFW_UNUSED(floating); }
|
||||||
void RGFW_window_setBorder(RGFW_window* win, RGFW_bool border) { RGFW_UNUSED(win); RGFW_UNUSED(border); }
|
void RGFW_window_setBorder(RGFW_window* win, RGFW_bool border) { RGFW_UNUSED(win); RGFW_UNUSED(border); }
|
||||||
RGFW_bool RGFW_window_setIcon(RGFW_window* win, u8* icon, RGFW_area a, i32 channels) { RGFW_UNUSED(win); RGFW_UNUSED(icon); RGFW_UNUSED(a); RGFW_UNUSED(channels); return RGFW_FALSE; }
|
RGFW_bool RGFW_window_setIconEx(RGFW_window* win, u8* icon, RGFW_area a, i32 channels, u8 type) { RGFW_UNUSED(win); RGFW_UNUSED(icon); RGFW_UNUSED(a); RGFW_UNUSED(channels); RGFW_UNUSED(type); return RGFW_FALSE; }
|
||||||
void RGFW_window_hide(RGFW_window* win) { RGFW_UNUSED(win); }
|
void RGFW_window_hide(RGFW_window* win) { RGFW_UNUSED(win); }
|
||||||
void RGFW_window_show(RGFW_window* win) {RGFW_UNUSED(win); }
|
void RGFW_window_show(RGFW_window* win) {RGFW_UNUSED(win); }
|
||||||
RGFW_bool RGFW_window_isHidden(RGFW_window* win) { RGFW_UNUSED(win); return RGFW_FALSE; }
|
RGFW_bool RGFW_window_isHidden(RGFW_window* win) { RGFW_UNUSED(win); return RGFW_FALSE; }
|
||||||
|
|
|
@ -275,7 +275,7 @@ void ToggleFullscreen(void)
|
||||||
CORE.Window.flags |= FLAG_FULLSCREEN_MODE;
|
CORE.Window.flags |= FLAG_FULLSCREEN_MODE;
|
||||||
|
|
||||||
RGFW_monitor_scaleToWindow(platform.mon, platform.window);
|
RGFW_monitor_scaleToWindow(platform.mon, platform.window);
|
||||||
RGFW_window_fullscreen(platform.window);
|
RGFW_window_setFullscreen(platform.window, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -285,8 +285,8 @@ void ToggleFullscreen(void)
|
||||||
if (platform.mon.mode.area.w)
|
if (platform.mon.mode.area.w)
|
||||||
{
|
{
|
||||||
RGFW_monitor monitor = RGFW_window_getMonitor(platform.window);
|
RGFW_monitor monitor = RGFW_window_getMonitor(platform.window);
|
||||||
|
RGFW_monitor_requestMode(monitor, platform.mon.mode, RGFW_monitorScale);
|
||||||
|
|
||||||
RGFW_monitor_scale(monitor, platform.mon.mode.area);
|
|
||||||
platform.mon.mode.area.w = 0;
|
platform.mon.mode.area.w = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,7 +411,7 @@ void SetWindowState(unsigned int flags)
|
||||||
}
|
}
|
||||||
if (flags & FLAG_MSAA_4X_HINT)
|
if (flags & FLAG_MSAA_4X_HINT)
|
||||||
{
|
{
|
||||||
RGFW_setGLSamples(4);
|
RGFW_setGLHint(RGFW_glSamples, 4);
|
||||||
}
|
}
|
||||||
if (flags & FLAG_INTERLACED_HINT)
|
if (flags & FLAG_INTERLACED_HINT)
|
||||||
{
|
{
|
||||||
|
@ -492,7 +492,7 @@ void ClearWindowState(unsigned int flags)
|
||||||
}
|
}
|
||||||
if (flags & FLAG_MSAA_4X_HINT)
|
if (flags & FLAG_MSAA_4X_HINT)
|
||||||
{
|
{
|
||||||
RGFW_setGLSamples(0);
|
RGFW_setGLHint(RGFW_glSamples, 0);
|
||||||
}
|
}
|
||||||
if (flags & FLAG_INTERLACED_HINT)
|
if (flags & FLAG_INTERLACED_HINT)
|
||||||
{
|
{
|
||||||
|
@ -500,37 +500,27 @@ void ClearWindowState(unsigned int flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set icon for window
|
int RGFW_formatToChannels(int format)
|
||||||
void SetWindowIcon(Image image)
|
|
||||||
{
|
{
|
||||||
i32 channels = 4;
|
switch (format) {
|
||||||
|
|
||||||
switch (image.format)
|
|
||||||
{
|
|
||||||
case PIXELFORMAT_UNCOMPRESSED_GRAYSCALE:
|
case PIXELFORMAT_UNCOMPRESSED_GRAYSCALE:
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R16: // 16 bpp (1 channel - half float)
|
case PIXELFORMAT_UNCOMPRESSED_R16: // 16 bpp (1 channel - half float)
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R32: // 32 bpp (1 channel - float)
|
case PIXELFORMAT_UNCOMPRESSED_R32: // 32 bpp (1 channel - float)
|
||||||
{
|
return 1;
|
||||||
channels = 1;
|
|
||||||
} break;
|
|
||||||
case PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA: // 8*2 bpp (2 channels)
|
case PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA: // 8*2 bpp (2 channels)
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R5G6B5: // 16 bpp
|
case PIXELFORMAT_UNCOMPRESSED_R5G6B5: // 16 bpp
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R8G8B8: // 24 bpp
|
case PIXELFORMAT_UNCOMPRESSED_R8G8B8: // 24 bpp
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: // 16 bpp (1 bit alpha)
|
case PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: // 16 bpp (1 bit alpha)
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: // 16 bpp (4 bit alpha)
|
case PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: // 16 bpp (4 bit alpha)
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: // 32 bpp
|
case PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: // 32 bpp
|
||||||
{
|
return 2;
|
||||||
channels = 2;
|
|
||||||
} break;
|
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R32G32B32: // 32*3 bpp (3 channels - float)
|
case PIXELFORMAT_UNCOMPRESSED_R32G32B32: // 32*3 bpp (3 channels - float)
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R16G16B16: // 16*3 bpp (3 channels - half float)
|
case PIXELFORMAT_UNCOMPRESSED_R16G16B16: // 16*3 bpp (3 channels - half float)
|
||||||
case PIXELFORMAT_COMPRESSED_DXT1_RGB: // 4 bpp (no alpha)
|
case PIXELFORMAT_COMPRESSED_DXT1_RGB: // 4 bpp (no alpha)
|
||||||
case PIXELFORMAT_COMPRESSED_ETC1_RGB: // 4 bpp
|
case PIXELFORMAT_COMPRESSED_ETC1_RGB: // 4 bpp
|
||||||
case PIXELFORMAT_COMPRESSED_ETC2_RGB: // 4 bpp
|
case PIXELFORMAT_COMPRESSED_ETC2_RGB: // 4 bpp
|
||||||
case PIXELFORMAT_COMPRESSED_PVRT_RGB: // 4 bpp
|
case PIXELFORMAT_COMPRESSED_PVRT_RGB: // 4 bpp
|
||||||
{
|
return 3;
|
||||||
channels = 3;
|
|
||||||
} break;
|
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: // 32*4 bpp (4 channels - float)
|
case PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: // 32*4 bpp (4 channels - float)
|
||||||
case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: // 16*4 bpp (4 channels - half float)
|
case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: // 16*4 bpp (4 channels - half float)
|
||||||
case PIXELFORMAT_COMPRESSED_DXT1_RGBA: // 4 bpp (1 bit alpha)
|
case PIXELFORMAT_COMPRESSED_DXT1_RGBA: // 4 bpp (1 bit alpha)
|
||||||
|
@ -540,19 +530,39 @@ void SetWindowIcon(Image image)
|
||||||
case PIXELFORMAT_COMPRESSED_PVRT_RGBA: // 4 bpp
|
case PIXELFORMAT_COMPRESSED_PVRT_RGBA: // 4 bpp
|
||||||
case PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA: // 8 bpp
|
case PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA: // 8 bpp
|
||||||
case PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA: // 2 bpp
|
case PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA: // 2 bpp
|
||||||
{
|
return 4;
|
||||||
channels = 4;
|
default: return 4;
|
||||||
} break;
|
|
||||||
default: break;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RGFW_window_setIcon(platform.window, image.data, RGFW_AREA(image.width, image.height), channels);
|
// Set icon for window
|
||||||
|
void SetWindowIcon(Image image)
|
||||||
|
{
|
||||||
|
RGFW_window_setIcon(platform.window, image.data, RGFW_AREA(image.width, image.height), RGFW_formatToChannels(image.format));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set icon for window
|
// Set icon for window
|
||||||
void SetWindowIcons(Image *images, int count)
|
void SetWindowIcons(Image *images, int count)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "SetWindowIcons() unsupported on target platform");
|
if ((images == NULL) || (count <= 0))
|
||||||
|
{
|
||||||
|
RGFW_window_setIcon(platform.window, NULL, RGFW_AREA(0, 0), 0);
|
||||||
|
} {
|
||||||
|
Image* bigIcon = NULL;
|
||||||
|
Image* smallIcon = NULL;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < count; i++) {
|
||||||
|
if (bigIcon == NULL || (images[i].width > bigIcon->width && images[i].height > bigIcon->height))
|
||||||
|
bigIcon = &images[i];
|
||||||
|
if (smallIcon == NULL || (images[i].width < smallIcon->width && images[i].height > smallIcon->height))
|
||||||
|
smallIcon = &images[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (smallIcon != NULL)
|
||||||
|
RGFW_window_setIconEx(platform.window, smallIcon->data, RGFW_AREA(smallIcon->width, smallIcon->height), RGFW_formatToChannels(smallIcon->format), RGFW_iconWindow);
|
||||||
|
if (bigIcon != NULL)
|
||||||
|
RGFW_window_setIconEx(platform.window, bigIcon->data, RGFW_AREA(bigIcon->width, bigIcon->height), RGFW_formatToChannels(bigIcon->format), RGFW_iconTaskbar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set title for window
|
// Set title for window
|
||||||
|
@ -602,7 +612,7 @@ void SetWindowSize(int width, int height)
|
||||||
// Set window opacity, value opacity is between 0.0 and 1.0
|
// Set window opacity, value opacity is between 0.0 and 1.0
|
||||||
void SetWindowOpacity(float opacity)
|
void SetWindowOpacity(float opacity)
|
||||||
{
|
{
|
||||||
RGFW_window_setOpacity(win, opacity);
|
RGFW_window_setOpacity(platform.window, opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set window focused
|
// Set window focused
|
||||||
|
@ -700,7 +710,7 @@ int GetMonitorRefreshRate(int monitor)
|
||||||
{
|
{
|
||||||
RGFW_monitor *mons = RGFW_getMonitors();
|
RGFW_monitor *mons = RGFW_getMonitors();
|
||||||
|
|
||||||
return (int)mons[monitor].refreshRate;
|
return (int)mons[monitor].mode.refreshRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the human-readable, UTF-8 encoded name of the selected monitor
|
// Get the human-readable, UTF-8 encoded name of the selected monitor
|
||||||
|
@ -971,18 +981,6 @@ void PollInputEvents(void)
|
||||||
|
|
||||||
while (RGFW_window_checkEvent(platform.window))
|
while (RGFW_window_checkEvent(platform.window))
|
||||||
{
|
{
|
||||||
if ((platform.window->event.type >= RGFW_gamepadButtonPressed) && (platform.window->event.type <= RGFW_gamepadAxisMove))
|
|
||||||
{
|
|
||||||
if (!CORE.Input.Gamepad.ready[platform.window->event.gamepad])
|
|
||||||
{
|
|
||||||
CORE.Input.Gamepad.ready[platform.window->event.gamepad] = true;
|
|
||||||
CORE.Input.Gamepad.axisCount[platform.window->event.gamepad] = platform.window->event.axisesCount;
|
|
||||||
CORE.Input.Gamepad.name[platform.window->event.gamepad][0] = '\0';
|
|
||||||
CORE.Input.Gamepad.axisState[platform.window->event.gamepad][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f;
|
|
||||||
CORE.Input.Gamepad.axisState[platform.window->event.gamepad][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RGFW_event *event = &platform.window->event;
|
RGFW_event *event = &platform.window->event;
|
||||||
// All input events can be processed after polling
|
// All input events can be processed after polling
|
||||||
|
|
||||||
|
@ -1128,6 +1126,17 @@ void PollInputEvents(void)
|
||||||
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
|
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
|
||||||
touchAction = 2;
|
touchAction = 2;
|
||||||
} break;
|
} break;
|
||||||
|
case RGFW_gamepadConnected:
|
||||||
|
CORE.Input.Gamepad.ready[platform.window->event.gamepad] = true;
|
||||||
|
CORE.Input.Gamepad.axisCount[platform.window->event.gamepad] = platform.window->event.axisesCount;
|
||||||
|
CORE.Input.Gamepad.axisState[platform.window->event.gamepad][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f;
|
||||||
|
CORE.Input.Gamepad.axisState[platform.window->event.gamepad][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f;
|
||||||
|
|
||||||
|
strcpy(CORE.Input.Gamepad.name[platform.window->event.gamepad], RGFW_getGamepadName(platform.window, platform.window->event.gamepad));
|
||||||
|
break;
|
||||||
|
case RGFW_gamepadDisconnected:
|
||||||
|
CORE.Input.Gamepad.ready[platform.window->event.gamepad] = false;
|
||||||
|
break;
|
||||||
case RGFW_gamepadButtonPressed:
|
case RGFW_gamepadButtonPressed:
|
||||||
{
|
{
|
||||||
int button = RGFW_gpConvTable[event->button];
|
int button = RGFW_gpConvTable[event->button];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue