mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
sokol: upgrade to latest version, fix all related issues
This commit is contained in:
parent
756075380b
commit
0bf85d049e
36 changed files with 8304 additions and 8096 deletions
2
.github/workflows/other_ci.yml
vendored
2
.github/workflows/other_ci.yml
vendored
|
@ -101,7 +101,7 @@ jobs:
|
||||||
|
|
||||||
- name: Shader examples can be build
|
- name: Shader examples can be build
|
||||||
run: |
|
run: |
|
||||||
wget https://github.com/floooh/sokol-tools-bin/raw/33d2e4cc26088c6c28eaef5467990f8940d15aab/bin/linux/sokol-shdc
|
wget https://github.com/floooh/sokol-tools-bin/raw/6040b18d39649d56dbae2ae1aed59fb755b26369/bin/linux/sokol-shdc
|
||||||
chmod +x ./sokol-shdc
|
chmod +x ./sokol-shdc
|
||||||
for f in examples/sokol/02_cubes_glsl/cube_glsl \
|
for f in examples/sokol/02_cubes_glsl/cube_glsl \
|
||||||
examples/sokol/03_march_tracing_glsl/rt_glsl \
|
examples/sokol/03_march_tracing_glsl/rt_glsl \
|
||||||
|
|
|
@ -13,13 +13,14 @@
|
||||||
// The shader language used is, as described on the overview page linked above, an 'annotated GLSL'
|
// The shader language used is, as described on the overview page linked above, an 'annotated GLSL'
|
||||||
// and 'modern GLSL' (v450) shader language format.
|
// and 'modern GLSL' (v450) shader language format.
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
import io.util
|
import io.util
|
||||||
import flag
|
import flag
|
||||||
import net.http
|
import net.http
|
||||||
|
|
||||||
const (
|
const (
|
||||||
shdc_full_hash = '33d2e4cc26088c6c28eaef5467990f8940d15aab'
|
shdc_full_hash = '6040b18d39649d56dbae2ae1aed59fb755b26369'
|
||||||
tool_version = '0.0.1'
|
tool_version = '0.0.2'
|
||||||
tool_description = "Compile shaders in sokol's annotated GLSL format to C headers for use with sokol based apps"
|
tool_description = "Compile shaders in sokol's annotated GLSL format to C headers for use with sokol based apps"
|
||||||
tool_name = os.file_name(os.executable())
|
tool_name = os.file_name(os.executable())
|
||||||
cache_dir = os.join_path(os.cache_dir(), 'v', tool_name)
|
cache_dir = os.join_path(os.cache_dir(), 'v', tool_name)
|
||||||
|
@ -29,15 +30,15 @@ const (
|
||||||
const (
|
const (
|
||||||
supported_hosts = ['linux', 'macos', 'windows']
|
supported_hosts = ['linux', 'macos', 'windows']
|
||||||
supported_slangs = [
|
supported_slangs = [
|
||||||
'glsl330', // desktop GL
|
'glsl330', // desktop OpenGL backend (SOKOL_GLCORE33)
|
||||||
'glsl100', // GLES2 / WebGL
|
'glsl100', // OpenGLES2 and WebGL (SOKOL_GLES3)
|
||||||
'glsl300es', // GLES3 / WebGL2
|
'glsl300es', // OpenGLES3 and WebGL2 (SOKOL_GLES3)
|
||||||
'hlsl4', // D3D11
|
'hlsl4', // Direct3D11 with HLSL4 (SOKOL_D3D11)
|
||||||
'hlsl5', // D3D11
|
'hlsl5', // Direct3D11 with HLSL5 (SOKOL_D3D11)
|
||||||
'metal_macos', // Metal on macOS
|
'metal_macos', // Metal on macOS (SOKOL_METAL)
|
||||||
'metal_ios', // Metal on iOS device
|
'metal_ios', // Metal on iOS devices (SOKOL_METAL)
|
||||||
'metal_sim', // Metal on iOS simulator
|
'metal_sim', // Metal on iOS simulator (SOKOL_METAL)
|
||||||
'wgpu', // WebGPU
|
'wgsl', // WebGPU (SOKOL_WGPU)
|
||||||
]
|
]
|
||||||
default_slangs = [
|
default_slangs = [
|
||||||
'glsl330',
|
'glsl330',
|
||||||
|
@ -48,7 +49,7 @@ const (
|
||||||
'metal_macos',
|
'metal_macos',
|
||||||
'metal_ios',
|
'metal_ios',
|
||||||
'metal_sim',
|
'metal_sim',
|
||||||
'wgpu',
|
'wgsl',
|
||||||
]
|
]
|
||||||
|
|
||||||
shdc_version = shdc_full_hash[0..8]
|
shdc_version = shdc_full_hash[0..8]
|
||||||
|
@ -56,6 +57,7 @@ const (
|
||||||
'windows': 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash}/bin/win32/sokol-shdc.exe'
|
'windows': 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash}/bin/win32/sokol-shdc.exe'
|
||||||
'macos': 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash}/bin/osx/sokol-shdc'
|
'macos': 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash}/bin/osx/sokol-shdc'
|
||||||
'linux': 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash}/bin/linux/sokol-shdc'
|
'linux': 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash}/bin/linux/sokol-shdc'
|
||||||
|
'osx_a64': 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash}/bin/osx_arm64/sokol-shdc'
|
||||||
}
|
}
|
||||||
shdc_version_file = os.join_path(cache_dir, 'sokol-shdc.version')
|
shdc_version_file = os.join_path(cache_dir, 'sokol-shdc.version')
|
||||||
shdc = shdc_exe()
|
shdc = shdc_exe()
|
||||||
|
@ -242,11 +244,20 @@ fn ensure_external_tools(opt Options) ! {
|
||||||
|
|
||||||
is_shdc_available := os.is_file(shdc)
|
is_shdc_available := os.is_file(shdc)
|
||||||
is_shdc_executable := os.is_executable(shdc)
|
is_shdc_executable := os.is_executable(shdc)
|
||||||
if is_shdc_available && is_shdc_executable {
|
if opt.verbose {
|
||||||
if opt.verbose {
|
eprintln('reading version from ${shdc_version_file} ...')
|
||||||
version := os.read_file(shdc_version_file) or { 'unknown' }
|
version := os.read_file(shdc_version_file) or { 'unknown' }
|
||||||
eprintln('${tool_name} using sokol-shdc version ${version} at "${shdc}"')
|
eprintln('${tool_name} using sokol-shdc version ${version} at "${shdc}"')
|
||||||
|
eprintln('executable: ${is_shdc_executable}')
|
||||||
|
eprintln(' available: ${is_shdc_available}')
|
||||||
|
if is_shdc_available {
|
||||||
|
eprintln(' file path: ${shdc}')
|
||||||
|
eprintln(' file size: ${os.file_size(shdc)}')
|
||||||
|
eprintln(' file time: ${time.unix_microsecond(os.file_last_mod_unix(shdc),
|
||||||
|
0)}')
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if is_shdc_available && is_shdc_executable {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,15 +274,24 @@ fn shdc_exe() string {
|
||||||
// download_shdc downloads the `sokol-shdc` tool to an OS specific cache directory.
|
// download_shdc downloads the `sokol-shdc` tool to an OS specific cache directory.
|
||||||
fn download_shdc(opt Options) ! {
|
fn download_shdc(opt Options) ! {
|
||||||
// We want to use the same, runtime, OS type as this tool is invoked on.
|
// We want to use the same, runtime, OS type as this tool is invoked on.
|
||||||
download_url := shdc_urls[runtime_os] or { '' }
|
mut download_url := shdc_urls[runtime_os] or { '' }
|
||||||
|
$if arm64 && macos {
|
||||||
|
download_url = shdc_urls['osx_a64']
|
||||||
|
}
|
||||||
if download_url == '' {
|
if download_url == '' {
|
||||||
return error('${tool_name} failed to download an external dependency "sokol-shdc" for ${runtime_os}.\nThe supported host platforms for shader compilation is ${supported_hosts}')
|
return error('${tool_name} failed to download an external dependency "sokol-shdc" for ${runtime_os}.\nThe supported host platforms for shader compilation is ${supported_hosts}')
|
||||||
}
|
}
|
||||||
|
if opt.verbose {
|
||||||
|
eprintln('> reading version from ${shdc_version_file} ...')
|
||||||
|
}
|
||||||
update_to_shdc_version := os.read_file(shdc_version_file) or { shdc_version }
|
update_to_shdc_version := os.read_file(shdc_version_file) or { shdc_version }
|
||||||
|
if opt.verbose {
|
||||||
|
eprintln('> update_to_shdc_version: ${update_to_shdc_version} | shdc_version: ${shdc_version}')
|
||||||
|
}
|
||||||
file := shdc_exe()
|
file := shdc_exe()
|
||||||
if opt.verbose {
|
if opt.verbose {
|
||||||
if shdc_version != update_to_shdc_version && os.exists(file) {
|
if shdc_version != update_to_shdc_version && os.exists(file) {
|
||||||
eprintln('${tool_name} updating sokol-shdc to version ${update_to_shdc_version} ...')
|
eprintln('${tool_name} updating sokol-shdc to version ${shdc_version} ...')
|
||||||
} else {
|
} else {
|
||||||
eprintln('${tool_name} installing sokol-shdc version ${update_to_shdc_version} ...')
|
eprintln('${tool_name} installing sokol-shdc version ${update_to_shdc_version} ...')
|
||||||
}
|
}
|
||||||
|
@ -298,5 +318,5 @@ fn download_shdc(opt Options) ! {
|
||||||
os.mv(file, shdc)!
|
os.mv(file, shdc)!
|
||||||
}
|
}
|
||||||
// Update internal version file
|
// Update internal version file
|
||||||
os.write_file(shdc_version_file, update_to_shdc_version)!
|
os.write_file(shdc_version_file, shdc_version)!
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,11 +45,11 @@ fn create_texture(w int, h int, buf &u8) gfx.Image {
|
||||||
width: w
|
width: w
|
||||||
height: h
|
height: h
|
||||||
num_mipmaps: 0
|
num_mipmaps: 0
|
||||||
min_filter: .linear
|
// min_filter: .linear
|
||||||
mag_filter: .linear
|
// mag_filter: .linear
|
||||||
// usage: .dynamic
|
// usage: .dynamic
|
||||||
wrap_u: .clamp_to_edge
|
// wrap_u: .clamp_to_edge
|
||||||
wrap_v: .clamp_to_edge
|
// wrap_v: .clamp_to_edge
|
||||||
label: &u8(0)
|
label: &u8(0)
|
||||||
d3d11_texture: 0
|
d3d11_texture: 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,11 +61,11 @@ fn create_texture(w int, h int, buf &byte) gfx.Image {
|
||||||
width: w
|
width: w
|
||||||
height: h
|
height: h
|
||||||
num_mipmaps: 0
|
num_mipmaps: 0
|
||||||
min_filter: .linear
|
// min_filter: .linear
|
||||||
mag_filter: .linear
|
// mag_filter: .linear
|
||||||
// usage: .dynamic
|
// usage: .dynamic
|
||||||
wrap_u: .clamp_to_edge
|
// wrap_u: .clamp_to_edge
|
||||||
wrap_v: .clamp_to_edge
|
// wrap_v: .clamp_to_edge
|
||||||
label: &u8(0)
|
label: &u8(0)
|
||||||
d3d11_texture: 0
|
d3d11_texture: 0
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,7 @@ fn init_cube_glsl(mut app App) {
|
||||||
|
|
||||||
app.cube_bind.vertex_buffers[0] = vbuf
|
app.cube_bind.vertex_buffers[0] = vbuf
|
||||||
app.cube_bind.index_buffer = ibuf
|
app.cube_bind.index_buffer = ibuf
|
||||||
app.cube_bind.fs_images[C.SLOT_tex] = app.texture
|
app.cube_bind.fs.images[C.SLOT_tex] = app.texture
|
||||||
app.cube_pip_glsl = gfx.make_pipeline(&pipdesc)
|
app.cube_pip_glsl = gfx.make_pipeline(&pipdesc)
|
||||||
println('GLSL init DONE!')
|
println('GLSL init DONE!')
|
||||||
}
|
}
|
||||||
|
@ -374,8 +374,8 @@ fn draw_cube_glsl(app App) {
|
||||||
// clear
|
// clear
|
||||||
ws := gg.window_size_real_pixels()
|
ws := gg.window_size_real_pixels()
|
||||||
mut color_action := gfx.ColorAttachmentAction{
|
mut color_action := gfx.ColorAttachmentAction{
|
||||||
action: unsafe { gfx.Action(C.SG_ACTION_DONTCARE) } // C.SG_ACTION_CLEAR)
|
load_action: unsafe { gfx.Action(C.SG_LOADACTION_DONTCARE) } // C.SG_ACTION_CLEAR)
|
||||||
value: gfx.Color{
|
clear_value: gfx.Color{
|
||||||
r: 1.0
|
r: 1.0
|
||||||
g: 1.0
|
g: 1.0
|
||||||
b: 1.0
|
b: 1.0
|
||||||
|
|
|
@ -60,11 +60,11 @@ fn create_texture(w int, h int, buf &byte) gfx.Image {
|
||||||
width: w
|
width: w
|
||||||
height: h
|
height: h
|
||||||
num_mipmaps: 0
|
num_mipmaps: 0
|
||||||
min_filter: .linear
|
// min_filter: .linear
|
||||||
mag_filter: .linear
|
// mag_filter: .linear
|
||||||
// usage: .dynamic
|
// usage: .dynamic
|
||||||
wrap_u: .clamp_to_edge
|
// wrap_u: .clamp_to_edge
|
||||||
wrap_v: .clamp_to_edge
|
// wrap_v: .clamp_to_edge
|
||||||
label: &u8(0)
|
label: &u8(0)
|
||||||
d3d11_texture: 0
|
d3d11_texture: 0
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ fn init_cube_glsl(mut app App) {
|
||||||
|
|
||||||
app.cube_bind.vertex_buffers[0] = vbuf
|
app.cube_bind.vertex_buffers[0] = vbuf
|
||||||
app.cube_bind.index_buffer = ibuf
|
app.cube_bind.index_buffer = ibuf
|
||||||
app.cube_bind.fs_images[C.SLOT_tex] = app.texture
|
app.cube_bind.fs.images[C.SLOT_tex] = app.texture
|
||||||
app.cube_pip_glsl = gfx.make_pipeline(&pipdesc)
|
app.cube_pip_glsl = gfx.make_pipeline(&pipdesc)
|
||||||
println('GLSL init DONE!')
|
println('GLSL init DONE!')
|
||||||
}
|
}
|
||||||
|
@ -312,8 +312,8 @@ fn frame(mut app App) {
|
||||||
|
|
||||||
// clear
|
// clear
|
||||||
mut color_action := gfx.ColorAttachmentAction{
|
mut color_action := gfx.ColorAttachmentAction{
|
||||||
action: .clear
|
load_action: .clear
|
||||||
value: gfx.Color{
|
clear_value: gfx.Color{
|
||||||
r: 0.0
|
r: 0.0
|
||||||
g: 0.0
|
g: 0.0
|
||||||
b: 0.0
|
b: 0.0
|
||||||
|
|
|
@ -63,11 +63,11 @@ fn create_texture(w int, h int, buf byteptr) gfx.Image {
|
||||||
width: w
|
width: w
|
||||||
height: h
|
height: h
|
||||||
num_mipmaps: 0
|
num_mipmaps: 0
|
||||||
min_filter: .linear
|
// min_filter: .linear
|
||||||
mag_filter: .linear
|
// mag_filter: .linear
|
||||||
// usage: .dynamic
|
// usage: .dynamic
|
||||||
wrap_u: .clamp_to_edge
|
// wrap_u: .clamp_to_edge
|
||||||
wrap_v: .clamp_to_edge
|
// wrap_v: .clamp_to_edge
|
||||||
label: &u8(0)
|
label: &u8(0)
|
||||||
d3d11_texture: 0
|
d3d11_texture: 0
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ fn init_cube_glsl_m(mut app App) {
|
||||||
unsafe { vmemset(&bind, 0, int(sizeof(bind))) }
|
unsafe { vmemset(&bind, 0, int(sizeof(bind))) }
|
||||||
bind.vertex_buffers[0] = vbuf
|
bind.vertex_buffers[0] = vbuf
|
||||||
bind.index_buffer = ibuf
|
bind.index_buffer = ibuf
|
||||||
bind.fs_images[C.SLOT_tex] = app.texture
|
bind.fs.images[C.SLOT_tex] = app.texture
|
||||||
app.bind['march'] = bind
|
app.bind['march'] = bind
|
||||||
|
|
||||||
app.pipe['march'] = gfx.make_pipeline(&pipdesc)
|
app.pipe['march'] = gfx.make_pipeline(&pipdesc)
|
||||||
|
@ -342,7 +342,7 @@ fn init_cube_glsl_p(mut app App) {
|
||||||
unsafe { vmemset(&bind, 0, int(sizeof(bind))) }
|
unsafe { vmemset(&bind, 0, int(sizeof(bind))) }
|
||||||
bind.vertex_buffers[0] = vbuf
|
bind.vertex_buffers[0] = vbuf
|
||||||
bind.index_buffer = ibuf
|
bind.index_buffer = ibuf
|
||||||
bind.fs_images[C.SLOT_tex] = app.texture
|
bind.fs.images[C.SLOT_tex] = app.texture
|
||||||
app.bind['puppy'] = bind
|
app.bind['puppy'] = bind
|
||||||
|
|
||||||
app.pipe['puppy'] = gfx.make_pipeline(&pipdesc)
|
app.pipe['puppy'] = gfx.make_pipeline(&pipdesc)
|
||||||
|
@ -501,8 +501,8 @@ fn frame(mut app App) {
|
||||||
|
|
||||||
// clear
|
// clear
|
||||||
mut color_action := gfx.ColorAttachmentAction{
|
mut color_action := gfx.ColorAttachmentAction{
|
||||||
action: .clear
|
load_action: .clear
|
||||||
value: gfx.Color{
|
clear_value: gfx.Color{
|
||||||
r: 0.0
|
r: 0.0
|
||||||
g: 0.0
|
g: 0.0
|
||||||
b: 0.0
|
b: 0.0
|
||||||
|
|
|
@ -71,11 +71,11 @@ fn create_texture(w int, h int, buf byteptr) gfx.Image {
|
||||||
width: w
|
width: w
|
||||||
height: h
|
height: h
|
||||||
num_mipmaps: 0
|
num_mipmaps: 0
|
||||||
min_filter: .linear
|
// min_filter: .linear
|
||||||
mag_filter: .linear
|
// mag_filter: .linear
|
||||||
//usage: .dynamic
|
//usage: .dynamic
|
||||||
wrap_u: .clamp_to_edge
|
// wrap_u: .clamp_to_edge
|
||||||
wrap_v: .clamp_to_edge
|
// wrap_v: .clamp_to_edge
|
||||||
label: &u8(0)
|
label: &u8(0)
|
||||||
d3d11_texture: 0
|
d3d11_texture: 0
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ fn init_cube_glsl_i(mut app App) {
|
||||||
bind.vertex_buffers[0] = vbuf // vertex buffer
|
bind.vertex_buffers[0] = vbuf // vertex buffer
|
||||||
bind.vertex_buffers[1] = inst_buf // instance buffer
|
bind.vertex_buffers[1] = inst_buf // instance buffer
|
||||||
bind.index_buffer = ibuf
|
bind.index_buffer = ibuf
|
||||||
bind.fs_images[C.SLOT_tex] = app.texture
|
bind.fs.images[C.SLOT_tex] = app.texture
|
||||||
app.bind['inst'] = bind
|
app.bind['inst'] = bind
|
||||||
app.pipe['inst'] = gfx.make_pipeline(&pipdesc)
|
app.pipe['inst'] = gfx.make_pipeline(&pipdesc)
|
||||||
|
|
||||||
|
@ -384,8 +384,8 @@ fn frame(mut app App) {
|
||||||
|
|
||||||
// clear
|
// clear
|
||||||
mut color_action := gfx.ColorAttachmentAction{
|
mut color_action := gfx.ColorAttachmentAction{
|
||||||
action: .clear
|
load_action: .clear
|
||||||
value: gfx.Color{
|
clear_value: gfx.Color{
|
||||||
r: 0.0
|
r: 0.0
|
||||||
g: 0.0
|
g: 0.0
|
||||||
b: 0.0
|
b: 0.0
|
||||||
|
|
|
@ -24,11 +24,11 @@ pub fn create_texture(w int, h int, buf &u8) gfx.Image {
|
||||||
width: w
|
width: w
|
||||||
height: h
|
height: h
|
||||||
num_mipmaps: 0
|
num_mipmaps: 0
|
||||||
min_filter: .linear
|
// min_filter: .linear
|
||||||
mag_filter: .linear
|
// mag_filter: .linear
|
||||||
// usage: .dynamic
|
// usage: .dynamic
|
||||||
wrap_u: .clamp_to_edge
|
// wrap_u: .clamp_to_edge
|
||||||
wrap_v: .clamp_to_edge
|
// wrap_v: .clamp_to_edge
|
||||||
label: &u8(0)
|
label: &u8(0)
|
||||||
d3d11_texture: 0
|
d3d11_texture: 0
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ pub fn (mut obj_part ObjPart) create_pipeline(in_part []int, shader gfx.Shader,
|
||||||
|
|
||||||
res.bind.vertex_buffers[0] = vbuf
|
res.bind.vertex_buffers[0] = vbuf
|
||||||
res.bind.index_buffer = ibuf
|
res.bind.index_buffer = ibuf
|
||||||
res.bind.fs_images[C.SLOT_tex] = texture
|
res.bind.fs.images[C.SLOT_tex] = texture
|
||||||
res.pipeline = gfx.make_pipeline(&pipdesc)
|
res.pipeline = gfx.make_pipeline(&pipdesc)
|
||||||
// println('Buffers part [$in_part] init done!')
|
// println('Buffers part [$in_part] init done!')
|
||||||
|
|
||||||
|
|
|
@ -150,8 +150,8 @@ fn frame(mut app App) {
|
||||||
|
|
||||||
// clear
|
// clear
|
||||||
mut color_action := gfx.ColorAttachmentAction{
|
mut color_action := gfx.ColorAttachmentAction{
|
||||||
action: .clear
|
load_action: .clear
|
||||||
value: gfx.Color{
|
clear_value: gfx.Color{
|
||||||
r: 0.0
|
r: 0.0
|
||||||
g: 0.0
|
g: 0.0
|
||||||
b: 0.0
|
b: 0.0
|
||||||
|
|
|
@ -15,8 +15,8 @@ mut:
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
mut color_action := gfx.ColorAttachmentAction{
|
mut color_action := gfx.ColorAttachmentAction{
|
||||||
action: .clear
|
load_action: .clear
|
||||||
value: gfx.Color{
|
clear_value: gfx.Color{
|
||||||
r: 0.3
|
r: 0.3
|
||||||
g: 0.3
|
g: 0.3
|
||||||
b: 0.32
|
b: 0.32
|
||||||
|
|
|
@ -63,8 +63,8 @@ mut:
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
mut color_action := gfx.ColorAttachmentAction{
|
mut color_action := gfx.ColorAttachmentAction{
|
||||||
action: .clear
|
load_action: .clear
|
||||||
value: gfx.Color{
|
clear_value: gfx.Color{
|
||||||
r: 1.0
|
r: 1.0
|
||||||
g: 1.0
|
g: 1.0
|
||||||
b: 1.0
|
b: 1.0
|
||||||
|
|
|
@ -121,11 +121,11 @@ fn create_texture(w int, h int, buf &u8) gfx.Image {
|
||||||
width: w
|
width: w
|
||||||
height: h
|
height: h
|
||||||
num_mipmaps: 0
|
num_mipmaps: 0
|
||||||
min_filter: .linear
|
// min_filter: .linear
|
||||||
mag_filter: .linear
|
// mag_filter: .linear
|
||||||
// usage: .dynamic
|
// usage: .dynamic
|
||||||
wrap_u: .clamp_to_edge
|
// wrap_u: .clamp_to_edge
|
||||||
wrap_v: .clamp_to_edge
|
// wrap_v: .clamp_to_edge
|
||||||
label: &u8(0)
|
label: &u8(0)
|
||||||
d3d11_texture: 0
|
d3d11_texture: 0
|
||||||
}
|
}
|
||||||
|
|
2365
thirdparty/sokol/sokol_app.h
vendored
2365
thirdparty/sokol/sokol_app.h
vendored
File diff suppressed because it is too large
Load diff
1216
thirdparty/sokol/sokol_audio.h
vendored
1216
thirdparty/sokol/sokol_audio.h
vendored
File diff suppressed because it is too large
Load diff
8396
thirdparty/sokol/sokol_gfx.h
vendored
8396
thirdparty/sokol/sokol_gfx.h
vendored
File diff suppressed because it is too large
Load diff
1917
thirdparty/sokol/util/sokol_fontstash.h
vendored
1917
thirdparty/sokol/util/sokol_fontstash.h
vendored
File diff suppressed because it is too large
Load diff
2121
thirdparty/sokol/util/sokol_gl.h
vendored
2121
thirdparty/sokol/util/sokol_gl.h
vendored
File diff suppressed because it is too large
Load diff
|
@ -452,7 +452,7 @@ pub fn new_context(cfg Config) &Context {
|
||||||
init_userdata_cb: gg_init_sokol_window
|
init_userdata_cb: gg_init_sokol_window
|
||||||
frame_userdata_cb: gg_frame_fn
|
frame_userdata_cb: gg_frame_fn
|
||||||
event_userdata_cb: gg_event_fn
|
event_userdata_cb: gg_event_fn
|
||||||
fail_userdata_cb: gg_fail_fn
|
// fail_userdata_cb: gg_fail_fn
|
||||||
cleanup_userdata_cb: gg_cleanup_fn
|
cleanup_userdata_cb: gg_cleanup_fn
|
||||||
window_title: &char(cfg.window_title.str)
|
window_title: &char(cfg.window_title.str)
|
||||||
html5_canvas_name: &char(cfg.html5_canvas_name.str)
|
html5_canvas_name: &char(cfg.html5_canvas_name.str)
|
||||||
|
@ -533,20 +533,20 @@ pub struct EndOptions {
|
||||||
const dontcare_pass = gfx.PassAction{
|
const dontcare_pass = gfx.PassAction{
|
||||||
colors: [
|
colors: [
|
||||||
gfx.ColorAttachmentAction{
|
gfx.ColorAttachmentAction{
|
||||||
action: .dontcare
|
load_action: .dontcare
|
||||||
value: gfx.Color{1.0, 1.0, 1.0, 1.0}
|
clear_value: gfx.Color{1.0, 1.0, 1.0, 1.0}
|
||||||
},
|
},
|
||||||
gfx.ColorAttachmentAction{
|
gfx.ColorAttachmentAction{
|
||||||
action: .dontcare
|
load_action: .dontcare
|
||||||
value: gfx.Color{1.0, 1.0, 1.0, 1.0}
|
clear_value: gfx.Color{1.0, 1.0, 1.0, 1.0}
|
||||||
},
|
},
|
||||||
gfx.ColorAttachmentAction{
|
gfx.ColorAttachmentAction{
|
||||||
action: .dontcare
|
load_action: .dontcare
|
||||||
value: gfx.Color{1.0, 1.0, 1.0, 1.0}
|
clear_value: gfx.Color{1.0, 1.0, 1.0, 1.0}
|
||||||
},
|
},
|
||||||
gfx.ColorAttachmentAction{
|
gfx.ColorAttachmentAction{
|
||||||
action: .dontcare
|
load_action: .dontcare
|
||||||
value: gfx.Color{1.0, 1.0, 1.0, 1.0}
|
clear_value: gfx.Color{1.0, 1.0, 1.0, 1.0}
|
||||||
},
|
},
|
||||||
]!
|
]!
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,8 +89,8 @@ pub fn (mut img Image) init_sokol_image() &Image {
|
||||||
width: img.width
|
width: img.width
|
||||||
height: img.height
|
height: img.height
|
||||||
num_mipmaps: 0
|
num_mipmaps: 0
|
||||||
wrap_u: .clamp_to_edge
|
// wrap_u: .clamp_to_edge // XTODO SAMPLER
|
||||||
wrap_v: .clamp_to_edge
|
// wrap_v: .clamp_to_edge
|
||||||
label: img.path.str
|
label: img.path.str
|
||||||
d3d11_texture: 0
|
d3d11_texture: 0
|
||||||
}
|
}
|
||||||
|
@ -142,10 +142,10 @@ pub fn (mut ctx Context) new_streaming_image(w int, h int, channels int, sicfg S
|
||||||
num_slices: 1
|
num_slices: 1
|
||||||
num_mipmaps: 1
|
num_mipmaps: 1
|
||||||
usage: .stream
|
usage: .stream
|
||||||
wrap_u: sicfg.wrap_u
|
// wrap_u: sicfg.wrap_u // SAMPLER
|
||||||
wrap_v: sicfg.wrap_v
|
// wrap_v: sicfg.wrap_v
|
||||||
min_filter: sicfg.min_filter
|
// min_filter: sicfg.min_filter
|
||||||
mag_filter: sicfg.mag_filter
|
// mag_filter: sicfg.mag_filter
|
||||||
label: img.path.str
|
label: img.path.str
|
||||||
}
|
}
|
||||||
// Sokol requires that streamed images have NO .ptr/.size initially:
|
// Sokol requires that streamed images have NO .ptr/.size initially:
|
||||||
|
|
|
@ -36,7 +36,7 @@ $if ios {
|
||||||
}
|
}
|
||||||
|
|
||||||
$if emscripten ? {
|
$if emscripten ? {
|
||||||
#flag -DSOKOL_GLES2
|
#flag -DSOKOL_GLES3
|
||||||
#flag -DSOKOL_NO_ENTRY
|
#flag -DSOKOL_NO_ENTRY
|
||||||
#flag -s ERROR_ON_UNDEFINED_SYMBOLS=0
|
#flag -s ERROR_ON_UNDEFINED_SYMBOLS=0
|
||||||
#flag -s ASSERTIONS=1
|
#flag -s ASSERTIONS=1
|
||||||
|
|
|
@ -2,12 +2,12 @@ module gfx
|
||||||
|
|
||||||
pub enum Backend {
|
pub enum Backend {
|
||||||
glcore33
|
glcore33
|
||||||
gles2
|
|
||||||
gles3
|
gles3
|
||||||
d3d11
|
d3d11
|
||||||
metal_ios
|
metal_ios
|
||||||
metal_macos
|
metal_macos
|
||||||
metal_simulator
|
metal_simulator
|
||||||
|
wgpu
|
||||||
dummy
|
dummy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ pub enum PixelFormat {
|
||||||
rg16si
|
rg16si
|
||||||
rg16f
|
rg16f
|
||||||
rgba8
|
rgba8
|
||||||
|
srgb8a8
|
||||||
rgba8sn
|
rgba8sn
|
||||||
rgba8ui
|
rgba8ui
|
||||||
rgba8si
|
rgba8si
|
||||||
|
|
|
@ -9,16 +9,16 @@ pub const used_import = c.used_import
|
||||||
|
|
||||||
// setup initialises the SOKOL's gfx library, based on the information passed in `desc`
|
// setup initialises the SOKOL's gfx library, based on the information passed in `desc`
|
||||||
pub fn setup(desc &Desc) {
|
pub fn setup(desc &Desc) {
|
||||||
if desc.allocator.alloc == unsafe { nil } && desc.allocator.free == unsafe { nil } {
|
if desc.allocator.alloc_fn == unsafe { nil } && desc.allocator.free_fn == unsafe { nil } {
|
||||||
unsafe {
|
unsafe {
|
||||||
desc.allocator.alloc = memory.salloc
|
desc.allocator.alloc_fn = memory.salloc
|
||||||
desc.allocator.free = memory.sfree
|
desc.allocator.free_fn = memory.sfree
|
||||||
desc.allocator.user_data = voidptr(0x1006fec5)
|
desc.allocator.user_data = voidptr(0x1006fec5)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if desc.logger.log_cb == unsafe { nil } {
|
if desc.logger.func == unsafe { nil } {
|
||||||
unsafe {
|
unsafe {
|
||||||
desc.logger.log_cb = memory.slog
|
desc.logger.func = memory.slog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
C.sg_setup(desc)
|
C.sg_setup(desc)
|
||||||
|
|
|
@ -5,14 +5,14 @@ import sokol.memory
|
||||||
[typedef]
|
[typedef]
|
||||||
pub struct C.sg_allocator {
|
pub struct C.sg_allocator {
|
||||||
pub mut:
|
pub mut:
|
||||||
alloc memory.FnAllocatorAlloc = unsafe { nil }
|
alloc_fn memory.FnAllocatorAlloc = unsafe { nil }
|
||||||
free memory.FnAllocatorFree = unsafe { nil }
|
free_fn memory.FnAllocatorFree = unsafe { nil }
|
||||||
user_data voidptr
|
user_data voidptr
|
||||||
}
|
}
|
||||||
|
|
||||||
[typedef]
|
[typedef]
|
||||||
pub struct C.sg_logger {
|
pub struct C.sg_logger {
|
||||||
pub mut:
|
pub mut:
|
||||||
log_cb memory.FnLogCb = unsafe { nil }
|
func memory.FnLogCb = unsafe { nil }
|
||||||
user_data voidptr
|
user_data voidptr
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub mut:
|
||||||
context_pool_size int
|
context_pool_size int
|
||||||
uniform_buffer_size int
|
uniform_buffer_size int
|
||||||
staging_buffer_size int
|
staging_buffer_size int
|
||||||
sampler_cache_size int
|
sampler_pool_size int
|
||||||
max_commit_listeners int
|
max_commit_listeners int
|
||||||
disable_validation bool // disable validation layer even in debug mode, useful for tests
|
disable_validation bool // disable validation layer even in debug mode, useful for tests
|
||||||
//
|
//
|
||||||
|
@ -61,14 +61,14 @@ struct C.sg_d3d11_context_desc {
|
||||||
|
|
||||||
pub type D3D11ContextDesc = C.sg_d3d11_context_desc
|
pub type D3D11ContextDesc = C.sg_d3d11_context_desc
|
||||||
|
|
||||||
struct C.sg_color_state {
|
struct C.sg_color_target_state {
|
||||||
pub mut:
|
pub mut:
|
||||||
pixel_format PixelFormat
|
pixel_format PixelFormat
|
||||||
write_mask ColorMask
|
write_mask ColorMask
|
||||||
blend BlendState
|
blend BlendState
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ColorState = C.sg_color_state
|
pub type ColorState = C.sg_color_target_state
|
||||||
|
|
||||||
pub struct C.sg_pipeline_desc {
|
pub struct C.sg_pipeline_desc {
|
||||||
pub mut:
|
pub mut:
|
||||||
|
@ -115,19 +115,26 @@ pub mut:
|
||||||
vertex_buffer_offsets [8]int
|
vertex_buffer_offsets [8]int
|
||||||
index_buffer Buffer
|
index_buffer Buffer
|
||||||
index_buffer_offset int
|
index_buffer_offset int
|
||||||
vs_images [8]Image
|
vs C.sg_stage_bindings
|
||||||
fs_images [8]Image
|
fs C.sg_stage_bindings
|
||||||
_end_canary u32
|
// vs_images [8]Image // old
|
||||||
|
// fs_images [8]Image // old
|
||||||
|
_end_canary u32
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct C.sg_stage_bindings {
|
||||||
|
pub mut:
|
||||||
|
images [12]Image
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Bindings = C.sg_bindings
|
pub type Bindings = C.sg_bindings
|
||||||
|
|
||||||
pub fn (mut b Bindings) set_vert_image(index int, img Image) {
|
pub fn (mut b Bindings) set_vert_image(index int, img Image) {
|
||||||
b.vs_images[index] = img
|
b.vs.images[index] = img
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut b Bindings) set_frag_image(index int, img Image) {
|
pub fn (mut b Bindings) set_frag_image(index int, img Image) {
|
||||||
b.fs_images[index] = img
|
b.fs.images[index] = img
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (b &Bindings) update_vert_buffer(index int, data voidptr, element_size int, element_count int) {
|
pub fn (b &Bindings) update_vert_buffer(index int, data voidptr, element_size int, element_count int) {
|
||||||
|
@ -186,13 +193,13 @@ pub fn (mut desc C.sg_shader_desc) set_frag_src(src string) &ShaderDesc {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut desc C.sg_shader_desc) set_vert_image(index int, name string) &ShaderDesc {
|
pub fn (mut desc C.sg_shader_desc) set_vert_image(index int, name string) &ShaderDesc {
|
||||||
desc.vs.images[index].name = &char(name.str)
|
// desc.vs.images[index].name = &char(name.str)
|
||||||
desc.vs.images[index].image_type = ._2d
|
desc.vs.images[index].image_type = ._2d
|
||||||
return desc
|
return desc
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut desc C.sg_shader_desc) set_frag_image(index int, name string) &ShaderDesc {
|
pub fn (mut desc C.sg_shader_desc) set_frag_image(index int, name string) &ShaderDesc {
|
||||||
desc.fs.images[index].name = &char(name.str)
|
// desc.fs.images[index].name = &char(name.str)
|
||||||
desc.fs.images[index].image_type = ._2d
|
desc.fs.images[index].image_type = ._2d
|
||||||
return desc
|
return desc
|
||||||
}
|
}
|
||||||
|
@ -244,7 +251,7 @@ pub mut:
|
||||||
pub type ShaderStageDesc = C.sg_shader_stage_desc
|
pub type ShaderStageDesc = C.sg_shader_stage_desc
|
||||||
|
|
||||||
pub fn (mut desc ShaderStageDesc) set_image(index int, name string) ShaderStageDesc {
|
pub fn (mut desc ShaderStageDesc) set_image(index int, name string) ShaderStageDesc {
|
||||||
desc.images[index].name = &char(name.str)
|
// desc.images[index].name = &char(name.str)
|
||||||
desc.images[index].image_type = ._2d
|
desc.images[index].image_type = ._2d
|
||||||
return *desc
|
return *desc
|
||||||
}
|
}
|
||||||
|
@ -269,7 +276,9 @@ pub type ShaderUniformDesc = C.sg_shader_uniform_desc
|
||||||
|
|
||||||
struct C.sg_shader_image_desc {
|
struct C.sg_shader_image_desc {
|
||||||
pub mut:
|
pub mut:
|
||||||
name &char
|
used bool
|
||||||
|
multisampled bool
|
||||||
|
// name &char
|
||||||
image_type ImageType
|
image_type ImageType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,27 +406,27 @@ pub fn (mut b Buffer) free() {
|
||||||
|
|
||||||
pub struct C.sg_image_desc {
|
pub struct C.sg_image_desc {
|
||||||
pub mut:
|
pub mut:
|
||||||
_start_canary u32
|
_start_canary u32
|
||||||
@type ImageType
|
@type ImageType
|
||||||
render_target bool
|
render_target bool
|
||||||
width int
|
width int
|
||||||
height int
|
height int
|
||||||
num_slices int
|
num_slices int
|
||||||
num_mipmaps int
|
num_mipmaps int
|
||||||
usage Usage
|
usage Usage
|
||||||
pixel_format PixelFormat
|
pixel_format PixelFormat
|
||||||
sample_count int
|
sample_count int
|
||||||
min_filter Filter
|
// min_filter Filter
|
||||||
mag_filter Filter
|
// mag_filter Filter
|
||||||
wrap_u Wrap
|
// wrap_u Wrap
|
||||||
wrap_v Wrap
|
// wrap_v Wrap
|
||||||
wrap_w Wrap
|
// wrap_w Wrap
|
||||||
border_color BorderColor
|
// border_color BorderColor
|
||||||
max_anisotropy u32
|
// max_anisotropy u32
|
||||||
min_lod f32
|
// min_lod f32
|
||||||
max_lod f32
|
// max_lod f32
|
||||||
data ImageData
|
data ImageData
|
||||||
label &char
|
label &char
|
||||||
// GL specific
|
// GL specific
|
||||||
gl_textures [2]u32
|
gl_textures [2]u32
|
||||||
gl_texture_target u32
|
gl_texture_target u32
|
||||||
|
@ -433,6 +442,18 @@ pub mut:
|
||||||
|
|
||||||
pub type ImageDesc = C.sg_image_desc
|
pub type ImageDesc = C.sg_image_desc
|
||||||
|
|
||||||
|
pub struct C.sg_sampler_desc {
|
||||||
|
min_filter Filter
|
||||||
|
mag_filter Filter
|
||||||
|
wrap_u Wrap
|
||||||
|
wrap_v Wrap
|
||||||
|
wrap_w Wrap
|
||||||
|
min_lod f32
|
||||||
|
max_lod f32
|
||||||
|
border_color BorderColor
|
||||||
|
max_anisotropy u32
|
||||||
|
}
|
||||||
|
|
||||||
pub struct C.sg_image_info {
|
pub struct C.sg_image_info {
|
||||||
pub mut:
|
pub mut:
|
||||||
slot SlotInfo // resource pool slot info
|
slot SlotInfo // resource pool slot info
|
||||||
|
@ -454,6 +475,8 @@ pub fn (mut i Image) free() {
|
||||||
C.sg_destroy_image(*i)
|
C.sg_destroy_image(*i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct C.sg_sampler {}
|
||||||
|
|
||||||
pub const sg_cubeface_num = 6
|
pub const sg_cubeface_num = 6
|
||||||
|
|
||||||
pub const sg_max_mipmaps = 16
|
pub const sg_max_mipmaps = 16
|
||||||
|
@ -492,31 +515,31 @@ pub:
|
||||||
|
|
||||||
pub type Limits = C.sg_limits
|
pub type Limits = C.sg_limits
|
||||||
|
|
||||||
pub struct C.sg_layout_desc {
|
pub struct C.sg_vertex_layout_state {
|
||||||
pub mut:
|
pub mut:
|
||||||
buffers [8]BufferLayoutDesc
|
buffers [8]BufferLayoutDesc
|
||||||
attrs [16]VertexAttrDesc
|
attrs [16]VertexAttrDesc
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type LayoutDesc = C.sg_layout_desc
|
pub type LayoutDesc = C.sg_vertex_layout_state
|
||||||
|
|
||||||
pub struct C.sg_buffer_layout_desc {
|
pub struct C.sg_vertex_buffer_layout_state {
|
||||||
pub mut:
|
pub mut:
|
||||||
stride int
|
stride int
|
||||||
step_func VertexStep
|
step_func VertexStep
|
||||||
step_rate int
|
step_rate int
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type BufferLayoutDesc = C.sg_buffer_layout_desc
|
pub type BufferLayoutDesc = C.sg_vertex_buffer_layout_state
|
||||||
|
|
||||||
pub struct C.sg_vertex_attr_desc {
|
pub struct C.sg_vertex_attr_state {
|
||||||
pub mut:
|
pub mut:
|
||||||
buffer_index int
|
buffer_index int
|
||||||
offset int
|
offset int
|
||||||
format VertexFormat
|
format VertexFormat
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type VertexAttrDesc = C.sg_vertex_attr_desc
|
pub type VertexAttrDesc = C.sg_vertex_attr_state
|
||||||
|
|
||||||
struct C.sg_stencil_state {
|
struct C.sg_stencil_state {
|
||||||
enabled bool
|
enabled bool
|
||||||
|
@ -564,8 +587,8 @@ pub type BlendState = C.sg_blend_state
|
||||||
|
|
||||||
struct C.sg_color_attachment_action {
|
struct C.sg_color_attachment_action {
|
||||||
pub mut:
|
pub mut:
|
||||||
action Action
|
load_action Action
|
||||||
value Color
|
clear_value Color
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ColorAttachmentAction = C.sg_color_attachment_action
|
pub type ColorAttachmentAction = C.sg_color_attachment_action
|
||||||
|
|
|
@ -2,8 +2,8 @@ module gfx
|
||||||
|
|
||||||
pub fn create_clear_pass(r f32, g f32, b f32, a f32) PassAction {
|
pub fn create_clear_pass(r f32, g f32, b f32, a f32) PassAction {
|
||||||
mut color_action := ColorAttachmentAction{
|
mut color_action := ColorAttachmentAction{
|
||||||
action: unsafe { Action(C.SG_ACTION_CLEAR) }
|
load_action: Action.clear // unsafe { Action(C.SG_ACTION_CLEAR) }
|
||||||
value: Color{
|
clear_value: Color{
|
||||||
r: r
|
r: r
|
||||||
g: g
|
g: g
|
||||||
b: b
|
b: b
|
||||||
|
|
|
@ -36,6 +36,8 @@ pub fn slog(const_message &char, user_data voidptr) {
|
||||||
C.fprintf(C.stderr, c'sokol.memory.slog | user_data: %p, message: %s\n', user_data,
|
C.fprintf(C.stderr, c'sokol.memory.slog | user_data: %p, message: %s\n', user_data,
|
||||||
const_message)
|
const_message)
|
||||||
}
|
}
|
||||||
|
C.fprintf(C.stderr, c'%s\n', const_message)
|
||||||
|
/*
|
||||||
$if msvc {
|
$if msvc {
|
||||||
C.fprintf(C.stderr, c'%s\n', const_message)
|
C.fprintf(C.stderr, c'%s\n', const_message)
|
||||||
} $else {
|
} $else {
|
||||||
|
@ -43,4 +45,5 @@ pub fn slog(const_message &char, user_data voidptr) {
|
||||||
C.SOKOL_LOG(const_message)
|
C.SOKOL_LOG(const_message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,28 +182,22 @@ pub fn get_clipboard_string() &char {
|
||||||
|
|
||||||
// special run-function for SOKOL_NO_ENTRY (in standard mode this is an empty stub)
|
// special run-function for SOKOL_NO_ENTRY (in standard mode this is an empty stub)
|
||||||
pub fn run(desc &Desc) {
|
pub fn run(desc &Desc) {
|
||||||
if desc.allocator.alloc == unsafe { nil } && desc.allocator.free == unsafe { nil } {
|
if desc.allocator.alloc_fn == unsafe { nil } && desc.allocator.free_fn == unsafe { nil } {
|
||||||
unsafe {
|
unsafe {
|
||||||
desc.allocator.alloc = memory.salloc
|
desc.allocator.alloc_fn = memory.salloc
|
||||||
desc.allocator.free = memory.sfree
|
desc.allocator.free_fn = memory.sfree
|
||||||
desc.allocator.user_data = voidptr(0x10005a44)
|
desc.allocator.user_data = voidptr(0x10005a44)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if desc.logger.log_cb == unsafe { nil } {
|
if desc.logger.func == unsafe { nil } {
|
||||||
unsafe {
|
unsafe {
|
||||||
desc.logger.log_cb = memory.slog
|
desc.logger.func = memory.slog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_desc = *desc
|
g_desc = *desc
|
||||||
C.sapp_run(desc)
|
C.sapp_run(desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GL: return true when GLES2 fallback is active (to detect fallback from GLES3)
|
|
||||||
[inline]
|
|
||||||
pub fn gles2() bool {
|
|
||||||
return C.sapp_gles2()
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTML5: enable or disable the hardwired "Leave Site?" dialog box
|
// HTML5: enable or disable the hardwired "Leave Site?" dialog box
|
||||||
[inline]
|
[inline]
|
||||||
pub fn html5_ask_leave_site(ask bool) {
|
pub fn html5_ask_leave_site(ask bool) {
|
||||||
|
|
|
@ -5,14 +5,14 @@ import sokol.memory
|
||||||
[typedef]
|
[typedef]
|
||||||
pub struct C.sapp_allocator {
|
pub struct C.sapp_allocator {
|
||||||
pub mut:
|
pub mut:
|
||||||
alloc memory.FnAllocatorAlloc = unsafe { nil }
|
alloc_fn memory.FnAllocatorAlloc = unsafe { nil }
|
||||||
free memory.FnAllocatorFree = unsafe { nil }
|
free_fn memory.FnAllocatorFree = unsafe { nil }
|
||||||
user_data voidptr
|
user_data voidptr
|
||||||
}
|
}
|
||||||
|
|
||||||
[typedef]
|
[typedef]
|
||||||
pub struct C.sapp_logger {
|
pub struct C.sapp_logger {
|
||||||
pub mut:
|
pub mut:
|
||||||
log_cb memory.FnLogCb = unsafe { nil }
|
func memory.FnLogCb = unsafe { nil }
|
||||||
user_data voidptr
|
user_data voidptr
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,9 +98,6 @@ fn C.sapp_get_dropped_file_path(int) &u8
|
||||||
// special run-function for SOKOL_NO_ENTRY (in standard mode this is an empty stub)
|
// special run-function for SOKOL_NO_ENTRY (in standard mode this is an empty stub)
|
||||||
fn C.sapp_run(desc &Desc) int
|
fn C.sapp_run(desc &Desc) int
|
||||||
|
|
||||||
// GL: return true when GLES2 fallback is active (to detect fallback from GLES3)
|
|
||||||
fn C.sapp_gles2() bool
|
|
||||||
|
|
||||||
// HTML5: enable or disable the hardwired "Leave Site?" dialog box
|
// HTML5: enable or disable the hardwired "Leave Site?" dialog box
|
||||||
fn C.sapp_html5_ask_leave_site(ask bool)
|
fn C.sapp_html5_ask_leave_site(ask bool)
|
||||||
|
|
||||||
|
|
|
@ -42,14 +42,14 @@ pub:
|
||||||
frame_cb fn () = unsafe { nil }
|
frame_cb fn () = unsafe { nil }
|
||||||
cleanup_cb fn () = unsafe { nil }
|
cleanup_cb fn () = unsafe { nil }
|
||||||
event_cb fn (&Event) = unsafe { nil } // &sapp_event
|
event_cb fn (&Event) = unsafe { nil } // &sapp_event
|
||||||
fail_cb fn (&u8) = unsafe { nil }
|
// fail_cb fn (&u8) = unsafe { nil }
|
||||||
|
|
||||||
user_data voidptr // these are the user-provided callbacks with user data
|
user_data voidptr // these are the user-provided callbacks with user data
|
||||||
init_userdata_cb fn (voidptr) = unsafe { nil }
|
init_userdata_cb fn (voidptr) = unsafe { nil }
|
||||||
frame_userdata_cb fn (voidptr) = unsafe { nil }
|
frame_userdata_cb fn (voidptr) = unsafe { nil }
|
||||||
cleanup_userdata_cb fn (voidptr) = unsafe { nil }
|
cleanup_userdata_cb fn (voidptr) = unsafe { nil }
|
||||||
event_userdata_cb fn (&Event, voidptr) = unsafe { nil }
|
event_userdata_cb fn (&Event, voidptr) = unsafe { nil }
|
||||||
fail_userdata_cb fn (&char, voidptr) = unsafe { nil }
|
// fail_userdata_cb fn (&char, voidptr) = unsafe { nil }
|
||||||
|
|
||||||
width int // the preferred width of the window / canvas
|
width int // the preferred width of the window / canvas
|
||||||
height int // the preferred height of the window / canvas
|
height int // the preferred height of the window / canvas
|
||||||
|
@ -66,7 +66,6 @@ pub:
|
||||||
max_dropped_file_path_length int // max length in bytes of a dropped UTF-8 file path (default: 2048)
|
max_dropped_file_path_length int // max length in bytes of a dropped UTF-8 file path (default: 2048)
|
||||||
icon IconDesc // the initial window icon to set
|
icon IconDesc // the initial window icon to set
|
||||||
// backend-specific options
|
// backend-specific options
|
||||||
gl_force_gles2 bool // if true, setup GLES2/WebGL even if GLES3/WebGL2 is available
|
|
||||||
win32_console_utf8 bool // if true, set the output console codepage to UTF-8
|
win32_console_utf8 bool // if true, set the output console codepage to UTF-8
|
||||||
win32_console_create bool // if true, attach stdout/stderr to a new console window
|
win32_console_create bool // if true, attach stdout/stderr to a new console window
|
||||||
win32_console_attach bool // if true, attach stdout/stderr to parent process
|
win32_console_attach bool // if true, attach stdout/stderr to parent process
|
||||||
|
|
|
@ -13,8 +13,8 @@ pub fn create(width int, height int, flags int) &fontstash.Context {
|
||||||
assert is_power_of_two(width)
|
assert is_power_of_two(width)
|
||||||
assert is_power_of_two(height)
|
assert is_power_of_two(height)
|
||||||
allocator := C.sfons_allocator_t{
|
allocator := C.sfons_allocator_t{
|
||||||
alloc: memory.salloc
|
alloc_fn: memory.salloc
|
||||||
free: memory.sfree
|
free_fn: memory.sfree
|
||||||
user_data: voidptr(0x100005f0)
|
user_data: voidptr(0x100005f0)
|
||||||
}
|
}
|
||||||
desc := C.sfons_desc_t{
|
desc := C.sfons_desc_t{
|
||||||
|
|
|
@ -6,8 +6,8 @@ import sokol.memory
|
||||||
[typedef]
|
[typedef]
|
||||||
pub struct C.sfons_allocator_t {
|
pub struct C.sfons_allocator_t {
|
||||||
pub:
|
pub:
|
||||||
alloc memory.FnAllocatorAlloc = unsafe { nil }
|
alloc_fn memory.FnAllocatorAlloc = unsafe { nil }
|
||||||
free memory.FnAllocatorFree = unsafe { nil }
|
free_fn memory.FnAllocatorFree = unsafe { nil }
|
||||||
user_data voidptr
|
user_data voidptr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,16 +9,16 @@ pub const context = Context{0x00010001} // C.SGL_DEFAULT_CONTEXT = { 0x00010001
|
||||||
|
|
||||||
// setup/shutdown/misc
|
// setup/shutdown/misc
|
||||||
pub fn setup(desc &Desc) {
|
pub fn setup(desc &Desc) {
|
||||||
if desc.allocator.alloc == unsafe { nil } && desc.allocator.free == unsafe { nil } {
|
if desc.allocator.alloc_fn == unsafe { nil } && desc.allocator.free_fn == unsafe { nil } {
|
||||||
unsafe {
|
unsafe {
|
||||||
desc.allocator.alloc = memory.salloc
|
desc.allocator.alloc_fn = memory.salloc
|
||||||
desc.allocator.free = memory.sfree
|
desc.allocator.free_fn = memory.sfree
|
||||||
desc.allocator.user_data = voidptr(0x10000561)
|
desc.allocator.user_data = voidptr(0x10000561)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if desc.logger.log_cb == unsafe { nil } {
|
if desc.logger.func == unsafe { nil } {
|
||||||
unsafe {
|
unsafe {
|
||||||
desc.logger.log_cb = memory.slog
|
desc.logger.func = memory.slog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
C.sgl_setup(desc)
|
C.sgl_setup(desc)
|
||||||
|
@ -123,7 +123,7 @@ pub fn disable_texture() {
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
pub fn texture(img gfx.Image) {
|
pub fn texture(img gfx.Image) {
|
||||||
C.sgl_texture(img)
|
C.sgl_texture(img, C.sg_sampler{}) // TODO need to pass SG_INVALID_ID ?
|
||||||
}
|
}
|
||||||
|
|
||||||
// pipeline stack functions
|
// pipeline stack functions
|
||||||
|
|
|
@ -5,14 +5,14 @@ import sokol.memory
|
||||||
[typedef]
|
[typedef]
|
||||||
pub struct C.sgl_allocator_t {
|
pub struct C.sgl_allocator_t {
|
||||||
pub mut:
|
pub mut:
|
||||||
alloc memory.FnAllocatorAlloc = unsafe { nil }
|
alloc_fn memory.FnAllocatorAlloc = unsafe { nil }
|
||||||
free memory.FnAllocatorFree = unsafe { nil }
|
free_fn memory.FnAllocatorFree = unsafe { nil }
|
||||||
user_data voidptr
|
user_data voidptr
|
||||||
}
|
}
|
||||||
|
|
||||||
[typedef]
|
[typedef]
|
||||||
pub struct C.sgl_logger_t {
|
pub struct C.sgl_logger_t {
|
||||||
pub mut:
|
pub mut:
|
||||||
log_cb memory.FnLogCb = unsafe { nil }
|
func memory.FnLogCb = unsafe { nil }
|
||||||
user_data voidptr
|
user_data voidptr
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ fn C.sgl_scissor_rect(x int, y int, w int, h int, origin_top_left bool)
|
||||||
fn C.sgl_scissor_rectf(x f32, y f32, w f32, h f32, origin_top_left bool)
|
fn C.sgl_scissor_rectf(x f32, y f32, w f32, h f32, origin_top_left bool)
|
||||||
fn C.sgl_enable_texture()
|
fn C.sgl_enable_texture()
|
||||||
fn C.sgl_disable_texture()
|
fn C.sgl_disable_texture()
|
||||||
fn C.sgl_texture(img C.sg_image)
|
fn C.sgl_texture(img C.sg_image, sampler C.sg_sampler)
|
||||||
|
|
||||||
// pipeline stack functions
|
// pipeline stack functions
|
||||||
fn C.sgl_load_default_pipeline()
|
fn C.sgl_load_default_pipeline()
|
||||||
|
|
|
@ -123,11 +123,11 @@ pub fn (mut tf_skl TTF_render_Sokol) create_texture() {
|
||||||
width: w
|
width: w
|
||||||
height: h
|
height: h
|
||||||
num_mipmaps: 0
|
num_mipmaps: 0
|
||||||
min_filter: .linear
|
// min_filter: .linear
|
||||||
mag_filter: .linear
|
// mag_filter: .linear
|
||||||
// usage: .dynamic
|
// usage: .dynamic
|
||||||
wrap_u: .clamp_to_edge
|
// wrap_u: .clamp_to_edge
|
||||||
wrap_v: .clamp_to_edge
|
// wrap_v: .clamp_to_edge
|
||||||
label: &char(0)
|
label: &char(0)
|
||||||
d3d11_texture: 0
|
d3d11_texture: 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue