test
This commit is contained in:
parent
ade18c6b08
commit
5d472cb966
@ -1,20 +0,0 @@
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec3 vertexPos;
|
||||
in vec2 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
uniform float divider = 0.5;
|
||||
|
||||
out vec4 finalColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
finalColor = vec4(0.5, 0.5, 0.5, 1.0);
|
||||
}
|
||||
66
assets/test_1.frag
Normal file
66
assets/test_1.frag
Normal file
@ -0,0 +1,66 @@
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec3 vertexPos;
|
||||
in vec2 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
uniform float divider = 0.5;
|
||||
|
||||
out vec4 finalColor;
|
||||
|
||||
float float_to_srgb(float l) {
|
||||
if (l < 0.0031308) {
|
||||
return l * 12.92;
|
||||
} else {
|
||||
return 1.055 * pow(l, 0.41666) - 0.055;
|
||||
}
|
||||
}
|
||||
|
||||
vec4 linear_to_srgb(vec4 linear) {
|
||||
vec4 srgb;
|
||||
|
||||
if (linear.r < 0.0031308) {
|
||||
srgb.r = linear.r * 12.92;
|
||||
} else {
|
||||
srgb.r = 1.055 * pow(linear.r, 0.41666) - 0.055;
|
||||
}
|
||||
|
||||
if (linear.g < 0.0031308) {
|
||||
srgb.g = linear.g * 12.92;
|
||||
} else {
|
||||
srgb.g = 1.055 * pow(linear.g, 0.41666) - 0.055;
|
||||
}
|
||||
|
||||
if (linear.b < 0.0031308) {
|
||||
srgb.b = linear.b * 12.92;
|
||||
} else {
|
||||
srgb.b = 1.055 * pow(linear.b, 0.41666) - 0.055;
|
||||
}
|
||||
|
||||
srgb.a = linear.a;
|
||||
|
||||
return srgb;
|
||||
}
|
||||
|
||||
float float_to_linear(float s) {
|
||||
if (s <= 0.04045) {
|
||||
return s / 12.92;
|
||||
} else {
|
||||
return pow((s + 0.055) / 1.055, 2.4);
|
||||
}
|
||||
}
|
||||
|
||||
vec4 srgb_to_linear(vec4 srgb) {
|
||||
return vec4(float_to_linear(srgb.r), float_to_linear(srgb.g), float_to_linear(srgb.b), srgb.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
finalColor = vec4(0.5);
|
||||
}
|
||||
66
assets/test_2.frag
Normal file
66
assets/test_2.frag
Normal file
@ -0,0 +1,66 @@
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec3 vertexPos;
|
||||
in vec2 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
uniform float divider = 0.5;
|
||||
|
||||
out vec4 finalColor;
|
||||
|
||||
float float_to_srgb(float l) {
|
||||
if (l < 0.0031308) {
|
||||
return l * 12.92;
|
||||
} else {
|
||||
return 1.055 * pow(l, 0.41666) - 0.055;
|
||||
}
|
||||
}
|
||||
|
||||
vec4 linear_to_srgb(vec4 linear) {
|
||||
vec4 srgb;
|
||||
|
||||
if (linear.r < 0.0031308) {
|
||||
srgb.r = linear.r * 12.92;
|
||||
} else {
|
||||
srgb.r = 1.055 * pow(linear.r, 0.41666) - 0.055;
|
||||
}
|
||||
|
||||
if (linear.g < 0.0031308) {
|
||||
srgb.g = linear.g * 12.92;
|
||||
} else {
|
||||
srgb.g = 1.055 * pow(linear.g, 0.41666) - 0.055;
|
||||
}
|
||||
|
||||
if (linear.b < 0.0031308) {
|
||||
srgb.b = linear.b * 12.92;
|
||||
} else {
|
||||
srgb.b = 1.055 * pow(linear.b, 0.41666) - 0.055;
|
||||
}
|
||||
|
||||
srgb.a = linear.a;
|
||||
|
||||
return srgb;
|
||||
}
|
||||
|
||||
float float_to_linear(float s) {
|
||||
if (s <= 0.04045) {
|
||||
return s / 12.92;
|
||||
} else {
|
||||
return pow((s + 0.055) / 1.055, 2.4);
|
||||
}
|
||||
}
|
||||
|
||||
vec4 srgb_to_linear(vec4 srgb) {
|
||||
return vec4(float_to_linear(srgb.r), float_to_linear(srgb.g), float_to_linear(srgb.b), srgb.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
finalColor = linear_to_srgb(vec4(1, 1, 1, 0.25));
|
||||
}
|
||||
@ -43,13 +43,20 @@ pub fn main() !void {
|
||||
|
||||
// kbts_shape_context *Context = kbts_CreateShapeContext(0, 0);
|
||||
|
||||
// if (gl.binding.isEnabled(@intFromEnum(gl.Capabilities.framebuffer_srgb)) != 0) {
|
||||
// std.log.info("SRGB: The driver reports GL_FRAMEBUFFER_SRGB is ENABLED", .{});
|
||||
// } else {
|
||||
// std.log.info("SRGB: The driver reports GL_FRAMEBUFFER_SRGB is DISABLED", .{});
|
||||
// }
|
||||
|
||||
font.ft_lib = try ft.Library.init();
|
||||
|
||||
var f = try font.Font.init("assets/fonts/Vollkorn/static/Vollkorn-Regular.ttf", 48, allocator);
|
||||
defer f.deinit(allocator);
|
||||
|
||||
font.shader = try rl.loadShader(null, "assets/text.frag");
|
||||
const test_shader = try rl.loadShader(null, "assets/test.frag");
|
||||
const test_shader1 = try rl.loadShader(null, "assets/test_1.frag");
|
||||
const test_shader2 = try rl.loadShader(null, "assets/test_2.frag");
|
||||
|
||||
// const img = rl.genImageColor(32, 32, .blank);
|
||||
// const tx = try rl.loadTextureFromImage(img);
|
||||
@ -177,7 +184,7 @@ pub fn main() !void {
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
rl.clearBackground(.sky_blue);
|
||||
rl.clearBackground(.black);
|
||||
|
||||
rl.beginDrawing();
|
||||
|
||||
@ -191,40 +198,56 @@ pub fn main() !void {
|
||||
// true
|
||||
// );
|
||||
|
||||
rl.beginShaderMode(test_shader);
|
||||
|
||||
rl.beginShaderMode(test_shader1);
|
||||
rl.gl.rlBegin(rl.gl.rl_quads);
|
||||
|
||||
{
|
||||
const topLeft : rl.Vector2 = .{ .x = 0.0, .y = 0.0 };
|
||||
// const topRight : rl.Vector2 = .{ .x = @floatFromInt(rl.getScreenWidth()), .y = 0.0 };
|
||||
// const bottomLeft : rl.Vector2 = .{ .x = 0.0, .y = @floatFromInt(rl.getScreenHeight()) };
|
||||
const bottomRight : rl.Vector2 = .{ .x = @floatFromInt(rl.getScreenWidth()), .y = @floatFromInt(rl.getScreenHeight()) };
|
||||
const bottomRight : rl.Vector2 = .{ .x = @as(f32, @floatFromInt(rl.getScreenWidth())) / 2.0, .y = @as(f32, @floatFromInt(rl.getScreenHeight())) };
|
||||
|
||||
rl.gl.rlVertex2f(topLeft.x, topLeft.y);
|
||||
rl.gl.rlVertex2f(topLeft.x, bottomRight.y);
|
||||
rl.gl.rlVertex2f(bottomRight.x, bottomRight.y);
|
||||
rl.gl.rlVertex2f(bottomRight.x, topLeft.y);
|
||||
|
||||
//rl.gl.rlTexCoord2f(0.0, 0.0);
|
||||
// rl.gl.rlVertex2f(topLeft.x, topLeft.y);
|
||||
//rl.gl.rlTexCoord2f(0.0, 1.0);
|
||||
// rl.gl.rlVertex2f(bottomLeft.x, bottomLeft.y);
|
||||
//rl.gl.rlTexCoord2f(1.0, 0.0);
|
||||
// rl.gl.rlVertex2f(topRight.x, topRight.y);
|
||||
|
||||
// rl.gl.rlTexCoord2f(1.0, 0.0);
|
||||
// rl.gl.rlVertex2f(topRight.x, topRight.y);
|
||||
// rl.gl.rlTexCoord2f(0.0, 1.0);
|
||||
// rl.gl.rlVertex2f(bottomLeft.x, bottomLeft.y);
|
||||
// rl.gl.rlTexCoord2f(1.0, 1.0);
|
||||
// rl.gl.rlVertex2f(bottomRight.x, bottomRight.y);
|
||||
}
|
||||
|
||||
rl.gl.rlEnd();
|
||||
rl.endShaderMode();
|
||||
|
||||
rl.drawRectangle(400, 0, 400, 450, rl.Color{ .r = 54, .g = 54, .b = 54, .a = 255 });
|
||||
rl.beginShaderMode(test_shader2);
|
||||
rl.gl.rlBegin(rl.gl.rl_quads);
|
||||
|
||||
{
|
||||
const topLeft : rl.Vector2 = .{ .x = @as(f32, @floatFromInt(rl.getScreenWidth())) / 2.0, .y = 0 };
|
||||
const bottomRight : rl.Vector2 = .{ .x = @floatFromInt(rl.getScreenWidth()), .y = @floatFromInt(rl.getScreenHeight()) };
|
||||
|
||||
rl.gl.rlVertex2f(topLeft.x, topLeft.y);
|
||||
rl.gl.rlVertex2f(topLeft.x, bottomRight.y);
|
||||
rl.gl.rlVertex2f(bottomRight.x, bottomRight.y);
|
||||
rl.gl.rlVertex2f(bottomRight.x, topLeft.y);
|
||||
}
|
||||
|
||||
rl.gl.rlEnd();
|
||||
rl.endShaderMode();
|
||||
|
||||
rl.beginShaderMode(test_shader2);
|
||||
rl.gl.rlBegin(rl.gl.rl_quads);
|
||||
|
||||
{
|
||||
const topLeft : rl.Vector2 = .{ .x = @as(f32, @floatFromInt(rl.getScreenWidth())) / 2.0, .y = 0 };
|
||||
const bottomRight : rl.Vector2 = .{ .x = @floatFromInt(rl.getScreenWidth()), .y = @floatFromInt(rl.getScreenHeight()) };
|
||||
|
||||
rl.gl.rlVertex2f(topLeft.x, topLeft.y);
|
||||
rl.gl.rlVertex2f(topLeft.x, bottomRight.y);
|
||||
rl.gl.rlVertex2f(bottomRight.x, bottomRight.y);
|
||||
rl.gl.rlVertex2f(bottomRight.x, topLeft.y);
|
||||
}
|
||||
|
||||
rl.gl.rlEnd();
|
||||
rl.endShaderMode();
|
||||
|
||||
// rl.drawRectangle(400, 0, 400, 450, rl.Color{ .r = 54, .g = 54, .b = 54, .a = 255 });
|
||||
|
||||
|
||||
// f.texture.drawPro(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user