sokol: fixes

pull/3831/head
lydiandy 2020-02-25 01:02:22 +08:00 committed by GitHub
parent 96da5b33c0
commit 3c0b73c2d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 114 additions and 48 deletions

View File

@ -82,7 +82,7 @@ pub enum PixelFormat {
etc2_rg11
etc2_rg11sn
num
_num
}
pub enum ResourceState {

View File

@ -82,6 +82,11 @@ pub fn append_buffer(buf C.sg_buffer, ptr voidptr, num_bytes int) int {
return C.sg_append_buffer(buf, ptr, num_bytes)
}
[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) {
@ -133,9 +138,56 @@ pub fn commit() {
C.sg_commit()
}
// getting information
[inline]
pub fn query_buffer_overflow(buf C.sg_buffer) bool {
return C.sg_query_buffer_overflow(buf)
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 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 sg_query_buffer_state(buf)
}
[inline]
pub fn query_image_state(img C.sg_image) C.sg_resource_state {
return sg_query_image_state(img)
}
[inline]
pub fn query_shader_state(shd C.sg_shader) C.sg_resource_state {
return sg_query_shader_state(shd)
}
[inline]
pub fn query_pipeline_state(pip C.sg_pipeline) C.sg_resource_state {
return sg_query_pipeline_state(pip)
}
[inline]
pub fn query_pass_state(pass C.sg_pass) C.sg_resource_state {
return sg_query_pass_state(pass)
}
// get runtime information about a resource
@ -164,32 +216,6 @@ 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 {
@ -216,3 +242,18 @@ pub fn query_pass_defaults(desc &C.sg_pass) C.sg_pass_desc {
return C.sg_query_pass_defaults(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)
}

View File

@ -19,6 +19,7 @@ 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
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)
@ -32,7 +33,19 @@ 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
// 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
@ -41,16 +54,14 @@ 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
/* 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)

View File

@ -325,13 +325,13 @@ pub mut:
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 */
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 */
}
pub struct C.sg_limits {
@ -339,8 +339,8 @@ 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_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) */
}

View File

@ -33,6 +33,13 @@ pub enum MouseButton {
middle = 2
}
pub enum Modifier {
shift = 1 //(1<<0)
ctrl = 2 //(1<<1)
alt = 4 //(1<<2)
super = 8 //(1<<3)
}
pub enum KeyCode {
invalid = 0
space = 32

View File

@ -186,3 +186,8 @@ pub fn win32_get_hwnd() voidptr {
return C.sapp_win32_get_hwnd()
}
/* Android: get native activity handle */
[inline]
pub fn android_get_native_activity() voidptr {
return C.sapp_android_get_native_activity()
}

View File

@ -67,3 +67,5 @@ fn C.sapp_d3d11_get_render_target_view() voidptr
fn C.sapp_d3d11_get_depth_stencil_view() voidptr
/* Win32: get the HWND window handle */
fn C.sapp_win32_get_hwnd() voidptr
/* Android: get native activity handle */
fn C.sapp_android_get_native_activity() voidptr

View File

@ -5,7 +5,7 @@ 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)
event_cb fn(&C.sapp_event) //&sapp_event)
fail_cb fn(byteptr)
user_data voidptr /* these are the user-provided callbacks with user data */
@ -13,7 +13,7 @@ pub:
frame_userdata_cb fn(voidptr)
cleanup_userdata_cb fn(voidptr)
event_userdata_cb fn(&C.sapp_event, voidptr)
fail_userdata_cb fn(voidptr)
fail_userdata_cb fn(byteptr,voidptr)
width int /* the preferred width of the window / canvas */
height int /* the preferred height of the window / canvas */