Fixup for rl 3.7

This commit is contained in:
Not-Nik 2021-11-28 14:07:22 +01:00
parent a8d8d4b9bc
commit 004388133b
Failed to generate hash of commit
7 changed files with 23 additions and 24 deletions

View file

@ -69,7 +69,7 @@ pub fn main() anyerror!void
camera.rotation = Clamp(camera.rotation, -40, 40);
// Camera zoom controls
camera.zoom += @intToFloat(f32, GetMouseWheelMove() * @floatToInt(c_int, 0.05));
camera.zoom += GetMouseWheelMove() * 0.05;
camera.zoom = Clamp(camera.zoom, 0.1, 3.0);

View file

@ -16,8 +16,8 @@ pub fn main() anyerror!void
InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window");
var boxPositionY: i32 = screenHeight / 2 - 40;
var scrollSpeed: i32 = 4; // Scrolling speed in pixels
var boxPositionY: f32 = screenHeight / 2 - 40;
var scrollSpeed: f32 = 4; // Scrolling speed in pixels
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -36,10 +36,10 @@ pub fn main() anyerror!void
ClearBackground(WHITE);
DrawRectangle(screenWidth/2 - 40, boxPositionY, 80, 80, MAROON);
DrawRectangle(screenWidth/2 - 40, @floatToInt(c_int, boxPositionY), 80, 80, MAROON);
DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, GRAY);
DrawText(FormatText("Box position Y: %03i", boxPositionY), 10, 40, 20, LIGHTGRAY);
DrawText(FormatText("Box position Y: %03i", @floatToInt(c_int, boxPositionY)), 10, 40, 20, LIGHTGRAY);
EndDrawing();
//----------------------------------------------------------------------------------

View file

@ -23,7 +23,7 @@ pub fn main() anyerror!void {
.target = Vector3{ .x = 0.0, .y = 10.0, .z = 0.0 }, // Camera looking at point
.up = Vector3{ .x = 0.0, .y = 1.0, .z = 0.0 }, // Camera up vector (rotation towards target)
.fovy = 45.0, // Camera field-of-view Y
.type = CameraType.CAMERA_PERSPECTIVE, // Camera mode type
.projection = CameraProjection.CAMERA_PERSPECTIVE, // Camera mode type
};
var model = LoadModel(resourceDir ++ "models/castle.obj"); // Load model

View file

@ -104,16 +104,16 @@ pub fn CreateLight(typ: LightType, position: Vector3, target: Vector3, color: Co
// NOTE: Light shader locations should be available
pub fn UpdateLightValues(shader: Shader, light: Light) void {
// Send to shader light enabled state and type
SetShaderValue(shader, light.enabledLoc, &light.enabled, @enumToInt(ShaderUniformDataType.UNIFORM_INT));
SetShaderValue(shader, light.typeLoc, &light.type, @enumToInt(ShaderUniformDataType.UNIFORM_INT));
SetShaderValue(shader, light.enabledLoc, &light.enabled, @enumToInt(ShaderUniformDataType.SHADER_UNIFORM_INT));
SetShaderValue(shader, light.typeLoc, &light.type, @enumToInt(ShaderUniformDataType.SHADER_UNIFORM_INT));
// Send to shader light position values
const position = [3]f32{ light.position.x, light.position.y, light.position.z };
SetShaderValue(shader, light.posLoc, &position, @enumToInt(ShaderUniformDataType.UNIFORM_VEC3));
SetShaderValue(shader, light.posLoc, &position, @enumToInt(ShaderUniformDataType.SHADER_UNIFORM_VEC3));
// Send to shader light target position values
const target = [3]f32{ light.target.x, light.target.y, light.target.z };
SetShaderValue(shader, light.targetLoc, &target, @enumToInt(ShaderUniformDataType.UNIFORM_VEC3));
SetShaderValue(shader, light.targetLoc, &target, @enumToInt(ShaderUniformDataType.SHADER_UNIFORM_VEC3));
// Send to shader light color values
const color = [4]f32{
@ -122,5 +122,5 @@ pub fn UpdateLightValues(shader: Shader, light: Light) void {
@intToFloat(f32, light.color.b) / 255.0,
@intToFloat(f32, light.color.a) / 255.0,
};
SetShaderValue(shader, light.colorLoc, &color, @enumToInt(ShaderUniformDataType.UNIFORM_VEC4));
SetShaderValue(shader, light.colorLoc, &color, @enumToInt(ShaderUniformDataType.SHADER_UNIFORM_VEC4));
}

View file

@ -32,7 +32,7 @@ pub fn main() !void {
.target = .{ .x = 0.0, .y = 0.5, .z = 0.0 }, // Camera looking at point
.up = .{ .x = 0.0, .y = 1.0, .z = 0.0 }, // Camera up vector (rotation towards target)
.fovy = 45.0, // Camera field-of-view Y
.type = CameraType.CAMERA_PERSPECTIVE, // Camera mode type
.projection = CameraProjection.CAMERA_PERSPECTIVE, // Camera mode type
};
// Load models
@ -54,13 +54,13 @@ pub fn main() !void {
);
// Get some shader loactions
shader.locs[@enumToInt(ShaderLocationIndex.LOC_MATRIX_MODEL)] = GetShaderLocation(shader, "matModel");
shader.locs[@enumToInt(ShaderLocationIndex.LOC_VECTOR_VIEW)] = GetShaderLocation(shader, "viewPos");
shader.locs[@enumToInt(ShaderLocationIndex.SHADER_LOC_MATRIX_MODEL)] = GetShaderLocation(shader, "matModel");
shader.locs[@enumToInt(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.UNIFORM_VEC4));
SetShaderValue(shader, ambientLoc, &ambientVals, @enumToInt(ShaderUniformDataType.SHADER_UNIFORM_VEC4));
var angle: f32 = 6.282;
@ -126,7 +126,7 @@ 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.LOC_VECTOR_VIEW)], &cameraPos, @enumToInt(ShaderUniformDataType.UNIFORM_VEC3));
SetShaderValue(shader, shader.locs[@enumToInt(ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW)], &cameraPos, @enumToInt(ShaderUniformDataType.SHADER_UNIFORM_VEC3));
//----------------------------------------------------------------------------------
// Draw