@@ -67,58 +67,52 @@ int main(void)
67
67
// Main game loop
68
68
while (!WindowShouldClose ()) // Detect window close button or ESC key
69
69
{
70
-
71
70
// Update
72
71
//----------------------------------------------------------------------------------
73
- if (IsKeyPressed (KEY_LEFT ) && fontSize > 9.0 ) fontSize -= 1 ; // Reduce fontSize
74
-
75
- if (IsKeyPressed (KEY_RIGHT ) && fontSize < 15.0 ) fontSize += 1 ; // Increase fontSize
76
-
77
- if (circlePos .x > 200.0f || circlePos .x < 40.0f ) circleSpeed *= -1 ; // Revert speed
78
-
79
72
circlePos .x += circleSpeed ;
73
+ if ((circlePos .x > 200.0f ) || (circlePos .x < 40.0f )) circleSpeed *= -1 ; // Revert speed
74
+
75
+ if (IsKeyPressed (KEY_LEFT ) && (fontSize > 9.0 )) fontSize -= 1 ; // Reduce fontSize
76
+ if (IsKeyPressed (KEY_RIGHT ) && (fontSize < 15.0 )) fontSize += 1 ; // Increase fontSize
80
77
81
78
// Set fontsize for the shader
82
79
SetShaderValue (shader , fontSizeLoc , & fontSize , SHADER_UNIFORM_FLOAT );
83
80
84
81
// Draw
85
82
//----------------------------------------------------------------------------------
86
-
87
83
BeginTextureMode (target );
88
- ClearBackground (WHITE ); // The background of the scene itself
84
+ ClearBackground (WHITE );
89
85
90
- // Samples Using custom shader
86
+ // Draw scene in our render texture
91
87
DrawTexture (fudesumi , 500 , -30 , WHITE );
92
88
DrawTextureV (raysan , circlePos , WHITE );
93
-
94
89
EndTextureMode ();
90
+
95
91
BeginDrawing ();
96
-
97
92
ClearBackground (RAYWHITE );
98
93
99
94
BeginShaderMode (shader );
100
-
101
95
// Draw the scene texture (that we rendered earlier) to the screen
102
96
// The shader will process every pixel of this texture
103
97
DrawTextureRec (target .texture ,
104
- (Rectangle ){ 0 , 0 , (float )target .texture .width , (float )- target .texture .height },
105
- (Vector2 ){ 0 , 0 },
106
- WHITE );
98
+ (Rectangle ){ 0 , 0 , (float )target .texture .width , (float )- target .texture .height },
99
+ (Vector2 ){ 0 , 0 }, WHITE );
107
100
EndShaderMode ();
108
101
109
102
DrawRectangle (0 , 0 , screenWidth , 40 , BLACK );
110
103
DrawText (TextFormat ("Ascii effect - FontSize:%2.0f - [Left] -1 [Right] +1 " , fontSize ), 120 , 10 , 20 , LIGHTGRAY );
111
104
DrawFPS (10 , 10 );
112
-
113
105
EndDrawing ();
114
106
//----------------------------------------------------------------------------------
115
107
}
116
108
117
109
// De-Initialization
118
110
//--------------------------------------------------------------------------------------
119
- UnloadShader (shader ); // Unload shader
120
- UnloadTexture (fudesumi ); // Unload texture
121
- UnloadTexture (raysan ); // Unload texture
111
+ UnloadRenderTexture (target ); // Unload render texture
112
+
113
+ UnloadShader (shader ); // Unload shader
114
+ UnloadTexture (fudesumi ); // Unload texture
115
+ UnloadTexture (raysan ); // Unload texture
122
116
123
117
CloseWindow (); // Close window and OpenGL context
124
118
//--------------------------------------------------------------------------------------
0 commit comments