mirror of
https://github.com/Not-Nik/raylib-zig.git
synced 2025-09-09 12:07:27 +00:00
Fixup for rl 3.7
This commit is contained in:
parent
a8d8d4b9bc
commit
004388133b
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -243,7 +243,7 @@ pub extern fn ImageAlphaClear(image: [*c]const Image, color: Color, threshold: f
|
||||
pub extern fn ImageAlphaMask(image: [*c]const Image, alphaMask: Image) void;
|
||||
pub extern fn ImageAlphaPremultiply(image: [*c]const Image) void;
|
||||
pub extern fn ImageResize(image: [*c]const Image, newWidth: c_int, newHeight: c_int) void;
|
||||
pub extern fn ImageResizeNN(image: [*c]const Image, newHeight: int newWidth,int) void;
|
||||
pub extern fn ImageResizeNN(image: [*c]const Image, newWidth: c_int, newHeight: c_int) void;
|
||||
pub extern fn ImageResizeCanvas(image: [*c]const Image, newWidth: c_int, newHeight: c_int, offsetX: c_int, offsetY: c_int, fill: Color) void;
|
||||
pub extern fn ImageMipmaps(image: [*c]const Image) void;
|
||||
pub extern fn ImageDither(image: [*c]const Image, rBpp: c_int, gBpp: c_int, bBpp: c_int, aBpp: c_int) void;
|
||||
@ -384,7 +384,7 @@ pub extern fn SetModelMeshMaterial(model: [*c]const Model, meshId: c_int, materi
|
||||
pub extern fn LoadModelAnimations(fileName: [*c]const u8, animsCount: [*c]const c_int) [*c]const ModelAnimation;
|
||||
pub extern fn UpdateModelAnimation(model: Model, anim: ModelAnimation, frame: c_int) void;
|
||||
pub extern fn UnloadModelAnimation(anim: ModelAnimation) void;
|
||||
pub extern fn UnloadModelAnimations(animations: ModelAnimation*, count: c_uint) void;
|
||||
pub extern fn UnloadModelAnimations(animations: [*c]const ModelAnimation, count: c_uint) void;
|
||||
pub extern fn IsModelAnimationValid(model: Model, anim: ModelAnimation) bool;
|
||||
pub extern fn GenMeshPoly(sides: c_int, radius: f32) Mesh;
|
||||
pub extern fn GenMeshPlane(width: f32, length: f32, resX: c_int, resZ: c_int) Mesh;
|
||||
@ -445,7 +445,7 @@ pub extern fn WaveCrop(wave: [*c]const Wave, initSample: c_int, finalSample: c_i
|
||||
pub extern fn LoadWaveSamples(wave: Wave) [*c]const f32;
|
||||
pub extern fn UnloadWaveSamples(samples: [*c]const f32) void;
|
||||
pub extern fn LoadMusicStream(fileName: [*c]const u8) Music;
|
||||
pub extern fn LoadMusicStreamFromMemory(fileType: [*c]const u8, data: unsigned char*, dataSize: c_int) Music;
|
||||
pub extern fn LoadMusicStreamFromMemory(fileType: [*c]const u8, data: [*c]const u8, dataSize: c_int) Music;
|
||||
pub extern fn UnloadMusicStream(music: Music) void;
|
||||
pub extern fn PlayMusicStream(music: Music) void;
|
||||
pub extern fn IsMusicPlaying(music: Music) bool;
|
||||
|
@ -226,7 +226,7 @@ pub const Camera3D = extern struct {
|
||||
target: Vector3,
|
||||
up: Vector3,
|
||||
fovy: f32,
|
||||
projection: c_int,
|
||||
projection: CameraProjection,
|
||||
|
||||
pub fn Begin(self: Camera3D) void {
|
||||
BeginMode3D(self);
|
||||
@ -541,7 +541,7 @@ pub const KeyboardKey = enum(c_int) {
|
||||
KEY_KP_ENTER = 335,
|
||||
KEY_KP_EQUAL = 336,
|
||||
KEY_BACK = 4,
|
||||
KEY_MENU = 82,
|
||||
//KEY_MENU = 82,
|
||||
KEY_VOLUME_UP = 24,
|
||||
KEY_VOLUME_DOWN = 25,
|
||||
};
|
||||
@ -772,10 +772,9 @@ pub const FILTER_POINT = TEXTURE_FILTER_POINT;
|
||||
pub const FILTER_BILINEAR = TEXTURE_FILTER_BILINEAR;
|
||||
pub const MAP_DIFFUSE = MATERIAL_MAP_DIFFUSE;
|
||||
pub const PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 = PIXELFORMAT_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
|
||||
pub const SpriteFont = Font;
|
||||
|
||||
pub const MATERIAL_MAP_DIFFUSE = MATERIAL_MAP_ALBEDO;
|
||||
pub const MATERIAL_MAP_SPECULAR = MATERIAL_MAP_METALNESS;
|
||||
pub const MATERIAL_MAP_DIFFUSE = MaterialMapIndex.MATERIAL_MAP_ALBEDO;
|
||||
pub const MATERIAL_MAP_SPECULAR = MaterialMapIndex.MATERIAL_MAP_METALNESS;
|
||||
pub const SHADER_LOC_MAP_DIFFUSE = SHADER_LOC_MAP_ALBEDO;
|
||||
pub const SHADER_LOC_MAP_SPECULAR = SHADER_LOC_MAP_METALNESS;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user