Clean up build.zig and examples

This commit affects the build.zig and examples files. It reformats the
code to meet a 120 column limit. It also adjusts comments so that
there is a space after the comment symbol '//' and the grammar in the
comments has been fixed.
This commit is contained in:
vent 2023-09-11 16:04:32 +01:00
parent 4dbbea186e
commit a378960088
9 changed files with 219 additions and 71 deletions

View file

@ -23,7 +23,10 @@ pub fn main() anyerror!void {
var outlineSize: f32 = 2.0;
const outlineColor = [4]f32{ 1.0, 0.0, 0.0, 1.0 }; // Normalized RED color
const textureSize = rl.Vector2.init(@as(f32, @floatFromInt(texture.width)), @as(f32, @floatFromInt(texture.height)));
const textureSize = rl.Vector2.init(
@as(f32, @floatFromInt(texture.width)),
@as(f32, @floatFromInt(texture.height)),
);
// Get shader locations
const outlineSizeLoc = rl.getShaderLocation(shdrOutline, "outlineSize");
@ -31,9 +34,24 @@ pub fn main() anyerror!void {
const textureSizeLoc = rl.getShaderLocation(shdrOutline, "textureSize");
// Set shader values (they can be changed later)
rl.setShaderValue(shdrOutline, outlineSizeLoc, &outlineSize, @intFromEnum(rl.ShaderUniformDataType.shader_uniform_float));
rl.setShaderValue(shdrOutline, outlineColorLoc, &outlineColor, @intFromEnum(rl.ShaderUniformDataType.shader_uniform_vec4));
rl.setShaderValue(shdrOutline, textureSizeLoc, &textureSize, @intFromEnum(rl.ShaderUniformDataType.shader_uniform_vec2));
rl.setShaderValue(
shdrOutline,
outlineSizeLoc,
&outlineSize,
@intFromEnum(rl.ShaderUniformDataType.shader_uniform_float),
);
rl.setShaderValue(
shdrOutline,
outlineColorLoc,
&outlineColor,
@intFromEnum(rl.ShaderUniformDataType.shader_uniform_vec4),
);
rl.setShaderValue(
shdrOutline,
textureSizeLoc,
&textureSize,
@intFromEnum(rl.ShaderUniformDataType.shader_uniform_vec2),
);
rl.setTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -45,7 +63,12 @@ pub fn main() anyerror!void {
outlineSize += rl.getMouseWheelMove();
if (outlineSize < 1.0) outlineSize = 1.0;
rl.setShaderValue(shdrOutline, outlineSizeLoc, &outlineSize, @intFromEnum(rl.ShaderUniformDataType.shader_uniform_float));
rl.setShaderValue(
shdrOutline,
outlineSizeLoc,
&outlineSize,
@intFromEnum(rl.ShaderUniformDataType.shader_uniform_float),
);
//----------------------------------------------------------------------------------
// Draw
@ -59,12 +82,22 @@ pub fn main() anyerror!void {
rl.beginShaderMode(shdrOutline);
defer rl.endShaderMode();
texture.draw(@divFloor(rl.getScreenWidth(), 2) - @divFloor(texture.width, 2), -30, rl.Color.white);
texture.draw(
@divFloor(rl.getScreenWidth(), 2) - @divFloor(texture.width, 2),
-30,
rl.Color.white,
);
}
rl.drawText("Shader-based\ntexture\noutline", 10, 10, 20, rl.Color.gray);
rl.drawText(rl.textFormat("Outline size: %i px", .{@as(i32, @intFromFloat(outlineSize))}), 10, 120, 20, rl.Color.maroon);
rl.drawText(
rl.textFormat("Outline size: %i px", .{@as(i32, @intFromFloat(outlineSize))}),
10,
120,
20,
rl.Color.maroon,
);
rl.drawFPS(710, 10);
//----------------------------------------------------------------------------------