mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
sokol and fontstash modules
This commit is contained in:
304
vlib/sokol/gfx/enums.v
Normal file
304
vlib/sokol/gfx/enums.v
Normal file
@@ -0,0 +1,304 @@
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
218
vlib/sokol/gfx/gfx.v
Normal file
218
vlib/sokol/gfx/gfx.v
Normal file
@@ -0,0 +1,218 @@
|
||||
module gfx
|
||||
|
||||
// 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, ptr voidptr, num_bytes int) {
|
||||
C.sg_update_buffer(buf, ptr, num_bytes)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn update_image(img C.sg_image, content &C.sg_image_content) {
|
||||
C.sg_update_image(img, content)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn append_buffer(buf C.sg_buffer, ptr voidptr, num_bytes int) int {
|
||||
return C.sg_append_buffer(buf, ptr, num_bytes)
|
||||
}
|
||||
|
||||
// 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 voidptr, num_bytes int) {
|
||||
C.sg_apply_uniforms(stage, ub_index, data, num_bytes)
|
||||
}
|
||||
|
||||
[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()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn query_buffer_overflow(buf C.sg_buffer) bool {
|
||||
return C.sg_query_buffer_overflow(buf)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// getting information
|
||||
[inline]
|
||||
pub fn query_desc() C.sg_desc {
|
||||
return C.sg_query_desc()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn query_backend() Backend {
|
||||
return 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 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(desc)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn query_image_defaults(desc &C.sg_image) C.sg_image_desc {
|
||||
return C.sg_query_image_defaults(desc)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn query_shader_defaults(desc &C.sg_shader) C.sg_shader_desc {
|
||||
return C.sg_query_shader_defaults(desc)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn query_pipeline_defaults(desc &C.sg_pipeline) C.sg_pipeline_desc {
|
||||
return C.sg_query_pipeline_defaults(desc)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn query_pass_defaults(desc &C.sg_pass) C.sg_pass_desc {
|
||||
return C.sg_query_pass_defaults(desc)
|
||||
}
|
||||
|
||||
56
vlib/sokol/gfx/gfx_funcs.v
Normal file
56
vlib/sokol/gfx/gfx_funcs.v
Normal file
@@ -0,0 +1,56 @@
|
||||
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, ptr voidptr, num_bytes int)
|
||||
fn C.sg_update_image(img C.sg_image, content &C.sg_image_content)
|
||||
fn C.sg_append_buffer(buf C.sg_buffer, ptr voidptr, num_bytes int) int
|
||||
|
||||
// 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_scissor_rect(x int, y int, width int, height int, origin_top_left bool)
|
||||
fn C.sg_apply_pipeline(pip C.sg_pipeline)
|
||||
fn C.sg_apply_bindings(bindings &C.sg_bindings)
|
||||
fn C.sg_apply_uniforms(stage int /*sg_shader_stage*/, ub_index int, data voidptr, num_bytes int)
|
||||
fn C.sg_draw(base_element int, num_elements int, num_instances int)
|
||||
fn C.sg_end_pass()
|
||||
fn C.sg_commit()
|
||||
|
||||
fn C.sg_query_buffer_overflow(buf C.sg_buffer) bool
|
||||
|
||||
// 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
|
||||
|
||||
// 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 resource creation desc struct with their default values replaced
|
||||
fn C.sg_query_buffer_defaults(desc &C.sg_buffer) C.sg_buffer_desc
|
||||
fn C.sg_query_image_defaults(desc &C.sg_image) C.sg_image_desc
|
||||
fn C.sg_query_shader_defaults(desc &C.sg_shader) C.sg_shader_desc
|
||||
fn C.sg_query_pipeline_defaults(desc &C.sg_pipeline) C.sg_pipeline_desc
|
||||
fn C.sg_query_pass_defaults(desc &C.sg_pass) C.sg_pass_desc
|
||||
460
vlib/sokol/gfx/gfx_structs.v
Normal file
460
vlib/sokol/gfx/gfx_structs.v
Normal file
@@ -0,0 +1,460 @@
|
||||
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
|
||||
/* 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_pipeline_desc {
|
||||
pub mut:
|
||||
_start_canary u32
|
||||
layout C.sg_layout_desc
|
||||
shader C.sg_shader
|
||||
primitive_type PrimitiveType
|
||||
index_type IndexType
|
||||
depth_stencil C.sg_depth_stencil_state
|
||||
blend C.sg_blend_state
|
||||
rasterizer C.sg_rasterizer_state
|
||||
label byteptr
|
||||
_end_canary u32
|
||||
}
|
||||
|
||||
pub struct C.sg_pipeline_info {
|
||||
|
||||
}
|
||||
|
||||
pub struct C.sg_pipeline {
|
||||
pub:
|
||||
id u32
|
||||
}
|
||||
pub fn (p C.sg_pipeline) free() { sg_destroy_pipeline(p) }
|
||||
|
||||
|
||||
pub struct C.sg_bindings {
|
||||
pub mut:
|
||||
_start_canary u32
|
||||
vertex_buffers [8]sg_buffer
|
||||
vertex_buffer_offsets [8]int
|
||||
index_buffer sg_buffer
|
||||
index_buffer_offset int
|
||||
vs_images [8]sg_image
|
||||
fs_images [8]sg_image
|
||||
_end_canary u32
|
||||
}
|
||||
|
||||
pub fn (b mut sg_bindings) set_vert_image(index int, img C.sg_image) {
|
||||
b.vs_images[index] = img
|
||||
}
|
||||
|
||||
pub fn (b mut 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) {
|
||||
sg_update_buffer(b.vertex_buffers[index], data, element_size * element_count)
|
||||
}
|
||||
|
||||
pub fn (b &C.sg_bindings) append_vert_buffer(index int, data voidptr, element_size int, element_count int) int {
|
||||
return sg_append_buffer(b.vertex_buffers[index], data, element_size * element_count)
|
||||
}
|
||||
|
||||
pub fn (b &C.sg_bindings) update_index_buffer(data voidptr, element_size int, element_count int) {
|
||||
sg_update_buffer(b.index_buffer, data, element_size * element_count)
|
||||
}
|
||||
|
||||
pub fn (b &C.sg_bindings) append_index_buffer(data voidptr, element_size int, element_count int) int {
|
||||
return sg_append_buffer(b.index_buffer, data, element_size * element_count)
|
||||
}
|
||||
|
||||
|
||||
pub struct C.sg_shader_desc {
|
||||
pub mut:
|
||||
_start_canary u32
|
||||
attrs [16]sg_shader_attr_desc
|
||||
vs C.sg_shader_stage_desc
|
||||
fs C.sg_shader_stage_desc
|
||||
label byteptr
|
||||
_end_canary u32
|
||||
}
|
||||
|
||||
pub fn (desc mut C.sg_shader_desc) set_vert_src(src string) &C.sg_shader_desc {
|
||||
desc.vs.source = src.str
|
||||
return desc
|
||||
}
|
||||
|
||||
pub fn (desc mut C.sg_shader_desc) set_frag_src(src string) &C.sg_shader_desc {
|
||||
desc.fs.source = src.str
|
||||
return desc
|
||||
}
|
||||
|
||||
pub fn (desc mut C.sg_shader_desc) set_vert_image(index int, name string) &C.sg_shader_desc {
|
||||
desc.vs.images[index].name = name.str
|
||||
desc.vs.images[index].@type = ._2d
|
||||
return desc
|
||||
}
|
||||
|
||||
pub fn (desc mut C.sg_shader_desc) set_frag_image(index int, name string) &C.sg_shader_desc {
|
||||
desc.fs.images[index].name = name.str
|
||||
desc.fs.images[index].@type = ._2d
|
||||
return desc
|
||||
}
|
||||
|
||||
pub fn (desc mut C.sg_shader_desc) set_vert_uniform_block_size(block_index, size int) &C.sg_shader_desc {
|
||||
desc.vs.uniform_blocks[block_index].size = size
|
||||
return desc
|
||||
}
|
||||
|
||||
pub fn (desc mut C.sg_shader_desc) set_frag_uniform_block_size(block_index, size int) &C.sg_shader_desc {
|
||||
desc.fs.uniform_blocks[block_index].size = size
|
||||
return desc
|
||||
}
|
||||
|
||||
pub fn (desc mut 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 = name.str
|
||||
desc.vs.uniform_blocks[block_index].uniforms[uniform_index].@type = @type
|
||||
return desc
|
||||
}
|
||||
|
||||
pub fn (desc mut 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 = 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 sg_make_shader(desc)
|
||||
}
|
||||
|
||||
|
||||
pub struct C.sg_shader_attr_desc {
|
||||
pub mut:
|
||||
name byteptr /* GLSL vertex attribute name (only required for GLES2) */
|
||||
sem_name byteptr /* HLSL semantic name */
|
||||
sem_index int /* HLSL semantic index */
|
||||
}
|
||||
|
||||
pub struct C.sg_shader_stage_desc {
|
||||
pub mut:
|
||||
source byteptr
|
||||
byte_code &byte
|
||||
byte_code_size int
|
||||
entry byteptr
|
||||
uniform_blocks [4]sg_shader_uniform_block_desc
|
||||
images [12]sg_shader_image_desc
|
||||
}
|
||||
|
||||
pub fn (desc mut C.sg_shader_stage_desc) set_image(index int, name string) C.sg_shader_stage_desc {
|
||||
desc.images[index].name = name.str
|
||||
desc.images[index].@type = ._2d
|
||||
return desc
|
||||
}
|
||||
|
||||
|
||||
pub struct C.sg_shader_uniform_block_desc {
|
||||
pub mut:
|
||||
size int
|
||||
uniforms [16]sg_shader_uniform_desc
|
||||
}
|
||||
|
||||
pub struct C.sg_shader_uniform_desc {
|
||||
pub mut:
|
||||
name byteptr
|
||||
@type UniformType
|
||||
array_count int
|
||||
}
|
||||
|
||||
pub struct C.sg_shader_image_desc {
|
||||
pub mut:
|
||||
name byteptr
|
||||
@type ImageType
|
||||
}
|
||||
|
||||
pub struct C.sg_shader_info {}
|
||||
|
||||
pub struct C.sg_context {
|
||||
id u32
|
||||
}
|
||||
|
||||
pub struct C.sg_shader {
|
||||
pub:
|
||||
id u32
|
||||
}
|
||||
pub fn (s C.sg_shader) free() { sg_destroy_shader(s) }
|
||||
|
||||
|
||||
pub struct C.sg_pass_desc {
|
||||
pub mut:
|
||||
_start_canary u32
|
||||
color_attachments [4]sg_attachment_desc
|
||||
depth_stencil_attachment C.sg_attachment_desc
|
||||
label byteptr
|
||||
_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]sg_color_attachment_action
|
||||
depth sg_depth_attachment_action
|
||||
stencil sg_stencil_attachment_action
|
||||
_end_canary u32
|
||||
}
|
||||
|
||||
pub struct C.sg_pass {
|
||||
id u32
|
||||
}
|
||||
pub fn (p C.sg_pass) free() { sg_destroy_pass(p) }
|
||||
|
||||
|
||||
pub struct C.sg_buffer_desc {
|
||||
pub mut:
|
||||
_start_canary u32
|
||||
size int
|
||||
@type BufferType
|
||||
usage Usage
|
||||
content byteptr
|
||||
label byteptr
|
||||
/* 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() { sg_destroy_buffer(b) }
|
||||
|
||||
|
||||
pub union 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
|
||||
|
||||
depth DepthLayers
|
||||
// depth int
|
||||
// union {
|
||||
// int depth;
|
||||
// int layers;
|
||||
// };
|
||||
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
|
||||
content C.sg_image_content
|
||||
label byteptr
|
||||
/* GL specific */
|
||||
gl_textures [2]u32
|
||||
/* Metal specific */
|
||||
mtl_textures [2]voidptr
|
||||
/* D3D11 specific */
|
||||
d3d11_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() { sg_destroy_image(i) }
|
||||
|
||||
|
||||
pub struct C.sg_image_content {
|
||||
pub mut:
|
||||
subimage [6][16]sg_subimage_content
|
||||
}
|
||||
|
||||
pub struct C.sg_subimage_content {
|
||||
pub mut:
|
||||
ptr voidptr /* pointer to subimage data */
|
||||
size int /* size in bytes of pointed-to subimage data */
|
||||
}
|
||||
|
||||
pub struct C.sg_features {
|
||||
pub:
|
||||
instancing bool
|
||||
origin_top_left bool
|
||||
multiple_render_targets bool
|
||||
msaa_render_targets bool
|
||||
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 */
|
||||
}
|
||||
|
||||
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_image_array_layers u32
|
||||
max_vertex_attrs u32 /* <= SG_MAX_VERTEX_ATTRIBUTES (only on some GLES2 impls) */
|
||||
}
|
||||
|
||||
pub struct C.sg_layout_desc {
|
||||
pub mut:
|
||||
buffers [8]sg_buffer_layout_desc
|
||||
attrs [16]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_depth_stencil_state {
|
||||
stencil_front sg_stencil_state
|
||||
stencil_back sg_stencil_state
|
||||
depth_compare_func CompareFunc
|
||||
depth_write_enabled bool
|
||||
stencil_enabled bool
|
||||
stencil_read_mask byte
|
||||
stencil_write_mask byte
|
||||
stencil_ref byte
|
||||
}
|
||||
|
||||
pub struct C.sg_stencil_state {
|
||||
fail_op StencilOp
|
||||
depth_fail_op StencilOp
|
||||
pass_op StencilOp
|
||||
compare_func CompareFunc
|
||||
}
|
||||
|
||||
pub struct C.sg_blend_state {
|
||||
enabled bool
|
||||
src_factor_rgb BlendFactor
|
||||
dst_factor_rgb BlendFactor
|
||||
op_rgb BlendOp
|
||||
src_factor_alpha BlendFactor
|
||||
dst_factor_alpha BlendFactor
|
||||
op_alpha BlendOp
|
||||
color_write_mask byte
|
||||
color_attachment_count int
|
||||
color_format PixelFormat
|
||||
depth_format PixelFormat
|
||||
blend_color [4]f32
|
||||
}
|
||||
|
||||
pub struct C.sg_rasterizer_state {
|
||||
pub mut:
|
||||
alpha_to_coverage_enabled bool
|
||||
cull_mode CullMode
|
||||
face_winding FaceWinding
|
||||
sample_count int
|
||||
depth_bias f32
|
||||
depth_bias_slope_scale f32
|
||||
depth_bias_clamp f32
|
||||
}
|
||||
|
||||
|
||||
pub struct C.sg_color_attachment_action {
|
||||
pub mut:
|
||||
action Action
|
||||
val [4]f32
|
||||
}
|
||||
|
||||
pub fn (action mut 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
|
||||
val f32
|
||||
}
|
||||
|
||||
pub struct C.sg_stencil_attachment_action {
|
||||
pub mut:
|
||||
action Action
|
||||
val 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_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
|
||||
// }
|
||||
}
|
||||
12
vlib/sokol/gfx/gfx_utils.v
Normal file
12
vlib/sokol/gfx/gfx_utils.v
Normal file
@@ -0,0 +1,12 @@
|
||||
module gfx
|
||||
|
||||
pub fn create_clear_pass(r, g, b, a f32) C.sg_pass_action {
|
||||
mut color_action := sg_color_attachment_action {
|
||||
action: C.SG_ACTION_CLEAR
|
||||
}
|
||||
color_action.set_color_values(r, g, b, a)
|
||||
|
||||
mut pass_action := sg_pass_action{}
|
||||
pass_action.colors[0] = color_action
|
||||
return pass_action
|
||||
}
|
||||
158
vlib/sokol/sapp/enums.v
Normal file
158
vlib/sokol/sapp/enums.v
Normal file
@@ -0,0 +1,158 @@
|
||||
module sapp
|
||||
|
||||
pub enum EventType {
|
||||
invalid
|
||||
key_down
|
||||
key_up
|
||||
char
|
||||
mouse_down
|
||||
mouse_up
|
||||
mouse_scroll
|
||||
mouse_move
|
||||
mouse_enter
|
||||
mouse_leave
|
||||
touches_began
|
||||
touches_moved
|
||||
touches_ended
|
||||
touches_cancelled
|
||||
resized
|
||||
iconified
|
||||
restored
|
||||
suspended
|
||||
resumed
|
||||
update_cursor
|
||||
quit_requested
|
||||
clipboard_pasted
|
||||
num
|
||||
}
|
||||
|
||||
pub enum MouseButton {
|
||||
invalid = -1
|
||||
left = 0
|
||||
right = 1
|
||||
middle = 2
|
||||
}
|
||||
|
||||
pub enum KeyCode {
|
||||
invalid = 0
|
||||
space = 32
|
||||
apostrophe = 39 /* ' */
|
||||
comma = 44 /* , */
|
||||
minus = 45 /* - */
|
||||
period = 46 /* . */
|
||||
slash = 47 /* / */
|
||||
_0 = 48
|
||||
_1 = 49
|
||||
_2 = 50
|
||||
_3 = 51
|
||||
_4 = 52
|
||||
_5 = 53
|
||||
_6 = 54
|
||||
_7 = 55
|
||||
_8 = 56
|
||||
_9 = 57
|
||||
semicolon = 59 /* ; */
|
||||
equal = 61 /* = */
|
||||
a = 65
|
||||
b = 66
|
||||
c = 67
|
||||
d = 68
|
||||
e = 69
|
||||
f = 70
|
||||
g = 71
|
||||
h = 72
|
||||
i = 73
|
||||
j = 74
|
||||
k = 75
|
||||
l = 76
|
||||
m = 77
|
||||
n = 78
|
||||
o = 79
|
||||
p = 80
|
||||
q = 81
|
||||
r = 82
|
||||
s = 83
|
||||
t = 84
|
||||
u = 85
|
||||
v = 86
|
||||
w = 87
|
||||
x = 88
|
||||
y = 89
|
||||
z = 90
|
||||
left_bracket = 91 /* [ */
|
||||
backslash = 92 /* \ */
|
||||
right_bracket = 93 /* ] */
|
||||
grave_accent = 96 /* ` */
|
||||
world_1 = 161 /* non-us #1 */
|
||||
world_2 = 162 /* non-us #2 */
|
||||
escape = 256
|
||||
enter = 257
|
||||
tab = 258
|
||||
backspace = 259
|
||||
insert = 260
|
||||
delete = 261
|
||||
right = 262
|
||||
left = 263
|
||||
down = 264
|
||||
up = 265
|
||||
page_up = 266
|
||||
page_down = 267
|
||||
home = 268
|
||||
end = 269
|
||||
caps_lock = 280
|
||||
scroll_lock = 281
|
||||
num_lock = 282
|
||||
print_screen = 283
|
||||
pause = 284
|
||||
f1 = 290
|
||||
f2 = 291
|
||||
f3 = 292
|
||||
f4 = 293
|
||||
f5 = 294
|
||||
f6 = 295
|
||||
f7 = 296
|
||||
f8 = 297
|
||||
f9 = 298
|
||||
f10 = 299
|
||||
f11 = 300
|
||||
f12 = 301
|
||||
f13 = 302
|
||||
f14 = 303
|
||||
f15 = 304
|
||||
f16 = 305
|
||||
f17 = 306
|
||||
f18 = 307
|
||||
f19 = 308
|
||||
f20 = 309
|
||||
f21 = 310
|
||||
f22 = 311
|
||||
f23 = 312
|
||||
f24 = 313
|
||||
f25 = 314
|
||||
kp_0 = 320
|
||||
kp_1 = 321
|
||||
kp_2 = 322
|
||||
kp_3 = 323
|
||||
kp_4 = 324
|
||||
kp_5 = 325
|
||||
kp_6 = 326
|
||||
kp_7 = 327
|
||||
kp_8 = 328
|
||||
kp_9 = 329
|
||||
kp_decimal = 330
|
||||
kp_divide = 331
|
||||
kp_multiply = 332
|
||||
kp_subtract = 333
|
||||
kp_add = 334
|
||||
kp_enter = 335
|
||||
kp_equal = 336
|
||||
left_shift = 340
|
||||
left_control = 341
|
||||
left_alt = 342
|
||||
left_super = 343
|
||||
right_shift = 344
|
||||
right_control = 345
|
||||
right_alt = 346
|
||||
right_super = 347
|
||||
menu = 348
|
||||
}
|
||||
188
vlib/sokol/sapp/sapp.v
Normal file
188
vlib/sokol/sapp/sapp.v
Normal file
@@ -0,0 +1,188 @@
|
||||
module sapp
|
||||
|
||||
/* returns true after sokol-app has been initialized */
|
||||
[inline]
|
||||
pub fn isvalid() bool {
|
||||
return C.sapp_isvalid()
|
||||
}
|
||||
|
||||
/* returns the current framebuffer width in pixels */
|
||||
[inline]
|
||||
pub fn width() int {
|
||||
return C.sapp_width()
|
||||
}
|
||||
|
||||
/* returns the current framebuffer height in pixels */
|
||||
[inline]
|
||||
pub fn height() int {
|
||||
return C.sapp_height()
|
||||
}
|
||||
|
||||
/* returns true when high_dpi was requested and actually running in a high-dpi scenario */
|
||||
[inline]
|
||||
pub fn high_dpi() bool {
|
||||
return C.sapp_high_dpi()
|
||||
}
|
||||
|
||||
/* returns the dpi scaling factor (window pixels to framebuffer pixels) */
|
||||
[inline]
|
||||
pub fn dpi_scale() f32 {
|
||||
return C.sapp_dpi_scale()
|
||||
}
|
||||
|
||||
/* show or hide the mobile device onscreen keyboard */
|
||||
[inline]
|
||||
pub fn show_keyboard(visible bool) {
|
||||
C.sapp_show_keyboard(visible)
|
||||
}
|
||||
|
||||
/* return true if the mobile device onscreen keyboard is currently shown */
|
||||
[inline]
|
||||
pub fn keyboard_shown() bool {
|
||||
return C.sapp_keyboard_shown()
|
||||
}
|
||||
|
||||
/* show or hide the mouse cursor */
|
||||
[inline]
|
||||
pub fn show_mouse(visible bool) {
|
||||
C.sapp_show_mouse(visible)
|
||||
}
|
||||
|
||||
/* show or hide the mouse cursor */
|
||||
[inline]
|
||||
pub fn mouse_shown() bool {
|
||||
return C.sapp_mouse_shown()
|
||||
}
|
||||
|
||||
/* return the userdata pointer optionally provided in sapp_desc */
|
||||
[inline]
|
||||
pub fn userdata() voidptr {
|
||||
return C.sapp_userdata()
|
||||
}
|
||||
|
||||
/* return a copy of the sapp_desc structure */
|
||||
[inline]
|
||||
pub fn query_desc() C.sapp_desc {
|
||||
return C.sapp_query_desc()
|
||||
}
|
||||
|
||||
/* initiate a "soft quit" (sends SAPP_EVENTTYPE_QUIT_REQUESTED) */
|
||||
[inline]
|
||||
pub fn request_quit() {
|
||||
C.sapp_request_quit()
|
||||
}
|
||||
|
||||
/* cancel a pending quit (when SAPP_EVENTTYPE_QUIT_REQUESTED has been received) */
|
||||
[inline]
|
||||
pub fn cancel_quit() {
|
||||
C.sapp_cancel_quit()
|
||||
}
|
||||
|
||||
/* intiate a "hard quit" (quit application without sending SAPP_EVENTTYPE_QUIT_REQUSTED) */
|
||||
[inline]
|
||||
pub fn quit() {
|
||||
C.sapp_quit()
|
||||
}
|
||||
|
||||
/* call from inside event callback to consume the current event (don't forward to platform) */
|
||||
[inline]
|
||||
pub fn consume_event() {
|
||||
C.sapp_consume_event()
|
||||
}
|
||||
|
||||
/* get the current frame counter (for comparison with sapp_event.frame_count) */
|
||||
[inline]
|
||||
pub fn frame_count() u64 {
|
||||
return C.sapp_frame_count()
|
||||
}
|
||||
|
||||
/* write string into clipboard */
|
||||
[inline]
|
||||
pub fn set_clipboard_string(str byteptr) {
|
||||
C.sapp_set_clipboard_string(str)
|
||||
}
|
||||
|
||||
/* read string from clipboard (usually during SAPP_EVENTTYPE_CLIPBOARD_PASTED) */
|
||||
[inline]
|
||||
pub fn get_clipboard_string() byteptr {
|
||||
return C.sapp_get_clipboard_string()
|
||||
}
|
||||
|
||||
/* special run-function for SOKOL_NO_ENTRY (in standard mode this is an empty stub) */
|
||||
[inline]
|
||||
pub fn run(desc &C.sapp_desc) int {
|
||||
return 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 */
|
||||
[inline]
|
||||
pub fn html5_ask_leave_site(ask bool) {
|
||||
C.sapp_html5_ask_leave_site(ask)
|
||||
}
|
||||
|
||||
/* Metal: get ARC-bridged pointer to Metal device object */
|
||||
[inline]
|
||||
pub fn metal_get_device() voidptr {
|
||||
return C.sapp_metal_get_device()
|
||||
}
|
||||
|
||||
/* Metal: get ARC-bridged pointer to this frame's renderpass descriptor */
|
||||
[inline]
|
||||
pub fn metal_get_renderpass_descriptor() voidptr {
|
||||
return C.sapp_metal_get_renderpass_descriptor()
|
||||
}
|
||||
|
||||
/* Metal: get ARC-bridged pointer to current drawable */
|
||||
[inline]
|
||||
pub fn metal_get_drawable() voidptr {
|
||||
return C.sapp_metal_get_drawable()
|
||||
}
|
||||
|
||||
/* macOS: get ARC-bridged pointer to macOS NSWindow */
|
||||
[inline]
|
||||
pub fn macos_get_window() voidptr {
|
||||
return C.sapp_macos_get_window()
|
||||
}
|
||||
|
||||
/* iOS: get ARC-bridged pointer to iOS UIWindow */
|
||||
[inline]
|
||||
pub fn ios_get_window() voidptr {
|
||||
return C.sapp_ios_get_window()
|
||||
}
|
||||
|
||||
/* D3D11: get pointer to ID3D11Device object */
|
||||
[inline]
|
||||
pub fn d3d11_get_device() voidptr {
|
||||
return C.sapp_d3d11_get_device()
|
||||
}
|
||||
|
||||
/* D3D11: get pointer to ID3D11DeviceContext object */
|
||||
[inline]
|
||||
pub fn d3d11_get_device_context() voidptr {
|
||||
return C.sapp_d3d11_get_device_context()
|
||||
}
|
||||
|
||||
/* D3D11: get pointer to ID3D11RenderTargetView object */
|
||||
[inline]
|
||||
pub fn d3d11_get_render_target_view() voidptr {
|
||||
return C.sapp_d3d11_get_render_target_view()
|
||||
}
|
||||
|
||||
/* D3D11: get pointer to ID3D11DepthStencilView */
|
||||
[inline]
|
||||
pub fn d3d11_get_depth_stencil_view() voidptr {
|
||||
return C.sapp_d3d11_get_depth_stencil_view()
|
||||
}
|
||||
|
||||
/* Win32: get the HWND window handle */
|
||||
[inline]
|
||||
pub fn win32_get_hwnd() voidptr {
|
||||
return C.sapp_win32_get_hwnd()
|
||||
}
|
||||
|
||||
69
vlib/sokol/sapp/sapp_funcs.v
Normal file
69
vlib/sokol/sapp/sapp_funcs.v
Normal file
@@ -0,0 +1,69 @@
|
||||
module sapp
|
||||
|
||||
/* returns true after sokol-app has been initialized */
|
||||
fn C.sapp_isvalid() bool
|
||||
/* returns the current framebuffer width in pixels */
|
||||
fn C.sapp_width() int
|
||||
/* returns the current framebuffer height in pixels */
|
||||
fn C.sapp_height() int
|
||||
/* returns true when high_dpi was requested and actually running in a high-dpi scenario */
|
||||
fn C.sapp_high_dpi() bool
|
||||
/* returns the dpi scaling factor (window pixels to framebuffer pixels) */
|
||||
fn C.sapp_dpi_scale() f32
|
||||
/* show or hide the mobile device onscreen keyboard */
|
||||
fn C.sapp_show_keyboard(visible bool)
|
||||
/* return true if the mobile device onscreen keyboard is currently shown */
|
||||
fn C.sapp_keyboard_shown() bool
|
||||
/* show or hide the mouse cursor */
|
||||
fn C.sapp_show_mouse(visible bool)
|
||||
/* show or hide the mouse cursor */
|
||||
fn C.sapp_mouse_shown() bool
|
||||
/* return the userdata pointer optionally provided in sapp_desc */
|
||||
fn C.sapp_userdata() voidptr
|
||||
/* return a copy of the sapp_desc structure */
|
||||
fn C.sapp_query_desc() C.sapp_desc
|
||||
/* initiate a "soft quit" (sends SAPP_EVENTTYPE_QUIT_REQUESTED) */
|
||||
fn C.sapp_request_quit()
|
||||
/* cancel a pending quit (when SAPP_EVENTTYPE_QUIT_REQUESTED has been received) */
|
||||
fn C.sapp_cancel_quit()
|
||||
/* intiate a "hard quit" (quit application without sending SAPP_EVENTTYPE_QUIT_REQUSTED) */
|
||||
fn C.sapp_quit()
|
||||
/* call from inside event callback to consume the current event (don't forward to platform) */
|
||||
fn C.sapp_consume_event()
|
||||
/* get the current frame counter (for comparison with sapp_event.frame_count) */
|
||||
fn C.sapp_frame_count() u64
|
||||
/* write string into clipboard */
|
||||
fn C.sapp_set_clipboard_string(str byteptr)
|
||||
/* read string from clipboard (usually during SAPP_EVENTTYPE_CLIPBOARD_PASTED) */
|
||||
fn C.sapp_get_clipboard_string() byteptr
|
||||
|
||||
/* special run-function for SOKOL_NO_ENTRY (in standard mode this is an empty stub) */
|
||||
fn C.sapp_run(desc &C.sapp_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 */
|
||||
fn C.sapp_html5_ask_leave_site(ask bool)
|
||||
|
||||
/* Metal: get ARC-bridged pointer to Metal device object */
|
||||
fn C.sapp_metal_get_device() voidptr
|
||||
/* Metal: get ARC-bridged pointer to this frame's renderpass descriptor */
|
||||
fn C.sapp_metal_get_renderpass_descriptor() voidptr
|
||||
/* Metal: get ARC-bridged pointer to current drawable */
|
||||
fn C.sapp_metal_get_drawable() voidptr
|
||||
/* macOS: get ARC-bridged pointer to macOS NSWindow */
|
||||
fn C.sapp_macos_get_window() voidptr
|
||||
/* iOS: get ARC-bridged pointer to iOS UIWindow */
|
||||
fn C.sapp_ios_get_window() voidptr
|
||||
|
||||
/* D3D11: get pointer to ID3D11Device object */
|
||||
fn C.sapp_d3d11_get_device() voidptr
|
||||
/* D3D11: get pointer to ID3D11DeviceContext object */
|
||||
fn C.sapp_d3d11_get_device_context() voidptr
|
||||
/* D3D11: get pointer to ID3D11RenderTargetView object */
|
||||
fn C.sapp_d3d11_get_render_target_view() voidptr
|
||||
/* D3D11: get pointer to ID3D11DepthStencilView */
|
||||
fn C.sapp_d3d11_get_depth_stencil_view() voidptr
|
||||
/* Win32: get the HWND window handle */
|
||||
fn C.sapp_win32_get_hwnd() voidptr
|
||||
69
vlib/sokol/sapp/sapp_structs.v
Normal file
69
vlib/sokol/sapp/sapp_structs.v
Normal file
@@ -0,0 +1,69 @@
|
||||
module sapp
|
||||
|
||||
pub struct C.sapp_desc {
|
||||
pub:
|
||||
init_cb fn() /* these are the user-provided callbacks without user data */
|
||||
frame_cb fn()
|
||||
cleanup_cb fn()
|
||||
event_cb fn( voidptr) //&sapp_event)
|
||||
fail_cb fn(byteptr)
|
||||
|
||||
user_data voidptr /* these are the user-provided callbacks with user data */
|
||||
init_userdata_cb fn(voidptr)
|
||||
frame_userdata_cb fn(voidptr)
|
||||
cleanup_userdata_cb fn(voidptr)
|
||||
event_userdata_cb fn(&C.sapp_event, voidptr)
|
||||
fail_userdata_cb fn(voidptr)
|
||||
|
||||
width int /* the preferred width of the window / canvas */
|
||||
height int /* the preferred height of the window / canvas */
|
||||
sample_count int /* MSAA sample count */
|
||||
swap_interval int /* the preferred swap interval (ignored on some platforms) */
|
||||
high_dpi bool /* whether the rendering canvas is full-resolution on HighDPI displays */
|
||||
fullscreen bool /* whether the window should be created in fullscreen mode */
|
||||
alpha bool /* whether the framebuffer should have an alpha channel (ignored on some platforms) */
|
||||
window_title byteptr /* the window title as UTF-8 encoded string */
|
||||
user_cursor bool /* if true, user is expected to manage cursor image in SAPP_EVENTTYPE_UPDATE_CURSOR */
|
||||
enable_clipboard bool /* enable clipboard access, default is false */
|
||||
clipboard_size int /* max size of clipboard content in bytes */
|
||||
|
||||
html5_canvas_name byteptr /* the name (id) of the HTML5 canvas element, default is "canvas" */
|
||||
html5_canvas_resize bool /* if true, the HTML5 canvas size is set to sapp_desc.width/height, otherwise canvas size is tracked */
|
||||
html5_preserve_drawing_buffer bool /* HTML5 only: whether to preserve default framebuffer content between frames */
|
||||
html5_premultiplied_alpha bool /* HTML5 only: whether the rendered pixels use premultiplied alpha convention */
|
||||
html5_ask_leave_site bool /* initial state of the internal html5_ask_leave_site flag (see sapp_html5_ask_leave_site()) */
|
||||
ios_keyboard_resizes_canvas bool /* if true, showing the iOS keyboard shrinks the canvas */
|
||||
gl_force_gles2 bool /* if true, setup GLES2/WebGL even if GLES3/WebGL2 is available */
|
||||
}
|
||||
|
||||
pub struct C.sapp_event {
|
||||
pub:
|
||||
frame_count u64
|
||||
@type EventType
|
||||
key_code KeyCode
|
||||
char_code u32
|
||||
key_repeat bool
|
||||
modifiers u32
|
||||
mouse_button MouseButton
|
||||
mouse_x f32
|
||||
mouse_y f32
|
||||
scroll_x f32
|
||||
scroll_y f32
|
||||
num_touches int
|
||||
touches [8]sapp_touchpoint
|
||||
window_width int
|
||||
window_height int
|
||||
framebuffer_width int
|
||||
framebuffer_height int
|
||||
}
|
||||
pub fn (e &C.sapp_event) str() string {
|
||||
return 'evt: frame_count=$e.frame_count, type=${e.@type}'
|
||||
}
|
||||
|
||||
pub struct C.sapp_touchpoint {
|
||||
pub:
|
||||
identifier u64
|
||||
pos_x f32
|
||||
pos_y f32
|
||||
changed bool
|
||||
}
|
||||
25
vlib/sokol/sfons/sfons.v
Normal file
25
vlib/sokol/sfons/sfons.v
Normal file
@@ -0,0 +1,25 @@
|
||||
module sfons
|
||||
import fontstash
|
||||
|
||||
#flag -I fontstash/thirdparty
|
||||
|
||||
[inline]
|
||||
pub fn sfons_create(width int, height int, flags int) &C.FONScontext {
|
||||
return C.sfons_create(width, height, flags)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn sfons_destroy(ctx &C.FONScontext) {
|
||||
C.sfons_destroy(ctx)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn sfons_rgba(r byte, g byte, b byte, a byte) u32 {
|
||||
return C.sfons_rgba(r, g, b, a)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn sfons_flush(ctx &C.FONScontext) {
|
||||
C.sfons_flush(ctx)
|
||||
}
|
||||
|
||||
6
vlib/sokol/sfons/sfons_funcs.v
Normal file
6
vlib/sokol/sfons/sfons_funcs.v
Normal file
@@ -0,0 +1,6 @@
|
||||
module sfons
|
||||
|
||||
fn C.sfons_create(width int, height int, flags int) &C.FONScontext
|
||||
fn C.sfons_destroy(ctx &FONScontext)
|
||||
fn C.sfons_rgba(r byte, g byte, b byte, a byte) u32
|
||||
fn C.sfons_flush(ctx &FONScontext)
|
||||
371
vlib/sokol/sgl/sgl.v
Normal file
371
vlib/sokol/sgl/sgl.v
Normal file
@@ -0,0 +1,371 @@
|
||||
module sgl
|
||||
|
||||
|
||||
/* setup/shutdown/misc */
|
||||
[inline]
|
||||
pub fn setup(desc &C.sgl_desc_t) {
|
||||
C.sgl_setup(desc)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn shutdown() {
|
||||
C.sgl_shutdown()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn error() C.sgl_error_t {
|
||||
return C.sgl_error()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn defaults() {
|
||||
C.sgl_defaults()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn rad(deg f32) f32 {
|
||||
return C.sgl_rad(deg)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn deg(rad f32) f32 {
|
||||
return C.sgl_deg(rad)
|
||||
}
|
||||
|
||||
/* create and destroy pipeline objects */
|
||||
[inline]
|
||||
pub fn make_pipeline(desc &C.sg_pipeline_desc) C.sgl_pipeline {
|
||||
return C.sgl_make_pipeline(desc)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn destroy_pipeline(pip C.sgl_pipeline) {
|
||||
C.sgl_destroy_pipeline(pip)
|
||||
}
|
||||
|
||||
/* render state functions */
|
||||
[inline]
|
||||
pub fn viewport(x int, y int, w int, h int, origin_top_left bool) {
|
||||
C.sgl_viewport(x, y, w, h, origin_top_left)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn scissor_rect(x int, y int, w int, h int, origin_top_left bool) {
|
||||
C.sgl_scissor_rect(x, y, w, h, origin_top_left)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn enable_texture() {
|
||||
C.sgl_enable_texture()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn disable_texture() {
|
||||
C.sgl_disable_texture()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn texture(img C.sg_image) {
|
||||
C.sgl_texture(img)
|
||||
}
|
||||
|
||||
/* pipeline stack functions */
|
||||
[inline]
|
||||
pub fn default_pipeline() {
|
||||
C.sgl_default_pipeline()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn load_pipeline(pip C.sgl_pipeline) {
|
||||
C.sgl_load_pipeline(pip)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn push_pipeline() {
|
||||
C.sgl_push_pipeline()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn pop_pipeline() {
|
||||
C.sgl_pop_pipeline()
|
||||
}
|
||||
|
||||
/* matrix stack functions */
|
||||
[inline]
|
||||
pub fn matrix_mode_modelview() {
|
||||
C.sgl_matrix_mode_modelview()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn matrix_mode_projection() {
|
||||
C.sgl_matrix_mode_projection()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn matrix_mode_texture() {
|
||||
C.sgl_matrix_mode_texture()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn load_identity() {
|
||||
C.sgl_load_identity()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn load_matrix(m []f32) {
|
||||
C.sgl_load_matrix(m.data)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn load_transpose_matrix(m []f32) {
|
||||
C.sgl_load_transpose_matrix(m.data)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn mult_matrix(m []f32) {
|
||||
C.sgl_mult_matrix(m.data)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn mult_transpose_matrix(m []f32) {
|
||||
C.sgl_mult_transpose_matrix(m.data)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn rotate(angle_rad f32, x f32, y f32, z f32) {
|
||||
C.sgl_rotate(angle_rad, x, y, z)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn scale(x f32, y f32, z f32) {
|
||||
C.sgl_scale(x, y, z)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn translate(x f32, y f32, z f32) {
|
||||
C.sgl_translate(x, y, z)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn frustum(l f32, r f32, b f32, t f32, n f32, f f32) {
|
||||
C.sgl_frustum(l, r, b, t, n, f)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn ortho(l f32, r f32, b f32, t f32, n f32, f f32) {
|
||||
C.sgl_ortho(l, r, b, t, n, f)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn perspective(fov_y f32, aspect f32, z_near f32, z_far f32) {
|
||||
C.sgl_perspective(fov_y, aspect, z_near, z_far)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn lookat(eye_x f32, eye_y f32, eye_z f32, center_x f32, center_y f32, center_z f32, up_x f32, up_y f32, up_z f32) {
|
||||
C.sgl_lookat(eye_x, eye_y, eye_z, center_x, center_y, center_z, up_x, up_y, up_z)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn push_matrix() {
|
||||
C.sgl_push_matrix()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn pop_matrix() {
|
||||
C.sgl_pop_matrix()
|
||||
}
|
||||
|
||||
/* these functions only set the internal 'current texcoord / color' (valid inside or outside begin/end) */
|
||||
[inline]
|
||||
pub fn t2f(u f32, v f32) {
|
||||
C.sgl_t2f(u, v)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn c3f(r f32, g f32, b f32) {
|
||||
C.sgl_c3f(r, g, b)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn c4f(r f32, g f32, b f32, a f32) {
|
||||
C.sgl_c4f(r, g, b, a)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn c3b(r byte, g byte, b byte) {
|
||||
C.sgl_c3b(r, g, b)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn c4b(r byte, g byte, b byte, a byte) {
|
||||
C.sgl_c4b(r, g, b, a)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn c1i(rgba u32) {
|
||||
C.sgl_c1i(rgba)
|
||||
}
|
||||
|
||||
/* define primitives, each begin/end is one draw command */
|
||||
[inline]
|
||||
pub fn begin_points() {
|
||||
C.sgl_begin_points()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn begin_lines() {
|
||||
C.sgl_begin_lines()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn begin_line_strip() {
|
||||
C.sgl_begin_line_strip()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn begin_triangles() {
|
||||
C.sgl_begin_triangles()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn begin_triangle_strip() {
|
||||
C.sgl_begin_triangle_strip()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn begin_quads() {
|
||||
C.sgl_begin_quads()
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v2f(x f32, y f32) {
|
||||
C.sgl_v2f(x, y)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v3f(x f32, y f32, z f32) {
|
||||
C.sgl_v3f(x, y, z)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v2f_t2f(x f32, y f32, u f32, v f32) {
|
||||
C.sgl_v2f_t2f(x, y, u, v)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v3f_t2f(x f32, y f32, z f32, u f32, v f32) {
|
||||
C.sgl_v3f_t2f(x, y, z, u, v)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v2f_c3f(x f32, y f32, r f32, g f32, b f32) {
|
||||
C.sgl_v2f_c3f(x, y, r, g, b)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v2f_c3b(x f32, y f32, r byte, g byte, b byte) {
|
||||
C.sgl_v2f_c3b(x, y, r, g, b)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v2f_c4f(x f32, y f32, r f32, g f32, b f32, a f32) {
|
||||
C.sgl_v2f_c4f(x, y, r, g, b, a)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v2f_c4b(x f32, y f32, r byte, g byte, b byte, a byte) {
|
||||
C.sgl_v2f_c4b(x, y, r, g, b, a)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v2f_c1i(x f32, y f32, rgba u32) {
|
||||
C.sgl_v2f_c1i(x, y, rgba)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v3f_c3f(x f32, y f32, z f32, r f32, g f32, b f32) {
|
||||
C.sgl_v3f_c3f(x, y, z, r, g, b)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v3f_c3b(x f32, y f32, z f32, r byte, g byte, b byte) {
|
||||
C.sgl_v3f_c3b(x, y, z, r, g, b)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v3f_c4f(x f32, y f32, z f32, r f32, g f32, b f32, a f32) {
|
||||
C.sgl_v3f_c4f(x, y, z, r, g, b, a)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v3f_c4b(x f32, y f32, z f32, r byte, g byte, b byte, a byte) {
|
||||
C.sgl_v3f_c4b(x, y, z, r, g, b, a)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v3f_c1i(x f32, y f32, z f32, rgba u32) {
|
||||
C.sgl_v3f_c1i(x, y, z, rgba)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v2f_t2f_c3f(x f32, y f32, u f32, v f32, r f32, g f32, b f32) {
|
||||
C.sgl_v2f_t2f_c3f(x, y, u, v, r, g, b)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v2f_t2f_c3b(x f32, y f32, u f32, v f32, r byte, g byte, b byte) {
|
||||
C.sgl_v2f_t2f_c3b(x, y, u, v, r, g, b)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v2f_t2f_c4f(x f32, y f32, u f32, v f32, r f32, g f32, b f32, a f32) {
|
||||
C.sgl_v2f_t2f_c4f(x, y, u, v, r, g, b, a)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v2f_t2f_c4b(x f32, y f32, u f32, v f32, r byte, g byte, b byte, a byte) {
|
||||
C.sgl_v2f_t2f_c4b(x, y, u, v, r, g, b, a)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v2f_t2f_c1i(x f32, y f32, u f32, v f32, rgba u32) {
|
||||
C.sgl_v2f_t2f_c1i(x, y, u, v, rgba)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v3f_t2f_c3f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32) {
|
||||
C.sgl_v3f_t2f_c3f(x, y, z, u, v, r, g, b)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v3f_t2f_c3b(x f32, y f32, z f32, u f32, v f32, r byte, g byte, b byte) {
|
||||
C.sgl_v3f_t2f_c3b(x, y, z, u, v, r, g, b)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v3f_t2f_c4f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32, a f32) {
|
||||
C.sgl_v3f_t2f_c4f(x, y, z, u, v, r, g, b, a)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v3f_t2f_c4b(x f32, y f32, z f32, u f32, v f32, r byte, g byte, b byte, a byte) {
|
||||
C.sgl_v3f_t2f_c4b(x, y, z, u, v, r, g, b, a)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn v3f_t2f_c1i(x f32, y f32, z f32, u f32, v f32, rgba u32) {
|
||||
C.sgl_v3f_t2f_c1i(x, y, z, u, v, rgba)
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn end() {
|
||||
C.sgl_end()
|
||||
}
|
||||
|
||||
/* render everything */
|
||||
[inline]
|
||||
pub fn draw() {
|
||||
C.sgl_draw()
|
||||
}
|
||||
|
||||
89
vlib/sokol/sgl/sgl_funcs.v
Normal file
89
vlib/sokol/sgl/sgl_funcs.v
Normal file
@@ -0,0 +1,89 @@
|
||||
module sgl
|
||||
|
||||
/* setup/shutdown/misc */
|
||||
fn C.sgl_setup(desc &C.sgl_desc_t)
|
||||
fn C.sgl_shutdown()
|
||||
fn C.sgl_error() C.sgl_error_t
|
||||
fn C.sgl_defaults()
|
||||
fn C.sgl_rad(deg f32) f32
|
||||
fn C.sgl_deg(rad f32) f32
|
||||
|
||||
/* create and destroy pipeline objects */
|
||||
fn C.sgl_make_pipeline(desc &C.sg_pipeline_desc) C.sgl_pipeline
|
||||
fn C.sgl_destroy_pipeline(pip C.sgl_pipeline)
|
||||
|
||||
/* render state functions */
|
||||
fn C.sgl_viewport(x int, y int, w int, h int, origin_top_left bool)
|
||||
fn C.sgl_scissor_rect(x int, y int, w int, h int, origin_top_left bool)
|
||||
fn C.sgl_enable_texture()
|
||||
fn C.sgl_disable_texture()
|
||||
fn C.sgl_texture(img C.sg_image)
|
||||
|
||||
/* pipeline stack functions */
|
||||
fn C.sgl_default_pipeline()
|
||||
fn C.sgl_load_pipeline(pip C.sgl_pipeline)
|
||||
fn C.sgl_push_pipeline()
|
||||
fn C.sgl_pop_pipeline()
|
||||
|
||||
/* matrix stack functions */
|
||||
fn C.sgl_matrix_mode_modelview()
|
||||
fn C.sgl_matrix_mode_projection()
|
||||
fn C.sgl_matrix_mode_texture()
|
||||
fn C.sgl_load_identity()
|
||||
fn C.sgl_load_matrix(m []f32) // should be [16]f32
|
||||
fn C.sgl_load_transpose_matrix(m []f32) // should be [16]f32
|
||||
fn C.sgl_mult_matrix(m []f32)
|
||||
fn C.sgl_mult_transpose_matrix(m []f32) // should be [16]f32
|
||||
fn C.sgl_rotate(angle_rad f32, x f32, y f32, z f32)
|
||||
fn C.sgl_scale(x f32, y f32, z f32)
|
||||
fn C.sgl_translate(x f32, y f32, z f32)
|
||||
fn C.sgl_frustum(l f32, r f32, b f32, t f32, n f32, f f32)
|
||||
fn C.sgl_ortho(l f32, r f32, b f32, t f32, n f32, f f32)
|
||||
fn C.sgl_perspective(fov_y f32, aspect f32, z_near f32, z_far f32)
|
||||
fn C.sgl_lookat(eye_x f32, eye_y f32, eye_z f32, center_x f32, center_y f32, center_z f32, up_x f32, up_y f32, up_z f32)
|
||||
fn C.sgl_push_matrix()
|
||||
fn C.sgl_pop_matrix()
|
||||
|
||||
/* these functions only set the internal 'current texcoord / color' (valid inside or outside begin/end) */
|
||||
fn C.sgl_t2f(u f32, v f32)
|
||||
fn C.sgl_c3f(r f32, g f32, b f32)
|
||||
fn C.sgl_c4f(r f32, g f32, b f32, a f32)
|
||||
fn C.sgl_c3b(r byte, g byte, b byte)
|
||||
fn C.sgl_c4b(r byte, g byte, b byte, a byte)
|
||||
fn C.sgl_c1i(rgba u32)
|
||||
|
||||
/* define primitives, each begin/end is one draw command */
|
||||
fn C.sgl_begin_points()
|
||||
fn C.sgl_begin_lines()
|
||||
fn C.sgl_begin_line_strip()
|
||||
fn C.sgl_begin_triangles()
|
||||
fn C.sgl_begin_triangle_strip()
|
||||
fn C.sgl_begin_quads()
|
||||
fn C.sgl_v2f(x f32, y f32)
|
||||
fn C.sgl_v3f(x f32, y f32, z f32)
|
||||
fn C.sgl_v2f_t2f(x f32, y f32, u f32, v f32)
|
||||
fn C.sgl_v3f_t2f(x f32, y f32, z f32, u f32, v f32)
|
||||
fn C.sgl_v2f_c3f(x f32, y f32, r f32, g f32, b f32)
|
||||
fn C.sgl_v2f_c3b(x f32, y f32, r byte, g byte, b byte)
|
||||
fn C.sgl_v2f_c4f(x f32, y f32, r f32, g f32, b f32, a f32)
|
||||
fn C.sgl_v2f_c4b(x f32, y f32, r byte, g byte, b byte, a byte)
|
||||
fn C.sgl_v2f_c1i(x f32, y f32, rgba u32)
|
||||
fn C.sgl_v3f_c3f(x f32, y f32, z f32, r f32, g f32, b f32)
|
||||
fn C.sgl_v3f_c3b(x f32, y f32, z f32, r byte, g byte, b byte)
|
||||
fn C.sgl_v3f_c4f(x f32, y f32, z f32, r f32, g f32, b f32, a f32)
|
||||
fn C.sgl_v3f_c4b(x f32, y f32, z f32, r byte, g byte, b byte, a byte)
|
||||
fn C.sgl_v3f_c1i(x f32, y f32, z f32, rgba u32)
|
||||
fn C.sgl_v2f_t2f_c3f(x f32, y f32, u f32, v f32, r f32, g f32, b f32)
|
||||
fn C.sgl_v2f_t2f_c3b(x f32, y f32, u f32, v f32, r byte, g byte, b byte)
|
||||
fn C.sgl_v2f_t2f_c4f(x f32, y f32, u f32, v f32, r f32, g f32, b f32, a f32)
|
||||
fn C.sgl_v2f_t2f_c4b(x f32, y f32, u f32, v f32, r byte, g byte, b byte, a byte)
|
||||
fn C.sgl_v2f_t2f_c1i(x f32, y f32, u f32, v f32, rgba u32)
|
||||
fn C.sgl_v3f_t2f_c3f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32)
|
||||
fn C.sgl_v3f_t2f_c3b(x f32, y f32, z f32, u f32, v f32, r byte, g byte, b byte)
|
||||
fn C.sgl_v3f_t2f_c4f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32, a f32)
|
||||
fn C.sgl_v3f_t2f_c4b(x f32, y f32, z f32, u f32, v f32, r byte, g byte, b byte, a byte)
|
||||
fn C.sgl_v3f_t2f_c1i(x f32, y f32, z f32, u f32, v f32, rgba u32)
|
||||
fn C.sgl_end()
|
||||
|
||||
/* render everything */
|
||||
fn C.sgl_draw()
|
||||
24
vlib/sokol/sgl/sgl_structs.v
Normal file
24
vlib/sokol/sgl/sgl_structs.v
Normal file
@@ -0,0 +1,24 @@
|
||||
module sgl
|
||||
|
||||
// should be in a proper module
|
||||
pub enum SglError {
|
||||
no_error
|
||||
vertices_full
|
||||
commands_full
|
||||
stack_overflow
|
||||
stack_underfloat
|
||||
}
|
||||
|
||||
pub struct C.sgl_pipeline {
|
||||
id u32
|
||||
}
|
||||
|
||||
pub struct C.sgl_desc_t {
|
||||
max_vertices int /* size for vertex buffer */
|
||||
max_commands int /* size of uniform- and command-buffers */
|
||||
pipeline_pool_size int /* size of the internal pipeline pool, default is 64 */
|
||||
color_format C.sg_pixel_format
|
||||
depth_format C.sg_pixel_format
|
||||
sample_count int
|
||||
face_winding C.sg_face_winding /* default front face winding is CCW */
|
||||
}
|
||||
39
vlib/sokol/sokol.v
Normal file
39
vlib/sokol/sokol.v
Normal file
@@ -0,0 +1,39 @@
|
||||
module sokol
|
||||
|
||||
#flag -I @VROOT/thirdparty/sokol
|
||||
#flag -I @VROOT/thirdparty/sokol/util
|
||||
|
||||
#flag darwin -fobjc-arc
|
||||
#flag linux -lX11 -lGL
|
||||
|
||||
#flag darwin -I/usr/local/Cellar/freetype/2.10.0/include/freetype2/
|
||||
#flag -lfreetype
|
||||
|
||||
|
||||
// METAL
|
||||
// #flag -DSOKOL_METAL
|
||||
// #flag darwin -framework Metal -framework Cocoa -framework MetalKit -framework QuartzCore
|
||||
|
||||
// OPENGL
|
||||
#flag -DSOKOL_GLCORE33
|
||||
#flag darwin -framework OpenGL -framework Cocoa -framework QuartzCore
|
||||
|
||||
|
||||
// for simplicity, all header includes are here because import order matters and we dont have any way
|
||||
// to ensure import order with V yet
|
||||
#define SOKOL_IMPL
|
||||
#define SOKOL_NO_ENTRY
|
||||
#include "sokol_app.h"
|
||||
|
||||
#define SOKOL_IMPL
|
||||
#define SOKOL_NO_DEPRECATED
|
||||
#include "sokol_gfx.h"
|
||||
|
||||
#define SOKOL_GL_IMPL
|
||||
#include "util/sokol_gl.h"
|
||||
|
||||
#define FONS_USE_FREETYPE
|
||||
#define FONTSTASH_IMPLEMENTATION
|
||||
#include "fontstash.h"
|
||||
#define SOKOL_FONTSTASH_IMPL
|
||||
#include "util/sokol_fontstash.h"
|
||||
Reference in New Issue
Block a user