shengine pre-release
shengine by mrsinho
Loading...
Searching...
No Matches
Template code with comments

#ifdef __cplusplus
extern "C" {
#endif//__cplusplus
#include <shengine/shEngine.h>//most of engine declarations are here
#include <shengine/shExport.h>//required when building a shared library
uint8_t SH_ENGINE_EXPORT_FUNCTION triangle_start(ShEngine* p_engine) {
// First function to be called chronologically.
return 1;
}
uint8_t SH_ENGINE_EXPORT_FUNCTION triangle_update(ShEngine* p_engine) {
// This function is called once per frame.
return 1;
}
uint8_t SH_ENGINE_EXPORT_FUNCTION triangle_main_cmd_buffer(ShEngine* p_engine) {
// This function is called once per frame while the main engine command buffer is recording
return 1;
}
uint8_t SH_ENGINE_EXPORT_FUNCTION triangle_main_renderpass(ShEngine* p_engine) {
// This function is called once per frame inside the main engine renderpass (you can setup your own of course using direcly the Vulkan API or the shvulkan library, by running on the triangle_update function).
return 1;
}
uint8_t SH_ENGINE_EXPORT_FUNCTION triangle_frame_resize(ShEngine* p_engine) {
// When the window is resized, this function is called. It's useful to destroy pipelines and reload them with a new viewport.
return 1;
}
uint8_t SH_ENGINE_EXPORT_FUNCTION triangle_close(ShEngine* p_engine) {
// When the engine is released/restarted, this function is called.
return 1;
}
#ifdef SH_APPLICATION_TARGET_TYPE_EXECUTABLE
int main() {
ShEngine* p_engine = shAllocateEngine();
p_engine == NULL,
"main: invalid engine memory",
return -1
);
p_engine->application_host.p_start = (ShApplicationFunc*) &triangle_start;
p_engine->application_host.p_update = (ShApplicationFunc*) &triangle_update;
p_engine->application_host.p_main_cmd_buffer = (ShApplicationFunc*) &triangle_main_cmd_buffer;
p_engine->application_host.p_main_renderpass = (ShApplicationFunc*) &triangle_main_renderpass;
p_engine->application_host.p_frame_resize = (ShApplicationFunc*) &triangle_frame_resize;
p_engine->application_host.p_close = (ShApplicationFunc*) &triangle_close;
p_engine->window.title = "triangle";
shEditorMain(p_engine);
return 0;
}
#endif//SH_APPLICATION_TARGET_TYPE_EXECUTABLE
#ifdef __cplusplus
}
#endif//__cplusplus
uint8_t() ShApplicationFunc(void *)
Represents the function signature for the application's main function.
Definition shApplicationHost.h:106
int main()
Definition shEditor.c:44
Declares the shEditorMain function for interacting with the engine from the editor.
int shEditorMain(ShEngine *p_engine)
Main function for the editor to interact with the shengine module.
Definition shEditor.c:24
Declares the ShEngine structure and associated functions for managing the engine.
#define shAllocateEngine()
Allocates memory for a new ShEngine instance.
Definition shEngine.h:108
#define shEngineError(condition, msg, failure_expression)
Generates an error message for the shengine module.
Definition shEngine.h:124
Defines the export function attribute for the shengine module.
#define SH_ENGINE_EXPORT_FUNCTION
Specifies the export function attribute for non-Windows platforms.
Definition shExport.h:21
ShApplicationFunc * p_close
Definition shApplicationHost.h:128
ShApplicationFunc * p_update
Definition shApplicationHost.h:124
ShApplicationFunc * p_frame_resize
Definition shApplicationHost.h:127
ShApplicationFunc * p_main_cmd_buffer
Definition shApplicationHost.h:125
ShApplicationFunc * p_start
Definition shApplicationHost.h:123
ShApplicationFunc * p_main_renderpass
Definition shApplicationHost.h:126
Represents the ShEngine structure, which is the main instance of the engine.
Definition shEngine.h:78
ShApplicationHost application_host
Definition shEngine.h:96
ShWindow window
Definition shEngine.h:80
const char * title
Definition shWindow.h:60