1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

sokol: make examples compile

This commit is contained in:
Alexander Medvednikov 2020-05-15 18:55:29 +02:00
parent 465f0ddf60
commit c4ca6a9113
5 changed files with 24 additions and 7 deletions

View File

@ -14,21 +14,21 @@ mut:
}
fn main() {
mut color_action := sg_color_attachment_action{
mut color_action := C.sg_color_attachment_action{
action: C.SG_ACTION_CLEAR
}
color_action.val[0] = 0.3
color_action.val[1] = 0.3
color_action.val[2] = 0.32
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
state := &AppState{
pass_action: pass_action
fons: &C.FONScontext(0)
}
title := 'V Metal/GL Text Rendering'
desc := sapp_desc{
desc := C.sapp_desc{
user_data: state
init_userdata_cb: init
frame_userdata_cb: frame
@ -41,7 +41,7 @@ fn main() {
fn init(user_data voidptr) {
mut state := &AppState(user_data)
// 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_renderpass_descriptor_cb: sapp.metal_get_renderpass_descriptor
mtl_drawable_cb: sapp.metal_get_drawable

View File

@ -415,12 +415,14 @@ pub mut:
val [4]f32
}
/*
pub fn (action mut C.sg_color_attachment_action) set_color_values(r, g, b, a f32) {
action.val[0] = r
action.val[1] = g
action.val[2] = b
action.val[3] = a
}
*/
pub struct C.sg_depth_attachment_action {
pub mut:

View File

@ -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 {
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{}
pass_action.colors[0] = color_action

View File

@ -654,7 +654,7 @@ fn (mut g Gen) stmt(node ast.Stmt) {
g.includes.writeln('#$it.val')
}
if typ == 'define' {
g.definitions.writeln('#$it.val')
g.includes.writeln('#$it.val')
}
}
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])
mut is_fixed_array_init := false
mut has_val := false
/*
if val is ast.ArrayInit {
is_fixed_array_init = val.is_fixed
has_val = val.has_val
}
*/
match val {
ast.ArrayInit {
is_fixed_array_init = it.is_fixed
@ -2444,6 +2450,9 @@ fn (mut g Gen) write_types(types []table.TypeSymbol) {
mut fixed := styp[12..]
len := styp.after('_')
fixed = fixed[..fixed.len - len.len - 1]
if fixed.starts_with('C__') {
fixed = fixed[3..]
}
g.definitions.writeln('typedef $fixed $styp [$len];')
// }
}

View File

@ -292,8 +292,10 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
if node.left_type == 0 {
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)
mut receiver_type_name := typ_sym.name.replace('.', '__')
if typ_sym.kind == .interface_ {
// Speaker_name_table[s._interface_idx].speak(s._object)
g.write('${c_name(receiver_type_name)}_name_table[')