Pico Headers
|
A powerful OpenGL-based graphics library written in C99. More...
#include <stdbool.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
Go to the source code of this file.
Classes | |
struct | pgl_blend_mode_t |
Blend mode. More... | |
struct | pgl_vertex_t |
A vertex describes a point and the data associated with it (color and texture coordinates) More... | |
Typedefs | |
typedef uint32_t | pgl_size_t |
OpenGL compatible size type. | |
typedef float | pgl_v2f_t[2] |
2D floating point vector | |
typedef float | pgl_v3f_t[3] |
3D floating point vector | |
typedef float | pgl_v4f_t[4] |
4D floating point vector | |
typedef int32_t | pgl_v2i_t[2] |
2D integer vector | |
typedef int32_t | pgl_v3i_t[3] |
3D integer vector | |
typedef int32_t | pgl_v4i_t[4] |
4D integer vector | |
typedef float | pgl_m2_t[4] |
2x2 floating point matrix | |
typedef float | pgl_m3_t[9] |
3x3 floating point matrix | |
typedef float | pgl_m4_t[16] |
4x4 floating point matrix | |
typedef struct pgl_ctx_t | pgl_ctx_t |
Contains core data/state for an instance of the renderer. | |
typedef struct pgl_shader_t | pgl_shader_t |
Contains shader data/state. | |
typedef struct pgl_texture_t | pgl_texture_t |
Contains texture data/state. | |
typedef struct pgl_buffer_t | pgl_buffer_t |
Contains vertex buffer data/state. | |
typedef void *(* | pgl_loader_fn) (const char *name) |
Defines an OpenGL (GLAD) function loader. | |
Functions | |
int | pgl_global_init (pgl_loader_fn loader_fp, bool gles) |
Loads all supported OpenGL functions via GLAD. | |
pgl_error_t | pgl_get_error (pgl_ctx_t *ctx) |
Returns the current error code. | |
const char * | pgl_get_error_str (pgl_error_t code) |
Returns the string associated with the specified error code. | |
pgl_version_t | pgl_get_version () |
Returns the current OpenGL version in use by the library. | |
void | pgl_print_info () |
Prints system info. | |
pgl_ctx_t * | pgl_create_context (uint32_t w, uint32_t h, bool depth, uint32_t samples, bool srgb, void *mem_ctx) |
Creates an instance of the renderer. | |
void | pgl_destroy_context (pgl_ctx_t *ctx) |
Destroys a renderer context, releasing it's resources. | |
void | pgl_resize (pgl_ctx_t *ctx, uint32_t w, uint32_t h, bool reset_vp) |
Resizes the drawable dimensions. | |
pgl_shader_t * | pgl_create_shader (pgl_ctx_t *ctx, const char *vert_src, const char *frag_src) |
Creates a shader program. | |
void | pgl_destroy_shader (pgl_shader_t *shader) |
Destroys a shader program. | |
void | pgl_bind_shader (pgl_ctx_t *ctx, pgl_shader_t *shader) |
Activates a shader program for rendering. | |
uint64_t | pgl_get_shader_id (const pgl_shader_t *shader) |
Return the implementation specific shader ID. | |
pgl_texture_t * | pgl_create_texture (pgl_ctx_t *ctx, bool target, pgl_format_t fmt, bool srgb, int32_t w, int32_t h, bool smooth, bool repeat) |
Creates an empty texture. | |
pgl_texture_t * | pgl_texture_from_bitmap (pgl_ctx_t *ctx, pgl_format_t fmt, bool srgb, int32_t w, int32_t h, bool smooth, bool repeat, const uint8_t *bitmap) |
Creates a texture from a bitmap. | |
int | pgl_upload_texture (pgl_ctx_t *ctx, pgl_texture_t *texture, int32_t w, int32_t h, const uint8_t *bitmap) |
Uploads data from a bitmap into a texture. | |
void | pgl_update_texture (pgl_ctx_t *ctx, pgl_texture_t *texture, int x, int y, int w, int h, const uint8_t *bitmap) |
Updates a region of an existing texture. | |
int | pgl_generate_mipmap (pgl_texture_t *texture, bool linear) |
Generate mipmaps for the specified texture. | |
void | pgl_destroy_texture (pgl_texture_t *texture) |
Destroys a texture. | |
void | pgl_get_texture_size (const pgl_texture_t *texture, int *w, int *h) |
Gets texture size. | |
void | pgl_get_max_texture_size (int *w, int *h) |
uint64_t | pgl_get_texture_id (const pgl_texture_t *texture) |
Return the implementation specific texture ID. | |
void | pgl_bind_texture (pgl_ctx_t *ctx, pgl_texture_t *texture) |
Activates a texture for rendering. | |
int | pgl_set_render_target (pgl_ctx_t *ctx, pgl_texture_t *texture) |
Draw to texture. | |
void | pgl_clear (float r, float g, float b, float a) |
Clears the framebuffer to the specified color. | |
void | pgl_draw_array (pgl_ctx_t *ctx, pgl_primitive_t primitive, const pgl_vertex_t *vertices, pgl_size_t count, pgl_texture_t *texture, pgl_shader_t *shader) |
void | pgl_draw_indexed_array (pgl_ctx_t *ctx, pgl_primitive_t primitive, const pgl_vertex_t *vertices, pgl_size_t vertex_count, const uint32_t *indices, pgl_size_t index_count, pgl_texture_t *texture, pgl_shader_t *shader) |
pgl_buffer_t * | pgl_create_buffer (pgl_ctx_t *ctx, pgl_primitive_t primitive, const pgl_vertex_t *vertices, pgl_size_t count) |
Creates a buffer in VRAM to store an array of vertices that can then be rendered without having upload the vertices every time they are drawn. | |
void | pgl_sub_buffer_data (pgl_ctx_t *ctx, pgl_buffer_t *buffer, const pgl_vertex_t *vertices, pgl_size_t count, pgl_size_t offset) |
Substitutes the data in a buffer with new data. | |
void | pgl_destroy_buffer (pgl_buffer_t *buffer) |
Destroys a previously created buffer. | |
void | pgl_draw_buffer (pgl_ctx_t *ctx, const pgl_buffer_t *buffer, pgl_size_t start, pgl_size_t count, pgl_texture_t *texture, pgl_shader_t *shader) |
Draw a previously created buffer. | |
void | pgl_set_transpose (pgl_ctx_t *ctx, bool enabled) |
Turns matrix transposition on/off. | |
void | pgl_set_blend_mode (pgl_ctx_t *ctx, pgl_blend_mode_t mode) |
Set the blending mode. | |
void | pgl_reset_blend_mode (pgl_ctx_t *ctx) |
Resets the blend mode to standard alpha blending. | |
void | pgl_set_transform (pgl_ctx_t *ctx, const pgl_m4_t matrix) |
Sets the context's global tranformation matrix. | |
void | pgl_set_transform_3d (pgl_ctx_t *ctx, const pgl_m3_t matrix) |
3D variant of pgl_set_transform | |
void | pgl_reset_transform (pgl_ctx_t *ctx) |
Resets the context's transform to the identity matrix. | |
void | pgl_set_projection (pgl_ctx_t *ctx, const pgl_m4_t matrix) |
Sets a context's global projecton matrix. | |
void | pgl_set_projection_3d (pgl_ctx_t *ctx, const pgl_m3_t matrix) |
3D variant of pgl_set_projection | |
void | pgl_reset_projection (pgl_ctx_t *ctx) |
Resets the context's project to the identity matrix. | |
void | pgl_set_viewport (pgl_ctx_t *ctx, int32_t x, int32_t y, int32_t w, int32_t h) |
Sets the location and dimensions of the rendering viewport. | |
void | pgl_reset_viewport (pgl_ctx_t *ctx) |
Reset the viewport to the drawable dimensions of the context. | |
void | pgl_set_line_width (pgl_ctx_t *ctx, float line_width) |
Sets the line primitive width. | |
void | pgl_reset_line_width (pgl_ctx_t *ctx) |
Resets the line width to 1.0f. | |
void | pgl_reset_state (pgl_ctx_t *ctx) |
Resets the current state of the context. | |
void | pgl_push_state (pgl_ctx_t *ctx) |
Pushes the current state onto the state stack, allowing it to be restored later. | |
void | pgl_pop_state (pgl_ctx_t *ctx) |
Pops a state off of the state stack and makes it the current state. | |
void | pgl_clear_stack (pgl_ctx_t *ctx) |
Removes all states from the state stack. | |
void | pgl_set_bool (pgl_shader_t *shader, const char *name, bool value) |
Sets a boolean uniform. | |
void | pgl_set_1i (pgl_shader_t *shader, const char *name, int32_t a) |
Sets an integer uniform. | |
void | pgl_set_2i (pgl_shader_t *shader, const char *name, int32_t a, int32_t b) |
Sets a 2D integer uniform. | |
void | pgl_set_3i (pgl_shader_t *shader, const char *name, int32_t a, int32_t b, int32_t c) |
Sets a 3D integer uniform. | |
void | pgl_set_4i (pgl_shader_t *shader, const char *name, int32_t a, int32_t b, int32_t c, int32_t d) |
Sets a 4D integer uniform. | |
void | pgl_set_v2i (pgl_shader_t *shader, const char *name, const pgl_v2i_t vec) |
Sets a 2D integer uniform by vector. | |
void | pgl_set_v3i (pgl_shader_t *shader, const char *name, const pgl_v3i_t vec) |
Sets a 3D integer uniform by vector. | |
void | pgl_set_v4i (pgl_shader_t *shader, const char *name, const pgl_v4i_t vec) |
Sets a 4D integer uniform by vector. | |
void | pgl_set_1f (pgl_shader_t *shader, const char *name, float x) |
Sets an floating point uniform. | |
void | pgl_set_2f (pgl_shader_t *shader, const char *name, float x, float y) |
Sets a 2D floating point uniform. | |
void | pgl_set_3f (pgl_shader_t *shader, const char *name, float x, float y, float z) |
Sets a 3D floating point uniform. | |
void | pgl_set_4f (pgl_shader_t *shader, const char *name, float x, float y, float z, float w) |
Sets a 4D floating point uniform. | |
void | pgl_set_v2f (pgl_shader_t *shader, const char *name, const pgl_v2f_t vec) |
Sets a 2D floating point uniform by vector. | |
void | pgl_set_v3f (pgl_shader_t *shader, const char *name, const pgl_v3f_t vec) |
Sets a 3D floating point uniform by vector. | |
void | pgl_set_v4f (pgl_shader_t *shader, const char *name, const pgl_v4f_t vec) |
Sets a 4D floating point uniform by vector. | |
void | pgl_set_a1f (pgl_shader_t *shader, const char *name, const float array[], pgl_size_t count) |
Sends an array of floating point numbers. | |
void | pgl_set_a2f (pgl_shader_t *shader, const char *name, const pgl_v2f_t array[], pgl_size_t count) |
Sends an array of 2D floating point vectors. | |
void | pgl_set_a3f (pgl_shader_t *shader, const char *name, const pgl_v3f_t array[], pgl_size_t count) |
Sends an array of 3D floating point vectors. | |
void | pgl_set_a4f (pgl_shader_t *shader, const char *name, const pgl_v4f_t array[], pgl_size_t count) |
Sends an array of 4D floating point vectors. | |
void | pgl_set_m2 (pgl_shader_t *shader, const char *name, const pgl_m2_t matrix) |
Sets a 2x2 floating point matrix. | |
void | pgl_set_m3 (pgl_shader_t *shader, const char *name, const pgl_m3_t matrix) |
Sets a 3x3 floating point matrix. | |
void | pgl_set_m4 (pgl_shader_t *shader, const char *name, const pgl_m4_t matrix) |
Sets a 4x4 floating point matrix. | |
void | pgl_set_s2d (pgl_shader_t *shader, const char *name, int32_t value) |
Sets a 2D sampler uniform. | |
A powerful OpenGL-based graphics library written in C99.
============================================================================= WARNING: This file was automatically generated on 27/06/2024 15:49:38.
This library is an advanced 2D renderer built on top of OpenGL. It currently supports OpenGL 3.0+ and OpenGL ES 3+ as well.
The basic workflow is to initialize the library, create a context, load any shaders and/or textures needed, specify some geometry (vertices) and draw the buffer or array of vertices. A vertex consists of position, color, and uv coordinates.
There is a default shader that makes sensible assumptions about how vertices and textures will be used. It is likely to be sufficient unless performing advanced VFX.
The default shader exposes two uniform variables: 1) a projection matrix; and 2) an affine transformation matrix. These two matrices are multipled together to form the mapping from vertices to the screen.
State including blend mode, the projection and transform matrices, and the viewport parameters are managed using the state stack. This enables state changes to be isolated. Push the current state on the top of the stack, make some local changes, and pop the stack to restore the original state.
Uniforms can be set using a simple, fast, and concise API.
Please see the examples for more details.
To use this library in your project, add
#define PICO_GL_IMPLEMENTATION #include "pico_gl.h"
to a source file.
Must be defined before PICO_GL_IMPLEMENTATION
typedef uint32_t pgl_size_t |
OpenGL compatible size type.
typedef float pgl_v2f_t[2] |
2D floating point vector
typedef float pgl_v3f_t[3] |
3D floating point vector
typedef float pgl_v4f_t[4] |
4D floating point vector
typedef int32_t pgl_v2i_t[2] |
2D integer vector
typedef int32_t pgl_v3i_t[3] |
3D integer vector
typedef int32_t pgl_v4i_t[4] |
4D integer vector
typedef float pgl_m2_t[4] |
2x2 floating point matrix
typedef float pgl_m3_t[9] |
3x3 floating point matrix
typedef float pgl_m4_t[16] |
4x4 floating point matrix
typedef struct pgl_shader_t pgl_shader_t |
Contains shader data/state.
typedef struct pgl_texture_t pgl_texture_t |
Contains texture data/state.
typedef struct pgl_buffer_t pgl_buffer_t |
Contains vertex buffer data/state.
typedef void *(* pgl_loader_fn) (const char *name) |
Defines an OpenGL (GLAD) function loader.
name | The name of the function to load |
enum pgl_error_t |
Runtime error codes.
enum pgl_version_t |
enum pgl_format_t |
enum pgl_blend_factor_t |
Blend factors.
enum pgl_blend_eq_t |
enum pgl_primitive_t |
Drawing primitives.
int pgl_global_init | ( | pgl_loader_fn | loader_fp, |
bool | gles | ||
) |
Loads all supported OpenGL functions via GLAD.
IMPORTANT: A valid OpenGL context must exist for this function to succeed. This function must be called before any other PGL functions.
loader_fp | Function loader (can be NULL except for GLES contexts) |
gles | Set to true if using OpenGL ES |
pgl_error_t pgl_get_error | ( | pgl_ctx_t * | ctx | ) |
Returns the current error code.
const char * pgl_get_error_str | ( | pgl_error_t | code | ) |
Returns the string associated with the specified error code.
code | The error code to query |
pgl_version_t pgl_get_version | ( | ) |
Returns the current OpenGL version in use by the library.
Currently the library does not use OpenGL features outside of 3.0 and ES 3.0. This unlikely to change unless there is an incompatibility with more recent versions or the library is ported to OpenGL 2.1.
void pgl_print_info | ( | ) |
Prints system info.
pgl_ctx_t * pgl_create_context | ( | uint32_t | w, |
uint32_t | h, | ||
bool | depth, | ||
uint32_t | samples, | ||
bool | srgb, | ||
void * | mem_ctx | ||
) |
Creates an instance of the renderer.
w | The drawable width of the window in pixels |
h | The drawable height of the window in pixels |
depth | Depth test is enabled if true |
samples | The number of MSAA (anti-alising) samples (disabled if 0) |
srgb | Enables support for the sRGB colorspace |
mem_ctx | User data provided to custom allocators |
void pgl_destroy_context | ( | pgl_ctx_t * | ctx | ) |
Destroys a renderer context, releasing it's resources.
ctx | A pointer to the context |
void pgl_resize | ( | pgl_ctx_t * | ctx, |
uint32_t | w, | ||
uint32_t | h, | ||
bool | reset_vp | ||
) |
Resizes the drawable dimensions.
ctx | A pointer to the context |
w | The drawable width of the window in pixels |
h | The drawable height of the window in pixels @pawram reset_vp Resets the viewport if true |
pgl_shader_t * pgl_create_shader | ( | pgl_ctx_t * | ctx, |
const char * | vert_src, | ||
const char * | frag_src | ||
) |
Creates a shader program.
If vert_src
and frag_src
are both NULL
, then the shader is compiled from the default vertex and fragment sources. If either vert_src
or frag_src
are NULL
, then the shader is compiled from the (respective) default vertex or fragment source, together with the non-NULL
argument.
ctx | The relevant context |
vert_src | Vertex shader source |
frag_src | Fragment shader source |
void pgl_destroy_shader | ( | pgl_shader_t * | shader | ) |
Destroys a shader program.
shader | Pointer to the shader program |
void pgl_bind_shader | ( | pgl_ctx_t * | ctx, |
pgl_shader_t * | shader | ||
) |
Activates a shader program for rendering.
This function sets the context's currently active shader. If shader
is NULL
the current shader is deactivated.
ctx | The relevant context |
shader | The shader program to activate, or NULL to deactivate |
uint64_t pgl_get_shader_id | ( | const pgl_shader_t * | shader | ) |
Return the implementation specific shader ID.
shader | The target shader |
pgl_texture_t * pgl_create_texture | ( | pgl_ctx_t * | ctx, |
bool | target, | ||
pgl_format_t | fmt, | ||
bool | srgb, | ||
int32_t | w, | ||
int32_t | h, | ||
bool | smooth, | ||
bool | repeat | ||
) |
Creates an empty texture.
ctx | The relevant context |
target | If true, the texture can be used as a render target |
w | The texture's width |
h | The texture's height |
srgb | True if the internal format is sRGB |
smooth | High (true) or low (false) quality filtering |
repeat | Repeats or clamps when uv coordinates exceed 1.0 |
pgl_texture_t * pgl_texture_from_bitmap | ( | pgl_ctx_t * | ctx, |
pgl_format_t | fmt, | ||
bool | srgb, | ||
int32_t | w, | ||
int32_t | h, | ||
bool | smooth, | ||
bool | repeat, | ||
const uint8_t * | bitmap | ||
) |
Creates a texture from a bitmap.
ctx | The relevant context |
w | The texture's width |
h | The texture's height |
srgb | True if the internal format is sRGB |
smooth | High (true) or low (false) quality filtering |
repeat | Repeats or clamps when uv coordinates exceed 1.0 |
bitmap | Pixel data in RGBA format |
int pgl_upload_texture | ( | pgl_ctx_t * | ctx, |
pgl_texture_t * | texture, | ||
int32_t | w, | ||
int32_t | h, | ||
const uint8_t * | bitmap | ||
) |
Uploads data from a bitmap into a texture.
ctx | The relevant context |
texture | The target texture |
w | The texture's width |
h | The texture's height |
bitmap | The pixel data in RGBA |
void pgl_update_texture | ( | pgl_ctx_t * | ctx, |
pgl_texture_t * | texture, | ||
int | x, | ||
int | y, | ||
int | w, | ||
int | h, | ||
const uint8_t * | bitmap | ||
) |
Updates a region of an existing texture.
ctx | The relevant context |
texture | The texture to update |
x | The x offset of the region |
y | The y offset of the region |
w | The width of the region |
h | The height of the region |
bitmap | The pixel data in RGBA |
int pgl_generate_mipmap | ( | pgl_texture_t * | texture, |
bool | linear | ||
) |
Generate mipmaps for the specified texture.
Generates a sequence of smaller pre-filtered / pre-optimized textures intended to reduce the effects of aliasing when rendering smaller versions of the texture.
texture | Pointer to the target texture |
linear | Determines the selection of the which mipmap to blend |
void pgl_destroy_texture | ( | pgl_texture_t * | texture | ) |
Destroys a texture.
texture | Texture to destroy |
void pgl_get_texture_size | ( | const pgl_texture_t * | texture, |
int * | w, | ||
int * | h | ||
) |
Gets texture size.
texture | The texture |
w | Pointer to width (output) |
h | Pointer to height (output) |
void pgl_get_max_texture_size | ( | int * | w, |
int * | h | ||
) |
Gets maximum texture size as reported by OpenGL
w | Pointer to width (output) |
h | Poineter to height (output) |
uint64_t pgl_get_texture_id | ( | const pgl_texture_t * | texture | ) |
Return the implementation specific texture ID.
texture | The target texture |
void pgl_bind_texture | ( | pgl_ctx_t * | ctx, |
pgl_texture_t * | texture | ||
) |
Activates a texture for rendering.
This function sets the context's currently texture. If texture
is NULL
the current texture is deactivated.
ctx | The relevant context |
texture | The texture to activate, or NULL to deactivate |
int pgl_set_render_target | ( | pgl_ctx_t * | ctx, |
pgl_texture_t * | texture | ||
) |
Draw to texture.
The function set a texture to be the target for rendering until the texture if replaced by another or set to NULL
.
ctx | The relevant context |
texture | The render target |
void pgl_clear | ( | float | r, |
float | g, | ||
float | b, | ||
float | a | ||
) |
Clears the framebuffer to the specified color.
All of the parameters are in [0.0, 1.0]
void pgl_draw_array | ( | pgl_ctx_t * | ctx, |
pgl_primitive_t | primitive, | ||
const pgl_vertex_t * | vertices, | ||
pgl_size_t | count, | ||
pgl_texture_t * | texture, | ||
pgl_shader_t * | shader | ||
) |
Draws primitives according to a vertex array
ctx | The relevant context |
primitive | The type of geometry to draw |
vertices | A vertex array |
count | The number of vertices |
texture | The texture to draw from (can be NULL ) |
shader | The shader used to draw the array (cannot be NULL ) |
void pgl_draw_indexed_array | ( | pgl_ctx_t * | ctx, |
pgl_primitive_t | primitive, | ||
const pgl_vertex_t * | vertices, | ||
pgl_size_t | vertex_count, | ||
const uint32_t * | indices, | ||
pgl_size_t | index_count, | ||
pgl_texture_t * | texture, | ||
pgl_shader_t * | shader | ||
) |
Draws primvities according to vertex and index arrays
ctx | The relevant context |
primitive | The type of geometry to draw |
vertices | An array of vertices |
vertex_count | The number of vertices |
indices | An array of indices |
index_ | count The number of indicies |
texture | The texture to draw from (can be NULL ) |
shader | The shader used to draw the array (cannot be NULL ) |
pgl_buffer_t * pgl_create_buffer | ( | pgl_ctx_t * | ctx, |
pgl_primitive_t | primitive, | ||
const pgl_vertex_t * | vertices, | ||
pgl_size_t | count | ||
) |
Creates a buffer in VRAM to store an array of vertices that can then be rendered without having upload the vertices every time they are drawn.
ctx | The relevant context |
primitive | The type of geometry to draw |
vertices | A vertex array |
count | The number of vertices to store in the buffer |
NULL
on error void pgl_sub_buffer_data | ( | pgl_ctx_t * | ctx, |
pgl_buffer_t * | buffer, | ||
const pgl_vertex_t * | vertices, | ||
pgl_size_t | count, | ||
pgl_size_t | offset | ||
) |
Substitutes the data in a buffer with new data.
ctx | The relevant context |
buffer | The buffer to write to |
vertices | A vertex array |
count | The number of vertices to substitute. |
void pgl_destroy_buffer | ( | pgl_buffer_t * | buffer | ) |
Destroys a previously created buffer.
void pgl_draw_buffer | ( | pgl_ctx_t * | ctx, |
const pgl_buffer_t * | buffer, | ||
pgl_size_t | start, | ||
pgl_size_t | count, | ||
pgl_texture_t * | texture, | ||
pgl_shader_t * | shader | ||
) |
Draw a previously created buffer.
ctx | The relevant context |
buffer | The buffer to draw |
start | The base vertex index |
count | The number of vertices to draw from start |
texture | The texture to draw from (can be NULL ) |
shader | The shader used to draw the array (cannot be NULL ) |
void pgl_set_transpose | ( | pgl_ctx_t * | ctx, |
bool | enabled | ||
) |
Turns matrix transposition on/off.
void pgl_set_blend_mode | ( | pgl_ctx_t * | ctx, |
pgl_blend_mode_t | mode | ||
) |
Set the blending mode.
ctx | The relevant context |
mode | The blending mode ( |
void pgl_reset_blend_mode | ( | pgl_ctx_t * | ctx | ) |
Resets the blend mode to standard alpha blending.
ctx | The relevant context |
Sets the context's global tranformation matrix.
ctx | The relevant context |
matrix | The global transform matrix |
3D variant of pgl_set_transform
ctx | The relevant context |
matrix | The 3D global transform matrix |
void pgl_reset_transform | ( | pgl_ctx_t * | ctx | ) |
Resets the context's transform to the identity matrix.
ctx | The relevant context |
Sets a context's global projecton matrix.
ctx | The relevant context |
matrix | The global projection matrix |
3D variant of pgl_set_projection
ctx | The relevant context |
matrix | The 3D global projection matrix |
void pgl_reset_projection | ( | pgl_ctx_t * | ctx | ) |
Resets the context's project to the identity matrix.
ctx | The relevant context |
void pgl_set_viewport | ( | pgl_ctx_t * | ctx, |
int32_t | x, | ||
int32_t | y, | ||
int32_t | w, | ||
int32_t | h | ||
) |
Sets the location and dimensions of the rendering viewport.
ctx | The relevant context |
x | The left edge of the viewport |
y | The bottom edge of the viewport |
w | The width of the viewport |
h | The height of the viewort |
void pgl_reset_viewport | ( | pgl_ctx_t * | ctx | ) |
Reset the viewport to the drawable dimensions of the context.
ctx | The relevant context |
void pgl_set_line_width | ( | pgl_ctx_t * | ctx, |
float | line_width | ||
) |
Sets the line primitive width.
void pgl_reset_line_width | ( | pgl_ctx_t * | ctx | ) |
Resets the line width to 1.0f.
void pgl_reset_state | ( | pgl_ctx_t * | ctx | ) |
Resets the current state of the context.
Resets the global transform, projection, blend mode, and viewport.
ctx | The relevant context |
void pgl_push_state | ( | pgl_ctx_t * | ctx | ) |
Pushes the current state onto the state stack, allowing it to be restored later.
ctx | The relevant context |
void pgl_pop_state | ( | pgl_ctx_t * | ctx | ) |
Pops a state off of the state stack and makes it the current state.
ctx | The relevant context |
void pgl_clear_stack | ( | pgl_ctx_t * | ctx | ) |
Removes all states from the state stack.
ctx | The relevant context |
void pgl_set_bool | ( | pgl_shader_t * | shader, |
const char * | name, | ||
bool | value | ||
) |
Sets a boolean uniform.
shader | The uniform's shader program |
name | The name of the uniform |
value | The boolean value |
void pgl_set_1i | ( | pgl_shader_t * | shader, |
const char * | name, | ||
int32_t | a | ||
) |
Sets an integer uniform.
shader | The uniform's shader program |
name | The name of the uniform |
value | The integer value |
void pgl_set_2i | ( | pgl_shader_t * | shader, |
const char * | name, | ||
int32_t | a, | ||
int32_t | b | ||
) |
Sets a 2D integer uniform.
shader | The uniform's shader program |
name | The name of the uniform |
a | The first value |
b | The second value |
void pgl_set_3i | ( | pgl_shader_t * | shader, |
const char * | name, | ||
int32_t | a, | ||
int32_t | b, | ||
int32_t | c | ||
) |
Sets a 3D integer uniform.
shader | The uniform's shader program |
name | The name of the uniform |
a | The first value |
b | The second value |
c | The third value |
void pgl_set_4i | ( | pgl_shader_t * | shader, |
const char * | name, | ||
int32_t | a, | ||
int32_t | b, | ||
int32_t | c, | ||
int32_t | d | ||
) |
Sets a 4D integer uniform.
shader | The uniform's shader program |
name | The name of the uniform |
a | The first value |
b | The second value |
c | The third value |
d | The fourth value |
void pgl_set_v2i | ( | pgl_shader_t * | shader, |
const char * | name, | ||
const pgl_v2i_t | vec | ||
) |
Sets a 2D integer uniform by vector.
shader | The uniform's shader program |
name | The name of the uniform |
vec | The vector |
void pgl_set_v3i | ( | pgl_shader_t * | shader, |
const char * | name, | ||
const pgl_v3i_t | vec | ||
) |
Sets a 3D integer uniform by vector.
shader | The uniform's shader program |
name | The name of the uniform |
vec | The vector |
void pgl_set_v4i | ( | pgl_shader_t * | shader, |
const char * | name, | ||
const pgl_v4i_t | vec | ||
) |
Sets a 4D integer uniform by vector.
shader | The uniform's shader program |
name | The name of the uniform |
vec | The vector |
void pgl_set_1f | ( | pgl_shader_t * | shader, |
const char * | name, | ||
float | x | ||
) |
Sets an floating point uniform.
shader | The uniform's shader program |
name | The name of the uniform |
x | The float value |
void pgl_set_2f | ( | pgl_shader_t * | shader, |
const char * | name, | ||
float | x, | ||
float | y | ||
) |
Sets a 2D floating point uniform.
shader | The uniform's shader program |
name | The name of the uniform |
x | The first value |
y | The second value |
void pgl_set_3f | ( | pgl_shader_t * | shader, |
const char * | name, | ||
float | x, | ||
float | y, | ||
float | z | ||
) |
Sets a 3D floating point uniform.
shader | The uniform's shader program |
name | The name of the uniform |
x | The first value |
y | The second value |
z | The third value |
void pgl_set_4f | ( | pgl_shader_t * | shader, |
const char * | name, | ||
float | x, | ||
float | y, | ||
float | z, | ||
float | w | ||
) |
Sets a 4D floating point uniform.
shader | The uniform's shader program |
name | The name of the uniform |
x | The first value |
y | The second value |
w | The third value |
z | The fourth value |
void pgl_set_v2f | ( | pgl_shader_t * | shader, |
const char * | name, | ||
const pgl_v2f_t | vec | ||
) |
Sets a 2D floating point uniform by vector.
shader | The uniform's shader program |
name | The name of the uniform |
vec | The vector |
void pgl_set_v3f | ( | pgl_shader_t * | shader, |
const char * | name, | ||
const pgl_v3f_t | vec | ||
) |
Sets a 3D floating point uniform by vector.
shader | The uniform's shader program |
name | The name of the uniform |
vec | The vector |
void pgl_set_v4f | ( | pgl_shader_t * | shader, |
const char * | name, | ||
const pgl_v4f_t | vec | ||
) |
Sets a 4D floating point uniform by vector.
shader | The uniform's shader program |
name | The name of the uniform |
vec | The vector |
void pgl_set_a1f | ( | pgl_shader_t * | shader, |
const char * | name, | ||
const float | array[], | ||
pgl_size_t | count | ||
) |
Sends an array of floating point numbers.
shader | The uniform's shader program |
name | The name of the uniform |
array | The array of floats |
count | The size of the array |
void pgl_set_a2f | ( | pgl_shader_t * | shader, |
const char * | name, | ||
const pgl_v2f_t | array[], | ||
pgl_size_t | count | ||
) |
Sends an array of 2D floating point vectors.
shader | The uniform's shader program |
name | The name of the uniform |
array | The array of vectors |
count | The size of the array |
void pgl_set_a3f | ( | pgl_shader_t * | shader, |
const char * | name, | ||
const pgl_v3f_t | array[], | ||
pgl_size_t | count | ||
) |
Sends an array of 3D floating point vectors.
shader | The uniform's shader program |
name | The name of the uniform |
array | The array of vectors |
count | The size of the array |
void pgl_set_a4f | ( | pgl_shader_t * | shader, |
const char * | name, | ||
const pgl_v4f_t | array[], | ||
pgl_size_t | count | ||
) |
Sends an array of 4D floating point vectors.
shader | The uniform's shader program |
name | The name of the uniform |
array | The array of vectors |
count | The size of the array |
void pgl_set_m2 | ( | pgl_shader_t * | shader, |
const char * | name, | ||
const pgl_m2_t | matrix | ||
) |
Sets a 2x2 floating point matrix.
shader | The uniform's shader program |
name | The name of the uniform |
matrix | The matrix |
void pgl_set_m3 | ( | pgl_shader_t * | shader, |
const char * | name, | ||
const pgl_m3_t | matrix | ||
) |
Sets a 3x3 floating point matrix.
shader | The uniform's shader program |
name | The name of the uniform |
matrix | The matrix |
void pgl_set_m4 | ( | pgl_shader_t * | shader, |
const char * | name, | ||
const pgl_m4_t | matrix | ||
) |
Sets a 4x4 floating point matrix.
shader | The uniform's shader program |
name | The name of the uniform |
matrix | The matrix |
void pgl_set_s2d | ( | pgl_shader_t * | shader, |
const char * | name, | ||
int32_t | value | ||
) |
Sets a 2D sampler uniform.
shader | The uniform's shader program |
name | The name of the uniform |
value | The sampler's texture unit |