Comments starting with a capital letter, and some minor fixes to adhere to the convention
This commit is contained in:
parent
d64af0a39f
commit
0abc047c84
|
|
@ -11,11 +11,11 @@ varying vec4 fragColor;
|
||||||
uniform vec2 offset; // Offset of the scale
|
uniform vec2 offset; // Offset of the scale
|
||||||
uniform float zoom; // Zoom of the scale
|
uniform float zoom; // Zoom of the scale
|
||||||
// NOTE: Maximum number of shader for-loop iterations depend on GPU,
|
// NOTE: Maximum number of shader for-loop iterations depend on GPU,
|
||||||
// for example, on RasperryPi for this examply only supports up to 60
|
// For example, on RasperryPi for this examply only supports up to 60
|
||||||
uniform int maxIterations; // Max iterations per pixel
|
uniform int maxIterations; // Max iterations per pixel
|
||||||
|
|
||||||
const float max = 4.0; // We consider infinite as 4.0: if a point reaches a distance of 4.0 it will escape to infinity
|
const float max = 4.0; // We consider infinite as 4.0: if a point reaches a distance of 4.0 it will escape to infinity
|
||||||
const float max2 = max * max; // Square of max to avoid computing square root
|
const float max2 = max*max; // Square of max to avoid computing square root
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
@ -28,7 +28,7 @@ void main()
|
||||||
float b = 0.0;
|
float b = 0.0;
|
||||||
|
|
||||||
// The Mandelbrot set is a two-dimensional set defined in the complex plane on which the iteration of the function
|
// The Mandelbrot set is a two-dimensional set defined in the complex plane on which the iteration of the function
|
||||||
// fc(z) = z^2 + c on the complex numbers c from the plane does not diverge to infinity starting at z = 0
|
// Fc(z) = z^2 + c on the complex numbers c from the plane does not diverge to infinity starting at z = 0
|
||||||
// Here: z = a + bi. Iterations: z -> z^2 + c = (a + bi)^2 + (c.x + c.yi) = (a^2 - b^2 + c.x) + (2ab + c.y)i
|
// Here: z = a + bi. Iterations: z -> z^2 + c = (a + bi)^2 + (c.x + c.yi) = (a^2 - b^2 + c.x) + (2ab + c.y)i
|
||||||
|
|
||||||
int iter = 0;
|
int iter = 0;
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@ varying vec4 fragColor;
|
||||||
uniform vec2 offset; // Offset of the scale
|
uniform vec2 offset; // Offset of the scale
|
||||||
uniform float zoom; // Zoom of the scale
|
uniform float zoom; // Zoom of the scale
|
||||||
// NOTE: Maximum number of shader for-loop iterations depend on GPU,
|
// NOTE: Maximum number of shader for-loop iterations depend on GPU,
|
||||||
// for example, on RasperryPi for this examply only supports up to 60
|
// For example, on RasperryPi for this examply only supports up to 60
|
||||||
uniform int maxIterations; // Max iterations per pixel
|
uniform int maxIterations; // Max iterations per pixel
|
||||||
|
|
||||||
const float max = 4.0; // We consider infinite as 4.0: if a point reaches a distance of 4.0 it will escape to infinity
|
const float max = 4.0; // We consider infinite as 4.0: if a point reaches a distance of 4.0 it will escape to infinity
|
||||||
const float max2 = max * max; // Square of max to avoid computing square root
|
const float max2 = max*max; // Square of max to avoid computing square root
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
@ -26,7 +26,7 @@ void main()
|
||||||
float b = 0.0;
|
float b = 0.0;
|
||||||
|
|
||||||
// The Mandelbrot set is a two-dimensional set defined in the complex plane on which the iteration of the function
|
// The Mandelbrot set is a two-dimensional set defined in the complex plane on which the iteration of the function
|
||||||
// fc(z) = z^2 + c on the complex numbers c from the plane does not diverge to infinity starting at z = 0
|
// Fc(z) = z^2 + c on the complex numbers c from the plane does not diverge to infinity starting at z = 0
|
||||||
// Here: z = a + bi. Iterations: z -> z^2 + c = (a + bi)^2 + (c.x + c.yi) = (a^2 - b^2 + c.x) + (2ab + c.y)i
|
// Here: z = a + bi. Iterations: z -> z^2 + c = (a + bi)^2 + (c.x + c.yi) = (a^2 - b^2 + c.x) + (2ab + c.y)i
|
||||||
|
|
||||||
int iter = 0;
|
int iter = 0;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ uniform float zoom; // Zoom of the scale
|
||||||
uniform int maxIterations; // Max iterations per pixel
|
uniform int maxIterations; // Max iterations per pixel
|
||||||
|
|
||||||
const float max = 4.0; // We consider infinite as 4.0: if a point reaches a distance of 4.0 it will escape to infinity
|
const float max = 4.0; // We consider infinite as 4.0: if a point reaches a distance of 4.0 it will escape to infinity
|
||||||
const float max2 = max * max; // Square of max to avoid computing square root
|
const float max2 = max*max; // Square of max to avoid computing square root
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
@ -27,7 +27,7 @@ void main()
|
||||||
float b = 0.0;
|
float b = 0.0;
|
||||||
|
|
||||||
// The Mandelbrot set is a two-dimensional set defined in the complex plane on which the iteration of the function
|
// The Mandelbrot set is a two-dimensional set defined in the complex plane on which the iteration of the function
|
||||||
// fc(z) = z^2 + c on the complex numbers c from the plane does not diverge to infinity starting at z = 0
|
// Fc(z) = z^2 + c on the complex numbers c from the plane does not diverge to infinity starting at z = 0
|
||||||
// Here: z = a + bi. Iterations: z -> z^2 + c = (a + bi)^2 + (c.x + c.yi) = (a^2 - b^2 + c.x) + (2ab + c.y)i
|
// Here: z = a + bi. Iterations: z -> z^2 + c = (a + bi)^2 + (c.x + c.yi) = (a^2 - b^2 + c.x) + (2ab + c.y)i
|
||||||
|
|
||||||
int iter = 0;
|
int iter = 0;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
* Example originally created with raylib 5.6, last time updated with raylib 5.6
|
* Example originally created with raylib 5.6, last time updated with raylib 5.6
|
||||||
*
|
*
|
||||||
* Example contributed by Jordi Santonja (@JordSant)
|
* Example contributed by Jordi Santonja (@JordSant)
|
||||||
* based on previous work by Josh Colclough (@joshcol9232)
|
* Based on previous work by Josh Colclough (@joshcol9232)
|
||||||
*
|
*
|
||||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||||
* BSD-like license that allows static linking with closed source software
|
* BSD-like license that allows static linking with closed source software
|
||||||
|
|
@ -146,12 +146,12 @@ int main(void)
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT) || IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
|
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT) || IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
|
||||||
{
|
{
|
||||||
// Change zoom. If Mouse left -> zoom in. Mouse right -> zoom out
|
// Change zoom. If Mouse left -> zoom in. Mouse right -> zoom out
|
||||||
zoom *= IsMouseButtonDown(MOUSE_BUTTON_LEFT)? zoomSpeed : 1.0f/zoomSpeed;
|
zoom *= IsMouseButtonDown(MOUSE_BUTTON_LEFT)? zoomSpeed : (1.0f/zoomSpeed);
|
||||||
|
|
||||||
const Vector2 mousePos = GetMousePosition();
|
const Vector2 mousePos = GetMousePosition();
|
||||||
Vector2 offsetVelocity;
|
Vector2 offsetVelocity;
|
||||||
// Find the velocity at which to change the camera. Take the distance of the mouse
|
// Find the velocity at which to change the camera. Take the distance of the mouse
|
||||||
// from the center of the screen as the direction, and adjust magnitude based on the current zoom
|
// From the center of the screen as the direction, and adjust magnitude based on the current zoom
|
||||||
offsetVelocity.x = (mousePos.x/(float)screenWidth - 0.5f)*offsetSpeedMul/zoom;
|
offsetVelocity.x = (mousePos.x/(float)screenWidth - 0.5f)*offsetSpeedMul/zoom;
|
||||||
offsetVelocity.y = (mousePos.y/(float)screenHeight - 0.5f)*offsetSpeedMul/zoom;
|
offsetVelocity.y = (mousePos.y/(float)screenHeight - 0.5f)*offsetSpeedMul/zoom;
|
||||||
|
|
||||||
|
|
@ -184,8 +184,8 @@ int main(void)
|
||||||
|
|
||||||
// Draw a rectangle in shader mode to be used as shader canvas
|
// Draw a rectangle in shader mode to be used as shader canvas
|
||||||
// NOTE: Rectangle uses font white character texture coordinates,
|
// NOTE: Rectangle uses font white character texture coordinates,
|
||||||
// so shader can not be applied here directly because input vertexTexCoord
|
// So shader can not be applied here directly because input vertexTexCoord
|
||||||
// do not represent full screen coordinates (space where want to apply shader)
|
// Do not represent full screen coordinates (space where want to apply shader)
|
||||||
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLACK);
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLACK);
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
|
|
@ -196,7 +196,7 @@ int main(void)
|
||||||
// NOTE: We do not invert texture on Y, already considered inside shader
|
// NOTE: We do not invert texture on Y, already considered inside shader
|
||||||
BeginShaderMode(shader);
|
BeginShaderMode(shader);
|
||||||
// WARNING: If FLAG_WINDOW_HIGHDPI is enabled, HighDPI monitor scaling should be considered
|
// WARNING: If FLAG_WINDOW_HIGHDPI is enabled, HighDPI monitor scaling should be considered
|
||||||
// when rendering the RenderTexture2D to fit in the HighDPI scaled Window
|
// When rendering the RenderTexture2D to fit in the HighDPI scaled Window
|
||||||
DrawTextureEx(target.texture, (Vector2){ 0.0f, 0.0f }, 0.0f, 1.0f, WHITE);
|
DrawTextureEx(target.texture, (Vector2){ 0.0f, 0.0f }, 0.0f, 1.0f, WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user