2018-04-12 16:08:48 +02:00
|
|
|
/*
|
2019-08-03 19:43:48 +02:00
|
|
|
* This software is licensed under the terms of the MIT License.
|
2018-04-12 16:08:48 +02:00
|
|
|
* See COPYING for further information.
|
|
|
|
* ---
|
2024-05-16 23:30:41 +02:00
|
|
|
* Copyright (c) 2011-2024, Lukas Weber <laochailan@web.de>.
|
|
|
|
* Copyright (c) 2012-2024, Andrei Alexeyev <akari@taisei-project.org>.
|
2018-04-12 16:08:48 +02:00
|
|
|
*/
|
|
|
|
|
2021-08-12 23:09:01 +02:00
|
|
|
#pragma once
|
2018-04-12 16:08:48 +02:00
|
|
|
#include "taisei.h"
|
|
|
|
|
|
|
|
#include "color.h"
|
2024-05-17 04:41:28 +02:00
|
|
|
#include "pixmap/pixmap.h"
|
|
|
|
#include "renderer/common/shaderlib/shaderlib.h"
|
2018-10-02 22:14:24 +02:00
|
|
|
#include "resource/resource.h"
|
2020-06-09 03:33:22 +02:00
|
|
|
#include "resource/shader_program.h"
|
|
|
|
#include "resource/texture.h"
|
2018-09-14 09:37:20 +02:00
|
|
|
|
|
|
|
typedef struct Texture Texture;
|
|
|
|
typedef struct Framebuffer Framebuffer;
|
|
|
|
typedef struct VertexBuffer VertexBuffer;
|
|
|
|
typedef struct VertexArray VertexArray;
|
2018-10-02 22:14:24 +02:00
|
|
|
typedef struct IndexBuffer IndexBuffer;
|
2018-09-14 09:37:20 +02:00
|
|
|
typedef struct ShaderObject ShaderObject;
|
|
|
|
typedef struct ShaderProgram ShaderProgram;
|
2018-10-02 22:14:24 +02:00
|
|
|
typedef struct Sprite Sprite;
|
|
|
|
typedef struct Model Model;
|
2018-09-14 09:37:20 +02:00
|
|
|
|
|
|
|
enum {
|
|
|
|
R_DEBUG_LABEL_SIZE = 128,
|
|
|
|
R_NUM_SPRITE_AUX_TEXTURES = 3,
|
|
|
|
};
|
2018-04-12 16:08:48 +02:00
|
|
|
|
|
|
|
typedef enum RendererFeature {
|
|
|
|
RFEAT_DRAW_INSTANCED,
|
|
|
|
RFEAT_DRAW_INSTANCED_BASE_INSTANCE,
|
|
|
|
RFEAT_DEPTH_TEXTURE,
|
2018-07-04 10:36:16 +02:00
|
|
|
RFEAT_FRAMEBUFFER_MULTIPLE_OUTPUTS,
|
2018-08-28 10:25:54 +02:00
|
|
|
RFEAT_TEXTURE_BOTTOMLEFT_ORIGIN,
|
2020-08-15 13:51:12 +02:00
|
|
|
RFEAT_TEXTURE_SWIZZLE,
|
|
|
|
RFEAT_PARTIAL_MIPMAPS,
|
2018-04-12 16:08:48 +02:00
|
|
|
|
|
|
|
NUM_RFEATS,
|
|
|
|
} RendererFeature;
|
|
|
|
|
|
|
|
typedef uint_fast8_t r_feature_bits_t;
|
|
|
|
|
|
|
|
typedef enum RendererCapability {
|
|
|
|
RCAP_DEPTH_TEST,
|
|
|
|
RCAP_DEPTH_WRITE,
|
|
|
|
RCAP_CULL_FACE,
|
|
|
|
|
|
|
|
NUM_RCAPS
|
|
|
|
} RendererCapability;
|
|
|
|
|
|
|
|
typedef uint_fast8_t r_capability_bits_t;
|
|
|
|
|
2020-08-15 13:51:12 +02:00
|
|
|
enum {
|
|
|
|
TEX_TYPE_COMPRESSED_BIT = 0x8000,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define TEX_TYPES_UNCOMPRESSED(X, ...) \
|
|
|
|
/* NOTE: whichever is placed first here is considered the "default" where applicable. */ \
|
|
|
|
X(RGBA_8, __VA_ARGS__) \
|
|
|
|
X(RGB_8, __VA_ARGS__) \
|
|
|
|
X(RG_8, __VA_ARGS__) \
|
|
|
|
X(R_8, __VA_ARGS__) \
|
|
|
|
X(RGBA_16, __VA_ARGS__) \
|
|
|
|
X(RGB_16, __VA_ARGS__) \
|
|
|
|
X(RG_16, __VA_ARGS__) \
|
|
|
|
X(R_16, __VA_ARGS__) \
|
|
|
|
X(RGBA_16_FLOAT, __VA_ARGS__) \
|
|
|
|
X(RGB_16_FLOAT, __VA_ARGS__) \
|
|
|
|
X(RG_16_FLOAT, __VA_ARGS__) \
|
|
|
|
X(R_16_FLOAT, __VA_ARGS__) \
|
|
|
|
X(RGBA_32_FLOAT, __VA_ARGS__) \
|
|
|
|
X(RGB_32_FLOAT, __VA_ARGS__) \
|
|
|
|
X(RG_32_FLOAT, __VA_ARGS__) \
|
|
|
|
X(R_32_FLOAT, __VA_ARGS__) \
|
|
|
|
X(DEPTH_8, __VA_ARGS__) \
|
|
|
|
X(DEPTH_16, __VA_ARGS__) \
|
|
|
|
X(DEPTH_24, __VA_ARGS__) \
|
|
|
|
X(DEPTH_32, __VA_ARGS__) \
|
|
|
|
X(DEPTH_16_FLOAT, __VA_ARGS__) \
|
|
|
|
X(DEPTH_32_FLOAT, __VA_ARGS__) \
|
|
|
|
|
|
|
|
#define TEX_TYPES_HANDLE_COMPRESSED(comp, layout, X, ...) \
|
|
|
|
X(COMPRESSED_##comp, __VA_ARGS__)
|
|
|
|
|
|
|
|
#define TEX_TYPES_COMPRESSED(X, ...) \
|
|
|
|
PIXMAP_COMPRESSION_FORMATS(TEX_TYPES_HANDLE_COMPRESSED, X, __VA_ARGS__)
|
|
|
|
|
|
|
|
#define TEX_TYPES(X, ...) \
|
|
|
|
TEX_TYPES_UNCOMPRESSED(X, __VA_ARGS__) \
|
|
|
|
TEX_TYPES_COMPRESSED(X, __VA_ARGS__) \
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
typedef enum TextureType {
|
2020-08-15 13:51:12 +02:00
|
|
|
TEX_TYPE_INVALID = -1,
|
|
|
|
|
|
|
|
#define DECLARE_TEX_UNCOMPRESSED_TYPE(type, ...) \
|
|
|
|
TEX_TYPE_##type,
|
|
|
|
TEX_TYPES_UNCOMPRESSED(DECLARE_TEX_UNCOMPRESSED_TYPE,)
|
|
|
|
#undef DECLARE_TEX_UNCOMPRESSED_TYPE
|
|
|
|
|
|
|
|
#define DECLARE_TEX_COMPRESSED_TYPE(fmt, ...) \
|
|
|
|
TEX_TYPE_COMPRESSED_##fmt = PIXMAP_COMPRESSION_##fmt | TEX_TYPE_COMPRESSED_BIT,
|
|
|
|
PIXMAP_COMPRESSION_FORMATS(DECLARE_TEX_COMPRESSED_TYPE,)
|
|
|
|
#undef DECLARE_TEX_COMPRESSED_TYPE
|
Support 16-bit uint and 32-bit float textures
When textures are loaded as resources, the best available format is now
picked by default. That means that if your source image is 16-bit RGB,
you will get a 16-bit RGB texture (the alpha channel is added only if
necessary). However, grayscale images currently get expanded into RGB(A)
by the loaders automatically, so you will never get less than 3 channels
by default. This is good, because you most often expect grayscale images
to stay gray, and not red.
This behavior can be overriden with the new 'format' key in .tex files.
For example, if you only care about one channel in a gray image, you can
do this to save some VRAM:
format = R16
The following is equivalent:
format = R16U
And so is this:
format = r 16 uint
The general syntax is:
format = <channels><depth>[datatype]
Where:
* Channels is one of: R, RG, RGB, RGBA;
* Depth is one of: 8, 16, 32;
* Datatype is one of: uint (or just u), float (or just f)
All fields are case-insensitive and may be separated by whitespace.
Note that the rendering backend may not support all of these formats,
and fallback to an inferior or a redundant one. The gl33 backend should
support all of them. The gles30 backend only supports 8-bit uint
textures for now.
2018-10-17 22:11:27 +02:00
|
|
|
|
|
|
|
TEX_TYPE_R = TEX_TYPE_R_8,
|
2020-08-15 13:51:12 +02:00
|
|
|
TEX_TYPE_RG = TEX_TYPE_RG_8,
|
|
|
|
TEX_TYPE_RGB = TEX_TYPE_RGB_8,
|
|
|
|
TEX_TYPE_RGBA = TEX_TYPE_RGBA_8,
|
|
|
|
TEX_TYPE_DEPTH = TEX_TYPE_DEPTH_24,
|
2018-04-12 16:08:48 +02:00
|
|
|
} TextureType;
|
|
|
|
|
2020-08-15 13:51:12 +02:00
|
|
|
#define TEX_TYPE_IS_COMPRESSED(type) ((bool)((type) & TEX_TYPE_COMPRESSED_BIT))
|
|
|
|
#define TEX_TYPE_TO_COMPRESSION_FORMAT(type) ((PixmapCompression)((type) & ~TEX_TYPE_COMPRESSED_BIT))
|
|
|
|
#define COMPRESSION_FORMAT_TO_TEX_TYPE(cfmt) ((TextureType)((cfmt) | TEX_TYPE_COMPRESSED_BIT))
|
|
|
|
#define TEX_TYPE_IS_DEPTH(type) ((type) >= TEX_TYPE_DEPTH_8 && (type) <= TEX_TYPE_DEPTH_32_FLOAT)
|
|
|
|
|
2021-06-27 10:22:39 +02:00
|
|
|
typedef enum TextureClass {
|
|
|
|
// NOTE: whichever is placed first here is considered the "default" where applicable.
|
|
|
|
TEXTURE_CLASS_2D,
|
|
|
|
TEXTURE_CLASS_CUBEMAP,
|
2024-08-27 20:02:52 +02:00
|
|
|
|
|
|
|
NUM_TEXTURE_CLASSES,
|
2021-06-27 10:22:39 +02:00
|
|
|
} TextureClass;
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
typedef enum TextureFilterMode {
|
2018-07-10 11:14:29 +02:00
|
|
|
// NOTE: whichever is placed first here is considered the "default" where applicable.
|
2018-04-12 16:08:48 +02:00
|
|
|
TEX_FILTER_LINEAR,
|
2018-07-10 11:14:29 +02:00
|
|
|
TEX_FILTER_LINEAR_MIPMAP_NEAREST,
|
|
|
|
TEX_FILTER_LINEAR_MIPMAP_LINEAR,
|
|
|
|
TEX_FILTER_NEAREST,
|
|
|
|
TEX_FILTER_NEAREST_MIPMAP_NEAREST,
|
|
|
|
TEX_FILTER_NEAREST_MIPMAP_LINEAR,
|
2018-04-12 16:08:48 +02:00
|
|
|
} TextureFilterMode;
|
|
|
|
|
|
|
|
typedef enum TextureWrapMode {
|
2018-07-10 11:14:29 +02:00
|
|
|
// NOTE: whichever is placed first here is considered the "default" where applicable.
|
2018-04-12 16:08:48 +02:00
|
|
|
TEX_WRAP_REPEAT,
|
|
|
|
TEX_WRAP_MIRROR,
|
|
|
|
TEX_WRAP_CLAMP,
|
|
|
|
} TextureWrapMode;
|
|
|
|
|
2018-07-10 11:14:29 +02:00
|
|
|
typedef enum TextureMipmapMode {
|
|
|
|
TEX_MIPMAP_MANUAL,
|
|
|
|
TEX_MIPMAP_AUTO,
|
|
|
|
} TextureMipmapMode;
|
|
|
|
|
2020-08-15 13:51:12 +02:00
|
|
|
typedef enum TextureFlags {
|
|
|
|
// NOTE: this can be later expanded to include intended usage flags, e.g. "render target", "filterable", etc.
|
|
|
|
TEX_FLAG_SRGB = (1 << 0),
|
|
|
|
TEX_FLAG_STREAM = (1 << 1),
|
|
|
|
} TextureFlags;
|
|
|
|
|
2018-09-14 09:37:20 +02:00
|
|
|
enum {
|
2019-09-08 00:38:53 +02:00
|
|
|
TEX_ANISOTROPY_DEFAULT = 1,
|
2018-09-14 09:37:20 +02:00
|
|
|
// TEX_MIPMAPS_MAX = ((uint)(-1)),
|
|
|
|
// pedantic out-of-range warning
|
|
|
|
#define TEX_MIPMAPS_MAX ((uint)(-1))
|
|
|
|
};
|
2018-07-10 11:14:29 +02:00
|
|
|
|
2021-06-27 10:22:39 +02:00
|
|
|
typedef enum CubemapFace {
|
|
|
|
CUBEMAP_FACE_POS_X,
|
|
|
|
CUBEMAP_FACE_NEG_X,
|
|
|
|
CUBEMAP_FACE_POS_Y,
|
|
|
|
CUBEMAP_FACE_NEG_Y,
|
|
|
|
CUBEMAP_FACE_POS_Z,
|
|
|
|
CUBEMAP_FACE_NEG_Z,
|
|
|
|
} CubemapFace;
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
typedef struct TextureParams {
|
|
|
|
uint width;
|
|
|
|
uint height;
|
2021-06-27 10:22:39 +02:00
|
|
|
uint layers;
|
2018-04-12 16:08:48 +02:00
|
|
|
TextureType type;
|
2021-06-27 10:22:39 +02:00
|
|
|
TextureClass class;
|
2018-04-12 16:08:48 +02:00
|
|
|
|
|
|
|
struct {
|
2018-07-10 11:14:29 +02:00
|
|
|
TextureFilterMode mag;
|
|
|
|
TextureFilterMode min;
|
2018-04-12 16:08:48 +02:00
|
|
|
} filter;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
TextureWrapMode s;
|
|
|
|
TextureWrapMode t;
|
|
|
|
} wrap;
|
|
|
|
|
2020-08-15 13:51:12 +02:00
|
|
|
SwizzleMask swizzle;
|
|
|
|
|
2018-08-12 01:38:03 +02:00
|
|
|
uint anisotropy;
|
2018-04-12 16:08:48 +02:00
|
|
|
uint mipmaps;
|
2018-07-10 11:14:29 +02:00
|
|
|
TextureMipmapMode mipmap_mode;
|
2020-08-15 13:51:12 +02:00
|
|
|
TextureFlags flags;
|
2018-04-12 16:08:48 +02:00
|
|
|
} attr_designated_init TextureParams;
|
|
|
|
|
2020-08-15 13:51:12 +02:00
|
|
|
typedef struct TextureTypeQueryResult {
|
|
|
|
PixmapFormat optimal_pixmap_format;
|
|
|
|
PixmapOrigin optimal_pixmap_origin;
|
|
|
|
bool supplied_pixmap_format_supported;
|
|
|
|
bool supplied_pixmap_origin_supported;
|
|
|
|
} TextureTypeQueryResult;
|
|
|
|
|
2018-07-04 10:36:16 +02:00
|
|
|
typedef enum FramebufferAttachment {
|
|
|
|
FRAMEBUFFER_ATTACH_DEPTH,
|
|
|
|
FRAMEBUFFER_ATTACH_COLOR0,
|
|
|
|
FRAMEBUFFER_ATTACH_COLOR1,
|
|
|
|
FRAMEBUFFER_ATTACH_COLOR2,
|
|
|
|
FRAMEBUFFER_ATTACH_COLOR3,
|
2018-04-12 16:08:48 +02:00
|
|
|
|
2018-07-04 10:36:16 +02:00
|
|
|
FRAMEBUFFER_MAX_COLOR_ATTACHMENTS = 4,
|
|
|
|
FRAMEBUFFER_MAX_ATTACHMENTS = FRAMEBUFFER_ATTACH_COLOR0 + FRAMEBUFFER_MAX_COLOR_ATTACHMENTS,
|
2020-08-15 13:51:12 +02:00
|
|
|
FRAMEBUFFER_ATTACH_NONE = -1,
|
2018-07-04 10:36:16 +02:00
|
|
|
} FramebufferAttachment;
|
2018-04-12 16:08:48 +02:00
|
|
|
|
2020-08-15 13:51:12 +02:00
|
|
|
enum {
|
|
|
|
FRAMEBUFFER_MAX_OUTPUTS = FRAMEBUFFER_MAX_COLOR_ATTACHMENTS,
|
|
|
|
};
|
|
|
|
|
2024-05-01 00:19:07 +02:00
|
|
|
typedef void (*FramebufferReadAsyncCallback)(const Pixmap *pixmap, void *userdata);
|
2024-04-29 00:46:52 +02:00
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
typedef enum Primitive {
|
|
|
|
PRIM_POINTS,
|
|
|
|
PRIM_LINE_STRIP,
|
|
|
|
PRIM_LINES,
|
|
|
|
PRIM_TRIANGLE_STRIP,
|
|
|
|
PRIM_TRIANGLES,
|
|
|
|
} Primitive;
|
|
|
|
|
2024-05-17 04:41:28 +02:00
|
|
|
struct Model {
|
|
|
|
VertexArray *vertex_array;
|
|
|
|
size_t num_vertices;
|
|
|
|
size_t num_indices;
|
|
|
|
size_t offset;
|
|
|
|
Primitive primitive;
|
|
|
|
};
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
typedef enum VertexAttribType {
|
|
|
|
VA_FLOAT,
|
|
|
|
VA_BYTE,
|
|
|
|
VA_UBYTE,
|
|
|
|
VA_SHORT,
|
|
|
|
VA_USHORT,
|
|
|
|
VA_INT,
|
|
|
|
VA_UINT,
|
|
|
|
} VertexAttribType;
|
|
|
|
|
|
|
|
typedef struct VertexAttribTypeInfo {
|
|
|
|
size_t size;
|
|
|
|
size_t alignment;
|
|
|
|
} VertexAttribTypeInfo;
|
|
|
|
|
|
|
|
typedef enum VertexAttribConversion {
|
|
|
|
VA_CONVERT_FLOAT,
|
|
|
|
VA_CONVERT_FLOAT_NORMALIZED,
|
|
|
|
VA_CONVERT_INT,
|
|
|
|
} VertexAttribConversion;
|
|
|
|
|
|
|
|
typedef struct VertexAttribSpec {
|
|
|
|
uint8_t elements;
|
|
|
|
VertexAttribType type;
|
|
|
|
VertexAttribConversion coversion;
|
|
|
|
uint divisor;
|
|
|
|
} VertexAttribSpec;
|
|
|
|
|
|
|
|
typedef struct VertexAttribFormat {
|
|
|
|
VertexAttribSpec spec;
|
|
|
|
size_t stride;
|
|
|
|
size_t offset;
|
|
|
|
uint attachment;
|
|
|
|
} VertexAttribFormat;
|
|
|
|
|
|
|
|
typedef struct GenericModelVertex {
|
2018-07-11 16:48:13 +02:00
|
|
|
float position[3];
|
2020-06-06 17:27:08 +02:00
|
|
|
float uv[2];
|
2018-07-11 16:48:13 +02:00
|
|
|
float normal[3];
|
2020-06-06 17:27:08 +02:00
|
|
|
float tangent[4]; // NOTE: bitangent = cross(normal, tangent) * tangent[3]
|
2018-04-12 16:08:48 +02:00
|
|
|
} GenericModelVertex;
|
|
|
|
|
|
|
|
typedef enum UniformType {
|
|
|
|
UNIFORM_FLOAT,
|
|
|
|
UNIFORM_VEC2,
|
|
|
|
UNIFORM_VEC3,
|
|
|
|
UNIFORM_VEC4,
|
|
|
|
UNIFORM_INT,
|
|
|
|
UNIFORM_IVEC2,
|
|
|
|
UNIFORM_IVEC3,
|
|
|
|
UNIFORM_IVEC4,
|
2021-07-09 02:08:08 +02:00
|
|
|
UNIFORM_SAMPLER_2D,
|
|
|
|
UNIFORM_SAMPLER_CUBE,
|
2018-04-12 16:08:48 +02:00
|
|
|
UNIFORM_MAT3,
|
|
|
|
UNIFORM_MAT4,
|
|
|
|
UNIFORM_UNKNOWN,
|
|
|
|
} UniformType;
|
|
|
|
|
2021-07-09 02:08:08 +02:00
|
|
|
#define UNIFORM_TYPE_IS_SAMPLER(ut) \
|
|
|
|
((ut) == UNIFORM_SAMPLER_2D || (ut) == UNIFORM_SAMPLER_CUBE)
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
typedef struct UniformTypeInfo {
|
|
|
|
// Refers to vector elements, not array elements.
|
|
|
|
uint8_t elements;
|
|
|
|
uint8_t element_size;
|
|
|
|
} UniformTypeInfo;
|
|
|
|
|
|
|
|
typedef struct Uniform Uniform;
|
|
|
|
|
2023-04-09 04:00:00 +02:00
|
|
|
typedef enum BufferKindFlags {
|
|
|
|
BUFFER_COLOR = (1 << 0),
|
|
|
|
BUFFER_DEPTH = (1 << 1),
|
2018-04-12 16:08:48 +02:00
|
|
|
|
2023-04-09 04:00:00 +02:00
|
|
|
BUFFER_ALL = BUFFER_COLOR | BUFFER_DEPTH,
|
|
|
|
|
|
|
|
CLEAR_COLOR attr_deprecated("Use BUFFER_COLOR instead") = BUFFER_COLOR,
|
|
|
|
CLEAR_DEPTH attr_deprecated("Use BUFFER_DEPTH instead") = BUFFER_DEPTH,
|
|
|
|
CLEAR_ALL attr_deprecated("Use BUFFER_ALL instead") = BUFFER_ALL,
|
|
|
|
} BufferKindFlags;
|
|
|
|
|
|
|
|
typedef BufferKindFlags ClearBufferFlags
|
|
|
|
attr_deprecated("Use BufferKindFlags instead");
|
2018-04-12 16:08:48 +02:00
|
|
|
|
|
|
|
// Blend modes API based on the SDL one.
|
|
|
|
|
|
|
|
typedef enum BlendModeComponent {
|
|
|
|
BLENDCOMP_COLOR_OP = 0x00,
|
|
|
|
BLENDCOMP_SRC_COLOR = 0x04,
|
|
|
|
BLENDCOMP_DST_COLOR = 0x08,
|
|
|
|
BLENDCOMP_ALPHA_OP = 0x10,
|
|
|
|
BLENDCOMP_SRC_ALPHA = 0x14,
|
|
|
|
BLENDCOMP_DST_ALPHA = 0x18,
|
|
|
|
} BlendModeComponent;
|
|
|
|
|
|
|
|
#define BLENDMODE_COMPOSE(src_color, dst_color, color_op, src_alpha, dst_alpha, alpha_op) \
|
|
|
|
( \
|
|
|
|
((uint32_t) color_op << BLENDCOMP_COLOR_OP ) | \
|
|
|
|
((uint32_t) src_color << BLENDCOMP_SRC_COLOR) | \
|
|
|
|
((uint32_t) dst_color << BLENDCOMP_DST_COLOR) | \
|
|
|
|
((uint32_t) alpha_op << BLENDCOMP_ALPHA_OP ) | \
|
|
|
|
((uint32_t) src_alpha << BLENDCOMP_SRC_ALPHA) | \
|
|
|
|
((uint32_t) dst_alpha << BLENDCOMP_DST_ALPHA) \
|
|
|
|
)
|
|
|
|
|
|
|
|
#define BLENDMODE_COMPONENT(mode, comp) \
|
|
|
|
(((uint32_t) mode >> (uint32_t) comp) & 0xF)
|
|
|
|
|
|
|
|
typedef enum BlendOp {
|
|
|
|
BLENDOP_ADD = 0x1, // dst + src
|
|
|
|
BLENDOP_SUB = 0x2, // dst - src
|
|
|
|
BLENDOP_REV_SUB = 0x3, // src - dst
|
|
|
|
BLENDOP_MIN = 0x4, // min(dst, src)
|
|
|
|
BLENDOP_MAX = 0x5, // max(dst, src)
|
|
|
|
} BlendOp;
|
|
|
|
|
|
|
|
typedef enum BlendFactor {
|
|
|
|
BLENDFACTOR_ZERO = 0x1, // 0, 0, 0, 0
|
|
|
|
BLENDFACTOR_ONE = 0x2, // 1, 1, 1, 1
|
|
|
|
BLENDFACTOR_SRC_COLOR = 0x3, // srcR, srcG, srcB, srcA
|
|
|
|
BLENDFACTOR_INV_SRC_COLOR = 0x4, // 1-srcR, 1-srcG, 1-srcB, 1-srcA
|
|
|
|
BLENDFACTOR_SRC_ALPHA = 0x5, // srcA, srcA, srcA, srcA
|
|
|
|
BLENDFACTOR_INV_SRC_ALPHA = 0x6, // 1-srcA, 1-srcA, 1-srcA, 1-srcA
|
|
|
|
BLENDFACTOR_DST_COLOR = 0x7, // dstR, dstG, dstB, dstA
|
|
|
|
BLENDFACTOR_INV_DST_COLOR = 0x8, // 1-dstR, 1-dstG, 1-dstB, 1-dstA
|
|
|
|
BLENDFACTOR_DST_ALPHA = 0x9, // dstA, dstA, dstA, dstA
|
|
|
|
BLENDFACTOR_INV_DST_ALPHA = 0xA, // 1-dstA, 1-dstA, 1-dstA, 1-dstA
|
|
|
|
} BlendFactor;
|
|
|
|
|
|
|
|
typedef enum BlendMode {
|
|
|
|
BLEND_NONE = BLENDMODE_COMPOSE(
|
|
|
|
BLENDFACTOR_ONE, BLENDFACTOR_ZERO, BLENDOP_ADD,
|
|
|
|
BLENDFACTOR_ONE, BLENDFACTOR_ZERO, BLENDOP_ADD
|
|
|
|
),
|
|
|
|
|
|
|
|
BLEND_ALPHA = BLENDMODE_COMPOSE(
|
|
|
|
BLENDFACTOR_SRC_ALPHA, BLENDFACTOR_INV_SRC_ALPHA, BLENDOP_ADD,
|
|
|
|
BLENDFACTOR_ONE, BLENDFACTOR_INV_SRC_ALPHA, BLENDOP_ADD
|
|
|
|
),
|
|
|
|
|
2018-07-23 19:07:59 +02:00
|
|
|
BLEND_PREMUL_ALPHA = BLENDMODE_COMPOSE(
|
|
|
|
BLENDFACTOR_ONE, BLENDFACTOR_INV_SRC_ALPHA, BLENDOP_ADD,
|
|
|
|
BLENDFACTOR_ONE, BLENDFACTOR_INV_SRC_ALPHA, BLENDOP_ADD
|
|
|
|
),
|
|
|
|
|
|
|
|
_BLEND_ADD = BLENDMODE_COMPOSE(
|
2018-04-12 16:08:48 +02:00
|
|
|
BLENDFACTOR_SRC_ALPHA, BLENDFACTOR_ONE, BLENDOP_ADD,
|
|
|
|
BLENDFACTOR_ZERO, BLENDFACTOR_ONE, BLENDOP_ADD
|
|
|
|
),
|
|
|
|
|
|
|
|
BLEND_SUB = BLENDMODE_COMPOSE(
|
|
|
|
BLENDFACTOR_SRC_ALPHA, BLENDFACTOR_ONE, BLENDOP_REV_SUB,
|
|
|
|
BLENDFACTOR_ZERO, BLENDFACTOR_ONE, BLENDOP_REV_SUB
|
|
|
|
),
|
|
|
|
|
|
|
|
BLEND_MOD = BLENDMODE_COMPOSE(
|
|
|
|
BLENDFACTOR_ZERO, BLENDFACTOR_SRC_COLOR, BLENDOP_ADD,
|
|
|
|
BLENDFACTOR_ZERO, BLENDFACTOR_ONE, BLENDOP_ADD
|
|
|
|
),
|
|
|
|
} BlendMode;
|
|
|
|
|
2018-09-14 09:37:20 +02:00
|
|
|
attr_deprecated("Use BLEND_PREMUL_ALPHA and a color with alpha == 0 instead")
|
2018-07-23 19:07:59 +02:00
|
|
|
static const BlendMode BLEND_ADD = _BLEND_ADD;
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
typedef struct UnpackedBlendModePart {
|
|
|
|
BlendOp op;
|
|
|
|
BlendFactor src;
|
|
|
|
BlendFactor dst;
|
|
|
|
} UnpackedBlendModePart;
|
|
|
|
|
|
|
|
typedef struct UnpackedBlendMode {
|
|
|
|
UnpackedBlendModePart color;
|
|
|
|
UnpackedBlendModePart alpha;
|
|
|
|
} UnpackedBlendMode;
|
|
|
|
|
|
|
|
typedef enum CullFaceMode {
|
|
|
|
CULL_FRONT = 0x1,
|
|
|
|
CULL_BACK = 0x2,
|
|
|
|
CULL_BOTH = CULL_FRONT | CULL_BACK,
|
|
|
|
} CullFaceMode;
|
|
|
|
|
|
|
|
typedef enum DepthTestFunc {
|
|
|
|
DEPTH_NEVER,
|
|
|
|
DEPTH_ALWAYS,
|
|
|
|
DEPTH_EQUAL,
|
|
|
|
DEPTH_NOTEQUAL,
|
|
|
|
DEPTH_LESS,
|
|
|
|
DEPTH_LEQUAL,
|
|
|
|
DEPTH_GREATER,
|
|
|
|
DEPTH_GEQUAL,
|
|
|
|
} DepthTestFunc;
|
|
|
|
|
|
|
|
typedef enum VsyncMode {
|
|
|
|
VSYNC_NONE,
|
|
|
|
VSYNC_NORMAL,
|
|
|
|
VSYNC_ADAPTIVE,
|
|
|
|
} VsyncMode;
|
|
|
|
|
2018-07-23 19:07:59 +02:00
|
|
|
typedef union ShaderCustomParams {
|
|
|
|
float vector[4];
|
|
|
|
Color color;
|
|
|
|
} ShaderCustomParams;
|
|
|
|
|
2019-10-03 01:49:10 +02:00
|
|
|
typedef struct SpriteStateParams {
|
2024-09-22 21:06:57 +02:00
|
|
|
ShaderProgram *shader;
|
2019-10-03 01:49:10 +02:00
|
|
|
Texture *primary_texture;
|
|
|
|
Texture *aux_textures[R_NUM_SPRITE_AUX_TEXTURES];
|
|
|
|
BlendMode blend;
|
|
|
|
} SpriteStateParams;
|
|
|
|
|
2019-12-11 10:25:57 +01:00
|
|
|
typedef union SpriteScaleParams {
|
|
|
|
struct {
|
|
|
|
union {
|
|
|
|
float x;
|
|
|
|
float both;
|
|
|
|
};
|
|
|
|
|
|
|
|
float y;
|
2019-10-03 01:49:10 +02:00
|
|
|
};
|
|
|
|
|
2020-05-09 08:31:20 +02:00
|
|
|
cmplxf as_cmplx;
|
2019-10-03 01:49:10 +02:00
|
|
|
} SpriteScaleParams;
|
|
|
|
|
|
|
|
typedef struct SpriteRotationParams {
|
|
|
|
vec3 vector;
|
|
|
|
float angle;
|
|
|
|
} SpriteRotationParams;
|
|
|
|
|
|
|
|
typedef struct SpriteFlipParams {
|
2024-09-22 21:09:34 +02:00
|
|
|
bool x;
|
|
|
|
bool y;
|
2019-10-03 01:49:10 +02:00
|
|
|
} SpriteFlipParams;
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
typedef struct SpriteParams {
|
|
|
|
Sprite *sprite_ptr;
|
|
|
|
ShaderProgram *shader_ptr;
|
2018-09-14 09:37:20 +02:00
|
|
|
Texture *aux_textures[R_NUM_SPRITE_AUX_TEXTURES];
|
2019-12-11 10:25:57 +01:00
|
|
|
|
|
|
|
// TODO: maybe embed these by value and get rid of SpriteParamsBuffer?
|
2018-07-23 19:07:59 +02:00
|
|
|
const Color *color;
|
2019-10-03 01:49:10 +02:00
|
|
|
const ShaderCustomParams *shader_params;
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
BlendMode blend;
|
|
|
|
|
2019-08-22 21:43:34 +02:00
|
|
|
FloatOffset pos;
|
2019-10-03 01:49:10 +02:00
|
|
|
SpriteScaleParams scale;
|
|
|
|
SpriteRotationParams rotation;
|
|
|
|
SpriteFlipParams flip;
|
|
|
|
} SpriteParams;
|
2018-04-12 16:08:48 +02:00
|
|
|
|
2019-12-11 10:25:57 +01:00
|
|
|
typedef struct SpriteParamsBuffer {
|
|
|
|
Color color;
|
|
|
|
ShaderCustomParams shader_params;
|
|
|
|
} SpriteParamsBuffer;
|
|
|
|
|
2019-10-03 01:49:10 +02:00
|
|
|
// Matches vertex buffer layout
|
|
|
|
typedef struct SpriteInstanceAttribs {
|
|
|
|
mat4 mv_transform;
|
|
|
|
mat4 tex_transform;
|
2018-04-12 16:08:48 +02:00
|
|
|
|
2019-10-03 01:49:10 +02:00
|
|
|
union {
|
|
|
|
FloatRect texrect;
|
|
|
|
vec4 texrect_vec4;
|
|
|
|
};
|
2018-04-12 16:08:48 +02:00
|
|
|
|
2019-10-03 01:49:10 +02:00
|
|
|
Color rgba;
|
|
|
|
FloatExtent sprite_size;
|
|
|
|
ShaderCustomParams custom;
|
2018-04-12 16:08:48 +02:00
|
|
|
|
2019-10-03 01:49:10 +02:00
|
|
|
// offsetof(end_of_fields) == size without padding.
|
|
|
|
char end_of_fields;
|
|
|
|
} SpriteInstanceAttribs;
|
2018-04-12 16:08:48 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Creates an SDL window with proper flags, and, if needed, sets up a rendering context associated with it.
|
|
|
|
* Must be called before anything else.
|
|
|
|
*/
|
|
|
|
|
|
|
|
SDL_Window* r_create_window(const char *title, int x, int y, int w, int h, uint32_t flags)
|
|
|
|
attr_nonnull(1) attr_nodiscard;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO: Document these, and put them in an order that makes a little bit of sense.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void r_init(void);
|
|
|
|
void r_post_init(void);
|
2023-03-22 23:41:32 +01:00
|
|
|
void r_release_resources(void);
|
2018-04-12 16:08:48 +02:00
|
|
|
void r_shutdown(void);
|
2020-02-15 18:45:09 +01:00
|
|
|
const char *r_backend_name(void);
|
2024-07-22 00:33:43 +02:00
|
|
|
void r_unclaim_window(SDL_Window *window);
|
2018-04-12 16:08:48 +02:00
|
|
|
|
2019-05-19 16:39:36 +02:00
|
|
|
r_feature_bits_t r_features(void);
|
|
|
|
|
|
|
|
r_capability_bits_t r_capabilities_current(void);
|
|
|
|
void r_capabilities(r_capability_bits_t newcaps);
|
2018-04-12 16:08:48 +02:00
|
|
|
|
|
|
|
void r_capability(RendererCapability cap, bool value);
|
|
|
|
bool r_capability_current(RendererCapability cap);
|
|
|
|
|
|
|
|
void r_color4(float r, float g, float b, float a);
|
2018-07-23 19:07:59 +02:00
|
|
|
const Color* r_color_current(void);
|
2018-04-12 16:08:48 +02:00
|
|
|
|
|
|
|
void r_blend(BlendMode mode);
|
|
|
|
BlendMode r_blend_current(void);
|
|
|
|
|
|
|
|
void r_cull(CullFaceMode mode);
|
|
|
|
CullFaceMode r_cull_current(void);
|
|
|
|
|
|
|
|
void r_depth_func(DepthTestFunc func);
|
|
|
|
DepthTestFunc r_depth_func_current(void);
|
|
|
|
|
2018-09-14 09:37:20 +02:00
|
|
|
bool r_shader_language_supported(const ShaderLangInfo *lang, ShaderLangInfo *out_alternative) attr_nonnull(1);
|
|
|
|
|
|
|
|
ShaderObject* r_shader_object_compile(ShaderSource *source) attr_nonnull(1);
|
|
|
|
void r_shader_object_destroy(ShaderObject *shobj) attr_nonnull(1);
|
|
|
|
void r_shader_object_set_debug_label(ShaderObject *shobj, const char *label) attr_nonnull(1);
|
|
|
|
const char* r_shader_object_get_debug_label(ShaderObject *shobj) attr_nonnull(1);
|
2021-11-24 08:31:40 +01:00
|
|
|
bool r_shader_object_transfer(ShaderObject *dst, ShaderObject *src) attr_nonnull_all;
|
2018-09-14 09:37:20 +02:00
|
|
|
|
|
|
|
ShaderProgram* r_shader_program_link(uint num_objects, ShaderObject *shobjs[num_objects]) attr_nonnull(2);
|
|
|
|
void r_shader_program_destroy(ShaderProgram *prog);
|
|
|
|
void r_shader_program_set_debug_label(ShaderProgram *prog, const char *label) attr_nonnull(1);
|
|
|
|
const char* r_shader_program_get_debug_label(ShaderProgram *prog) attr_nonnull(1);
|
2021-11-24 08:31:40 +01:00
|
|
|
bool r_shader_program_transfer(ShaderProgram *dst, ShaderProgram *src) attr_nonnull_all;
|
2018-09-14 09:37:20 +02:00
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
void r_shader_ptr(ShaderProgram *prog) attr_nonnull(1);
|
|
|
|
ShaderProgram* r_shader_current(void) attr_returns_nonnull;
|
|
|
|
|
2020-03-17 09:09:49 +01:00
|
|
|
Uniform* _r_shader_uniform(ShaderProgram *prog, const char *uniform_name, hash_t uniform_name_hash) attr_nonnull(1, 2);
|
2018-04-12 16:08:48 +02:00
|
|
|
UniformType r_uniform_type(Uniform *uniform);
|
2018-09-14 09:37:20 +02:00
|
|
|
void r_uniform_ptr_unsafe(Uniform *uniform, uint offset, uint count, void *data);
|
|
|
|
|
|
|
|
#define _R_UNIFORM_GENERIC(suffix, uniform, ...) (_Generic((uniform), \
|
2019-01-24 21:21:08 +01:00
|
|
|
char* : _r_uniform_##suffix, \
|
|
|
|
const char* : _r_uniform_##suffix, \
|
|
|
|
Uniform* : _r_uniform_ptr_##suffix \
|
2018-09-14 09:37:20 +02:00
|
|
|
))(uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_float(Uniform *uniform, float value);
|
|
|
|
void _r_uniform_float(const char *uniform, float value) attr_nonnull(1);
|
|
|
|
#define r_uniform_float(uniform, ...) _R_UNIFORM_GENERIC(float, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_float_array(Uniform *uniform, uint offset, uint count, float elements[count]) attr_nonnull(4);
|
|
|
|
void _r_uniform_float_array(const char *uniform, uint offset, uint count, float elements[count]) attr_nonnull(1, 4);
|
|
|
|
#define r_uniform_float_array(uniform, ...) _R_UNIFORM_GENERIC(float_array, uniform, __VA_ARGS__)
|
|
|
|
|
2021-02-04 00:50:10 +01:00
|
|
|
void _r_uniform_ptr_vec2(Uniform *uniform, float x, float y);
|
2018-09-14 09:37:20 +02:00
|
|
|
void _r_uniform_vec2(const char *uniform, float x, float y) attr_nonnull(1);
|
|
|
|
#define r_uniform_vec2(uniform, ...) _R_UNIFORM_GENERIC(vec2, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_vec2_vec(Uniform *uniform, vec2_noalign value) attr_nonnull(2);
|
|
|
|
void _r_uniform_vec2_vec(const char *uniform, vec2_noalign value) attr_nonnull(1, 2);
|
|
|
|
#define r_uniform_vec2_vec(uniform, ...) _R_UNIFORM_GENERIC(vec2_vec, uniform, __VA_ARGS__)
|
|
|
|
|
2019-11-22 04:37:11 +01:00
|
|
|
void _r_uniform_ptr_vec2_complex(Uniform *uniform, cmplx value);
|
|
|
|
void _r_uniform_vec2_complex(const char *uniform, cmplx value) attr_nonnull(1);
|
2018-09-14 09:37:20 +02:00
|
|
|
#define r_uniform_vec2_complex(uniform, ...) _R_UNIFORM_GENERIC(vec2_complex, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_vec2_array(Uniform *uniform, uint offset, uint count, vec2_noalign elements[count]) attr_nonnull(4);
|
|
|
|
void _r_uniform_vec2_array(const char *uniform, uint offset, uint count, vec2_noalign elements[count]) attr_nonnull(1, 4);
|
|
|
|
#define r_uniform_vec2_array(uniform, ...) _R_UNIFORM_GENERIC(vec2_array, uniform, __VA_ARGS__)
|
|
|
|
|
2019-11-22 04:37:11 +01:00
|
|
|
void _r_uniform_ptr_vec2_array_complex(Uniform *uniform, uint offset, uint count, cmplx elements[count]) attr_nonnull(4);
|
|
|
|
void _r_uniform_vec2_array_complex(const char *uniform, uint offset, uint count, cmplx elements[count]) attr_nonnull(1, 4);
|
2018-09-14 09:37:20 +02:00
|
|
|
#define r_uniform_vec2_array_complex(uniform, ...) _R_UNIFORM_GENERIC(vec2_array_complex, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_vec3(Uniform *uniform, float x, float y, float z);
|
|
|
|
void _r_uniform_vec3(const char *uniform, float x, float y, float z) attr_nonnull(1);
|
|
|
|
#define r_uniform_vec3(uniform, ...) _R_UNIFORM_GENERIC(vec3, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_vec3_vec(Uniform *uniform, vec3_noalign value) attr_nonnull(2);
|
|
|
|
void _r_uniform_vec3_vec(const char *uniform, vec3_noalign value) attr_nonnull(1, 2);
|
|
|
|
#define r_uniform_vec3_vec(uniform, ...) _R_UNIFORM_GENERIC(vec3_vec, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_vec3_rgb(Uniform *uniform, const Color *rgb) attr_nonnull(2);
|
|
|
|
void _r_uniform_vec3_rgb(const char *uniform, const Color *rgb) attr_nonnull(1, 2);
|
|
|
|
#define r_uniform_vec3_rgb(uniform, ...) _R_UNIFORM_GENERIC(vec3_rgb, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_vec3_array(Uniform *uniform, uint offset, uint count, vec3_noalign elements[count]) attr_nonnull(4);
|
|
|
|
void _r_uniform_vec3_array(const char *uniform, uint offset, uint count, vec3_noalign elements[count]) attr_nonnull(1, 4);
|
|
|
|
#define r_uniform_vec3_array(uniform, ...) _R_UNIFORM_GENERIC(vec3_array, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_vec4(Uniform *uniform, float x, float y, float z, float w);
|
|
|
|
void _r_uniform_vec4(const char *uniform, float x, float y, float z, float w) attr_nonnull(1);
|
|
|
|
#define r_uniform_vec4(uniform, ...) _R_UNIFORM_GENERIC(vec4, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_vec4_vec(Uniform *uniform, vec4_noalign value) attr_nonnull(2);
|
|
|
|
void _r_uniform_vec4_vec(const char *uniform, vec4_noalign value) attr_nonnull(1, 2);
|
|
|
|
#define r_uniform_vec4_vec(uniform, ...) _R_UNIFORM_GENERIC(vec4_vec, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_vec4_rgba(Uniform *uniform, const Color *rgba) attr_nonnull(2);
|
|
|
|
void _r_uniform_vec4_rgba(const char *uniform, const Color *rgba) attr_nonnull(1, 2);
|
|
|
|
#define r_uniform_vec4_rgba(uniform, ...) _R_UNIFORM_GENERIC(vec4_rgba, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_vec4_array(Uniform *uniform, uint offset, uint count, vec4_noalign elements[count]) attr_nonnull(4);
|
|
|
|
void _r_uniform_vec4_array(const char *uniform, uint offset, uint count, vec4_noalign elements[count]) attr_nonnull(1, 4);
|
|
|
|
#define r_uniform_vec4_array(uniform, ...) _R_UNIFORM_GENERIC(vec4_array, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_mat3(Uniform *uniform, mat3_noalign value) attr_nonnull(2);
|
|
|
|
void _r_uniform_mat3(const char *uniform, mat3_noalign value) attr_nonnull(1, 2);
|
|
|
|
#define r_uniform_mat3(uniform, ...) _R_UNIFORM_GENERIC(mat3, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_mat3_array(Uniform *uniform, uint offset, uint count, mat3_noalign elements[count]) attr_nonnull(4);
|
|
|
|
void _r_uniform_mat3_array(const char *uniform, uint offset, uint count, mat3_noalign elements[count]) attr_nonnull(1, 4);
|
|
|
|
#define r_uniform_mat3_array(uniform, ...) _R_UNIFORM_GENERIC(mat3_array, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_mat4(Uniform *uniform, mat4_noalign value) attr_nonnull(2);
|
|
|
|
void _r_uniform_mat4(const char *uniform, mat4_noalign value) attr_nonnull(1, 2);
|
|
|
|
#define r_uniform_mat4(uniform, ...) _R_UNIFORM_GENERIC(mat4, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_mat4_array(Uniform *uniform, uint offset, uint count, mat4_noalign elements[count]) attr_nonnull(4);
|
|
|
|
void _r_uniform_mat4_array(const char *uniform, uint offset, uint count, mat4_noalign elements[count]) attr_nonnull(1, 4);
|
|
|
|
#define r_uniform_mat4_array(uniform, ...) _R_UNIFORM_GENERIC(mat4_array, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_int(Uniform *uniform, int value);
|
|
|
|
void _r_uniform_int(const char *uniform, int value) attr_nonnull(1);
|
|
|
|
#define r_uniform_int(uniform, ...) _R_UNIFORM_GENERIC(int, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_int_array(Uniform *uniform, uint offset, uint count, int elements[count]) attr_nonnull(4);
|
|
|
|
void _r_uniform_int_array(const char *uniform, uint offset, uint count, int elements[count]) attr_nonnull(1, 4);
|
|
|
|
#define r_uniform_int_array(uniform, ...) _R_UNIFORM_GENERIC(int_array, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_ivec2(Uniform *uniform, int x, int y);
|
|
|
|
void _r_uniform_ivec2(const char *uniform, int x, int y) attr_nonnull(1);
|
|
|
|
#define r_uniform_ivec2(uniform, ...) _R_UNIFORM_GENERIC(ivec2, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_ivec2_vec(Uniform *uniform, ivec2_noalign value) attr_nonnull(2);
|
|
|
|
void _r_uniform_ivec2_vec(const char *uniform, ivec2_noalign value) attr_nonnull(1, 2);
|
|
|
|
#define r_uniform_ivec2_vec(uniform, ...) _R_UNIFORM_GENERIC(ivec2_vec, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_ivec2_array(Uniform *uniform, uint offset, uint count, ivec2_noalign elements[count]) attr_nonnull(4);
|
|
|
|
void _r_uniform_ivec2_array(const char *uniform, uint offset, uint count, ivec2_noalign elements[count]) attr_nonnull(1, 4);
|
|
|
|
#define r_uniform_ivec2_array(uniform, ...) _R_UNIFORM_GENERIC(ivec2_array, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_ivec3(Uniform *uniform, int x, int y, int z);
|
|
|
|
void _r_uniform_ivec3(const char *uniform, int x, int y, int z) attr_nonnull(1);
|
|
|
|
#define r_uniform_ivec3(uniform, ...) _R_UNIFORM_GENERIC(ivec3, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_ivec3_vec(Uniform *uniform, ivec3_noalign value) attr_nonnull(2);
|
|
|
|
void _r_uniform_ivec3_vec(const char *uniform, ivec3_noalign value) attr_nonnull(1, 2);
|
|
|
|
#define r_uniform_ivec3_vec(uniform, ...) _R_UNIFORM_GENERIC(ivec3_vec, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_ivec3_array(Uniform *uniform, uint offset, uint count, ivec3_noalign elements[count]) attr_nonnull(4);
|
|
|
|
void _r_uniform_ivec3_array(const char *uniform, uint offset, uint count, ivec3_noalign elements[count]) attr_nonnull(1, 4);
|
|
|
|
#define r_uniform_ivec3_array(uniform, ...) _R_UNIFORM_GENERIC(ivec3_array, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_ivec4(Uniform *uniform, int x, int y, int z, int w);
|
|
|
|
void _r_uniform_ivec4(const char *uniform, int x, int y, int z, int w) attr_nonnull(1);
|
|
|
|
#define r_uniform_ivec4(uniform, ...) _R_UNIFORM_GENERIC(ivec4, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_ivec4_vec(Uniform *uniform, ivec4_noalign value) attr_nonnull(2);
|
|
|
|
void _r_uniform_ivec4_vec(const char *uniform, ivec4_noalign value) attr_nonnull(1, 2);
|
|
|
|
#define r_uniform_ivec4_vec(uniform, ...) _R_UNIFORM_GENERIC(ivec4_vec, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_ivec4_array(Uniform *uniform, uint offset, uint count, ivec4_noalign elements[count]) attr_nonnull(4);
|
|
|
|
void _r_uniform_ivec4_array(const char *uniform, uint offset, uint count, ivec4_noalign elements[count]) attr_nonnull(1, 4);
|
|
|
|
#define r_uniform_ivec4_array(uniform, ...) _R_UNIFORM_GENERIC(ivec4_array, uniform, __VA_ARGS__)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_sampler_ptr(Uniform *uniform, Texture *tex) attr_nonnull(2);
|
|
|
|
void _r_uniform_sampler_ptr(const char *uniform, Texture *tex) attr_nonnull(1, 2);
|
|
|
|
void _r_uniform_ptr_sampler(Uniform *uniform, const char *tex) attr_nonnull(2);
|
|
|
|
void _r_uniform_sampler(const char *uniform, const char *tex) attr_nonnull(1, 2);
|
|
|
|
#define r_uniform_sampler(uniform, tex) (_Generic((uniform), \
|
|
|
|
char* : _Generic((tex), \
|
2019-01-24 21:21:08 +01:00
|
|
|
char* : _r_uniform_sampler, \
|
|
|
|
const char* : _r_uniform_sampler, \
|
|
|
|
Texture* : _r_uniform_sampler_ptr \
|
|
|
|
), \
|
|
|
|
const char* : _Generic((tex), \
|
|
|
|
char* : _r_uniform_sampler, \
|
|
|
|
const char* : _r_uniform_sampler, \
|
|
|
|
Texture* : _r_uniform_sampler_ptr \
|
2018-09-14 09:37:20 +02:00
|
|
|
), \
|
|
|
|
Uniform* : _Generic((tex), \
|
2019-01-24 21:21:08 +01:00
|
|
|
char* : _r_uniform_ptr_sampler, \
|
|
|
|
const char* : _r_uniform_ptr_sampler, \
|
|
|
|
Texture* : _r_uniform_ptr_sampler_ptr \
|
2018-09-14 09:37:20 +02:00
|
|
|
) \
|
|
|
|
))(uniform, tex)
|
|
|
|
|
|
|
|
void _r_uniform_ptr_sampler_array_ptr(Uniform *uniform, uint offset, uint count, Texture *values[count]) attr_nonnull(4);
|
|
|
|
void _r_uniform_sampler_array_ptr(const char *uniform, uint offset, uint count, Texture *values[count]) attr_nonnull(1, 4);
|
|
|
|
void _r_uniform_ptr_sampler_array(Uniform *uniform, uint offset, uint count, const char *values[count]) attr_nonnull(4);
|
|
|
|
void _r_uniform_sampler_array(const char *uniform, uint offset, uint count, const char *values[count]) attr_nonnull(4);
|
|
|
|
#define r_uniform_sampler_array(uniform, offset, count, values) (_Generic(uniform, \
|
2019-01-24 21:21:08 +01:00
|
|
|
char* : _Generic((values), \
|
|
|
|
char** : _r_uniform_sampler_array, \
|
|
|
|
Texture** : _r_uniform_sampler_array_ptr \
|
|
|
|
), \
|
|
|
|
const char* : _Generic((values), \
|
2018-09-14 09:37:20 +02:00
|
|
|
char** : _r_uniform_sampler_array, \
|
|
|
|
Texture** : _r_uniform_sampler_array_ptr \
|
|
|
|
), \
|
2019-01-24 21:21:08 +01:00
|
|
|
Uniform* : _Generic((values), \
|
2018-09-14 09:37:20 +02:00
|
|
|
char** : _r_uniform_ptr_sampler_array, \
|
|
|
|
Texture** : _r_uniform_ptr_sampler_array_ptr \
|
|
|
|
) \
|
|
|
|
))(uniform, offset, count, values)
|
2018-04-12 16:08:48 +02:00
|
|
|
|
2018-10-02 22:14:24 +02:00
|
|
|
void r_draw(VertexArray *varr, Primitive prim, uint firstvert, uint count, uint instances, uint base_instance);
|
|
|
|
void r_draw_indexed(VertexArray *varr, Primitive prim, uint firstidx, uint count, uint instances, uint base_instance);
|
2018-04-12 16:08:48 +02:00
|
|
|
|
2018-09-14 09:37:20 +02:00
|
|
|
Texture* r_texture_create(const TextureParams *params) attr_nonnull(1);
|
|
|
|
void r_texture_get_size(Texture *tex, uint mipmap, uint *width, uint *height) attr_nonnull(1);
|
|
|
|
uint r_texture_get_width(Texture *tex, uint mipmap) attr_nonnull(1);
|
|
|
|
uint r_texture_get_height(Texture *tex, uint mipmap) attr_nonnull(1);
|
2018-07-10 11:14:29 +02:00
|
|
|
void r_texture_get_params(Texture *tex, TextureParams *params) attr_nonnull(1, 2);
|
2018-09-14 09:37:20 +02:00
|
|
|
const char* r_texture_get_debug_label(Texture *tex) attr_nonnull(1);
|
|