diff --git a/README.md b/README.md index 7a475ec..112eed2 100644 --- a/README.md +++ b/README.md @@ -55,13 +55,11 @@ extern "C" fn cleanup() { } fn main() { - let window_title = b"clear\0".as_ptr() as _; - sapp::run(&sapp::Desc { init_cb: Some(init), cleanup_cb: Some(cleanup), frame_cb: Some(frame), - window_title, + window_title: c"clear".as_ptr(), width: 800, height: 600, sample_count: 4, @@ -77,7 +75,7 @@ fn main() { ## Dependencies The Rust compiler and cargo can be installed using [rustup](https://rustup.rs/) -The same dependencies apply as with sokol normally for each platform +The same dependencies apply as with sokol normally for each platform. ## Building with cargo Cargo will compile and link the sokol headers automatically during compilation thanks to the buildscript `build.rs` @@ -85,6 +83,8 @@ Cargo will compile and link the sokol headers automatically during compilation t ## Examples Not all examples have been translated to Rust yet, but you can check the ones that have been in the `examples` directory. +Rust 1.77 or later is required to build the examples. + You can compile all examples using the following command: ```console cargo build --all-targets diff --git a/examples/audio/audio.rs b/examples/audio/audio.rs index 01bb062..bfcfc2e 100644 --- a/examples/audio/audio.rs +++ b/examples/audio/audio.rs @@ -79,7 +79,7 @@ pub fn main() { width: 640, height: 480, icon: sapp::IconDesc { sokol_default: true, ..Default::default() }, - window_title: b"saudio\0".as_ptr() as _, + window_title: c"saudio".as_ptr(), logger: sapp::Logger { func: Some(slog::slog_func), ..Default::default() }, ..Default::default() }); diff --git a/examples/blend/blend.rs b/examples/blend/blend.rs index bcf4ac6..7047159 100644 --- a/examples/blend/blend.rs +++ b/examples/blend/blend.rs @@ -165,8 +165,6 @@ extern "C" fn cleanup() { } fn main() { - let window_title = b"blend\0".as_ptr() as _; - sapp::run(&sapp::Desc { init_cb: Some(init), frame_cb: Some(frame), @@ -174,7 +172,7 @@ fn main() { width: 800, height: 600, sample_count: 4, - window_title, + window_title: c"blend".as_ptr(), logger: sapp::Logger { func: Some(sokol::log::slog_func), ..Default::default() }, icon: sapp::IconDesc { sokol_default: true, ..Default::default() }, ..Default::default() diff --git a/examples/blend/shader.rs b/examples/blend/shader.rs index b11f298..c62e8d7 100644 --- a/examples/blend/shader.rs +++ b/examples/blend/shader.rs @@ -660,39 +660,39 @@ pub fn bg_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { let mut desc = sg::ShaderDesc::new(); match backend { sg::Backend::Glcore33 => { - desc.attrs[0].name = b"position\0".as_ptr() as *const _; + desc.attrs[0].name = c"position".as_ptr(); desc.vs.source = &VS_BG_SOURCE_GLSL330 as *const _ as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.entry = c"main".as_ptr(); desc.fs.source = &FS_BG_SOURCE_GLSL330 as *const _ as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; + desc.fs.entry = c"main".as_ptr(); desc.fs.uniform_blocks[0].size = 16; desc.fs.uniform_blocks[0].layout = sg::UniformLayout::Std140; - desc.fs.uniform_blocks[0].uniforms[0].name = b"bg_fs_params\0".as_ptr() as *const _; + desc.fs.uniform_blocks[0].uniforms[0].name = c"bg_fs_params".as_ptr(); desc.fs.uniform_blocks[0].uniforms[0]._type = sg::UniformType::Float4; desc.fs.uniform_blocks[0].uniforms[0].array_count = 1; - desc.label = b"bg_shader\0".as_ptr() as *const _; + desc.label = c"bg_shader".as_ptr(); }, sg::Backend::D3d11 => { - desc.attrs[0].sem_name = b"TEXCOORD\0".as_ptr() as *const _; + desc.attrs[0].sem_name = c"TEXCOORD".as_ptr(); desc.attrs[0].sem_index = 0; desc.vs.source = &VS_BG_SOURCE_HLSL4 as *const _ as *const _; - desc.vs.d3d11_target = b"vs_4_0\0".as_ptr() as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.d3d11_target = c"vs_4_0".as_ptr(); + desc.vs.entry = c"main".as_ptr(); desc.fs.source = &FS_BG_SOURCE_HLSL4 as *const _ as *const _; - desc.fs.d3d11_target = b"ps_4_0\0".as_ptr() as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; + desc.fs.d3d11_target = c"ps_4_0".as_ptr(); + desc.fs.entry = c"main".as_ptr(); desc.fs.uniform_blocks[0].size = 16; desc.fs.uniform_blocks[0].layout = sg::UniformLayout::Std140; - desc.label = b"bg_shader\0".as_ptr() as *const _; + desc.label = c"bg_shader".as_ptr(); }, sg::Backend::MetalMacos => { desc.vs.source = &VS_BG_SOURCE_METAL_MACOS as *const _ as *const _; - desc.vs.entry = b"main0\0".as_ptr() as *const _; + desc.vs.entry = c"main0".as_ptr(); desc.fs.source = &FS_BG_SOURCE_METAL_MACOS as *const _ as *const _; - desc.fs.entry = b"main0\0".as_ptr() as *const _; + desc.fs.entry = c"main0".as_ptr(); desc.fs.uniform_blocks[0].size = 16; desc.fs.uniform_blocks[0].layout = sg::UniformLayout::Std140; - desc.label = b"bg_shader\0".as_ptr() as *const _; + desc.label = c"bg_shader".as_ptr(); }, _ => {}, } @@ -702,42 +702,42 @@ pub fn quad_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { let mut desc = sg::ShaderDesc::new(); match backend { sg::Backend::Glcore33 => { - desc.attrs[0].name = b"position\0".as_ptr() as *const _; - desc.attrs[1].name = b"color0\0".as_ptr() as *const _; + desc.attrs[0].name = c"position".as_ptr(); + desc.attrs[1].name = c"color0".as_ptr(); desc.vs.source = &VS_QUAD_SOURCE_GLSL330 as *const _ as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.entry = c"main".as_ptr(); desc.vs.uniform_blocks[0].size = 64; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; - desc.vs.uniform_blocks[0].uniforms[0].name = b"quad_vs_params\0".as_ptr() as *const _; + desc.vs.uniform_blocks[0].uniforms[0].name = c"quad_vs_params".as_ptr(); desc.vs.uniform_blocks[0].uniforms[0]._type = sg::UniformType::Float4; desc.vs.uniform_blocks[0].uniforms[0].array_count = 4; desc.fs.source = &FS_QUAD_SOURCE_GLSL330 as *const _ as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; - desc.label = b"quad_shader\0".as_ptr() as *const _; + desc.fs.entry = c"main".as_ptr(); + desc.label = c"quad_shader".as_ptr(); }, sg::Backend::D3d11 => { - desc.attrs[0].sem_name = b"TEXCOORD\0".as_ptr() as *const _; + desc.attrs[0].sem_name = c"TEXCOORD".as_ptr(); desc.attrs[0].sem_index = 0; - desc.attrs[1].sem_name = b"TEXCOORD\0".as_ptr() as *const _; + desc.attrs[1].sem_name = c"TEXCOORD".as_ptr(); desc.attrs[1].sem_index = 1; desc.vs.source = &VS_QUAD_SOURCE_HLSL4 as *const _ as *const _; - desc.vs.d3d11_target = b"vs_4_0\0".as_ptr() as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.d3d11_target = c"vs_4_0".as_ptr(); + desc.vs.entry = c"main".as_ptr(); desc.vs.uniform_blocks[0].size = 64; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; desc.fs.source = &FS_QUAD_SOURCE_HLSL4 as *const _ as *const _; - desc.fs.d3d11_target = b"ps_4_0\0".as_ptr() as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; - desc.label = b"quad_shader\0".as_ptr() as *const _; + desc.fs.d3d11_target = c"ps_4_0".as_ptr(); + desc.fs.entry = c"main".as_ptr(); + desc.label = c"quad_shader".as_ptr(); }, sg::Backend::MetalMacos => { desc.vs.source = &VS_QUAD_SOURCE_METAL_MACOS as *const _ as *const _; - desc.vs.entry = b"main0\0".as_ptr() as *const _; + desc.vs.entry = c"main0".as_ptr(); desc.vs.uniform_blocks[0].size = 64; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; desc.fs.source = &FS_QUAD_SOURCE_METAL_MACOS as *const _ as *const _; - desc.fs.entry = b"main0\0".as_ptr() as *const _; - desc.label = b"quad_shader\0".as_ptr() as *const _; + desc.fs.entry = c"main0".as_ptr(); + desc.label = c"quad_shader".as_ptr(); }, _ => {}, } diff --git a/examples/clear/clear.rs b/examples/clear/clear.rs index faaa4dc..55807dd 100644 --- a/examples/clear/clear.rs +++ b/examples/clear/clear.rs @@ -67,13 +67,11 @@ extern "C" fn cleanup() { } fn main() { - let window_title = b"clear\0".as_ptr() as _; - sapp::run(&sapp::Desc { init_cb: Some(init), cleanup_cb: Some(cleanup), frame_cb: Some(frame), - window_title, + window_title: c"clear".as_ptr(), width: 800, height: 600, sample_count: 4, diff --git a/examples/cube/cube.rs b/examples/cube/cube.rs index 215527d..a2ade41 100644 --- a/examples/cube/cube.rs +++ b/examples/cube/cube.rs @@ -152,8 +152,6 @@ extern "C" fn cleanup() { } fn main() { - let window_title = b"cube\0".as_ptr() as _; - sapp::run(&sapp::Desc { init_cb: Some(init), frame_cb: Some(frame), @@ -161,7 +159,7 @@ fn main() { width: 800, height: 600, sample_count: 4, - window_title, + window_title: c"cube".as_ptr(), logger: sapp::Logger { func: Some(sokol::log::slog_func), ..Default::default() }, icon: sapp::IconDesc { sokol_default: true, ..Default::default() }, diff --git a/examples/cube/shader.rs b/examples/cube/shader.rs index 8bf4c02..ee0c090 100644 --- a/examples/cube/shader.rs +++ b/examples/cube/shader.rs @@ -342,42 +342,42 @@ pub fn cube_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { let mut desc = sg::ShaderDesc::new(); match backend { sg::Backend::Glcore33 => { - desc.attrs[0].name = b"position\0".as_ptr() as *const _; - desc.attrs[1].name = b"color0\0".as_ptr() as *const _; + desc.attrs[0].name = c"position".as_ptr(); + desc.attrs[1].name = c"color0".as_ptr(); desc.vs.source = &VS_SOURCE_GLSL330 as *const _ as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.entry = c"main".as_ptr(); desc.vs.uniform_blocks[0].size = 64; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; - desc.vs.uniform_blocks[0].uniforms[0].name = b"vs_params\0".as_ptr() as *const _; + desc.vs.uniform_blocks[0].uniforms[0].name = c"vs_params".as_ptr(); desc.vs.uniform_blocks[0].uniforms[0]._type = sg::UniformType::Float4; desc.vs.uniform_blocks[0].uniforms[0].array_count = 4; desc.fs.source = &FS_SOURCE_GLSL330 as *const _ as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; - desc.label = b"cube_shader\0".as_ptr() as *const _; + desc.fs.entry = c"main".as_ptr(); + desc.label = c"cube_shader".as_ptr(); }, sg::Backend::D3d11 => { - desc.attrs[0].sem_name = b"TEXCOORD\0".as_ptr() as *const _; + desc.attrs[0].sem_name = c"TEXCOORD".as_ptr(); desc.attrs[0].sem_index = 0; - desc.attrs[1].sem_name = b"TEXCOORD\0".as_ptr() as *const _; + desc.attrs[1].sem_name = c"TEXCOORD".as_ptr(); desc.attrs[1].sem_index = 1; desc.vs.source = &VS_SOURCE_HLSL4 as *const _ as *const _; - desc.vs.d3d11_target = b"vs_4_0\0".as_ptr() as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.d3d11_target = c"vs_4_0".as_ptr(); + desc.vs.entry = c"main".as_ptr(); desc.vs.uniform_blocks[0].size = 64; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; desc.fs.source = &FS_SOURCE_HLSL4 as *const _ as *const _; - desc.fs.d3d11_target = b"ps_4_0\0".as_ptr() as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; - desc.label = b"cube_shader\0".as_ptr() as *const _; + desc.fs.d3d11_target = c"ps_4_0".as_ptr(); + desc.fs.entry = c"main".as_ptr(); + desc.label = c"cube_shader".as_ptr(); }, sg::Backend::MetalMacos => { desc.vs.source = &VS_SOURCE_METAL_MACOS as *const _ as *const _; - desc.vs.entry = b"main0\0".as_ptr() as *const _; + desc.vs.entry = c"main0".as_ptr(); desc.vs.uniform_blocks[0].size = 64; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; desc.fs.source = &FS_SOURCE_METAL_MACOS as *const _ as *const _; - desc.fs.entry = b"main0\0".as_ptr() as *const _; - desc.label = b"cube_shader\0".as_ptr() as *const _; + desc.fs.entry = c"main0".as_ptr(); + desc.label = c"cube_shader".as_ptr(); }, _ => {}, } diff --git a/examples/debugtext/debugtext.rs b/examples/debugtext/debugtext.rs index d20c9b4..69d7cc2 100644 --- a/examples/debugtext/debugtext.rs +++ b/examples/debugtext/debugtext.rs @@ -89,15 +89,13 @@ extern "C" fn cleanup() { } fn main() { - let window_title = b"debugtext\0".as_ptr() as *const _; - sapp::run(&sapp::Desc { init_cb: Some(init), frame_cb: Some(frame), cleanup_cb: Some(cleanup), width: 1024, height: 600, - window_title, + window_title: c"debugtext".as_ptr(), logger: sapp::Logger { func: Some(sokol::log::slog_func), ..Default::default() }, icon: sapp::IconDesc { sokol_default: true, ..Default::default() }, ..Default::default() diff --git a/examples/instancing/instancing.rs b/examples/instancing/instancing.rs index 39c0986..2007d04 100644 --- a/examples/instancing/instancing.rs +++ b/examples/instancing/instancing.rs @@ -187,7 +187,7 @@ fn main() { width: 800, height: 600, sample_count: 4, - window_title: b"instancing\0".as_ptr() as _, + window_title: c"instancing".as_ptr(), icon: sapp::IconDesc { sokol_default: true, ..Default::default() }, logger: sapp::Logger { func: Some(slog::slog_func), ..Default::default() }, ..Default::default() diff --git a/examples/instancing/shader.rs b/examples/instancing/shader.rs index d4a9600..b436fe6 100644 --- a/examples/instancing/shader.rs +++ b/examples/instancing/shader.rs @@ -362,45 +362,45 @@ pub fn instancing_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { let mut desc = sg::ShaderDesc::new(); match backend { sg::Backend::Glcore33 => { - desc.attrs[0].name = b"pos\0".as_ptr() as *const _; - desc.attrs[1].name = b"color0\0".as_ptr() as *const _; - desc.attrs[2].name = b"inst_pos\0".as_ptr() as *const _; + desc.attrs[0].name = c"pos".as_ptr(); + desc.attrs[1].name = c"color0".as_ptr(); + desc.attrs[2].name = c"inst_pos".as_ptr(); desc.vs.source = &VS_SOURCE_GLSL330 as *const _ as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.entry = c"main".as_ptr(); desc.vs.uniform_blocks[0].size = 64; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; - desc.vs.uniform_blocks[0].uniforms[0].name = b"vs_params\0".as_ptr() as *const _; + desc.vs.uniform_blocks[0].uniforms[0].name = c"vs_params".as_ptr(); desc.vs.uniform_blocks[0].uniforms[0]._type = sg::UniformType::Float4; desc.vs.uniform_blocks[0].uniforms[0].array_count = 4; desc.fs.source = &FS_SOURCE_GLSL330 as *const _ as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; - desc.label = b"instancing_shader\0".as_ptr() as *const _; + desc.fs.entry = c"main".as_ptr(); + desc.label = c"instancing_shader".as_ptr(); }, sg::Backend::D3d11 => { - desc.attrs[0].sem_name = b"TEXCOORD\0".as_ptr() as *const _; + desc.attrs[0].sem_name = c"TEXCOORD".as_ptr(); desc.attrs[0].sem_index = 0; - desc.attrs[1].sem_name = b"TEXCOORD\0".as_ptr() as *const _; + desc.attrs[1].sem_name = c"TEXCOORD".as_ptr(); desc.attrs[1].sem_index = 1; - desc.attrs[2].sem_name = b"TEXCOORD\0".as_ptr() as *const _; + desc.attrs[2].sem_name = c"TEXCOORD".as_ptr(); desc.attrs[2].sem_index = 2; desc.vs.source = &VS_SOURCE_HLSL4 as *const _ as *const _; - desc.vs.d3d11_target = b"vs_4_0\0".as_ptr() as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.d3d11_target = c"vs_4_0".as_ptr(); + desc.vs.entry = c"main".as_ptr(); desc.vs.uniform_blocks[0].size = 64; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; desc.fs.source = &FS_SOURCE_HLSL4 as *const _ as *const _; - desc.fs.d3d11_target = b"ps_4_0\0".as_ptr() as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; - desc.label = b"instancing_shader\0".as_ptr() as *const _; + desc.fs.d3d11_target = c"ps_4_0".as_ptr(); + desc.fs.entry = c"main".as_ptr(); + desc.label = c"instancing_shader".as_ptr(); }, sg::Backend::MetalMacos => { desc.vs.source = &VS_SOURCE_METAL_MACOS as *const _ as *const _; - desc.vs.entry = b"main0\0".as_ptr() as *const _; + desc.vs.entry = c"main0".as_ptr(); desc.vs.uniform_blocks[0].size = 64; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; desc.fs.source = &FS_SOURCE_METAL_MACOS as *const _ as *const _; - desc.fs.entry = b"main0\0".as_ptr() as *const _; - desc.label = b"instancing_shader\0".as_ptr() as *const _; + desc.fs.entry = c"main0".as_ptr(); + desc.label = c"instancing_shader".as_ptr(); }, _ => {}, } diff --git a/examples/mrt/mrt.rs b/examples/mrt/mrt.rs index 174420a..6c52276 100644 --- a/examples/mrt/mrt.rs +++ b/examples/mrt/mrt.rs @@ -342,8 +342,6 @@ extern "C" fn cleanup() { } fn main() { - let window_title = b"mrt\0".as_ptr() as _; - sapp::run(&sapp::Desc { init_cb: Some(init), frame_cb: Some(frame), @@ -352,7 +350,7 @@ fn main() { width: 800, height: 600, sample_count: 1, - window_title, + window_title: c"mrt".as_ptr(), logger: sapp::Logger { func: Some(sokol::log::slog_func), ..Default::default() }, icon: sapp::IconDesc { sokol_default: true, ..Default::default() }, diff --git a/examples/mrt/shader.rs b/examples/mrt/shader.rs index 9eaacdb..6403d43 100644 --- a/examples/mrt/shader.rs +++ b/examples/mrt/shader.rs @@ -1191,11 +1191,11 @@ pub fn dbg_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { let mut desc = sg::ShaderDesc::new(); match backend { sg::Backend::Glcore33 => { - desc.attrs[0].name = b"pos\0".as_ptr() as *const _; + desc.attrs[0].name = c"pos".as_ptr(); desc.vs.source = &VS_DBG_SOURCE_GLSL330 as *const _ as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.entry = c"main".as_ptr(); desc.fs.source = &FS_DBG_SOURCE_GLSL330 as *const _ as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; + desc.fs.entry = c"main".as_ptr(); desc.fs.images[0].used = true; desc.fs.images[0].multisampled = false; desc.fs.images[0].image_type = sg::ImageType::Dim2; @@ -1205,18 +1205,18 @@ pub fn dbg_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { desc.fs.image_sampler_pairs[0].used = true; desc.fs.image_sampler_pairs[0].image_slot = 0; desc.fs.image_sampler_pairs[0].sampler_slot = 0; - desc.fs.image_sampler_pairs[0].glsl_name = b"tex_smp\0".as_ptr() as *const _; - desc.label = b"dbg_shader\0".as_ptr() as *const _; + desc.fs.image_sampler_pairs[0].glsl_name = c"tex_smp".as_ptr(); + desc.label = c"dbg_shader".as_ptr(); }, sg::Backend::D3d11 => { - desc.attrs[0].sem_name = b"TEXCOORD\0".as_ptr() as *const _; + desc.attrs[0].sem_name = c"TEXCOORD".as_ptr(); desc.attrs[0].sem_index = 0; desc.vs.source = &VS_DBG_SOURCE_HLSL4 as *const _ as *const _; - desc.vs.d3d11_target = b"vs_4_0\0".as_ptr() as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.d3d11_target = c"vs_4_0".as_ptr(); + desc.vs.entry = c"main".as_ptr(); desc.fs.source = &FS_DBG_SOURCE_HLSL4 as *const _ as *const _; - desc.fs.d3d11_target = b"ps_4_0\0".as_ptr() as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; + desc.fs.d3d11_target = c"ps_4_0".as_ptr(); + desc.fs.entry = c"main".as_ptr(); desc.fs.images[0].used = true; desc.fs.images[0].multisampled = false; desc.fs.images[0].image_type = sg::ImageType::Dim2; @@ -1226,13 +1226,13 @@ pub fn dbg_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { desc.fs.image_sampler_pairs[0].used = true; desc.fs.image_sampler_pairs[0].image_slot = 0; desc.fs.image_sampler_pairs[0].sampler_slot = 0; - desc.label = b"dbg_shader\0".as_ptr() as *const _; + desc.label = c"dbg_shader".as_ptr(); }, sg::Backend::MetalMacos => { desc.vs.source = &VS_DBG_SOURCE_METAL_MACOS as *const _ as *const _; - desc.vs.entry = b"main0\0".as_ptr() as *const _; + desc.vs.entry = c"main0".as_ptr(); desc.fs.source = &FS_DBG_SOURCE_METAL_MACOS as *const _ as *const _; - desc.fs.entry = b"main0\0".as_ptr() as *const _; + desc.fs.entry = c"main0".as_ptr(); desc.fs.images[0].used = true; desc.fs.images[0].multisampled = false; desc.fs.images[0].image_type = sg::ImageType::Dim2; @@ -1242,7 +1242,7 @@ pub fn dbg_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { desc.fs.image_sampler_pairs[0].used = true; desc.fs.image_sampler_pairs[0].image_slot = 0; desc.fs.image_sampler_pairs[0].sampler_slot = 0; - desc.label = b"dbg_shader\0".as_ptr() as *const _; + desc.label = c"dbg_shader".as_ptr(); }, _ => {}, } @@ -1252,16 +1252,16 @@ pub fn fsq_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { let mut desc = sg::ShaderDesc::new(); match backend { sg::Backend::Glcore33 => { - desc.attrs[0].name = b"pos\0".as_ptr() as *const _; + desc.attrs[0].name = c"pos".as_ptr(); desc.vs.source = &VS_FSQ_SOURCE_GLSL330 as *const _ as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.entry = c"main".as_ptr(); desc.vs.uniform_blocks[0].size = 16; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; - desc.vs.uniform_blocks[0].uniforms[0].name = b"fsq_params\0".as_ptr() as *const _; + desc.vs.uniform_blocks[0].uniforms[0].name = c"fsq_params".as_ptr(); desc.vs.uniform_blocks[0].uniforms[0]._type = sg::UniformType::Float4; desc.vs.uniform_blocks[0].uniforms[0].array_count = 1; desc.fs.source = &FS_FSQ_SOURCE_GLSL330 as *const _ as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; + desc.fs.entry = c"main".as_ptr(); desc.fs.images[0].used = true; desc.fs.images[0].multisampled = false; desc.fs.images[0].image_type = sg::ImageType::Dim2; @@ -1279,28 +1279,28 @@ pub fn fsq_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { desc.fs.image_sampler_pairs[0].used = true; desc.fs.image_sampler_pairs[0].image_slot = 0; desc.fs.image_sampler_pairs[0].sampler_slot = 0; - desc.fs.image_sampler_pairs[0].glsl_name = b"tex0_smp\0".as_ptr() as *const _; + desc.fs.image_sampler_pairs[0].glsl_name = c"tex0_smp".as_ptr(); desc.fs.image_sampler_pairs[1].used = true; desc.fs.image_sampler_pairs[1].image_slot = 1; desc.fs.image_sampler_pairs[1].sampler_slot = 0; - desc.fs.image_sampler_pairs[1].glsl_name = b"tex1_smp\0".as_ptr() as *const _; + desc.fs.image_sampler_pairs[1].glsl_name = c"tex1_smp".as_ptr(); desc.fs.image_sampler_pairs[2].used = true; desc.fs.image_sampler_pairs[2].image_slot = 2; desc.fs.image_sampler_pairs[2].sampler_slot = 0; - desc.fs.image_sampler_pairs[2].glsl_name = b"tex2_smp\0".as_ptr() as *const _; - desc.label = b"fsq_shader\0".as_ptr() as *const _; + desc.fs.image_sampler_pairs[2].glsl_name = c"tex2_smp".as_ptr(); + desc.label = c"fsq_shader".as_ptr(); }, sg::Backend::D3d11 => { - desc.attrs[0].sem_name = b"TEXCOORD\0".as_ptr() as *const _; + desc.attrs[0].sem_name = c"TEXCOORD".as_ptr(); desc.attrs[0].sem_index = 0; desc.vs.source = &VS_FSQ_SOURCE_HLSL4 as *const _ as *const _; - desc.vs.d3d11_target = b"vs_4_0\0".as_ptr() as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.d3d11_target = c"vs_4_0".as_ptr(); + desc.vs.entry = c"main".as_ptr(); desc.vs.uniform_blocks[0].size = 16; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; desc.fs.source = &FS_FSQ_SOURCE_HLSL4 as *const _ as *const _; - desc.fs.d3d11_target = b"ps_4_0\0".as_ptr() as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; + desc.fs.d3d11_target = c"ps_4_0".as_ptr(); + desc.fs.entry = c"main".as_ptr(); desc.fs.images[0].used = true; desc.fs.images[0].multisampled = false; desc.fs.images[0].image_type = sg::ImageType::Dim2; @@ -1324,15 +1324,15 @@ pub fn fsq_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { desc.fs.image_sampler_pairs[2].used = true; desc.fs.image_sampler_pairs[2].image_slot = 2; desc.fs.image_sampler_pairs[2].sampler_slot = 0; - desc.label = b"fsq_shader\0".as_ptr() as *const _; + desc.label = c"fsq_shader".as_ptr(); }, sg::Backend::MetalMacos => { desc.vs.source = &VS_FSQ_SOURCE_METAL_MACOS as *const _ as *const _; - desc.vs.entry = b"main0\0".as_ptr() as *const _; + desc.vs.entry = c"main0".as_ptr(); desc.vs.uniform_blocks[0].size = 16; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; desc.fs.source = &FS_FSQ_SOURCE_METAL_MACOS as *const _ as *const _; - desc.fs.entry = b"main0\0".as_ptr() as *const _; + desc.fs.entry = c"main0".as_ptr(); desc.fs.images[0].used = true; desc.fs.images[0].multisampled = false; desc.fs.images[0].image_type = sg::ImageType::Dim2; @@ -1356,7 +1356,7 @@ pub fn fsq_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { desc.fs.image_sampler_pairs[2].used = true; desc.fs.image_sampler_pairs[2].image_slot = 2; desc.fs.image_sampler_pairs[2].sampler_slot = 0; - desc.label = b"fsq_shader\0".as_ptr() as *const _; + desc.label = c"fsq_shader".as_ptr(); }, _ => {}, } @@ -1366,42 +1366,42 @@ pub fn offscreen_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { let mut desc = sg::ShaderDesc::new(); match backend { sg::Backend::Glcore33 => { - desc.attrs[0].name = b"pos\0".as_ptr() as *const _; - desc.attrs[1].name = b"bright0\0".as_ptr() as *const _; + desc.attrs[0].name = c"pos".as_ptr(); + desc.attrs[1].name = c"bright0".as_ptr(); desc.vs.source = &VS_OFFSCREEN_SOURCE_GLSL330 as *const _ as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.entry = c"main".as_ptr(); desc.vs.uniform_blocks[0].size = 64; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; - desc.vs.uniform_blocks[0].uniforms[0].name = b"offscreen_params\0".as_ptr() as *const _; + desc.vs.uniform_blocks[0].uniforms[0].name = c"offscreen_params".as_ptr(); desc.vs.uniform_blocks[0].uniforms[0]._type = sg::UniformType::Float4; desc.vs.uniform_blocks[0].uniforms[0].array_count = 4; desc.fs.source = &FS_OFFSCREEN_SOURCE_GLSL330 as *const _ as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; - desc.label = b"offscreen_shader\0".as_ptr() as *const _; + desc.fs.entry = c"main".as_ptr(); + desc.label = c"offscreen_shader".as_ptr(); }, sg::Backend::D3d11 => { - desc.attrs[0].sem_name = b"TEXCOORD\0".as_ptr() as *const _; + desc.attrs[0].sem_name = c"TEXCOORD".as_ptr(); desc.attrs[0].sem_index = 0; - desc.attrs[1].sem_name = b"TEXCOORD\0".as_ptr() as *const _; + desc.attrs[1].sem_name = c"TEXCOORD".as_ptr(); desc.attrs[1].sem_index = 1; desc.vs.source = &VS_OFFSCREEN_SOURCE_HLSL4 as *const _ as *const _; - desc.vs.d3d11_target = b"vs_4_0\0".as_ptr() as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.d3d11_target = c"vs_4_0".as_ptr(); + desc.vs.entry = c"main".as_ptr(); desc.vs.uniform_blocks[0].size = 64; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; desc.fs.source = &FS_OFFSCREEN_SOURCE_HLSL4 as *const _ as *const _; - desc.fs.d3d11_target = b"ps_4_0\0".as_ptr() as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; - desc.label = b"offscreen_shader\0".as_ptr() as *const _; + desc.fs.d3d11_target = c"ps_4_0".as_ptr(); + desc.fs.entry = c"main".as_ptr(); + desc.label = c"offscreen_shader".as_ptr(); }, sg::Backend::MetalMacos => { desc.vs.source = &VS_OFFSCREEN_SOURCE_METAL_MACOS as *const _ as *const _; - desc.vs.entry = b"main0\0".as_ptr() as *const _; + desc.vs.entry = c"main0".as_ptr(); desc.vs.uniform_blocks[0].size = 64; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; desc.fs.source = &FS_OFFSCREEN_SOURCE_METAL_MACOS as *const _ as *const _; - desc.fs.entry = b"main0\0".as_ptr() as *const _; - desc.label = b"offscreen_shader\0".as_ptr() as *const _; + desc.fs.entry = c"main0".as_ptr(); + desc.label = c"offscreen_shader".as_ptr(); }, _ => {}, } diff --git a/examples/sgl-context/sgl-context.rs b/examples/sgl-context/sgl-context.rs index dd590bd..76622f5 100644 --- a/examples/sgl-context/sgl-context.rs +++ b/examples/sgl-context/sgl-context.rs @@ -209,8 +209,6 @@ extern "C" fn cleanup() { } fn main() { - let window_title = b"sgl-context\0".as_ptr() as *const _; - sapp::run(&sapp::Desc { init_cb: Some(init), frame_cb: Some(frame), @@ -218,7 +216,7 @@ fn main() { width: 800, height: 600, sample_count: 4, - window_title, + window_title: c"sgl-context".as_ptr(), logger: sapp::Logger { func: Some(sokol::log::slog_func), ..Default::default() }, icon: sapp::IconDesc { sokol_default: true, ..Default::default() }, ..Default::default() diff --git a/examples/sgl-points/sgl-points.rs b/examples/sgl-points/sgl-points.rs index 2dd6778..7cd7edf 100644 --- a/examples/sgl-points/sgl-points.rs +++ b/examples/sgl-points/sgl-points.rs @@ -98,8 +98,6 @@ extern "C" fn cleanup() { } fn main() { - let window_title = b"sgl-points\0".as_ptr() as *const _; - sapp::run(&sapp::Desc { init_cb: Some(init), frame_cb: Some(frame), @@ -107,7 +105,7 @@ fn main() { width: 512, height: 512, sample_count: 4, - window_title, + window_title: c"sgl-points".as_ptr(), logger: sapp::Logger { func: Some(sokol::log::slog_func), ..Default::default() }, icon: sapp::IconDesc { sokol_default: true, ..Default::default() }, ..Default::default() diff --git a/examples/texcube/shader.rs b/examples/texcube/shader.rs index fab226a..b24c236 100644 --- a/examples/texcube/shader.rs +++ b/examples/texcube/shader.rs @@ -426,18 +426,18 @@ pub fn texcube_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { let mut desc = sg::ShaderDesc::new(); match backend { sg::Backend::Glcore33 => { - desc.attrs[0].name = b"pos\0".as_ptr() as *const _; - desc.attrs[1].name = b"color0\0".as_ptr() as *const _; - desc.attrs[2].name = b"texcoord0\0".as_ptr() as *const _; + desc.attrs[0].name = c"pos".as_ptr(); + desc.attrs[1].name = c"color0".as_ptr(); + desc.attrs[2].name = c"texcoord0".as_ptr(); desc.vs.source = &VS_SOURCE_GLSL330 as *const _ as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.entry = c"main".as_ptr(); desc.vs.uniform_blocks[0].size = 64; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; - desc.vs.uniform_blocks[0].uniforms[0].name = b"vs_params\0".as_ptr() as *const _; + desc.vs.uniform_blocks[0].uniforms[0].name = c"vs_params".as_ptr(); desc.vs.uniform_blocks[0].uniforms[0]._type = sg::UniformType::Float4; desc.vs.uniform_blocks[0].uniforms[0].array_count = 4; desc.fs.source = &FS_SOURCE_GLSL330 as *const _ as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; + desc.fs.entry = c"main".as_ptr(); desc.fs.images[0].used = true; desc.fs.images[0].multisampled = false; desc.fs.images[0].image_type = sg::ImageType::Dim2; @@ -447,24 +447,24 @@ pub fn texcube_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { desc.fs.image_sampler_pairs[0].used = true; desc.fs.image_sampler_pairs[0].image_slot = 0; desc.fs.image_sampler_pairs[0].sampler_slot = 0; - desc.fs.image_sampler_pairs[0].glsl_name = b"tex_smp\0".as_ptr() as *const _; - desc.label = b"texcube_shader\0".as_ptr() as *const _; + desc.fs.image_sampler_pairs[0].glsl_name = c"tex_smp".as_ptr(); + desc.label = c"texcube_shader".as_ptr(); }, sg::Backend::D3d11 => { - desc.attrs[0].sem_name = b"TEXCOORD\0".as_ptr() as *const _; + desc.attrs[0].sem_name = c"TEXCOORD".as_ptr(); desc.attrs[0].sem_index = 0; - desc.attrs[1].sem_name = b"TEXCOORD\0".as_ptr() as *const _; + desc.attrs[1].sem_name = c"TEXCOORD".as_ptr(); desc.attrs[1].sem_index = 1; - desc.attrs[2].sem_name = b"TEXCOORD\0".as_ptr() as *const _; + desc.attrs[2].sem_name = c"TEXCOORD".as_ptr(); desc.attrs[2].sem_index = 2; desc.vs.source = &VS_SOURCE_HLSL4 as *const _ as *const _; - desc.vs.d3d11_target = b"vs_4_0\0".as_ptr() as *const _; - desc.vs.entry = b"main\0".as_ptr() as *const _; + desc.vs.d3d11_target = c"vs_4_0".as_ptr(); + desc.vs.entry = c"main".as_ptr(); desc.vs.uniform_blocks[0].size = 64; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; desc.fs.source = &FS_SOURCE_HLSL4 as *const _ as *const _; - desc.fs.d3d11_target = b"ps_4_0\0".as_ptr() as *const _; - desc.fs.entry = b"main\0".as_ptr() as *const _; + desc.fs.d3d11_target = c"ps_4_0".as_ptr(); + desc.fs.entry = c"main".as_ptr(); desc.fs.images[0].used = true; desc.fs.images[0].multisampled = false; desc.fs.images[0].image_type = sg::ImageType::Dim2; @@ -474,15 +474,15 @@ pub fn texcube_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { desc.fs.image_sampler_pairs[0].used = true; desc.fs.image_sampler_pairs[0].image_slot = 0; desc.fs.image_sampler_pairs[0].sampler_slot = 0; - desc.label = b"texcube_shader\0".as_ptr() as *const _; + desc.label = c"texcube_shader".as_ptr(); }, sg::Backend::MetalMacos => { desc.vs.source = &VS_SOURCE_METAL_MACOS as *const _ as *const _; - desc.vs.entry = b"main0\0".as_ptr() as *const _; + desc.vs.entry = c"main0".as_ptr(); desc.vs.uniform_blocks[0].size = 64; desc.vs.uniform_blocks[0].layout = sg::UniformLayout::Std140; desc.fs.source = &FS_SOURCE_METAL_MACOS as *const _ as *const _; - desc.fs.entry = b"main0\0".as_ptr() as *const _; + desc.fs.entry = c"main0".as_ptr(); desc.fs.images[0].used = true; desc.fs.images[0].multisampled = false; desc.fs.images[0].image_type = sg::ImageType::Dim2; @@ -492,7 +492,7 @@ pub fn texcube_shader_desc(backend: sg::Backend) -> sg::ShaderDesc { desc.fs.image_sampler_pairs[0].used = true; desc.fs.image_sampler_pairs[0].image_slot = 0; desc.fs.image_sampler_pairs[0].sampler_slot = 0; - desc.label = b"texcube_shader\0".as_ptr() as *const _; + desc.label = c"texcube_shader".as_ptr(); }, _ => {}, } diff --git a/examples/texcube/texcube.rs b/examples/texcube/texcube.rs index c422212..22ddecf 100644 --- a/examples/texcube/texcube.rs +++ b/examples/texcube/texcube.rs @@ -209,7 +209,7 @@ fn main() { width: 800, height: 600, sample_count: 4, - window_title: b"texcube\0".as_ptr() as _, + window_title: c"texcube".as_ptr(), icon: sapp::IconDesc { sokol_default: true, ..Default::default() }, logger: sapp::Logger { func: Some(slog::slog_func), ..Default::default() }, ..Default::default() diff --git a/examples/userdata/userdata.rs b/examples/userdata/userdata.rs index fcf000e..554f2a5 100644 --- a/examples/userdata/userdata.rs +++ b/examples/userdata/userdata.rs @@ -46,8 +46,6 @@ extern "C" fn cleanup() { } fn main() { - let window_title = b"test\0".as_ptr() as _; - let mut user_data = ExampleUserData { data: 0, map: std::collections::HashMap::default() }; sapp::run(&sapp::Desc { @@ -67,7 +65,7 @@ fn main() { width: 800, height: 600, sample_count: 4, - window_title, + window_title: c"test".as_ptr(), logger: sapp::Logger { func: Some(sokol::log::slog_func), ..Default::default() }, icon: sapp::IconDesc { sokol_default: true, ..Default::default() }, ..Default::default()