2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-06-30 19:03:42 -04:00

Update enum/color names to match C# naming convention (#224)

This commit is contained in:
Danil
2024-01-18 21:00:57 +02:00
committed by GitHub
parent 2a1889403d
commit 70d86837d4
123 changed files with 1843 additions and 1847 deletions

View File

@ -43,7 +43,7 @@ public class BasicLighting
const int screenHeight = 450;
// Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - basic lighting");
// Define the camera to look into our 3d world
@ -52,7 +52,7 @@ public class BasicLighting
camera.Target = new Vector3(0.0f, 0.5f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Load plane model from a generated mesh
Model model = LoadModelFromMesh(GenMeshPlane(10.0f, 10.0f, 3, 3));
@ -64,12 +64,12 @@ public class BasicLighting
);
// Get some required shader loactions
shader.Locs[(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
shader.Locs[(int)ShaderLocationIndex.VectorView] = GetShaderLocation(shader, "viewPos");
// ambient light level
int ambientLoc = GetShaderLocation(shader, "ambient");
float[] ambient = new[] { 0.1f, 0.1f, 0.1f, 1.0f };
Raylib.SetShaderValue(shader, ambientLoc, ambient, ShaderUniformDataType.SHADER_UNIFORM_VEC4);
Raylib.SetShaderValue(shader, ambientLoc, ambient, ShaderUniformDataType.Vec4);
// Assign out lighting shader to model
model.Materials[0].Shader = shader;
@ -82,7 +82,7 @@ public class BasicLighting
LightType.Point,
new Vector3(-2, 1, -2),
Vector3.Zero,
Color.YELLOW,
Color.Yellow,
shader
);
lights[1] = Rlights.CreateLight(
@ -90,7 +90,7 @@ public class BasicLighting
LightType.Point,
new Vector3(2, 1, 2),
Vector3.Zero,
Color.RED,
Color.Red,
shader
);
lights[2] = Rlights.CreateLight(
@ -98,7 +98,7 @@ public class BasicLighting
LightType.Point,
new Vector3(-2, 1, 2),
Vector3.Zero,
Color.GREEN,
Color.Green,
shader
);
lights[3] = Rlights.CreateLight(
@ -106,7 +106,7 @@ public class BasicLighting
LightType.Point,
new Vector3(2, 1, -2),
Vector3.Zero,
Color.BLUE,
Color.Blue,
shader
);
@ -118,21 +118,21 @@ public class BasicLighting
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
if (IsKeyPressed(KeyboardKey.KEY_Y))
if (IsKeyPressed(KeyboardKey.Y))
{
lights[0].Enabled = !lights[0].Enabled;
}
if (IsKeyPressed(KeyboardKey.KEY_R))
if (IsKeyPressed(KeyboardKey.R))
{
lights[1].Enabled = !lights[1].Enabled;
}
if (IsKeyPressed(KeyboardKey.KEY_G))
if (IsKeyPressed(KeyboardKey.G))
{
lights[2].Enabled = !lights[2].Enabled;
}
if (IsKeyPressed(KeyboardKey.KEY_B))
if (IsKeyPressed(KeyboardKey.B))
{
lights[3].Enabled = !lights[3].Enabled;
}
@ -146,57 +146,57 @@ public class BasicLighting
// Update the light shader with the camera view position
Raylib.SetShaderValue(
shader,
shader.Locs[(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW],
shader.Locs[(int)ShaderLocationIndex.VectorView],
camera.Position,
ShaderUniformDataType.SHADER_UNIFORM_VEC3
ShaderUniformDataType.Vec3
);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawModel(model, Vector3.Zero, 1.0f, Color.WHITE);
DrawModel(cube, Vector3.Zero, 1.0f, Color.WHITE);
DrawModel(model, Vector3.Zero, 1.0f, Color.White);
DrawModel(cube, Vector3.Zero, 1.0f, Color.White);
// Draw markers to show where the lights are
if (lights[0].Enabled)
{
DrawSphereEx(lights[0].Position, 0.2f, 8, 8, Color.YELLOW);
DrawSphereEx(lights[0].Position, 0.2f, 8, 8, Color.Yellow);
}
else
{
DrawSphereWires(lights[0].Position, 0.2f, 8, 8, ColorAlpha(Color.YELLOW, 0.3f));
DrawSphereWires(lights[0].Position, 0.2f, 8, 8, ColorAlpha(Color.Yellow, 0.3f));
}
if (lights[1].Enabled)
{
DrawSphereEx(lights[1].Position, 0.2f, 8, 8, Color.RED);
DrawSphereEx(lights[1].Position, 0.2f, 8, 8, Color.Red);
}
else
{
DrawSphereWires(lights[1].Position, 0.2f, 8, 8, ColorAlpha(Color.RED, 0.3f));
DrawSphereWires(lights[1].Position, 0.2f, 8, 8, ColorAlpha(Color.Red, 0.3f));
}
if (lights[2].Enabled)
{
DrawSphereEx(lights[2].Position, 0.2f, 8, 8, Color.GREEN);
DrawSphereEx(lights[2].Position, 0.2f, 8, 8, Color.Green);
}
else
{
DrawSphereWires(lights[2].Position, 0.2f, 8, 8, ColorAlpha(Color.GREEN, 0.3f));
DrawSphereWires(lights[2].Position, 0.2f, 8, 8, ColorAlpha(Color.Green, 0.3f));
}
if (lights[3].Enabled)
{
DrawSphereEx(lights[3].Position, 0.2f, 8, 8, Color.BLUE);
DrawSphereEx(lights[3].Position, 0.2f, 8, 8, Color.Blue);
}
else
{
DrawSphereWires(lights[3].Position, 0.2f, 8, 8, ColorAlpha(Color.BLUE, 0.3f));
DrawSphereWires(lights[3].Position, 0.2f, 8, 8, ColorAlpha(Color.Blue, 0.3f));
}
DrawGrid(10, 1.0f);
@ -204,7 +204,7 @@ public class BasicLighting
EndMode3D();
DrawFPS(10, 10);
DrawText("Use keys [Y][R][G][B] to toggle lights", 10, 40, 20, Color.DARKGRAY);
DrawText("Use keys [Y][R][G][B] to toggle lights", 10, 40, 20, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ public class CustomUniform
const int screenHeight = 450;
// Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable");
@ -41,13 +41,13 @@ public class CustomUniform
camera.Target = new Vector3(0.0f, 1.5f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Model model = LoadModel("resources/models/obj/barracks.obj");
Texture2D texture = LoadTexture("resources/models/obj/barracks_diffuse.png");
// Set model diffuse texture
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
Vector3 position = new(0.0f, 0.0f, 0.0f);
@ -78,28 +78,28 @@ public class CustomUniform
swirlCenter[1] = screenHeight - mousePosition.Y;
// Send new value to the shader to be used on drawing
Raylib.SetShaderValue(shader, swirlCenterLoc, swirlCenter, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, swirlCenterLoc, swirlCenter, ShaderUniformDataType.Vec2);
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Enable drawing to texture
BeginTextureMode(target);
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawModel(model, position, 0.5f, Color.WHITE);
DrawModel(model, position, 0.5f, Color.White);
DrawGrid(10, 1.0f);
EndMode3D();
DrawText("TEXT DRAWN IN RENDER TEXTURE", 200, 10, 30, Color.RED);
DrawText("TEXT DRAWN IN RENDER TEXTURE", 200, 10, 30, Color.Red);
// End drawing to texture (now we have a texture available for next passes)
EndTextureMode();
@ -111,7 +111,7 @@ public class CustomUniform
target.Texture,
new Rectangle(0, 0, target.Texture.Width, -target.Texture.Height),
new Vector2(0, 0),
Color.WHITE
Color.White
);
EndShaderMode();
@ -121,7 +121,7 @@ public class CustomUniform
screenWidth - 220,
screenHeight - 20,
10,
Color.GRAY
Color.Gray
);
DrawFPS(10, 10);

View File

@ -61,17 +61,17 @@ public class Eratosthenes
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Enable drawing to texture
BeginTextureMode(target);
ClearBackground(Color.BLACK);
ClearBackground(Color.Black);
// Draw a rectangle in shader mode to be used as shader canvas
// NOTE: Rectangle uses font white character texture coordinates,
// so shader can not be applied here directly because input vertexTexCoord
// do not represent full screen coordinates (space where want to apply shader)
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Color.BLACK);
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Color.Black);
// End drawing to texture (now we have a blank texture available for the shader)
EndTextureMode();
@ -82,7 +82,7 @@ public class Eratosthenes
target.Texture,
new Rectangle(0, 0, target.Texture.Width, -target.Texture.Height),
new Vector2(0.0f, 0.0f),
Color.WHITE
Color.White
);
EndShaderMode();

View File

@ -42,7 +42,7 @@ public class Fog
const int screenHeight = 450;
// Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - fog");
// Define the camera to look into our 3d world
@ -51,7 +51,7 @@ public class Fog
camera.Target = new Vector3(0.0f, 0.5f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Load models and texture
Model modelA = LoadModelFromMesh(GenMeshTorus(0.4f, 1.0f, 16, 32));
@ -60,14 +60,14 @@ public class Fog
Texture2D texture = LoadTexture("resources/texel_checker.png");
// Assign texture to default model material
Raylib.SetMaterialTexture(ref modelA, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref modelB, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref modelC, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref modelA, 0, MaterialMapIndex.Albedo, ref texture);
Raylib.SetMaterialTexture(ref modelB, 0, MaterialMapIndex.Albedo, ref texture);
Raylib.SetMaterialTexture(ref modelC, 0, MaterialMapIndex.Albedo, ref texture);
// Load shader and set up some uniforms
Shader shader = LoadShader("resources/shaders/glsl330/lighting.vs", "resources/shaders/glsl330/fog.fs");
shader.Locs[(int)ShaderLocationIndex.SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(shader, "matModel");
shader.Locs[(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
shader.Locs[(int)ShaderLocationIndex.MatrixModel] = GetShaderLocation(shader, "matModel");
shader.Locs[(int)ShaderLocationIndex.VectorView] = GetShaderLocation(shader, "viewPos");
// Ambient light level
int ambientLoc = GetShaderLocation(shader, "ambient");
@ -75,12 +75,12 @@ public class Fog
shader,
ambientLoc,
new float[] { 0.2f, 0.2f, 0.2f, 1.0f },
ShaderUniformDataType.SHADER_UNIFORM_VEC4
ShaderUniformDataType.Vec4
);
float fogDensity = 0.15f;
int fogDensityLoc = GetShaderLocation(shader, "fogDensity");
Raylib.SetShaderValue(shader, fogDensityLoc, fogDensity, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, fogDensityLoc, fogDensity, ShaderUniformDataType.Float);
// NOTE: All models share the same shader
Raylib.SetMaterialShader(ref modelA, 0, ref shader);
@ -88,7 +88,7 @@ public class Fog
Raylib.SetMaterialShader(ref modelC, 0, ref shader);
// Using just 1 point lights
Rlights.CreateLight(0, LightType.Point, new Vector3(0, 2, 6), Vector3.Zero, Color.WHITE, shader);
Rlights.CreateLight(0, LightType.Point, new Vector3(0, 2, 6), Vector3.Zero, Color.White, shader);
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -98,9 +98,9 @@ public class Fog
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
if (IsKeyDown(KeyboardKey.KEY_UP))
if (IsKeyDown(KeyboardKey.Up))
{
fogDensity += 0.001f;
if (fogDensity > 1.0f)
@ -109,7 +109,7 @@ public class Fog
}
}
if (IsKeyDown(KeyboardKey.KEY_DOWN))
if (IsKeyDown(KeyboardKey.Down))
{
fogDensity -= 0.001f;
if (fogDensity < 0.0f)
@ -118,7 +118,7 @@ public class Fog
}
}
Raylib.SetShaderValue(shader, fogDensityLoc, fogDensity, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, fogDensityLoc, fogDensity, ShaderUniformDataType.Float);
// Rotate the torus
modelA.Transform = MatrixMultiply(modelA.Transform, MatrixRotateX(-0.025f));
@ -127,27 +127,27 @@ public class Fog
// Update the light shader with the camera view position
Raylib.SetShaderValue(
shader,
shader.Locs[(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW],
shader.Locs[(int)ShaderLocationIndex.VectorView],
camera.Position,
ShaderUniformDataType.SHADER_UNIFORM_VEC3
ShaderUniformDataType.Vec3
);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.GRAY);
ClearBackground(Color.Gray);
BeginMode3D(camera);
// Draw the three models
DrawModel(modelA, Vector3.Zero, 1.0f, Color.WHITE);
DrawModel(modelB, new Vector3(-2.6f, 0, 0), 1.0f, Color.WHITE);
DrawModel(modelC, new Vector3(2.6f, 0, 0), 1.0f, Color.WHITE);
DrawModel(modelA, Vector3.Zero, 1.0f, Color.White);
DrawModel(modelB, new Vector3(-2.6f, 0, 0), 1.0f, Color.White);
DrawModel(modelC, new Vector3(2.6f, 0, 0), 1.0f, Color.White);
for (int i = -20; i < 20; i += 2)
{
DrawModel(modelA, new Vector3(i, 0, 2), 1.0f, Color.WHITE);
DrawModel(modelA, new Vector3(i, 0, 2), 1.0f, Color.White);
}
EndMode3D();
@ -157,7 +157,7 @@ public class Fog
10,
10,
20,
Color.RAYWHITE
Color.RayWhite
);
EndDrawing();

View File

@ -41,7 +41,7 @@ public class HotReloading
int timeLoc = GetShaderLocation(shader, "time");
float[] resolution = new[] { (float)screenWidth, (float)screenHeight };
Raylib.SetShaderValue(shader, resolutionLoc, resolution, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, resolutionLoc, resolution, ShaderUniformDataType.Vec2);
float totalTime = 0.0f;
bool shaderAutoReloading = false;
@ -59,11 +59,11 @@ public class HotReloading
float[] mousePos = new[] { mouse.X, mouse.Y };
// Set shader required uniform values
Raylib.SetShaderValue(shader, timeLoc, totalTime, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, mouseLoc, mousePos, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, timeLoc, totalTime, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, mouseLoc, mousePos, ShaderUniformDataType.Vec2);
// Hot shader reloading
if (shaderAutoReloading || (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON)))
if (shaderAutoReloading || (IsMouseButtonPressed(MouseButton.Left)))
{
long currentFragShaderModTime = GetFileModTime(fragShaderFileName);
@ -89,7 +89,7 @@ public class HotReloading
shader,
resolutionLoc,
resolution,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
}
@ -97,7 +97,7 @@ public class HotReloading
}
}
if (IsKeyPressed(KeyboardKey.KEY_A))
if (IsKeyPressed(KeyboardKey.A))
{
shaderAutoReloading = !shaderAutoReloading;
}
@ -106,18 +106,18 @@ public class HotReloading
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// We only draw a white full-screen rectangle, frame is generated in shader
BeginShaderMode(shader);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.WHITE);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.White);
EndShaderMode();
string info = $"PRESS [A] to TOGGLE SHADER AUTOLOADING: {(shaderAutoReloading ? "AUTO" : "MANUAL")}";
DrawText(info, 10, 10, 10, shaderAutoReloading ? Color.RED : Color.BLACK);
DrawText(info, 10, 10, 10, shaderAutoReloading ? Color.Red : Color.Black);
if (!shaderAutoReloading)
{
DrawText("MOUSE CLICK to SHADER RE-LOADING", 10, 30, 10, Color.BLACK);
DrawText("MOUSE CLICK to SHADER RE-LOADING", 10, 30, 10, Color.Black);
}
// DrawText($"Shader last modification: ", 10, 430, 10, Color.BLACK);

View File

@ -60,7 +60,7 @@ public class HybridRender
shdrRaymarch,
marchLocs.ScreenCenter,
screenCenter,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
// Use customized function to create writable depth texture buffer
@ -72,7 +72,7 @@ public class HybridRender
camera.Target = new Vector3(0.0f, 0.5f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Camera FOV is pre-calculated in the camera Distance.
float camDist = 1.0f / (MathF.Tan(camera.FovY * 0.5f * Raylib.DEG2RAD));
@ -85,41 +85,41 @@ public class HybridRender
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
// Update Camera Postion in the ray march shader.
SetShaderValue(
shdrRaymarch,
marchLocs.CamPos,
camera.Position,
ShaderUniformDataType.SHADER_UNIFORM_VEC3
ShaderUniformDataType.Vec3
);
// Update Camera Looking Vector. Vector length determines FOV.
Vector3 camDir = Vector3.Normalize(camera.Target - camera.Position) * camDist;
SetShaderValue(shdrRaymarch, marchLocs.CamDir, camDir, ShaderUniformDataType.SHADER_UNIFORM_VEC3);
SetShaderValue(shdrRaymarch, marchLocs.CamDir, camDir, ShaderUniformDataType.Vec3);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
// Draw into our custom render texture (framebuffer)
BeginTextureMode(target);
ClearBackground(Color.WHITE);
ClearBackground(Color.White);
// Raymarch Scene
// Manually enable Depth Test to handle multiple rendering methods.
Rlgl.EnableDepthTest();
BeginShaderMode(shdrRaymarch);
DrawRectangleRec(new Rectangle(0, 0, screenWidth, screenHeight), Color.WHITE);
DrawRectangleRec(new Rectangle(0, 0, screenWidth, screenHeight), Color.White);
EndShaderMode();
// Rasterize Scene
BeginMode3D(camera);
BeginShaderMode(shdrRaster);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.RED);
DrawCubeV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.PURPLE);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.DARKGREEN);
DrawCubeV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.YELLOW);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.Red);
DrawCubeV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.Purple);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.DarkGreen);
DrawCubeV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.Yellow);
DrawGrid(10, 1.0f);
EndShaderMode();
EndMode3D();
@ -128,13 +128,13 @@ public class HybridRender
// Draw custom render texture
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawTextureRec(
target.Texture,
new Rectangle(0, 0, screenWidth, -screenHeight),
Vector2.Zero,
Color.WHITE
Color.White
);
DrawFPS(10, 10);
@ -171,48 +171,48 @@ public class HybridRender
null,
width,
height,
PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
PixelFormat.UncompressedR8G8B8A8,
1
);
target.Texture.Width = width;
target.Texture.Height = height;
target.Texture.Format = PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
target.Texture.Format = PixelFormat.UncompressedR8G8B8A8;
target.Texture.Mipmaps = 1;
// Create depth texture buffer (instead of raylib default renderbuffer)
target.Depth.Id = Rlgl.LoadTextureDepth(width, height, false);
target.Depth.Width = width;
target.Depth.Height = height;
target.Depth.Format = PixelFormat.PIXELFORMAT_COMPRESSED_PVRT_RGBA;
target.Depth.Format = PixelFormat.CompressedPvrtRgba;
target.Depth.Mipmaps = 1;
// Attach color texture and depth texture to FBO
Rlgl.FramebufferAttach(
target.Id,
target.Texture.Id,
FramebufferAttachType.RL_ATTACHMENT_COLOR_CHANNEL0,
FramebufferAttachTextureType.RL_ATTACHMENT_TEXTURE2D,
FramebufferAttachType.ColorChannel0,
FramebufferAttachTextureType.Texture2D,
0
);
Rlgl.FramebufferAttach(
target.Id,
target.Depth.Id,
FramebufferAttachType.RL_ATTACHMENT_DEPTH,
FramebufferAttachTextureType.RL_ATTACHMENT_TEXTURE2D,
FramebufferAttachType.Depth,
FramebufferAttachTextureType.Texture2D,
0
);
// Check if fbo is complete with attachments (valid)
if (Rlgl.FramebufferComplete(target.Id))
{
TraceLog(TraceLogLevel.LOG_INFO, $"FBO: [ID {target.Id}] Framebuffer object created successfully");
TraceLog(TraceLogLevel.Info, $"FBO: [ID {target.Id}] Framebuffer object created successfully");
}
Rlgl.DisableFramebuffer();
}
else
{
TraceLog(TraceLogLevel.LOG_WARNING, "FBO: Framebuffer object can not be created");
TraceLog(TraceLogLevel.Warning, "FBO: Framebuffer object can not be created");
}
return target;

View File

@ -69,12 +69,12 @@ public class JuliaSet
shader,
GetShaderLocation(shader, "screenDims"),
screenDims,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(shader, cLoc, c, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, zoomLoc, zoomLoc, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, offsetLoc, offset, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, cLoc, c, ShaderUniformDataType.Vec2);
Raylib.SetShaderValue(shader, zoomLoc, zoomLoc, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, offsetLoc, offset, ShaderUniformDataType.Vec2);
// Create a RenderTexture2D to be used for render to texture
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
@ -95,80 +95,80 @@ public class JuliaSet
// Update
//----------------------------------------------------------------------------------
// Press [1 - 6] to reset c to a point of interest
if (IsKeyPressed(KeyboardKey.KEY_ONE) ||
IsKeyPressed(KeyboardKey.KEY_TWO) ||
IsKeyPressed(KeyboardKey.KEY_THREE) ||
IsKeyPressed(KeyboardKey.KEY_FOUR) ||
IsKeyPressed(KeyboardKey.KEY_FIVE) ||
IsKeyPressed(KeyboardKey.KEY_SIX))
if (IsKeyPressed(KeyboardKey.One) ||
IsKeyPressed(KeyboardKey.Two) ||
IsKeyPressed(KeyboardKey.Three) ||
IsKeyPressed(KeyboardKey.Four) ||
IsKeyPressed(KeyboardKey.Five) ||
IsKeyPressed(KeyboardKey.Six))
{
if (IsKeyPressed(KeyboardKey.KEY_ONE))
if (IsKeyPressed(KeyboardKey.One))
{
c[0] = PointsOfInterest[0][0];
c[1] = PointsOfInterest[0][1];
}
else if (IsKeyPressed(KeyboardKey.KEY_TWO))
else if (IsKeyPressed(KeyboardKey.Two))
{
c[0] = PointsOfInterest[1][0];
c[1] = PointsOfInterest[1][1];
}
else if (IsKeyPressed(KeyboardKey.KEY_THREE))
else if (IsKeyPressed(KeyboardKey.Three))
{
c[0] = PointsOfInterest[2][0];
c[1] = PointsOfInterest[2][1];
}
else if (IsKeyPressed(KeyboardKey.KEY_FOUR))
else if (IsKeyPressed(KeyboardKey.Four))
{
c[0] = PointsOfInterest[3][0];
c[1] = PointsOfInterest[3][1];
}
else if (IsKeyPressed(KeyboardKey.KEY_FIVE))
else if (IsKeyPressed(KeyboardKey.Five))
{
c[0] = PointsOfInterest[4][0];
c[1] = PointsOfInterest[4][1];
}
else if (IsKeyPressed(KeyboardKey.KEY_SIX))
else if (IsKeyPressed(KeyboardKey.Six))
{
c[0] = PointsOfInterest[5][0];
c[1] = PointsOfInterest[5][1];
}
Raylib.SetShaderValue(shader, cLoc, c, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, cLoc, c, ShaderUniformDataType.Vec2);
}
// Pause animation (c change)
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
pause = !pause;
}
// Toggle whether or not to show controls
if (IsKeyPressed(KeyboardKey.KEY_F1))
if (IsKeyPressed(KeyboardKey.F1))
{
showControls = !showControls;
}
if (!pause)
{
if (IsKeyPressed(KeyboardKey.KEY_RIGHT))
if (IsKeyPressed(KeyboardKey.Right))
{
incrementSpeed++;
}
else if (IsKeyPressed(KeyboardKey.KEY_LEFT))
else if (IsKeyPressed(KeyboardKey.Left))
{
incrementSpeed--;
}
// TODO: The idea is to zoom and move around with mouse
// Probably offset movement should be proportional to zoom level
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON) || IsMouseButtonDown(MouseButton.MOUSE_RIGHT_BUTTON))
if (IsMouseButtonDown(MouseButton.Left) || IsMouseButtonDown(MouseButton.Right))
{
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonDown(MouseButton.Left))
{
zoom += zoom * 0.003f;
}
if (IsMouseButtonDown(MouseButton.MOUSE_RIGHT_BUTTON))
if (IsMouseButtonDown(MouseButton.Right))
{
zoom -= zoom * 0.003f;
}
@ -187,48 +187,48 @@ public class JuliaSet
offsetSpeed = new Vector2(0.0f, 0.0f);
}
Raylib.SetShaderValue(shader, zoomLoc, zoom, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, offsetLoc, offset, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, zoomLoc, zoom, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, offsetLoc, offset, ShaderUniformDataType.Vec2);
// Increment c value with time
float amount = GetFrameTime() * incrementSpeed * 0.0005f;
c[0] += amount;
c[1] += amount;
Raylib.SetShaderValue(shader, cLoc, c, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, cLoc, c, ShaderUniformDataType.Vec2);
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.BLACK);
ClearBackground(Color.Black);
// Using a render texture to draw Julia set
// Enable drawing to texture
BeginTextureMode(target);
ClearBackground(Color.BLACK);
ClearBackground(Color.Black);
// Draw a rectangle in shader mode to be used as shader canvas
// NOTE: Rectangle uses font Color.white character texture coordinates,
// so shader can not be applied here directly because input vertexTexCoord
// do not represent full screen coordinates (space where want to apply shader)
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Color.BLACK);
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Color.Black);
EndTextureMode();
// Draw the saved texture and rendered julia set with shader
// NOTE: We do not invert texture on Y, already considered inside shader
BeginShaderMode(shader);
DrawTexture(target.Texture, 0, 0, Color.WHITE);
DrawTexture(target.Texture, 0, 0, Color.White);
EndShaderMode();
if (showControls)
{
DrawText("Press Mouse buttons right/left to zoom in/out and move", 10, 15, 10, Color.RAYWHITE);
DrawText("Press KEY_F1 to toggle these controls", 10, 30, 10, Color.RAYWHITE);
DrawText("Press KEYS [1 - 6] to change point of interest", 10, 45, 10, Color.RAYWHITE);
DrawText("Press KEY_LEFT | KEY_RIGHT to change speed", 10, 60, 10, Color.RAYWHITE);
DrawText("Press KEY_SPACE to pause movement animation", 10, 75, 10, Color.RAYWHITE);
DrawText("Press Mouse buttons right/left to zoom in/out and move", 10, 15, 10, Color.RayWhite);
DrawText("Press KEY_F1 to toggle these controls", 10, 30, 10, Color.RayWhite);
DrawText("Press KEYS [1 - 6] to change point of interest", 10, 45, 10, Color.RayWhite);
DrawText("Press KEY_LEFT | KEY_RIGHT to change speed", 10, 60, 10, Color.RayWhite);
DrawText("Press KEY_SPACE to pause movement animation", 10, 75, 10, Color.RayWhite);
}
EndDrawing();

View File

@ -30,7 +30,7 @@ public class MeshInstancing
const int fps = 60;
// Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - rlgl mesh instanced");
// Speed of jump animation
@ -55,7 +55,7 @@ public class MeshInstancing
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Number of instances to display
const int instances = 10000;
@ -97,9 +97,9 @@ public class MeshInstancing
unsafe
{
int* locs = (int*)shader.Locs;
locs[(int)ShaderLocationIndex.SHADER_LOC_MATRIX_MVP] = GetShaderLocation(shader, "mvp");
locs[(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
locs[(int)ShaderLocationIndex.SHADER_LOC_MATRIX_MODEL] = GetShaderLocationAttrib(
locs[(int)ShaderLocationIndex.MatrixMvp] = GetShaderLocation(shader, "mvp");
locs[(int)ShaderLocationIndex.VectorView] = GetShaderLocation(shader, "viewPos");
locs[(int)ShaderLocationIndex.MatrixModel] = GetShaderLocationAttrib(
shader,
"instanceTransform"
);
@ -111,7 +111,7 @@ public class MeshInstancing
shader,
ambientLoc,
new float[] { 0.2f, 0.2f, 0.2f, 1.0f },
ShaderUniformDataType.SHADER_UNIFORM_VEC4
ShaderUniformDataType.Vec4
);
Rlights.CreateLight(
@ -119,7 +119,7 @@ public class MeshInstancing
LightType.Directorional,
new Vector3(50, 50, 0),
Vector3.Zero,
Color.WHITE,
Color.White,
shader
);
@ -127,7 +127,7 @@ public class MeshInstancing
material.Shader = shader;
unsafe
{
material.Maps[(int)MaterialMapIndex.MATERIAL_MAP_DIFFUSE].Color = Color.RED;
material.Maps[(int)MaterialMapIndex.Diffuse].Color = Color.Red;
}
int textPositionY = 300;
@ -143,77 +143,77 @@ public class MeshInstancing
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
textPositionY = 300;
framesCounter += 1;
if (IsKeyDown(KeyboardKey.KEY_UP))
if (IsKeyDown(KeyboardKey.Up))
{
amp += 0.5f;
}
if (IsKeyDown(KeyboardKey.KEY_DOWN))
if (IsKeyDown(KeyboardKey.Down))
{
amp = (amp <= 1) ? 1.0f : (amp - 1.0f);
}
if (IsKeyDown(KeyboardKey.KEY_LEFT))
if (IsKeyDown(KeyboardKey.Left))
{
variance = (variance <= 0.0f) ? 0.0f : (variance - 0.01f);
}
if (IsKeyDown(KeyboardKey.KEY_RIGHT))
if (IsKeyDown(KeyboardKey.Right))
{
variance = (variance >= 1.0f) ? 1.0f : (variance + 0.01f);
}
if (IsKeyDown(KeyboardKey.KEY_ONE))
if (IsKeyDown(KeyboardKey.One))
{
groups = 1;
}
if (IsKeyDown(KeyboardKey.KEY_TWO))
if (IsKeyDown(KeyboardKey.Two))
{
groups = 2;
}
if (IsKeyDown(KeyboardKey.KEY_THREE))
if (IsKeyDown(KeyboardKey.Three))
{
groups = 3;
}
if (IsKeyDown(KeyboardKey.KEY_FOUR))
if (IsKeyDown(KeyboardKey.Four))
{
groups = 4;
}
if (IsKeyDown(KeyboardKey.KEY_FIVE))
if (IsKeyDown(KeyboardKey.Five))
{
groups = 5;
}
if (IsKeyDown(KeyboardKey.KEY_SIX))
if (IsKeyDown(KeyboardKey.Six))
{
groups = 6;
}
if (IsKeyDown(KeyboardKey.KEY_SEVEN))
if (IsKeyDown(KeyboardKey.Seven))
{
groups = 7;
}
if (IsKeyDown(KeyboardKey.KEY_EIGHT))
if (IsKeyDown(KeyboardKey.Eight))
{
groups = 8;
}
if (IsKeyDown(KeyboardKey.KEY_NINE))
if (IsKeyDown(KeyboardKey.Nine))
{
groups = 9;
}
if (IsKeyDown(KeyboardKey.KEY_W))
if (IsKeyDown(KeyboardKey.W))
{
groups = 7;
amp = 25;
@ -221,22 +221,22 @@ public class MeshInstancing
variance = 0.70f;
}
if (IsKeyDown(KeyboardKey.KEY_EQUAL))
if (IsKeyDown(KeyboardKey.Equal))
{
speed = (speed <= (int)(fps * 0.25f)) ? (int)(fps * 0.25f) : (int)(speed * 0.95f);
}
if (IsKeyDown(KeyboardKey.KEY_KP_ADD))
if (IsKeyDown(KeyboardKey.KpAdd))
{
speed = (speed <= (int)(fps * 0.25f)) ? (int)(fps * 0.25f) : (int)(speed * 0.95f);
}
if (IsKeyDown(KeyboardKey.KEY_MINUS))
if (IsKeyDown(KeyboardKey.Minus))
{
speed = (int)MathF.Max(speed * 1.02f, speed + 1);
}
if (IsKeyDown(KeyboardKey.KEY_KP_SUBTRACT))
if (IsKeyDown(KeyboardKey.KpSubtract))
{
speed = (int)MathF.Max(speed * 1.02f, speed + 1);
}
@ -245,9 +245,9 @@ public class MeshInstancing
float[] cameraPos = { camera.Position.X, camera.Position.Y, camera.Position.Z };
Raylib.SetShaderValue(
shader,
(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW,
(int)ShaderLocationIndex.VectorView,
cameraPos,
ShaderUniformDataType.SHADER_UNIFORM_VEC3
ShaderUniformDataType.Vec3
);
// Apply per-instance transformations
@ -273,42 +273,42 @@ public class MeshInstancing
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawMeshInstanced(cube, material, transforms, instances);
EndMode3D();
DrawText("A CUBE OF DANCING CUBES!", 490, 10, 20, Color.MAROON);
DrawText("PRESS KEYS:", 10, textPositionY, 20, Color.BLACK);
DrawText("A CUBE OF DANCING CUBES!", 490, 10, 20, Color.Maroon);
DrawText("PRESS KEYS:", 10, textPositionY, 20, Color.Black);
DrawText("1 - 9", 10, textPositionY += 25, 10, Color.BLACK);
DrawText(": Number of groups", 50, textPositionY, 10, Color.BLACK);
DrawText($": {groups}", 160, textPositionY, 10, Color.BLACK);
DrawText("1 - 9", 10, textPositionY += 25, 10, Color.Black);
DrawText(": Number of groups", 50, textPositionY, 10, Color.Black);
DrawText($": {groups}", 160, textPositionY, 10, Color.Black);
DrawText("UP", 10, textPositionY += 15, 10, Color.BLACK);
DrawText(": increase amplitude", 50, textPositionY, 10, Color.BLACK);
DrawText($": {amp}%.2f", 160, textPositionY, 10, Color.BLACK);
DrawText("UP", 10, textPositionY += 15, 10, Color.Black);
DrawText(": increase amplitude", 50, textPositionY, 10, Color.Black);
DrawText($": {amp}%.2f", 160, textPositionY, 10, Color.Black);
DrawText("DOWN", 10, textPositionY += 15, 10, Color.BLACK);
DrawText(": decrease amplitude", 50, textPositionY, 10, Color.BLACK);
DrawText("DOWN", 10, textPositionY += 15, 10, Color.Black);
DrawText(": decrease amplitude", 50, textPositionY, 10, Color.Black);
DrawText("LEFT", 10, textPositionY += 15, 10, Color.BLACK);
DrawText(": decrease variance", 50, textPositionY, 10, Color.BLACK);
DrawText($": {variance}.2f", 160, textPositionY, 10, Color.BLACK);
DrawText("LEFT", 10, textPositionY += 15, 10, Color.Black);
DrawText(": decrease variance", 50, textPositionY, 10, Color.Black);
DrawText($": {variance}.2f", 160, textPositionY, 10, Color.Black);
DrawText("RIGHT", 10, textPositionY += 15, 10, Color.BLACK);
DrawText(": increase variance", 50, textPositionY, 10, Color.BLACK);
DrawText("RIGHT", 10, textPositionY += 15, 10, Color.Black);
DrawText(": increase variance", 50, textPositionY, 10, Color.Black);
DrawText("+/=", 10, textPositionY += 15, 10, Color.BLACK);
DrawText(": increase speed", 50, textPositionY, 10, Color.BLACK);
DrawText($": {speed} = {((float)fps / speed)} loops/sec", 160, textPositionY, 10, Color.BLACK);
DrawText("+/=", 10, textPositionY += 15, 10, Color.Black);
DrawText(": increase speed", 50, textPositionY, 10, Color.Black);
DrawText($": {speed} = {((float)fps / speed)} loops/sec", 160, textPositionY, 10, Color.Black);
DrawText("-", 10, textPositionY += 15, 10, Color.BLACK);
DrawText(": decrease speed", 50, textPositionY, 10, Color.BLACK);
DrawText("-", 10, textPositionY += 15, 10, Color.Black);
DrawText(": decrease speed", 50, textPositionY, 10, Color.Black);
DrawText("W", 10, textPositionY += 15, 10, Color.BLACK);
DrawText(": Wild setup!", 50, textPositionY, 10, Color.BLACK);
DrawText("W", 10, textPositionY += 15, 10, Color.Black);
DrawText(": Wild setup!", 50, textPositionY, 10, Color.Black);
DrawFPS(10, 10);

View File

@ -31,7 +31,7 @@ public class ModelShader
const int screenHeight = 450;
// Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader");
@ -41,7 +41,7 @@ public class ModelShader
camera.Target = new Vector3(0.0f, 1.0f, -1.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Model model = LoadModel("resources/models/obj/watermill.obj");
Texture2D texture = LoadTexture("resources/models/obj/watermill_diffuse.png");
@ -49,7 +49,7 @@ public class ModelShader
"resources/shaders/glsl330/grayscale.fs");
Raylib.SetMaterialShader(ref model, 0, ref shader);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
Vector3 position = new(0.0f, 0.0f, 0.0f);
@ -61,17 +61,17 @@ public class ModelShader
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawModel(model, position, 0.2f, Color.WHITE);
DrawModel(model, position, 0.2f, Color.White);
DrawGrid(10, 1.0f);
@ -82,11 +82,11 @@ public class ModelShader
screenWidth - 210,
screenHeight - 20,
10,
Color.GRAY
Color.Gray
);
DrawText($"Camera3D position: ({camera.Position})", 600, 20, 10, Color.BLACK);
DrawText($"Camera3D target: ({camera.Position})", 600, 40, 10, Color.GRAY);
DrawText($"Camera3D position: ({camera.Position})", 600, 20, 10, Color.Black);
DrawText($"Camera3D target: ({camera.Position})", 600, 40, 10, Color.Gray);
DrawFPS(10, 10);

View File

@ -56,11 +56,11 @@ public class MultiSample2d
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyDown(KeyboardKey.KEY_RIGHT))
if (IsKeyDown(KeyboardKey.Right))
{
dividerValue += 0.01f;
}
else if (IsKeyDown(KeyboardKey.KEY_LEFT))
else if (IsKeyDown(KeyboardKey.Left))
{
dividerValue -= 0.01f;
}
@ -74,13 +74,13 @@ public class MultiSample2d
dividerValue = 1.0f;
}
Raylib.SetShaderValue(shader, dividerLoc, dividerValue, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, dividerLoc, dividerValue, ShaderUniformDataType.Float);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginShaderMode(shader);
@ -91,12 +91,12 @@ public class MultiSample2d
// We are drawing texRed using default sampler2D texture0 but
// an additional texture units is enabled for texBlue (sampler2D texture1)
DrawTexture(texRed, 0, 0, Color.WHITE);
DrawTexture(texRed, 0, 0, Color.White);
EndShaderMode();
int y = GetScreenHeight() - 40;
DrawText("Use KEY_LEFT/KEY_RIGHT to move texture mixing in shader!", 80, y, 20, Color.RAYWHITE);
DrawText("Use KEY_LEFT/KEY_RIGHT to move texture mixing in shader!", 80, y, 20, Color.RayWhite);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -99,11 +99,11 @@ public class PaletteSwitch
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.KEY_RIGHT))
if (IsKeyPressed(KeyboardKey.Right))
{
currentPalette++;
}
else if (IsKeyPressed(KeyboardKey.KEY_LEFT))
else if (IsKeyPressed(KeyboardKey.Left))
{
currentPalette--;
}
@ -123,7 +123,7 @@ public class PaletteSwitch
shader,
paletteLoc,
Palettes[currentPalette],
ShaderUniformDataType.SHADER_UNIFORM_IVEC3,
ShaderUniformDataType.IVec3,
ColorsPerPalette
);
//----------------------------------------------------------------------------------
@ -131,7 +131,7 @@ public class PaletteSwitch
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginShaderMode(shader);
@ -144,9 +144,9 @@ public class PaletteSwitch
EndShaderMode();
DrawText("< >", 10, 10, 30, Color.DARKBLUE);
DrawText("CURRENT PALETTE:", 60, 15, 20, Color.RAYWHITE);
DrawText(PaletteText[currentPalette], 300, 15, 20, Color.RED);
DrawText("< >", 10, 10, 30, Color.DarkBlue);
DrawText("CURRENT PALETTE:", 60, 15, 20, Color.RayWhite);
DrawText(PaletteText[currentPalette], 300, 15, 20, Color.Red);
DrawFPS(700, 15);

View File

@ -67,7 +67,7 @@ public class PostProcessing
const int screenHeight = 450;
// Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader");
// Define the camera to look into our 3d world
@ -76,13 +76,13 @@ public class PostProcessing
camera.Target = new Vector3(0.0f, 1.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Model model = LoadModel("resources/models/obj/church.obj");
Texture2D texture = LoadTexture("resources/models/obj/church_diffuse.png");
// Set model diffuse texture
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
Vector3 position = new(0.0f, 0.0f, 0.0f);
@ -119,13 +119,13 @@ public class PostProcessing
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
if (IsKeyPressed(KeyboardKey.KEY_RIGHT))
if (IsKeyPressed(KeyboardKey.Right))
{
currentShader++;
}
else if (IsKeyPressed(KeyboardKey.KEY_LEFT))
else if (IsKeyPressed(KeyboardKey.Left))
{
currentShader--;
}
@ -143,15 +143,15 @@ public class PostProcessing
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Enable drawing to texture
BeginTextureMode(target);
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawModel(model, position, 0.1f, Color.WHITE);
DrawModel(model, position, 0.1f, Color.White);
DrawGrid(10, 1.0f);
@ -168,18 +168,18 @@ public class PostProcessing
target.Texture,
new Rectangle(0, 0, target.Texture.Width, -target.Texture.Height),
new Vector2(0, 0),
Color.WHITE
Color.White
);
EndShaderMode();
DrawRectangle(0, 9, 580, 30, ColorAlpha(Color.LIGHTGRAY, 0.7f));
DrawRectangle(0, 9, 580, 30, ColorAlpha(Color.LightGray, 0.7f));
DrawText("(c) Church 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, Color.GRAY);
DrawText("(c) Church 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, Color.Gray);
DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, Color.BLACK);
DrawText(postproShaderText[currentShader], 330, 15, 20, Color.RED);
DrawText("< >", 540, 10, 30, Color.DARKBLUE);
DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, Color.Black);
DrawText(postproShaderText[currentShader], 330, 15, 20, Color.Red);
DrawText("< >", 540, 10, 30, Color.DarkBlue);
DrawFPS(700, 15);

View File

@ -33,7 +33,7 @@ public class Raymarching
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
SetConfigFlags(ResizableWindow);
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - raymarching shapes");
Camera3D camera = new();
@ -53,7 +53,7 @@ public class Raymarching
int resolutionLoc = GetShaderLocation(shader, "resolution");
float[] resolution = { (float)screenWidth, (float)screenHeight };
Raylib.SetShaderValue(shader, resolutionLoc, resolution, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, resolutionLoc, resolution, ShaderUniformDataType.Vec2);
float runTime = 0.0f;
@ -70,31 +70,31 @@ public class Raymarching
screenWidth = GetScreenWidth();
screenHeight = GetScreenHeight();
resolution = new float[] { (float)screenWidth, (float)screenHeight };
Raylib.SetShaderValue(shader, resolutionLoc, resolution, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, resolutionLoc, resolution, ShaderUniformDataType.Vec2);
}
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
float deltaTime = GetFrameTime();
runTime += deltaTime;
// Set shader required uniform values
Raylib.SetShaderValue(shader, viewEyeLoc, camera.Position, ShaderUniformDataType.SHADER_UNIFORM_VEC3);
Raylib.SetShaderValue(shader, viewCenterLoc, camera.Target, ShaderUniformDataType.SHADER_UNIFORM_VEC3);
Raylib.SetShaderValue(shader, runTimeLoc, runTime, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, viewEyeLoc, camera.Position, ShaderUniformDataType.Vec3);
Raylib.SetShaderValue(shader, viewCenterLoc, camera.Target, ShaderUniformDataType.Vec3);
Raylib.SetShaderValue(shader, runTimeLoc, runTime, ShaderUniformDataType.Float);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// We only draw a white full-screen rectangle,
// frame is generated in shader using raymarching
BeginShaderMode(shader);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.WHITE);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.White);
EndShaderMode();
DrawText(
@ -102,7 +102,7 @@ public class Raymarching
screenWidth - 280,
screenHeight - 20,
10,
Color.BLACK
Color.Black
);
EndDrawing();

View File

@ -54,54 +54,54 @@ public class ShapesTextures
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Start drawing with default shader
DrawText("USING DEFAULT SHADER", 20, 40, 10, Color.RED);
DrawText("USING DEFAULT SHADER", 20, 40, 10, Color.Red);
DrawCircle(80, 120, 35, Color.DARKBLUE);
DrawCircleGradient(80, 220, 60, Color.GREEN, Color.SKYBLUE);
DrawCircleLines(80, 340, 80, Color.DARKBLUE);
DrawCircle(80, 120, 35, Color.DarkBlue);
DrawCircleGradient(80, 220, 60, Color.Green, Color.SkyBlue);
DrawCircleLines(80, 340, 80, Color.DarkBlue);
// Activate our custom shader to be applied on next shapes/textures drawings
BeginShaderMode(shader);
DrawText("USING CUSTOM SHADER", 190, 40, 10, Color.RED);
DrawText("USING CUSTOM SHADER", 190, 40, 10, Color.Red);
DrawRectangle(250 - 60, 90, 120, 60, Color.RED);
DrawRectangleGradientH(250 - 90, 170, 180, 130, Color.MAROON, Color.GOLD);
DrawRectangleLines(250 - 40, 320, 80, 60, Color.ORANGE);
DrawRectangle(250 - 60, 90, 120, 60, Color.Red);
DrawRectangleGradientH(250 - 90, 170, 180, 130, Color.Maroon, Color.Gold);
DrawRectangleLines(250 - 40, 320, 80, 60, Color.Orange);
// Activate our default shader for next drawings
EndShaderMode();
DrawText("USING DEFAULT SHADER", 370, 40, 10, Color.RED);
DrawText("USING DEFAULT SHADER", 370, 40, 10, Color.Red);
DrawTriangle(
new Vector2(430, 80),
new Vector2(430 - 60, 150),
new Vector2(430 + 60, 150), Color.VIOLET
new Vector2(430 + 60, 150), Color.Violet
);
DrawTriangleLines(
new Vector2(430, 160),
new Vector2(430 - 20, 230),
new Vector2(430 + 20, 230), Color.DARKBLUE
new Vector2(430 + 20, 230), Color.DarkBlue
);
DrawPoly(new Vector2(430, 320), 6, 80, 0, Color.BROWN);
DrawPoly(new Vector2(430, 320), 6, 80, 0, Color.Brown);
// Activate our custom shader to be applied on next shapes/textures drawings
BeginShaderMode(shader);
// Using custom shader
DrawTexture(fudesumi, 500, -30, Color.WHITE);
DrawTexture(fudesumi, 500, -30, Color.White);
// Activate our default shader for next drawings
EndShaderMode();
DrawText("(c) Fudesumi sprite by Eiden Marsal", 380, screenHeight - 20, 10, Color.GRAY);
DrawText("(c) Fudesumi sprite by Eiden Marsal", 380, screenHeight - 20, 10, Color.Gray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -41,7 +41,7 @@ public class SimpleMask
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Define our three models to show the shader on
Mesh torus = GenMeshTorus(.3f, 1, 16, 32);
@ -62,11 +62,11 @@ public class SimpleMask
Material* materials = model1.Materials;
MaterialMap* maps = materials[0].Maps;
model1.Materials[0].Maps[(int)MaterialMapIndex.MATERIAL_MAP_ALBEDO].Texture = texDiffuse;
model1.Materials[0].Maps[(int)MaterialMapIndex.Albedo].Texture = texDiffuse;
materials = model2.Materials;
maps = materials[0].Maps;
maps[(int)MaterialMapIndex.MATERIAL_MAP_ALBEDO].Texture = texDiffuse;
maps[(int)MaterialMapIndex.Albedo].Texture = texDiffuse;
// Using MAP_EMISSION as a spare slot to use for 2nd texture
// NOTE: Don't use MAP_IRRADIANCE, MAP_PREFILTER or MAP_CUBEMAP
@ -75,14 +75,14 @@ public class SimpleMask
materials = model1.Materials;
maps = (MaterialMap*)materials[0].Maps;
maps[(int)MaterialMapIndex.MATERIAL_MAP_EMISSION].Texture = texMask;
maps[(int)MaterialMapIndex.Emission].Texture = texMask;
materials = model2.Materials;
maps = (MaterialMap*)materials[0].Maps;
maps[(int)MaterialMapIndex.MATERIAL_MAP_EMISSION].Texture = texMask;
maps[(int)MaterialMapIndex.Emission].Texture = texMask;
int* locs = shader.Locs;
locs[(int)ShaderLocationIndex.SHADER_LOC_MAP_EMISSION] = GetShaderLocation(shader, "mask");
locs[(int)ShaderLocationIndex.MapEmission] = GetShaderLocation(shader, "mask");
// Frame is incremented each frame to animate the shader
int shaderFrame = GetShaderLocation(shader, "framesCounter");
@ -113,31 +113,31 @@ public class SimpleMask
rotation.Z -= 0.0025f;
// Send frames counter to shader for animation
Raylib.SetShaderValue(shader, shaderFrame, framesCounter, ShaderUniformDataType.SHADER_UNIFORM_INT);
Raylib.SetShaderValue(shader, shaderFrame, framesCounter, ShaderUniformDataType.Int);
// Rotate one of the models
model1.Transform = MatrixRotateXYZ(rotation);
UpdateCamera(ref camera, CameraMode.CAMERA_CUSTOM);
UpdateCamera(ref camera, CameraMode.Custom);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.DARKBLUE);
ClearBackground(Color.DarkBlue);
BeginMode3D(camera);
DrawModel(model1, new Vector3(0.5f, 0, 0), 1, Color.WHITE);
DrawModelEx(model2, new Vector3(-.5f, 0, 0), new Vector3(1, 1, 0), 50, new Vector3(1, 1, 1), Color.WHITE);
DrawModel(model3, new Vector3(0, 0, -1.5f), 1, Color.WHITE);
DrawModel(model1, new Vector3(0.5f, 0, 0), 1, Color.White);
DrawModelEx(model2, new Vector3(-.5f, 0, 0), new Vector3(1, 1, 0), 50, new Vector3(1, 1, 1), Color.White);
DrawModel(model3, new Vector3(0, 0, -1.5f), 1, Color.White);
DrawGrid(10, 1.0f);
EndMode3D();
string frameText = $"Frame: {framesCounter}";
DrawRectangle(16, 698, MeasureText(frameText, 20) + 8, 42, Color.BLUE);
DrawText(frameText, 20, 700, 20, Color.WHITE);
DrawRectangle(16, 698, MeasureText(frameText, 20) + 8, 42, Color.Blue);
DrawText(frameText, 20, 700, 20, Color.White);
DrawFPS(10, 10);

View File

@ -111,7 +111,7 @@ public class Spotlight
// a pitch Color.black half and a dimly lit half.
int wLoc = GetShaderLocation(shdrSpot, "screenWidth");
float sw = (float)GetScreenWidth();
Raylib.SetShaderValue(shdrSpot, wLoc, sw, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shdrSpot, wLoc, sw, ShaderUniformDataType.Float);
// Randomise the locations and velocities of the spotlights
// and initialise the shader locations
@ -134,19 +134,19 @@ public class Spotlight
shdrSpot,
spots[i].posLoc,
spots[i].pos,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(
shdrSpot,
spots[i].innerLoc,
spots[i].inner,
ShaderUniformDataType.SHADER_UNIFORM_FLOAT
ShaderUniformDataType.Float
);
Raylib.SetShaderValue(
shdrSpot,
spots[i].radiusLoc,
spots[i].radius,
ShaderUniformDataType.SHADER_UNIFORM_FLOAT
ShaderUniformDataType.Float
);
}
@ -205,20 +205,20 @@ public class Spotlight
shdrSpot,
spots[i].posLoc,
spots[i].pos,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
}
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.DARKBLUE);
ClearBackground(Color.DarkBlue);
// Draw stars and bobs
for (int n = 0; n < MaxStars; n++)
{
// MathF.Single pixel is just too small these days!
DrawRectangle((int)stars[n].pos.X, (int)stars[n].pos.Y, 2, 2, Color.WHITE);
DrawRectangle((int)stars[n].pos.X, (int)stars[n].pos.Y, 2, 2, Color.White);
}
for (int i = 0; i < 16; i++)
@ -227,7 +227,7 @@ public class Spotlight
texRay,
(int)((screenWidth / 2.0) + MathF.Cos((frameCounter + i * 8) / 51.45f) * (screenWidth / 2.2) - 32),
(int)((screenHeight / 2.0) + MathF.Sin((frameCounter + i * 8) / 17.87f) * (screenHeight / 4.2)),
Color.WHITE
Color.White
);
}
@ -236,14 +236,14 @@ public class Spotlight
// Instead of a blank rectangle you could render a render texture of the full screen used to do screen
// scaling (slight adjustment to shader would be required to actually pay attention to the colour!)
DrawRectangle(0, 0, screenWidth, screenHeight, Color.WHITE);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.White);
EndShaderMode();
DrawFPS(10, 10);
DrawText("Move the mouse!", 10, 30, 20, Color.GREEN);
DrawText("Pitch Color.Black", (int)(screenWidth * 0.2f), screenHeight / 2, 20, Color.GREEN);
DrawText("Dark", (int)(screenWidth * 0.66f), screenHeight / 2, 20, Color.GREEN);
DrawText("Move the mouse!", 10, 30, 20, Color.Green);
DrawText("Pitch Color.Black", (int)(screenWidth * 0.2f), screenHeight / 2, 20, Color.Green);
DrawText("Dark", (int)(screenWidth * 0.66f), screenHeight / 2, 20, Color.Green);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ public class TextureDrawing
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture drawing");
// Load blank texture to fill on shader
Image imBlank = GenImageColor(1024, 1024, Color.BLANK);
Image imBlank = GenImageColor(1024, 1024, Color.Blank);
Texture2D texture = LoadTextureFromImage(imBlank);
UnloadImage(imBlank);
@ -40,7 +40,7 @@ public class TextureDrawing
float time = 0.0f;
int timeLoc = GetShaderLocation(shader, "uTime");
Raylib.SetShaderValue(shader, timeLoc, time, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, timeLoc, time, ShaderUniformDataType.Float);
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -51,24 +51,24 @@ public class TextureDrawing
// Update
//----------------------------------------------------------------------------------
time = (float)GetTime();
Raylib.SetShaderValue(shader, timeLoc, time, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, timeLoc, time, ShaderUniformDataType.Float);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Enable our custom shader for next shapes/textures drawings
BeginShaderMode(shader);
// Drawing blank texture, all magic happens on shader
DrawTexture(texture, 0, 0, Color.WHITE);
DrawTexture(texture, 0, 0, Color.White);
// Disable our custom shader, return to default shader
EndShaderMode();
DrawText("BACKGROUND is PAINTED and ANIMATED on SHADER!", 10, 10, 20, Color.MAROON);
DrawText("BACKGROUND is PAINTED and ANIMATED on SHADER!", 10, 10, 20, Color.Maroon);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -49,19 +49,19 @@ public class TextureOutline
shdrOutline,
outlineSizeLoc,
outlineSize,
ShaderUniformDataType.SHADER_UNIFORM_FLOAT
ShaderUniformDataType.Float
);
Raylib.SetShaderValue(
shdrOutline,
outlineColorLoc,
outlineColor,
ShaderUniformDataType.SHADER_UNIFORM_VEC4
ShaderUniformDataType.Vec4
);
Raylib.SetShaderValue(
shdrOutline,
textureSizeLoc,
textureSize,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
SetTargetFPS(60);
@ -82,7 +82,7 @@ public class TextureOutline
shdrOutline,
outlineSizeLoc,
outlineSize,
ShaderUniformDataType.SHADER_UNIFORM_FLOAT
ShaderUniformDataType.Float
);
//----------------------------------------------------------------------------------
@ -90,15 +90,15 @@ public class TextureOutline
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginShaderMode(shdrOutline);
DrawTexture(texture, GetScreenWidth() / 2 - texture.Width / 2, -30, Color.WHITE);
DrawTexture(texture, GetScreenWidth() / 2 - texture.Width / 2, -30, Color.White);
EndShaderMode();
DrawText("Shader-based\ntexture\noutline", 10, 10, 20, Color.GRAY);
DrawText("Shader-based\ntexture\noutline", 10, 10, 20, Color.Gray);
DrawText($"Outline size: {outlineSize} px", 10, 120, 20, Color.MAROON);
DrawText($"Outline size: {outlineSize} px", 10, 120, 20, Color.Maroon);
DrawFPS(710, 10);

View File

@ -62,14 +62,14 @@ public class TextureWaves
shader,
GetShaderLocation(shader, "size"),
screenSize,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(shader, freqXLoc, freqX, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, freqYLoc, freqY, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, ampXLoc, ampX, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, ampYLoc, ampY, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, speedXLoc, speedX, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, speedYLoc, speedY, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, freqXLoc, freqX, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, freqYLoc, freqY, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, ampXLoc, ampX, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, ampYLoc, ampY, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, speedXLoc, speedX, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, speedYLoc, speedY, ShaderUniformDataType.Float);
float seconds = 0.0f;
@ -83,18 +83,18 @@ public class TextureWaves
//----------------------------------------------------------------------------------
seconds += GetFrameTime();
Raylib.SetShaderValue(shader, secondsLoc, seconds, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, secondsLoc, seconds, ShaderUniformDataType.Float);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginShaderMode(shader);
DrawTexture(texture, 0, 0, Color.WHITE);
DrawTexture(texture, texture.Width, 0, Color.WHITE);
DrawTexture(texture, 0, 0, Color.White);
DrawTexture(texture, texture.Width, 0, Color.White);
EndShaderMode();

View File

@ -43,27 +43,27 @@ public class WriteDepth
camera.Target = new Vector3(0.0f, 0.5f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
// Draw into our custom render texture (framebuffer)
BeginTextureMode(target);
ClearBackground(Color.WHITE);
ClearBackground(Color.White);
BeginMode3D(camera);
BeginShaderMode(shader);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.RED);
DrawCubeV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.PURPLE);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.DARKGREEN);
DrawCubeV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.YELLOW);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.Red);
DrawCubeV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.Purple);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.DarkGreen);
DrawCubeV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.Yellow);
DrawGrid(10, 1.0f);
EndShaderMode();
@ -72,13 +72,13 @@ public class WriteDepth
// Draw custom render texture
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawTextureRec(
target.Texture,
new Rectangle(0, 0, screenWidth, -screenHeight),
Vector2.Zero,
Color.WHITE
Color.White
);
DrawFPS(10, 10);
@ -113,48 +113,48 @@ public class WriteDepth
null,
width,
height,
PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
PixelFormat.UncompressedR8G8B8A8,
1
);
target.Texture.Width = width;
target.Texture.Height = height;
target.Texture.Format = PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
target.Texture.Format = PixelFormat.UncompressedR8G8B8A8;
target.Texture.Mipmaps = 1;
// Create depth texture buffer (instead of raylib default renderbuffer)
target.Depth.Id = Rlgl.LoadTextureDepth(width, height, false);
target.Depth.Width = width;
target.Depth.Height = height;
target.Depth.Format = PixelFormat.PIXELFORMAT_COMPRESSED_PVRT_RGBA;
target.Depth.Format = PixelFormat.CompressedPvrtRgba;
target.Depth.Mipmaps = 1;
// Attach color texture and depth texture to FBO
Rlgl.FramebufferAttach(
target.Id,
target.Texture.Id,
FramebufferAttachType.RL_ATTACHMENT_COLOR_CHANNEL0,
FramebufferAttachTextureType.RL_ATTACHMENT_TEXTURE2D,
FramebufferAttachType.ColorChannel0,
FramebufferAttachTextureType.Texture2D,
0
);
Rlgl.FramebufferAttach(
target.Id,
target.Depth.Id,
FramebufferAttachType.RL_ATTACHMENT_DEPTH,
FramebufferAttachTextureType.RL_ATTACHMENT_TEXTURE2D,
FramebufferAttachType.Depth,
FramebufferAttachTextureType.Texture2D,
0
);
// Check if fbo is complete with attachments (valid)
if (Rlgl.FramebufferComplete(target.Id))
{
TraceLog(TraceLogLevel.LOG_INFO, $"FBO: [ID {target.Id}] Framebuffer object created successfully");
TraceLog(TraceLogLevel.Info, $"FBO: [ID {target.Id}] Framebuffer object created successfully");
}
Rlgl.DisableFramebuffer();
}
else
{
TraceLog(TraceLogLevel.LOG_WARNING, "FBO: Framebuffer object can not be created");
TraceLog(TraceLogLevel.Warning, "FBO: Framebuffer object can not be created");
}
return target;