mirror of
https://github.com/Not-Nik/raylib-zig.git
synced 2025-09-09 03:57:29 +00:00
Texture member functions
This commit is contained in:
parent
8a2cd7dce2
commit
2578dceb42
@ -53,7 +53,7 @@ pub fn main() anyerror!void {
|
||||
|
||||
rl.beginShaderMode(shdrOutline);
|
||||
|
||||
rl.drawTexture(texture, @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.endShaderMode();
|
||||
|
||||
|
@ -79,7 +79,7 @@ pub fn main() anyerror!void {
|
||||
rl.drawRectangleLines(250 + 21 * @intCast(c_int, i), 205, 20, 20, rl.Color.maroon);
|
||||
}
|
||||
|
||||
rl.drawTextureRec(scarfy, frameRec, position, rl.Color.white); // Draw part of the texture
|
||||
scarfy.drawRec(frameRec, position, rl.Color.white); // Draw part of the texture
|
||||
|
||||
rl.drawText("(c) Scarfy sprite by Eiden Marsal", screenWidth - 200, screenHeight - 20, 10, rl.Color.gray);
|
||||
|
||||
|
@ -96,6 +96,10 @@ pub const Rectangle = extern struct {
|
||||
y: f32,
|
||||
width: f32,
|
||||
height: f32,
|
||||
|
||||
pub fn init(x: f32, y: f32, width: f32, height: f32) Rectangle {
|
||||
return Rectangle{ .x = x, .y = y, .width = width, .height = height };
|
||||
}
|
||||
};
|
||||
|
||||
pub const Image = extern struct {
|
||||
@ -168,6 +172,42 @@ pub const Texture = extern struct {
|
||||
height: c_int,
|
||||
mipmaps: c_int,
|
||||
format: c_int,
|
||||
|
||||
pub fn init(fileName: [*c]const u8) Texture {
|
||||
return rl.loadTexture(fileName);
|
||||
}
|
||||
|
||||
pub fn fromImage(image: Image) Texture {
|
||||
return rl.loadTextureFromImage(image);
|
||||
}
|
||||
|
||||
pub fn fromCubemap(image: Image, layout: i32) Texture {
|
||||
return rl.loadTextureCubemap(image, layout);
|
||||
}
|
||||
|
||||
pub fn draw(self: Texture, posX: i32, posY: i32, tint: Color) void {
|
||||
rl.drawTexture(self, posX, posY, tint);
|
||||
}
|
||||
|
||||
pub fn drawV(self: Texture, position: Vector2, tint: Color) void {
|
||||
rl.drawTextureV(self, position, tint);
|
||||
}
|
||||
|
||||
pub fn drawEx(self: Texture, position: Vector2, rotation: f32, scale: f32, tint: Color) void {
|
||||
rl.drawTextureEx(self, position, rotation, scale, tint);
|
||||
}
|
||||
|
||||
pub fn drawRec(self: Texture, source: Rectangle, position: Vector2, tint: Color) void {
|
||||
rl.drawTextureRec(self, source, position, tint);
|
||||
}
|
||||
|
||||
pub fn drawPro(self: Texture, source: Rectangle, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) void {
|
||||
rl.drawTexturePro(self, source, dest, origin, rotation, tint);
|
||||
}
|
||||
|
||||
pub fn drawNPatch(self: Texture, nPatchInfo: NPatchInfo, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) void {
|
||||
rl.drawTextureNPatch(self, nPatchInfo, dest, origin, rotation, tint);
|
||||
}
|
||||
};
|
||||
pub const Texture2D = Texture;
|
||||
pub const TextureCubemap = Texture;
|
||||
@ -177,6 +217,10 @@ pub const RenderTexture = extern struct {
|
||||
texture: Texture,
|
||||
depth: Texture,
|
||||
|
||||
pub fn init(width: i32, height: i32) RenderTexture {
|
||||
return rl.loadRenderTexture(width, height);
|
||||
}
|
||||
|
||||
pub fn begin(self: RenderTexture2D) void {
|
||||
rl.beginTextureMode(self);
|
||||
}
|
||||
|
@ -96,6 +96,10 @@ pub const Rectangle = extern struct {
|
||||
y: f32,
|
||||
width: f32,
|
||||
height: f32,
|
||||
|
||||
pub fn init(x: f32, y: f32, width: f32, height: f32) Rectangle {
|
||||
return Rectangle{ .x = x, .y = y, .width = width, .height = height };
|
||||
}
|
||||
};
|
||||
|
||||
pub const Image = extern struct {
|
||||
@ -168,6 +172,42 @@ pub const Texture = extern struct {
|
||||
height: c_int,
|
||||
mipmaps: c_int,
|
||||
format: c_int,
|
||||
|
||||
pub fn init(fileName: [*c]const u8) Texture {
|
||||
return rl.loadTexture(fileName);
|
||||
}
|
||||
|
||||
pub fn fromImage(image: Image) Texture {
|
||||
return rl.loadTextureFromImage(image);
|
||||
}
|
||||
|
||||
pub fn fromCubemap(image: Image, layout: i32) Texture {
|
||||
return rl.loadTextureCubemap(image, layout);
|
||||
}
|
||||
|
||||
pub fn draw(self: Texture, posX: i32, posY: i32, tint: Color) void {
|
||||
rl.drawTexture(self, posX, posY, tint);
|
||||
}
|
||||
|
||||
pub fn drawV(self: Texture, position: Vector2, tint: Color) void {
|
||||
rl.drawTextureV(self, position, tint);
|
||||
}
|
||||
|
||||
pub fn drawEx(self: Texture, position: Vector2, rotation: f32, scale: f32, tint: Color) void {
|
||||
rl.drawTextureEx(self, position, rotation, scale, tint);
|
||||
}
|
||||
|
||||
pub fn drawRec(self: Texture, source: Rectangle, position: Vector2, tint: Color) void {
|
||||
rl.drawTextureRec(self, source, position, tint);
|
||||
}
|
||||
|
||||
pub fn drawPro(self: Texture, source: Rectangle, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) void {
|
||||
rl.drawTexturePro(self, source, dest, origin, rotation, tint);
|
||||
}
|
||||
|
||||
pub fn drawNPatch(self: Texture, nPatchInfo: NPatchInfo, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) void {
|
||||
rl.drawTextureNPatch(self, nPatchInfo, dest, origin, rotation, tint);
|
||||
}
|
||||
};
|
||||
pub const Texture2D = Texture;
|
||||
pub const TextureCubemap = Texture;
|
||||
@ -177,6 +217,10 @@ pub const RenderTexture = extern struct {
|
||||
texture: Texture,
|
||||
depth: Texture,
|
||||
|
||||
pub fn init(width: i32, height: i32) RenderTexture {
|
||||
return rl.loadRenderTexture(width, height);
|
||||
}
|
||||
|
||||
pub fn begin(self: RenderTexture2D) void {
|
||||
rl.beginTextureMode(self);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user