sokol: fix examples and remove copy pasta
parent
94c3a912ba
commit
542b149290
|
@ -27,15 +27,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init(user_data voidptr) {
|
fn init(user_data voidptr) {
|
||||||
desc := C.sg_desc{
|
desc := sapp.create_desc() // C.sg_desc{
|
||||||
mtl_device: sapp.metal_get_device()
|
|
||||||
mtl_renderpass_descriptor_cb: sapp.metal_get_renderpass_descriptor
|
|
||||||
mtl_drawable_cb: sapp.metal_get_drawable
|
|
||||||
d3d11_device: sapp.d3d11_get_device()
|
|
||||||
d3d11_device_context: sapp.d3d11_get_device_context()
|
|
||||||
d3d11_render_target_view_cb: sapp.d3d11_get_render_target_view
|
|
||||||
d3d11_depth_stencil_view_cb: sapp.d3d11_get_depth_stencil_view
|
|
||||||
}
|
|
||||||
gfx.setup(&desc)
|
gfx.setup(&desc)
|
||||||
sgl_desc := C.sgl_desc_t{}
|
sgl_desc := C.sgl_desc_t{}
|
||||||
sgl.setup(&sgl_desc)
|
sgl.setup(&sgl_desc)
|
||||||
|
|
|
@ -38,16 +38,8 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init(mut state AppState) {
|
fn init(mut state AppState) {
|
||||||
// dont actually alocate this on the heap in real life
|
desc := sapp.create_desc()
|
||||||
gfx.setup(&C.sg_desc{
|
gfx.setup(&desc)
|
||||||
mtl_device: sapp.metal_get_device()
|
|
||||||
mtl_renderpass_descriptor_cb: sapp.metal_get_renderpass_descriptor
|
|
||||||
mtl_drawable_cb: sapp.metal_get_drawable
|
|
||||||
d3d11_device: sapp.d3d11_get_device()
|
|
||||||
d3d11_device_context: sapp.d3d11_get_device_context()
|
|
||||||
d3d11_render_target_view_cb: sapp.d3d11_get_render_target_view
|
|
||||||
d3d11_depth_stencil_view_cb: sapp.d3d11_get_depth_stencil_view
|
|
||||||
})
|
|
||||||
s := &C.sgl_desc_t{}
|
s := &C.sgl_desc_t{}
|
||||||
C.sgl_setup(s)
|
C.sgl_setup(s)
|
||||||
state.fons = sfons.create(512, 512, 1)
|
state.fons = sfons.create(512, 512, 1)
|
||||||
|
|
|
@ -92,16 +92,8 @@ fn main() {
|
||||||
|
|
||||||
fn init(user_data voidptr) {
|
fn init(user_data voidptr) {
|
||||||
mut state := &AppState(user_data)
|
mut state := &AppState(user_data)
|
||||||
// dont actually alocate this on the heap in real life
|
desc := sapp.create_desc()
|
||||||
gfx.setup(&C.sg_desc{
|
gfx.setup(&desc)
|
||||||
mtl_device: sapp.metal_get_device()
|
|
||||||
mtl_renderpass_descriptor_cb: sapp.metal_get_renderpass_descriptor
|
|
||||||
mtl_drawable_cb: sapp.metal_get_drawable
|
|
||||||
d3d11_device: sapp.d3d11_get_device()
|
|
||||||
d3d11_device_context: sapp.d3d11_get_device_context()
|
|
||||||
d3d11_render_target_view_cb: sapp.d3d11_get_render_target_view
|
|
||||||
d3d11_depth_stencil_view_cb: sapp.d3d11_get_depth_stencil_view
|
|
||||||
})
|
|
||||||
s := &C.sgl_desc_t{}
|
s := &C.sgl_desc_t{}
|
||||||
C.sgl_setup(s)
|
C.sgl_setup(s)
|
||||||
state.fons = sfons.create(512, 512, 1)
|
state.fons = sfons.create(512, 512, 1)
|
||||||
|
|
|
@ -68,15 +68,7 @@ fn (a App) draw() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init(user_data voidptr) {
|
fn init(user_data voidptr) {
|
||||||
desc := C.sg_desc{
|
desc := sapp.create_desc()
|
||||||
mtl_device: sapp.metal_get_device()
|
|
||||||
mtl_renderpass_descriptor_cb: sapp.metal_get_renderpass_descriptor
|
|
||||||
mtl_drawable_cb: sapp.metal_get_drawable
|
|
||||||
d3d11_device: sapp.d3d11_get_device()
|
|
||||||
d3d11_device_context: sapp.d3d11_get_device_context()
|
|
||||||
d3d11_render_target_view_cb: sapp.d3d11_get_render_target_view
|
|
||||||
d3d11_depth_stencil_view_cb: sapp.d3d11_get_depth_stencil_view
|
|
||||||
}
|
|
||||||
gfx.setup(&desc)
|
gfx.setup(&desc)
|
||||||
sgl_desc := C.sgl_desc_t{
|
sgl_desc := C.sgl_desc_t{
|
||||||
max_vertices: 50 * 65536
|
max_vertices: 50 * 65536
|
||||||
|
|
18
vlib/gg/gg.v
18
vlib/gg/gg.v
|
@ -74,23 +74,7 @@ pub:
|
||||||
|
|
||||||
fn gg_init_sokol_window(user_data voidptr) {
|
fn gg_init_sokol_window(user_data voidptr) {
|
||||||
mut g := &Context(user_data)
|
mut g := &Context(user_data)
|
||||||
mtl_desc := C.sg_mtl_context_desc {
|
desc := sapp.create_desc()
|
||||||
device: sapp.metal_get_device()
|
|
||||||
renderpass_descriptor_cb: sapp.metal_get_renderpass_descriptor
|
|
||||||
drawable_cb: sapp.metal_get_drawable
|
|
||||||
}
|
|
||||||
d3d11_desc := C.sg_d3d11_context_desc {
|
|
||||||
device: sapp.d3d11_get_device()
|
|
||||||
device_context: sapp.d3d11_get_device_context()
|
|
||||||
render_target_view_cb: sapp.d3d11_get_render_target_view
|
|
||||||
depth_stencil_view_cb: sapp.d3d11_get_depth_stencil_view
|
|
||||||
}
|
|
||||||
desc := C.sg_desc{
|
|
||||||
context: C.sg_context_desc{
|
|
||||||
metal: mtl_desc
|
|
||||||
d3d11: d3d11_desc
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
desc := C.sg_desc{
|
desc := C.sg_desc{
|
||||||
mtl_device: sapp.metal_get_device()
|
mtl_device: sapp.metal_get_device()
|
||||||
|
|
|
@ -3,6 +3,40 @@ module sapp
|
||||||
// Android needs a global reference to `g_desc`
|
// Android needs a global reference to `g_desc`
|
||||||
__global g_desc C.sapp_desc
|
__global g_desc C.sapp_desc
|
||||||
|
|
||||||
|
pub fn create_desc() C.sg_desc {
|
||||||
|
mtl_desc := C.sg_mtl_context_desc {
|
||||||
|
device: metal_get_device()
|
||||||
|
renderpass_descriptor_cb: metal_get_renderpass_descriptor
|
||||||
|
drawable_cb: metal_get_drawable
|
||||||
|
}
|
||||||
|
d3d11_desc := C.sg_d3d11_context_desc {
|
||||||
|
device: d3d11_get_device()
|
||||||
|
device_context: d3d11_get_device_context()
|
||||||
|
render_target_view_cb: d3d11_get_render_target_view
|
||||||
|
depth_stencil_view_cb: d3d11_get_depth_stencil_view
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Old Sokol
|
||||||
|
return C.sg_desc{
|
||||||
|
mtl_device: sapp.metal_get_device()
|
||||||
|
mtl_renderpass_descriptor_cb: sapp.metal_get_renderpass_descriptor
|
||||||
|
mtl_drawable_cb: sapp.metal_get_drawable
|
||||||
|
d3d11_device: sapp.d3d11_get_device()
|
||||||
|
d3d11_device_context: sapp.d3d11_get_device_context()
|
||||||
|
d3d11_render_target_view_cb: sapp.d3d11_get_render_target_view
|
||||||
|
d3d11_depth_stencil_view_cb: sapp.d3d11_get_depth_stencil_view
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
return C.sg_desc{
|
||||||
|
context: C.sg_context_desc{
|
||||||
|
metal: mtl_desc
|
||||||
|
d3d11: d3d11_desc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* returns true after sokol-app has been initialized */
|
/* returns true after sokol-app has been initialized */
|
||||||
[inline]
|
[inline]
|
||||||
pub fn isvalid() bool {
|
pub fn isvalid() bool {
|
||||||
|
|
|
@ -17,3 +17,4 @@ pub enum Key {
|
||||||
space = C.SAPP_KEYCODE_SPACE
|
space = C.SAPP_KEYCODE_SPACE
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue