blaze
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules
blaze.h
Go to the documentation of this file.
1 /*
2 MIT license
3 
4 Copyright 2019 (c) Adel Vilkov
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 SOFTWARE.
23 */
24 #ifndef _BLAZE_H
25 #define _BLAZE_H
26 
27 #include "stddef.h"
28 #include "./cassert.h"
29 #include "./deps/SOIL/SOIL.h"
30 #include "./glad/include/glad/glad.h"
31 
32 /* TODO: Check on Mac and compilers other than GCC */
33 /* \cond */
34 #define BLZAPICALL
35 #define BLZAPIENTRY
36 
37 /* ------------------------------- Data types ------------------------------- */
38 #define BLZ_TRUE 1
39 #define BLZ_FALSE 0
40 /* \endcond */
41 
46 {
47  NONE = 0,
48  FLIP_H = 1,
49  FLIP_V = 2,
51 };
52 
57 {
58  float x, y;
59 };
60 
65 {
66  float x, y, z, w;
67 };
68 
74 {
75  float x, y, w, h;
76 };
77 
78 #pragma pack(push, 1)
79 
82 struct BLZ_Vertex
83 {
84  GLfloat x, y;
85  GLfloat u, v;
86  GLfloat r, g, b, a;
87 };
88 #pragma pack(pop)
89 
98 {
99  struct BLZ_Vertex vertices[4];
100 };
101 
106 {
107  GLuint id;
108  int width;
109  int height;
110 };
111 
117 {
118  ZERO = GL_ZERO,
119  ONE = GL_ONE,
120  SRC_COLOR = GL_SRC_COLOR,
121  ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR,
122  DST_COLOR = GL_DST_COLOR,
123  ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR,
124  SRC_ALPHA = GL_SRC_ALPHA,
125  ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA,
126  DST_ALPHA = GL_DST_ALPHA,
127  ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA
128 };
129 
137 {
140 };
141 
145 extern const struct BLZ_BlendFunc BLEND_NORMAL;
149 extern const struct BLZ_BlendFunc BLEND_ADDITIVE;
153 extern const struct BLZ_BlendFunc BLEND_MULTIPLY;
154 
155 struct BLZ_SpriteBatch;
163 
164 struct BLZ_StaticBatch;
170 struct BLZ_Shader;
174 typedef struct BLZ_Shader BLZ_Shader;
175 
180 typedef void (*glGetProcAddress)(const char *name);
181 
182 #ifdef __cplusplus
183 extern "C"
184 {
185 #endif
186 
187  /* -------------------------------- API --------------------------------- */
199  extern BLZAPIENTRY int BLZAPICALL BLZ_Load(glGetProcAddress loader);
204  extern BLZAPIENTRY int BLZAPICALL BLZ_SetViewport(int w, int h);
209  extern BLZAPIENTRY char *BLZAPICALL BLZ_GetLastError();
214  extern BLZAPIENTRY void BLZAPICALL BLZ_SetClearColor(struct BLZ_Vector4 color);
219  extern BLZAPIENTRY void BLZAPICALL BLZ_Clear();
229  extern BLZAPIENTRY void BLZAPICALL BLZ_SetBlendMode(const struct BLZ_BlendFunc func);
248  {
250  DEFAULT = 0,
256  };
257 
269  extern BLZAPIENTRY struct BLZ_SpriteBatch *BLZAPICALL BLZ_CreateBatch(
270  int max_buckets,
271  int max_sprites_per_bucket,
272  enum BLZ_InitFlags flags);
273 
278  extern BLZAPIENTRY int BLZAPICALL BLZ_GetOptions(
279  struct BLZ_SpriteBatch *batch,
280  int *max_buckets,
281  int *max_sprites_per_bucket,
282  enum BLZ_InitFlags *flags);
283 
288  extern BLZAPIENTRY int BLZAPICALL BLZ_FreeBatch(struct BLZ_SpriteBatch *batch);
289 
307  extern BLZAPIENTRY int BLZAPICALL BLZ_Draw(
308  struct BLZ_SpriteBatch *batch,
309  struct BLZ_Texture *texture,
310  struct BLZ_Vector2 position,
311  struct BLZ_Rectangle *srcRectangle,
312  float rotation,
313  struct BLZ_Vector2 *origin,
314  struct BLZ_Vector2 *scale,
315  struct BLZ_Vector4 color,
316  enum BLZ_SpriteFlip effects);
317 
323  extern BLZAPIENTRY int BLZAPICALL BLZ_LowerDraw(
324  struct BLZ_SpriteBatch *batch,
325  GLuint texture,
326  struct BLZ_SpriteQuad *quad);
327 
331  extern BLZAPIENTRY int BLZAPICALL BLZ_Present(struct BLZ_SpriteBatch *batch);
358  extern BLZAPIENTRY struct BLZ_StaticBatch BLZAPICALL *BLZ_CreateStatic(
359  struct BLZ_Texture *texture, int max_sprite_count);
360 
366  extern BLZAPIENTRY int BLZAPICALL BLZ_GetOptionsStatic(
367  struct BLZ_StaticBatch *batch,
368  int *max_sprite_count);
369 
374  extern BLZAPIENTRY int BLZAPICALL BLZ_FreeBatchStatic(
375  struct BLZ_StaticBatch *batch);
376 
393  extern BLZAPIENTRY int BLZAPICALL BLZ_DrawStatic(
394  struct BLZ_StaticBatch *batch,
395  struct BLZ_Vector2 position,
396  struct BLZ_Rectangle *srcRectangle,
397  float rotation,
398  struct BLZ_Vector2 *origin,
399  struct BLZ_Vector2 *scale,
400  struct BLZ_Vector4 color,
401  enum BLZ_SpriteFlip effects);
402 
408  extern BLZAPIENTRY int BLZAPICALL BLZ_LowerDrawStatic(
409  struct BLZ_StaticBatch *batch,
410  struct BLZ_SpriteQuad *quad);
411 
422  extern BLZAPIENTRY int BLZAPICALL BLZ_PresentStatic(
423  struct BLZ_StaticBatch *batch,
424  GLfloat *transformMatrix4x4);
446  extern BLZAPIENTRY int BLZAPICALL BLZ_DrawImmediate(
447  struct BLZ_Texture *texture,
448  struct BLZ_Vector2 position,
449  struct BLZ_Rectangle *srcRectangle,
450  float rotation,
451  struct BLZ_Vector2 *origin,
452  struct BLZ_Vector2 *scale,
453  struct BLZ_Vector4 color,
454  enum BLZ_SpriteFlip effects);
455 
462  extern BLZAPIENTRY int BLZAPICALL BLZ_LowerDrawImmediate(
463  GLuint texture,
464  struct BLZ_SpriteQuad *quad);
476  {
477  NEAREST = GL_NEAREST,
478  LINEAR = GL_LINEAR,
479  };
480 
486  {
487  CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE,
488  REPEAT = GL_REPEAT,
489  MIRRORED_REPEAT = GL_MIRRORED_REPEAT
490  };
491 
496  extern BLZAPIENTRY int BLZAPICALL BLZ_GetMaxTextureSlots();
506  extern BLZAPIENTRY int BLZAPICALL BLZ_BindTexture(
507  struct BLZ_Texture *texture,
508  int slot);
509 
513  extern BLZAPIENTRY int BLZAPICALL BLZ_SetTextureFiltering(
514  struct BLZ_Texture *texture,
515  enum BLZ_TextureFilter minification,
516  enum BLZ_TextureFilter magnification);
517 
521  extern BLZAPIENTRY int BLZAPICALL BLZ_SetTextureWrap(
522  struct BLZ_Texture *texture,
523  enum BLZ_TextureWrap x,
524  enum BLZ_TextureWrap y);
525 
539  {
541  GLuint id;
544  };
545 
549  extern BLZAPIENTRY struct BLZ_RenderTarget *BLZAPICALL BLZ_CreateRenderTarget(
550  int width, int height);
551 
556  extern BLZAPIENTRY int BLZAPICALL BLZ_BindRenderTarget(struct BLZ_RenderTarget *target);
560  extern BLZAPIENTRY int BLZAPICALL BLZ_FreeRenderTarget(struct BLZ_RenderTarget *target);
574  extern BLZAPIENTRY struct BLZ_Shader *BLZAPICALL BLZ_CompileShader(
575  char *vert, char *frag);
576 
580  extern BLZAPIENTRY int BLZAPICALL BLZ_UseShader(BLZ_Shader *program);
584  extern BLZAPIENTRY int BLZAPICALL BLZ_FreeShader(BLZ_Shader *program);
585 
589  extern BLZAPIENTRY struct BLZ_Shader BLZAPICALL *BLZ_GetDefaultShader();
590 
601  extern BLZAPIENTRY GLint BLZAPICALL BLZ_GetUniformLocation(
602  struct BLZ_Shader *shader,
603  const char *name);
604 
605  extern BLZAPIENTRY void BLZAPICALL BLZ_Uniform1f(GLint location,
606  GLfloat v0);
607 
608  extern BLZAPIENTRY void BLZAPICALL BLZ_Uniform2f(GLint location,
609  GLfloat v0,
610  GLfloat v1);
611 
612  extern BLZAPIENTRY void BLZAPICALL BLZ_Uniform3f(GLint location,
613  GLfloat v0,
614  GLfloat v1,
615  GLfloat v2);
616 
617  extern BLZAPIENTRY void BLZAPICALL BLZ_Uniform4f(GLint location,
618  GLfloat v0,
619  GLfloat v1,
620  GLfloat v2,
621  GLfloat v3);
622 
623  extern BLZAPIENTRY void BLZAPICALL BLZ_Uniform1i(GLint location,
624  GLint v0);
625 
626  extern BLZAPIENTRY void BLZAPICALL BLZ_Uniform2i(GLint location,
627  GLint v0,
628  GLint v1);
629 
630  extern BLZAPIENTRY void BLZAPICALL BLZ_Uniform3i(GLint location,
631  GLint v0,
632  GLint v1,
633  GLint v2);
634 
635  extern BLZAPIENTRY void BLZAPICALL BLZ_Uniform4i(GLint location,
636  GLint v0,
637  GLint v1,
638  GLint v2,
639  GLint v3);
640 
641  extern BLZAPIENTRY void BLZAPICALL BLZ_Uniform1ui(GLint location,
642  GLuint v0);
643 
644  extern BLZAPIENTRY void BLZAPICALL BLZ_Uniform2ui(GLint location,
645  GLuint v0,
646  GLuint v1);
647 
648  extern BLZAPIENTRY void BLZAPICALL BLZ_Uniform3ui(GLint location,
649  GLuint v0,
650  GLuint v1,
651  GLuint v2);
652 
653  extern BLZAPIENTRY void BLZAPICALL BLZ_Uniform4ui(GLint location,
654  GLuint v0,
655  GLuint v1,
656  GLuint v2,
657  GLuint v3);
658 
659  extern BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix2fv(GLint location,
660  GLsizei count,
661  GLboolean transpose,
662  const GLfloat *value);
663 
664  extern BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix3fv(GLint location,
665  GLsizei count,
666  GLboolean transpose,
667  const GLfloat *value);
668 
669  extern BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix4fv(GLint location,
670  GLsizei count,
671  GLboolean transpose,
672  const GLfloat *value);
673 
674  extern BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix2x3fv(GLint location,
675  GLsizei count,
676  GLboolean transpose,
677  const GLfloat *value);
678 
679  extern BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix3x2fv(GLint location,
680  GLsizei count,
681  GLboolean transpose,
682  const GLfloat *value);
683 
684  extern BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix2x4fv(GLint location,
685  GLsizei count,
686  GLboolean transpose,
687  const GLfloat *value);
688 
689  extern BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix4x2fv(GLint location,
690  GLsizei count,
691  GLboolean transpose,
692  const GLfloat *value);
693 
694  extern BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix3x4fv(GLint location,
695  GLsizei count,
696  GLboolean transpose,
697  const GLfloat *value);
698 
699  extern BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix4x3fv(GLint location,
700  GLsizei count,
701  GLboolean transpose,
702  const GLfloat *value);
703 
715  {
716  AUTO = SOIL_LOAD_AUTO,
717  GRAYSCALE = SOIL_LOAD_L,
718  GRAYSCALE_ALPHA = SOIL_LOAD_LA,
719  RGB = SOIL_LOAD_RGB,
720  RGBA = SOIL_LOAD_RGBA
721  };
722 
727  {
729  MIPMAPS = 2,
732  INVERT_Y = 16,
736  CoCg_Y = 256,
738  };
739 
745  {
746  TGA = SOIL_SAVE_TYPE_TGA,
747  BMP = SOIL_SAVE_TYPE_BMP,
748  DDS = SOIL_SAVE_TYPE_DDS
749  };
750 
758  extern BLZAPIENTRY struct BLZ_Texture *BLZAPICALL BLZ_LoadTextureFromFile(
759  const char *filename,
760  enum BLZ_ImageChannels channels,
761  unsigned int texture_id,
762  enum BLZ_ImageFlags flags);
763 
772  extern BLZAPIENTRY struct BLZ_Texture *BLZAPICALL BLZ_LoadTextureFromMemory(
773  const unsigned char *const buffer,
774  int buffer_length,
775  enum BLZ_ImageChannels force_channels,
776  unsigned int texture_id,
777  enum BLZ_ImageFlags flags);
778 
788  extern BLZAPIENTRY int BLZAPICALL BLZ_SaveScreenshot(
789  const char *filename,
790  enum BLZ_SaveImageFormat format,
791  int x, int y,
792  int width, int height);
793 
797  extern BLZAPIENTRY int BLZAPICALL BLZ_FreeTexture(struct BLZ_Texture *texture);
800 #ifdef __cplusplus
801 }
802 #endif
803 
804 /* Compile-time assertions */
805 /* \cond */
806 #define BLZ_ASSERT(expr) CASSERT(expr, blaze_h)
807 BLZ_ASSERT(sizeof(struct BLZ_Vertex) == 32)
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)
811 #undef BLZ_ASSERT
812 /* \endcond */
813 
814 #endif
A vector which contains 2 floats.
Definition: blaze.h:56
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.
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.
Definition: blaze.h:127
Definition: blaze.h:734
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.
Definition: blaze.h:748
Definition: blaze.h:746
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
Definition: blaze.h:49
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
Definition: blaze.h:489
BLZAPIENTRY int BLZAPICALL BLZ_LowerDrawStatic(struct BLZ_StaticBatch *batch, struct BLZ_SpriteQuad *quad)
Lower level static batching function, called by BLZ_DrawStatic.
Definition: blaze.h:123
int width
OpenGL texture id (name)
Definition: blaze.h:108
Definition: blaze.h:126
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
Definition: blaze.h:477
Definition: blaze.h:737
BLZ_TextureFilter
Defines texture filtering modes.
Definition: blaze.h:475
Definition: blaze.h:118
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
Definition: blaze.h:717
BLZAPIENTRY void BLZAPICALL BLZ_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
Definition: blaze.h:48
Definition: blaze.h:50
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
Definition: blaze.h:716
Definition: blaze.h:487
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)
Definition: blaze.h:120
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
Definition: blaze.h:733
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
Definition: blaze.h:124
Definition: blaze.h:730
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
Definition: blaze.h:747
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 int BLZAPICALL BLZ_LowerDrawImmediate(GLuint texture, struct BLZ_SpriteQuad *quad)
Lower level immediate drawing function, called by BLZ_DrawImmediate.
BLZAPIENTRY void BLZAPICALL BLZ_Uniform1f(GLint location, GLfloat v0)
const struct BLZ_BlendFunc BLEND_MULTIPLY
Multiplicative blending (src = DST_COLOR, dst = ZERO)
Definition: blaze.h:122
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
Definition: blaze.h:735
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.
Definition: blaze.h:488
Definition: blaze.h:119
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
Definition: blaze.h:720
Definition: blaze.h:121
Definition: blaze.h:478
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
Definition: blaze.h:729
Definition: blaze.h:728
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
Definition: blaze.h:732
BLZAPIENTRY void BLZAPICALL BLZ_Clear()
Clears the screen with the specified color.
Definition: blaze.h:125
Definition: blaze.h:731
Definition: blaze.h:736
Definition: blaze.h:718
float z
Definition: blaze.h:66
BLZAPIENTRY int BLZAPICALL BLZ_UseShader(BLZ_Shader *program)
Sets the specified shader as the current.
Definition: blaze.h:719
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
Definition: blaze.h:47
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