Skip to content

Commit

Permalink
metal samples: osx_get_ => osx_
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Feb 13, 2024
1 parent 9d64a9e commit 3af935f
Show file tree
Hide file tree
Showing 20 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions metal/arraytex-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ typedef struct {
static void init(void) {
// setup sokol
sg_setup(&(sg_desc){
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});

Expand Down Expand Up @@ -219,7 +219,7 @@ static void frame() {
state.frame_index++;

// render the frame
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_get_swapchain() });
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_swapchain() });
sg_apply_pipeline(state.pip);
sg_apply_bindings(&state.bind);
sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &SG_RANGE(vs_params));
Expand Down
4 changes: 2 additions & 2 deletions metal/binshader-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef struct {

static void init(void) {
sg_setup(&(sg_desc){
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});

Expand Down Expand Up @@ -129,7 +129,7 @@ static void frame() {
hmm_mat4 model = HMM_MultiplyMat4(rxm, rym);
vs_params.mvp = HMM_MultiplyMat4(state.view_proj, model);

sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_get_swapchain() });
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_swapchain() });
sg_apply_pipeline(state.pip);
sg_apply_bindings(&state.bind);
sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &SG_RANGE(vs_params));
Expand Down
4 changes: 2 additions & 2 deletions metal/blend-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct {
static void init(void) {
sg_setup(&(sg_desc){
.pipeline_pool_size = NUM_BLEND_FACTORS * NUM_BLEND_FACTORS + 1,
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});

Expand Down Expand Up @@ -183,7 +183,7 @@ static void init(void) {
}

static void frame(void) {
sg_begin_pass(&(sg_pass){ .swapchain = osx_get_swapchain() });
sg_begin_pass(&(sg_pass){ .swapchain = osx_swapchain() });

/* draw a background quad */
sg_apply_pipeline(state.bg_pip);
Expand Down
4 changes: 2 additions & 2 deletions metal/bufferoffsets-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static struct {

static void init(void) {
sg_setup(&(sg_desc){
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});

Expand Down Expand Up @@ -94,7 +94,7 @@ static void init(void) {
}

static void frame(void) {
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_get_swapchain() });
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_swapchain() });
sg_apply_pipeline(state.pip);
// render the triangle
state.bind.vertex_buffer_offsets[0] = 0;
Expand Down
4 changes: 2 additions & 2 deletions metal/clear-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ static sg_pass_action pass_action;

static void init(void) {
sg_setup(&(sg_desc) {
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});

Expand All @@ -26,7 +26,7 @@ static void frame(void) {
pass_action.colors[0].clear_value.g = g;

// draw one frame
sg_begin_pass(&(sg_pass){ .action = pass_action, .swapchain = osx_get_swapchain() });
sg_begin_pass(&(sg_pass){ .action = pass_action, .swapchain = osx_swapchain() });
sg_end_pass();
sg_commit();
}
Expand Down
4 changes: 2 additions & 2 deletions metal/cube-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ typedef struct {
static void init(void) {
// setup sokol
sg_setup(&(sg_desc){
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});

Expand Down Expand Up @@ -146,7 +146,7 @@ static void frame(void) {
hmm_mat4 model = HMM_MultiplyMat4(rxm, rym);
vs_params.mvp = HMM_MultiplyMat4(state.view_proj, model);

sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_get_swapchain() });
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_swapchain() });
sg_apply_pipeline(state.pip);
sg_apply_bindings(&state.bind);
sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &SG_RANGE(vs_params));
Expand Down
4 changes: 2 additions & 2 deletions metal/dyntex-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static void game_of_life_update();
static void init(void) {
// setup sokol_gfx
sg_setup(&(sg_desc){
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});

Expand Down Expand Up @@ -190,7 +190,7 @@ static void frame(void) {
});

// render the frame
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_get_swapchain() });
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_swapchain() });
sg_apply_pipeline(state.pip);
sg_apply_bindings(&state.bind);
sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &SG_RANGE(vs_params));
Expand Down
4 changes: 2 additions & 2 deletions metal/imgui-metal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static sg_pass_action pass_action;
void init() {
// setup sokol_gfx and sokol_time
const sg_desc desc = {
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger = {
.func = slog_func,
}
Expand Down Expand Up @@ -105,7 +105,7 @@ void frame() {
}

// the sokol draw pass
sg_begin_pass({ .action = pass_action, .swapchain = osx_get_swapchain() });
sg_begin_pass({ .action = pass_action, .swapchain = osx_swapchain() });
simgui_render();
sg_end_pass();
sg_commit();
Expand Down
4 changes: 2 additions & 2 deletions metal/inject-metal.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
static void init(void) {
// setup sokol_gfx
sg_setup(&(sg_desc){
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger = {
.func = slog_func,
}
Expand Down Expand Up @@ -255,7 +255,7 @@ static void frame(void) {
state.counter++;
sg_update_image(state.bind.fs.images[0], &(sg_image_data){ .subimage[0][0] = SG_RANGE(state.pixels) });

sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_get_swapchain() });
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_swapchain() });
sg_apply_pipeline(state.pip);
sg_apply_bindings(&state.bind);
sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &SG_RANGE(vs_params));
Expand Down
4 changes: 2 additions & 2 deletions metal/instancing-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ typedef struct {
static void init(void) {
// setup sokol_gfx
sg_setup(&(sg_desc){
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});

Expand Down Expand Up @@ -179,7 +179,7 @@ static void frame(void) {
vs_params.mvp = HMM_MultiplyMat4(state.view_proj, HMM_Rotate(state.ry, HMM_Vec3(0.0f, 1.0f, 0.0f)));;

// ...and draw
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_get_swapchain() });
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_swapchain() });
sg_apply_pipeline(state.pip);
sg_apply_bindings(&state.bind);
sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &SG_RANGE(vs_params));
Expand Down
4 changes: 2 additions & 2 deletions metal/mipmap-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ typedef struct {
static void init(void) {
// setup sokol
sg_setup(&(sg_desc){
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});

Expand Down Expand Up @@ -213,7 +213,7 @@ static void frame(void) {
.vertex_buffers[0] = state.vbuf,
.fs.images[0] = state.img,
};
sg_begin_pass(&(sg_pass){ .swapchain = osx_get_swapchain() });
sg_begin_pass(&(sg_pass){ .swapchain = osx_swapchain() });
sg_apply_pipeline(state.pip);
for (int i = 0; i < 12; i++) {
const float x = ((float)(i & 3) - 1.5f) * 2.0f;
Expand Down
4 changes: 2 additions & 2 deletions metal/mrt-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ typedef struct {
static void init(void) {
/* setup sokol */
sg_setup(&(sg_desc){
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});

Expand Down Expand Up @@ -385,7 +385,7 @@ static void frame(void) {
// render fullscreen quad with the 'composed image'
sg_begin_pass(&(sg_pass){
.action = state.default_pass_action,
.swapchain = osx_get_swapchain()
.swapchain = osx_swapchain()
});
sg_apply_pipeline(state.fsq_pip);
sg_apply_bindings(&state.fsq_bind);
Expand Down
4 changes: 2 additions & 2 deletions metal/noninterleaved-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef struct {
static void init(void) {
// setup sokol
sg_setup(&(sg_desc){
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});

Expand Down Expand Up @@ -155,7 +155,7 @@ static void frame(void) {
hmm_mat4 model = HMM_MultiplyMat4(rxm, rym);
vs_params.mvp = HMM_MultiplyMat4(state.view_proj, model);

sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_get_swapchain() });
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_swapchain() });
sg_apply_pipeline(state.pip);
sg_apply_bindings(&state.bind);
sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &SG_RANGE(vs_params));
Expand Down
4 changes: 2 additions & 2 deletions metal/offscreen-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ typedef struct {
static void init(void) {
// setup sokol
sg_setup(&(sg_desc){
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});

Expand Down Expand Up @@ -299,7 +299,7 @@ static void frame(void) {
// previously rendered offscreen render-target as texture
sg_begin_pass(&(sg_pass){
.action = state.default_pass_action,
.swapchain = osx_get_swapchain()
.swapchain = osx_swapchain()
});
sg_apply_pipeline(state.default_pip);
sg_apply_bindings(&state.default_bind);
Expand Down
4 changes: 2 additions & 2 deletions metal/osxentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ typedef void(*osx_mouse_wheel_func)(float v);
/* entry function */
extern void osx_start(int w, int h, int sample_count, const char* title, osx_init_func, osx_frame_func, osx_shutdown_func);
/* return an initialized sg_environment struct */
sg_environment osx_get_environment(void);
sg_environment osx_environment(void);
/* return an initialized sg_swapchain struct */
sg_swapchain osx_get_swapchain(void);
sg_swapchain osx_swapchain(void);
/* get width and height of drawable */
extern int osx_width();
extern int osx_height();
Expand Down
4 changes: 2 additions & 2 deletions metal/osxentry.m
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ void osx_start(int w, int h, int smp_count, const char* title, osx_init_func ifu
#endif
}

sg_environment osx_get_environment(void) {
sg_environment osx_environment(void) {
return (sg_environment) {
.defaults = {
.sample_count = sample_count,
Expand All @@ -348,7 +348,7 @@ sg_environment osx_get_environment(void) {
};
}

sg_swapchain osx_get_swapchain(void) {
sg_swapchain osx_swapchain(void) {
return (sg_swapchain) {
.width = (int) [mtk_view drawableSize].width,
.height = (int) [mtk_view drawableSize].height,
Expand Down
4 changes: 2 additions & 2 deletions metal/quad-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static struct {
static void init(void) {
// setup sokol
sg_setup(&(sg_desc){
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});

Expand Down Expand Up @@ -83,7 +83,7 @@ static void init(void) {
}

static void frame(void) {
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_get_swapchain() });
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_swapchain() });
sg_apply_pipeline(state.pip);
sg_apply_bindings(&state.bind);
sg_draw(0, 6, 1);
Expand Down
4 changes: 2 additions & 2 deletions metal/releasetest-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static void init(void) {
.shader_pool_size = 4,
.pipeline_pool_size = 4,
.attachments_pool_size = 2,
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});
}
Expand Down Expand Up @@ -87,7 +87,7 @@ static void frame(void) {
});

// draw one frame
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_get_swapchain() });
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_swapchain() });
sg_apply_pipeline(state.pip);
sg_apply_bindings(&state.bind);
sg_draw(0, 3, 1);
Expand Down
4 changes: 2 additions & 2 deletions metal/texcube-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ typedef struct {
static void init(void) {
// setup sokol_gfx
sg_setup(&(sg_desc){
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});

Expand Down Expand Up @@ -184,7 +184,7 @@ static void frame(void) {
hmm_mat4 model = HMM_MultiplyMat4(rxm, rym);
vs_params.mvp = HMM_MultiplyMat4(state.view_proj, model);

sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_get_swapchain() });
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_swapchain() });
sg_apply_pipeline(state.pip);
sg_apply_bindings(&state.bind);
sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &SG_RANGE(vs_params));
Expand Down
4 changes: 2 additions & 2 deletions metal/triangle-metal.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static struct {
static void init(void) {
// setup sokol
sg_setup(&(sg_desc){
.environment = osx_get_environment(),
.environment = osx_environment(),
.logger.func = slog_func,
});

Expand Down Expand Up @@ -79,7 +79,7 @@ static void init(void) {
}

static void frame(void) {
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_get_swapchain() });
sg_begin_pass(&(sg_pass){ .action = state.pass_action, .swapchain = osx_swapchain() });
sg_apply_pipeline(state.pip);
sg_apply_bindings(&state.bind);
sg_draw(0, 3, 1);
Expand Down

0 comments on commit 3af935f

Please sign in to comment.