improve game icon
This commit is contained in:
parent
f4fa4159c9
commit
fe54b39afd
4 changed files with 10 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,6 +9,7 @@ zig-out/
|
||||||
/docgen_tmp/
|
/docgen_tmp/
|
||||||
|
|
||||||
# Temporary project-specific things
|
# Temporary project-specific things
|
||||||
|
qgl/
|
||||||
vsh/
|
vsh/
|
||||||
dumped/
|
dumped/
|
||||||
menu/
|
menu/
|
||||||
|
|
BIN
icon-normal-3.png
Normal file
BIN
icon-normal-3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
13
src/main.zig
13
src/main.zig
|
@ -21,8 +21,7 @@ pub fn main() !void {
|
||||||
defer crossmenu.deinit();
|
defer crossmenu.deinit();
|
||||||
|
|
||||||
const game_column = try crossmenu.appendColumn(.{
|
const game_column = try crossmenu.appendColumn(.{
|
||||||
.icon = raylib.LoadTexture("icon-mask.png"),
|
.icon = raylib.LoadTexture("icon-normal-3.png"),
|
||||||
.normal = raylib.LoadTexture("icon-normal-2.png"),
|
|
||||||
.title = "Game",
|
.title = "Game",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -273,18 +272,18 @@ pub const Column = struct {
|
||||||
|
|
||||||
pub const Options = struct {
|
pub const Options = struct {
|
||||||
icon: raylib.Texture2D,
|
icon: raylib.Texture2D,
|
||||||
normal: ?raylib.Texture2D = null,
|
|
||||||
title: []const u8,
|
title: []const u8,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn init(allocator: Allocator, options: Options) Column {
|
pub fn init(allocator: Allocator, options: Options) Column {
|
||||||
raylib.SetTextureFilter(options.icon, raylib.TEXTURE_FILTER_BILINEAR);
|
raylib.SetTextureFilter(options.icon, raylib.TEXTURE_FILTER_BILINEAR);
|
||||||
|
raylib.SetTextureWrap(options.icon, raylib.TEXTURE_WRAP_CLAMP);
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
.items = .init(allocator),
|
.items = .init(allocator),
|
||||||
.icon = .{
|
.icon = .{
|
||||||
.texture = options.icon,
|
.texture = options.icon,
|
||||||
.normal = options.normal,
|
.is_normal_map = true,
|
||||||
},
|
},
|
||||||
.title = .{
|
.title = .{
|
||||||
.string = options.title,
|
.string = options.title,
|
||||||
|
@ -627,7 +626,8 @@ pub const BoundingBox = struct {
|
||||||
pub const Image = struct {
|
pub const Image = struct {
|
||||||
box: BoundingBox = undefined,
|
box: BoundingBox = undefined,
|
||||||
texture: raylib.Texture2D,
|
texture: raylib.Texture2D,
|
||||||
normal: ?raylib.Texture2D = null,
|
// normal: ?raylib.Texture2D = null,
|
||||||
|
is_normal_map: bool = false,
|
||||||
|
|
||||||
mode: Mode = .fit,
|
mode: Mode = .fit,
|
||||||
align_h: Align = .center,
|
align_h: Align = .center,
|
||||||
|
@ -664,8 +664,7 @@ pub const Image = struct {
|
||||||
raylib.MAROON,
|
raylib.MAROON,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (self.normal) |n| {
|
if (self.is_normal_map) {
|
||||||
raylib.SetShaderValueTexture(icon_shader, raylib.GetShaderLocation(icon_shader, "textureNormal"), n);
|
|
||||||
raylib.BeginShaderMode(icon_shader);
|
raylib.BeginShaderMode(icon_shader);
|
||||||
defer raylib.EndShaderMode();
|
defer raylib.EndShaderMode();
|
||||||
raylib.DrawTextureEx(self.texture, position, 0, scale, raylib.WHITE);
|
raylib.DrawTextureEx(self.texture, position, 0, scale, raylib.WHITE);
|
||||||
|
|
|
@ -4,7 +4,7 @@ in vec2 fragTexCoord;
|
||||||
in vec4 fragColor;
|
in vec4 fragColor;
|
||||||
|
|
||||||
uniform sampler2D texture0;
|
uniform sampler2D texture0;
|
||||||
uniform sampler2D textureNormal;
|
// uniform sampler2D textureNormal;
|
||||||
|
|
||||||
uniform vec3 lightDir;
|
uniform vec3 lightDir;
|
||||||
uniform vec4 lightColor;
|
uniform vec4 lightColor;
|
||||||
|
@ -15,7 +15,7 @@ out vec4 finalColor;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
float d = length(lightDir);
|
float d = length(lightDir);
|
||||||
vec3 n = normalize(texture(textureNormal, fragTexCoord).xyz);
|
vec3 n = normalize(texture(texture0, fragTexCoord).xyz);
|
||||||
vec3 l = normalize(lightDir);
|
vec3 l = normalize(lightDir);
|
||||||
|
|
||||||
vec3 diffuse = lightColor.rgb * lightColor.a * max(dot(n, l), 0.0);
|
vec3 diffuse = lightColor.rgb * lightColor.a * max(dot(n, l), 0.0);
|
||||||
|
@ -25,5 +25,5 @@ void main() {
|
||||||
|
|
||||||
vec3 final = diffuse.rgb * intensity;
|
vec3 final = diffuse.rgb * intensity;
|
||||||
|
|
||||||
finalColor = vec4(final, texture(texture0, fragTexCoord).a * 0.93);
|
finalColor = vec4(final, texture(texture0, fragTexCoord).a);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue