working textures and events
This commit is contained in:
parent
dc6fd0a73c
commit
a53727318a
BIN
dist/index.wasm
vendored
BIN
dist/index.wasm
vendored
Binary file not shown.
BIN
dist/main.o
vendored
BIN
dist/main.o
vendored
Binary file not shown.
@ -17,11 +17,31 @@ create_arbtri_pipeline :: () {
|
||||
pipeline: sg_pipeline_desc;
|
||||
shader_desc := triangle_shader_desc(sg_query_backend());
|
||||
pipeline.shader = sg_make_shader(*shader_desc);
|
||||
|
||||
pipeline.layout.attrs[ATTR_triangle_position] = .{ format = .FLOAT3 };
|
||||
pipeline.layout.attrs[ATTR_triangle_color0] = .{ format = .FLOAT4 };
|
||||
pipeline.layout.attrs[ATTR_triangle_uv] = .{ format = .FLOAT2 };
|
||||
pipeline.layout.attrs[ATTR_triangle_color0] = .{ format = .FLOAT4 };
|
||||
pipeline.layout.attrs[ATTR_triangle_uv] = .{ format = .FLOAT2 };
|
||||
|
||||
color_state := sg_color_target_state.{
|
||||
pixel_format = .RGBA8,
|
||||
blend = .{
|
||||
enabled = true,
|
||||
src_factor_rgb = .SRC_ALPHA,
|
||||
dst_factor_rgb = .ONE_MINUS_SRC_ALPHA
|
||||
}
|
||||
};
|
||||
|
||||
pipeline.color_count = 4;
|
||||
pipeline.colors[0] = color_state;
|
||||
|
||||
gPipelines.arbtri.pipeline = sg_make_pipeline(*pipeline);
|
||||
|
||||
buffer := sg_buffer_desc.{ usage = .DYNAMIC, size = size_of(type_of(gArbtriMem)) };
|
||||
gPipelines.arbtri.bind.vertex_buffers[0] = sg_make_buffer(*buffer);
|
||||
gPipelines.arbtri.bind.samplers[0] = sg_make_sampler(*(sg_sampler_desc.{
|
||||
wrap_u = .CLAMP_TO_EDGE,
|
||||
wrap_v = .CLAMP_TO_EDGE,
|
||||
min_filter = .NEAREST,
|
||||
mag_filter = .NEAREST,
|
||||
}));
|
||||
}
|
||||
|
||||
@ -17,23 +17,34 @@
|
||||
ATTR_triangle_color0 => 1
|
||||
ATTR_triangle_uv => 2
|
||||
Bindings:
|
||||
Image 'tex':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_tex => 0
|
||||
Sampler 'smp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_smp => 0
|
||||
*/
|
||||
ATTR_triangle_position :: 0;
|
||||
ATTR_triangle_color0 :: 1;
|
||||
ATTR_triangle_uv :: 2;
|
||||
IMG_tex :: 0;
|
||||
SMP_smp :: 0;
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(location = 0) in vec4 position;
|
||||
layout(location = 0) out vec4 color;
|
||||
layout(location = 1) in vec4 color0;
|
||||
layout(location = 1) out vec4 texcoord;
|
||||
layout(location = 2) in vec4 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = position;
|
||||
color = color0;
|
||||
color.x = fma(9.9999999392252902907785028219223e-09, uv.x, color.x);
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
@ -47,39 +58,103 @@ vs_source_glsl430 := u8.[
|
||||
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,
|
||||
0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x6c,
|
||||
0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,
|
||||
0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76,0x3b,0x0a,
|
||||
0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,
|
||||
0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,
|
||||
0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x20,0x3d,0x20,0x66,0x6d,0x61,
|
||||
0x28,0x39,0x2e,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x33,0x39,0x32,0x32,0x35,0x32,
|
||||
0x39,0x30,0x32,0x39,0x30,0x37,0x37,0x38,0x35,0x30,0x32,0x38,0x32,0x31,0x39,0x32,
|
||||
0x32,0x33,0x65,0x2d,0x30,0x39,0x2c,0x20,0x75,0x76,0x2e,0x78,0x2c,0x20,0x63,0x6f,
|
||||
0x6c,0x6f,0x72,0x2e,0x78,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
0x20,0x31,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x74,0x65,0x78,
|
||||
0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,
|
||||
0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,
|
||||
0x65,0x63,0x34,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,
|
||||
0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,
|
||||
0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,0x63,0x6f,
|
||||
0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(binding = 16) uniform sampler2D tex_smp;
|
||||
|
||||
layout(location = 1) in vec4 texcoord;
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
layout(location = 0) in vec4 color;
|
||||
|
||||
bool is_near(float a, float b)
|
||||
{
|
||||
return abs(a - b) < 0.00999999977648258209228515625;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = color;
|
||||
float param = texcoord.x;
|
||||
float param_1 = -4.0;
|
||||
bool _33 = is_near(param, param_1);
|
||||
bool _43;
|
||||
if (_33)
|
||||
{
|
||||
float param_2 = texcoord.y;
|
||||
float param_3 = -2.0;
|
||||
_43 = is_near(param_2, param_3);
|
||||
}
|
||||
else
|
||||
{
|
||||
_43 = _33;
|
||||
}
|
||||
if (_43)
|
||||
{
|
||||
frag_color = color;
|
||||
}
|
||||
else
|
||||
{
|
||||
frag_color = texture(tex_smp, texcoord.xy) * color;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
fs_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,
|
||||
0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,
|
||||
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,
|
||||
0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
|
||||
0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,
|
||||
0x36,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,
|
||||
0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,
|
||||
0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x74,0x65,0x78,0x63,
|
||||
0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,
|
||||
0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,
|
||||
0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,
|
||||
0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,
|
||||
0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,
|
||||
0x6f,0x72,0x3b,0x0a,0x0a,0x62,0x6f,0x6f,0x6c,0x20,0x69,0x73,0x5f,0x6e,0x65,0x61,
|
||||
0x72,0x28,0x66,0x6c,0x6f,0x61,0x74,0x20,0x61,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x62,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,
|
||||
0x20,0x61,0x62,0x73,0x28,0x61,0x20,0x2d,0x20,0x62,0x29,0x20,0x3c,0x20,0x30,0x2e,
|
||||
0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,
|
||||
0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x3b,0x0a,0x7d,
|
||||
0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,
|
||||
0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x20,
|
||||
0x3d,0x20,0x2d,0x34,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x62,0x6f,0x6f,0x6c,
|
||||
0x20,0x5f,0x33,0x33,0x20,0x3d,0x20,0x69,0x73,0x5f,0x6e,0x65,0x61,0x72,0x28,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x62,0x6f,0x6f,0x6c,0x20,0x5f,0x34,0x33,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x33,0x33,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,
|
||||
0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
|
||||
0x64,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x2d,0x32,0x2e,
|
||||
0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x34,0x33,0x20,0x3d,
|
||||
0x20,0x69,0x73,0x5f,0x6e,0x65,0x61,0x72,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,
|
||||
0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x34,0x33,0x20,0x3d,0x20,0x5f,
|
||||
0x33,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,
|
||||
0x20,0x28,0x5f,0x34,0x33,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
|
||||
0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
|
||||
0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x5f,0x73,
|
||||
0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x79,0x29,
|
||||
0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,
|
||||
0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
@ -87,13 +162,14 @@ fs_source_glsl430 := u8.[
|
||||
layout(location = 0) in vec4 position;
|
||||
out vec4 color;
|
||||
layout(location = 1) in vec4 color0;
|
||||
out vec4 texcoord;
|
||||
layout(location = 2) in vec4 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = position;
|
||||
color = color0;
|
||||
color.x = 9.9999999392252902907785028219223e-09 * uv.x + color.x;
|
||||
texcoord = uv;
|
||||
}
|
||||
|
||||
*/
|
||||
@ -104,30 +180,57 @@ vs_source_glsl300es := u8.[
|
||||
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,
|
||||
0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,
|
||||
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,
|
||||
0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x6c,0x61,0x79,
|
||||
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,
|
||||
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,
|
||||
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x70,
|
||||
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,
|
||||
0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x63,0x6f,0x6c,0x6f,0x72,0x2e,0x78,0x20,0x3d,0x20,0x39,0x2e,0x39,0x39,0x39,
|
||||
0x39,0x39,0x39,0x39,0x33,0x39,0x32,0x32,0x35,0x32,0x39,0x30,0x32,0x39,0x30,0x37,
|
||||
0x37,0x38,0x35,0x30,0x32,0x38,0x32,0x31,0x39,0x32,0x32,0x33,0x65,0x2d,0x30,0x39,
|
||||
0x20,0x2a,0x20,0x75,0x76,0x2e,0x78,0x20,0x2b,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x2e,
|
||||
0x78,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x6f,0x75,0x74,
|
||||
0x20,0x76,0x65,0x63,0x34,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,
|
||||
0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,
|
||||
0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76,0x3b,
|
||||
0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,
|
||||
0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,
|
||||
0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform highp sampler2D tex_smp;
|
||||
|
||||
in highp vec4 texcoord;
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
in highp vec4 color;
|
||||
|
||||
bool is_near(highp float a, highp float b)
|
||||
{
|
||||
return abs(a - b) < 0.00999999977648258209228515625;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = color;
|
||||
highp float param = texcoord.x;
|
||||
highp float param_1 = -4.0;
|
||||
bool _33 = is_near(param, param_1);
|
||||
bool _43;
|
||||
if (_33)
|
||||
{
|
||||
highp float param_2 = texcoord.y;
|
||||
highp float param_3 = -2.0;
|
||||
_43 = is_near(param_2, param_3);
|
||||
}
|
||||
else
|
||||
{
|
||||
_43 = _33;
|
||||
}
|
||||
if (_43)
|
||||
{
|
||||
frag_color = color;
|
||||
}
|
||||
else
|
||||
{
|
||||
frag_color = texture(tex_smp, texcoord.xy) * color;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
@ -135,14 +238,51 @@ fs_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
|
||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x6c,
|
||||
0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,
|
||||
0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,
|
||||
0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,
|
||||
0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,
|
||||
0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,
|
||||
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,
|
||||
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x5f,0x73,0x6d,0x70,0x3b,0x0a,
|
||||
0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x74,
|
||||
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
|
||||
0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,
|
||||
0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,
|
||||
0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,
|
||||
0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x62,
|
||||
0x6f,0x6f,0x6c,0x20,0x69,0x73,0x5f,0x6e,0x65,0x61,0x72,0x28,0x68,0x69,0x67,0x68,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x61,0x2c,0x20,0x68,0x69,0x67,0x68,0x70,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x62,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x61,0x62,0x73,0x28,0x61,0x20,0x2d,0x20,0x62,
|
||||
0x29,0x20,0x3c,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,
|
||||
0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,
|
||||
0x36,0x32,0x35,0x3b,0x0a,0x7d,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,
|
||||
0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x74,0x65,
|
||||
0x78,0x63,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,
|
||||
0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,
|
||||
0x31,0x20,0x3d,0x20,0x2d,0x34,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x62,0x6f,
|
||||
0x6f,0x6c,0x20,0x5f,0x33,0x33,0x20,0x3d,0x20,0x69,0x73,0x5f,0x6e,0x65,0x61,0x72,
|
||||
0x28,0x70,0x61,0x72,0x61,0x6d,0x2c,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x31,0x29,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x62,0x6f,0x6f,0x6c,0x20,0x5f,0x34,0x33,0x3b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x33,0x33,0x29,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x20,0x3d,
|
||||
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x20,0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x20,0x3d,0x20,0x2d,0x32,0x2e,0x30,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x34,0x33,0x20,0x3d,0x20,0x69,
|
||||
0x73,0x5f,0x6e,0x65,0x61,0x72,0x28,0x70,0x61,0x72,0x61,0x6d,0x5f,0x32,0x2c,0x20,
|
||||
0x70,0x61,0x72,0x61,0x6d,0x5f,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x34,0x33,0x20,0x3d,0x20,0x5f,0x33,0x33,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,
|
||||
0x5f,0x34,0x33,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,
|
||||
0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,
|
||||
0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x5f,0x73,0x6d,0x70,
|
||||
0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x2e,0x78,0x79,0x29,0x20,0x2a,
|
||||
0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,
|
||||
0x0a,0x00,
|
||||
];
|
||||
triangle_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
@ -159,6 +299,16 @@ triangle_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc.attrs[1].glsl_name = "color0";
|
||||
desc.attrs[2].base_type = .FLOAT;
|
||||
desc.attrs[2].glsl_name = "uv";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "tex_smp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
@ -170,6 +320,16 @@ triangle_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc.attrs[1].glsl_name = "color0";
|
||||
desc.attrs[2].base_type = .FLOAT;
|
||||
desc.attrs[2].glsl_name = "uv";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "tex_smp";
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
@ -4,20 +4,34 @@ in vec4 color0;
|
||||
in vec4 uv;
|
||||
|
||||
out vec4 color;
|
||||
out vec4 texcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = position;
|
||||
color = color0;
|
||||
color.x += 0.00000001 * uv.x;
|
||||
texcoord = uv;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs
|
||||
in vec4 color;
|
||||
in vec4 texcoord;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding = 0) uniform texture2D tex;
|
||||
layout(binding = 0) uniform sampler smp;
|
||||
|
||||
bool is_near(float a, float b) {
|
||||
return abs(a-b) < 0.01;
|
||||
}
|
||||
|
||||
void main() {
|
||||
frag_color = color;
|
||||
if(is_near(texcoord.x, -4) && is_near(texcoord.y, -2)) {
|
||||
frag_color = color;
|
||||
} else {
|
||||
vec4 sampled = texture(sampler2D(tex, smp), texcoord.xy) * color;
|
||||
frag_color = sampled;
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@ -1,10 +1,19 @@
|
||||
GR :: #import "GetRect_LeftHanded"()(Type_Indicator = Ui_Type_Indicator);
|
||||
Input :: #import "Input";
|
||||
|
||||
|
||||
Ui_Font_Glyph :: struct {
|
||||
advance : u32 = 1;
|
||||
};
|
||||
|
||||
Ui_Font :: struct {
|
||||
em_width: u32 = 1;
|
||||
character_height: u32 = 30;
|
||||
}
|
||||
typical_descender: u32 = 1;
|
||||
typical_ascender: u32 = 1;
|
||||
temporary_glyphs: [..]Ui_Font_Glyph;
|
||||
temporary_glyphs_byte_offsets : [..]u32;
|
||||
};
|
||||
|
||||
Ui_Texture :: struct {
|
||||
tex: sg_image;
|
||||
@ -28,7 +37,6 @@ defaultFont: Font;
|
||||
ui_texture_counter : u32 = 0;
|
||||
|
||||
texture_load_from_memory :: (texture: *Ui_Texture, memory: []u8, srgb: bool, build_mipmaps: bool) -> bool {
|
||||
print("LOAD FROM MEMORY CALLED!!!\n");
|
||||
x : s32;
|
||||
y : s32;
|
||||
channels : s32;
|
||||
@ -40,7 +48,7 @@ texture_load_from_memory :: (texture: *Ui_Texture, memory: []u8, srgb: bool, bui
|
||||
ptr = data,
|
||||
size = xx (x * y * 4)
|
||||
};
|
||||
|
||||
|
||||
sg_init_image(*img, *(sg_image_desc.{
|
||||
width = x,
|
||||
height = y,
|
||||
@ -74,13 +82,13 @@ clear_scissor :: () {
|
||||
gCurrentTexture : *Ui_Texture = null;
|
||||
|
||||
set_shader_for_color :: (enable_blend := false) {
|
||||
// gCurrentTexture = null;
|
||||
gCurrentTexture = null;
|
||||
}
|
||||
|
||||
|
||||
set_shader_for_images :: (texture: *Ui_Texture) {
|
||||
// gPipelines.arbtri.bind.images[0] = texture.tex;
|
||||
// gCurrentTexture = texture;
|
||||
gPipelines.arbtri.bind.images[0] = texture.tex;
|
||||
gCurrentTexture = texture;
|
||||
}
|
||||
|
||||
gPreppedText: string;
|
||||
@ -132,8 +140,8 @@ immediate_triangle :: (p0: Vector3, p1: Vector3, p2: Vector3, c0 := Vector4.{1,1
|
||||
tri.uv[2] = nullUV;
|
||||
} else {
|
||||
tri.uv[0] = uv0;
|
||||
tri.uv[1] = uv2;
|
||||
tri.uv[2] = uv1;
|
||||
tri.uv[1] = uv1;
|
||||
tri.uv[2] = uv2;
|
||||
}
|
||||
|
||||
arb_tri_add(tri);
|
||||
@ -204,8 +212,13 @@ render_ui :: () {
|
||||
if pressed {
|
||||
}
|
||||
|
||||
r.y += 50;
|
||||
|
||||
GR.text_input(r, "TTT", *my_theme.text_input_theme);
|
||||
|
||||
r.y += 150;
|
||||
if GR.base_checkbox(r, "CHECK!!!", idk, null) {
|
||||
idk = !idk;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user