bgfx/include/bgfx.c99.h

1345 lines
40 KiB
C
Raw Normal View History

2014-05-31 03:18:45 -04:00
/*
* Copyright 2011-2014 Branimir Karadzic. All rights reserved.
2014-06-01 16:25:31 -04:00
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*
* vim: set tabstop=4 expandtab:
2014-05-31 03:18:45 -04:00
*/
#ifndef BGFX_C99_H_HEADER_GUARD
#define BGFX_C99_H_HEADER_GUARD
#include <stdbool.h> // bool
#include <stdint.h> // uint32_t
#include <stdlib.h> // size_t
#include "bgfxdefines.h"
2014-05-31 18:50:01 -04:00
typedef enum bgfx_renderer_type
2014-05-31 03:18:45 -04:00
{
2014-06-01 00:02:37 -04:00
BGFX_RENDERER_TYPE_NULL,
BGFX_RENDERER_TYPE_DIRECT3D9,
BGFX_RENDERER_TYPE_DIRECT3D11,
BGFX_RENDERER_TYPE_OPENGLES,
BGFX_RENDERER_TYPE_OPENGL,
2014-05-31 03:18:45 -04:00
2014-06-01 00:02:37 -04:00
BGFX_RENDERER_TYPE_COUNT
2014-05-31 03:18:45 -04:00
2014-05-31 18:50:01 -04:00
} bgfx_renderer_type_t;
2014-05-31 03:18:45 -04:00
2014-07-22 00:13:16 -04:00
typedef enum bgfx_access
{
BGFX_ACCESS_READ,
BGFX_ACCESS_WRITE,
BGFX_ACCESS_READWRITE,
BGFX_ACCESS_COUNT
} bgfx_access_t;
2014-05-31 18:50:01 -04:00
typedef enum bgfx_attrib
2014-05-31 03:18:45 -04:00
{
2014-06-01 00:02:37 -04:00
BGFX_ATTRIB_POSITION,
BGFX_ATTRIB_NORMAL,
BGFX_ATTRIB_TANGENT,
BGFX_ATTRIB_COLOR0,
BGFX_ATTRIB_COLOR1,
BGFX_ATTRIB_INDICES,
BGFX_ATTRIB_WEIGHT,
BGFX_ATTRIB_TEXCOORD0,
BGFX_ATTRIB_TEXCOORD1,
BGFX_ATTRIB_TEXCOORD2,
BGFX_ATTRIB_TEXCOORD3,
BGFX_ATTRIB_TEXCOORD4,
BGFX_ATTRIB_TEXCOORD5,
BGFX_ATTRIB_TEXCOORD6,
BGFX_ATTRIB_TEXCOORD7,
BGFX_ATTRIB_COUNT
2014-05-31 03:18:45 -04:00
2014-05-31 18:50:01 -04:00
} bgfx_attrib_t;
2014-05-31 03:18:45 -04:00
2014-05-31 18:50:01 -04:00
typedef enum bgfx_attrib_type
2014-05-31 03:18:45 -04:00
{
2014-06-01 00:02:37 -04:00
BGFX_ATTRIB_TYPE_UINT8,
BGFX_ATTRIB_TYPE_INT16,
BGFX_ATTRIB_TYPE_HALF,
BGFX_ATTRIB_TYPE_FLOAT,
2014-05-31 03:18:45 -04:00
2014-06-01 00:02:37 -04:00
BGFX_ATTRIB_TYPE_COUNT
2014-05-31 03:18:45 -04:00
2014-05-31 18:50:01 -04:00
} bgfx_attrib_type_t;
2014-05-31 03:18:45 -04:00
2014-05-31 18:50:01 -04:00
typedef enum bgfx_texture_format
2014-05-31 03:18:45 -04:00
{
2014-06-01 00:02:37 -04:00
BGFX_TEXTURE_FORMAT_BC1,
BGFX_TEXTURE_FORMAT_BC2,
BGFX_TEXTURE_FORMAT_BC3,
BGFX_TEXTURE_FORMAT_BC4,
BGFX_TEXTURE_FORMAT_BC5,
BGFX_TEXTURE_FORMAT_ETC1,
BGFX_TEXTURE_FORMAT_ETC2,
BGFX_TEXTURE_FORMAT_ETC2A,
BGFX_TEXTURE_FORMAT_ETC2A1,
BGFX_TEXTURE_FORMAT_PTC12,
BGFX_TEXTURE_FORMAT_PTC14,
BGFX_TEXTURE_FORMAT_PTC12A,
BGFX_TEXTURE_FORMAT_PTC14A,
BGFX_TEXTURE_FORMAT_PTC22,
BGFX_TEXTURE_FORMAT_PTC24,
BGFX_TEXTURE_FORMAT_UNKNOWN,
BGFX_TEXTURE_FORMAT_R8,
BGFX_TEXTURE_FORMAT_R16,
BGFX_TEXTURE_FORMAT_R16F,
2014-07-22 00:13:16 -04:00
BGFX_TEXTURE_FORMAT_R32,
BGFX_TEXTURE_FORMAT_R32F,
2014-07-26 02:16:11 -04:00
BGFX_TEXTURE_FORMAT_RG8,
2014-07-22 00:13:16 -04:00
BGFX_TEXTURE_FORMAT_RG16,
BGFX_TEXTURE_FORMAT_RG16F,
BGFX_TEXTURE_FORMAT_RG32,
BGFX_TEXTURE_FORMAT_RG32F,
2014-06-01 00:02:37 -04:00
BGFX_TEXTURE_FORMAT_BGRA8,
BGFX_TEXTURE_FORMAT_RGBA16,
BGFX_TEXTURE_FORMAT_RGBA16F,
2014-07-22 00:13:16 -04:00
BGFX_TEXTURE_FORMAT_RGBA32,
BGFX_TEXTURE_FORMAT_RGBA32F,
2014-06-01 00:02:37 -04:00
BGFX_TEXTURE_FORMAT_R5G6B5,
BGFX_TEXTURE_FORMAT_RGBA4,
BGFX_TEXTURE_FORMAT_RGB5A1,
BGFX_TEXTURE_FORMAT_RGB10A2,
BGFX_TEXTURE_FORMAT_UNKNOWN_DEPTH,
BGFX_TEXTURE_FORMAT_D16,
BGFX_TEXTURE_FORMAT_D24,
BGFX_TEXTURE_FORMAT_D24S8,
BGFX_TEXTURE_FORMAT_D32,
BGFX_TEXTURE_FORMAT_D16F,
BGFX_TEXTURE_FORMAT_D24F,
BGFX_TEXTURE_FORMAT_D32F,
BGFX_TEXTURE_FORMAT_D0S8,
BGFX_TEXTURE_FORMAT_COUNT
2014-05-31 03:18:45 -04:00
2014-05-31 18:50:01 -04:00
} bgfx_texture_format_t;
2014-05-31 03:18:45 -04:00
2014-05-31 18:50:01 -04:00
typedef enum bgfx_uniform_type
2014-05-31 03:18:45 -04:00
{
2014-06-01 00:02:37 -04:00
BGFX_UNIFORM_TYPE_UNIFORM1I,
BGFX_UNIFORM_TYPE_UNIFORM1F,
BGFX_UNIFORM_TYPE_END,
2014-05-31 03:18:45 -04:00
2014-06-01 00:02:37 -04:00
BGFX_UNIFORM_TYPE_UNIFORM1IV,
BGFX_UNIFORM_TYPE_UNIFORM1FV,
BGFX_UNIFORM_TYPE_UNIFORM2FV,
BGFX_UNIFORM_TYPE_UNIFORM3FV,
BGFX_UNIFORM_TYPE_UNIFORM4FV,
BGFX_UNIFORM_TYPE_UNIFORM3X3FV,
BGFX_UNIFORM_TYPE_UNIFORM4X4FV,
2014-05-31 03:18:45 -04:00
2014-06-01 00:02:37 -04:00
BGFX_UNIFORM_TYPE_COUNT
2014-05-31 03:18:45 -04:00
2014-05-31 18:50:01 -04:00
} bgfx_uniform_type_t;
2014-05-31 03:18:45 -04:00
#define BGFX_HANDLE_T(_name) \
2014-06-01 00:02:37 -04:00
typedef struct _name { uint16_t idx; } _name##_t;
2014-05-31 03:18:45 -04:00
BGFX_HANDLE_T(bgfx_dynamic_index_buffer_handle);
BGFX_HANDLE_T(bgfx_dynamic_vertex_buffer_handle);
BGFX_HANDLE_T(bgfx_frame_buffer_handle);
BGFX_HANDLE_T(bgfx_index_buffer_handle);
BGFX_HANDLE_T(bgfx_program_handle);
BGFX_HANDLE_T(bgfx_shader_handle);
BGFX_HANDLE_T(bgfx_texture_handle);
BGFX_HANDLE_T(bgfx_uniform_handle);
BGFX_HANDLE_T(bgfx_vertex_buffer_handle);
BGFX_HANDLE_T(bgfx_vertex_decl_handle);
#undef BGFX_HANDLE_T
2014-06-01 00:02:37 -04:00
/**
*/
2014-05-31 18:50:01 -04:00
typedef struct bgfx_memory
2014-05-31 03:18:45 -04:00
{
2014-06-01 00:02:37 -04:00
uint8_t* data;
uint32_t size;
2014-05-31 03:18:45 -04:00
2014-05-31 18:50:01 -04:00
} bgfx_memory_t;
2014-05-31 03:18:45 -04:00
2014-06-01 00:02:37 -04:00
/**
* Vertex declaration.
*/
2014-05-31 18:50:01 -04:00
typedef struct bgfx_vertex_decl
2014-05-31 03:18:45 -04:00
{
2014-06-01 00:02:37 -04:00
uint32_t hash;
uint16_t stride;
uint16_t offset[BGFX_ATTRIB_COUNT];
uint8_t attributes[BGFX_ATTRIB_COUNT];
2014-05-31 03:18:45 -04:00
2014-05-31 18:50:01 -04:00
} bgfx_vertex_decl_t;
2014-05-31 03:18:45 -04:00
2014-06-01 00:02:37 -04:00
/**
*/
2014-05-31 18:50:01 -04:00
typedef struct bgfx_transient_index_buffer
2014-05-31 03:18:45 -04:00
{
2014-06-01 00:02:37 -04:00
uint8_t* data;
uint32_t size;
bgfx_index_buffer_handle_t handle;
uint32_t startIndex;
2014-05-31 03:18:45 -04:00
2014-05-31 18:50:01 -04:00
} bgfx_transient_index_buffer_t;
2014-05-31 03:18:45 -04:00
2014-06-01 00:02:37 -04:00
/**
*/
2014-05-31 18:50:01 -04:00
typedef struct bgfx_transient_vertex_buffer
2014-05-31 03:18:45 -04:00
{
2014-06-01 00:02:37 -04:00
uint8_t* data;
uint32_t size;
uint32_t startVertex;
uint16_t stride;
bgfx_vertex_buffer_handle_t handle;
bgfx_vertex_decl_handle_t decl;
2014-05-31 03:18:45 -04:00
2014-05-31 18:50:01 -04:00
} bgfx_transient_vertex_buffer_t;
2014-05-31 03:18:45 -04:00
2014-06-01 00:02:37 -04:00
/**
*/
2014-05-31 18:50:01 -04:00
typedef struct bgfx_instance_data_buffer
2014-05-31 03:18:45 -04:00
{
2014-06-01 00:02:37 -04:00
uint8_t* data;
uint32_t size;
uint32_t offset;
uint16_t stride;
uint16_t num;
bgfx_vertex_buffer_handle_t handle;
2014-05-31 03:18:45 -04:00
2014-05-31 18:50:01 -04:00
} bgfx_instance_data_buffer_t;
2014-05-31 03:18:45 -04:00
2014-06-01 00:02:37 -04:00
/**
*/
2014-05-31 18:50:01 -04:00
typedef struct bgfx_texture_info
2014-05-31 03:18:45 -04:00
{
2014-06-01 00:02:37 -04:00
bgfx_texture_format_t format;
uint32_t storageSize;
uint16_t width;
uint16_t height;
uint16_t depth;
uint8_t numMips;
uint8_t bitsPerPixel;
2014-05-31 03:18:45 -04:00
2014-05-31 18:50:01 -04:00
} bgfx_texture_info_t;
2014-05-31 03:18:45 -04:00
2014-06-01 00:02:37 -04:00
/**
* Renderer capabilities.
*/
typedef struct bgfx_caps
{
/**
* Renderer backend type.
*/
bgfx_renderer_type_t rendererType;
/**
* Supported functionality, it includes emulated functionality.
* Checking supported and not emulated will give functionality
* natively supported by renderer.
*/
uint64_t supported;
/**
* Emulated functionality. For example some texture compression
* modes are not natively supported by all renderers. The library
* internally decompresses texture into supported format.
*/
uint64_t emulated;
uint16_t maxTextureSize; /* < Maximum texture size. */
uint16_t maxDrawCalls; /* < Maximum draw calls. */
uint8_t maxFBAttachments; /* < Maximum frame buffer attachments. */
/**
* Supported texture formats.
* 0 - not supported
* 1 - supported
* 2 - emulated
*/
uint8_t formats[BGFX_TEXTURE_FORMAT_COUNT];
2014-06-01 00:02:37 -04:00
} bgfx_caps_t;
/**
*/
2014-05-31 18:50:01 -04:00
typedef enum bgfx_fatal
2014-05-31 13:33:37 -04:00
{
2014-06-01 00:02:37 -04:00
BGFX_FATAL_DEBUG_CHECK,
BGFX_FATAL_MINIMUM_REQUIRED_SPECS,
BGFX_FATAL_INVALID_SHADER,
BGFX_FATAL_UNABLE_TO_INITIALIZE,
BGFX_FATAL_UNABLE_TO_CREATE_TEXTURE,
2014-05-31 13:33:37 -04:00
2014-05-31 18:50:01 -04:00
} bgfx_fatal_t;
2014-05-31 13:33:37 -04:00
2014-06-01 18:26:36 -04:00
#ifndef BGFX_SHARED_LIB_BUILD
# define BGFX_SHARED_LIB_BUILD 0
#endif // BGFX_SHARED_LIB_BUILD
#ifndef BGFX_SHARED_LIB_USE
# define BGFX_SHARED_LIB_USE 0
#endif // BGFX_SHARED_LIB_USE
2014-06-01 15:01:50 -04:00
#if defined(_MSC_VER)
# define BGFX_VTBL_CALL __stdcall
# define BGFX_VTBL_THIS // passed via ecx
# define BGFX_VTBL_THIS_ // passed via ecx
2014-06-01 18:26:36 -04:00
# if BGFX_SHARED_LIB_BUILD
# define BGFX_SHARED_LIB_API __declspec(dllexport)
# elif BGFX_SHARED_LIB_USE
# define BGFX_SHARED_LIB_API __declspec(dllimport)
# else
# define BGFX_SHARED_LIB_API
# endif // BGFX_SHARED_LIB_*
2014-06-01 15:01:50 -04:00
#else
2014-06-01 18:26:36 -04:00
# define BGFX_VTBL_CALL
2014-06-01 15:01:50 -04:00
# define BGFX_VTBL_THIS BGFX_VTBL_INTEFRACE _this
# define BGFX_VTBL_THIS_ BGFX_VTBL_INTEFRACE _this,
2014-06-01 18:26:36 -04:00
# define BGFX_SHARED_LIB_API
2014-06-01 15:01:50 -04:00
#endif // defined(_MSC_VER)
2014-06-01 18:26:36 -04:00
#if defined(__cplusplus)
# define BGFX_C_API extern "C" BGFX_SHARED_LIB_API
#else
# define BGFX_C_API BGFX_SHARED_LIB_API
#endif // defined(__cplusplus)
2014-06-01 15:01:50 -04:00
/**
*/
typedef struct bgfx_callback_interface
{
const struct bgfx_callback_vtbl* vtbl;
} bgfx_callback_interface_t;
2014-06-01 00:02:37 -04:00
/**
* Callback interface to implement application specific behavior.
* Cached items are currently used only for OpenGL binary shaders.
*
* NOTE:
* 'fatal' callback can be called from any thread. Other callbacks
* are called from the render thread.
*/
2014-05-31 18:50:01 -04:00
typedef struct bgfx_callback_vtbl
2014-05-31 13:33:37 -04:00
{
2014-06-01 15:01:50 -04:00
# define BGFX_VTBL_INTEFRACE bgfx_callback_interface_t
void* ctor;
2014-06-01 00:02:37 -04:00
/**
2014-06-01 15:01:50 -04:00
* If fatal code code is not BGFX_FATAL_DEBUG_CHECK this callback is
2014-06-01 00:02:37 -04:00
* called on unrecoverable error. It's not safe to continue, inform
* user and terminate application from this call.
*/
2014-06-01 15:01:50 -04:00
void (BGFX_VTBL_CALL *fatal)(BGFX_VTBL_THIS_ bgfx_fatal_t _code, const char* _str);
2014-06-01 00:02:37 -04:00
/**
* Return size of for cached item. Return 0 if no cached item was
* found.
*/
2014-06-01 15:01:50 -04:00
uint32_t (BGFX_VTBL_CALL *cache_read_size)(BGFX_VTBL_THIS_ uint64_t _id);
2014-06-01 00:02:37 -04:00
/**
* Read cached item.
*/
2014-06-01 15:01:50 -04:00
bool (BGFX_VTBL_CALL *cache_read)(BGFX_VTBL_THIS_ uint64_t _id, void* _data, uint32_t _size);
2014-06-01 00:02:37 -04:00
/**
* Write cached item.
*/
2014-06-01 15:01:50 -04:00
void (BGFX_VTBL_CALL *cache_write)(BGFX_VTBL_THIS_ uint64_t _id, const void* _data, uint32_t _size);
2014-06-01 00:02:37 -04:00
/**
* Screenshot captured. Screenshot format is always 4-byte BGRA.
*/
2014-06-01 15:01:50 -04:00
void (BGFX_VTBL_CALL *screen_shot)(BGFX_VTBL_THIS_ const char* _filePath, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _data, uint32_t _size, bool _yflip);
2014-06-01 00:02:37 -04:00
/**
* Called when capture begins.
*/
2014-06-01 15:01:50 -04:00
void (BGFX_VTBL_CALL *capture_begin)(BGFX_VTBL_THIS_ uint32_t _width, uint32_t _height, uint32_t _pitch, bgfx_texture_format_t _format, bool _yflip);
2014-06-01 00:02:37 -04:00
/**
* Called when capture ends.
*/
2014-06-01 15:01:50 -04:00
void (BGFX_VTBL_CALL *capture_end)(BGFX_VTBL_THIS);
2014-06-01 00:02:37 -04:00
/**
* Captured frame.
*/
2014-06-01 15:01:50 -04:00
void (BGFX_VTBL_CALL *capture_frame)(BGFX_VTBL_THIS_ const void* _data, uint32_t _size);
# undef BGFX_VTBL_INTEFRACE
2014-05-31 13:33:37 -04:00
2014-05-31 18:50:01 -04:00
} bgfx_callback_vtbl_t;
2014-06-01 00:02:37 -04:00
/**
*/
2014-06-01 15:01:50 -04:00
typedef struct bgfx_reallocator_interface
2014-05-31 13:33:37 -04:00
{
2014-06-01 15:01:50 -04:00
const struct bgfx_reallocator_vtbl* vtbl;
2014-05-31 18:50:01 -04:00
2014-06-01 15:01:50 -04:00
} bgfx_reallocator_interface_t;
2014-05-31 13:33:37 -04:00
2014-06-01 00:02:37 -04:00
/**
*/
2014-05-31 18:50:01 -04:00
typedef struct bgfx_reallocator_vtbl
2014-05-31 13:33:37 -04:00
{
2014-06-01 15:01:50 -04:00
# define BGFX_VTBL_INTEFRACE bgfx_reallocator_interface_t
2014-05-31 13:33:37 -04:00
2014-06-01 15:01:50 -04:00
void* ctor;
void* (BGFX_VTBL_CALL *alloc)(BGFX_VTBL_THIS_ size_t _size, size_t _align, const char* _file, uint32_t _line);
void (BGFX_VTBL_CALL *free)(BGFX_VTBL_THIS_ void* _ptr, size_t _align, const char* _file, uint32_t _line);
void* (BGFX_VTBL_CALL *realloc)(BGFX_VTBL_THIS_ void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line);
2014-05-31 18:50:01 -04:00
2014-06-01 15:01:50 -04:00
# undef BGFX_VTBL_INTEFRACE
2014-05-31 18:50:01 -04:00
2014-06-01 15:01:50 -04:00
} bgfx_reallocator_vtbl_t;
2014-05-31 13:33:37 -04:00
2014-06-01 00:02:37 -04:00
/**
* Start vertex declaration.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_vertex_decl_begin(bgfx_vertex_decl_t* _decl, bgfx_renderer_type_t _renderer);
2014-06-01 00:02:37 -04:00
/**
* Add attribute to vertex declaration.
*
* @param _attrib Attribute semantics.
* @param _num Number of elements 1, 2, 3 or 4.
* @param _type Element type.
* @param _normalized When using fixed point AttribType (f.e. Uint8)
* value will be normalized for vertex shader usage. When normalized
* is set to true, AttribType::Uint8 value in range 0-255 will be
* in range 0.0-1.0 in vertex shader.
* @param _asInt Packaging rule for vertexPack, vertexUnpack, and
* vertexConvert for AttribType::Uint8 and AttribType::Int16.
* Unpacking code must be implemented inside vertex shader.
*
* NOTE:
* Must be called between begin/end.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_vertex_decl_add(bgfx_vertex_decl_t* _decl, bgfx_attrib_t _attrib, uint8_t _num, bgfx_attrib_type_t _type, bool _normalized, bool _asInt);
2014-06-01 00:02:37 -04:00
/**
* Skip _num bytes in vertex stream.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_vertex_decl_skip(bgfx_vertex_decl_t* _decl, uint8_t _num);
2014-06-01 00:02:37 -04:00
/**
* End vertex declaration.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_vertex_decl_end(bgfx_vertex_decl_t* _decl);
2014-06-01 16:25:31 -04:00
/**
* Pack vec4 into vertex stream format.
*/
2014-06-01 16:26:57 -04:00
BGFX_C_API void bgfx_vertex_pack(const float _input[4], bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_decl_t* _decl, void* _data, uint32_t _index);
2014-06-01 16:25:31 -04:00
/**
* Unpack vec4 from vertex stream format.
*/
BGFX_C_API void bgfx_vertex_unpack(float _output[4], bgfx_attrib_t _attr, const bgfx_vertex_decl_t* _decl, const void* _data, uint32_t _index);
/**
* Converts vertex stream data from one vertex stream format to another.
*
* @param _destDecl Destination vertex stream declaration.
* @param _destData Destination vertex stream.
* @param _srcDecl Source vertex stream declaration.
* @param _srcData Source vertex stream data.
* @param _num Number of vertices to convert from source to destination.
*/
BGFX_C_API void bgfx_vertex_convert(const bgfx_vertex_decl_t* _destDecl, void* _destData, const bgfx_vertex_decl_t* _srcDecl, const void* _srcData, uint32_t _num);
/**
* Weld vertices.
*
* @param _output Welded vertices remapping table. The size of buffer
* must be the same as number of vertices.
* @param _decl Vertex stream declaration.
* @param _data Vertex stream.
* @param _num Number of vertices in vertex stream.
* @param _epsilon Error tolerance for vertex position comparison.
* @returns Number of unique vertices after vertex welding.
*/
BGFX_C_API uint16_t bgfx_weld_vertices(uint16_t* _output, const bgfx_vertex_decl_t* _decl, const void* _data, uint16_t _num, float _epsilon);
/**
* Swizzle RGBA8 image to BGRA8.
*
* @param _width Width of input image (pixels).
* @param _height Height of input image (pixels).
* @param _pitch Pitch of input image (bytes).
* @param _src Source image.
* @param _dst Destination image. Must be the same size as input image.
* _dst might be pointer to the same memory as _src.
*/
BGFX_C_API void bgfx_image_swizzle_bgra8(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
/**
* Downsample RGBA8 image with 2x2 pixel average filter.
*
* @param _width Width of input image (pixels).
* @param _height Height of input image (pixels).
* @param _pitch Pitch of input image (bytes).
* @param _src Source image.
* @param _dst Destination image. Must be at least quarter size of
* input image. _dst might be pointer to the same memory as _src.
*/
BGFX_C_API void bgfx_image_rgba8_downsample_2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
/**
* Returns supported backend API renderers.
*/
BGFX_C_API uint8_t bgfx_get_supported_renderers(bgfx_renderer_type_t _enum[BGFX_RENDERER_TYPE_COUNT]);
/**
* Returns name of renderer.
*/
BGFX_C_API const char* bgfx_get_renderer_name(bgfx_renderer_type_t _type);
2014-06-01 00:02:37 -04:00
/**
* Initialize bgfx library.
*
* @param _type Select rendering backend. When set to RendererType::Count
* default rendering backend will be selected.
*
* @param _callback Provide application specific callback interface.
* See: CallbackI
*
* @param _reallocator Custom allocator. When custom allocator is not
* specified, library uses default CRT allocator. The library assumes
* custom allocator is thread safe.
*/
2014-05-31 18:50:01 -04:00
BGFX_C_API void bgfx_init(bgfx_renderer_type_t _type, bgfx_callback_interface_t* _callback, bgfx_reallocator_interface_t* _allocator);
2014-05-31 03:18:45 -04:00
2014-06-01 00:02:37 -04:00
/**
* Shutdown bgfx library.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_shutdown();
2014-06-01 00:02:37 -04:00
/**
* Reset graphic settings.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_reset(uint32_t _width, uint32_t _height, uint32_t _flags);
2014-06-01 00:02:37 -04:00
/**
* Advance to next frame. When using multithreaded renderer, this call
* just swaps internal buffers, kicks render thread, and returns. In
* singlethreaded renderer this call does frame rendering.
*
* @returns Current frame number. This might be used in conjunction with
* double/multi buffering data outside the library and passing it to
* library via makeRef calls.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API uint32_t bgfx_frame();
2014-06-01 00:02:37 -04:00
/**
* Returns current renderer backend API type.
*
* NOTE:
* Library must be initialized.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_renderer_type_t bgfx_get_renderer_type();
2014-06-01 16:25:31 -04:00
/**
* Returns renderer capabilities.
*
* NOTE:
* Library must be initialized.
*/
BGFX_C_API bgfx_caps_t* bgfx_get_caps();
2014-06-01 00:02:37 -04:00
/**
* Allocate buffer to pass to bgfx calls. Data will be freed inside bgfx.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API const bgfx_memory_t* bgfx_alloc(uint32_t _size);
2014-06-01 00:02:37 -04:00
/**
* Allocate buffer and copy data into it. Data will be freed inside bgfx.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API const bgfx_memory_t* bgfx_copy(const void* _data, uint32_t _size);
2014-06-01 00:02:37 -04:00
/**
* Make reference to data to pass to bgfx. Unlike bgfx::alloc this call
* doesn't allocate memory for data. It just copies pointer to data.
* You must make sure data is available for at least 2 bgfx::frame calls.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API const bgfx_memory_t* bgfx_make_ref(const void* _data, uint32_t _size);
2014-06-01 00:02:37 -04:00
/**
* Set debug flags.
*
* @param _debug Available flags:
*
* BGFX_DEBUG_IFH - Infinitely fast hardware. When this flag is set
* all rendering calls will be skipped. It's useful when profiling
* to quickly assess bottleneck between CPU and GPU.
*
* BGFX_DEBUG_STATS - Display internal statistics.
*
* BGFX_DEBUG_TEXT - Display debug text.
*
* BGFX_DEBUG_WIREFRAME - Wireframe rendering. All rendering
* primitives will be rendered as lines.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_debug(uint32_t _debug);
2014-06-01 00:02:37 -04:00
/**
* Clear internal debug text buffer.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_dbg_text_clear(uint8_t _attr, bool _small);
2014-06-01 00:02:37 -04:00
/**
* Print into internal debug text buffer.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_dbg_text_printf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ...);
2014-06-01 00:02:37 -04:00
/**
* Create static index buffer.
*
* NOTE:
* Only 16-bit index buffer is supported.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_index_buffer_handle_t bgfx_create_index_buffer(const bgfx_memory_t* _mem);
2014-06-01 00:02:37 -04:00
/**
* Destroy static index buffer.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_destroy_index_buffer(bgfx_index_buffer_handle_t _handle);
2014-06-01 00:02:37 -04:00
/**
* Create static vertex buffer.
*
* @param _mem Vertex buffer data.
* @param _decl Vertex declaration.
* @returns Static vertex buffer handle.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl);
2014-06-01 00:02:37 -04:00
/**
* Destroy static vertex buffer.
*
* @param _handle Static vertex buffer handle.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_destroy_vertex_buffer(bgfx_vertex_buffer_handle_t _handle);
2014-06-01 00:02:37 -04:00
/**
* Create empty dynamic index buffer.
*
* @param _num Number of indices.
*
* NOTE:
* Only 16-bit index buffer is supported.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer(uint32_t _num);
2014-06-01 00:02:37 -04:00
/**
* Create dynamic index buffer and initialized it.
*
* @param _mem Index buffer data.
*
* NOTE:
* Only 16-bit index buffer is supported.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer_mem(const bgfx_memory_t* _mem);
2014-06-01 00:02:37 -04:00
/**
* Update dynamic index buffer.
*
* @param _handle Dynamic index buffer handle.
* @param _mem Index buffer data.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_update_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, const bgfx_memory_t* _mem);
2014-06-01 00:02:37 -04:00
/**
* Destroy dynamic index buffer.
*
* @param _handle Dynamic index buffer handle.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle);
2014-06-01 00:02:37 -04:00
/**
* Create empty dynamic vertex buffer.
*
* @param _num Number of vertices.
* @param _decl Vertex declaration.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint16_t _num, const bgfx_vertex_decl_t* _decl);
2014-06-01 00:02:37 -04:00
/**
* Create dynamic vertex buffer and initialize it.
*
* @param _mem Vertex buffer data.
* @param _decl Vertex declaration.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl);
2014-06-01 00:02:37 -04:00
/**
* Update dynamic vertex buffer.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_update_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, const bgfx_memory_t* _mem);
2014-06-01 00:02:37 -04:00
/**
* Destroy dynamic vertex buffer.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_destroy_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle);
2014-06-01 00:02:37 -04:00
/**
* Returns true if internal transient index buffer has enough space.
*
* @param _num Number of indices.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bool bgfx_check_avail_transient_index_buffer(uint32_t _num);
2014-06-01 00:02:37 -04:00
/**
* Returns true if internal transient vertex buffer has enough space.
*
* @param _num Number of vertices.
* @param _decl Vertex declaration.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bool bgfx_check_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl);
2014-06-01 00:02:37 -04:00
/**
* Returns true if internal instance data buffer has enough space.
*
* @param _num Number of instances.
* @param _stride Stride per instance.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bool bgfx_check_avail_instance_data_buffer(uint32_t _num, uint16_t _stride);
2014-06-01 00:02:37 -04:00
/**
* Returns true if both internal transient index and vertex buffer have
* enough space.
*
* @param _numVertices Number of vertices.
* @param _decl Vertex declaration.
* @param _numIndices Number of indices.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bool bgfx_check_avail_transient_buffers(uint32_t _numVertices, const bgfx_vertex_decl_t* _decl, uint32_t _numIndices);
2014-06-01 00:02:37 -04:00
/**
* Allocate transient index buffer.
*
* @param[out] _tib TransientIndexBuffer structure is filled and is valid
* for the duration of frame, and it can be reused for multiple draw
* calls.
* @param _num Number of indices to allocate.
*
* NOTE:
* 1. You must call setIndexBuffer after alloc in order to avoid memory
* leak.
* 2. Only 16-bit index buffer is supported.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t* _tib, uint32_t _num);
2014-06-01 00:02:37 -04:00
/**
* Allocate transient vertex buffer.
*
* @param[out] _tvb TransientVertexBuffer structure is filled and is valid
* for the duration of frame, and it can be reused for multiple draw
* calls.
* @param _num Number of vertices to allocate.
* @param _decl Vertex declaration.
*
* NOTE:
* You must call setVertexBuffer after alloc in order to avoid memory
* leak.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_decl_t* _decl);
2014-06-01 00:02:37 -04:00
/**
* Check for required space and allocate transient vertex and index
* buffers. If both space requirements are satisfied function returns
* true.
*
* NOTE:
* Only 16-bit index buffer is supported.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_decl_t* _decl, uint16_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint16_t _numIndices);
2014-06-01 00:02:37 -04:00
/**
* Allocate instance data buffer.
*
* NOTE:
* You must call setInstanceDataBuffer after alloc in order to avoid
* memory leak.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API const bgfx_instance_data_buffer_t* bgfx_alloc_instance_data_buffer(uint32_t _num, uint16_t _stride);
2014-06-01 00:02:37 -04:00
/**
* Create shader from memory buffer.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_shader_handle_t bgfx_create_shader(const bgfx_memory_t* _mem);
2014-06-01 00:02:37 -04:00
/**
* Returns num of uniforms, and uniform handles used inside shader.
*
* @param _handle Shader handle.
* @param _uniforms UniformHandle array where data will be stored.
* @param _max Maximum capacity of array.
* @returns Number of uniforms used by shader.
*
* NOTE:
* Only non-predefined uniforms are returned.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API uint16_t bgfx_get_shader_uniforms(bgfx_shader_handle_t _handle, bgfx_uniform_handle_t* _uniforms, uint16_t _max);
2014-06-01 00:02:37 -04:00
/**
* Destroy shader. Once program is created with shader it is safe to
* destroy shader.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_destroy_shader(bgfx_shader_handle_t _handle);
2014-06-01 00:02:37 -04:00
/**
* Create program with vertex and fragment shaders.
*
* @param _vsh Vertex shader.
* @param _fsh Fragment shader.
* @param _destroyShaders If true, shaders will be destroyed when
* program is destroyed.
* @returns Program handle if vertex shader output and fragment shader
* input are matching, otherwise returns invalid program handle.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_program_handle_t bgfx_create_program(bgfx_shader_handle_t _vsh, bgfx_shader_handle_t _fsh, bool _destroyShaders);
2014-06-01 00:02:37 -04:00
/**
* Destroy program.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_destroy_program(bgfx_program_handle_t _handle);
2014-06-01 00:02:37 -04:00
/**
* Calculate amount of memory required for texture.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_calc_texture_size(bgfx_texture_info_t* _info, uint16_t _width, uint16_t _height, uint16_t _depth, uint8_t _numMips, bgfx_texture_format_t _format);
2014-06-01 00:02:37 -04:00
/**
* Create texture from memory buffer.
*
* @param _mem DDS, KTX or PVR texture data.
* @param _flags Default texture sampling mode is linear, and wrap mode
* is repeat.
*
* BGFX_TEXTURE_[U/V/W]_[MIRROR/CLAMP] - Mirror or clamp to edge wrap
* mode.
*
* BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC] - Point or anisotropic
* sampling.
*
* @param _skip Skip top level mips when parsing texture.
* @param _info Returns parsed texture information.
* @returns Texture handle.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_texture_handle_t bgfx_create_texture(const bgfx_memory_t* _mem, uint32_t _flags, uint8_t _skip, bgfx_texture_info_t* _info);
2014-06-01 00:02:37 -04:00
/**
* Create 2D texture.
*
* @param _width
* @param _height
* @param _numMips
* @param _format
* @param _flags
* @param _mem
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d(uint16_t _width, uint16_t _height, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem);
2014-06-01 00:02:37 -04:00
/**
* Create 3D texture.
*
* @param _width
* @param _height
* @param _depth
* @param _numMips
* @param _format
* @param _flags
* @param _mem
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_3d(uint16_t _width, uint16_t _height, uint16_t _depth, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem);
2014-06-01 00:02:37 -04:00
/**
* Create Cube texture.
*
* @param _size
* @param _numMips
* @param _format
* @param _flags
* @param _mem
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_cube(uint16_t _size, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem);
2014-06-01 00:02:37 -04:00
/**
* Update 2D texture.
*
* @param _handle
* @param _mip
* @param _x
* @param _y
* @param _width
* @param _height
* @param _mem
* @param _pitch Pitch of input image (bytes). When _pitch is set to
* UINT16_MAX, it will be calculated internally based on _width.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_update_texture_2d(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
2014-06-01 00:02:37 -04:00
/**
* Update 3D texture.
*
* @param _handle
* @param _mip
* @param _x
* @param _y
* @param _z
* @param _width
* @param _height
* @param _depth
* @param _mem
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_update_texture_3d(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const bgfx_memory_t* _mem);
2014-06-01 00:02:37 -04:00
/**
* Update Cube texture.
*
* @param _handle
* @param _side Cubemap side, where 0 is +X, 1 is -X, 2 is +Y, 3 is
* -Y, 4 is +Z, and 5 is -Z.
*
* +----------+
* |-z 2|
* | ^ +y |
* | | |
* | +---->+x |
* +----------+----------+----------+----------+
* |+y 1|+y 4|+y 0|+y 5|
* | ^ -x | ^ +z | ^ +x | ^ -z |
* | | | | | | | | |
* | +---->+z | +---->+x | +---->-z | +---->-x |
* +----------+----------+----------+----------+
* |+z 3|
* | ^ -y |
* | | |
* | +---->+x |
* +----------+
*
* @param _mip
* @param _x
* @param _y
* @param _width
* @param _height
* @param _mem
* @param _pitch Pitch of input image (bytes). When _pitch is set to
* UINT16_MAX, it will be calculated internally based on _width.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_update_texture_cube(bgfx_texture_handle_t _handle, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
2014-06-01 00:02:37 -04:00
/**
* Destroy texture.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle);
2014-06-01 00:02:37 -04:00
/**
* Create frame buffer (simple).
*
* @param _width Texture width.
* @param _height Texture height.
* @param _format Texture format.
* @param _textureFlags Texture flags.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint32_t _textureFlags);
2014-06-01 00:02:37 -04:00
/**
* Create frame buffer.
*
* @param _num Number of texture attachments.
* @param _handles Texture attachments.
2014-06-01 16:25:31 -04:00
* @param _destroyTextures If true, textures will be destroyed when
2014-06-01 00:02:37 -04:00
* frame buffer is destroyed.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, bgfx_texture_handle_t* _handles, bool _destroyTextures);
2014-06-01 00:02:37 -04:00
/**
* Destroy frame buffer.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_destroy_frame_buffer(bgfx_frame_buffer_handle_t _handle);
2014-06-01 00:02:37 -04:00
/**
* Create shader uniform parameter.
*
* @param _name Uniform name in shader.
* @param _type Type of uniform (See: UniformType).
* @param _num Number of elements in array.
*
* Predefined uniforms:
*
* u_viewRect vec4(x, y, width, height) - view rectangle for current
* view.
*
* u_viewTexel vec4(1.0/width, 1.0/height, undef, undef) - inverse
* width and height
*
* u_view mat4 - view matrix
*
* u_invView mat4 - inverted view matrix
*
* u_proj mat4 - projection matrix
*
* u_invProj mat4 - inverted projection matrix
*
* u_viewProj mat4 - concatenated view projection matrix
*
* u_invViewProj mat4 - concatenated inverted view projection matrix
*
* u_model mat4[BGFX_CONFIG_MAX_BONES] - array of model matrices.
*
* u_modelView mat4 - concatenated model view matrix, only first
* model matrix from array is used.
*
* u_modelViewProj mat4 - concatenated model view projection matrix.
*
* u_alphaRef float - alpha reference value for alpha test.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API bgfx_uniform_handle_t bgfx_create_uniform(const char* _name, bgfx_uniform_type_t _type, uint16_t _num);
2014-06-01 00:02:37 -04:00
/**
* Destroy shader uniform parameter.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_destroy_uniform(bgfx_uniform_handle_t _handle);
2014-06-01 00:02:37 -04:00
/**
* Set view name.
*
* @param _id View id.
* @param _name View name.
*
* NOTE:
* This is debug only feature.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_view_name(uint8_t _id, const char* _name);
2014-06-01 00:02:37 -04:00
/**
* Set view rectangle. Draw primitive outside view will be clipped.
*
* @param _id View id.
* @param _x Position x from the left corner of the window.
* @param _y Position y from the top corner of the window.
* @param _width Width of view port region.
* @param _height Height of view port region.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_view_rect(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
2014-06-01 00:02:37 -04:00
/**
* Set view rectangle for multiple views.
*
* @param _viewMask Bit mask representing affected views.
* @param _x Position x from the left corner of the window.
* @param _y Position y from the top corner of the window.
* @param _width Width of view port region.
* @param _height Height of view port region.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_view_rect_mask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
2014-06-01 00:02:37 -04:00
/**
* Set view scissor. Draw primitive outside view will be clipped. When
* _x, _y, _width and _height are set to 0, scissor will be disabled.
*
* @param _x Position x from the left corner of the window.
* @param _y Position y from the top corner of the window.
* @param _width Width of scissor region.
* @param _height Height of scissor region.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_view_scissor(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
2014-06-01 00:02:37 -04:00
/**
* Set view scissor for multiple views. When _x, _y, _width and _height
* are set to 0, scissor will be disabled.
*
* @param _id View id.
* @param _viewMask Bit mask representing affected views.
* @param _x Position x from the left corner of the window.
* @param _y Position y from the top corner of the window.
* @param _width Width of scissor region.
* @param _height Height of scissor region.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_view_scissor_mask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
2014-06-01 00:02:37 -04:00
/**
* Set view clear flags.
*
* @param _id View id.
* @param _flags Clear flags. Use BGFX_CLEAR_NONE to remove any clear
* operation. See: BGFX_CLEAR_*.
* @param _rgba Color clear value.
* @param _depth Depth clear value.
* @param _stencil Stencil clear value.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_view_clear(uint8_t _id, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil);
2014-06-01 00:02:37 -04:00
/**
* Set view clear flags for multiple views.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_view_clear_mask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil);
2014-06-01 00:02:37 -04:00
/**
* Set view into sequential mode. Draw calls will be sorted in the same
* order in which submit calls were called.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_view_seq(uint8_t _id, bool _enabled);
2014-06-01 00:02:37 -04:00
/**
* Set multiple views into sequential mode.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_view_seq_mask(uint32_t _viewMask, bool _enabled);
2014-06-01 00:02:37 -04:00
/**
* Set view frame buffer.
*
* @param _id View id.
* @param _handle Frame buffer handle. Passing BGFX_INVALID_HANDLE as
* frame buffer handle will draw primitives from this view into
* default back buffer.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_view_frame_buffer(uint8_t _id, bgfx_frame_buffer_handle_t _handle);
2014-06-01 00:02:37 -04:00
/**
* Set view frame buffer for multiple views.
*
* @param _viewMask View mask.
* @param _handle Frame buffer handle. Passing BGFX_INVALID_HANDLE as
* frame buffer handle will draw primitives from this view into
* default back buffer.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_view_frame_buffer_mask(uint32_t _viewMask, bgfx_frame_buffer_handle_t _handle);
2014-06-01 00:02:37 -04:00
/**
* Set view view and projection matrices, all draw primitives in this
* view will use these matrices.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_view_transform(uint8_t _id, const void* _view, const void* _proj);
2014-06-01 00:02:37 -04:00
/**
* Set view view and projection matrices for multiple views.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_view_transform_mask(uint32_t _viewMask, const void* _view, const void* _proj);
2014-06-01 00:02:37 -04:00
/**
* Sets debug marker.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_marker(const char* _marker);
2014-06-01 00:02:37 -04:00
/**
* Set render states for draw primitive.
*
* @param _state State flags. Default state for primitive type is
* triangles. See: BGFX_STATE_DEFAULT.
*
* BGFX_STATE_ALPHA_WRITE - Enable alpha write.
* BGFX_STATE_DEPTH_WRITE - Enable depth write.
* BGFX_STATE_DEPTH_TEST_* - Depth test function.
* BGFX_STATE_BLEND_* - See NOTE 1: BGFX_STATE_BLEND_FUNC.
* BGFX_STATE_BLEND_EQUATION_* - See NOTE 2.
* BGFX_STATE_CULL_* - Backface culling mode.
* BGFX_STATE_RGB_WRITE - Enable RGB write.
* BGFX_STATE_MSAA - Enable MSAA.
* BGFX_STATE_PT_[LINES/POINTS] - Primitive type.
*
* @param _rgba Sets blend factor used by BGFX_STATE_BLEND_FACTOR and
* BGFX_STATE_BLEND_INV_FACTOR blend modes.
*
* NOTE:
* 1. Use BGFX_STATE_ALPHA_REF, BGFX_STATE_POINT_SIZE and
* BGFX_STATE_BLEND_FUNC macros to setup more complex states.
* 2. BGFX_STATE_BLEND_EQUATION_ADD is set when no other blend
* equation is specified.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_state(uint64_t _state, uint32_t _rgba);
2014-06-01 00:02:37 -04:00
/**
* Set stencil test state.
*
* @param _fstencil Front stencil state.
* @param _bstencil Back stencil state. If back is set to BGFX_STENCIL_NONE
* _fstencil is applied to both front and back facing primitives.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_stencil(uint32_t _fstencil, uint32_t _bstencil);
2014-06-01 00:02:37 -04:00
/**
* Set scissor for draw primitive. For scissor for all primitives in
* view see setViewScissor.
*
* @param _x Position x from the left corner of the window.
* @param _y Position y from the top corner of the window.
* @param _width Width of scissor region.
* @param _height Height of scissor region.
* @returns Scissor cache index.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API uint16_t bgfx_set_scissor(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
2014-06-01 00:02:37 -04:00
/**
* Set scissor from cache for draw primitive.
*
* @param _cache Index in scissor cache. Passing UINT16_MAX unset primitive
* scissor and primitive will use view scissor instead.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_scissor_cached(uint16_t _cache);
2014-06-01 00:02:37 -04:00
/**
* Set model matrix for draw primitive. If it is not called model will
* be rendered with identity model matrix.
*
* @param _mtx Pointer to first matrix in array.
* @param _num Number of matrices in array.
* @returns index into matrix cache in case the same model matrix has
* to be used for other draw primitive call.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API uint32_t bgfx_set_transform(const void* _mtx, uint16_t _num);
2014-06-01 00:02:37 -04:00
/**
* Set model matrix from matrix cache for draw primitive.
*
* @param _cache Index in matrix cache.
* @param _num Number of matrices from cache.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_transform_cached(uint32_t _cache, uint16_t _num);
2014-06-01 00:02:37 -04:00
/**
* Set shader uniform parameter for draw primitive.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_uniform(bgfx_uniform_handle_t _handle, const void* _value, uint16_t _num);
2014-06-01 00:02:37 -04:00
/**
* Set index buffer for draw primitive.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_index_buffer(bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
2014-06-01 00:02:37 -04:00
/**
* Set index buffer for draw primitive.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
2014-06-01 00:02:37 -04:00
/**
* Set index buffer for draw primitive.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_transient_index_buffer(const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices);
2014-06-01 00:02:37 -04:00
/**
* Set vertex buffer for draw primitive.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_vertex_buffer(bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
2014-06-01 00:02:37 -04:00
/**
* Set vertex buffer for draw primitive.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _numVertices);
2014-06-01 00:02:37 -04:00
/**
* Set vertex buffer for draw primitive.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_transient_vertex_buffer(const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices);
2014-06-01 00:02:37 -04:00
/**
* Set instance data buffer for draw primitive.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_instance_data_buffer(const bgfx_instance_data_buffer_t* _idb, uint16_t _num);
2014-06-01 00:02:37 -04:00
/**
* Set program for draw primitive.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_program(bgfx_program_handle_t _handle);
2014-06-01 00:02:37 -04:00
/**
* Set texture stage for draw primitive.
*
* @param _stage Texture unit.
* @param _sampler Program sampler.
* @param _handle Texture handle.
* @param _flags Texture sampling mode. Default value UINT32_MAX uses
* texture sampling settings from the texture.
*
* BGFX_TEXTURE_[U/V/W]_[MIRROR/CLAMP] - Mirror or clamp to edge wrap
* mode.
*
* BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC] - Point or anisotropic
* sampling.
*
* @param _flags Texture sampler filtering flags. UINT32_MAX use the
* sampler filtering mode set by texture.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_texture(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags);
2014-06-01 00:02:37 -04:00
/**
* Set texture stage for draw primitive.
*
* @param _stage Texture unit.
* @param _sampler Program sampler.
* @param _handle Frame buffer handle.
* @param _attachment Attachment index.
* @param _flags Texture sampling mode. Default value UINT32_MAX uses
* texture sampling settings from the texture.
*
* BGFX_TEXTURE_[U/V/W]_[MIRROR/CLAMP] - Mirror or clamp to edge wrap
* mode.
*
* BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC] - Point or anisotropic
* sampling.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_set_texture_from_frame_buffer(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, uint32_t _flags);
2014-06-01 00:02:37 -04:00
/**
* Submit primitive for rendering into single view.
*
* @param _id View id.
* @param _depth Depth for sorting.
* @returns Number of draw calls.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API uint32_t bgfx_submit(uint8_t _id, int32_t _depth);
2014-06-01 00:02:37 -04:00
/**
* Submit primitive for rendering into multiple views.
*
* @param _viewMask Mask to which views to submit draw primitive calls.
* @param _depth Depth for sorting.
* @returns Number of draw calls.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API uint32_t bgfx_submit_mask(uint32_t _viewMask, int32_t _depth);
2014-07-22 00:13:16 -04:00
/**
*
*/
BGFX_C_API void bgfx_set_image(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_texture_format_t _format, bgfx_access_t _access);
/**
*
*/
BGFX_C_API void bgfx_set_image_from_frame_buffer(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, bgfx_texture_format_t _format, bgfx_access_t _access);
/**
* Dispatch compute.
*/
BGFX_C_API void bgfx_dispatch(uint8_t _id, bgfx_program_handle_t _handle, uint16_t _numX, uint16_t _numY, uint16_t _numZ);
2014-06-01 00:02:37 -04:00
/**
* Discard all previously set state for draw call.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_discard();
2014-06-01 00:02:37 -04:00
/**
* Request screen shot.
*
* @param _filePath Will be passed to CallbackI::screenShot callback.
*
* NOTE:
* CallbackI::screenShot must be implemented.
*/
2014-05-31 03:18:45 -04:00
BGFX_C_API void bgfx_save_screen_shot(const char* _filePath);
#endif // BGFX_C99_H_HEADER_GUARD