I started a library thats similar to https://github.com/jimon/entrypoint
The point of it:
Other features I want to add but I'm not sure about them, or maybe add it after a 1.0:
So the way its used its pretty similar to your sokol samples, in fact these entry points there is what I started with.
Currently I'm implementing OSX and iOS, both supporting Metal & OpenGL (for OpenGL it looks like I still need something like glad)
So this is how your clear-metal looks now with sokol_entry, not much changed, in fact for OSX/iOS its mostly renaming...
//------------------------------------------------------------------------------
// clear-metal.c
//------------------------------------------------------------------------------
#include "sokol_gfx.h"
#include "sokol_entry/sokol_entry.h"
sg_pass_action pass_action;
void init(const sg_gfx_init_data *data) {
sg_desc desc = {
.mtl_device = data->mtl_device,
.mtl_renderpass_descriptor_cb = data->mtl_renderpass_descriptor_cb,
.mtl_drawable_cb = data->mtl_drawable_cb
};
sg_setup(&desc);
pass_action = (sg_pass_action) {
.colors[0] = { .action = SG_ACTION_CLEAR, .val = { 1.0f, 0.0f, 0.0f, 1.0f } }
};
}
static bool wasFullscreen;
void frame() {
sg_set_window_fullscreen(true);
if (sg_is_window_fullscreen()) {
wasFullscreen = true;
}
if (!sg_is_window_fullscreen() && wasFullscreen) {
sg_quite();
}
/* animate clear colors */
float g = pass_action.colors[0].val[1] + 0.01f;
if (g > 1.0f) g = 0.0f;
pass_action.colors[0].val[1] = g;
/* draw one frame */
sg_begin_default_pass(&pass_action, sg_get_window_width(), sg_get_window_width());
sg_end_pass();
sg_commit();
}
void shutdown() {
sg_shutdown();
}
void sg_main() {
sg_start(840, 480, 1, "Sokol Clear (Metal)", init, frame, shutdown);
}
So.. do you have interest in this? If not I will rename it to something else. Also any feedback is very welcome.
You can see my current WiP code here:
https://github.com/pjako/sokol/tree/entry/sokol_entry
Looks nice :) I'll give it a try ASAP and try to give some feedback. One reason why I didn't do this right away was the overlap with GLFW, and I also didn't want to accidently limit sokol_gfx to a frame-callback model (but for a general entry-point lib this is the only way to go).
Oh and another thing: I was thinking that only the sokol_gfx header should use the sg_ prefix (for sokolgfx. Other headers would use something different, e.g. an sokol_input.h would use si_.
I think I finally made up my mind about an application wrapper sokol header... My main problem was what needs to be different from GLFW to justify the effort. I'll start sketching out a sokol_app.h header, this will be fairly low prio until I have finished the move of Oryol to sokol-gfx.
I hope you don't mind that I'm not forking sokol_entry.h ;)
Here's what I thought up so far:
The main difference to sokol_entry.h would be that there will be less API functions for window control, basically I want to avoid functions that are not needed on mobile platforms as long as possible :)
I don't mind at all, its pretty sketchy in its current state anyways.
Reducing the input api sounds like a good idea to me. I was even thinking about delivering everything you need to do a frame update in a single big struct as a parameter of your frame update callback. (But this approach has some problems in some cases)
So I guess we can close this issue, looking forward to sokol_app.h :)
Most helpful comment
Looks nice :) I'll give it a try ASAP and try to give some feedback. One reason why I didn't do this right away was the overlap with GLFW, and I also didn't want to accidently limit sokol_gfx to a frame-callback model (but for a general entry-point lib this is the only way to go).
Oh and another thing: I was thinking that only the sokol_gfx header should use the sg_ prefix (for sokolgfx. Other headers would use something different, e.g. an sokol_input.h would use si_.