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
|
||||
# Options:
|
||||
# raylib_USE_STATIC_LIBS - OFF by default
|
||||
# raylib_USE_STATIC_LIBS - ON by default
|
||||
# raylib_VERBOSE - OFF by default
|
||||
# Once done, this defines a raylib target that can be passed to
|
||||
# target_link_libraries as well as following variables:
|
||||
|
|
@ -11,6 +11,9 @@
|
|||
# raylib_LDFLAGS - The linker flags needed with 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)
|
||||
set(XPREFIX PC_RAYLIB)
|
||||
|
||||
|
|
@ -25,23 +28,22 @@ if (NOT TARGET raylib)
|
|||
|
||||
find_path(raylib_INCLUDE_DIR
|
||||
NAMES raylib.h
|
||||
HINTS ${${XPREFIX}_INCLUDE_DIRS}
|
||||
HINTS ${${XPREFIX}_INCLUDE_DIRS} ${raylib_DIR}/../../../include/
|
||||
)
|
||||
|
||||
set(RAYLIB_NAMES raylib)
|
||||
|
||||
if (raylib_USE_STATIC_LIBS)
|
||||
set(RAYLIB_NAMES libraylib.a raylib.lib ${RAYLIB_NAMES})
|
||||
endif()
|
||||
set(RAYLIB_NAMES libraylib.a raylib.lib)
|
||||
else ()
|
||||
set(RAYLIB_NAMES raylib)
|
||||
endif ()
|
||||
|
||||
find_library(raylib_LIBRARY
|
||||
NAMES ${RAYLIB_NAMES}
|
||||
HINTS ${${XPREFIX}_LIBRARY_DIRS}
|
||||
HINTS ${${XPREFIX}_LIBRARY_DIRS} ${raylib_DIR}/../../
|
||||
)
|
||||
|
||||
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_LDFLAGS ${${XPREFIX}_LDFLAGS})
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ int main(void)
|
|||
EndMode3D();
|
||||
|
||||
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();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ int main(void)
|
|||
|
||||
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);
|
||||
|
||||
|
|
@ -125,4 +125,4 @@ int main(void)
|
|||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ int main(void)
|
|||
|
||||
EndMode3D();
|
||||
|
||||
DrawTexture(texture, screenWidth - texture.width - 20, 20, WHITE);
|
||||
DrawRectangleLines(screenWidth - texture.width - 20, 20, texture.width, texture.height, GREEN);
|
||||
DrawTexture(texture, GetScreenWidth() - texture.width - 20, 20, WHITE);
|
||||
DrawRectangleLines(GetScreenWidth() - texture.width - 20, 20, texture.width, texture.height, GREEN);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
|
|
@ -89,4 +89,4 @@ int main(void)
|
|||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ int main(void)
|
|||
DrawText("Drag & drop model to load mesh/texture.", 10, GetScreenHeight() - 20, 10, DARKGRAY);
|
||||
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);
|
||||
|
||||
|
|
@ -152,4 +152,4 @@ int main(void)
|
|||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,11 +182,11 @@ int main(void)
|
|||
EndMode3D();
|
||||
|
||||
// Display info
|
||||
DrawRectangle(10, 400, 340, 60, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines(10, 400, 340, 60, Fade(DARKBLUE, 0.5f));
|
||||
DrawText("MOUSE LEFT BUTTON to CYCLE VOX MODELS", 40, 410, 10, BLUE);
|
||||
DrawText("MOUSE MIDDLE BUTTON to ZOOM OR ROTATE CAMERA", 40, 420, 10, BLUE);
|
||||
DrawText("UP-DOWN-LEFT-RIGHT KEYS to MOVE CAMERA", 40, 430, 10, BLUE);
|
||||
DrawRectangle(10, GetScreenHeight() - 50, 340, 60, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines(10, GetScreenHeight() - 50, 340, 60, Fade(DARKBLUE, 0.5f));
|
||||
DrawText("MOUSE LEFT BUTTON to CYCLE VOX MODELS", 40, GetScreenHeight() - 50 + 10, 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, GetScreenHeight() - 50 + 30, 10, BLUE);
|
||||
DrawText(TextFormat("File: %s", GetFileName(voxFileNames[currentModel])), 10, 10, 20, GRAY);
|
||||
|
||||
EndDrawing();
|
||||
|
|
|
|||
|
|
@ -110,21 +110,21 @@ int main(void)
|
|||
|
||||
EndMode3D();
|
||||
|
||||
DrawRectangle(30, 400, 310, 30, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines(30, 400, 310, 30, Fade(DARKBLUE, 0.5f));
|
||||
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL MODELS", 40, 410, 10, BLUE);
|
||||
DrawRectangle(30, GetScreenHeight() - 50, 310, 30, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines(30, GetScreenHeight() - 50, 310, 30, Fade(DARKBLUE, 0.5f));
|
||||
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL MODELS", 40, GetScreenHeight() - 50 + 10, 10, BLUE);
|
||||
|
||||
switch (currentModel)
|
||||
{
|
||||
case 0: DrawText("PLANE", 680, 10, 20, DARKBLUE); break;
|
||||
case 1: DrawText("CUBE", 680, 10, 20, DARKBLUE); break;
|
||||
case 2: DrawText("SPHERE", 680, 10, 20, DARKBLUE); break;
|
||||
case 3: DrawText("HEMISPHERE", 640, 10, 20, DARKBLUE); break;
|
||||
case 4: DrawText("CYLINDER", 680, 10, 20, DARKBLUE); break;
|
||||
case 5: DrawText("TORUS", 680, 10, 20, DARKBLUE); break;
|
||||
case 6: DrawText("KNOT", 680, 10, 20, DARKBLUE); break;
|
||||
case 7: DrawText("POLY", 680, 10, 20, DARKBLUE); break;
|
||||
case 8: DrawText("Custom (triangle)", 580, 10, 20, DARKBLUE); break;
|
||||
case 0: DrawText("PLANE", GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
|
||||
case 1: DrawText("CUBE", GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
|
||||
case 2: DrawText("SPHERE", GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
|
||||
case 3: DrawText("HEMISPHERE", GetScreenWidth() - 160, 10, 20, DARKBLUE); break;
|
||||
case 4: DrawText("CYLINDER", GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
|
||||
case 5: DrawText("TORUS", GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
|
||||
case 6: DrawText("KNOT", GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
|
||||
case 7: DrawText("POLY", GetScreenWidth() - 120, 10, 20, DARKBLUE); break;
|
||||
case 8: DrawText("Custom (triangle)", GetScreenWidth() - 220, 10, 20, DARKBLUE); 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("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);
|
||||
|
||||
|
|
@ -245,4 +245,4 @@ int main(void)
|
|||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ int main()
|
|||
EndMode3D();
|
||||
|
||||
// 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("Down - decrease points", 20, 100, 20, WHITE);
|
||||
DrawText("Space - drawing function", 20, 130, 20, WHITE);
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ int main(void)
|
|||
|
||||
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);
|
||||
|
||||
EndDrawing();
|
||||
|
|
|
|||
|
|
@ -101,13 +101,13 @@ int main(void)
|
|||
EndMode3D();
|
||||
|
||||
// Draw controls info
|
||||
DrawRectangle(30, 370, 260, 70, Fade(GREEN, 0.5f));
|
||||
DrawRectangleLines(30, 370, 260, 70, Fade(DARKGREEN, 0.5f));
|
||||
DrawText("Pitch controlled with: KEY_UP / KEY_DOWN", 40, 380, 10, DARKGRAY);
|
||||
DrawText("Roll controlled with: KEY_LEFT / KEY_RIGHT", 40, 400, 10, DARKGRAY);
|
||||
DrawText("Yaw controlled with: KEY_A / KEY_S", 40, 420, 10, DARKGRAY);
|
||||
DrawRectangle(30, GetScreenHeight() - 80, 260, 70, Fade(GREEN, 0.5f));
|
||||
DrawRectangleLines(30, GetScreenHeight() - 80, 260, 70, Fade(DARKGREEN, 0.5f));
|
||||
DrawText("Pitch controlled with: KEY_UP / KEY_DOWN", 40, GetScreenHeight() - 70, 10, DARKGRAY);
|
||||
DrawText("Roll controlled with: KEY_LEFT / KEY_RIGHT", 40, GetScreenHeight() - 50, 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();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -12,19 +12,15 @@ uniform vec4 colDiffuse;
|
|||
|
||||
// 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 angle = 0.8;
|
||||
|
||||
uniform vec2 size = { 800.0, 450.0 };
|
||||
uniform vec2 center;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 texSize = vec2(renderWidth, renderHeight);
|
||||
vec2 tc = fragTexCoord*texSize;
|
||||
vec2 tc = fragTexCoord*size;
|
||||
tc -= center;
|
||||
|
||||
float dist = length(tc);
|
||||
|
|
@ -40,7 +36,7 @@ void main()
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,19 +10,15 @@ uniform vec4 colDiffuse;
|
|||
|
||||
// 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 angle = 0.8;
|
||||
|
||||
uniform vec2 size = vec2(800.0, 450.0);
|
||||
uniform vec2 center;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 texSize = vec2(renderWidth, renderHeight);
|
||||
vec2 tc = fragTexCoord*texSize;
|
||||
vec2 tc = fragTexCoord*size;
|
||||
tc -= center;
|
||||
|
||||
float dist = length(tc);
|
||||
|
|
@ -38,7 +34,7 @@ void main()
|
|||
}
|
||||
|
||||
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);;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,19 +13,15 @@ out vec4 finalColor;
|
|||
|
||||
// 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 angle = 0.8;
|
||||
|
||||
uniform vec2 size = vec2(800.0, 450.0);
|
||||
uniform vec2 center = vec2(200.0, 200.0);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 texSize = vec2(renderWidth, renderHeight);
|
||||
vec2 tc = fragTexCoord*texSize;
|
||||
vec2 tc = fragTexCoord*size;
|
||||
tc -= center;
|
||||
|
||||
float dist = length(tc);
|
||||
|
|
@ -41,7 +37,7 @@ void main()
|
|||
}
|
||||
|
||||
tc += center;
|
||||
vec4 color = texture(texture0, tc/texSize)*colDiffuse*fragColor;;
|
||||
vec4 color = texture(texture0, tc/size)*colDiffuse*fragColor;;
|
||||
|
||||
finalColor = vec4(color.rgb, 1.0);;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ int main()
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,8 +35,10 @@ int main(void)
|
|||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
int screenWidth = 800;
|
||||
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)
|
||||
|
||||
|
|
@ -62,12 +64,11 @@ int main(void)
|
|||
|
||||
// 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
|
||||
int swirlSizeLoc = GetShaderLocation(shader, "size");
|
||||
int swirlCenterLoc = GetShaderLocation(shader, "center");
|
||||
|
||||
float swirlCenter[2] = { (float)screenWidth/2, (float)screenHeight/2 };
|
||||
|
||||
// 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
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
|
@ -75,15 +76,24 @@ int main(void)
|
|||
// Main game loop
|
||||
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
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||
|
||||
Vector2 mousePosition = GetMousePosition();
|
||||
|
||||
swirlSize[0] = screenWidth;
|
||||
swirlSize[1] = screenHeight;
|
||||
SetShaderValue(shader, swirlSizeLoc, swirlSize, SHADER_UNIFORM_VEC2);
|
||||
|
||||
swirlCenter[0] = mousePosition.x;
|
||||
swirlCenter[1] = screenHeight - mousePosition.y;
|
||||
|
||||
// Send new value to the shader to be used on drawing
|
||||
SetShaderValue(shader, swirlCenterLoc, swirlCenter, SHADER_UNIFORM_VEC2);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
@ -98,7 +108,7 @@ int main(void)
|
|||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
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)
|
||||
|
||||
BeginDrawing();
|
||||
|
|
@ -107,7 +117,7 @@ int main(void)
|
|||
// Enable shader using the custom uniform
|
||||
BeginShaderMode(shader);
|
||||
// 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();
|
||||
|
||||
// Draw some 2d text over drawn texture
|
||||
|
|
@ -128,4 +138,4 @@ int main(void)
|
|||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,9 +51,6 @@ int main(void)
|
|||
int mouseLoc = GetShaderLocation(shader, "mouse");
|
||||
int timeLoc = GetShaderLocation(shader, "time");
|
||||
|
||||
float resolution[2] = { (float)screenWidth, (float)screenHeight };
|
||||
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
|
||||
|
||||
float totalTime = 0.0f;
|
||||
bool shaderAutoReloading = false;
|
||||
|
||||
|
|
@ -65,6 +62,9 @@ int main(void)
|
|||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
float resolution[2] = { (float)GetScreenWidth(), (float)GetScreenHeight() };
|
||||
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
|
||||
|
||||
totalTime += GetFrameTime();
|
||||
Vector2 mouse = GetMousePosition();
|
||||
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
|
||||
BeginShaderMode(shader);
|
||||
DrawRectangle(0, 0, screenWidth, screenHeight, WHITE);
|
||||
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), WHITE);
|
||||
EndShaderMode();
|
||||
|
||||
DrawText(TextFormat("PRESS [A] to TOGGLE SHADER AUTOLOADING: %s",
|
||||
shaderAutoReloading? "AUTO" : "MANUAL"), 10, 10, 10, shaderAutoReloading? RED : 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();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -69,12 +69,6 @@ int main(void)
|
|||
marchLocs.camDir = GetShaderLocation(shdrRaymarch, "camDir");
|
||||
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
|
||||
Camera camera = {
|
||||
|
|
@ -87,6 +81,7 @@ int main(void)
|
|||
|
||||
// Camera FOV is pre-calculated in the camera Distance.
|
||||
float camDist = 1.0f/(tanf(camera.fovy*0.5f*DEG2RAD));
|
||||
RenderTexture2D target;
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
|
@ -96,6 +91,14 @@ int main(void)
|
|||
{
|
||||
// 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);
|
||||
|
||||
// Update Camera Postion in the ray march shader.
|
||||
|
|
@ -115,7 +118,7 @@ int main(void)
|
|||
// Raymarch Scene
|
||||
rlEnableDepthTest(); //Manually enable Depth Test to handle multiple rendering methods.
|
||||
BeginShaderMode(shdrRaymarch);
|
||||
DrawRectangleRec((Rectangle){0,0, (float)screenWidth, (float)screenHeight},WHITE);
|
||||
DrawRectangleRec((Rectangle){0,0, (float)GetScreenWidth(), (float)GetScreenHeight()},WHITE);
|
||||
EndShaderMode();
|
||||
|
||||
// Rasterize Scene
|
||||
|
|
@ -134,7 +137,7 @@ int main(void)
|
|||
BeginDrawing();
|
||||
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);
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ int main(void)
|
|||
|
||||
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);
|
||||
|
||||
|
|
@ -106,4 +106,4 @@ int main(void)
|
|||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,6 +133,8 @@ int main(void)
|
|||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
UnloadRenderTexture(target);
|
||||
target = LoadRenderTexture(GetScreenWidth(), GetScreenHeight());
|
||||
BeginTextureMode(target); // Enable drawing to texture
|
||||
ClearBackground(RAYWHITE); // Clear texture background
|
||||
|
||||
|
|
@ -148,17 +150,17 @@ int main(void)
|
|||
// Render generated texture using selected postprocessing shader
|
||||
BeginShaderMode(shaders[currentShader]);
|
||||
// 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();
|
||||
|
||||
// Draw 2d shapes and text over drawn texture
|
||||
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(postproShaderText[currentShader], 330, 15, 20, RED);
|
||||
DrawText("< >", 540, 10, 30, DARKBLUE);
|
||||
DrawFPS(700, 15);
|
||||
DrawFPS(GetScreenWidth() - 100, 15);
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue