test
This commit is contained in:
parent
57a289e86d
commit
e3ecede0ca
@ -16,12 +16,5 @@ out vec4 finalColor;
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
// // Texel color fetching from texture sampler
|
finalColor = vec4(0.5, 0.5, 0.5, 1.0);
|
||||||
vec4 texelColor0 = texture(texture0, fragTexCoord);
|
|
||||||
// vec4 texelColor1 = texture(texture1, fragTexCoord);
|
|
||||||
|
|
||||||
// float x = fract(fragTexCoord.s);
|
|
||||||
// float final = smoothstep(divider - 0.1, divider + 0.1, x);
|
|
||||||
|
|
||||||
finalColor = vec4(1, 1, 1, texelColor0.r);//xelColor0;//vec4(1, 1, 0.0, 1.0);
|
|
||||||
}
|
}
|
||||||
|
|||||||
27
assets/text.frag
Normal file
27
assets/text.frag
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#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()
|
||||||
|
{
|
||||||
|
// // Texel color fetching from texture sampler
|
||||||
|
vec4 texelColor0 = texture(texture0, fragTexCoord);
|
||||||
|
// vec4 texelColor1 = texture(texture1, fragTexCoord);
|
||||||
|
|
||||||
|
// float x = fract(fragTexCoord.s);
|
||||||
|
// float final = smoothstep(divider - 0.1, divider + 0.1, x);
|
||||||
|
|
||||||
|
finalColor = vec4(1, 1, 1, texelColor0.r);//xelColor0;//vec4(1, 1, 0.0, 1.0);
|
||||||
|
}
|
||||||
@ -251,8 +251,6 @@ pub const Font = struct {
|
|||||||
std.log.info("aah it's wrong!! idk how to handle the error rn!!", .{});
|
std.log.info("aah it's wrong!! idk how to handle the error rn!!", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
std.log.debug("RunGlyph: {}", .{RunGlyph});
|
|
||||||
|
|
||||||
// glyph : *Glyph = table_find_pointer(*text.font.glyphs, RunGlyph.Id);
|
// glyph : *Glyph = table_find_pointer(*text.font.glyphs, RunGlyph.Id);
|
||||||
if (self.glyphs.getPtr(RunGlyph.Id)) |glyph| {
|
if (self.glyphs.getPtr(RunGlyph.Id)) |glyph| {
|
||||||
var v0 = rl.Vector2.zero();
|
var v0 = rl.Vector2.zero();
|
||||||
@ -297,7 +295,6 @@ pub const Font = struct {
|
|||||||
rl.gl.rlTexCoord2f(st1.x, st1.y); rl.gl.rlVertex2f(p1.x, p1.y);
|
rl.gl.rlTexCoord2f(st1.x, st1.y); rl.gl.rlVertex2f(p1.x, p1.y);
|
||||||
rl.gl.rlTexCoord2f(st1.x, st0.y); rl.gl.rlVertex2f(p1.x, p0.y);
|
rl.gl.rlTexCoord2f(st1.x, st0.y); rl.gl.rlVertex2f(p1.x, p0.y);
|
||||||
} else {
|
} else {
|
||||||
std.log.debug("x_offset: {}", .{x_offset});
|
|
||||||
x_offset += @floatFromInt(ft.mulFix(RunGlyph.AdvanceX, @intCast(self.face.size().metrics().x_scale)) >> 6);
|
x_offset += @floatFromInt(ft.mulFix(RunGlyph.AdvanceX, @intCast(self.face.size().metrics().x_scale)) >> 6);
|
||||||
y_offset += @floatFromInt(ft.mulFix(RunGlyph.AdvanceY, @intCast(self.face.size().metrics().y_scale)) >> 6);
|
y_offset += @floatFromInt(ft.mulFix(RunGlyph.AdvanceY, @intCast(self.face.size().metrics().y_scale)) >> 6);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -48,7 +48,8 @@ pub fn main() !void {
|
|||||||
var f = try font.Font.init("assets/fonts/Vollkorn/static/Vollkorn-Regular.ttf", 48, allocator);
|
var f = try font.Font.init("assets/fonts/Vollkorn/static/Vollkorn-Regular.ttf", 48, allocator);
|
||||||
defer f.deinit(allocator);
|
defer f.deinit(allocator);
|
||||||
|
|
||||||
font.shader = try rl.loadShader(null, "assets/test.frag");
|
font.shader = try rl.loadShader(null, "assets/text.frag");
|
||||||
|
const test_shader = try rl.loadShader(null, "assets/test.frag");
|
||||||
|
|
||||||
// const img = rl.genImageColor(32, 32, .blank);
|
// const img = rl.genImageColor(32, 32, .blank);
|
||||||
// const tx = try rl.loadTextureFromImage(img);
|
// const tx = try rl.loadTextureFromImage(img);
|
||||||
@ -180,32 +181,36 @@ pub fn main() !void {
|
|||||||
|
|
||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
|
|
||||||
// rl.beginShaderMode(shader);
|
// f.render_text(
|
||||||
|
// "Hello, Sa ilor!",
|
||||||
|
// rl.Vector2.init(400, 400),
|
||||||
|
// true,
|
||||||
|
// rl.Color.white,
|
||||||
|
// rl.Color.blank,
|
||||||
|
// false,
|
||||||
|
// true
|
||||||
|
// );
|
||||||
|
|
||||||
f.render_text(
|
rl.beginShaderMode(test_shader);
|
||||||
"Hello, Sa ilor!",
|
|
||||||
rl.Vector2.init(400, 400),
|
|
||||||
true,
|
|
||||||
rl.Color.white,
|
|
||||||
rl.Color.blank,
|
|
||||||
false,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
|
rl.gl.rlBegin(rl.gl.rl_quads);
|
||||||
|
|
||||||
// rl.gl.rlBegin(rl.gl.rl_triangles);
|
{
|
||||||
|
const topLeft : rl.Vector2 = .{ .x = 0.0, .y = 0.0 };
|
||||||
// {
|
|
||||||
// const topLeft : rl.Vector2 = .{ .x = 0.0, .y = 0.0 };
|
|
||||||
// const topRight : rl.Vector2 = .{ .x = @floatFromInt(rl.getScreenWidth()), .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 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 = @floatFromInt(rl.getScreenWidth()), .y = @floatFromInt(rl.getScreenHeight()) };
|
||||||
|
|
||||||
// rl.gl.rlTexCoord2f(0.0, 0.0);
|
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.rlVertex2f(topLeft.x, topLeft.y);
|
||||||
// rl.gl.rlTexCoord2f(0.0, 1.0);
|
//rl.gl.rlTexCoord2f(0.0, 1.0);
|
||||||
// rl.gl.rlVertex2f(bottomLeft.x, bottomLeft.y);
|
// rl.gl.rlVertex2f(bottomLeft.x, bottomLeft.y);
|
||||||
// rl.gl.rlTexCoord2f(1.0, 0.0);
|
//rl.gl.rlTexCoord2f(1.0, 0.0);
|
||||||
// rl.gl.rlVertex2f(topRight.x, topRight.y);
|
// rl.gl.rlVertex2f(topRight.x, topRight.y);
|
||||||
|
|
||||||
// rl.gl.rlTexCoord2f(1.0, 0.0);
|
// rl.gl.rlTexCoord2f(1.0, 0.0);
|
||||||
@ -214,10 +219,10 @@ pub fn main() !void {
|
|||||||
// rl.gl.rlVertex2f(bottomLeft.x, bottomLeft.y);
|
// rl.gl.rlVertex2f(bottomLeft.x, bottomLeft.y);
|
||||||
// rl.gl.rlTexCoord2f(1.0, 1.0);
|
// rl.gl.rlTexCoord2f(1.0, 1.0);
|
||||||
// rl.gl.rlVertex2f(bottomRight.x, bottomRight.y);
|
// rl.gl.rlVertex2f(bottomRight.x, bottomRight.y);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// rl.gl.rlEnd();
|
rl.gl.rlEnd();
|
||||||
// rl.endShaderMode();
|
rl.endShaderMode();
|
||||||
|
|
||||||
// f.texture.drawPro(
|
// f.texture.drawPro(
|
||||||
// .{.x = 0, .y = 0, .width = 4096, .height = 4096},
|
// .{.x = 0, .y = 0, .width = 4096, .height = 4096},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user