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

@ -28,7 +28,7 @@ pub fn main() anyerror!void {
var model = LoadModel(resourceDir ++ "models/castle.obj"); // Load model
var texture = LoadTexture(resourceDir ++ "models/castle_diffuse.png"); // Load model texture
model.materials[0].maps[@enumToInt(MAP_DIFFUSE)].texture = texture; // Set map diffuse texture
model.materials[0].maps[@intFromEnum(MAP_DIFFUSE)].texture = texture; // Set map diffuse texture
var position = Vector3{ .x = 0.0, .y = 0.0, .z = 0.0 }; // Set model position
@ -64,7 +64,8 @@ pub fn main() anyerror!void {
{
UnloadModel(model); // Unload previous model
model = LoadModel(droppedFiles[0]); // Load new model
model.materials[0].maps[@enumToInt(MAP_DIFFUSE)].texture = texture; // Set current map diffuse texture
// Set current map diffuse texture
model.materials[0].maps[@intFromEnum(MAP_DIFFUSE)].texture = texture;
bounds = MeshBoundingBox(model.meshes[0]);
@ -74,7 +75,7 @@ pub fn main() anyerror!void {
// Unload current model texture and load new one
UnloadTexture(texture);
texture = LoadTexture(droppedFiles[0]);
model.materials[0].maps[@enumToInt(MAP_DIFFUSE)].texture = texture;
model.materials[0].maps[@intFromEnum(MAP_DIFFUSE)].texture = texture;
}
}

View file

@ -44,9 +44,9 @@ pub fn main() !void {
const texture = LoadTexture(resourceDir ++ "texel_checker.png");
// Assign texture to default model material
modelA.materials[0].maps[@enumToInt(MAP_DIFFUSE)].texture = texture;
modelB.materials[0].maps[@enumToInt(MAP_DIFFUSE)].texture = texture;
modelC.materials[0].maps[@enumToInt(MAP_DIFFUSE)].texture = texture;
modelA.materials[0].maps[@intFromEnum(MAP_DIFFUSE)].texture = texture;
modelB.materials[0].maps[@intFromEnum(MAP_DIFFUSE)].texture = texture;
modelC.materials[0].maps[@intFromEnum(MAP_DIFFUSE)].texture = texture;
var shader = LoadShader(
resourceDir ++ "/shaders/glsl330/base_lighting.vs",
@ -54,13 +54,13 @@ pub fn main() !void {
);
// Get some shader loactions
shader.locs[@enumToInt(ShaderLocationIndex.SHADER_LOC_MATRIX_MODEL)] = GetShaderLocation(shader, "matModel");
shader.locs[@enumToInt(ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW)] = GetShaderLocation(shader, "viewPos");
shader.locs[@intFromEnum(ShaderLocationIndex.SHADER_LOC_MATRIX_MODEL)] = GetShaderLocation(shader, "matModel");
shader.locs[@intFromEnum(ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW)] = GetShaderLocation(shader, "viewPos");
// ambient light level
const ambientLoc = GetShaderLocation(shader, "ambient");
const ambientVals = [4]f32{ 0.2, 0.2, 0.2, 1.0 };
SetShaderValue(shader, ambientLoc, &ambientVals, @enumToInt(ShaderUniformDataType.SHADER_UNIFORM_VEC4));
SetShaderValue(shader, ambientLoc, &ambientVals, @intFromEnum(ShaderUniformDataType.SHADER_UNIFORM_VEC4));
var angle: f32 = 6.282;
@ -126,7 +126,12 @@ pub fn main() !void {
// Update the light shader with the camera view position
const cameraPos = [3]f32{ camera.position.x, camera.position.y, camera.position.z };
SetShaderValue(shader, shader.locs[@enumToInt(ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW)], &cameraPos, @enumToInt(ShaderUniformDataType.SHADER_UNIFORM_VEC3));
SetShaderValue(
shader,
shader.locs[@intFromEnum(ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW)],
&cameraPos,
@intFromEnum(ShaderUniformDataType.SHADER_UNIFORM_VEC3),
);
//----------------------------------------------------------------------------------
// Draw