Merge 2e2d0cbd2b
into 5f497d0687
This commit is contained in:
commit
1db3a1c252
29 changed files with 148 additions and 132 deletions
|
@ -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);
|
||||||
|
|
||||||
|
@ -125,4 +125,4 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
@ -89,4 +89,4 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
@ -152,4 +152,4 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
@ -245,4 +245,4 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);;
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,7 +263,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
|
||||||
|
@ -128,4 +138,4 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
@ -106,4 +106,4 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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", (int)rec.x - 20, (int)rec.y - 35, 10, DARKGRAY);
|
DrawText("Rounded rectangle", (int)rec.x - 20, (int)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((int)rec.x - 20, (int)rec.y - 20, (int)rec.width + 40, (int)rec.height + 40, DARKGRAY);
|
DrawRectangleLines((int)rec.x - 20, (int)rec.y - 20, (int)rec.width + 40, (int)rec.height + 40, DARKGRAY);
|
||||||
DrawText("Rounded rectangle shadow", (int)rec.x - 20, (int)rec.y - 35, 10, DARKGRAY);
|
DrawText("Rounded rectangle shadow", (int)rec.x - 20, (int)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((int)rec.x - 20, (int)rec.y - 20, (int)rec.width + 40, (int)rec.height + 40, DARKGRAY);
|
DrawRectangleLines((int)rec.x - 20, (int)rec.y - 20, (int)rec.width + 40, (int)rec.height + 40, DARKGRAY);
|
||||||
DrawText("Rounded rectangle border", (int)rec.x - 20, (int)rec.y - 35, 10, DARKGRAY);
|
DrawText("Rounded rectangle border", (int)rec.x - 20, (int)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((int)rec.x - 30, (int)rec.y - 30, (int)rec.width + 60, (int)rec.height + 60, DARKGRAY);
|
DrawRectangleLines(rec.x - 30, rec.y - 30, rec.width + 60, rec.height + 60, DARKGRAY);
|
||||||
DrawText("Rectangle with all three combined", (int)rec.x - 30, (int)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();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -74,6 +74,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);
|
||||||
|
@ -91,8 +93,8 @@ int main(void)
|
||||||
|
|
||||||
// Draw into screen our custom render texture
|
// Draw into screen our custom render texture
|
||||||
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();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -164,4 +166,4 @@ void UnloadRenderTextureDepthTex(RenderTexture2D target)
|
||||||
// queried and deleted before deleting framebuffer
|
// queried and deleted before deleting framebuffer
|
||||||
rlUnloadFramebuffer(target.id);
|
rlUnloadFramebuffer(target.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
@ -81,4 +81,4 @@ int main(void)
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -114,4 +114,4 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
@ -108,4 +113,4 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -60,4 +60,4 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -413,23 +413,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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue