mirror of
https://github.com/raysan5/raylib.git
synced 2025-10-06 09:56:28 +00:00
Update shaders_ascii_rendering.c
This commit is contained in:
@@ -67,58 +67,52 @@ 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
|
||||||
{
|
{
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (IsKeyPressed(KEY_LEFT) && fontSize > 9.0) fontSize -= 1; // Reduce fontSize
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_RIGHT) && fontSize < 15.0) fontSize += 1; // Increase fontSize
|
|
||||||
|
|
||||||
if (circlePos.x > 200.0f || circlePos.x < 40.0f) circleSpeed *= -1; // Revert speed
|
|
||||||
|
|
||||||
circlePos.x += circleSpeed;
|
circlePos.x += circleSpeed;
|
||||||
|
if ((circlePos.x > 200.0f) || (circlePos.x < 40.0f)) circleSpeed *= -1; // Revert speed
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_LEFT) && (fontSize > 9.0)) fontSize -= 1; // Reduce fontSize
|
||||||
|
if (IsKeyPressed(KEY_RIGHT) && (fontSize < 15.0)) fontSize += 1; // Increase fontSize
|
||||||
|
|
||||||
// Set fontsize for the shader
|
// Set fontsize for the shader
|
||||||
SetShaderValue(shader, fontSizeLoc, &fontSize, SHADER_UNIFORM_FLOAT);
|
SetShaderValue(shader, fontSizeLoc, &fontSize, SHADER_UNIFORM_FLOAT);
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
BeginTextureMode(target);
|
BeginTextureMode(target);
|
||||||
ClearBackground(WHITE); // The background of the scene itself
|
ClearBackground(WHITE);
|
||||||
|
|
||||||
// Samples Using custom shader
|
// Draw scene in our render texture
|
||||||
DrawTexture(fudesumi, 500, -30, WHITE);
|
DrawTexture(fudesumi, 500, -30, WHITE);
|
||||||
DrawTextureV(raysan, circlePos, WHITE);
|
DrawTextureV(raysan, circlePos, WHITE);
|
||||||
|
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
BeginShaderMode(shader);
|
BeginShaderMode(shader);
|
||||||
|
|
||||||
// Draw the scene texture (that we rendered earlier) to the screen
|
// Draw the scene texture (that we rendered earlier) to the screen
|
||||||
// The shader will process every pixel of this texture
|
// The shader will process every pixel of this texture
|
||||||
DrawTextureRec(target.texture,
|
DrawTextureRec(target.texture,
|
||||||
(Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height },
|
(Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height },
|
||||||
(Vector2){ 0, 0 },
|
(Vector2){ 0, 0 }, WHITE);
|
||||||
WHITE);
|
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
DrawRectangle(0, 0, screenWidth, 40, BLACK);
|
DrawRectangle(0, 0, screenWidth, 40, BLACK);
|
||||||
DrawText(TextFormat("Ascii effect - FontSize:%2.0f - [Left] -1 [Right] +1 ", fontSize), 120, 10, 20, LIGHTGRAY);
|
DrawText(TextFormat("Ascii effect - FontSize:%2.0f - [Left] -1 [Right] +1 ", fontSize), 120, 10, 20, LIGHTGRAY);
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
UnloadShader(shader); // Unload shader
|
UnloadRenderTexture(target); // Unload render texture
|
||||||
UnloadTexture(fudesumi); // Unload texture
|
|
||||||
UnloadTexture(raysan); // Unload texture
|
UnloadShader(shader); // Unload shader
|
||||||
|
UnloadTexture(fudesumi); // Unload texture
|
||||||
|
UnloadTexture(raysan); // Unload texture
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user