21
21
using static Raylib_cs . Color ;
22
22
using static Raylib_cs . KeyboardKey ;
23
23
using static Raylib_cs . MouseButton ;
24
- using static Raylib_cs . ShaderLocationIndex ;
25
24
using static Raylib_cs . ShaderUniformDataType ;
26
25
27
26
namespace Examples
@@ -54,7 +53,7 @@ public static int Main()
54
53
Shader shader = LoadShader ( null , string . Format ( "resources/shaders/glsl{0}/julia_set.fs" , GLSL_VERSION ) ) ;
55
54
56
55
// c constant to use in z^2 + c
57
- float [ ] c = new float [ 2 ] { POINTS_OF_INTEREST [ 0 ] [ 0 ] , POINTS_OF_INTEREST [ 0 ] [ 1 ] } ;
56
+ float [ ] c = { POINTS_OF_INTEREST [ 0 ] [ 0 ] , POINTS_OF_INTEREST [ 0 ] [ 1 ] } ;
58
57
59
58
// Offset and zoom to draw the julia set at. (centered on screen and default size)
60
59
float [ ] offset = { - ( float ) screenWidth / 2 , - ( float ) screenHeight / 2 } ;
@@ -70,11 +69,11 @@ public static int Main()
70
69
71
70
// Tell the shader what the screen dimensions, zoom, offset and c are
72
71
float [ ] screenDims = { ( float ) screenWidth , ( float ) screenHeight } ;
73
- SetShaderValue ( shader , GetShaderLocation ( shader , "screenDims" ) , ref screenDims , UNIFORM_VEC2 ) ;
72
+ Utils . SetShaderValue ( shader , GetShaderLocation ( shader , "screenDims" ) , screenDims , UNIFORM_VEC2 ) ;
74
73
75
- SetShaderValue ( shader , cLoc , ref c , UNIFORM_VEC2 ) ;
76
- SetShaderValue ( shader , zoomLoc , ref zoomLoc , UNIFORM_FLOAT ) ;
77
- SetShaderValue ( shader , offsetLoc , ref offset , UNIFORM_VEC2 ) ;
74
+ Utils . SetShaderValue ( shader , cLoc , c , UNIFORM_VEC2 ) ;
75
+ Utils . SetShaderValue ( shader , zoomLoc , ref zoomLoc , UNIFORM_FLOAT ) ;
76
+ Utils . SetShaderValue ( shader , offsetLoc , offset , UNIFORM_VEC2 ) ;
78
77
79
78
// Create a RenderTexture2D to be used for render to texture
80
79
RenderTexture2D target = LoadRenderTexture ( screenWidth , screenHeight ) ;
@@ -130,11 +129,20 @@ public static int Main()
130
129
c [ 0 ] = POINTS_OF_INTEREST [ 5 ] [ 0 ] ;
131
130
c [ 1 ] = POINTS_OF_INTEREST [ 5 ] [ 1 ] ;
132
131
}
133
- SetShaderValue ( shader , cLoc , ref c , UNIFORM_VEC2 ) ;
132
+ Utils . SetShaderValue ( shader , cLoc , c , UNIFORM_VEC2 ) ;
134
133
}
135
134
136
- if ( IsKeyPressed ( KEY_SPACE ) ) pause = ! pause ; // Pause animation (c change)
137
- if ( IsKeyPressed ( KEY_F1 ) ) showControls = ! showControls ; // Toggle whether or not to show controls
135
+ // Pause animation (c change)
136
+ if ( IsKeyPressed ( KEY_SPACE ) )
137
+ {
138
+ pause = ! pause ;
139
+ }
140
+
141
+ // Toggle whether or not to show controls
142
+ if ( IsKeyPressed ( KEY_F1 ) )
143
+ {
144
+ showControls = ! showControls ;
145
+ }
138
146
139
147
if ( ! pause )
140
148
{
@@ -157,17 +165,20 @@ public static int Main()
157
165
offset [ 0 ] += GetFrameTime ( ) * offsetSpeed . x * 0.8f ;
158
166
offset [ 1 ] += GetFrameTime ( ) * offsetSpeed . y * 0.8f ;
159
167
}
160
- else offsetSpeed = new Vector2 ( 0.0f , 0.0f ) ;
168
+ else
169
+ {
170
+ offsetSpeed = new Vector2 ( 0.0f , 0.0f ) ;
171
+ }
161
172
162
- SetShaderValue ( shader , zoomLoc , ref zoom , UNIFORM_FLOAT ) ;
163
- SetShaderValue ( shader , offsetLoc , ref offset , UNIFORM_VEC2 ) ;
173
+ Utils . SetShaderValue ( shader , zoomLoc , ref zoom , UNIFORM_FLOAT ) ;
174
+ Utils . SetShaderValue ( shader , offsetLoc , offset , UNIFORM_VEC2 ) ;
164
175
165
176
// Increment c value with time
166
177
float amount = GetFrameTime ( ) * incrementSpeed * 0.0005f ;
167
178
c [ 0 ] += amount ;
168
179
c [ 1 ] += amount ;
169
180
170
- SetShaderValue ( shader , cLoc , ref c , UNIFORM_VEC2 ) ;
181
+ Utils . SetShaderValue ( shader , cLoc , c , UNIFORM_VEC2 ) ;
171
182
}
172
183
//----------------------------------------------------------------------------------
173
184
@@ -179,7 +190,7 @@ public static int Main()
179
190
180
191
// Using a render texture to draw Julia set
181
192
BeginTextureMode ( target ) ; // Enable drawing to texture
182
- ClearBackground ( BLACK ) ; // Clear the render texture
193
+ ClearBackground ( BLACK ) ; // Clear the render texture
183
194
184
195
// Draw a rectangle in shader mode to be used as shader canvas
185
196
// NOTE: Rectangle uses font white character texture coordinates,
0 commit comments