libESTK v4.0.0 documentation
typedef enum {
ES_FAIL = 0 ,
ES_OK = 1 ,
} esErr ;
typedef enum {
ES_FALSE = 0 ,
ES_TRUE = 1 ,
} esBool ;
void esCheckGlError (void );
void * esFileAlloc (const char * file_name );
typedef struct { float x , y ; } esVec2f ;
typedef struct { float x , y , z ; } esVec3f ;
typedef struct {
float mat [3 * 3 ];
} esMat3f ;
typedef struct {
float mat [4 * 4 ];
} esMat4f ;
esVec3f esMat3f_MulVec3f (const esMat3f * m , esVec3f v );
typedef struct {
float x , y , z , w ;
} esQuatf ;
esQuatf esQuatf_normalize (esQuatf q );
esQuatf esQuatf_mul (esQuatf q0 , esQuatf q1 );
esQuatf esQuatf_local (esQuatf q , float angle );
void esQuatf_matrix (esMat3f * dst , esQuatf q );
typedef enum {
ES_INFO , // Information
ES_WARN , // Warning
ES_ERRO , // Error
ES_DEBU , // Debug
} esLogClass ;
typedef void (* esLogMessage ) (esLogClass class , const char * message );
void esLogCallback (esLogMessage callback );
void esLog (int class , const char * fmt , ...);
void esLogUnimplemented ();
void esGame_init (int screen_width , int screen_height );
void esGame_glSwap (void );
void esGame_loop (void (* frame )(float t ), void (* exit )(), int frame_rate );
void esGame_loopQuit (void );
void esGame_registerKey (int sdlkey , void (* callback )(int key , int down ));
void esGame_registerMouse (void (* callback ) (int button , int down , int x , int y , int dx , int dy ));
void esGame_captureMouse (void (* callback ) (int button , int down , int x , int y , int dx , int dy ));
void esGame_windowSize (int * w , int * h );
typedef enum {
ES_SHADER_VERT ,
ES_SHADER_FRAG ,
} esShaderType ;
typedef struct {
int glProgram ;
esUniform uniforms [UNIFORMS_MAX ];
int glShaders [SHADERS_MAX ];
int shaderCount ;
} esShader ;
void esShader_reset (esShader * shader );
esErr esShader_loadFile (esShader * shader ,
esShaderType type , const char * fileName );
esErr esShader_loadText (esShader * shader ,
esShaderType type , const char * source );
esErr esShader_compile (esShader * shader ,
const esShaderAttrib * attribs , int attribCount );
esErr esShader_dualFile (esShader * shader ,
const char * vertFile , const char * fragFile ,
const esShaderAttrib * attribs , int attribCount );
esErr esShader_dualText (esShader * shader ,
const char * vertSource , const char * fragSource ,
const esShaderAttrib * attribs , int attribCount );
void esShader_use (const esShader * shader );
void esShader_free (esShader * shader );
esErr esShader_uniformRegister (esShader * shader ,
esUniform reg , const char * name );
esErr esShader_uniformGl (esShader * shader , esUniform reg );
typedef enum {
ES_GEOBUF_STATIC ,
ES_GEOBUF_DYNAMIC ,
ES_GEOBUF_STREAM ,
} esGeoBufType ;
typedef enum {
ES_GEODATA_FLOAT ,
ES_GEODATA_INT ,
ES_GEODATA_UINT ,
ES_GEODATA_SHORT ,
ES_GEODATA_USHORT ,
ES_GEODATA_BYTE ,
ES_GEODATA_UBYTE ,
} esGeoDataType ;
typedef struct {
esGeoDataType dataType ;
unsigned int glBuf ;
} esGeoBuf ;
void esGeoBuf_create (esGeoBuf * buf );
void esGeoBuf_array (esGeoBuf * buf ,
const void * data , size_t size , esGeoBufType type );
void esGeoBuf_arraySub (esGeoBuf * buf ,
const void * data , size_t size , int bufOffset );
void esGeoBuf_element (esGeoBuf * buf ,
const void * data , size_t size , esGeoBufType type );
void esGeoBuf_free (esGeoBuf * buf );
typedef struct {
int bufCount ;
struct {
esGeoBuf * geobuf ;
esGeoDataType datatype ;
int elements ;
size_t offset , stride ;
esBool normalized ;
} buf [ES_GEOBUFS_MAX ];
} esGeo ;
void esGeo_reset (esGeo * geo , int bufCount );
void esGeo_point (esGeo * geo , int id , esGeoBuf * geobuf ,
esGeoDataType datatype , int elements ,
size_t offset , size_t stride , esBool normalized );
void esGeo_renderArray (const esGeo * geo , int vertices );
void esGeo_renderElements (const esGeo * geo , const esGeoBuf * indices ,
esGeoDataType dataType , int vertexCount );
void esProj_identity (esMat4f * mat );
void esProj_ortho (esMat4f * mat , float x0 , float y0 , float x1 , float y1 );
void esProj_perspective (
esMat4f * mat , float fov , float screenratio , float near , float far ,
esVec3f eye , esVec3f at , esVec3f up );
typedef enum {
TEX_NONE ,
TEX_LINEAR ,
} esTextureMipmap ;
typedef struct {
int w , h ;
int gltexture ;
} esTexture ;
esErr esTexture_load (esTexture * tex , const char * file_name ,
enum esTextureMipmap min , enum esTextureMipmap mag );
void esTexture_use (esTexture * tex );
void esTexture_free (esTexture * tex );
typedef struct {
unsigned textureCount , width , height ;
esGLuint frameBuffer , depthBuffer ;
esGLuint renderTextures [ES_FRAMEBUFFER_MAX_TEXTURES ];
} esMultiRender ;
esErr esMultiRender_create (esMultiRender * mr ,
unsigned width , unsigned height ,
esTextureMipmap mipMapMin , esTextureMipmap mipMapMag ,
unsigned textureCount , ...);
void esMultiRender_destroy (esMultiRender * mr );
void esMultiRender_bind (esMultiRender * mr );
void esMultiRender_unBind (void );
esMultiRender_bindTexture
void esMultiRender_bindTexture (esMultiRender * mr , unsigned textureId );
esMultiRender_bindTextureWithId
void esMultiRender_bindTextureWithId (esMultiRender * mr , unsigned textureId ,
unsigned openGlTextureId );
typedef struct {
Mix_Chunk * chunk ;
} esSound ;
esErr esSound_create (esSound * sn , const char * file_name );
void esSound_free (esSound * sn );
void esSound_play (esSound * sn );
typedef struct {
Mix_Music * music ;
} esMusic ;
esErr esMusic_create (esMusic * mu , const char * file_name );
void esMusic_free (esMusic * mu );
void esMusic_play (esMusic * mu );