examples: cleanup compiler notices for all sokol examples

This commit is contained in:
Delyan Angelov 2024-01-29 03:42:40 +02:00
parent d8b158be2b
commit 4f7476eaa3
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
7 changed files with 9 additions and 79 deletions

View file

@ -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
@ -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{
@ -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()
@ -306,11 +293,6 @@ fn frame(mut app App) {
app.gg.end()
}
/******************************************************************************
*
* Init / Cleanup
*
******************************************************************************/
fn my_init(mut app App) {
app.init_flag = true
@ -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)
@ -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
@ -423,6 +391,5 @@ fn main() {
init_fn: my_init
event_fn: my_event_manager
)
app.gg.run()
}

View file

@ -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

View file

@ -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
@ -429,7 +422,6 @@ fn main() {
init_fn: my_init
event_fn: my_event_manager
)
app.ticks = time.ticks()
app.gg.run()
}

View file

@ -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
@ -632,7 +625,6 @@ fn main() {
init_fn: my_init
event_fn: my_event_manager
)
app.ticks = time.ticks()
app.gg.run()
}

View file

@ -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
@ -514,7 +507,6 @@ fn main() {
event_fn: my_event_manager
)
// vfmt on
app.ticks = time.ticks()
app.gg.run()
}

View file

@ -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)))
@ -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)))

View file

@ -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
@ -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