Skip to content

Commit

Permalink
examples, gg, gg.m4: fix `VFLAGS='-no-skip-unused -cstrict -cc clang-…
Browse files Browse the repository at this point in the history
…18' v should-compile-all examples/sokol/` too
  • Loading branch information
spytheman committed Mar 6, 2025
1 parent 3a331e0 commit 0ffc33a
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 76 deletions.
2 changes: 1 addition & 1 deletion examples/sokol/01_cubes/cube.v
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn create_texture(w int, h int, buf &u8) (gfx.Image, gfx.Sampler) {
height: h
num_mipmaps: 0
// usage: .dynamic
label: &u8(0)
label: &char(0)
d3d11_texture: 0
}
// comment, if .dynamic is enabled
Expand Down
6 changes: 3 additions & 3 deletions examples/sokol/02_cubes_glsl/cube_glsl.v
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn create_texture(w int, h int, buf &u8) (gfx.Image, gfx.Sampler) {
height: h
num_mipmaps: 0
// usage: .dynamic
label: &u8(0)
label: &char(0)
d3d11_texture: 0
}
// comment if .dynamic is enabled
Expand Down Expand Up @@ -339,7 +339,7 @@ fn init_cube_glsl(mut app App) {
ibuf := gfx.make_buffer(&index_buffer_desc)

// create shader
shader := gfx.make_shader(C.cube_shader_desc(C.sg_query_backend()))
shader := gfx.make_shader(voidptr(C.cube_shader_desc(C.sg_query_backend())))

mut pipdesc := gfx.PipelineDesc{}
unsafe { vmemset(&pipdesc, 0, int(sizeof(pipdesc))) }
Expand All @@ -360,7 +360,7 @@ fn init_cube_glsl(mut app App) {
}
pipdesc.cull_mode = .back

pipdesc.label = 'glsl_shader pipeline'.str
pipdesc.label = c'glsl_shader pipeline'

app.cube_bind.vertex_buffers[0] = vbuf
app.cube_bind.index_buffer = ibuf
Expand Down
6 changes: 3 additions & 3 deletions examples/sokol/03_march_tracing_glsl/rt_glsl.v
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn create_texture(w int, h int, buf &u8) (gfx.Image, gfx.Sampler) {
// usage: .dynamic
// wrap_u: .clamp_to_edge
// wrap_v: .clamp_to_edge
label: &u8(0)
label: &char(0)
d3d11_texture: 0
}
// comment if .dynamic is enabled
Expand Down Expand Up @@ -205,7 +205,7 @@ fn init_cube_glsl(mut app App) {
ibuf := gfx.make_buffer(&index_buffer_desc)

// create shader
shader := gfx.make_shader(C.rt_shader_desc(C.sg_query_backend()))
shader := gfx.make_shader(voidptr(C.rt_shader_desc(C.sg_query_backend())))

mut pipdesc := gfx.PipelineDesc{}
unsafe { vmemset(&pipdesc, 0, int(sizeof(pipdesc))) }
Expand All @@ -226,7 +226,7 @@ fn init_cube_glsl(mut app App) {
}
pipdesc.cull_mode = .back

pipdesc.label = 'glsl_shader pipeline'.str
pipdesc.label = c'glsl_shader pipeline'

app.cube_bind.vertex_buffers[0] = vbuf
app.cube_bind.index_buffer = ibuf
Expand Down
4 changes: 2 additions & 2 deletions examples/sokol/04_multi_shader_glsl/rt_glsl.v
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,12 @@ fn (mut app App) on_init() {
app.texture, app.sampler = create_texture(w, h, tmp_txt)

// vfmt off
app.init_glsl_shader('march', C.rt_march_shader_desc(C.sg_query_backend()), [
app.init_glsl_shader('march', voidptr(C.rt_march_shader_desc(C.sg_query_backend())), [
u16(0), 1, 2, 0, 2, 3,
6, 5, 4, 7, 6, 4,
8, 9, 10, 8, 10, 11,
])
app.init_glsl_shader('puppy', C.rt_puppy_shader_desc(C.sg_query_backend()), [
app.init_glsl_shader('puppy', voidptr(C.rt_puppy_shader_desc(C.sg_query_backend())), [
u16(14), 13, 12, 15, 14, 12,
16, 17, 18, 16, 18, 19,
22, 21, 20, 23, 22, 20,
Expand Down
6 changes: 3 additions & 3 deletions examples/sokol/05_instancing_glsl/rt_glsl.v
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn create_texture(w int, h int, buf byteptr) (gfx.Image, gfx.Sampler) {
//usage: .dynamic
// wrap_u: .clamp_to_edge
// wrap_v: .clamp_to_edge
label: &u8(0)
label: &char(0)
d3d11_texture: 0
}
// vfmt on
Expand Down Expand Up @@ -225,7 +225,7 @@ fn init_cube_glsl_i(mut app App) {
ibuf := gfx.make_buffer(&index_buffer_desc)

// create shader
shader := gfx.make_shader(C.instancing_shader_desc(C.sg_query_backend()))
shader := gfx.make_shader(voidptr(C.instancing_shader_desc(C.sg_query_backend())))

mut pipdesc := gfx.PipelineDesc{}
unsafe { vmemset(&pipdesc, 0, int(sizeof(pipdesc))) }
Expand Down Expand Up @@ -257,7 +257,7 @@ fn init_cube_glsl_i(mut app App) {
}
pipdesc.cull_mode = .back

pipdesc.label = 'glsl_shader pipeline'.str
pipdesc.label = c'glsl_shader pipeline'

mut bind := gfx.Bindings{}
unsafe { vmemset(&bind, 0, int(sizeof(bind))) }
Expand Down
10 changes: 5 additions & 5 deletions examples/sokol/06_obj_viewer/modules/obj/rend.v
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn create_texture(w int, h int, buf &u8) (gfx.Image, gfx.Sampler) {
// usage: .dynamic
// wrap_u: .clamp_to_edge
// wrap_v: .clamp_to_edge
label: &u8(0)
label: &char(0)
d3d11_texture: 0
}
// comment if .dynamic is enabled
Expand Down Expand Up @@ -87,7 +87,7 @@ pub fn (mut obj_part ObjPart) create_pipeline(in_part []int, shader gfx.Shader,
}

vert_buffer_desc.type = .vertexbuffer
vert_buffer_desc.label = 'vertbuf_part_${in_part:03}'.str
vert_buffer_desc.label = &char('vertbuf_part_${in_part:03}'.str)
vbuf := gfx.make_buffer(&vert_buffer_desc)

// index buffer
Expand All @@ -101,7 +101,7 @@ pub fn (mut obj_part ObjPart) create_pipeline(in_part []int, shader gfx.Shader,
}

index_buffer_desc.type = .indexbuffer
index_buffer_desc.label = 'indbuf_part_${in_part:03}'.str
index_buffer_desc.label = &char('indbuf_part_${in_part:03}'.str)
ibuf := gfx.make_buffer(&index_buffer_desc)

mut pipdesc := gfx.PipelineDesc{}
Expand Down Expand Up @@ -131,7 +131,7 @@ pub fn (mut obj_part ObjPart) create_pipeline(in_part []int, shader gfx.Shader,
}
pipdesc.cull_mode = .front

pipdesc.label = 'pip_part_${in_part:03}'.str
pipdesc.label = &char('pip_part_${in_part:03}'.str)

// shader
pipdesc.shader = shader
Expand All @@ -153,7 +153,7 @@ pub fn (mut obj_part ObjPart) create_pipeline(in_part []int, shader gfx.Shader,
pub fn (mut obj_part ObjPart) init_render_data(texture gfx.Image, sampler gfx.Sampler) {
// create shader
// One shader for all the model
shader := gfx.make_shader(C.gouraud_shader_desc(gfx.query_backend()))
shader := gfx.make_shader(voidptr(C.gouraud_shader_desc(gfx.query_backend())))

mut part_dict := map[string][]int{}
for i, p in obj_part.part {
Expand Down
2 changes: 1 addition & 1 deletion examples/sokol/08_sdf/sdf.v
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn init(mut state State) {

mut pipeline := gfx.PipelineDesc{}
pipeline.layout.attrs[C.ATTR_vs_position].format = .float2
pipeline.shader = gfx.make_shader(C.sdf_shader_desc(gfx.query_backend()))
pipeline.shader = gfx.make_shader(voidptr(C.sdf_shader_desc(gfx.query_backend())))
state.pip = gfx.make_pipeline(&pipeline)

// No need to clear the window, since the shader will overwrite the whole framebuffer
Expand Down
7 changes: 4 additions & 3 deletions vlib/gg/gg.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -799,16 +799,17 @@ pub fn screen_size() Size {
if output_info == unsafe { nil } {
return Size{}
}
defer { C.XRRFreeOutputInfo(output_info) }
crtc_info := C.XRRGetCrtcInfo(display, resources, output_info.crtc)
C.XRRFreeOutputInfo(output_info)
if crtc_info == unsafe { nil } {
return Size{}
}
defer { C.XRRFreeCrtcInfo(crtc_info) }
return Size{
res := Size{
width: unsafe { int(crtc_info.width) }
height: unsafe { int(crtc_info.height) }
}
C.XRRFreeCrtcInfo(crtc_info)
return res
}
}
}
Expand Down
Loading

0 comments on commit 0ffc33a

Please sign in to comment.