28 #include "./cassert.h"
29 #include "./deps/SOIL/SOIL.h"
30 #include "./glad/include/glad/glad.h"
219 extern BLZAPIENTRY
void BLZAPICALL
BLZ_Clear();
271 int max_sprites_per_bucket,
281 int *max_sprites_per_bucket,
307 extern BLZAPIENTRY
int BLZAPICALL
BLZ_Draw(
359 struct BLZ_Texture *texture,
int max_sprite_count);
368 int *max_sprite_count);
424 GLfloat *transformMatrix4x4);
550 int width,
int height);
575 char *vert,
char *frag);
605 extern BLZAPIENTRY
void BLZAPICALL
BLZ_Uniform1f(GLint location,
608 extern BLZAPIENTRY
void BLZAPICALL
BLZ_Uniform2f(GLint location,
612 extern BLZAPIENTRY
void BLZAPICALL
BLZ_Uniform3f(GLint location,
617 extern BLZAPIENTRY
void BLZAPICALL
BLZ_Uniform4f(GLint location,
623 extern BLZAPIENTRY
void BLZAPICALL
BLZ_Uniform1i(GLint location,
626 extern BLZAPIENTRY
void BLZAPICALL
BLZ_Uniform2i(GLint location,
630 extern BLZAPIENTRY
void BLZAPICALL
BLZ_Uniform3i(GLint location,
635 extern BLZAPIENTRY
void BLZAPICALL
BLZ_Uniform4i(GLint location,
662 const GLfloat *value);
667 const GLfloat *value);
672 const GLfloat *value);
677 const GLfloat *value);
682 const GLfloat *value);
687 const GLfloat *value);
692 const GLfloat *value);
697 const GLfloat *value);
702 const GLfloat *value);
759 const char *filename,
761 unsigned int texture_id,
773 const unsigned char *
const buffer,
776 unsigned int texture_id,
789 const char *filename,
806 #define BLZ_ASSERT(expr) CASSERT(expr, blaze_h)
808 BLZ_ASSERT(offsetof(struct
BLZ_Vertex, x) == 0)
809 BLZ_ASSERT(offsetof(struct BLZ_Vertex, u) == 8)
810 BLZ_ASSERT(offsetof(struct BLZ_Vertex, r) == 16)
A vector which contains 2 floats.
Definition: blaze.h:56
int height
Texture width in pixels.
Definition: blaze.h:109
BLZAPIENTRY int BLZAPICALL BLZ_SetTextureWrap(struct BLZ_Texture *texture, enum BLZ_TextureWrap x, enum BLZ_TextureWrap y)
Sets the texture wrapping mode.
Default flags.
Definition: blaze.h:250
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.
BLZAPIENTRY int BLZAPICALL BLZ_FreeRenderTarget(struct BLZ_RenderTarget *target)
Destroys the specified render target.
float y
Definition: blaze.h:75
GLfloat a
Definition: blaze.h:86
GLfloat y
Definition: blaze.h:84
BLZAPIENTRY int BLZAPICALL BLZ_SetViewport(int w, int h)
Sets the viewport size in pixels.
BLZAPIENTRY int BLZAPICALL BLZ_Present(struct BLZ_SpriteBatch *batch)
Draws everything from the specified dynamic batch to screen.
Disables sprite vertex array buffering, which lowers GPU memory usage, but sacrifices sprite drawing ...
Definition: blaze.h:255
BLZ_BlendFactor
Defines a blend factor in blending equation.
Definition: blaze.h:116
BLZAPIENTRY int BLZAPICALL BLZ_LowerDrawStatic(struct BLZ_StaticBatch *batch, struct BLZ_SpriteQuad *quad)
Lower level static batching function, called by BLZ_DrawStatic.
int width
OpenGL texture id (name)
Definition: blaze.h:108
BLZAPIENTRY int BLZAPICALL BLZ_FreeBatch(struct BLZ_SpriteBatch *batch)
Destroys the specified dynamic batch object.
BLZAPIENTRY void BLZAPICALL BLZ_Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
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.
enum BLZ_BlendFactor source
Definition: blaze.h:138
const struct BLZ_BlendFunc BLEND_NORMAL
Normal alpha blending (src = SRC_ALPHA, dst = ONE_MINUS_SRC_ALPHA)
BLZAPIENTRY void BLZAPICALL BLZ_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
GLfloat x
Definition: blaze.h:84
BLZAPIENTRY void BLZAPICALL BLZ_SetBlendMode(const struct BLZ_BlendFunc func)
Sets the currently used blend function.
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
BLZAPIENTRY void BLZAPICALL BLZ_Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
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.
BLZAPIENTRY void BLZAPICALL BLZ_Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
BLZ_SpriteFlip
Defines if the sprite should be flipped in any direction.
Definition: blaze.h:45
BLZ_TextureFilter
Defines texture filtering modes.
Definition: blaze.h:475
BLZAPIENTRY int BLZAPICALL BLZ_LowerDraw(struct BLZ_SpriteBatch *batch, GLuint texture, struct BLZ_SpriteQuad *quad)
Lower level dynamic batching function, called by BLZ_Draw.
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.
enum BLZ_BlendFactor destination
Source blend factor.
Definition: blaze.h:139
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
BLZ_ImageChannels
Defines which channels should be used when loading a texture.
Definition: blaze.h:714
BLZAPIENTRY void BLZAPICALL BLZ_Uniform2ui(GLint location, GLuint v0, GLuint v1)
GLfloat g
Definition: blaze.h:86
BLZAPIENTRY struct BLZ_StaticBatch BLZAPICALL * BLZ_CreateStatic(struct BLZ_Texture *texture, int max_sprite_count)
Creates a 'static' batch object.
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
BLZAPIENTRY struct BLZ_Shader *BLZAPICALL BLZ_CompileShader(char *vert, char *frag)
Compiles a shader program from the specified sources.
Defines a texture.
Definition: blaze.h:105
struct BLZ_StaticBatch BLZ_StaticBatch
Defines a pre-baked sprite batch which is useful for drawing static geometry like tiles...
Definition: blaze.h:169
BLZAPIENTRY void BLZAPICALL BLZ_Uniform1i(GLint location, GLint v0)
const struct BLZ_BlendFunc BLEND_ADDITIVE
Additive blending (src = ONE, dst = ONE)
struct BLZ_Texture texture
Underlying texture.
Definition: blaze.h:543
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
BLZAPIENTRY void BLZAPICALL BLZ_SetClearColor(struct BLZ_Vector4 color)
Sets the background clear color.
BLZAPIENTRY int BLZAPICALL BLZ_BindTexture(struct BLZ_Texture *texture, int slot)
Binds the specified texture to the specified slot number.
BLZAPIENTRY void BLZAPICALL BLZ_Uniform2f(GLint location, GLfloat v0, GLfloat v1)
float x
Definition: blaze.h:75
BLZAPIENTRY int BLZAPICALL BLZ_PresentStatic(struct BLZ_StaticBatch *batch, GLfloat *transformMatrix4x4)
Draws everything from the specified static batch to screen.
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
float x
Definition: blaze.h:66
BLZAPIENTRY int BLZAPICALL BLZ_GetMaxTextureSlots()
Returns the maximum count of available texture slots which can be used simultaneously for BLZ_BindTex...
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
BLZAPIENTRY int BLZAPICALL BLZ_FreeTexture(struct BLZ_Texture *texture)
Frees the specified texture.
Render target object.
Definition: blaze.h:538
BLZ_ImageFlags
Defines various options for image loading.
Definition: blaze.h:726
struct BLZ_SpriteBatch BLZ_SpriteBatch
Defines a dynamic sprite batch which is drawn when BLZ_Present is called.
Definition: blaze.h:162
GLfloat u
Definition: blaze.h:85
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.
A rectangle which has it's top-left corner position, width and height expressed in floats...
Definition: blaze.h:73
BLZAPIENTRY char *BLZAPICALL BLZ_GetLastError()
Returns a pointer to error string, if any.
BLZAPIENTRY void BLZAPICALL BLZ_Uniform1ui(GLint location, GLuint v0)
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
BLZAPIENTRY void BLZAPICALL BLZ_Uniform2i(GLint location, GLint v0, GLint v1)
BLZAPIENTRY int BLZAPICALL BLZ_SetTextureFiltering(struct BLZ_Texture *texture, enum BLZ_TextureFilter minification, enum BLZ_TextureFilter magnification)
Sets the texture filtering mode.
BLZAPIENTRY void BLZAPICALL BLZ_Uniform1f(GLint location, GLfloat v0)
const struct BLZ_BlendFunc BLEND_MULTIPLY
Multiplicative blending (src = DST_COLOR, dst = ZERO)
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
BLZAPIENTRY void BLZAPICALL BLZ_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
float h
Definition: blaze.h:75
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
BLZAPIENTRY GLint BLZAPICALL BLZ_GetUniformLocation(struct BLZ_Shader *shader, const char *name)
Returns the uniform location for the specified shader program.
float w
Definition: blaze.h:66
GLuint id
OpenGL framebuffer ID.
Definition: blaze.h:541
BLZ_InitFlags
Defines initialization flags for dynamic batches.
Definition: blaze.h:247
struct BLZ_Vertex vertices[4]
Definition: blaze.h:99
BLZAPIENTRY int BLZAPICALL BLZ_FreeBatchStatic(struct BLZ_StaticBatch *batch)
Destroys the specified static batch object.
BLZAPIENTRY int BLZAPICALL BLZ_Load(glGetProcAddress loader)
Loads the OpenGL functions using the specified loader and initializes the library.
A vector which contains 4 floats.
Definition: blaze.h:64
Underlying sprite quad data structure.
Definition: blaze.h:97
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.
BLZ_TextureWrap
Defines texture wrapping modes.
Definition: blaze.h:485
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.
GLfloat b
Definition: blaze.h:86
BLZ_SaveImageFormat
Defines formats in which images can be saved.
Definition: blaze.h:744
GLfloat v
Definition: blaze.h:85
BLZAPIENTRY struct BLZ_Shader BLZAPICALL * BLZ_GetDefaultShader()
Returns a pointer to the default shader program.
void(* glGetProcAddress)(const char *name)
OpenGL function loader signature.
Definition: blaze.h:180
float y
Definition: blaze.h:58
float w
Definition: blaze.h:75
float y
Definition: blaze.h:66
struct BLZ_Shader BLZ_Shader
Represents a GLSL shader handle.
Definition: blaze.h:174
BLZAPIENTRY void BLZAPICALL BLZ_Uniform3i(GLint location, GLint v0, GLint v1, GLint v2)
BLZAPIENTRY struct BLZ_RenderTarget *BLZAPICALL BLZ_CreateRenderTarget(int width, int height)
Creates a RGBA render target using specified parameters.
Defines a blending function.
Definition: blaze.h:136
float x
Definition: blaze.h:58
BLZAPIENTRY void BLZAPICALL BLZ_Clear()
Clears the screen with the specified color.
float z
Definition: blaze.h:66
BLZAPIENTRY int BLZAPICALL BLZ_UseShader(BLZ_Shader *program)
Sets the specified shader as the current.
GLfloat r
Definition: blaze.h:86
BLZAPIENTRY int BLZAPICALL BLZ_BindRenderTarget(struct BLZ_RenderTarget *target)
Binds the specified render target for output.
BLZAPIENTRY int BLZAPICALL BLZ_FreeShader(BLZ_Shader *program)
Frees memory used by specified shader program.
GLuint id
Definition: blaze.h:107
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.
Underlying vertex array structure.
Definition: blaze.h:82