Source

dark-hammer / src / engine / engine.h

The branch 'v0.4' does not exist.
/***********************************************************************************
 * Copyright (c) 2012, Sepehr Taghdisian
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 *
 * - Redistributions of source code must retain the above copyright notice, 
 *   this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation 
 *   and/or other materials provided with the distribution.
 *
 ***********************************************************************************/

/** 
 * @mainpage Engine library API reference
 * Current version: 0.3.5
 */

/**
 * @defgroup eng Engine 
 */

#ifndef __ENGINE_H__
#define __ENGINE_H__

#include "core/types.h"
#include "engine-api.h"
#include "core/allocator.h"
#include "init-params.h"

/* fwd */
struct file_mgr;
struct timer_mgr;

struct frame_stats
{
    uint64 start_tick;
    uint32 frame;
    fl32   ft;
    uint32 fps;
};

struct eng_mem_stats
{
    size_t data_max;
    size_t data_size;
    size_t lsr_max;
    size_t lsr_size;
    size_t tmp0_total;
    size_t tmp0_max;    /* maximum memory allocated by main temp allocator */
    uint32 tmp0_max_frameid;
};

#ifdef __cplusplus
extern "C"  {
#endif

/**
 * resets engine structures
 * must be called at the start of the application __before__ any other calls
 * @ingroup eng
 */
ENGINE_API void eng_zero();


#if defined(_LINUX_)
/**
 * loads engine init params from json file
 * @param params returning (and memzero'd) init_params structure to be filled with config, @see init_params
 * @param conf_file valid json parameters file (absolute path)
 * @param xdisp X11 display object, can be fetched from running application
 * @param XVisualInfo a valid X11 VI object, created by application
 * @param wnd valid window handle for the renderer view
 * @ingroup eng
 */
ENGINE_API result_t eng_load_params(struct init_params* params, const char* conf_file,
		Display* xdisp, XVisualInfo* vi, Window wnd);
#elif defined(_WIN_)
/**
 * loads engine init params from json file
 * @param params returning (and memzero'd) init_params structure to be filled with config, @see init_params
 * @param conf_file valid json parameters file (absolute path)
 * @param hinst valid application instance handle, can be fetched by win32 `GetModuleHandle` function
 * @param hwnd valid window handle for renderer view
 * @ingroup eng
 */
ENGINE_API result_t eng_load_params(struct init_params* params, const char* conf_file,
		HINSTANCE hinst, HWND hwnd);
#endif
ENGINE_API void eng_unload_params(struct init_params* params);

/**
 * initializes the engine using parameters\n
 * @param params init params structure, should be filled by user or parsed from json file
 * @see eng_load_params
 * @see init_params
 * @ingroup eng
 */
ENGINE_API result_t eng_init(const struct init_params* params);

/**
 * releases engine and all it's sub-systems
 * @ingroup eng
 */
ENGINE_API void eng_release();

/**
 * progress one frame, all that is needed to be done in one frame is done by this function\n
 * updates components, renders scene, updates physics, etc.
 * @ingroup eng
 */
ENGINE_API void eng_update();

/**
 * returns engine frame allocator, frame allocator is actually main threads temp allocator\n
 * which is very fast, but doesn't have any 'free' operation and resets at the start of each frame
 * @ingroup eng
 */
ENGINE_API struct allocator* eng_get_framealloc();

/**
 * returns load-stay-resident memory allocator\n
 * should be used for initializing resident objects and structures
 * @ingroup eng
 */
ENGINE_API struct allocator* eng_get_lsralloc();

/**
 * returns main data allocator, for allocating scene objects
 * @ingroup eng
 */
ENGINE_API struct allocator* eng_get_dataalloc();

/** 
 * sends crucial keyboard messages to the UI for resposive in-game console\n
 * @param c is the last character input\n
 * in windows, it is mainly the result of WM_CHAR's 'wparam' argument
 * @param vkey virtual-key code of the last key pressed.\n
 * in windows, it is mainly the result of WM_KEYDOWN's 'wparam' argument
 * @ingroup eng
 */
ENGINE_API void eng_send_guimsgs(char c, uint32 vkey);


/* internal */
void eng_save_framealloc();
void eng_load_framealloc();
const struct frame_stats* eng_get_framestats();
const struct init_params* eng_get_params();
void eng_get_memstats(struct eng_mem_stats* stats);

#ifdef __cplusplus
}
#endif

#endif /* __ENGINE_H__ */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.