sokol: make examples compile
parent
465f0ddf60
commit
c4ca6a9113
|
@ -14,21 +14,21 @@ mut:
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
mut color_action := sg_color_attachment_action{
|
mut color_action := C.sg_color_attachment_action{
|
||||||
action: C.SG_ACTION_CLEAR
|
action: C.SG_ACTION_CLEAR
|
||||||
}
|
}
|
||||||
color_action.val[0] = 0.3
|
color_action.val[0] = 0.3
|
||||||
color_action.val[1] = 0.3
|
color_action.val[1] = 0.3
|
||||||
color_action.val[2] = 0.32
|
color_action.val[2] = 0.32
|
||||||
color_action.val[3] = 1.0
|
color_action.val[3] = 1.0
|
||||||
mut pass_action := sg_pass_action{}
|
mut pass_action := C.sg_pass_action{}
|
||||||
pass_action.colors[0] = color_action
|
pass_action.colors[0] = color_action
|
||||||
state := &AppState{
|
state := &AppState{
|
||||||
pass_action: pass_action
|
pass_action: pass_action
|
||||||
fons: &C.FONScontext(0)
|
fons: &C.FONScontext(0)
|
||||||
}
|
}
|
||||||
title := 'V Metal/GL Text Rendering'
|
title := 'V Metal/GL Text Rendering'
|
||||||
desc := sapp_desc{
|
desc := C.sapp_desc{
|
||||||
user_data: state
|
user_data: state
|
||||||
init_userdata_cb: init
|
init_userdata_cb: init
|
||||||
frame_userdata_cb: frame
|
frame_userdata_cb: frame
|
||||||
|
@ -41,7 +41,7 @@ fn main() {
|
||||||
fn init(user_data voidptr) {
|
fn init(user_data voidptr) {
|
||||||
mut state := &AppState(user_data)
|
mut state := &AppState(user_data)
|
||||||
// dont actually alocate this on the heap in real life
|
// dont actually alocate this on the heap in real life
|
||||||
gfx.setup(&sg_desc{
|
gfx.setup(&C.sg_desc{
|
||||||
mtl_device: sapp.metal_get_device()
|
mtl_device: sapp.metal_get_device()
|
||||||
mtl_renderpass_descriptor_cb: sapp.metal_get_renderpass_descriptor
|
mtl_renderpass_descriptor_cb: sapp.metal_get_renderpass_descriptor
|
||||||
mtl_drawable_cb: sapp.metal_get_drawable
|
mtl_drawable_cb: sapp.metal_get_drawable
|
||||||
|
|
|
@ -415,12 +415,14 @@ pub mut:
|
||||||
val [4]f32
|
val [4]f32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
pub fn (action mut C.sg_color_attachment_action) set_color_values(r, g, b, a f32) {
|
pub fn (action mut C.sg_color_attachment_action) set_color_values(r, g, b, a f32) {
|
||||||
action.val[0] = r
|
action.val[0] = r
|
||||||
action.val[1] = g
|
action.val[1] = g
|
||||||
action.val[2] = b
|
action.val[2] = b
|
||||||
action.val[3] = a
|
action.val[3] = a
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
pub struct C.sg_depth_attachment_action {
|
pub struct C.sg_depth_attachment_action {
|
||||||
pub mut:
|
pub mut:
|
||||||
|
|
|
@ -4,7 +4,11 @@ pub fn create_clear_pass(r, g, b, a f32) C.sg_pass_action {
|
||||||
mut color_action := C.sg_color_attachment_action {
|
mut color_action := C.sg_color_attachment_action {
|
||||||
action: C.SG_ACTION_CLEAR
|
action: C.SG_ACTION_CLEAR
|
||||||
}
|
}
|
||||||
color_action.set_color_values(r, g, b, a)
|
//color_action.set_color_values(r, g, b, a)
|
||||||
|
color_action.val[0] = r
|
||||||
|
color_action.val[1] = g
|
||||||
|
color_action.val[2] = b
|
||||||
|
color_action.val[3] = a
|
||||||
|
|
||||||
mut pass_action := C.sg_pass_action{}
|
mut pass_action := C.sg_pass_action{}
|
||||||
pass_action.colors[0] = color_action
|
pass_action.colors[0] = color_action
|
||||||
|
|
|
@ -654,7 +654,7 @@ fn (mut g Gen) stmt(node ast.Stmt) {
|
||||||
g.includes.writeln('#$it.val')
|
g.includes.writeln('#$it.val')
|
||||||
}
|
}
|
||||||
if typ == 'define' {
|
if typ == 'define' {
|
||||||
g.definitions.writeln('#$it.val')
|
g.includes.writeln('#$it.val')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast.Import {}
|
ast.Import {}
|
||||||
|
@ -967,6 +967,12 @@ fn (mut g Gen) gen_assign_stmt(assign_stmt ast.AssignStmt) {
|
||||||
right_sym := g.table.get_type_symbol(assign_stmt.right_types[i])
|
right_sym := g.table.get_type_symbol(assign_stmt.right_types[i])
|
||||||
mut is_fixed_array_init := false
|
mut is_fixed_array_init := false
|
||||||
mut has_val := false
|
mut has_val := false
|
||||||
|
/*
|
||||||
|
if val is ast.ArrayInit {
|
||||||
|
is_fixed_array_init = val.is_fixed
|
||||||
|
has_val = val.has_val
|
||||||
|
}
|
||||||
|
*/
|
||||||
match val {
|
match val {
|
||||||
ast.ArrayInit {
|
ast.ArrayInit {
|
||||||
is_fixed_array_init = it.is_fixed
|
is_fixed_array_init = it.is_fixed
|
||||||
|
@ -2444,6 +2450,9 @@ fn (mut g Gen) write_types(types []table.TypeSymbol) {
|
||||||
mut fixed := styp[12..]
|
mut fixed := styp[12..]
|
||||||
len := styp.after('_')
|
len := styp.after('_')
|
||||||
fixed = fixed[..fixed.len - len.len - 1]
|
fixed = fixed[..fixed.len - len.len - 1]
|
||||||
|
if fixed.starts_with('C__') {
|
||||||
|
fixed = fixed[3..]
|
||||||
|
}
|
||||||
g.definitions.writeln('typedef $fixed $styp [$len];')
|
g.definitions.writeln('typedef $fixed $styp [$len];')
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,8 +292,10 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
|
||||||
if node.left_type == 0 {
|
if node.left_type == 0 {
|
||||||
verror('method receiver type is 0, this means there are some uchecked exprs')
|
verror('method receiver type is 0, this means there are some uchecked exprs')
|
||||||
}
|
}
|
||||||
mut receiver_type_name := g.cc_type(node.receiver_type)
|
// mut receiver_type_name := g.cc_type(node.receiver_type)
|
||||||
|
//mut receiver_type_name := g.typ(node.receiver_type)
|
||||||
typ_sym := g.table.get_type_symbol(node.receiver_type)
|
typ_sym := g.table.get_type_symbol(node.receiver_type)
|
||||||
|
mut receiver_type_name := typ_sym.name.replace('.', '__')
|
||||||
if typ_sym.kind == .interface_ {
|
if typ_sym.kind == .interface_ {
|
||||||
// Speaker_name_table[s._interface_idx].speak(s._object)
|
// Speaker_name_table[s._interface_idx].speak(s._object)
|
||||||
g.write('${c_name(receiver_type_name)}_name_table[')
|
g.write('${c_name(receiver_type_name)}_name_table[')
|
||||||
|
|
Loading…
Reference in New Issue