library: "setcallback.." -> "on.."

This commit is contained in:
Adam
2024-08-17 16:29:41 +01:00
parent f4831a1380
commit ea9aab0a2c
4 changed files with 26 additions and 26 deletions

View File

@@ -1336,7 +1336,7 @@ void _bolt_gl_onDrawElements(GLenum mode, GLsizei count, GLenum type, const void
batch.texture_functions.compare = _bolt_gl_plugin_texture_compare;
batch.texture_functions.data = _bolt_gl_plugin_texture_data;
_bolt_plugin_handle_2d(&batch);
_bolt_plugin_handle_render2d(&batch);
}
}
if (type == GL_UNSIGNED_SHORT && mode == GL_TRIANGLES && c->bound_program->is_3d) {
@@ -1390,7 +1390,7 @@ void _bolt_gl_onDrawElements(GLenum mode, GLsizei count, GLenum type, const void
render.matrix_functions.to_screen_space = _bolt_gl_plugin_matrix3d_toscreenspace;
render.matrix_functions.world_pos = _bolt_gl_plugin_matrix3d_worldpos;
_bolt_plugin_handle_3d(&render);
_bolt_plugin_handle_render3d(&render);
}
}
}

View File

@@ -133,7 +133,7 @@ static uint64_t _bolt_plugin_map_hash(const void* item, uint64_t seed0, uint64_t
static struct hashmap* plugins;
// macro for defining callback functions "_bolt_plugin_handle_*" and "api_setcallback*"
// macro for defining callback functions "_bolt_plugin_handle_*" and "api_on*"
// e.g. DEFINE_CALLBACK(swapbuffers, SWAPBUFFERS, SwapBuffersEvent)
#define DEFINE_CALLBACK(APINAME, REGNAME, STRUCTNAME) \
void _bolt_plugin_handle_##APINAME(struct STRUCTNAME* e) { \
@@ -163,8 +163,8 @@ void _bolt_plugin_handle_##APINAME(struct STRUCTNAME* e) { \
} \
} \
} \
static int api_setcallback##APINAME(lua_State* state) { \
_bolt_check_argc(state, 1, "setcallback" #APINAME); \
static int api_on##APINAME(lua_State* state) { \
_bolt_check_argc(state, 1, "on" #APINAME); \
PUSHSTRING(state, REGNAME##_CB_REGISTRYNAME); \
if (lua_isfunction(state, 1)) { \
lua_pushvalue(state, 1); \
@@ -282,14 +282,14 @@ static int _bolt_api_init(lua_State* state) {
API_ADD(time)
API_ADD(datetime)
API_ADD(weekday)
API_ADD(setcallback2d)
API_ADD(setcallback3d)
API_ADD(setcallbackminimap)
API_ADD(setcallbackswapbuffers)
API_ADD(setcallbackmousemotion)
API_ADD(setcallbackmousebutton)
API_ADD(setcallbackmousebuttonup)
API_ADD(setcallbackscroll)
API_ADD(onrender2d)
API_ADD(onrender3d)
API_ADD(onminimap)
API_ADD(onswapbuffers)
API_ADD(onmousemotion)
API_ADD(onmousebutton)
API_ADD(onmousebuttonup)
API_ADD(onscroll)
API_ADD(createsurface)
API_ADD(createsurfacefromrgba)
API_ADD(createsurfacefrompng)
@@ -743,8 +743,8 @@ static void _bolt_check_argc(lua_State* state, int expected_argc, const char* fu
}
DEFINE_CALLBACK(swapbuffers, SWAPBUFFERS, SwapBuffersEvent)
DEFINE_CALLBACK(2d, BATCH2D, RenderBatch2D)
DEFINE_CALLBACK(3d, RENDER3D, Render3D)
DEFINE_CALLBACK(render2d, BATCH2D, RenderBatch2D)
DEFINE_CALLBACK(render3d, RENDER3D, Render3D)
DEFINE_CALLBACK(minimap, MINIMAP, RenderMinimapEvent)
DEFINE_CALLBACK(mousemotion, MOUSEMOTION, MouseMotionEvent)
DEFINE_CALLBACK(mousebutton, MOUSEBUTTON, MouseButtonEvent)

View File

@@ -271,10 +271,10 @@ void _bolt_plugin_stop(char* id, uint32_t id_length);
void _bolt_plugin_handle_swapbuffers(struct SwapBuffersEvent*);
/// Sends a RenderBatch2D to all plugins.
void _bolt_plugin_handle_2d(struct RenderBatch2D*);
void _bolt_plugin_handle_render2d(struct RenderBatch2D*);
/// Sends a Render3D to all plugins.
void _bolt_plugin_handle_3d(struct Render3D*);
void _bolt_plugin_handle_render3d(struct Render3D*);
/// Sends a RenderMinimap to all plugins.
void _bolt_plugin_handle_minimap(struct RenderMinimapEvent*);

View File

@@ -17,7 +17,7 @@
* --...
* ```
*
* After that, pass Lua functions to the `bolt.setcallback...` functions to set event callbacks.
* After that, pass Lua functions to the `bolt.on...` functions to set event callbacks.
*
* The 2D rendering pipeline is fairly simple. Images are drawn in large batches of vertices,
* usually 6 vertices per icon (three per triangle, two triangles.) Plugins should call the
@@ -146,7 +146,7 @@ static int api_createwindow(lua_State*);
///
/// The callback will be called every frame - that's anywhere from 5 to 150+ times per second - so
/// avoid using it for anything time-consuming.
static int api_setcallbackswapbuffers(lua_State*);
static int api_onswapbuffers(lua_State*);
/// [-1, +0, -]
/// Sets a callback function for rendering of 2D images, overwriting the previous callback, if any.
@@ -161,7 +161,7 @@ static int api_setcallbackswapbuffers(lua_State*);
/// The callback will be called an extremely high amount of times per second, so great care should
/// be taken to determine as quickly as possible whether any image is of interest or not, such as
/// by checking each image's width and height.
static int api_setcallback2d(lua_State*);
static int api_onrender2d(lua_State*);
/// [-1, +0, -]
/// Sets a callback function for rendering of 3D models, overwriting the previous callback, if any.
@@ -176,7 +176,7 @@ static int api_setcallback2d(lua_State*);
/// The callback will be called an extremely high amount of times per second, so great care should
/// be taken to determine as quickly as possible whether any image is of interest or not, such as
/// by checking the model's vertex count.
static int api_setcallback3d(lua_State*);
static int api_onrender3d(lua_State*);
/// [-1, +0, -]
/// Sets a callback function for rendering of a minimap background image, overwriting the previous
@@ -193,7 +193,7 @@ static int api_setcallback3d(lua_State*);
///
/// The pixel contents cannot be examined directly, however it's possible to query the image angle,
/// image scale (zoom level), and a rough estimate of the tile position it's centered on.
static int api_setcallbackminimap(lua_State*);
static int api_onminimap(lua_State*);
/// [-1, +0, -]
/// Sets a callback function for mouse motion events, overwriting the previous callback, if any.
@@ -208,7 +208,7 @@ static int api_setcallbackminimap(lua_State*);
///
/// The callback will be called with one param, that being a mouse motion object. All of the member
/// functions of that object can be found in this file, prefixed with "api_mouseevent_".
static int api_setcallbackmousemotion(lua_State*);
static int api_onmousemotion(lua_State*);
/// [-1, +0, -]
/// Sets a callback function for mouse button events, overwriting the previous callback, if any.
@@ -221,7 +221,7 @@ static int api_setcallbackmousemotion(lua_State*);
/// The callback will be called with one param, that being a mouse-button object. All of the member
/// functions of that object can be found in this file, prefixed with "api_mouseevent_" and
/// "api_mousebutton_".
static int api_setcallbackmousebutton(lua_State*);
static int api_onmousebutton(lua_State*);
/// [-1, +0, -]
/// Sets a callback function for mouse button release events, overwriting the previous callback, if
@@ -235,7 +235,7 @@ static int api_setcallbackmousebutton(lua_State*);
/// The callback will be called with one param, that being a mouse-button object. All of the member
/// functions of that object can be found in this file, prefixed with "api_mouseevent_" and
/// "api_mousebutton_".
static int api_setcallbackmousebuttonup(lua_State*);
static int api_onmousebuttonup(lua_State*);
/// [-1, +0, -]
/// Sets a callback function for mouse scroll events, overwriting the previous callback, if any.
@@ -248,7 +248,7 @@ static int api_setcallbackmousebuttonup(lua_State*);
/// The callback will be called with one param, that being a mouse-scroll object. All of the member
/// functions of that object can be found in this file, prefixed with "api_mouseevent_" and
/// "api_scroll_".
static int api_setcallbackscroll(lua_State*);
static int api_onscroll(lua_State*);
/// [-1, +1, -]
/// Returns the number of vertices in a 2D batch object.