blaze
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules
blaze.h File Reference
#include "stddef.h"
#include "./cassert.h"
#include "./deps/SOIL/SOIL.h"
#include "./glad/include/glad/glad.h"

Go to the source code of this file.

Data Structures

struct  BLZ_BlendFunc
 Defines a blending function. More...
 
struct  BLZ_Rectangle
 A rectangle which has it's top-left corner position, width and height expressed in floats. More...
 
struct  BLZ_RenderTarget
 Render target object. More...
 
struct  BLZ_SpriteQuad
 Underlying sprite quad data structure. More...
 
struct  BLZ_Texture
 Defines a texture. More...
 
struct  BLZ_Vector2
 A vector which contains 2 floats. More...
 
struct  BLZ_Vector4
 A vector which contains 4 floats. More...
 
struct  BLZ_Vertex
 Underlying vertex array structure. More...
 

Typedefs

typedef struct BLZ_Shader BLZ_Shader
 Represents a GLSL shader handle. More...
 
typedef struct BLZ_SpriteBatch BLZ_SpriteBatch
 Defines a dynamic sprite batch which is drawn when BLZ_Present is called. More...
 
typedef struct BLZ_StaticBatch BLZ_StaticBatch
 Defines a pre-baked sprite batch which is useful for drawing static geometry like tiles. More...
 
typedef void(* glGetProcAddress )(const char *name)
 OpenGL function loader signature. More...
 

Enumerations

enum  BLZ_BlendFactor { ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR, SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA }
 Defines a blend factor in blending equation. More...
 
enum  BLZ_ImageChannels { AUTO, GRAYSCALE, GRAYSCALE_ALPHA, RGB, RGBA }
 Defines which channels should be used when loading a texture. More...
 
enum  BLZ_ImageFlags { POWER_OF_TWO, MIPMAPS, TEXTURE_REPEATS, MULTIPLY_ALPHA, INVERT_Y, COMPRESS_TO_DXT, DDS_LOAD_DIRECT, NTSC_SAFE_RGB, CoCg_Y, TEXTURE_RECTANGLE }
 Defines various options for image loading. More...
 
enum  BLZ_InitFlags { DEFAULT, NO_BUFFERING }
 Defines initialization flags for dynamic batches. More...
 
enum  BLZ_SaveImageFormat { TGA, BMP, DDS }
 Defines formats in which images can be saved. More...
 
enum  BLZ_SpriteFlip { NONE, FLIP_H, FLIP_V, BOTH }
 Defines if the sprite should be flipped in any direction. More...
 
enum  BLZ_TextureFilter { NEAREST, LINEAR }
 Defines texture filtering modes. More...
 
enum  BLZ_TextureWrap { CLAMP_TO_EDGE, REPEAT, MIRRORED_REPEAT }
 Defines texture wrapping modes. More...
 

Functions

BLZAPIENTRY int BLZAPICALL BLZ_BindRenderTarget (struct BLZ_RenderTarget *target)
 Binds the specified render target for output. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_BindTexture (struct BLZ_Texture *texture, int slot)
 Binds the specified texture to the specified slot number. More...
 
BLZAPIENTRY void BLZAPICALL BLZ_Clear ()
 Clears the screen with the specified color. More...
 
BLZAPIENTRY struct BLZ_Shader
*BLZAPICALL 
BLZ_CompileShader (char *vert, char *frag)
 Compiles a shader program from the specified sources. More...
 
BLZAPIENTRY struct
BLZ_SpriteBatch *BLZAPICALL 
BLZ_CreateBatch (int max_buckets, int max_sprites_per_bucket, enum BLZ_InitFlags flags)
 Creates a new dynamic batch using the specified parameters. More...
 
BLZAPIENTRY struct
BLZ_RenderTarget *BLZAPICALL 
BLZ_CreateRenderTarget (int width, int height)
 Creates a RGBA render target using specified parameters. More...
 
BLZAPIENTRY struct
BLZ_StaticBatch BLZAPICALL * 
BLZ_CreateStatic (struct BLZ_Texture *texture, int max_sprite_count)
 Creates a 'static' batch object. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_Draw (struct BLZ_SpriteBatch *batch, struct BLZ_Texture *texture, struct BLZ_Vector2 position, struct BLZ_Rectangle *srcRectangle, float rotation, struct BLZ_Vector2 *origin, struct BLZ_Vector2 *scale, struct BLZ_Vector4 color, enum BLZ_SpriteFlip effects)
 Adds a sprite to specified batch using specified parameters. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_DrawImmediate (struct BLZ_Texture *texture, struct BLZ_Vector2 position, struct BLZ_Rectangle *srcRectangle, float rotation, struct BLZ_Vector2 *origin, struct BLZ_Vector2 *scale, struct BLZ_Vector4 color, enum BLZ_SpriteFlip effects)
 Immediately draws a sprite using the specified parameters to screen. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_DrawStatic (struct BLZ_StaticBatch *batch, struct BLZ_Vector2 position, struct BLZ_Rectangle *srcRectangle, float rotation, struct BLZ_Vector2 *origin, struct BLZ_Vector2 *scale, struct BLZ_Vector4 color, enum BLZ_SpriteFlip effects)
 Adds a sprite to specified batch using specified parameters. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_FreeBatch (struct BLZ_SpriteBatch *batch)
 Destroys the specified dynamic batch object. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_FreeBatchStatic (struct BLZ_StaticBatch *batch)
 Destroys the specified static batch object. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_FreeRenderTarget (struct BLZ_RenderTarget *target)
 Destroys the specified render target. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_FreeShader (BLZ_Shader *program)
 Frees memory used by specified shader program. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_FreeTexture (struct BLZ_Texture *texture)
 Frees the specified texture. More...
 
BLZAPIENTRY struct BLZ_Shader
BLZAPICALL * 
BLZ_GetDefaultShader ()
 Returns a pointer to the default shader program. More...
 
BLZAPIENTRY char *BLZAPICALL BLZ_GetLastError ()
 Returns a pointer to error string, if any. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_GetMaxTextureSlots ()
 Returns the maximum count of available texture slots which can be used simultaneously for BLZ_BindTexture texture binding. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_GetOptions (struct BLZ_SpriteBatch *batch, int *max_buckets, int *max_sprites_per_bucket, enum BLZ_InitFlags *flags)
 Reads options specified in BLZ_CreateBatch for the specified batch object. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_GetOptionsStatic (struct BLZ_StaticBatch *batch, int *max_sprite_count)
 Reads options specified in BLZ_CreateStatic for the specified static batch object. More...
 
BLZAPIENTRY GLint BLZAPICALL BLZ_GetUniformLocation (struct BLZ_Shader *shader, const char *name)
 Returns the uniform location for the specified shader program. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_Load (glGetProcAddress loader)
 Loads the OpenGL functions using the specified loader and initializes the library. More...
 
BLZAPIENTRY struct BLZ_Texture
*BLZAPICALL 
BLZ_LoadTextureFromFile (const char *filename, enum BLZ_ImageChannels channels, unsigned int texture_id, enum BLZ_ImageFlags flags)
 Loads a texture from file. More...
 
BLZAPIENTRY struct BLZ_Texture
*BLZAPICALL 
BLZ_LoadTextureFromMemory (const unsigned char *const buffer, int buffer_length, enum BLZ_ImageChannels force_channels, unsigned int texture_id, enum BLZ_ImageFlags flags)
 Loads a texture from memory. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_LowerDraw (struct BLZ_SpriteBatch *batch, GLuint texture, struct BLZ_SpriteQuad *quad)
 Lower level dynamic batching function, called by BLZ_Draw. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_LowerDrawImmediate (GLuint texture, struct BLZ_SpriteQuad *quad)
 Lower level immediate drawing function, called by BLZ_DrawImmediate. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_LowerDrawStatic (struct BLZ_StaticBatch *batch, struct BLZ_SpriteQuad *quad)
 Lower level static batching function, called by BLZ_DrawStatic. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_Present (struct BLZ_SpriteBatch *batch)
 Draws everything from the specified dynamic batch to screen. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_PresentStatic (struct BLZ_StaticBatch *batch, GLfloat *transformMatrix4x4)
 Draws everything from the specified static batch to screen. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_SaveScreenshot (const char *filename, enum BLZ_SaveImageFormat format, int x, int y, int width, int height)
 Saves a screenshot to file. More...
 
BLZAPIENTRY void BLZAPICALL BLZ_SetBlendMode (const struct BLZ_BlendFunc func)
 Sets the currently used blend function. More...
 
BLZAPIENTRY void BLZAPICALL BLZ_SetClearColor (struct BLZ_Vector4 color)
 Sets the background clear color. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_SetTextureFiltering (struct BLZ_Texture *texture, enum BLZ_TextureFilter minification, enum BLZ_TextureFilter magnification)
 Sets the texture filtering mode. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_SetTextureWrap (struct BLZ_Texture *texture, enum BLZ_TextureWrap x, enum BLZ_TextureWrap y)
 Sets the texture wrapping mode. More...
 
BLZAPIENTRY int BLZAPICALL BLZ_SetViewport (int w, int h)
 Sets the viewport size in pixels. More...
 
BLZAPIENTRY void BLZAPICALL BLZ_Uniform1f (GLint location, GLfloat v0)
 
BLZAPIENTRY void BLZAPICALL BLZ_Uniform1i (GLint location, GLint v0)
 
BLZAPIENTRY void BLZAPICALL BLZ_Uniform1ui (GLint location, GLuint v0)
 
BLZAPIENTRY void BLZAPICALL BLZ_Uniform2f (GLint location, GLfloat v0, GLfloat v1)
 
BLZAPIENTRY void BLZAPICALL BLZ_Uniform2i (GLint location, GLint v0, GLint v1)
 
BLZAPIENTRY void BLZAPICALL BLZ_Uniform2ui (GLint location, GLuint v0, GLuint v1)
 
BLZAPIENTRY void BLZAPICALL BLZ_Uniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
 
BLZAPIENTRY void BLZAPICALL BLZ_Uniform3i (GLint location, GLint v0, GLint v1, GLint v2)
 
BLZAPIENTRY void BLZAPICALL BLZ_Uniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2)
 
BLZAPIENTRY void BLZAPICALL BLZ_Uniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
 
BLZAPIENTRY void BLZAPICALL BLZ_Uniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
 
BLZAPIENTRY void BLZAPICALL BLZ_Uniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
 
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
 
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
 
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
 
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
 
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
 
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
 
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
 
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
 
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
 
BLZAPIENTRY int BLZAPICALL BLZ_UseShader (BLZ_Shader *program)
 Sets the specified shader as the current. More...
 

Variables

const struct BLZ_BlendFunc BLEND_ADDITIVE
 Additive blending (src = ONE, dst = ONE) More...
 
const struct BLZ_BlendFunc BLEND_MULTIPLY
 Multiplicative blending (src = DST_COLOR, dst = ZERO) More...
 
const struct BLZ_BlendFunc BLEND_NORMAL
 Normal alpha blending (src = SRC_ALPHA, dst = ONE_MINUS_SRC_ALPHA) More...
 

Typedef Documentation

typedef struct BLZ_Shader BLZ_Shader

Represents a GLSL shader handle.

Defines a dynamic sprite batch which is drawn when BLZ_Present is called.

See also
BLZ_Draw
BLZ_LowerDraw
BLZ_Present

Defines a pre-baked sprite batch which is useful for drawing static geometry like tiles.

typedef void(* glGetProcAddress)(const char *name)

OpenGL function loader signature.

See also
BLZ_Load

Enumeration Type Documentation

Defines a blend factor in blending equation.

See also
BLZ_BlendFunc
Enumerator
ZERO 
ONE 
SRC_COLOR 
ONE_MINUS_SRC_COLOR 
DST_COLOR 
ONE_MINUS_DST_COLOR 
SRC_ALPHA 
ONE_MINUS_SRC_ALPHA 
DST_ALPHA 
ONE_MINUS_DST_ALPHA 

Defines if the sprite should be flipped in any direction.

Enumerator
NONE 
FLIP_H 
FLIP_V 
BOTH 

Variable Documentation

const struct BLZ_BlendFunc BLEND_ADDITIVE

Additive blending (src = ONE, dst = ONE)

const struct BLZ_BlendFunc BLEND_MULTIPLY

Multiplicative blending (src = DST_COLOR, dst = ZERO)

const struct BLZ_BlendFunc BLEND_NORMAL

Normal alpha blending (src = SRC_ALPHA, dst = ONE_MINUS_SRC_ALPHA)