bgfx/include/bgfx.h

2021 lines
71 KiB
C
Raw Normal View History

2012-10-07 23:41:18 -04:00
/*
2015-01-01 18:04:46 -05:00
* Copyright 2011-2015 Branimir Karadzic. All rights reserved.
2014-06-01 16:25:31 -04:00
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
2012-10-07 23:41:18 -04:00
*/
#ifndef BGFX_H_HEADER_GUARD
#define BGFX_H_HEADER_GUARD
2012-10-07 23:41:18 -04:00
2015-07-24 21:02:17 -04:00
#include <stdarg.h> // va_list
2012-10-07 23:41:18 -04:00
#include <stdint.h> // uint32_t
#include <stdlib.h> // size_t
2014-05-31 03:18:45 -04:00
#include "bgfxdefines.h"
2013-10-10 21:29:57 -04:00
2012-11-10 22:59:23 -05:00
///
#define BGFX_HANDLE(_name) \
struct _name { uint16_t idx; }; \
2015-07-21 21:15:12 -04:00
inline bool isValid(_name _handle) { return bgfx::invalidHandle != _handle.idx; }
2012-10-07 23:41:18 -04:00
#define BGFX_INVALID_HANDLE { bgfx::invalidHandle }
2013-09-17 00:40:30 -04:00
namespace bx { struct ReallocatorI; }
2012-11-10 22:59:23 -05:00
/// BGFX
2012-10-07 23:41:18 -04:00
namespace bgfx
{
2015-07-23 23:37:46 -04:00
/// Fatal error enum.
///
/// @attention C99 equivalent is `bgfx_fatal_t`.
///
2012-10-07 23:41:18 -04:00
struct Fatal
{
enum Enum
{
DebugCheck,
MinimumRequiredSpecs,
InvalidShader,
2012-12-08 17:30:41 -05:00
UnableToInitialize,
UnableToCreateTexture,
DeviceLost,
Count
2012-10-07 23:41:18 -04:00
};
};
2015-07-23 23:37:46 -04:00
/// Renderer backend type enum.
///
/// @attention C99 equivalent is `bgfx_renderer_type_t`.
///
2012-10-07 23:41:18 -04:00
struct RendererType
{
2014-10-11 13:12:27 -04:00
/// Renderer type enumeration.
2012-10-07 23:41:18 -04:00
enum Enum
{
2014-10-11 17:08:43 -04:00
Null, //!< No rendering.
Direct3D9, //!< Direct3D 9.0
Direct3D11, //!< Direct3D 11.0
2015-02-15 21:27:54 -05:00
Direct3D12, //!< Direct3D 12.0
2015-06-11 12:38:17 -04:00
Metal, //!< Metal
2015-02-15 21:27:54 -05:00
OpenGLES, //!< OpenGL ES 2.0+
2014-10-11 17:08:43 -04:00
OpenGL, //!< OpenGL 2.1+
2015-03-05 23:34:39 -05:00
Vulkan, //!< Vulkan
Count
2012-10-07 23:41:18 -04:00
};
};
2015-07-23 23:37:46 -04:00
/// Access mode enum.
///
/// @attention C99 equivalent is `bgfx_access_t`.
///
2014-07-20 23:27:13 -04:00
struct Access
{
enum Enum
{
Read,
Write,
ReadWrite,
Count
};
};
2015-07-23 23:37:46 -04:00
/// Vertex attribute enum.
///
/// @attention C99 equivalent is `bgfx_attrib_t`.
///
2012-10-07 23:41:18 -04:00
struct Attrib
{
2014-10-11 17:08:43 -04:00
/// Corresponds to vertex shader attribute.
enum Enum
2012-10-07 23:41:18 -04:00
{
2014-10-11 17:08:43 -04:00
Position, //!< a_position
Normal, //!< a_normal
Tangent, //!< a_tangent
Bitangent, //!< a_bitangent
Color0, //!< a_color0
Color1, //!< a_color1
Indices, //!< a_indices
Weight, //!< a_weight
TexCoord0, //!< a_texcoord0
TexCoord1, //!< a_texcoord1
TexCoord2, //!< a_texcoord2
TexCoord3, //!< a_texcoord3
TexCoord4, //!< a_texcoord4
TexCoord5, //!< a_texcoord5
TexCoord6, //!< a_texcoord6
TexCoord7, //!< a_texcoord7
2012-10-07 23:41:18 -04:00
Count
2012-10-07 23:41:18 -04:00
};
};
2015-07-23 23:37:46 -04:00
/// Vertex attribute type enum.
///
/// @attention C99 equivalent is `bgfx_attrib_type_t`.
///
2012-10-07 23:41:18 -04:00
struct AttribType
{
enum Enum
{
Uint8,
2015-08-04 22:03:56 -04:00
Uint10, //!< Availability depends on: `BGFX_CAPS_VERTEX_ATTRIB_UINT10`.
Int16,
2015-08-04 22:03:56 -04:00
Half, //!< Availability depends on: `BGFX_CAPS_VERTEX_ATTRIB_HALF`.
2012-10-07 23:41:18 -04:00
Float,
Count
2012-10-07 23:41:18 -04:00
};
};
2015-07-23 23:37:46 -04:00
/// Texture format enum.
///
/// @attention C99 equivalent is `bgfx_texture_format_t`.
///
2012-10-07 23:41:18 -04:00
struct TextureFormat
{
// Availability depends on Caps (see: formats).
2012-10-07 23:41:18 -04:00
enum Enum
{
2013-09-05 00:42:31 -04:00
BC1, // DXT1
BC2, // DXT3
BC3, // DXT5
BC4, // LATC1/ATI1
BC5, // LATC2/ATI2
2014-08-01 22:24:42 -04:00
BC6H, // BC6H
BC7, // BC7
2013-09-05 00:42:31 -04:00
ETC1, // ETC1 RGB8
ETC2, // ETC2 RGB8
ETC2A, // ETC2 RGBA8
ETC2A1, // ETC2 RGB8A1
PTC12, // PVRTC1 RGB 2BPP
PTC14, // PVRTC1 RGB 4BPP
PTC12A, // PVRTC1 RGBA 2BPP
PTC14A, // PVRTC1 RGBA 4BPP
2013-09-05 00:42:31 -04:00
PTC22, // PVRTC2 RGBA 2BPP
PTC24, // PVRTC2 RGBA 4BPP
2014-01-12 16:51:26 -05:00
Unknown, // compressed formats above
R1,
R8,
R16,
R16F,
2014-07-22 00:13:16 -04:00
R32,
R32F,
2014-07-26 02:16:11 -04:00
RG8,
2014-07-22 00:13:16 -04:00
RG16,
RG16F,
RG32,
RG32F,
2012-12-30 23:52:47 -05:00
BGRA8,
2015-03-05 20:44:56 -05:00
RGBA8,
2012-12-30 23:52:47 -05:00
RGBA16,
2013-01-27 02:00:35 -05:00
RGBA16F,
2014-07-22 00:13:16 -04:00
RGBA32,
RGBA32F,
R5G6B5,
RGBA4,
RGB5A1,
RGB10A2,
2014-08-26 23:56:53 -04:00
R11G11B10F,
2014-01-09 01:08:37 -05:00
2014-01-12 16:51:26 -05:00
UnknownDepth, // depth formats below
D16,
D24,
D24S8,
D32,
D16F,
D24F,
D32F,
D0S8,
2012-10-07 23:41:18 -04:00
Count
};
};
2015-07-23 23:37:46 -04:00
/// Uniform type enum.
///
/// @attention C99 equivalent is `bgfx_uniform_type_t`.
///
2012-11-04 00:36:17 -04:00
struct UniformType
{
enum Enum
{
2015-05-28 18:27:00 -04:00
Int1,
2012-11-04 00:36:17 -04:00
End,
2015-05-28 18:27:00 -04:00
Vec4,
Mat3,
Mat4,
2012-11-04 00:36:17 -04:00
Count
};
};
2015-07-23 23:37:46 -04:00
/// Backbuffer ratio enum.
///
/// @attention C99 equivalent is `bgfx_backbuffer_ratio_t`.
///
struct BackbufferRatio
{
enum Enum
{
Equal,
Half,
Quarter,
Eighth,
Sixteenth,
Double,
2015-04-26 14:34:33 -04:00
Count
};
};
2012-10-28 16:27:50 -04:00
static const uint16_t invalidHandle = UINT16_MAX;
BGFX_HANDLE(DynamicIndexBufferHandle);
BGFX_HANDLE(DynamicVertexBufferHandle);
BGFX_HANDLE(FrameBufferHandle);
2012-10-28 16:27:50 -04:00
BGFX_HANDLE(IndexBufferHandle);
2015-05-13 17:11:56 -04:00
BGFX_HANDLE(IndirectBufferHandle);
2012-10-28 16:27:50 -04:00
BGFX_HANDLE(ProgramHandle);
BGFX_HANDLE(ShaderHandle);
2012-10-28 16:27:50 -04:00
BGFX_HANDLE(TextureHandle);
BGFX_HANDLE(UniformHandle);
BGFX_HANDLE(VertexBufferHandle);
BGFX_HANDLE(VertexDeclHandle);
2012-10-07 23:41:18 -04:00
2012-12-30 23:52:47 -05:00
/// Callback interface to implement application specific behavior.
2013-04-04 12:48:20 -04:00
/// Cached items are currently used only for OpenGL binary shaders.
2012-12-30 23:52:47 -05:00
///
/// @remarks
2015-07-20 22:49:51 -04:00
/// 'fatal' and 'trace' callbacks can be called from any thread. Other
/// callbacks are called from the render thread.
///
2015-07-23 23:37:46 -04:00
/// @attention C99 equivalent is `bgfx_callback_interface_t`.
///
2012-12-30 23:52:47 -05:00
struct CallbackI
{
virtual ~CallbackI() = 0;
/// If fatal code code is not Fatal::DebugCheck this callback is
/// called on unrecoverable error. It's not safe to continue, inform
2012-12-30 23:52:47 -05:00
/// user and terminate application from this call.
2014-10-11 13:12:27 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _code Fatal error code.
/// @param[in] _str More information about error.
2014-10-11 13:12:27 -04:00
///
2015-07-20 22:49:51 -04:00
/// @remarks
/// Not thread safe and it can be called from any thread.
///
2015-07-23 23:37:46 -04:00
/// @attention C99 equivalent is `bgfx_callback_vtbl.fatal`.
///
2012-12-30 23:52:47 -05:00
virtual void fatal(Fatal::Enum _code, const char* _str) = 0;
/// Print debug message.
///
2015-07-24 21:02:17 -04:00
/// @param[in] _filePath File path where debug message was generated.
/// @param[in] _line Line where debug message was generated.
/// @param[in] _format `printf` style format.
/// @param[in] _argList Variable arguments list initialized with
/// `va_start`.
///
2015-07-20 22:49:51 -04:00
/// @remarks
/// Not thread safe and it can be called from any thread.
///
2015-07-24 21:02:17 -04:00
/// @attention C99 equivalent is `bgfx_callback_vtbl.trace_vargs`.
2015-07-23 23:37:46 -04:00
///
2015-07-24 21:02:17 -04:00
virtual void traceVargs(const char* _filePath, uint16_t _line, const char* _format, va_list _argList) = 0;
2012-12-30 23:52:47 -05:00
/// Return size of for cached item. Return 0 if no cached item was
/// found.
2014-10-11 13:12:27 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _id Cache id.
2014-10-11 13:12:27 -04:00
/// @returns Number of bytes to read.
///
2015-07-23 23:37:46 -04:00
/// @attention C99 equivalent is `bgfx_callback_vtbl.cache_read_size`.
///
2012-12-30 23:52:47 -05:00
virtual uint32_t cacheReadSize(uint64_t _id) = 0;
/// Read cached item.
2014-10-11 13:12:27 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _id Cache id.
/// @param[in] _data Buffer where to read data.
/// @param[in] _size Size of data to read.
2014-10-11 13:12:27 -04:00
///
/// @returns True if data is read.
///
2015-07-23 23:37:46 -04:00
/// @attention C99 equivalent is `bgfx_callback_vtbl.cache_read`.
///
2012-12-30 23:52:47 -05:00
virtual bool cacheRead(uint64_t _id, void* _data, uint32_t _size) = 0;
/// Write cached item.
2014-10-11 13:12:27 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _id Cache id.
/// @param[in] _data Data to write.
/// @param[in] _size Size of data to write.
2014-10-11 13:12:27 -04:00
///
2015-07-23 23:37:46 -04:00
/// @attention C99 equivalent is `bgfx_callback_vtbl.cache_write`.
///
2012-12-30 23:52:47 -05:00
virtual void cacheWrite(uint64_t _id, const void* _data, uint32_t _size) = 0;
/// Screenshot captured. Screenshot format is always 4-byte BGRA.
2014-10-11 13:12:27 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _filePath File path.
/// @param[in] _width Image width.
/// @param[in] _height Image height.
/// @param[in] _pitch Number of bytes to skip to next line.
/// @param[in] _data Image data.
/// @param[in] _size Image size.
/// @param[in] _yflip If true image origin is bottom left.
2014-10-11 13:12:27 -04:00
///
2015-07-23 23:37:46 -04:00
/// @attention C99 equivalent is `bgfx_callback_vtbl.screen_shot`.
///
2012-12-30 23:52:47 -05:00
virtual void screenShot(const char* _filePath, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _data, uint32_t _size, bool _yflip) = 0;
/// Called when capture begins.
2015-07-23 23:37:46 -04:00
///
/// @attention C99 equivalent is `bgfx_callback_vtbl.capture_begin`.
///
2014-05-31 03:18:45 -04:00
virtual void captureBegin(uint32_t _width, uint32_t _height, uint32_t _pitch, TextureFormat::Enum _format, bool _yflip) = 0;
2012-12-30 23:52:47 -05:00
/// Called when capture ends.
2015-07-23 23:37:46 -04:00
///
/// @attention C99 equivalent is `bgfx_callback_vtbl.capture_end`.
///
2012-12-30 23:52:47 -05:00
virtual void captureEnd() = 0;
/// Captured frame.
2014-10-11 13:12:27 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _data Image data.
/// @param[in] _size Image size.
2014-10-11 13:12:27 -04:00
///
2015-07-23 23:37:46 -04:00
/// @attention C99 equivalent is `bgfx_callback_vtbl.capture_frame`.
///
2012-12-30 23:52:47 -05:00
virtual void captureFrame(const void* _data, uint32_t _size) = 0;
};
2013-02-16 18:38:52 -05:00
inline CallbackI::~CallbackI()
{
2012-12-30 23:52:47 -05:00
}
2012-11-04 00:36:17 -04:00
2015-07-23 23:37:46 -04:00
/// Memory release callback.
///
/// @attention C99 equivalent is `bgfx_release_fn_t`.
2015-04-01 19:44:44 -04:00
///
typedef void (*ReleaseFn)(void* _ptr, void* _userData);
2015-07-23 23:37:46 -04:00
/// Memory obtained by calling `bgfx::alloc`, `bgfx::copy`, or `bgfx::makeRef`.
///
/// @attention C99 equivalent is `bgfx_memory_t`.
///
2012-10-07 23:41:18 -04:00
struct Memory
{
uint8_t* data;
uint32_t size;
};
2013-10-10 21:29:57 -04:00
/// Renderer capabilities.
2015-07-23 23:37:46 -04:00
///
/// @attention C99 equivalent is `bgfx_caps_t`.
///
2013-10-10 21:29:57 -04:00
struct Caps
{
2014-10-11 15:51:32 -04:00
/// Renderer backend type. See: `bgfx::RendererType`
2013-10-10 21:29:57 -04:00
RendererType::Enum rendererType;
2014-10-11 15:51:32 -04:00
/// Supported functionality.
///
/// - `BGFX_CAPS_TEXTURE_COMPARE_LEQUAL` - Less equal texture
/// compare mode.
/// - `BGFX_CAPS_TEXTURE_COMPARE_ALL` - All texture compare modes.
/// - `BGFX_CAPS_TEXTURE_3D` - 3D textures.
/// - `BGFX_CAPS_VERTEX_ATTRIB_HALF` - AttribType::Half.
/// - `BGFX_CAPS_INSTANCING` - Vertex instancing.
/// - `BGFX_CAPS_RENDERER_MULTITHREADED` - Renderer on separate
/// thread.
/// - `BGFX_CAPS_FRAGMENT_DEPTH` - Fragment shader can modify depth
/// buffer value (gl_FragDepth).
/// - `BGFX_CAPS_BLEND_INDEPENDENT` - Multiple render targets can
/// have different blend mode set individually.
/// - `BGFX_CAPS_COMPUTE` - Renderer has compute shaders.
/// - `BGFX_CAPS_FRAGMENT_ORDERING` - Intel's pixel sync.
/// - `BGFX_CAPS_SWAP_CHAIN` - Multiple windows.
///
2013-10-10 21:29:57 -04:00
uint64_t supported;
2015-07-23 23:37:46 -04:00
uint32_t maxDrawCalls; //!< Maximum draw calls.
uint16_t maxTextureSize; //!< Maximum texture size.
uint16_t maxViews; //!< Maximum views.
uint8_t maxFBAttachments; //!< Maximum frame buffer attachments.
uint8_t numGPUs; //!< Number of enumerated GPUs.
uint16_t vendorId; //!< Selected GPU vendor id.
uint16_t deviceId; //!< Selected GPU device id.
2015-03-26 18:01:47 -04:00
2015-07-23 23:37:46 -04:00
/// GPU info.
///
/// @attention C99 equivalent is `bgfx_caps_gpu_t`.
///
2015-03-26 18:01:47 -04:00
struct GPU
{
uint16_t vendorId;
uint16_t deviceId;
};
2015-07-23 23:37:46 -04:00
GPU gpu[4]; //!< Enumerated GPUs.
/// Supported texture formats.
2015-03-02 01:01:30 -05:00
/// - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - not supported
/// - `BGFX_CAPS_FORMAT_TEXTURE_COLOR` - supported
/// - `BGFX_CAPS_FORMAT_TEXTURE_EMULATED` - emulated
/// - `BGFX_CAPS_FORMAT_TEXTURE_VERTEX` - supported vertex texture
uint8_t formats[TextureFormat::Count];
2013-10-10 21:29:57 -04:00
};
2015-07-23 23:37:46 -04:00
/// Transient index buffer.
///
/// @attention C99 equivalent is `bgfx_transient_index_buffer_t`.
///
2012-10-07 23:41:18 -04:00
struct TransientIndexBuffer
{
2015-07-23 23:37:46 -04:00
uint8_t* data; //!< Pointer to data.
uint32_t size; //!< Data size.
uint32_t startIndex; //!< First index.
IndexBufferHandle handle; //!< Index buffer handle.
2012-10-07 23:41:18 -04:00
};
2015-07-23 23:37:46 -04:00
/// Transient vertex buffer.
///
/// @attention C99 equivalent is `bgfx_transient_vertex_buffer_t`.
///
2012-10-07 23:41:18 -04:00
struct TransientVertexBuffer
{
2015-07-23 23:37:46 -04:00
uint8_t* data; //!< Pointer to data.
uint32_t size; //!< Data size.
uint32_t startVertex; //!< First vertex.
uint16_t stride; //!< Vertex stride.
VertexBufferHandle handle; //!< Vertex buffer handle.
VertexDeclHandle decl; //!< Vertex declaration handle.
2012-10-07 23:41:18 -04:00
};
2015-07-23 23:37:46 -04:00
/// Instance data buffer info.
///
/// @attention C99 equivalent is `bgfx_texture_info_t`.
///
2012-10-07 23:41:18 -04:00
struct InstanceDataBuffer
{
2014-10-11 17:08:43 -04:00
uint8_t* data; //!< Pointer to data.
uint32_t size; //!< Data size.
uint32_t offset; //!< Offset in vertex buffer.
2014-12-10 02:16:27 -05:00
uint32_t num; //!< Number of instances.
2014-10-11 17:08:43 -04:00
uint16_t stride; //!< Vertex buffer stride.
VertexBufferHandle handle; //!< Vertex buffer object handle.
2012-10-07 23:41:18 -04:00
};
2015-07-23 23:37:46 -04:00
/// Texture info.
///
/// @attention C99 equivalent is `bgfx_texture_info_t`.
///
2012-11-04 00:36:17 -04:00
struct TextureInfo
2012-10-07 23:41:18 -04:00
{
2014-10-11 17:08:43 -04:00
TextureFormat::Enum format; //!< Texture format.
uint32_t storageSize; //!< Total amount of bytes required to store texture.
uint16_t width; //!< Texture width.
uint16_t height; //!< Texture height.
uint16_t depth; //!< Texture depth.
uint8_t numMips; //!< Number of MIP maps.
uint8_t bitsPerPixel; //!< Format bits per pixel.
bool cubeMap; //!< Texture is cubemap.
};
2015-07-23 23:37:46 -04:00
/// Transform data.
///
/// @attention C99 equivalent is `bgfx_transform_t`.
///
struct Transform
{
2014-10-11 17:08:43 -04:00
float* data; //!< Pointer to first matrix.
uint16_t num; //!< Number of matrices.
2012-10-07 23:41:18 -04:00
};
2014-10-29 01:08:55 -04:00
/// HMD info.
2015-07-23 23:37:46 -04:00
///
/// @attention C99 equivalent is `bgfx_hmd_t`.
///
2014-10-29 01:08:55 -04:00
struct HMD
{
/// Eye
2015-07-23 23:37:46 -04:00
///
/// @attention C99 equivalent is `bgfx_hmd_eye_t`.
///
2014-10-29 01:08:55 -04:00
struct Eye
{
float rotation[4]; //!< Eye rotation represented as quaternion.
float translation[3]; //!< Eye translation.
float fov[4]; //!< Field of view (up, down, left, right).
float viewOffset[3]; //!< Eye view matrix translation adjustment.
float pixelsPerTanAngle[2]; //!<
2014-10-29 01:08:55 -04:00
};
Eye eye[2];
uint16_t width; //!< Framebuffer width.
uint16_t height; //!< Framebuffer width.
uint32_t deviceWidth; //!< Device resolution width
uint32_t deviceHeight; //!< Device resolution height
uint8_t flags; //!< Status flags
2014-10-29 01:08:55 -04:00
};
2015-07-23 23:37:46 -04:00
/// Renderer statistics data.
///
/// @attention C99 equivalent is `bgfx_stats_t`.
///
struct Stats
{
uint64_t cpuTime; //!< CPU frame time.
uint64_t cpuTimerFreq; //!< CPU timer frequency.
uint64_t gpuTime; //!< GPU frame time.
uint64_t gpuTimerFreq; //!< GPU timer frequency.
};
2012-12-30 23:52:47 -05:00
/// Vertex declaration.
2015-07-23 23:37:46 -04:00
///
/// @attention C99 equivalent is `bgfx_vertex_decl_t`.
///
2012-10-07 23:41:18 -04:00
struct VertexDecl
{
VertexDecl();
/// Start VertexDecl.
2015-07-23 23:37:46 -04:00
///
/// @attention C99 equivalent is `bgfx_vertex_decl_begin`.
///
VertexDecl& begin(RendererType::Enum _renderer = RendererType::Null);
/// End VertexDecl.
2015-07-23 23:37:46 -04:00
///
/// @attention C99 equivalent is `bgfx_vertex_decl_begin`.
///
2012-10-07 23:41:18 -04:00
void end();
2013-02-16 14:51:36 -05:00
/// Add attribute to VertexDecl.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _attrib Attribute semantics. See: `bgfx::Attrib`
/// @param[in] _num Number of elements 1, 2, 3 or 4.
/// @param[in] _type Element type.
/// @param[in] _normalized When using fixed point AttribType (f.e. Uint8)
2013-03-19 12:02:58 -04:00
/// 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.
2015-07-10 21:59:28 -04:00
/// @param[in] _asInt Packaging rule for vertexPack, vertexUnpack, and
/// vertexConvert for AttribType::Uint8 and AttribType::Int16.
/// Unpacking code must be implemented inside vertex shader.
///
/// @remarks
2013-02-16 14:51:36 -05:00
/// Must be called between begin/end.
///
2015-07-23 23:37:46 -04:00
/// @attention C99 equivalent is `bgfx_vertex_decl_add`.
///
VertexDecl& add(Attrib::Enum _attrib, uint8_t _num, AttribType::Enum _type, bool _normalized = false, bool _asInt = false);
/// Skip _num bytes in vertex stream.
2015-07-23 23:37:46 -04:00
///
/// @attention C99 equivalent is `bgfx_vertex_decl_skip`.
///
VertexDecl& skip(uint8_t _num);
/// Decode attribute.
2015-07-23 23:37:46 -04:00
///
/// @attention C99 equivalent is ``.
///
2012-12-31 21:48:52 -05:00
void decode(Attrib::Enum _attrib, uint8_t& _num, AttribType::Enum& _type, bool& _normalized, bool& _asInt) const;
/// Returns true if VertexDecl contains attribute.
bool has(Attrib::Enum _attrib) const { return 0xff != m_attributes[_attrib]; }
/// Returns relative attribute offset from the vertex.
uint16_t getOffset(Attrib::Enum _attrib) const { return m_offset[_attrib]; }
/// Returns vertex stride.
uint16_t getStride() const { return m_stride; }
/// Returns size of vertex buffer for number of vertices.
uint32_t getSize(uint32_t _num) const { return _num*m_stride; }
2012-10-07 23:41:18 -04:00
uint32_t m_hash;
uint16_t m_stride;
uint16_t m_offset[Attrib::Count];
2015-08-04 22:03:56 -04:00
uint16_t m_attributes[Attrib::Count];
2012-10-07 23:41:18 -04:00
};
2012-12-31 21:48:52 -05:00
/// Pack vec4 into vertex stream format.
2015-07-23 23:37:46 -04:00
///
/// @attention C99 equivalent is `bgfx_vertex_pack`.
///
2012-12-31 21:48:52 -05:00
void vertexPack(const float _input[4], bool _inputNormalized, Attrib::Enum _attr, const VertexDecl& _decl, void* _data, uint32_t _index = 0);
/// Unpack vec4 from vertex stream format.
2015-07-23 23:37:46 -04:00
///
/// @attention C99 equivalent is `bgfx_vertex_unpack`.
///
2012-12-31 21:48:52 -05:00
void vertexUnpack(float _output[4], Attrib::Enum _attr, const VertexDecl& _decl, const void* _data, uint32_t _index = 0);
2013-05-10 01:09:17 -04:00
/// Converts vertex stream data from one vertex stream format to another.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _destDecl Destination vertex stream declaration.
/// @param[in] _destData Destination vertex stream.
/// @param[in] _srcDecl Source vertex stream declaration.
/// @param[in] _srcData Source vertex stream data.
/// @param[in] _num Number of vertices to convert from source to destination.
2013-05-10 01:09:17 -04:00
///
2015-07-23 23:37:46 -04:00
/// @attention C99 equivalent is `bgfx_vertex_convert`.
///
void vertexConvert(const VertexDecl& _destDecl, void* _destData, const VertexDecl& _srcDecl, const void* _srcData, uint32_t _num = 1);
2013-11-03 01:00:31 -05:00
/// Weld vertices.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _output Welded vertices remapping table. The size of buffer
2013-11-03 01:00:31 -05:00
/// must be the same as number of vertices.
2015-07-10 21:59:28 -04:00
/// @param[in] _decl Vertex stream declaration.
/// @param[in] _data Vertex stream.
/// @param[in] _num Number of vertices in vertex stream.
/// @param[in] _epsilon Error tolerance for vertex position comparison.
2013-11-03 01:00:31 -05:00
/// @returns Number of unique vertices after vertex welding.
///
2015-07-23 23:37:46 -04:00
/// @attention C99 equivalent is `bgfx_weld_vertices`.
///
2013-11-03 01:00:31 -05:00
uint16_t weldVertices(uint16_t* _output, const VertexDecl& _decl, const void* _data, uint16_t _num, float _epsilon = 0.001f);
/// Swizzle RGBA8 image to BGRA8.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _width Width of input image (pixels).
/// @param[in] _height Height of input image (pixels).
/// @param[in] _pitch Pitch of input image (bytes).
/// @param[in] _src Source image.
/// @param[in] _dst Destination image. Must be the same size as input image.
/// _dst might be pointer to the same memory as _src.
///
2015-07-23 23:37:46 -04:00
/// @attention C99 equivalent is `bgfx_image_swizzle_bgra8`.
///
void imageSwizzleBgra8(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
/// Downsample RGBA8 image with 2x2 pixel average filter.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _width Width of input image (pixels).
/// @param[in] _height Height of input image (pixels).
/// @param[in] _pitch Pitch of input image (bytes).
/// @param[in] _src Source image.
/// @param[in] _dst Destination image. Must be at least quarter size of
/// input image. _dst might be pointer to the same memory as _src.
///
2015-07-23 23:37:46 -04:00
/// @attention C99 equivalent is `bgfx_image_rgba8_downsample_2x2`.
///
void imageRgba8Downsample2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
/// Returns supported backend API renderers.
2015-07-23 23:37:46 -04:00
///
/// @attention C99 equivalent is `bgfx_get_supported_renderers`.
///
uint8_t getSupportedRenderers(RendererType::Enum _enum[RendererType::Count]);
2012-10-07 23:41:18 -04:00
2014-05-27 23:05:13 -04:00
/// Returns name of renderer.
2015-07-23 23:37:46 -04:00
///
/// @attention C99 equivalent is `bgfx_get_renderer_name`.
///
2014-05-27 23:05:13 -04:00
const char* getRendererName(RendererType::Enum _type);
/// Initialize bgfx library.
2013-04-04 12:48:20 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _type Select rendering backend. When set to RendererType::Count
/// default rendering backend will be selected.
2014-10-11 13:12:27 -04:00
/// See: `bgfx::RendererType`
///
2015-07-26 12:16:36 -04:00
/// @param[in] _vendorId Vendor PCI id. If set to `BGFX_PCI_ID_NONE` it will select the first
/// device.
2015-03-26 18:09:31 -04:00
/// - `BGFX_PCI_ID_NONE` - autoselect.
/// - `BGFX_PCI_ID_AMD` - AMD.
/// - `BGFX_PCI_ID_INTEL` - Intel.
/// - `BGFX_PCI_ID_NVIDIA` - nVidia.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _deviceId Device id. If set to 0 it will select first device, or device with
2015-03-26 18:09:31 -04:00
/// matching id.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _callback Provide application specific callback interface.
2014-10-11 13:12:27 -04:00
/// See: `bgfx::CallbackI`
2013-04-04 12:48:20 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _reallocator Custom allocator. When custom allocator is not
2013-04-04 12:48:20 -04:00
/// specified, library uses default CRT allocator. The library assumes
2014-10-11 13:12:27 -04:00
/// icustom allocator is thread safe.
///
/// @returns `true` if initialization is sucessful.
///
2014-10-11 13:12:27 -04:00
/// @attention C99 equivalent is `bgfx_init`.
2013-04-04 12:48:20 -04:00
///
bool init(RendererType::Enum _type = RendererType::Count, uint16_t _vendorId = BGFX_PCI_ID_NONE, uint16_t _deviceId = 0, CallbackI* _callback = NULL, bx::ReallocatorI* _reallocator = NULL);
2012-10-07 23:41:18 -04:00
/// Shutdown bgfx library.
2014-10-11 13:12:27 -04:00
///
/// @attention C99 equivalent is `bgfx_shutdown`.
///
2012-10-07 23:41:18 -04:00
void shutdown();
/// Reset graphic settings and back-buffer size.
2014-10-11 13:12:27 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _width Back-buffer width.
/// @param[in] _height Back-buffer height.
2015-07-26 20:36:06 -04:00
/// @param[in] _flags See: `BGFX_RESET_*` for more info.
2014-10-11 13:12:27 -04:00
/// - `BGFX_RESET_NONE` - No reset flags.
/// - `BGFX_RESET_FULLSCREEN` - Not supported yet.
/// - `BGFX_RESET_MSAA_X[2/4/8/16]` - Enable 2, 4, 8 or 16 x MSAA.
/// - `BGFX_RESET_VSYNC` - Enable V-Sync.
2015-04-14 23:03:05 -04:00
/// - `BGFX_RESET_MAXANISOTROPY` - Turn on/off max anisotropy.
2014-10-11 13:12:27 -04:00
/// - `BGFX_RESET_CAPTURE` - Begin screen capture.
2015-04-14 23:03:05 -04:00
/// - `BGFX_RESET_HMD` - HMD stereo rendering.
/// - `BGFX_RESET_HMD_DEBUG` - HMD stereo rendering debug mode.
/// - `BGFX_RESET_HMD_RECENTER` - HMD calibration.
2015-07-26 20:36:06 -04:00
/// - `BGFX_RESET_FLUSH_AFTER_RENDER` - Flush rendering after submitting to GPU.
2015-04-15 14:49:20 -04:00
/// - `BGFX_RESET_FLIP_AFTER_RENDER` - This flag specifies where flip
/// occurs. Default behavior is that flip occurs before rendering new
/// frame. This flag only has effect when `BGFX_CONFIG_MULTITHREADED=0`.
2015-07-26 20:36:06 -04:00
/// - `BGFX_RESET_SRGB_BACKBUFFER` - Enable sRGB backbuffer.
2014-10-11 13:12:27 -04:00
///
/// @attention This call doesn't actually change window size, it just
/// resizes back-buffer. Windowing code has to change window size.
///
2014-10-11 13:12:27 -04:00
/// @attention C99 equivalent is `bgfx_reset`.
///
2012-10-07 23:41:18 -04:00
void reset(uint32_t _width, uint32_t _height, uint32_t _flags = BGFX_RESET_NONE);
/// 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
2014-01-09 01:08:37 -05:00
/// double/multi buffering data outside the library and passing it to
2014-10-11 13:12:27 -04:00
/// library via `bgfx::makeRef` calls.
///
/// @attention C99 equivalent is `bgfx_frame`.
///
uint32_t frame();
2012-10-07 23:41:18 -04:00
/// Returns current renderer backend API type.
///
/// @remarks
/// Library must be initialized.
///
2014-10-11 13:12:27 -04:00
/// @attention C99 equivalent is `bgfx_get_renderer_type`.
///
RendererType::Enum getRendererType();
2013-10-10 21:29:57 -04:00
/// Returns renderer capabilities.
///
2014-10-11 13:12:27 -04:00
/// @returns Pointer to static `bgfx::Caps` structure.
///
/// @remarks
/// Library must be initialized.
///
2014-10-11 13:12:27 -04:00
/// @attention C99 equivalent is `bgfx_get_caps`.
///
2013-10-10 21:29:57 -04:00
const Caps* getCaps();
2014-10-29 01:08:55 -04:00
/// Returns HMD info.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_get_hmd`.
///
2014-10-29 01:08:55 -04:00
const HMD* getHMD();
/// Returns performance counters.
///
const Stats* getStats();
2012-10-07 23:41:18 -04:00
/// Allocate buffer to pass to bgfx calls. Data will be freed inside bgfx.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_alloc`.
///
2012-10-07 23:41:18 -04:00
const Memory* alloc(uint32_t _size);
2014-04-17 01:24:31 -04:00
/// Allocate buffer and copy data into it. Data will be freed inside bgfx.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_copy`.
///
2014-04-17 01:24:31 -04:00
const Memory* copy(const void* _data, uint32_t _size);
2014-10-11 13:12:27 -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
2015-04-01 19:44:44 -04:00
/// can pass `ReleaseFn` function pointer to release this memory after it's
/// consumed, or you must make sure data is available for at least 2
/// `bgfx::frame` calls. `ReleaseFn` function must be able to be called
/// called from any thread.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent are `bgfx_make_ref`, `bgfx_make_ref_release`.
///
2015-04-01 19:44:44 -04:00
const Memory* makeRef(const void* _data, uint32_t _size, ReleaseFn _releaseFn = NULL, void* _userData = NULL);
2012-10-07 23:41:18 -04:00
/// Set debug flags.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _debug Available flags:
/// - `BGFX_DEBUG_IFH` - Infinitely fast hardware. When this flag is set
2012-11-10 22:59:23 -05:00
/// 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
2012-10-07 23:41:18 -04:00
/// primitives will be rendered as lines.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_debug`.
///
2012-10-07 23:41:18 -04:00
void setDebug(uint32_t _debug);
2012-10-28 00:34:41 -04:00
/// Clear internal debug text buffer.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_dbg_text_clear`.
///
2012-10-07 23:41:18 -04:00
void dbgTextClear(uint8_t _attr = 0, bool _small = false);
2012-10-28 00:34:41 -04:00
/// Print into internal debug text buffer.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_dbg_text_printf`.
///
2012-10-07 23:41:18 -04:00
void dbgTextPrintf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ...);
/// Draw image into internal debug text buffer.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _x X position from top-left.
/// @param[in] _y Y position from top-left.
/// @param[in] _width Image width.
/// @param[in] _height Image height.
/// @param[in] _data Raw image data (character/attribute raw encoding).
/// @param[in] _pitch Image pitch in bytes.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_dbg_text_image`.
///
void dbgTextImage(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const void* _data, uint16_t _pitch);
/// Create static index buffer.
2014-05-20 01:08:35 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _mem Index buffer data.
/// @param[in] _flags Buffer creation flags.
2015-04-09 00:15:37 -04:00
/// - `BGFX_BUFFER_NONE` - No flags.
/// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader.
/// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer
/// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU.
/// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader.
/// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if different amount of
/// data is passed. If this flag is not specified if more data is passed on update buffer
/// will be trimmed to fit existing buffer size. This flag has effect only on dynamic
/// buffers.
/// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
/// index buffers.
2014-05-20 01:08:35 -04:00
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_index_buffer`.
///
2015-05-14 14:37:32 -04:00
IndexBufferHandle createIndexBuffer(const Memory* _mem, uint16_t _flags = BGFX_BUFFER_NONE);
2012-10-07 23:41:18 -04:00
/// Destroy static index buffer.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_destroy_index_buffer`.
///
2012-10-07 23:41:18 -04:00
void destroyIndexBuffer(IndexBufferHandle _handle);
/// Create static vertex buffer.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _mem Vertex buffer data.
/// @param[in] _decl Vertex declaration.
2015-07-25 21:19:45 -04:00
/// @param[in] _flags Buffer creation flags.
/// - `BGFX_BUFFER_NONE` - No flags.
/// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader.
/// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer
/// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU.
/// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader.
/// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if different amount of
/// data is passed. If this flag is not specified if more data is passed on update buffer
/// will be trimmed to fit existing buffer size. This flag has effect only on dynamic
/// buffers.
/// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
/// index buffers.
/// @returns Static vertex buffer handle.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_vertex_buffer`.
///
2015-05-14 14:37:32 -04:00
VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint16_t _flags = BGFX_BUFFER_NONE);
2012-10-07 23:41:18 -04:00
/// Destroy static vertex buffer.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _handle Static vertex buffer handle.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_destroy_vertex_buffer`.
///
2012-10-07 23:41:18 -04:00
void destroyVertexBuffer(VertexBufferHandle _handle);
/// Create empty dynamic index buffer.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _num Number of indices.
/// @param[in] _flags Buffer creation flags.
2015-04-09 00:15:37 -04:00
/// - `BGFX_BUFFER_NONE` - No flags.
/// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader.
/// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer
/// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU.
/// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader.
/// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if different amount of
/// data is passed. If this flag is not specified if more data is passed on update buffer
/// will be trimmed to fit existing buffer size. This flag has effect only on dynamic
/// buffers.
/// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
/// index buffers.
2014-05-20 01:08:35 -04:00
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_dynamic_index_buffer`.
///
2015-05-14 14:37:32 -04:00
DynamicIndexBufferHandle createDynamicIndexBuffer(uint32_t _num, uint16_t _flags = BGFX_BUFFER_NONE);
2012-10-07 23:41:18 -04:00
/// Create dynamic index buffer and initialized it.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _mem Index buffer data.
/// @param[in] _flags Buffer creation flags.
2015-04-09 00:15:37 -04:00
/// - `BGFX_BUFFER_NONE` - No flags.
/// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader.
/// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer
/// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU.
/// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader.
/// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if different amount of
/// data is passed. If this flag is not specified if more data is passed on update buffer
/// will be trimmed to fit existing buffer size. This flag has effect only on dynamic
/// buffers.
/// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
/// index buffers.
2014-05-20 01:08:35 -04:00
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_dynamic_index_buffer_mem`.
///
2015-05-14 14:37:32 -04:00
DynamicIndexBufferHandle createDynamicIndexBuffer(const Memory* _mem, uint16_t _flags = BGFX_BUFFER_NONE);
2012-10-07 23:41:18 -04:00
/// Update dynamic index buffer.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _handle Dynamic index buffer handle.
/// @param[in] _startIndex Start index.
/// @param[in] _mem Index buffer data.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_update_dynamic_index_buffer`.
///
void updateDynamicIndexBuffer(DynamicIndexBufferHandle _handle, uint32_t _startIndex, const Memory* _mem);
2012-10-07 23:41:18 -04:00
/// Destroy dynamic index buffer.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _handle Dynamic index buffer handle.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_destroy_dynamic_index_buffer`.
///
2012-10-07 23:41:18 -04:00
void destroyDynamicIndexBuffer(DynamicIndexBufferHandle _handle);
/// Create empty dynamic vertex buffer.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _num Number of vertices.
/// @param[in] _decl Vertex declaration.
/// @param[in] _flags Buffer creation flags.
2015-04-09 00:15:37 -04:00
/// - `BGFX_BUFFER_NONE` - No flags.
/// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader.
/// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer
/// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU.
/// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader.
/// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if different amount of
/// data is passed. If this flag is not specified if more data is passed on update buffer
/// will be trimmed to fit existing buffer size. This flag has effect only on dynamic
/// buffers.
/// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
/// index buffers.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_dynamic_vertex_buffer`.
///
2015-05-14 14:37:32 -04:00
DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexDecl& _decl, uint16_t _flags = BGFX_BUFFER_NONE);
2012-10-07 23:41:18 -04:00
/// Create dynamic vertex buffer and initialize it.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _mem Vertex buffer data.
/// @param[in] _decl Vertex declaration.
/// @param[in] _flags Buffer creation flags.
2015-04-09 00:15:37 -04:00
/// - `BGFX_BUFFER_NONE` - No flags.
/// - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader.
/// - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer
/// is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU.
/// - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader.
/// - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if different amount of
/// data is passed. If this flag is not specified if more data is passed on update buffer
/// will be trimmed to fit existing buffer size. This flag has effect only on dynamic
/// buffers.
/// - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on
/// index buffers.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_dynamic_vertex_buffer_mem`.
///
2015-05-14 14:37:32 -04:00
DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint16_t _flags = BGFX_BUFFER_NONE);
2012-10-07 23:41:18 -04:00
/// Update dynamic vertex buffer.
2015-05-14 23:33:33 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _handle Dynamic vertex buffer handle.
/// @param[in] _startVertex Start vertex.
/// @param[in] _mem Vertex buffer data.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_update_dynamic_vertex_buffer`.
///
void updateDynamicVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _startVertex, const Memory* _mem);
2012-10-07 23:41:18 -04:00
/// Destroy dynamic vertex buffer.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_destroy_dynamic_vertex_buffer`.
///
2012-10-07 23:41:18 -04:00
void destroyDynamicVertexBuffer(DynamicVertexBufferHandle _handle);
2012-11-04 00:36:17 -04:00
/// Returns true if internal transient index buffer has enough space.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _num Number of indices.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_check_avail_transient_index_buffer`.
///
bool checkAvailTransientIndexBuffer(uint32_t _num);
2012-10-07 23:41:18 -04:00
/// Returns true if internal transient vertex buffer has enough space.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _num Number of vertices.
/// @param[in] _decl Vertex declaration.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_check_avail_transient_vertex_buffer`.
///
bool checkAvailTransientVertexBuffer(uint32_t _num, const VertexDecl& _decl);
/// Returns true if internal instance data buffer has enough space.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _num Number of instances.
/// @param[in] _stride Stride per instance.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_check_avail_instance_data_buffer`.
///
bool checkAvailInstanceDataBuffer(uint32_t _num, uint16_t _stride);
/// Returns true if both internal transient index and vertex buffer have
/// enough space.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _numVertices Number of vertices.
/// @param[in] _decl Vertex declaration.
/// @param[in] _numIndices Number of indices.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_check_avail_transient_buffers`.
///
bool checkAvailTransientBuffers(uint32_t _numVertices, const VertexDecl& _decl, uint32_t _numIndices);
2012-11-10 22:59:23 -05:00
/// Allocate transient index buffer.
2012-10-07 23:41:18 -04:00
///
2013-07-14 17:32:09 -04:00
/// @param[out] _tib TransientIndexBuffer structure is filled and is valid
/// for the duration of frame, and it can be reused for multiple draw
/// calls.
2015-07-10 21:59:28 -04:00
/// @param[in] _num Number of indices to allocate.
///
/// @remarks
2014-05-20 01:08:35 -04:00
/// 1. You must call setIndexBuffer after alloc in order to avoid memory
/// leak.
/// 2. Only 16-bit index buffer is supported.
2013-07-29 22:01:29 -04:00
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_alloc_transient_index_buffer`.
///
void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint32_t _num);
2012-10-07 23:41:18 -04:00
2012-11-10 22:59:23 -05:00
/// Allocate transient vertex buffer.
2012-10-07 23:41:18 -04:00
///
2013-07-14 17:32:09 -04:00
/// @param[out] _tvb TransientVertexBuffer structure is filled and is valid
/// for the duration of frame, and it can be reused for multiple draw
/// calls.
2015-07-10 21:59:28 -04:00
/// @param[in] _num Number of vertices to allocate.
/// @param[in] _decl Vertex declaration.
///
/// @remarks
2013-07-29 22:01:29 -04:00
/// You must call setVertexBuffer after alloc in order to avoid memory
/// leak.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_alloc_transient_vertex_buffer`.
///
void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexDecl& _decl);
2012-10-07 23:41:18 -04:00
2014-05-20 01:08:35 -04:00
/// Check for required space and allocate transient vertex and index
/// buffers. If both space requirements are satisfied function returns
/// true.
///
/// @remarks
2014-05-20 01:08:35 -04:00
/// Only 16-bit index buffer is supported.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_alloc_transient_buffers`.
///
bool allocTransientBuffers(TransientVertexBuffer* _tvb, const VertexDecl& _decl, uint32_t _numVertices, TransientIndexBuffer* _tib, uint32_t _numIndices);
2014-05-20 01:08:35 -04:00
/// Allocate instance data buffer.
2013-07-29 22:01:29 -04:00
///
/// @remarks
2013-07-29 22:01:29 -04:00
/// You must call setInstanceDataBuffer after alloc in order to avoid
/// memory leak.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_alloc_instance_data_buffer`.
///
const InstanceDataBuffer* allocInstanceDataBuffer(uint32_t _num, uint16_t _stride);
2012-10-07 23:41:18 -04:00
2015-05-14 23:33:33 -04:00
/// Create draw indirect buffer.
///
/// @attention C99 equivalent is `bgfx_create_indirect_buffer`.
2015-04-29 20:18:51 -04:00
///
2015-05-01 17:54:23 -04:00
IndirectBufferHandle createIndirectBuffer(uint32_t _num);
2015-04-29 20:18:51 -04:00
2015-05-14 23:33:33 -04:00
/// Destroy draw indirect buffer.
///
/// @attention C99 equivalent is `bgfx_destroy_indirect_buffer`.
2015-04-29 20:18:51 -04:00
///
2015-05-01 17:54:23 -04:00
void destroyIndirectBuffer(IndirectBufferHandle _handle);
2015-04-29 20:18:51 -04:00
/// Create shader from memory buffer.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_create_shader`.
///
ShaderHandle createShader(const Memory* _mem);
2012-10-07 23:41:18 -04:00
/// Returns num of uniforms, and uniform handles used inside shader.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _handle Shader handle.
/// @param[in] _uniforms UniformHandle array where data will be stored.
/// @param[in] _max Maximum capacity of array.
/// @returns Number of uniforms used by shader.
///
/// @remarks
/// Only non-predefined uniforms are returned.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_get_shader_uniforms`.
///
uint16_t getShaderUniforms(ShaderHandle _handle, UniformHandle* _uniforms = NULL, uint16_t _max = 0);
/// Destroy shader. Once program is created with shader it is safe to
/// destroy shader.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_destroy_shader`.
///
void destroyShader(ShaderHandle _handle);
2012-10-07 23:41:18 -04:00
2012-11-04 00:36:17 -04:00
/// Create program with vertex and fragment shaders.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _vsh Vertex shader.
/// @param[in] _fsh Fragment shader.
/// @param[in] _destroyShaders If true, shaders will be destroyed when
/// program is destroyed.
/// @returns Program handle if vertex shader output and fragment shader
2013-02-16 14:51:36 -05:00
/// input are matching, otherwise returns invalid program handle.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_program`.
///
ProgramHandle createProgram(ShaderHandle _vsh, ShaderHandle _fsh, bool _destroyShaders = false);
2012-10-07 23:41:18 -04:00
2014-12-16 23:12:09 -05:00
/// Create program with compute shader.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _csh Compute shader.
/// @param[in] _destroyShader If true, shader will be destroyed when
2014-12-16 23:12:09 -05:00
/// program is destroyed.
/// @returns Program handle.
///
2015-05-16 19:07:10 -04:00
/// @attention C99 equivalent is `bgfx_create_compute_program`.
2015-05-14 23:33:33 -04:00
///
2014-12-16 23:12:09 -05:00
ProgramHandle createProgram(ShaderHandle _csh, bool _destroyShader = false);
2012-11-04 00:36:17 -04:00
/// Destroy program.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_destroy_program`.
///
2012-10-07 23:41:18 -04:00
void destroyProgram(ProgramHandle _handle);
2013-01-05 02:52:37 -05:00
/// Calculate amount of memory required for texture.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_calc_texture_size`.
///
void calcTextureSize(TextureInfo& _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, uint8_t _numMips, TextureFormat::Enum _format);
2013-01-05 02:52:37 -05:00
2013-02-16 18:38:52 -05:00
/// Create texture from memory buffer.
2013-04-28 15:47:20 -04:00
///
/// @param[in] _mem DDS, KTX or PVR texture data.
/// @param[in] _flags Default texture sampling mode is linear, and wrap mode
2013-02-16 18:38:52 -05:00
/// is repeat.
/// - `BGFX_TEXTURE_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
2013-02-16 18:38:52 -05:00
/// mode.
/// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
2013-02-16 18:38:52 -05:00
/// sampling.
///
/// @param[in] _skip Skip top level mips when parsing texture.
/// @param[out] _info When non-`NULL` is specified it returns parsed texture information.
2013-02-16 18:38:52 -05:00
/// @returns Texture handle.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_texture`.
///
TextureHandle createTexture(const Memory* _mem, uint32_t _flags = BGFX_TEXTURE_NONE, uint8_t _skip = 0, TextureInfo* _info = NULL);
2012-10-07 23:41:18 -04:00
/// Create 2D texture.
///
2015-07-07 00:27:54 -04:00
/// @param[in] _width Width.
/// @param[in] _height Height.
/// @param[in] _numMips Number of mip-maps.
/// @param[in] _format Texture format. See: `TextureFormat::Enum`.
/// @param[in] _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[in] _mem Texture data.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_texture_2d`.
///
2012-08-13 00:02:11 -04:00
TextureHandle createTexture2D(uint16_t _width, uint16_t _height, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags = BGFX_TEXTURE_NONE, const Memory* _mem = NULL);
2012-10-07 23:41:18 -04:00
2015-07-25 21:19:45 -04:00
/// Create frame buffer with size based on backbuffer ratio. Frame buffer will maintain ratio
/// if back buffer resolution changes.
///
/// @param[in] _ratio Frame buffer size in respect to back-buffer size. See:
/// `BackbufferRatio::Enum`.
/// @param[in] _numMips Number of mip-maps.
/// @param[in] _format Texture format. See: `TextureFormat::Enum`.
/// @param[in] _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.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_create_texture_2d_scaled`.
///
TextureHandle createTexture2D(BackbufferRatio::Enum _ratio, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags = BGFX_TEXTURE_NONE);
/// Create 3D texture.
///
2015-07-07 00:27:54 -04:00
/// @param[in] _width Width.
/// @param[in] _height Height.
/// @param[in] _depth Depth.
/// @param[in] _numMips Number of mip-maps.
/// @param[in] _format Texture format. See: `TextureFormat::Enum`.
/// @param[in] _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[in] _mem Texture data.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_texture_3d`.
///
2012-08-13 00:02:11 -04:00
TextureHandle createTexture3D(uint16_t _width, uint16_t _height, uint16_t _depth, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags = BGFX_TEXTURE_NONE, const Memory* _mem = NULL);
2012-10-07 23:41:18 -04:00
/// Create Cube texture.
///
2015-07-07 00:27:54 -04:00
/// @param[in] _size Cube side size.
/// @param[in] _numMips Number of mip-maps.
/// @param[in] _format Texture format. See: `TextureFormat::Enum`.
/// @param[in] _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[in] _mem Texture data.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_texture_cube`.
///
TextureHandle createTextureCube(uint16_t _size, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags = BGFX_TEXTURE_NONE, const Memory* _mem = NULL);
2012-10-07 23:41:18 -04:00
/// Update 2D texture.
///
2015-07-07 00:27:54 -04:00
/// @param[in] _handle Texture handle.
/// @param[in] _mip Mip level.
/// @param[in] _x X offset in texture.
/// @param[in] _y Y offset in texture.
/// @param[in] _width Width of texture block.
/// @param[in] _height Height of texture block.
/// @param[in] _mem Texture update data.
/// @param[in] _pitch Pitch of input image (bytes). When _pitch is set to
/// UINT16_MAX, it will be calculated internally based on _width.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_update_texture_2d`.
///
void updateTexture2D(TextureHandle _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem, uint16_t _pitch = UINT16_MAX);
2012-10-07 23:41:18 -04:00
/// Update 3D texture.
///
2015-07-07 00:27:54 -04:00
/// @param[in] _handle Texture handle.
/// @param[in] _mip Mip level.
/// @param[in] _x X offset in texture.
/// @param[in] _y Y offset in texture.
/// @param[in] _z Z offset in texture.
/// @param[in] _width Width of texture block.
/// @param[in] _height Height of texture block.
/// @param[in] _depth Depth of texture block.
/// @param[in] _mem Texture update data.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_update_texture_3d`.
///
2012-10-07 23:41:18 -04:00
void updateTexture3D(TextureHandle _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const Memory* _mem);
/// Update Cube texture.
///
2015-07-07 00:27:54 -04:00
/// @param[in] _handle Texture handle.
/// @param[in] _side Cubemap side, where 0 is +X, 1 is -X, 2 is +Y, 3 is
2013-04-04 12:51:42 -04:00
/// -Y, 4 is +Z, and 5 is -Z.
///
2015-07-26 12:16:36 -04:00
/// +----------+
/// |-z 2|
/// | ^ +y |
/// | | |
/// | +---->+x |
/// +----------+----------+----------+----------+
/// |+y 1|+y 4|+y 0|+y 5|
/// | ^ -x | ^ +z | ^ +x | ^ -z |
/// | | | | | | | | |
/// | +---->+z | +---->+x | +---->-z | +---->-x |
/// +----------+----------+----------+----------+
/// |+z 3|
/// | ^ -y |
/// | | |
/// | +---->+x |
/// +----------+
2013-08-27 01:38:53 -04:00
///
2015-07-07 00:27:54 -04:00
/// @param[in] _mip Mip level.
/// @param[in] _x X offset in texture.
/// @param[in] _y Y offset in texture.
/// @param[in] _width Width of texture block.
/// @param[in] _height Height of texture block.
/// @param[in] _mem Texture update data.
/// @param[in] _pitch Pitch of input image (bytes). When _pitch is set to
/// UINT16_MAX, it will be calculated internally based on _width.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_update_texture_cube`.
///
void updateTextureCube(TextureHandle _handle, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem, uint16_t _pitch = UINT16_MAX);
2012-10-07 23:41:18 -04:00
/// Destroy texture.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_destroy_texture`.
///
2012-10-07 23:41:18 -04:00
void destroyTexture(TextureHandle _handle);
2014-02-06 02:07:11 -05:00
/// Create frame buffer (simple).
///
2015-07-07 00:27:54 -04:00
/// @param[in] _width Texture width.
/// @param[in] _height Texture height.
/// @param[in] _format Texture format. See: `TextureFormat::Enum`.
2015-07-25 21:21:34 -04:00
/// @param[in] _textureFlags Default texture sampling mode is linear, and wrap mode
2015-07-07 00:27:54 -04:00
/// 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.
2014-02-06 02:07:11 -05:00
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_frame_buffer`.
///
2014-02-06 02:07:11 -05:00
FrameBufferHandle createFrameBuffer(uint16_t _width, uint16_t _height, TextureFormat::Enum _format, uint32_t _textureFlags = BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
2015-07-07 00:27:54 -04:00
/// Create frame buffer with size based on backbuffer ratio. Frame buffer will maintain ratio
/// if back buffer resolution changes.
2015-05-14 23:33:33 -04:00
///
2015-07-25 21:19:45 -04:00
/// @param[in] _ratio Frame buffer size in respect to back-buffer size. See:
/// `BackbufferRatio::Enum`.
/// @param[in] _format Texture format. See: `TextureFormat::Enum`.
2015-07-25 21:21:34 -04:00
/// @param[in] _textureFlags Default texture sampling mode is linear, and wrap mode
2015-07-25 21:19:45 -04:00
/// 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.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_frame_buffer_scaled`.
///
FrameBufferHandle createFrameBuffer(BackbufferRatio::Enum _ratio, TextureFormat::Enum _format, uint32_t _textureFlags = BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
2014-02-06 02:07:11 -05:00
/// Create frame buffer.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _num Number of texture attachments.
/// @param[in] _handles Texture attachments.
/// @param[in] _destroyTextures If true, textures will be destroyed when
/// frame buffer is destroyed.
2014-02-06 02:07:11 -05:00
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_frame_buffer_from_handles`.
///
2014-02-06 02:07:11 -05:00
FrameBufferHandle createFrameBuffer(uint8_t _num, TextureHandle* _handles, bool _destroyTextures = false);
2012-10-07 23:41:18 -04:00
2014-09-07 21:31:45 -04:00
/// Create frame buffer for multiple window rendering.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _nwh OS' target native window handle.
/// @param[in] _width Window back buffer width.
/// @param[in] _height Window back buffer height.
/// @param[in] _depthFormat Window back buffer depth format.
2014-09-07 21:31:45 -04:00
///
2014-10-11 17:08:43 -04:00
/// @returns Handle to frame buffer object.
///
/// @remarks
2014-09-07 21:33:38 -04:00
/// Frame buffer cannnot be used for sampling.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_frame_buffer_from_nwh`.
///
2014-09-07 20:17:38 -04:00
FrameBufferHandle createFrameBuffer(void* _nwh, uint16_t _width, uint16_t _height, TextureFormat::Enum _depthFormat = TextureFormat::UnknownDepth);
2014-02-06 02:07:11 -05:00
/// Destroy frame buffer.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_destroy_frame_buffer`.
///
2014-02-06 02:07:11 -05:00
void destroyFrameBuffer(FrameBufferHandle _handle);
2012-10-07 23:41:18 -04:00
/// Create shader uniform parameter.
2013-09-29 13:42:41 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _name Uniform name in shader.
/// @param[in] _type Type of uniform (See: `bgfx::UniformType`).
/// @param[in] _num Number of elements in array.
2013-09-29 13:42:41 -04:00
///
2014-10-11 17:08:43 -04:00
/// @returns Handle to uniform object.
2013-09-29 13:42:41 -04:00
///
2014-10-11 17:08:43 -04:00
/// @remarks
/// Predefined uniforms (declared in `bgfx_shader.sh`):
/// - `u_viewRect vec4(x, y, width, height)` - view rectangle for current
/// view.
2014-10-11 17:08:43 -04:00
/// - `u_viewTexel vec4(1.0/width, 1.0/height, undef, undef)` - inverse
/// width and height
2014-10-11 17:08:43 -04:00
/// - `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.
2014-10-11 17:08:43 -04:00
/// - `u_modelViewProj mat4` - concatenated model view projection matrix.
/// - `u_alphaRef float` - alpha reference value for alpha test.
2013-09-29 13:42:41 -04:00
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_create_uniform`.
///
2012-10-28 00:34:41 -04:00
UniformHandle createUniform(const char* _name, UniformType::Enum _type, uint16_t _num = 1);
2012-10-07 23:41:18 -04:00
/// Destroy shader uniform parameter.
2014-10-11 17:08:43 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _handle Handle to uniform object.
2014-10-11 17:08:43 -04:00
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_destroy_uniform`.
///
2012-10-07 23:41:18 -04:00
void destroyUniform(UniformHandle _handle);
2014-09-01 14:24:51 -04:00
/// Set clear color palette value.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _index Index into palette.
/// @param[in] _rgba Packed 32-bit RGBA value.
2014-09-01 14:24:51 -04:00
///
2015-06-27 19:47:07 -04:00
/// @attention C99 equivalent is `bgfx_set_clear_color`.
2015-05-14 23:33:33 -04:00
///
2014-09-01 14:24:51 -04:00
void setClearColor(uint8_t _index, uint32_t _rgba);
/// Set clear color palette value.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _index Index into palette.
/// @param[in] _r, _g, _b, _a RGBA floating point values.
2014-09-01 14:24:51 -04:00
///
2015-06-27 19:47:07 -04:00
/// @attention C99 equivalent is `bgfx_set_clear_color`.
2015-05-14 23:33:33 -04:00
///
2014-09-01 14:24:51 -04:00
void setClearColor(uint8_t _index, float _r, float _g, float _b, float _a);
/// Set clear color palette value.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _index Index into palette.
/// @param[in] _rgba RGBA floating point value.
2014-09-01 14:24:51 -04:00
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_clear_color`.
///
2014-09-01 14:24:51 -04:00
void setClearColor(uint8_t _index, const float _rgba[4]);
/// Set view name.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _id View id.
/// @param[in] _name View name.
///
/// @remarks
/// This is debug only feature.
///
2015-04-02 14:57:53 -04:00
/// In graphics debugger view name will appear as:
///
/// "nnnce <view name>"
/// ^ ^^ ^
/// | |+-- eye (L/R)
/// | +-- compute (C)
/// +-- view id
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_view_name`.
///
void setViewName(uint8_t _id, const char* _name);
2012-10-28 00:34:41 -04:00
/// Set view rectangle. Draw primitive outside view will be clipped.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _id View id.
/// @param[in] _x Position x from the left corner of the window.
/// @param[in] _y Position y from the top corner of the window.
/// @param[in] _width Width of view port region.
/// @param[in] _height Height of view port region.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_view_rect`.
///
2012-10-07 23:41:18 -04:00
void setViewRect(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
2013-07-14 17:32:09 -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.
///
2015-07-25 21:19:45 -04:00
/// @param[in] _id View id.
2015-07-10 21:59:28 -04:00
/// @param[in] _x Position x from the left corner of the window.
/// @param[in] _y Position y from the top corner of the window.
/// @param[in] _width Width of scissor region.
/// @param[in] _height Height of scissor region.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_view_scissor`.
///
2013-07-14 17:32:09 -04:00
void setViewScissor(uint8_t _id, uint16_t _x = 0, uint16_t _y = 0, uint16_t _width = 0, uint16_t _height = 0);
2012-10-28 00:34:41 -04:00
/// Set view clear flags.
2012-11-11 00:18:50 -05:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _id View id.
/// @param[in] _flags Clear flags. Use `BGFX_CLEAR_NONE` to remove any clear
/// operation. See: `BGFX_CLEAR_*`.
2015-07-10 21:59:28 -04:00
/// @param[in] _rgba Color clear value.
/// @param[in] _depth Depth clear value.
/// @param[in] _stencil Stencil clear value.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_view_clear`.
///
void setViewClear(uint8_t _id, uint16_t _flags, uint32_t _rgba = 0x000000ff, float _depth = 1.0f, uint8_t _stencil = 0);
2012-10-07 23:41:18 -04:00
2014-09-01 14:24:51 -04:00
/// Set view clear flags with different clear color for each
/// frame buffer texture. Must use setClearColor to setup clear color
/// palette.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _id View id.
/// @param[in] _flags Clear flags. Use `BGFX_CLEAR_NONE` to remove any clear
/// operation. See: `BGFX_CLEAR_*`.
2015-07-10 21:59:28 -04:00
/// @param[in] _depth Depth clear value.
/// @param[in] _stencil Stencil clear value.
2015-07-25 21:19:45 -04:00
/// @param[in] _0 Palette index for frame buffer attachment 0.
/// @param[in] _1 Palette index for frame buffer attachment 1.
/// @param[in] _2 Palette index for frame buffer attachment 2.
/// @param[in] _3 Palette index for frame buffer attachment 3.
/// @param[in] _4 Palette index for frame buffer attachment 4.
/// @param[in] _5 Palette index for frame buffer attachment 5.
/// @param[in] _6 Palette index for frame buffer attachment 6.
/// @param[in] _7 Palette index for frame buffer attachment 7.
2014-09-01 14:24:51 -04:00
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_view_clear_mrt`.
///
void setViewClear(uint8_t _id, uint16_t _flags, float _depth, uint8_t _stencil, uint8_t _0 = UINT8_MAX, uint8_t _1 = UINT8_MAX, uint8_t _2 = UINT8_MAX, uint8_t _3 = UINT8_MAX, uint8_t _4 = UINT8_MAX, uint8_t _5 = UINT8_MAX, uint8_t _6 = UINT8_MAX, uint8_t _7 = UINT8_MAX);
2014-09-01 14:24:51 -04:00
2012-10-28 00:34:41 -04:00
/// Set view into sequential mode. Draw calls will be sorted in the same
/// order in which submit calls were called.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_set_view_seq`.
///
2012-10-07 23:41:18 -04:00
void setViewSeq(uint8_t _id, bool _enabled);
2014-02-06 02:07:11 -05:00
/// Set view frame buffer.
2013-07-07 14:59:43 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _id View id.
/// @param[in] _handle Frame buffer handle. Passing `BGFX_INVALID_HANDLE` as
2014-02-06 02:07:11 -05:00
/// frame buffer handle will draw primitives from this view into
/// default back buffer.
2013-07-07 14:59:43 -04:00
///
/// @remarks
/// Not persistent after `bgfx::reset` call.
2014-09-07 20:17:38 -04:00
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_view_frame_buffer`.
///
2014-02-06 02:07:11 -05:00
void setViewFrameBuffer(uint8_t _id, FrameBufferHandle _handle);
2012-10-07 23:41:18 -04:00
2012-10-28 00:34:41 -04:00
/// Set view view and projection matrices, all draw primitives in this
/// view will use these matrices.
2015-04-29 23:20:19 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _id View id.
/// @param[in] _view View matrix.
/// @param[in] _projL Projection matrix. When using stereo rendering this projection matrix
2015-04-29 23:20:19 -04:00
/// represent projection matrix for left eye.
2015-07-10 21:59:28 -04:00
/// @param[in] _flags View flags. Use
2015-04-29 23:20:19 -04:00
/// - `BGFX_VIEW_NONE` - View will be rendered only once if stereo mode is enabled.
/// - `BGFX_VIEW_STEREO` - View will be rendered for both eyes if stereo mode is enabled. When
/// stereo mode is disabled this flag doesn't have effect.
2015-07-10 21:59:28 -04:00
/// @param[in] _projR Projection matrix for right eye in stereo mode.
2015-04-29 23:20:19 -04:00
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent are `bgfx_set_view_transform`, `bgfx_set_view_transform_stereo`.
///
2014-10-29 01:08:55 -04:00
void setViewTransform(uint8_t _id, const void* _view, const void* _projL, uint8_t _flags = BGFX_VIEW_STEREO, const void* _projR = NULL);
2012-10-07 23:41:18 -04:00
/// Post submit view reordering.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _id First view id.
/// @param[in] _num Number of views to remap.
/// @param[in] _remap View remap id table. Passing `NULL` will reset view ids
/// to default state.
///
2015-06-27 19:47:07 -04:00
/// @attention C99 equivalent is `bgfx_set_view_remap`.
2015-05-14 23:33:33 -04:00
///
void setViewRemap(uint8_t _id = 0, uint8_t _num = UINT8_MAX, const void* _remap = NULL);
/// Sets debug marker.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_set_marker`.
///
void setMarker(const char* _marker);
2012-10-28 00:34:41 -04:00
/// Set render states for draw primitive.
2013-04-28 15:47:20 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _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 remark 1 about BGFX_STATE_BLEND_FUNC.
/// - `BGFX_STATE_BLEND_EQUATION_*` - See remark 2.
/// - `BGFX_STATE_CULL_*` - Backface culling mode.
/// - `BGFX_STATE_RGB_WRITE` - Enable RGB write.
/// - `BGFX_STATE_MSAA` - Enable MSAA.
/// - `BGFX_STATE_PT_[TRISTRIP/LINES/POINTS]` - Primitive type.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _rgba Sets blend factor used by `BGFX_STATE_BLEND_FACTOR` and
/// `BGFX_STATE_BLEND_INV_FACTOR` blend modes.
///
/// @remarks
/// 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
2013-06-18 01:11:45 -04:00
/// equation is specified.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_state`.
///
void setState(uint64_t _state, uint32_t _rgba = 0);
2012-10-07 23:41:18 -04:00
2012-11-10 22:59:23 -05:00
/// Set stencil test state.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _fstencil Front stencil state.
/// @param[in] _bstencil Back stencil state. If back is set to `BGFX_STENCIL_NONE`
2013-02-16 14:51:36 -05:00
/// _fstencil is applied to both front and back facing primitives.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_stencil`.
///
2012-11-10 22:59:23 -05:00
void setStencil(uint32_t _fstencil, uint32_t _bstencil = BGFX_STENCIL_NONE);
/// Set scissor for draw primitive. For scissor for all primitives in
2015-07-26 14:07:04 -04:00
/// view see `bgfx::setViewScissor`.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _x Position x from the left corner of the window.
/// @param[in] _y Position y from the top corner of the window.
/// @param[in] _width Width of scissor region.
/// @param[in] _height Height of scissor region.
/// @returns Scissor cache index.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_scissor`.
///
2013-07-14 17:32:09 -04:00
uint16_t setScissor(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
/// Set scissor from cache for draw primitive.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _cache Index in scissor cache. Passing UINT16_MAX unset primitive
/// scissor and primitive will use view scissor instead.
2013-07-14 17:32:09 -04:00
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_scissor_cached`.
///
void setScissor(uint16_t _cache = UINT16_MAX);
2013-07-14 17:32:09 -04:00
2012-10-28 00:34:41 -04:00
/// Set model matrix for draw primitive. If it is not called model will
/// be rendered with identity model matrix.
2012-10-07 23:41:18 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _mtx Pointer to first matrix in array.
/// @param[in] _num Number of matrices in array.
2013-04-04 12:51:42 -04:00
/// @returns index into matrix cache in case the same model matrix has
/// to be used for other draw primitive call.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_transform`.
///
2012-10-07 23:41:18 -04:00
uint32_t setTransform(const void* _mtx, uint16_t _num = 1);
2014-10-08 23:18:37 -04:00
/// Reserve `_num` matrices in internal matrix cache. Pointer returned
/// can be modifed until `bgfx::frame` is called.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _transform Pointer to `Transform` structure.
/// @param[in] _num Number of matrices.
2014-10-11 13:12:27 -04:00
/// @returns index into matrix cache.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_alloc_transform`.
///
2014-10-11 13:12:27 -04:00
uint32_t allocTransform(Transform* _transform, uint16_t _num);
2014-10-11 13:12:27 -04:00
/// Set model matrix from matrix cache for draw primitive.
2014-10-08 23:18:37 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _cache Index in matrix cache.
/// @param[in] _num Number of matrices from cache.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_transform_cached`.
///
2014-10-11 13:12:27 -04:00
void setTransform(uint32_t _cache, uint16_t _num = 1);
/// Set shader uniform parameter for draw primitive.
2015-05-14 23:33:33 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _handle Uniform.
/// @param[in] _value Pointer to uniform data.
/// @param[in] _num Number of elements.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_uniform`.
///
2012-10-07 23:41:18 -04:00
void setUniform(UniformHandle _handle, const void* _value, uint16_t _num = 1);
/// Set index buffer for draw primitive.
2015-05-14 23:33:33 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _handle Index buffer.
/// @param[in] _firstIndex First index to render.
/// @param[in] _numIndices Number of indices to render.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_index_buffer`.
///
2012-12-28 20:09:34 -05:00
void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex = 0, uint32_t _numIndices = UINT32_MAX);
2012-10-07 23:41:18 -04:00
/// Set index buffer for draw primitive.
2015-05-14 23:33:33 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _handle Dynamic index buffer.
/// @param[in] _firstIndex First index to render.
/// @param[in] _numIndices Number of indices to render.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_dynamic_index_buffer`.
///
2012-12-28 20:09:34 -05:00
void setIndexBuffer(DynamicIndexBufferHandle _handle, uint32_t _firstIndex = 0, uint32_t _numIndices = UINT32_MAX);
2012-10-07 23:41:18 -04:00
/// Set index buffer for draw primitive.
2015-05-14 23:33:33 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _tib Transient index buffer.
///
2015-06-27 19:47:07 -04:00
/// @attention C99 equivalent is `bgfx_set_transient_index_buffer`.
2015-05-14 23:33:33 -04:00
///
2014-04-27 02:48:41 -04:00
void setIndexBuffer(const TransientIndexBuffer* _tib);
/// Set index buffer for draw primitive.
2015-05-14 23:33:33 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _tib Transient index buffer.
/// @param[in] _firstIndex First index to render.
/// @param[in] _numIndices Number of indices to render.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_transient_index_buffer`.
///
2014-04-27 02:48:41 -04:00
void setIndexBuffer(const TransientIndexBuffer* _tib, uint32_t _firstIndex, uint32_t _numIndices);
2012-10-07 23:41:18 -04:00
/// Set vertex buffer for draw primitive.
2015-05-14 23:33:33 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _handle Vertex buffer.
///
2015-06-27 19:47:07 -04:00
/// @attention C99 equivalent is `bgfx_set_vertex_buffer`.
2015-05-14 23:33:33 -04:00
///
2014-04-17 01:11:14 -04:00
void setVertexBuffer(VertexBufferHandle _handle);
/// Set vertex buffer for draw primitive.
2015-05-14 23:33:33 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _handle Vertex buffer.
/// @param[in] _startVertex First vertex to render.
/// @param[in] _numVertices Number of vertices to render.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_vertex_buffer`.
///
2014-04-17 01:11:14 -04:00
void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices);
2012-10-07 23:41:18 -04:00
/// Set vertex buffer for draw primitive.
2015-05-14 23:33:33 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _handle Dynamic vertex buffer.
/// @param[in] _numVertices Number of vertices to render.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_dynamic_vertex_buffer`.
///
2012-10-07 23:41:18 -04:00
void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices = UINT32_MAX);
/// Set vertex buffer for draw primitive.
2015-05-14 23:33:33 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _tvb Transient vertex buffer.
///
2015-06-27 19:47:07 -04:00
/// @attention C99 equivalent is `bgfx_set_transient_vertex_buffer`.
2015-05-14 23:33:33 -04:00
///
2014-04-27 02:48:41 -04:00
void setVertexBuffer(const TransientVertexBuffer* _tvb);
/// Set vertex buffer for draw primitive.
2015-05-14 23:33:33 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _tvb Transient vertex buffer.
/// @param[in] _startVertex First vertex to render.
/// @param[in] _numVertices Number of vertices to render.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_transient_vertex_buffer`.
///
2014-04-27 02:48:41 -04:00
void setVertexBuffer(const TransientVertexBuffer* _tvb, uint32_t _startVertex, uint32_t _numVertices);
2012-10-07 23:41:18 -04:00
/// Set instance data buffer for draw primitive.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_set_instance_data_buffer`.
///
2014-12-10 02:16:27 -05:00
void setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint32_t _num = UINT32_MAX);
/// Set instance data buffer for draw primitive.
2015-05-14 23:33:33 -04:00
///
2015-05-16 19:07:10 -04:00
/// @attention C99 equivalent is `bgfx_set_instance_data_from_vertex_buffer`.
2015-05-14 23:33:33 -04:00
///
2015-01-29 22:54:23 -05:00
void setInstanceDataBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num);
2014-12-10 02:16:27 -05:00
/// Set instance data buffer for draw primitive.
2015-05-14 23:33:33 -04:00
///
2015-05-16 19:07:10 -04:00
/// @attention C99 equivalent is `bgfx_set_instance_data_from_dynamic_vertex_buffer`.
2015-05-14 23:33:33 -04:00
///
2015-01-29 22:54:23 -05:00
void setInstanceDataBuffer(DynamicVertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num);
2012-10-07 23:41:18 -04:00
/// Set texture stage for draw primitive.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _stage Texture unit.
/// @param[in] _sampler Program sampler.
/// @param[in] _handle Texture handle.
/// @param[in] _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.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _flags Texture sampler filtering flags. UINT32_MAX use the
/// sampler filtering mode set by texture.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_texture`.
///
void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint32_t _flags = UINT32_MAX);
2012-10-07 23:41:18 -04:00
/// Set texture stage for draw primitive.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _stage Texture unit.
/// @param[in] _sampler Program sampler.
/// @param[in] _handle Frame buffer handle.
/// @param[in] _attachment Attachment index.
/// @param[in] _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.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_texture_from_frame_buffer`.
///
2014-02-06 02:07:11 -05:00
void setTexture(uint8_t _stage, UniformHandle _sampler, FrameBufferHandle _handle, uint8_t _attachment = 0, uint32_t _flags = UINT32_MAX);
2012-10-07 23:41:18 -04:00
/// Touch view.
uint32_t touch(uint8_t _id);
2015-05-14 23:33:33 -04:00
/// Submit primitive for rendering.
2012-11-11 00:18:50 -05:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _id View id.
/// @param[in] _handle Program.
2015-07-10 21:59:28 -04:00
/// @param[in] _depth Depth for sorting.
/// @returns Number of draw calls.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_submit`.
///
uint32_t submit(uint8_t _id, ProgramHandle _handle, int32_t _depth = 0);
2012-10-07 23:41:18 -04:00
2015-05-14 23:33:33 -04:00
/// Submit primitive for rendering with index and instance data info from
/// indirect buffer.
///
/// @param[in] _id View id.
/// @param[in] _handle Program.
/// @param[in] _indirectHandle Indirect buffer.
/// @param[in] _start First element in indirect buffer.
/// @param[in] _num Number of dispatches.
/// @param[in] _depth Depth for sorting.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_submit_indirect`.
2015-05-01 17:54:23 -04:00
///
uint32_t submit(uint8_t _id, ProgramHandle _handle, IndirectBufferHandle _indirectHandle, uint16_t _start = 0, uint16_t _num = 1, int32_t _depth = 0);
2015-05-01 17:54:23 -04:00
2015-07-08 01:53:27 -04:00
/// Set compute index buffer.
2015-05-14 23:33:33 -04:00
///
2015-07-10 00:52:19 -04:00
/// @param[in] _stage Compute stage.
/// @param[in] _handle Index buffer handle.
/// @param[in] _access Buffer access. See `Access::Enum`.
///
2015-05-16 19:07:10 -04:00
/// @attention C99 equivalent is `bgfx_set_compute_index_buffer`.
///
void setBuffer(uint8_t _stage, IndexBufferHandle _handle, Access::Enum _access);
2015-07-08 01:53:27 -04:00
/// Set compute vertex buffer.
2015-05-14 23:33:33 -04:00
///
2015-07-10 00:52:19 -04:00
/// @param[in] _stage Compute stage.
/// @param[in] _handle Vertex buffer handle.
/// @param[in] _access Buffer access. See `Access::Enum`.
///
2015-05-16 19:07:10 -04:00
/// @attention C99 equivalent is `bgfx_set_compute_vertex_buffer`.
2014-12-10 02:16:27 -05:00
///
void setBuffer(uint8_t _stage, VertexBufferHandle _handle, Access::Enum _access);
2015-07-08 01:53:27 -04:00
/// Set compute dynamic index buffer.
2015-05-14 23:33:33 -04:00
///
2015-07-10 00:52:19 -04:00
/// @param[in] _stage Compute stage.
/// @param[in] _handle Dynamic index buffer handle.
/// @param[in] _access Buffer access. See `Access::Enum`.
///
2015-05-16 19:07:10 -04:00
/// @attention C99 equivalent is `bgfx_set_compute_dynamic_index_buffer`.
///
void setBuffer(uint8_t _stage, DynamicIndexBufferHandle _handle, Access::Enum _access);
2015-07-08 01:53:27 -04:00
/// Set compute dynamic vertex buffer.
2015-05-14 23:33:33 -04:00
///
2015-07-10 00:52:19 -04:00
/// @param[in] _stage Compute stage.
/// @param[in] _handle Dynamic vertex buffer handle.
/// @param[in] _access Buffer access. See `Access::Enum`.
///
2015-05-16 19:07:10 -04:00
/// @attention C99 equivalent is `bgfx_set_compute_dynamic_vertex_buffer`.
2014-12-10 02:16:27 -05:00
///
void setBuffer(uint8_t _stage, DynamicVertexBufferHandle _handle, Access::Enum _access);
2015-07-08 01:53:27 -04:00
/// Set compute indirect buffer.
2015-05-14 23:33:33 -04:00
///
2015-07-10 00:52:19 -04:00
/// @param[in] _stage Compute stage.
/// @param[in] _handle Indirect buffer handle.
/// @param[in] _access Buffer access. See `Access::Enum`.
///
2015-05-16 19:07:10 -04:00
/// @attention C99 equivalent is `bgfx_set_compute_indirect_buffer`.
2015-04-30 21:06:41 -04:00
///
2015-05-01 17:54:23 -04:00
void setBuffer(uint8_t _stage, IndirectBufferHandle _handle, Access::Enum _access);
2015-04-30 21:06:41 -04:00
2015-05-14 23:33:33 -04:00
/// Set compute image from texture.
///
2015-07-10 00:52:19 -04:00
/// @param[in] _stage Texture unit.
/// @param[in] _sampler Program sampler.
/// @param[in] _handle Texture handle.
/// @param[in] _mip Mip level.
/// @param[in] _access Texture access. See `Access::Enum`.
/// @param[in] _format Texture format. See: `TextureFormat::Enum`.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_image`.
2014-07-20 23:27:13 -04:00
///
void setImage(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint8_t _mip, Access::Enum _access, TextureFormat::Enum _format = TextureFormat::Count);
2014-07-20 23:27:13 -04:00
2015-05-14 23:33:33 -04:00
/// Set compute image from frame buffer texture.
///
2015-07-10 00:52:19 -04:00
/// @param[in] _stage Texture unit.
/// @param[in] _sampler Program sampler.
/// @param[in] _handle Frame buffer handle.
/// @param[in] _attachment Attachment index.
/// @param[in] _access Texture access. See `Access::Enum`.
/// @param[in] _format Texture format. See: `TextureFormat::Enum`.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_set_image_from_frame_buffer`.
2014-07-20 23:27:13 -04:00
///
void setImage(uint8_t _stage, UniformHandle _sampler, FrameBufferHandle _handle, uint8_t _attachment, Access::Enum _access, TextureFormat::Enum _format = TextureFormat::Count);
2014-07-20 23:27:13 -04:00
/// Dispatch compute.
2015-05-14 23:33:33 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _id View id.
/// @param[in] _handle Compute program.
/// @param[in] _numX Number of groups X.
/// @param[in] _numY Number of groups Y.
/// @param[in] _numZ Number of groups Z.
/// @param[in] _flags View flags. Use
/// - `BGFX_VIEW_NONE` - View will be rendered only once if stereo mode is enabled.
/// - `BGFX_VIEW_STEREO` - View will be rendered for both eyes if stereo mode is enabled. When
/// stereo mode is disabled this flag doesn't have effect.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_dispatch`.
///
2015-05-01 17:54:23 -04:00
uint32_t dispatch(uint8_t _id, ProgramHandle _handle, uint16_t _numX = 1, uint16_t _numY = 1, uint16_t _numZ = 1, uint8_t _flags = BGFX_SUBMIT_EYE_FIRST);
2015-05-14 23:33:33 -04:00
/// Dispatch compute indirect.
///
2015-07-10 21:59:28 -04:00
/// @param[in] _id View id.
/// @param[in] _handle Compute program.
/// @param[in] _indirectHandle Indirect buffer.
/// @param[in] _start First element in indirect buffer.
/// @param[in] _num Number of dispatches.
/// @param[in] _flags View flags. Use
/// - `BGFX_VIEW_NONE` - View will be rendered only once if stereo mode is enabled.
/// - `BGFX_VIEW_STEREO` - View will be rendered for both eyes if stereo mode is enabled. When
/// stereo mode is disabled this flag doesn't have effect.
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_dispatch_indirect`.
2015-05-01 17:54:23 -04:00
///
uint32_t dispatch(uint8_t _id, ProgramHandle _handle, IndirectBufferHandle _indirectHandle, uint16_t _start = 0, uint16_t _num = 1, uint8_t _flags = BGFX_SUBMIT_EYE_FIRST);
2014-07-20 23:27:13 -04:00
/// Discard all previously set state for draw or compute call.
2015-05-14 23:33:33 -04:00
///
/// @attention C99 equivalent is `bgfx_discard`.
///
2013-07-29 22:01:29 -04:00
void discard();
/// Request screen shot.
2013-08-18 03:00:14 -04:00
///
2015-07-10 21:59:28 -04:00
/// @param[in] _filePath Will be passed to `bgfx::CallbackI::screenShot` callback.
2013-08-18 03:00:14 -04:00
///
/// @remarks
2014-10-11 13:12:27 -04:00
/// `bgfx::CallbackI::screenShot` must be implemented.
2013-08-18 03:00:14 -04:00
///
2015-05-14 23:33:33 -04:00
/// @attention C99 equivalent is `bgfx_save_screen_shot`.
///
2012-10-07 23:41:18 -04:00
void saveScreenShot(const char* _filePath);
} // namespace bgfx
#endif // BGFX_H_HEADER_GUARD