Skip to content

Commit

Permalink
examples: cleanup compiler notices for all sokol examples
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Jan 29, 2024
1 parent d8b158b commit 4f7476e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 79 deletions.
35 changes: 1 addition & 34 deletions examples/sokol/01_cubes/cube.v
@@ -1,11 +1,8 @@
/**********************************************************************
*
* Sokol 3d cube demo
*
* Copyright (c) 2021 Dario Deledda. All rights reserved.
* Use of this source code is governed by an MIT license
* that can be found in the LICENSE file.
*
* TODO:
* - add instancing
* - add an example with shaders
Expand Down Expand Up @@ -33,11 +30,6 @@ mut:
mouse_y int = -1
}

/******************************************************************************
*
* Texture functions
*
******************************************************************************/
fn create_texture(w int, h int, buf &u8) (gfx.Image, gfx.Sampler) {
sz := w * h * 4
mut img_desc := gfx.ImageDesc{
Expand Down Expand Up @@ -82,11 +74,6 @@ fn update_text_texture(sg_img gfx.Image, w int, h int, buf &u8) {
gfx.update_image(sg_img, &tmp_sbc)
}

/******************************************************************************
*
* Draw functions
*
******************************************************************************/
fn draw_triangle() {
sgl.defaults()
sgl.begin_triangles()
Expand Down Expand Up @@ -306,11 +293,6 @@ fn frame(mut app App) {
app.gg.end()
}

/******************************************************************************
*
* Init / Cleanup
*
******************************************************************************/
fn my_init(mut app App) {
app.init_flag = true

Expand Down Expand Up @@ -382,11 +364,6 @@ fn my_init(mut app App) {
}
}

/******************************************************************************
*
* event
*
******************************************************************************/
fn my_event_manager(mut ev gg.Event, mut app App) {
if ev.typ == .mouse_move {
app.mouse_x = int(ev.mouse_x)
Expand All @@ -401,17 +378,8 @@ fn my_event_manager(mut ev gg.Event, mut app App) {
}
}

/******************************************************************************
*
* Main
*
******************************************************************************/
fn main() {
// App init
mut app := &App{
gg: 0
}

mut app := &App{}
app.gg = gg.new_context(
width: win_width
height: win_height
Expand All @@ -423,6 +391,5 @@ fn main() {
init_fn: my_init
event_fn: my_event_manager
)

app.gg.run()
}
4 changes: 1 addition & 3 deletions examples/sokol/02_cubes_glsl/cube_glsl.v
Expand Up @@ -604,9 +604,7 @@ fn my_event_manager(mut ev gg.Event, mut app App) {

fn main() {
// App init
mut app := &App{
gg: 0
}
mut app := &App{}

mut a := [5]int{}
a[0] = 2
Expand Down
10 changes: 1 addition & 9 deletions examples/sokol/03_march_tracing_glsl/rt_glsl.v
Expand Up @@ -409,15 +409,8 @@ fn my_event_manager(mut ev gg.Event, mut app App) {
}
}

/******************************************************************************
* Main
******************************************************************************/
fn main() {
// App init
mut app := &App{
gg: 0
}

mut app := &App{}
app.gg = gg.new_context(
width: win_width
height: win_height
Expand All @@ -429,7 +422,6 @@ fn main() {
init_fn: my_init
event_fn: my_event_manager
)

app.ticks = time.ticks()
app.gg.run()
}
10 changes: 1 addition & 9 deletions examples/sokol/04_multi_shader_glsl/rt_glsl.v
Expand Up @@ -612,15 +612,8 @@ fn my_event_manager(mut ev gg.Event, mut app App) {
}
}

/******************************************************************************
* Main
******************************************************************************/
fn main() {
// App init
mut app := &App{
gg: 0
}

mut app := &App{}
app.gg = gg.new_context(
width: win_width
height: win_height
Expand All @@ -632,7 +625,6 @@ fn main() {
init_fn: my_init
event_fn: my_event_manager
)

app.ticks = time.ticks()
app.gg.run()
}
10 changes: 1 addition & 9 deletions examples/sokol/05_instancing_glsl/rt_glsl.v
Expand Up @@ -492,15 +492,8 @@ fn my_event_manager(mut ev gg.Event, mut app App) {
}
}

/******************************************************************************
* Main
******************************************************************************/
fn main() {
// App init
mut app := &App{
gg: 0
}

mut app := &App{}
// vfmt off
app.gg = gg.new_context(
width: win_width
Expand All @@ -514,7 +507,6 @@ fn main() {
event_fn: my_event_manager
)
// vfmt on

app.ticks = time.ticks()
app.gg.run()
}
8 changes: 2 additions & 6 deletions examples/sokol/06_obj_viewer/modules/obj/rend.v
Expand Up @@ -77,9 +77,7 @@ pub fn (mut obj_part ObjPart) create_pipeline(in_part []int, shader gfx.Shader,
res.material = obj_part.part[in_part[0]].material

// vertex buffer
mut vert_buffer_desc := gfx.BufferDesc{
label: 0
}
mut vert_buffer_desc := gfx.BufferDesc{}
unsafe { vmemset(&vert_buffer_desc, 0, int(sizeof(vert_buffer_desc))) }

vert_buffer_desc.size = usize(obj_buf.vbuf.len * int(sizeof(Vertex_pnct)))
Expand All @@ -93,9 +91,7 @@ pub fn (mut obj_part ObjPart) create_pipeline(in_part []int, shader gfx.Shader,
vbuf := gfx.make_buffer(&vert_buffer_desc)

// index buffer
mut index_buffer_desc := gfx.BufferDesc{
label: 0
}
mut index_buffer_desc := gfx.BufferDesc{}
unsafe { vmemset(&index_buffer_desc, 0, int(sizeof(index_buffer_desc))) }

index_buffer_desc.size = usize(obj_buf.ibuf.len * int(sizeof(u32)))
Expand Down
11 changes: 2 additions & 9 deletions examples/sokol/06_obj_viewer/show_obj.v
Expand Up @@ -55,7 +55,7 @@ mut:
// time
ticks i64
// model
obj_part &obj.ObjPart
obj_part &obj.ObjPart = unsafe { nil }
n_vertex u32
// init parameters
file_name string
Expand Down Expand Up @@ -261,20 +261,13 @@ fn my_event_manager(mut ev gg.Event, mut app App) {
}
}

/******************************************************************************
* Main
******************************************************************************/
fn main() {
/*
obj.tst()
exit(0)
*/

// App init
mut app := &App{
gg: 0
obj_part: 0
}
mut app := &App{}

// app.file_name = 'v.obj' // default object is the v logo
app.file_name = 'utahTeapot.obj' // default object is the v logo
Expand Down

0 comments on commit 4f7476e

Please sign in to comment.