Initial setup of sokol_gfx to replace the raylib impl for rendering.
Next I need to setup sokol_gp
This commit is contained in:
parent
cf81d3f9bd
commit
13c3032dba
@ -2,6 +2,7 @@ package sectr
|
||||
|
||||
// Scratch space
|
||||
|
||||
import sokol_gfx "thirdparty:sokol/gfx"
|
||||
import rl "vendor:raylib"
|
||||
|
||||
DebugData :: struct {
|
||||
@ -38,5 +39,10 @@ DebugData :: struct {
|
||||
cam_vp : rl.Camera3D,
|
||||
viewport_rt : rl.RenderTexture,
|
||||
|
||||
proto_text_shader : rl.Shader
|
||||
gfx_clear_demo_pass_action : sokol_gfx.Pass_Action,
|
||||
gfx_tri_demo_state : struct {
|
||||
pipeline : sokol_gfx.Pipeline,
|
||||
bindings : sokol_gfx.Bindings,
|
||||
pass_action : sokol_gfx.Pass_Action,
|
||||
}
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ ui_screen_settings_menu :: proc( captures : rawptr = nil ) -> ( should_raise : b
|
||||
layout.text_alignment = {0, 0.5}
|
||||
layout.anchor.left = 1.0
|
||||
layout.flags = {.Fixed_Width}
|
||||
layout.size.min = cast(Vec2) measure_text_size( value_txt.text.str, value_txt.style.font, value_txt.layout.font_size, 0 )
|
||||
// layout.size.min = cast(Vec2) measure_text_size( value_txt.text.str, value_txt.style.font, value_txt.layout.font_size, 0 )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,10 @@ import "core:strings"
|
||||
import "core:time"
|
||||
import "core:prof/spall"
|
||||
|
||||
import sokol_app "thirdparty:sokol/app"
|
||||
import sokol_app "thirdparty:sokol/app"
|
||||
import sokol_gfx "thirdparty:sokol/gfx"
|
||||
import sokol_app_gfx_glue "thirdparty:sokol/glue"
|
||||
|
||||
import rl "vendor:raylib"
|
||||
|
||||
Path_Assets :: "../assets/"
|
||||
@ -188,6 +191,79 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem
|
||||
}
|
||||
}
|
||||
|
||||
// Setup sokol_gfx
|
||||
{
|
||||
glue_env := sokol_app_gfx_glue.environment()
|
||||
|
||||
desc := sokol_gfx.Desc {
|
||||
buffer_pool_size = 128,
|
||||
image_pool_size = 128,
|
||||
sampler_pool_size = 64,
|
||||
shader_pool_size = 32,
|
||||
pipeline_pool_size = 64,
|
||||
// pass_pool_size = 16, // (No longer exists)
|
||||
attachments_pool_size = 16,
|
||||
uniform_buffer_size = 4 * Megabyte,
|
||||
max_commit_listeners = Kilo,
|
||||
allocator = { sokol_gfx_alloc, sokol_gfx_free, nil },
|
||||
logger = { sokol_gfx_log_callback, nil },
|
||||
environment = glue_env,
|
||||
}
|
||||
sokol_gfx.setup(desc)
|
||||
|
||||
backend := sokol_gfx.query_backend()
|
||||
switch backend
|
||||
{
|
||||
case .D3D11: logf("sokol_gfx: using D3D11 backend")
|
||||
case .GLCORE, .GLES3: logf("sokol_gfx: using GL backend")
|
||||
|
||||
case .METAL_MACOS, .METAL_IOS, .METAL_SIMULATOR:
|
||||
logf("sokol_gfx: using Metal backend")
|
||||
|
||||
case .WGPU: logf("sokol_gfx: using WebGPU backend")
|
||||
case .DUMMY: logf("sokol_gfx: using dummy backend")
|
||||
}
|
||||
|
||||
// Learning examples
|
||||
{
|
||||
|
||||
debug.gfx_clear_demo_pass_action.colors[0] = {
|
||||
load_action = .CLEAR,
|
||||
clear_value = { 1, 0, 0, 1 }
|
||||
}
|
||||
vertices := [?]f32 {
|
||||
// positions // colors
|
||||
0.0, 0.5, 0.5, 1.0, 0.0, 0.0, 1.0,
|
||||
0.5, -0.5, 0.5, 0.0, 1.0, 0.0, 1.0,
|
||||
-0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 1.0,
|
||||
}
|
||||
|
||||
tri_shader_attr_vs_position :: 0
|
||||
tri_shader_attr_vs_color0 :: 1
|
||||
|
||||
using debug.gfx_tri_demo_state
|
||||
bindings.vertex_buffers[0] = sokol_gfx.make_buffer( sokol_gfx.Buffer_Desc {
|
||||
data = {
|
||||
ptr = & vertices,
|
||||
size = size_of(vertices)
|
||||
}
|
||||
})
|
||||
pipeline = sokol_gfx.make_pipeline( sokol_gfx.Pipeline_Desc {
|
||||
shader = sokol_gfx.make_shader( triangle_shader_desc(backend)),
|
||||
layout = sokol_gfx.Vertex_Layout_State {
|
||||
attrs = {
|
||||
tri_shader_attr_vs_position = { format = .FLOAT3 },
|
||||
tri_shader_attr_vs_color0 = { format = .FLOAT4 },
|
||||
}
|
||||
}
|
||||
})
|
||||
pass_action.colors[0] = {
|
||||
load_action = .CLEAR,
|
||||
clear_value = { 0, 0, 0, 1 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Basic Font Setup
|
||||
if false
|
||||
{
|
||||
@ -205,7 +281,7 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem
|
||||
}
|
||||
|
||||
// Setup the screen ui state
|
||||
if false
|
||||
if true
|
||||
{
|
||||
ui_startup( & screen_ui.base, cache_allocator = persistent_slab_allocator() )
|
||||
ui_floating_startup( & screen_ui.floating, persistent_slab_allocator(), 1 * Kilobyte, 1 * Kilobyte, "screen ui floating manager" )
|
||||
@ -220,7 +296,7 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem
|
||||
|
||||
// Demo project setup
|
||||
// TODO(Ed): This will eventually have to occur when the user either creates or loads a workspace. I don't know
|
||||
if false
|
||||
if true
|
||||
{
|
||||
using project
|
||||
path = str_intern("./")
|
||||
@ -345,48 +421,55 @@ tick :: proc( host_delta_time_ms : f64, host_delta_ns : Duration ) -> b32
|
||||
state := get_state(); using state
|
||||
|
||||
client_tick := time.tick_now()
|
||||
tick_work_frame()
|
||||
should_close |= tick_work_frame( host_delta_time_ms)
|
||||
tick_frametime( & client_tick, host_delta_time_ms, host_delta_ns )
|
||||
|
||||
profile_begin("sokol_app: post_client_tick")
|
||||
sokol_app.post_client_frame()
|
||||
profile_end()
|
||||
return ! should_close
|
||||
}
|
||||
|
||||
|
||||
// Lifted out of tick so that sokol_app_frame_callback can do it as well.
|
||||
tick_work_frame :: #force_inline proc()
|
||||
tick_work_frame :: #force_inline proc( host_delta_time_ms : f64 ) -> b32
|
||||
{
|
||||
context.logger = to_odin_logger( & Memory_App.logger )
|
||||
state := get_state(); using state
|
||||
profile("Work frame")
|
||||
context.logger = to_odin_logger( & Memory_App.logger )
|
||||
state := get_state(); using state
|
||||
profile("Work frame")
|
||||
|
||||
// Setup Frame Slab
|
||||
{
|
||||
alloc_error : AllocatorError
|
||||
frame_slab, alloc_error = slab_init( & default_slab_policy, bucket_reserve_num = 0,
|
||||
allocator = frame_allocator(),
|
||||
dbg_name = Frame_Slab_DBG_Name,
|
||||
should_zero_buckets = true )
|
||||
verify( alloc_error == .None, "Failed to allocate frame slab" )
|
||||
}
|
||||
should_close : b32
|
||||
|
||||
// The policy for the work tick is that the default allocator is the frame's slab.
|
||||
// Transient's is the temp allocator.
|
||||
context.allocator = frame_slab_allocator()
|
||||
context.temp_allocator = transient_allocator()
|
||||
// Setup Frame Slab
|
||||
{
|
||||
alloc_error : AllocatorError
|
||||
frame_slab, alloc_error = slab_init( & default_slab_policy, bucket_reserve_num = 0,
|
||||
allocator = frame_allocator(),
|
||||
dbg_name = Frame_Slab_DBG_Name,
|
||||
should_zero_buckets = true )
|
||||
verify( alloc_error == .None, "Failed to allocate frame slab" )
|
||||
}
|
||||
|
||||
// rl.PollInputEvents()
|
||||
// The policy for the work tick is that the default allocator is the frame's slab.
|
||||
// Transient's is the temp allocator.
|
||||
context.allocator = frame_slab_allocator()
|
||||
context.temp_allocator = transient_allocator()
|
||||
|
||||
debug.draw_ui_box_bounds_points = false
|
||||
debug.draw_UI_padding_bounds = false
|
||||
debug.draw_ui_content_bounds = false
|
||||
// rl.PollInputEvents()
|
||||
|
||||
// config.color_theme = App_Thm_Light
|
||||
// config.color_theme = App_Thm_Dusk
|
||||
config.color_theme = App_Thm_Dark
|
||||
debug.draw_ui_box_bounds_points = false
|
||||
debug.draw_UI_padding_bounds = false
|
||||
debug.draw_ui_content_bounds = false
|
||||
|
||||
// should_close |= update( host_delta_time )
|
||||
// render()
|
||||
// config.color_theme = App_Thm_Light
|
||||
// config.color_theme = App_Thm_Dusk
|
||||
config.color_theme = App_Thm_Dark
|
||||
|
||||
// rl.SwapScreenBuffer()
|
||||
should_close |= update( host_delta_time_ms )
|
||||
render()
|
||||
|
||||
// rl.SwapScreenBuffer()
|
||||
return should_close
|
||||
}
|
||||
|
||||
// Lifted out of tick so that sokol_app_frame_callback can do it as well.
|
||||
@ -440,10 +523,6 @@ tick_frametime :: #force_inline proc( client_tick : ^time.Tick, host_delta_time_
|
||||
if frametime_elapsed_ms > 60.0 {
|
||||
log( str_fmt("Big tick! %v ms", frametime_elapsed_ms), LogLevel.Warning )
|
||||
}
|
||||
|
||||
profile_begin("sokol_app: post_client_tick")
|
||||
sokol_app.post_client_frame()
|
||||
profile_end()
|
||||
}
|
||||
|
||||
@export
|
||||
|
@ -6,17 +6,20 @@ import str "core:strings"
|
||||
|
||||
import sokol_app "thirdparty:sokol/app"
|
||||
|
||||
#region("Sokol App")
|
||||
|
||||
sokol_app_init_callback :: proc "c" () {
|
||||
context = get_state().sokol_context
|
||||
log("sokol_app: Confirmed initialization")
|
||||
}
|
||||
|
||||
// This is being filled in but we're directly controlling the lifetime of sokol_app's execution.
|
||||
// So this will only get called during resize events (on Win32 at least)
|
||||
// So this will only get called during window pan or resize events (on Win32 at least)
|
||||
sokol_app_frame_callback :: proc "c" () {
|
||||
context = get_state().sokol_context
|
||||
state := get_state()
|
||||
|
||||
state := get_state()
|
||||
should_close : b32
|
||||
|
||||
sokol_width := sokol_app.widthf()
|
||||
sokol_height := sokol_app.heightf()
|
||||
@ -33,7 +36,7 @@ sokol_app_frame_callback :: proc "c" () {
|
||||
sokol_delta_ns := transmute(Duration) sokol_delta_ms * MS_To_NS
|
||||
|
||||
client_tick := time.tick_now()
|
||||
tick_work_frame()
|
||||
should_close |= tick_work_frame( sokol_delta_ms )
|
||||
tick_frametime( & client_tick, sokol_delta_ms, sokol_delta_ns )
|
||||
}
|
||||
|
||||
@ -45,7 +48,7 @@ sokol_app_cleanup_callback :: proc "c" () {
|
||||
sokol_app_alloc :: proc "c" ( size : u64, user_data : rawptr ) -> rawptr {
|
||||
context = get_state().sokol_context
|
||||
block, error := alloc( int(size), allocator = persistent_slab_allocator() )
|
||||
ensure(error != AllocatorError.None, "sokol_app allocation failed")
|
||||
ensure(error == AllocatorError.None, "sokol_app allocation failed")
|
||||
return block
|
||||
}
|
||||
|
||||
@ -95,3 +98,52 @@ sokol_app_event_callback :: proc "c" (event : ^sokol_app.Event)
|
||||
monitor_refresh_hz := sokol_app.refresh_rate()
|
||||
}
|
||||
}
|
||||
|
||||
#endregion("Sokol App")
|
||||
|
||||
#region("Sokol GFX")
|
||||
|
||||
sokol_gfx_alloc :: proc "c" ( size : u64, user_data : rawptr ) -> rawptr {
|
||||
context = get_state().sokol_context
|
||||
block, error := alloc( int(size), allocator = persistent_slab_allocator() )
|
||||
ensure(error == AllocatorError.None, "sokol_gfx allocation failed")
|
||||
return block
|
||||
}
|
||||
|
||||
sokol_gfx_free :: proc "c" ( data : rawptr, user_data : rawptr ) {
|
||||
context = get_state().sokol_context
|
||||
free(data, allocator = persistent_slab_allocator() )
|
||||
}
|
||||
|
||||
sokol_gfx_log_callback :: proc "c" (
|
||||
tag: cstring,
|
||||
log_level: u32,
|
||||
log_item_id: u32,
|
||||
message_or_null: cstring,
|
||||
line_nr: u32,
|
||||
filename_or_null: cstring,
|
||||
user_data: rawptr) {
|
||||
context = get_state().sokol_context
|
||||
|
||||
odin_level : LogLevel
|
||||
switch log_level {
|
||||
case 0: odin_level = .Fatal
|
||||
case 1: odin_level = .Error
|
||||
case 2: odin_level = .Warning
|
||||
case 3: odin_level = .Info
|
||||
}
|
||||
|
||||
cloned_msg : string = ""
|
||||
if message_or_null != nil {
|
||||
cloned_msg = str.clone_from_cstring(message_or_null, context.temp_allocator)
|
||||
}
|
||||
cloned_fname : string = ""
|
||||
if filename_or_null != nil {
|
||||
cloned_fname = str.clone_from_cstring(filename_or_null, context.temp_allocator)
|
||||
}
|
||||
|
||||
cloned_tag := str.clone_from_cstring(tag, context.temp_allocator)
|
||||
logf( "%-80s %s::%v", cloned_msg, cloned_tag, line_nr, level = odin_level )
|
||||
}
|
||||
|
||||
#endregion("Sokol GFX")
|
||||
|
@ -4,6 +4,7 @@ import "core:fmt"
|
||||
|
||||
import rl "vendor:raylib"
|
||||
|
||||
when false {
|
||||
range2_to_rl_rect :: #force_inline proc "contextless"( range : Range2 ) -> rl.Rectangle
|
||||
{
|
||||
rect := rl.Rectangle {
|
||||
@ -399,3 +400,4 @@ render_screen_ui :: proc()
|
||||
}
|
||||
//endregion App UI
|
||||
}
|
||||
} // when false
|
||||
|
@ -1,2 +1,37 @@
|
||||
package sectr
|
||||
|
||||
import sokol_gfx "thirdparty:sokol/gfx"
|
||||
import sokol_glue "thirdparty:sokol/glue"
|
||||
|
||||
render :: proc()
|
||||
{
|
||||
state := get_state(); using state
|
||||
|
||||
// Clear Demo
|
||||
if false
|
||||
{
|
||||
green_value := debug.gfx_clear_demo_pass_action.colors[0].clear_value.g + 0.01
|
||||
debug.gfx_clear_demo_pass_action.colors[0].clear_value.g = green_value > 1.0 ? 0.0 : green_value
|
||||
|
||||
sokol_gfx.begin_pass( sokol_gfx.Pass {
|
||||
action = debug.gfx_clear_demo_pass_action,
|
||||
swapchain = sokol_glue.swapchain()
|
||||
})
|
||||
sokol_gfx.end_pass()
|
||||
sokol_gfx.commit()
|
||||
}
|
||||
|
||||
// Triangle Demo
|
||||
if true
|
||||
{
|
||||
using debug.gfx_tri_demo_state
|
||||
sokol_gfx.begin_pass(sokol_gfx.Pass { action = pass_action, swapchain = sokol_glue.swapchain() })
|
||||
sokol_gfx.apply_pipeline( pipeline )
|
||||
sokol_gfx.apply_bindings( bindings )
|
||||
|
||||
sokol_gfx.draw( 0, 3, 1 )
|
||||
|
||||
sokol_gfx.end_pass()
|
||||
sokol_gfx.commit()
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import "core:strings"
|
||||
import "core:unicode/utf8"
|
||||
import rl "vendor:raylib"
|
||||
|
||||
when false {
|
||||
debug_draw_text :: proc( content : string, pos : Vec2, size : f32, color : rl.Color = rl.WHITE, font : FontID = Font_Default )
|
||||
{
|
||||
// profile(#procedure)
|
||||
@ -222,3 +223,4 @@ measure_text_size_raylib :: proc( text : string, font : FontID, font_size := Fon
|
||||
|
||||
return text_size
|
||||
}
|
||||
} // when false
|
||||
|
@ -66,6 +66,7 @@ frametime_delta32 :: #force_inline proc "contextless" () -> f32 {
|
||||
return cast(f32) get_state().frametime_avg_ms
|
||||
}
|
||||
|
||||
//TODO(Ed): Just use avg delta not this.
|
||||
update :: proc( delta_time : f64 ) -> b32
|
||||
{
|
||||
profile(#procedure)
|
||||
|
@ -143,10 +143,10 @@ dot :: proc {
|
||||
dot_unitv3_vs,
|
||||
}
|
||||
|
||||
ws_view_draw_text :: proc {
|
||||
ws_view_draw_text_string,
|
||||
ws_view_draw_text_StrRunesPair,
|
||||
}
|
||||
// ws_view_draw_text :: proc {
|
||||
// ws_view_draw_text_string,
|
||||
// ws_view_draw_text_StrRunesPair,
|
||||
// }
|
||||
|
||||
from_bytes :: proc {
|
||||
str_builder_from_bytes,
|
||||
@ -166,9 +166,9 @@ is_power_of_two :: proc {
|
||||
is_power_of_two_uintptr,
|
||||
}
|
||||
|
||||
measure_text_size :: proc {
|
||||
measure_text_size_raylib,
|
||||
}
|
||||
// measure_text_size :: proc {
|
||||
// measure_text_size_raylib,
|
||||
// }
|
||||
|
||||
mov_avg_exp :: proc {
|
||||
mov_avg_exp_f32,
|
||||
@ -274,9 +274,9 @@ to_quat128 :: proc {
|
||||
rotor3_to_quat128,
|
||||
}
|
||||
|
||||
to_rl_rect :: proc {
|
||||
range2_to_rl_rect,
|
||||
}
|
||||
// to_rl_rect :: proc {
|
||||
// range2_to_rl_rect,
|
||||
// }
|
||||
|
||||
to_runes :: proc {
|
||||
string_to_runes,
|
||||
|
346
code/sectr/shader/traingle_demo_shader.odin
Normal file
346
code/sectr/shader/traingle_demo_shader.odin
Normal file
@ -0,0 +1,346 @@
|
||||
package sectr
|
||||
|
||||
import sg "thirdparty:sokol/gfx"
|
||||
|
||||
triangle_shader_desc :: proc (backend: sg.Backend) -> sg.Shader_Desc
|
||||
{
|
||||
/*
|
||||
#version:1# (machine generated, don't edit!)
|
||||
|
||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc -i examples/triangle/shader.glsl -o examples/triangle/shader.odin -l glsl430:metal_macos:hlsl5 -f sokol_odin
|
||||
|
||||
Overview:
|
||||
=========
|
||||
Shader program: 'triangle':
|
||||
Get shader desc: triangle_shader_desc(sg.query_backend())
|
||||
Vertex shader: vs
|
||||
Attributes:
|
||||
ATTR_vs_position => 0
|
||||
ATTR_vs_color0 => 1
|
||||
Fragment shader: fs
|
||||
*/
|
||||
ATTR_vs_position :: 0
|
||||
ATTR_vs_color0 :: 1
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(location = 0) in vec4 position;
|
||||
layout(location = 0) out vec4 color;
|
||||
layout(location = 1) in vec4 color0;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = position;
|
||||
color = color0;
|
||||
}
|
||||
|
||||
*/
|
||||
@static vs_source_glsl430 := [194]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,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,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,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,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,0x7d,0x0a,
|
||||
0x0a,0x00,
|
||||
}
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
layout(location = 0) in vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = color;
|
||||
}
|
||||
|
||||
*/
|
||||
@static fs_source_glsl430 := [135]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,
|
||||
}
|
||||
/*
|
||||
static float4 gl_Position;
|
||||
static float4 position;
|
||||
static float4 color;
|
||||
static float4 color0;
|
||||
|
||||
struct SPIRV_Cross_Input
|
||||
{
|
||||
float4 position : TEXCOORD0;
|
||||
float4 color0 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
{
|
||||
float4 color : TEXCOORD0;
|
||||
float4 gl_Position : SV_Position;
|
||||
};
|
||||
|
||||
void vert_main()
|
||||
{
|
||||
gl_Position = position;
|
||||
color = color0;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
position = stage_input.position;
|
||||
color0 = stage_input.color0;
|
||||
vert_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.gl_Position = gl_Position;
|
||||
stage_output.color = color;
|
||||
return stage_output;
|
||||
}
|
||||
*/
|
||||
@static vs_source_hlsl5 := [645]u8 {
|
||||
0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,
|
||||
0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,
|
||||
0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||
0x6e,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
|
||||
0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x73,
|
||||
0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,
|
||||
0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,
|
||||
0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x20,0x3a,0x20,0x54,
|
||||
0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x31,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,
|
||||
0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,
|
||||
0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x54,0x45,0x58,
|
||||
0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,
|
||||
0x20,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x3b,
|
||||
0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f,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,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,
|
||||
0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,
|
||||
0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,
|
||||
0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x70,0x6f,0x73,0x69,
|
||||
0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,
|
||||
0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x63,
|
||||
0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x72,0x74,0x5f,
|
||||
0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,
|
||||
0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,
|
||||
0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x67,0x6c,
|
||||
0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,
|
||||
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,
|
||||
0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,
|
||||
0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,
|
||||
0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,
|
||||
0x3b,0x0a,0x7d,0x0a,0x00,
|
||||
}
|
||||
/*
|
||||
static float4 frag_color;
|
||||
static float4 color;
|
||||
|
||||
struct SPIRV_Cross_Input
|
||||
{
|
||||
float4 color : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
{
|
||||
float4 frag_color : SV_Target0;
|
||||
};
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
frag_color = color;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
color = stage_input.color;
|
||||
frag_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.frag_color = frag_color;
|
||||
return stage_output;
|
||||
}
|
||||
*/
|
||||
@static fs_source_hlsl5 := [435]u8 {
|
||||
0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,
|
||||
0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,
|
||||
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,
|
||||
0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x54,0x45,
|
||||
0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,
|
||||
0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,
|
||||
0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,
|
||||
0x20,0x53,0x56,0x5f,0x54,0x61,0x72,0x67,0x65,0x74,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,
|
||||
0x0a,0x76,0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,0x5f,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,0x53,
|
||||
0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,
|
||||
0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,
|
||||
0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,
|
||||
0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,
|
||||
0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,
|
||||
0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,
|
||||
0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,
|
||||
0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x66,0x72,
|
||||
0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x72,0x61,0x67,0x5f,
|
||||
0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,
|
||||
0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,
|
||||
0x7d,0x0a,0x00,
|
||||
}
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 color [[user(locn0)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float4 position [[attribute(0)]];
|
||||
float4 color0 [[attribute(1)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.gl_Position = in.position;
|
||||
out.color = in.color0;
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
@static vs_source_metal_macos := [419]u8 {
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,
|
||||
0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
|
||||
0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,
|
||||
0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,
|
||||
0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,
|
||||
0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x20,
|
||||
0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,
|
||||
0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,
|
||||
0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,
|
||||
0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,
|
||||
0x5f,0x69,0x6e,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,
|
||||
0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,
|
||||
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,
|
||||
0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,
|
||||
0x0a,0x0a,0x00,
|
||||
}
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 frag_color [[color(0)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float4 color [[user(locn0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.frag_color = in.color;
|
||||
return out;
|
||||
}
|
||||
|
||||
*/
|
||||
@static fs_source_metal_macos := [315]u8 {
|
||||
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
|
||||
0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,
|
||||
0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
|
||||
0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
|
||||
0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,
|
||||
0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,
|
||||
0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,
|
||||
0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,
|
||||
0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,
|
||||
0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,
|
||||
0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x2e,
|
||||
0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,
|
||||
0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
}
|
||||
|
||||
desc: sg.Shader_Desc
|
||||
desc.label = "triangle_shader"
|
||||
#partial switch backend {
|
||||
case .GLCORE:
|
||||
desc.attrs[0].name = "position"
|
||||
desc.attrs[1].name = "color0"
|
||||
desc.vs.source = transmute(cstring)&vs_source_glsl430
|
||||
desc.vs.entry = "main"
|
||||
desc.fs.source = transmute(cstring)&fs_source_glsl430
|
||||
desc.fs.entry = "main"
|
||||
case .D3D11:
|
||||
desc.attrs[0].sem_name = "TEXCOORD"
|
||||
desc.attrs[0].sem_index = 0
|
||||
desc.attrs[1].sem_name = "TEXCOORD"
|
||||
desc.attrs[1].sem_index = 1
|
||||
desc.vs.source = transmute(cstring)&vs_source_hlsl5
|
||||
desc.vs.d3d11_target = "vs_5_0"
|
||||
desc.vs.entry = "main"
|
||||
desc.fs.source = transmute(cstring)&fs_source_hlsl5
|
||||
desc.fs.d3d11_target = "ps_5_0"
|
||||
desc.fs.entry = "main"
|
||||
case .METAL_MACOS:
|
||||
desc.vs.source = transmute(cstring)&vs_source_metal_macos
|
||||
desc.vs.entry = "main0"
|
||||
desc.fs.source = transmute(cstring)&fs_source_metal_macos
|
||||
desc.fs.entry = "main0"
|
||||
}
|
||||
return desc
|
||||
}
|
@ -70,17 +70,17 @@ ui_box_compute_layout :: proc( box : ^UI_Box,
|
||||
adjusted_size.x = max( adjusted_max_size_x, layout.size.min.x)
|
||||
adjusted_size.y = max( adjusted_max_size_y, layout.size.min.y)
|
||||
|
||||
text_size : Vec2
|
||||
if layout.font_size == computed.text_size.y {
|
||||
text_size = computed.text_size
|
||||
}
|
||||
else {
|
||||
text_size = cast(Vec2) measure_text_size( box.text.str, style.font, layout.font_size, 0 )
|
||||
}
|
||||
// text_size : Vec2
|
||||
// if layout.font_size == computed.text_size.y {
|
||||
// text_size = computed.text_size
|
||||
// }
|
||||
// else {
|
||||
// text_size = cast(Vec2) measure_text_size( box.text.str, style.font, layout.font_size, 0 )
|
||||
// }
|
||||
|
||||
if size_to_text {
|
||||
adjusted_size = text_size
|
||||
}
|
||||
// if size_to_text {
|
||||
// adjusted_size = text_size
|
||||
// }
|
||||
|
||||
if .Scale_Width_By_Height_Ratio in layout.flags {
|
||||
adjusted_size.x = adjusted_size.y * layout.size.min.x
|
||||
@ -161,16 +161,16 @@ ui_box_compute_layout :: proc( box : ^UI_Box,
|
||||
computed.content = content_bounds
|
||||
|
||||
// 8. Text position & size
|
||||
if len(box.text.str) > 0
|
||||
{
|
||||
content_size := content_bounds.max - content_bounds.min
|
||||
text_pos : Vec2
|
||||
text_pos = content_bounds.min + { 0, text_size.y }
|
||||
text_pos += (content_size - text_size) * layout.text_alignment
|
||||
// if len(box.text.str) > 0
|
||||
// {
|
||||
// content_size := content_bounds.max - content_bounds.min
|
||||
// text_pos : Vec2
|
||||
// text_pos = content_bounds.min + { 0, text_size.y }
|
||||
// text_pos += (content_size - text_size) * layout.text_alignment
|
||||
|
||||
computed.text_size = text_size
|
||||
computed.text_pos = text_pos
|
||||
}
|
||||
// computed.text_size = text_size
|
||||
// computed.text_pos = text_pos
|
||||
// }
|
||||
computed.fresh = true && !dont_mark_fresh
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user