aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/sokol/gfx
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/vlib/sokol/gfx
downloadcli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.gz
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.bz2
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/vlib/sokol/gfx')
-rw-r--r--v_windows/v/vlib/sokol/gfx/enums.v297
-rw-r--r--v_windows/v/vlib/sokol/gfx/gfx.c.v266
-rw-r--r--v_windows/v/vlib/sokol/gfx/gfx_funcs.c.v71
-rw-r--r--v_windows/v/vlib/sokol/gfx/gfx_structs.c.v535
-rw-r--r--v_windows/v/vlib/sokol/gfx/gfx_utils.c.v17
5 files changed, 1186 insertions, 0 deletions
diff --git a/v_windows/v/vlib/sokol/gfx/enums.v b/v_windows/v/vlib/sokol/gfx/enums.v
new file mode 100644
index 0000000..fbe336e
--- /dev/null
+++ b/v_windows/v/vlib/sokol/gfx/enums.v
@@ -0,0 +1,297 @@
+module gfx
+
+pub enum Backend {
+ glcore33
+ gles2
+ gles3
+ d3d11
+ metal_ios
+ metal_macos
+ metal_simulator
+ dummy
+}
+
+pub enum PixelFormat {
+ _default // value 0 reserved for default-init
+ @none
+ r8
+ r8sn
+ r8ui
+ r8si
+ r16
+ r16sn
+ r16ui
+ r16si
+ r16f
+ rg8
+ rg8sn
+ rg8ui
+ rg8si
+ r32ui
+ r32si
+ r32f
+ rg16
+ rg16sn
+ rg16ui
+ rg16si
+ rg16f
+ rgba8
+ rgba8sn
+ rgba8ui
+ rgba8si
+ bgra8
+ rgb10a2
+ rg11b10f
+ rg32ui
+ rg32si
+ rg32f
+ rgba16
+ rgba16sn
+ rgba16ui
+ rgba16si
+ rgba16f
+ rgba32ui
+ rgba32si
+ rgba32f
+ depth
+ depth_stencil
+ bc1_rgba
+ bc2_rgba
+ bc3_rgba
+ bc4_r
+ bc4_rsn
+ bc5_rg
+ bc5_rgsn
+ bc6h_rgbf
+ bc6h_rgbuf
+ bc7_rgba
+ pvrtc_rgb_2bpp
+ pvrtc_rgb_4bpp
+ pvrtc_rgba_2bpp
+ pvrtc_rgba_4bpp
+ etc2_rgb8
+ etc2_rgb8a1
+ etc2_rgba8
+ etc2_rg11
+ etc2_rg11sn
+ _num
+}
+
+pub enum ResourceState {
+ initial
+ alloc
+ valid
+ failed
+ invalid
+}
+
+pub enum Usage {
+ _default // value 0 reserved for default-init
+ immutable
+ dynamic
+ stream
+ _num
+}
+
+pub enum BufferType {
+ _default // value 0 reserved for default-init
+ vertexbuffer
+ indexbuffer
+ _num
+}
+
+pub enum IndexType {
+ _default // value 0 reserved for default-init
+ @none
+ uint16
+ uint32
+ _num
+}
+
+pub enum ImageType {
+ _default // value 0 reserved for default-init
+ _2d
+ cube
+ _3d
+ array
+ _num
+}
+
+pub enum CubeFace {
+ pos_x
+ neg_x
+ pos_y
+ neg_y
+ pos_z
+ neg_z
+ num
+ _force_u32 = 0x7fffffff
+}
+
+pub enum ShaderStage {
+ vs
+ fs
+}
+
+pub enum PrimitiveType {
+ _default // value 0 reserved for default-init
+ points
+ lines
+ line_strip
+ triangles
+ triangle_strip
+ _num
+}
+
+pub enum Filter {
+ _default // value 0 reserved for default-init
+ nearest
+ linear
+ nearest_mipmap_nearest
+ nearest_mipmap_linear
+ linear_mipmap_nearest
+ linear_mipmap_linear
+ _num
+}
+
+pub enum Wrap {
+ _default // value 0 reserved for default-init
+ repeat
+ clamp_to_edge
+ clamp_to_border
+ mirrored_repeat
+ _num
+}
+
+pub enum BorderColor {
+ _default // value 0 reserved for default-init
+ transparent_black
+ opaque_black
+ opaque_white
+ _num
+}
+
+pub enum VertexFormat {
+ invalid
+ float
+ float2
+ float3
+ float4
+ byte4
+ byte4n
+ ubyte4
+ ubyte4n
+ short2
+ short2n
+ ushort2n
+ short4
+ short4n
+ ushort4n
+ uint10_n2
+ _num
+}
+
+pub enum VertexStep {
+ _default // value 0 reserved for default-init
+ per_vertex
+ per_instance
+ _num
+}
+
+pub enum UniformType {
+ invalid
+ float
+ float2
+ float3
+ float4
+ mat4
+ _num
+}
+
+pub enum CullMode {
+ _default // value 0 reserved for default-init
+ @none
+ front
+ back
+ _num
+}
+
+pub enum FaceWinding {
+ _facewinding_default // value 0 reserved for default-init
+ facewinding_ccw
+ facewinding_cw
+ _facewinding_num
+}
+
+pub enum CompareFunc {
+ _default // value 0 reserved for default-init
+ never
+ less
+ equal
+ less_equal
+ greater
+ not_equal
+ greater_equal
+ always
+ _num
+}
+
+pub enum StencilOp {
+ _default // value 0 reserved for default-init
+ keep
+ zero
+ replace
+ incr_clamp
+ decr_clamp
+ invert
+ incr_wrap
+ decr_wrap
+ _num
+}
+
+pub enum BlendFactor {
+ _default // value 0 reserved for default-init
+ zero
+ one
+ src_color
+ one_minus_src_color
+ src_alpha
+ one_minus_src_alpha
+ dst_color
+ one_minus_dst_color
+ dst_alpha
+ one_minus_dst_alpha
+ src_alpha_saturated
+ blend_color
+ one_minus_blend_color
+ blend_alpha
+ one_minus_blend_alpha
+ _num
+}
+
+pub enum BlendOp {
+ _default // value 0 reserved for default-init
+ add
+ subtract
+ reverse_subtract
+ _num
+}
+
+pub enum ColorMask {
+ _default = 0 // value 0 reserved for default-init
+ @none = 0x10 // special value for 'all channels disabled
+ r = 1
+ g = 2
+ b = 4
+ a = 8
+ rgb = 0x7
+ rgba = 0xF
+}
+
+pub enum Action {
+ _default
+ clear
+ load
+ dontcare
+ _num
+}
diff --git a/v_windows/v/vlib/sokol/gfx/gfx.c.v b/v_windows/v/vlib/sokol/gfx/gfx.c.v
new file mode 100644
index 0000000..9480173
--- /dev/null
+++ b/v_windows/v/vlib/sokol/gfx/gfx.c.v
@@ -0,0 +1,266 @@
+module gfx
+
+import sokol.c
+
+pub const (
+ version = 1
+ used_import = c.used_import
+)
+
+// setup and misc functions
+[inline]
+pub fn setup(desc &C.sg_desc) {
+ C.sg_setup(desc)
+}
+
+[inline]
+pub fn shutdown() {
+ C.sg_shutdown()
+}
+
+[inline]
+pub fn reset_state_cache() {
+ C.sg_reset_state_cache()
+}
+
+// resource creation, destruction and updating
+[inline]
+pub fn make_buffer(desc &C.sg_buffer_desc) C.sg_buffer {
+ return C.sg_make_buffer(desc)
+}
+
+[inline]
+pub fn make_image(desc &C.sg_image_desc) C.sg_image {
+ return C.sg_make_image(desc)
+}
+
+[inline]
+pub fn make_shader(desc &C.sg_shader_desc) C.sg_shader {
+ return C.sg_make_shader(desc)
+}
+
+[inline]
+pub fn make_pipeline(desc &C.sg_pipeline_desc) C.sg_pipeline {
+ return C.sg_make_pipeline(desc)
+}
+
+[inline]
+pub fn make_pass(desc &C.sg_pass_desc) C.sg_pass {
+ return C.sg_make_pass(desc)
+}
+
+[inline]
+pub fn destroy_buffer(buf C.sg_buffer) {
+ C.sg_destroy_buffer(buf)
+}
+
+[inline]
+pub fn destroy_image(img C.sg_image) {
+ C.sg_destroy_image(img)
+}
+
+[inline]
+pub fn destroy_shader(shd C.sg_shader) {
+ C.sg_destroy_shader(shd)
+}
+
+[inline]
+pub fn destroy_pipeline(pip C.sg_pipeline) {
+ C.sg_destroy_pipeline(pip)
+}
+
+[inline]
+pub fn destroy_pass(pass C.sg_pass) {
+ C.sg_destroy_pass(pass)
+}
+
+[inline]
+pub fn update_buffer(buf C.sg_buffer, data &C.sg_range) {
+ C.sg_update_buffer(buf, data)
+}
+
+[inline]
+pub fn update_image(img C.sg_image, data &C.sg_image_data) {
+ C.sg_update_image(img, data)
+}
+
+[inline]
+pub fn append_buffer(buf C.sg_buffer, data &C.sg_range) int {
+ return C.sg_append_buffer(buf, data)
+}
+
+[inline]
+pub fn query_buffer_overflow(buf C.sg_buffer) bool {
+ return C.sg_query_buffer_overflow(buf)
+}
+
+// rendering functions
+[inline]
+pub fn begin_default_pass(actions &C.sg_pass_action, width int, height int) {
+ C.sg_begin_default_pass(actions, width, height)
+}
+
+[inline]
+pub fn begin_pass(pass C.sg_pass, actions &C.sg_pass_action) {
+ C.sg_begin_pass(pass, actions)
+}
+
+[inline]
+pub fn apply_viewport(x int, y int, width int, height int, origin_top_left bool) {
+ C.sg_apply_viewport(x, y, width, height, origin_top_left)
+}
+
+[inline]
+pub fn apply_scissor_rect(x int, y int, width int, height int, origin_top_left bool) {
+ C.sg_apply_scissor_rect(x, y, width, height, origin_top_left)
+}
+
+[inline]
+pub fn apply_pipeline(pip C.sg_pipeline) {
+ C.sg_apply_pipeline(pip)
+}
+
+[inline]
+pub fn apply_bindings(bindings &C.sg_bindings) {
+ C.sg_apply_bindings(bindings)
+}
+
+[inline]
+pub fn apply_uniforms(stage int, ub_index int, data &C.sg_range) {
+ C.sg_apply_uniforms(stage, ub_index, data)
+}
+
+[inline]
+pub fn draw(base_element int, num_elements int, num_instances int) {
+ C.sg_draw(base_element, num_elements, num_instances)
+}
+
+[inline]
+pub fn end_pass() {
+ C.sg_end_pass()
+}
+
+[inline]
+pub fn commit() {
+ C.sg_commit()
+}
+
+// getting information
+[inline]
+pub fn query_desc() C.sg_desc {
+ return C.sg_query_desc()
+}
+
+[inline]
+pub fn query_backend() Backend {
+ return Backend(C.sg_query_backend())
+}
+
+[inline]
+pub fn query_features() C.sg_features {
+ return C.sg_query_features()
+}
+
+[inline]
+pub fn query_limits() C.sg_limits {
+ return C.sg_query_limits()
+}
+
+[inline]
+pub fn query_pixelformat(fmt PixelFormat) C.sg_pixelformat_info {
+ return C.sg_query_pixelformat(fmt)
+}
+
+// get current state of a resource (INITIAL, ALLOC, VALID, FAILED, INVALID)
+[inline]
+pub fn query_buffer_state(buf C.sg_buffer) C.sg_resource_state {
+ return C.sg_query_buffer_state(buf)
+}
+
+[inline]
+pub fn query_image_state(img C.sg_image) C.sg_resource_state {
+ return C.sg_query_image_state(img)
+}
+
+[inline]
+pub fn query_shader_state(shd C.sg_shader) C.sg_resource_state {
+ return C.sg_query_shader_state(shd)
+}
+
+[inline]
+pub fn query_pipeline_state(pip C.sg_pipeline) C.sg_resource_state {
+ return C.sg_query_pipeline_state(pip)
+}
+
+[inline]
+pub fn query_pass_state(pass C.sg_pass) C.sg_resource_state {
+ return C.sg_query_pass_state(pass)
+}
+
+// get runtime information about a resource
+[inline]
+pub fn query_buffer_info(buf C.sg_buffer) C.sg_buffer_info {
+ return C.sg_query_buffer_info(buf)
+}
+
+[inline]
+pub fn query_image_info(img C.sg_image) C.sg_image_info {
+ return C.sg_query_image_info(img)
+}
+
+[inline]
+pub fn query_shader_info(shd C.sg_shader) C.sg_shader_info {
+ return C.sg_query_shader_info(shd)
+}
+
+[inline]
+pub fn query_pipeline_info(pip C.sg_pipeline) C.sg_pipeline_info {
+ return C.sg_query_pipeline_info(pip)
+}
+
+[inline]
+pub fn query_pass_info(pass C.sg_pass) C.sg_pass_info {
+ return C.sg_query_pass_info(pass)
+}
+
+// get resource creation desc struct with their default values replaced
+[inline]
+pub fn query_buffer_defaults(desc &C.sg_buffer) C.sg_buffer_desc {
+ return C.sg_query_buffer_defaults(unsafe { &C.sg_buffer_desc(desc) })
+}
+
+[inline]
+pub fn query_image_defaults(desc &C.sg_image) C.sg_image_desc {
+ return C.sg_query_image_defaults(unsafe { &C.sg_image_desc(desc) })
+}
+
+[inline]
+pub fn query_shader_defaults(desc &C.sg_shader) C.sg_shader_desc {
+ return C.sg_query_shader_defaults(unsafe { &C.sg_shader_desc(desc) })
+}
+
+[inline]
+pub fn query_pipeline_defaults(desc &C.sg_pipeline) C.sg_pipeline_desc {
+ return C.sg_query_pipeline_defaults(unsafe { &C.sg_pipeline_desc(desc) })
+}
+
+[inline]
+pub fn query_pass_defaults(desc &C.sg_pass) C.sg_pass_desc {
+ return C.sg_query_pass_defaults(unsafe { &C.sg_pass_desc(desc) })
+}
+
+// rendering contexts (optional)
+[inline]
+pub fn setup_context() C.sg_context {
+ return C.sg_setup_context()
+}
+
+[inline]
+pub fn activate_context(ctx_id C.sg_context) {
+ C.sg_activate_context(ctx_id)
+}
+
+[inline]
+pub fn discard_context(ctx_id C.sg_context) {
+ C.sg_discard_context(ctx_id)
+}
diff --git a/v_windows/v/vlib/sokol/gfx/gfx_funcs.c.v b/v_windows/v/vlib/sokol/gfx/gfx_funcs.c.v
new file mode 100644
index 0000000..eb4e99b
--- /dev/null
+++ b/v_windows/v/vlib/sokol/gfx/gfx_funcs.c.v
@@ -0,0 +1,71 @@
+module gfx
+
+// setup and misc functions
+fn C.sg_setup(desc &C.sg_desc)
+fn C.sg_shutdown()
+fn C.sg_reset_state_cache()
+
+// resource creation, destruction and updating
+fn C.sg_make_buffer(desc &C.sg_buffer_desc) C.sg_buffer
+fn C.sg_make_image(desc &C.sg_image_desc) C.sg_image
+fn C.sg_make_shader(desc &C.sg_shader_desc) C.sg_shader
+fn C.sg_make_pipeline(desc &C.sg_pipeline_desc) C.sg_pipeline
+fn C.sg_make_pass(desc &C.sg_pass_desc) C.sg_pass
+fn C.sg_destroy_buffer(buf C.sg_buffer)
+fn C.sg_destroy_image(img C.sg_image)
+fn C.sg_destroy_shader(shd C.sg_shader)
+fn C.sg_destroy_pipeline(pip C.sg_pipeline)
+fn C.sg_destroy_pass(pass C.sg_pass)
+fn C.sg_update_buffer(buf C.sg_buffer, data &C.sg_range)
+fn C.sg_update_image(img C.sg_image, data &C.sg_image_data)
+fn C.sg_append_buffer(buf C.sg_buffer, data &C.sg_range) int
+fn C.sg_query_buffer_overflow(buf C.sg_buffer) bool
+
+// rendering functions
+fn C.sg_begin_default_pass(actions &C.sg_pass_action, width int, height int)
+fn C.sg_begin_pass(pass C.sg_pass, actions &C.sg_pass_action)
+fn C.sg_apply_viewport(x int, y int, width int, height int, origin_top_left bool)
+fn C.sg_apply_viewportf(x f32, y f32, width f32, height f32, origin_top_left bool)
+fn C.sg_apply_scissor_rect(x int, y int, width int, height int, origin_top_left bool)
+fn C.sg_apply_scissor_rectf(x f32, y f32, width f32, height f32, origin_top_left bool)
+fn C.sg_apply_pipeline(pip C.sg_pipeline)
+fn C.sg_apply_bindings(bindings &C.sg_bindings)
+
+// stage == sg_shader_stage
+fn C.sg_apply_uniforms(stage int, ub_index int, data &C.sg_range)
+fn C.sg_draw(base_element int, num_elements int, num_instances int)
+fn C.sg_end_pass()
+fn C.sg_commit()
+
+// getting information
+fn C.sg_query_desc() C.sg_desc
+fn C.sg_query_backend() Backend
+fn C.sg_query_features() C.sg_features
+fn C.sg_query_limits() C.sg_limits
+fn C.sg_query_pixelformat(fmt PixelFormat) C.sg_pixelformat_info
+
+// get current state of a resource (INITIAL, ALLOC, VALID, FAILED, INVALID)
+fn C.sg_query_buffer_state(buf C.sg_buffer) C.sg_resource_state
+fn C.sg_query_image_state(img C.sg_image) C.sg_resource_state
+fn C.sg_query_shader_state(shd C.sg_shader) C.sg_resource_state
+fn C.sg_query_pipeline_state(pip C.sg_pipeline) C.sg_resource_state
+fn C.sg_query_pass_state(pass C.sg_pass) C.sg_resource_state
+
+// get runtime information about a resource
+fn C.sg_query_buffer_info(buf C.sg_buffer) C.sg_buffer_info
+fn C.sg_query_image_info(img C.sg_image) C.sg_image_info
+fn C.sg_query_shader_info(shd C.sg_shader) C.sg_shader_info
+fn C.sg_query_pipeline_info(pip C.sg_pipeline) C.sg_pipeline_info
+fn C.sg_query_pass_info(pass C.sg_pass) C.sg_pass_info
+
+// get resource creation desc struct with their default values replaced
+fn C.sg_query_buffer_defaults(desc &C.sg_buffer_desc) C.sg_buffer_desc
+fn C.sg_query_image_defaults(desc &C.sg_image_desc) C.sg_image_desc
+fn C.sg_query_shader_defaults(desc &C.sg_shader_desc) C.sg_shader_desc
+fn C.sg_query_pipeline_defaults(desc &C.sg_pipeline_desc) C.sg_pipeline_desc
+fn C.sg_query_pass_defaults(desc &C.sg_pass_desc) C.sg_pass_desc
+
+// rendering contexts (optional)
+fn C.sg_setup_context() C.sg_context
+fn C.sg_activate_context(ctx_id C.sg_context)
+fn C.sg_discard_context(ctx_id C.sg_context)
diff --git a/v_windows/v/vlib/sokol/gfx/gfx_structs.c.v b/v_windows/v/vlib/sokol/gfx/gfx_structs.c.v
new file mode 100644
index 0000000..1bf6c3a
--- /dev/null
+++ b/v_windows/v/vlib/sokol/gfx/gfx_structs.c.v
@@ -0,0 +1,535 @@
+module gfx
+
+pub struct C.sg_desc {
+ _start_canary u32
+ buffer_pool_size int
+ image_pool_size int
+ shader_pool_size int
+ pipeline_pool_size int
+ pass_pool_size int
+ context_pool_size int
+ context C.sg_context_desc
+ /*
+ // GL specific
+ gl_force_gles2 bool
+ // Metal-specific
+ mtl_device voidptr
+ mtl_renderpass_descriptor_cb fn() voidptr
+ mtl_drawable_cb fn() voidptr
+ mtl_global_uniform_buffer_size int
+ mtl_sampler_cache_size int
+ // D3D11-specific
+ d3d11_device voidptr
+ d3d11_device_context voidptr
+ d3d11_render_target_view_cb fn() voidptr
+ d3d11_depth_stencil_view_cb fn() voidptr
+ */
+ _end_canary u32
+}
+
+pub struct C.sg_context_desc {
+ /*
+ sg_pixel_format color_format;
+ sg_pixel_format depth_format;
+ int sample_count;
+ sg_wgpu_context_desc wgpu;
+ */
+ sample_count int
+ gl C.sg_gl_context_desc
+ metal C.sg_metal_context_desc
+ d3d11 C.sg_d3d11_context_desc
+ color_format PixelFormat
+ depth_format PixelFormat
+}
+
+pub struct C.sg_gl_context_desc {
+ force_gles2 bool
+}
+
+pub struct C.sg_metal_context_desc {
+ device voidptr
+ renderpass_descriptor_cb fn () voidptr
+ drawable_cb fn () voidptr
+}
+
+pub struct C.sg_d3d11_context_desc {
+ device voidptr
+ device_context voidptr
+ render_target_view_cb fn () voidptr
+ depth_stencil_view_cb fn () voidptr
+}
+
+pub struct C.sg_color_state {
+pub mut:
+ pixel_format PixelFormat
+ write_mask ColorMask
+ blend C.sg_blend_state
+}
+
+pub struct C.sg_pipeline_desc {
+pub mut:
+ _start_canary u32
+ shader C.sg_shader
+ layout C.sg_layout_desc
+ depth C.sg_depth_state
+ stencil C.sg_stencil_state
+ color_count int
+ colors [4]C.sg_color_state // C.SG_MAX_COLOR_ATTACHMENTS
+ primitive_type PrimitiveType
+ index_type IndexType
+ cull_mode CullMode
+ face_winding FaceWinding
+ sample_count int
+ blend_color C.sg_color
+ alpha_to_coverage_enabled bool
+ label &char = &char(0)
+ _end_canary u32
+}
+
+pub struct C.sg_pipeline_info {
+}
+
+pub struct C.sg_pipeline {
+pub:
+ id u32
+}
+
+pub fn (p C.sg_pipeline) free() {
+ C.sg_destroy_pipeline(p)
+}
+
+pub struct C.sg_bindings {
+pub mut:
+ _start_canary u32
+ vertex_buffers [8]C.sg_buffer
+ vertex_buffer_offsets [8]int
+ index_buffer C.sg_buffer
+ index_buffer_offset int
+ vs_images [8]C.sg_image
+ fs_images [8]C.sg_image
+ _end_canary u32
+}
+
+pub fn (mut b C.sg_bindings) set_vert_image(index int, img C.sg_image) {
+ b.vs_images[index] = img
+}
+
+pub fn (mut b C.sg_bindings) set_frag_image(index int, img C.sg_image) {
+ b.fs_images[index] = img
+}
+
+pub fn (b &C.sg_bindings) update_vert_buffer(index int, data voidptr, element_size int, element_count int) {
+ range := C.sg_range{
+ ptr: data
+ size: size_t(element_size * element_count)
+ }
+ C.sg_update_buffer(b.vertex_buffers[index], &range)
+}
+
+pub fn (b &C.sg_bindings) append_vert_buffer(index int, data voidptr, element_size int, element_count int) int {
+ range := C.sg_range{
+ ptr: data
+ size: size_t(element_size * element_count)
+ }
+ return C.sg_append_buffer(b.vertex_buffers[index], &range)
+}
+
+pub fn (b &C.sg_bindings) update_index_buffer(data voidptr, element_size int, element_count int) {
+ range := C.sg_range{
+ ptr: data
+ size: size_t(element_size * element_count)
+ }
+ C.sg_update_buffer(b.index_buffer, &range)
+}
+
+pub fn (b &C.sg_bindings) append_index_buffer(data voidptr, element_size int, element_count int) int {
+ range := C.sg_range{
+ ptr: data
+ size: size_t(element_size * element_count)
+ }
+ return C.sg_append_buffer(b.index_buffer, &range)
+}
+
+[heap]
+pub struct C.sg_shader_desc {
+pub mut:
+ _start_canary u32
+ attrs [16]C.sg_shader_attr_desc
+ vs C.sg_shader_stage_desc
+ fs C.sg_shader_stage_desc
+ label &char
+ _end_canary u32
+}
+
+pub fn (mut desc C.sg_shader_desc) set_vert_src(src string) &C.sg_shader_desc {
+ desc.vs.source = &char(src.str)
+ return desc
+}
+
+pub fn (mut desc C.sg_shader_desc) set_frag_src(src string) &C.sg_shader_desc {
+ desc.fs.source = &char(src.str)
+ return desc
+}
+
+pub fn (mut desc C.sg_shader_desc) set_vert_image(index int, name string) &C.sg_shader_desc {
+ desc.vs.images[index].name = &char(name.str)
+ desc.vs.images[index].image_type = ._2d
+ return desc
+}
+
+pub fn (mut desc C.sg_shader_desc) set_frag_image(index int, name string) &C.sg_shader_desc {
+ desc.fs.images[index].name = &char(name.str)
+ desc.fs.images[index].image_type = ._2d
+ return desc
+}
+
+pub fn (mut desc C.sg_shader_desc) set_vert_uniform_block_size(block_index int, size size_t) &C.sg_shader_desc {
+ desc.vs.uniform_blocks[block_index].size = size
+ return desc
+}
+
+pub fn (mut desc C.sg_shader_desc) set_frag_uniform_block_size(block_index int, size size_t) &C.sg_shader_desc {
+ desc.fs.uniform_blocks[block_index].size = size
+ return desc
+}
+
+pub fn (mut desc C.sg_shader_desc) set_vert_uniform(block_index int, uniform_index int, name string, @type UniformType, array_count int) &C.sg_shader_desc {
+ desc.vs.uniform_blocks[block_index].uniforms[uniform_index].name = &char(name.str)
+ desc.vs.uniform_blocks[block_index].uniforms[uniform_index].@type = @type
+ return desc
+}
+
+pub fn (mut desc C.sg_shader_desc) set_frag_uniform(block_index int, uniform_index int, name string, @type UniformType, array_count int) &C.sg_shader_desc {
+ desc.fs.uniform_blocks[block_index].uniforms[uniform_index].name = &char(name.str)
+ desc.fs.uniform_blocks[block_index].uniforms[uniform_index].@type = @type
+ return desc
+}
+
+pub fn (desc &C.sg_shader_desc) make_shader() C.sg_shader {
+ return C.sg_make_shader(desc)
+}
+
+pub struct C.sg_shader_attr_desc {
+pub mut:
+ name &char // GLSL vertex attribute name (only required for GLES2)
+ sem_name &char // HLSL semantic name
+ sem_index int // HLSL semantic index
+}
+
+pub struct C.sg_shader_stage_desc {
+pub mut:
+ source &char
+ bytecode C.sg_range
+ entry &char
+ uniform_blocks [4]C.sg_shader_uniform_block_desc
+ images [12]C.sg_shader_image_desc
+}
+
+pub fn (mut desc C.sg_shader_stage_desc) set_image(index int, name string) C.sg_shader_stage_desc {
+ desc.images[index].name = &char(name.str)
+ desc.images[index].image_type = ._2d
+ return *desc
+}
+
+pub struct C.sg_shader_uniform_block_desc {
+pub mut:
+ size size_t
+ uniforms [16]C.sg_shader_uniform_desc
+}
+
+pub struct C.sg_shader_uniform_desc {
+pub mut:
+ name &char
+ @type UniformType
+ array_count int
+}
+
+pub struct C.sg_shader_image_desc {
+pub mut:
+ name &char
+ image_type ImageType
+}
+
+pub struct C.sg_shader_info {
+}
+
+pub struct C.sg_context {
+ id u32
+}
+
+pub struct C.sg_range {
+pub mut:
+ ptr voidptr
+ size size_t
+}
+
+pub struct C.sg_color {
+pub mut:
+ r f32
+ g f32
+ b f32
+ a f32
+}
+
+pub struct C.sg_shader {
+pub:
+ id u32
+}
+
+pub fn (s C.sg_shader) free() {
+ C.sg_destroy_shader(s)
+}
+
+pub struct C.sg_pass_desc {
+pub mut:
+ _start_canary u32
+ color_attachments [4]C.sg_pass_attachment_desc
+ depth_stencil_attachment C.sg_pass_attachment_desc
+ label &char
+ _end_canary u32
+}
+
+pub struct C.sg_pass_info {
+ info C.sg_slot_info
+}
+
+pub struct C.sg_pass_action {
+pub mut:
+ _start_canary u32
+ colors [4]C.sg_color_attachment_action
+ depth C.sg_depth_attachment_action
+ stencil C.sg_stencil_attachment_action
+ _end_canary u32
+}
+
+pub struct C.sg_pass {
+ id u32
+}
+
+pub fn (p C.sg_pass) free() {
+ C.sg_destroy_pass(p)
+}
+
+pub struct C.sg_buffer_desc {
+pub mut:
+ _start_canary u32
+ size size_t
+ @type BufferType
+ usage Usage
+ data C.sg_range
+ label &char
+ // GL specific
+ gl_buffers [2]u32
+ // Metal specific
+ mtl_buffers [2]voidptr
+ // D3D11 specific
+ d3d11_buffer voidptr
+ _end_canary u32
+}
+
+pub struct C.sg_buffer_info {
+}
+
+pub struct C.sg_buffer {
+ id u32
+}
+
+pub fn (b C.sg_buffer) free() {
+ C.sg_destroy_buffer(b)
+}
+
+pub struct DepthLayers {
+ depth int
+ layers int
+}
+
+pub struct C.sg_image_desc {
+pub mut:
+ _start_canary u32
+ @type ImageType
+ render_target bool
+ width int
+ height int
+ num_slices int
+ num_mipmaps int
+ usage Usage
+ pixel_format PixelFormat
+ sample_count int
+ min_filter Filter
+ mag_filter Filter
+ wrap_u Wrap
+ wrap_v Wrap
+ wrap_w Wrap
+ border_color BorderColor
+ max_anisotropy u32
+ min_lod f32
+ max_lod f32
+ data C.sg_image_data
+ label &char
+ // GL specific
+ gl_textures [2]u32
+ gl_texture_target u32
+ // Metal specific
+ mtl_textures [2]voidptr
+ // D3D11 specific
+ d3d11_texture voidptr
+ d3d11_shader_resource_view voidptr
+ // WebGPU specific
+ wgpu_texture voidptr
+ _end_canary u32
+}
+
+pub struct C.sg_image_info {
+pub mut:
+ slot C.sg_slot_info // resource pool slot info
+ upd_frame_index u32 // frame index of last sg_update_image()
+ num_slots int // number of renaming-slots for dynamically updated images
+ active_slot int // currently active write-slot for dynamically updated images
+}
+
+pub struct C.sg_image {
+pub:
+ id u32
+}
+
+pub fn (i C.sg_image) free() {
+ C.sg_destroy_image(i)
+}
+
+pub const sg_cubeface_num = 6
+
+pub const sg_max_mipmaps = 16
+
+pub struct C.sg_image_data {
+pub mut:
+ subimage [sg_cubeface_num][sg_max_mipmaps]C.sg_range
+}
+
+pub struct C.sg_features {
+pub:
+ instancing bool // hardware instancing supported
+ origin_top_left bool // framebuffer and texture origin is in top left corner
+ multiple_render_targets bool // offscreen render passes can have multiple render targets attached
+ msaa_render_targets bool // offscreen render passes support MSAA antialiasing
+ imagetype_3d bool // creation of SG_IMAGETYPE_3D images is supported
+ imagetype_array bool // creation of SG_IMAGETYPE_ARRAY images is supported
+ image_clamp_to_border bool // border color and clamp-to-border UV-wrap mode is supported
+ mrt_independent_blend_state bool // multiple-render-target rendering can use per-render-target blend state
+ mrt_independent_write_mask bool // multiple-render-target rendering can use per-render-target color write masks
+}
+
+pub struct C.sg_limits {
+pub:
+ max_image_size_2d u32 // max width/height of SG_IMAGETYPE_2D images
+ max_image_size_cube u32 // max width/height of SG_IMAGETYPE_CUBE images
+ max_image_size_3d u32 // max width/height/depth of SG_IMAGETYPE_3D images
+ max_image_size_array u32 // max width/height pf SG_IMAGETYPE_ARRAY images
+ max_image_array_layers u32 // max number of layers in SG_IMAGETYPE_ARRAY images
+ max_vertex_attrs u32 // <= SG_MAX_VERTEX_ATTRIBUTES (only on some GLES2 impls)
+}
+
+pub struct C.sg_layout_desc {
+pub mut:
+ buffers [8]C.sg_buffer_layout_desc
+ attrs [16]C.sg_vertex_attr_desc
+}
+
+pub struct C.sg_buffer_layout_desc {
+pub mut:
+ stride int
+ step_func VertexStep
+ step_rate int
+}
+
+pub struct C.sg_vertex_attr_desc {
+pub mut:
+ buffer_index int
+ offset int
+ format VertexFormat
+}
+
+pub struct C.sg_stencil_state {
+ enabled bool
+ front C.sg_stencil_face_state
+ back C.sg_stencil_face_state
+ read_mask byte
+ write_mask byte
+ ref byte
+}
+
+pub struct C.sg_depth_state {
+ pixel_format PixelFormat
+ compare CompareFunc
+ write_enabled bool
+ bias f32
+ bias_slope_scale f32
+ bias_clamp f32
+}
+
+pub struct C.sg_stencil_face_state {
+ fail_op StencilOp
+ depth_fail_op StencilOp
+ pass_op StencilOp
+ compare_func CompareFunc
+}
+
+pub struct C.sg_blend_state {
+pub mut:
+ enabled bool
+ src_factor_rgb BlendFactor
+ dst_factor_rgb BlendFactor
+ op_rgb BlendOp
+ src_factor_alpha BlendFactor
+ dst_factor_alpha BlendFactor
+ op_alpha BlendOp
+}
+
+pub struct C.sg_color_attachment_action {
+pub mut:
+ action Action
+ value C.sg_color
+}
+
+/*
+pub fn (mut action C.sg_color_attachment_action) set_color_values(r, g, b, a f32) {
+ action.val[0] = r
+ action.val[1] = g
+ action.val[2] = b
+ action.val[3] = a
+}
+*/
+pub struct C.sg_depth_attachment_action {
+pub mut:
+ action Action
+ value f32
+}
+
+pub struct C.sg_stencil_attachment_action {
+pub mut:
+ action Action
+ value byte
+}
+
+pub struct C.sg_pixelformat_info {
+pub:
+ sample bool // pixel format can be sampled in shaders
+ filter bool // pixel format can be sampled with filtering
+ render bool // pixel format can be used as render target
+ blend bool // alpha-blending is supported
+ msaa bool // pixel format can be used as MSAA render target
+ depth bool // pixel format is a depth format
+}
+
+pub struct C.sg_pass_attachment_desc {
+pub mut:
+ image C.sg_image
+ mip_level int
+ face int
+ // image sg_image
+ // mip_level int
+ // union {
+ // face int
+ // layer int
+ // slice int
+ // }
+}
diff --git a/v_windows/v/vlib/sokol/gfx/gfx_utils.c.v b/v_windows/v/vlib/sokol/gfx/gfx_utils.c.v
new file mode 100644
index 0000000..c95ff69
--- /dev/null
+++ b/v_windows/v/vlib/sokol/gfx/gfx_utils.c.v
@@ -0,0 +1,17 @@
+module gfx
+
+pub fn create_clear_pass(r f32, g f32, b f32, a f32) C.sg_pass_action {
+ mut color_action := C.sg_color_attachment_action{
+ action: Action(C.SG_ACTION_CLEAR)
+ value: C.sg_color{
+ r: r
+ g: g
+ b: b
+ a: a
+ }
+ }
+ // color_action.set_color_values(r, g, b, a)
+ mut pass_action := C.sg_pass_action{}
+ pass_action.colors[0] = color_action
+ return pass_action
+}