Compare commits
3 Commits
5b0169cd94
...
c98c00bfb9
Author | SHA1 | Date | |
---|---|---|---|
c98c00bfb9 | |||
fc3fa32ddd | |||
cd83c528ee |
43
.ecode/project_build.json
Normal file
43
.ecode/project_build.json
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"Debug": {
|
||||
"build": [
|
||||
{
|
||||
"args": "",
|
||||
"command": "scripts/compile_shaders.sh",
|
||||
"working_dir": ""
|
||||
},
|
||||
{
|
||||
"args": "clean-run -g",
|
||||
"command": "c3c",
|
||||
"working_dir": ""
|
||||
}
|
||||
],
|
||||
"build_types": [],
|
||||
"clean": [
|
||||
{
|
||||
"args": "",
|
||||
"command": "rm build/ugui",
|
||||
"working_dir": ""
|
||||
}
|
||||
],
|
||||
"config": {
|
||||
"clear_sys_env": false
|
||||
},
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"output_parser": {
|
||||
"config": {
|
||||
"relative_file_paths": true
|
||||
}
|
||||
},
|
||||
"run": [
|
||||
{
|
||||
"args": "",
|
||||
"command": "build/ugui",
|
||||
"name": "Custom Executable",
|
||||
"working_dir": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ void main()
|
||||
vec2 centerpoint = in_quad_size.xy + in_quad_size.zw * 0.5;
|
||||
vec2 half_size = in_quad_size.zw * 0.5;
|
||||
float distance = sdf_rr(vec2(gl_FragCoord) - centerpoint, half_size, in_radius);
|
||||
float alpha = 1.0 - smoothstep(0.0, 1.0, distance);
|
||||
float alpha = 1.0 - smoothstep(0.0, 1.5, distance);
|
||||
|
||||
fragColor = vec4(in_color.rgb, in_color.a * alpha);
|
||||
}
|
@ -7,7 +7,7 @@ layout(set = 1, binding = 0) uniform Viewport {
|
||||
layout(location = 0) in ivec2 position;
|
||||
layout(location = 1) in ivec4 attr; // quad x,y,w,h
|
||||
layout(location = 2) in ivec2 uv; // x,y in the texture
|
||||
layout(location = 3) in ivec4 color;
|
||||
layout(location = 3) in uvec4 color;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
layout(location = 1) out vec4 out_quad_size;
|
||||
|
@ -7,7 +7,7 @@ layout(set = 1, binding = 0) uniform Viewport {
|
||||
layout(location = 0) in ivec2 position;
|
||||
layout(location = 1) in ivec4 attr; // quad x,y,w,h
|
||||
layout(location = 2) in ivec2 in_uv;
|
||||
layout(location = 3) in ivec4 color;
|
||||
layout(location = 3) in uvec4 color;
|
||||
|
||||
layout(location = 0) out vec2 out_uv;
|
||||
layout(location = 1) out vec4 out_color;
|
||||
|
@ -86,7 +86,7 @@ struct Renderer {
|
||||
Id sprite_atlas_id;
|
||||
Id font_atlas_id;
|
||||
|
||||
uint scissor_x, scissor_y, scissor_w, scissor_h;
|
||||
int scissor_x, scissor_y, scissor_w, scissor_h;
|
||||
}
|
||||
|
||||
// How each vertex is represented in the gpu
|
||||
@ -291,7 +291,18 @@ fn void Renderer.free(&self)
|
||||
}
|
||||
self.pipelines.free();
|
||||
|
||||
// FIXME: release the quad buffer
|
||||
foreach (&t: self.textures) {
|
||||
sdl::release_gpu_texture(self.gpu, t.texture);
|
||||
sdl::release_gpu_sampler(self.gpu, t.sampler);
|
||||
}
|
||||
self.textures.free();
|
||||
|
||||
QuadBuffer* qb = &self.quad_buffer;
|
||||
sdl::unmap_gpu_transfer_buffer(self.gpu, qb.attr_ts);
|
||||
sdl::release_gpu_transfer_buffer(self.gpu, qb.attr_ts);
|
||||
sdl::release_gpu_buffer(self.gpu, qb.vert_buf);
|
||||
sdl::release_gpu_buffer(self.gpu, qb.idx_buf);
|
||||
sdl::release_gpu_buffer(self.gpu, qb.attr_buf);
|
||||
|
||||
sdl::release_window_from_gpu_device(self.gpu, self.win);
|
||||
sdl::destroy_gpu_device(self.gpu);
|
||||
@ -377,12 +388,14 @@ fn void Renderer.load_spirv_shader_from_file(&self, String name, String vert_pat
|
||||
char[] frag_code;
|
||||
|
||||
// create vertex shader
|
||||
vert_code = mem::new_array(char, file::get_size(vert_path)!!+1);
|
||||
usz size = file::get_size(vert_path)!!;
|
||||
vert_code = mem::new_array(char, size + size%4);
|
||||
file::load_buffer(vert_path, vert_code)!!;
|
||||
defer mem::free(vert_code);
|
||||
|
||||
// create fragment shader
|
||||
frag_code = mem::new_array(char, file::get_size(frag_path)!!+1);
|
||||
size = file::get_size(frag_path)!!;
|
||||
frag_code = mem::new_array(char, size + size%4);
|
||||
file::load_buffer(frag_path, frag_code)!!;
|
||||
defer mem::free(frag_code);
|
||||
|
||||
@ -810,8 +823,11 @@ fn void Renderer.bind_texture(&self, String texture_name)
|
||||
);
|
||||
}
|
||||
|
||||
fn void Renderer.set_scissor(&self, uint x, uint y, uint w, uint h)
|
||||
fn void Renderer.set_scissor(&self, int x, int y, int w, int h)
|
||||
{
|
||||
// in vulkan scissor size must be positive, clamp to zero
|
||||
w = max(w, 0);
|
||||
h = max(h, 0);
|
||||
sdl::set_gpu_scissor(self.render_pass, &&(sdl::Rect){x,y,w,h});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user