Skip to content

Commit

Permalink
sokol, gg, examples: update to match uptream at 058a4c5 (vlang#20953)
Browse files Browse the repository at this point in the history
  • Loading branch information
larpon authored Mar 5, 2024
1 parent 60b4fb3 commit 790ea2f
Show file tree
Hide file tree
Showing 20 changed files with 3,057 additions and 2,327 deletions.
3 changes: 2 additions & 1 deletion examples/sokol/02_cubes_glsl/cube_glsl.v
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ fn draw_cube_glsl(app App) {
}
mut pass_action := gfx.PassAction{}
pass_action.colors[0] = color_action
gfx.begin_default_pass(&pass_action, ws.width, ws.height)
pass := sapp.create_default_pass(pass_action)
gfx.begin_pass(&pass)
{
rot := [f32(app.mouse_y), f32(app.mouse_x)]
// ratio := f32(ws.width)/ws.height
Expand Down
5 changes: 2 additions & 3 deletions examples/sokol/03_march_tracing_glsl/rt_glsl.v
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,6 @@ fn draw_cube_glsl(app App) {
}

fn frame(mut app App) {
ws := gg.window_size_real_pixels()

// clear
mut color_action := gfx.ColorAttachmentAction{
load_action: .clear
Expand All @@ -329,7 +327,8 @@ fn frame(mut app App) {

mut pass_action := gfx.PassAction{}
pass_action.colors[0] = color_action
gfx.begin_default_pass(&pass_action, ws.width, ws.height)
pass := sapp.create_default_pass(pass_action)
gfx.begin_pass(&pass)

// glsl cube
draw_cube_glsl(app)
Expand Down
5 changes: 2 additions & 3 deletions examples/sokol/04_multi_shader_glsl/rt_glsl.v
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,6 @@ fn draw_end_glsl(app App) {
}

fn frame(mut app App) {
ws := gg.window_size_real_pixels()

// clear
mut color_action := gfx.ColorAttachmentAction{
load_action: .clear
Expand All @@ -516,7 +514,8 @@ fn frame(mut app App) {
}
mut pass_action := gfx.PassAction{}
pass_action.colors[0] = color_action
gfx.begin_default_pass(&pass_action, ws.width, ws.height)
pass := sapp.create_default_pass(pass_action)
gfx.begin_pass(&pass)

/*
// glsl cube
Expand Down
5 changes: 2 additions & 3 deletions examples/sokol/05_instancing_glsl/rt_glsl.v
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,6 @@ fn draw_end_glsl(app App) {
}

fn frame(mut app App) {
ws := gg.window_size_real_pixels()

// clear
mut color_action := gfx.ColorAttachmentAction{
load_action: .clear
Expand All @@ -402,7 +400,8 @@ fn frame(mut app App) {
}
mut pass_action := gfx.PassAction{}
pass_action.colors[0] = color_action
gfx.begin_default_pass(&pass_action, ws.width, ws.height)
pass := gg.create_default_pass(pass_action)
gfx.begin_pass(&pass)

draw_start_glsl(app)
draw_cube_glsl_i(mut app)
Expand Down
5 changes: 2 additions & 3 deletions examples/sokol/06_obj_viewer/show_obj.v
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ fn draw_model(app App, model_pos m4.Vec4) u32 {
}

fn frame(mut app App) {
ws := gg.window_size_real_pixels()

// clear
mut color_action := gfx.ColorAttachmentAction{
load_action: .clear
Expand All @@ -159,7 +157,8 @@ fn frame(mut app App) {

mut pass_action := gfx.PassAction{}
pass_action.colors[0] = color_action
gfx.begin_default_pass(&pass_action, ws.width, ws.height)
pass := sapp.create_default_pass(pass_action)
gfx.begin_pass(&pass)

// render the data
draw_start_glsl(app)
Expand Down
5 changes: 3 additions & 2 deletions examples/sokol/drawing.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const used_import = sokol.used_import

fn main() {
state := &AppState{
pass_action: gfx.create_clear_pass(0.1, 0.1, 0.1, 1.0)
pass_action: gfx.create_clear_pass_action(0.1, 0.1, 0.1, 1.0)
}
title := 'Sokol Drawing Template'
desc := sapp.Desc{
Expand All @@ -36,7 +36,8 @@ fn init(user_data voidptr) {
fn frame(state &AppState) {
// println('frame')
draw()
gfx.begin_default_pass(&state.pass_action, sapp.width(), sapp.height())
pass := sapp.create_default_pass(state.pass_action)
gfx.begin_pass(&pass)
sgl.draw()
gfx.end_pass()
gfx.commit()
Expand Down
16 changes: 3 additions & 13 deletions examples/sokol/fonts.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,8 @@ mut:
}

fn main() {
mut color_action := gfx.ColorAttachmentAction{
load_action: .clear
clear_value: gfx.Color{
r: 0.3
g: 0.3
b: 0.32
a: 1.0
}
}
mut pass_action := gfx.PassAction{}
pass_action.colors[0] = color_action
state := &AppState{
pass_action: pass_action
pass_action: gfx.create_clear_pass_action(0.3, 0.3, 0.32, 1.0)
font_context: unsafe { nil } // &fontstash.Context(0)
}
title := 'V Metal/GL Text Rendering'
Expand Down Expand Up @@ -57,7 +46,8 @@ fn init(mut state AppState) {

fn frame(mut state AppState) {
state.render_font()
gfx.begin_default_pass(&state.pass_action, sapp.width(), sapp.height())
pass := sapp.create_default_pass(state.pass_action)
gfx.begin_pass(&pass)
sgl.draw()
gfx.end_pass()
gfx.commit()
Expand Down
3 changes: 2 additions & 1 deletion examples/sokol/freetype_raven.v
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ fn init(mut state AppState) {

fn frame(mut state AppState) {
state.render_font()
gfx.begin_default_pass(&state.pass_action, sapp.width(), sapp.height())
pass := sapp.create_default_pass(state.pass_action)
gfx.begin_pass(&pass)
sgl.draw()
gfx.end_pass()
gfx.commit()
Expand Down
5 changes: 3 additions & 2 deletions examples/sokol/particles/particles.v
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn main() {
mut app := &App{
width: 800
height: 400
pass_action: gfx.create_clear_pass(0.1, 0.1, 0.1, 1.0)
pass_action: gfx.create_clear_pass_action(0.1, 0.1, 0.1, 1.0)
}
app.init()
app.run()
Expand Down Expand Up @@ -105,7 +105,8 @@ fn frame(mut app App) {
dt := f64(t - app.last) / 1000.0
app.ps.update(dt)
draw(app)
gfx.begin_default_pass(&app.pass_action, app.width, app.height)
pass := sapp.create_default_pass(app.pass_action)
gfx.begin_pass(&pass)
sgl.default_pipeline()
sgl.draw()
gfx.end_pass()
Expand Down
5 changes: 3 additions & 2 deletions examples/sokol/simple_shader_glsl/simple_shader.v
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() {
mut app := &App{
width: 800
height: 400
pass_action: gfx.create_clear_pass(0.0, 0.0, 0.0, 1.0) // This will create a black color as a default pass (window background color)
pass_action: gfx.create_clear_pass_action(0.0, 0.0, 0.0, 1.0) // This will create a black color as a default pass (window background color)
}
app.run()
}
Expand Down Expand Up @@ -143,7 +143,8 @@ fn cleanup(user_data voidptr) {
fn frame(user_data voidptr) {
mut app := unsafe { &App(user_data) }

gfx.begin_default_pass(&app.pass_action, sapp.width(), sapp.height())
pass := sapp.create_default_pass(state.pass_action)
gfx.begin_pass(&pass)

gfx.apply_pipeline(app.shader_pipeline)
gfx.apply_bindings(&app.bind)
Expand Down
Loading

0 comments on commit 790ea2f

Please sign in to comment.