mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
sokol: fix usage of sokol sampler (#19527)
This commit is contained in:
parent
e19e17f10b
commit
3c68e78f32
24 changed files with 354 additions and 239 deletions
|
@ -39,6 +39,7 @@ struct App {
|
|||
mut:
|
||||
gg &gg.Context = unsafe { nil }
|
||||
texture gfx.Image
|
||||
sampler gfx.Sampler
|
||||
init_flag bool
|
||||
frame_count int
|
||||
|
||||
|
@ -54,7 +55,7 @@ mut:
|
|||
/******************************************************************************
|
||||
* Texture functions
|
||||
******************************************************************************/
|
||||
fn create_texture(w int, h int, buf &byte) gfx.Image {
|
||||
fn create_texture(w int, h int, buf &byte) (gfx.Image, gfx.Sampler) {
|
||||
sz := w * h * 4
|
||||
mut img_desc := gfx.ImageDesc{
|
||||
width: w
|
||||
|
@ -75,7 +76,16 @@ fn create_texture(w int, h int, buf &byte) gfx.Image {
|
|||
}
|
||||
|
||||
sg_img := gfx.make_image(&img_desc)
|
||||
return sg_img
|
||||
|
||||
mut smp_desc := gfx.SamplerDesc{
|
||||
min_filter: .linear
|
||||
mag_filter: .linear
|
||||
wrap_u: .clamp_to_edge
|
||||
wrap_v: .clamp_to_edge
|
||||
}
|
||||
|
||||
sg_smp := gfx.make_sampler(&smp_desc)
|
||||
return sg_img, sg_smp
|
||||
}
|
||||
|
||||
fn destroy_texture(sg_img gfx.Image) {
|
||||
|
@ -224,6 +234,7 @@ fn init_cube_glsl(mut app App) {
|
|||
app.cube_bind.vertex_buffers[0] = vbuf
|
||||
app.cube_bind.index_buffer = ibuf
|
||||
app.cube_bind.fs.images[C.SLOT_tex] = app.texture
|
||||
app.cube_bind.fs.samplers[C.SLOT_smp] = app.sampler
|
||||
app.cube_pip_glsl = gfx.make_pipeline(&pipdesc)
|
||||
println('GLSL init DONE!')
|
||||
}
|
||||
|
@ -377,7 +388,7 @@ fn my_init(mut app App) {
|
|||
}
|
||||
}
|
||||
unsafe {
|
||||
app.texture = create_texture(w, h, tmp_txt)
|
||||
app.texture, app.sampler = create_texture(w, h, tmp_txt)
|
||||
free(tmp_txt)
|
||||
}
|
||||
// glsl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue