bgfx/include/bgfx.h

1176 lines
36 KiB
C
Raw Normal View History

2012-10-08 07:41:18 +04:00
/*
2014-02-11 10:07:04 +04:00
* Copyright 2011-2014 Branimir Karadzic. All rights reserved.
2014-06-02 00:25:31 +04:00
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
2012-10-08 07:41:18 +04:00
*/
#ifndef BGFX_H_HEADER_GUARD
#define BGFX_H_HEADER_GUARD
2012-10-08 07:41:18 +04:00
#include <stdint.h> // uint32_t
#include <stdlib.h> // size_t
2014-05-31 11:18:45 +04:00
#include "bgfxdefines.h"
2013-10-11 05:29:57 +04:00
2012-11-11 07:59:23 +04:00
///
#define BGFX_HANDLE(_name) \
struct _name { uint16_t idx; }; \
inline bool isValid(_name _handle) { return bgfx::invalidHandle != _handle.idx; }
2012-10-08 07:41:18 +04:00
#define BGFX_INVALID_HANDLE { bgfx::invalidHandle }
2013-09-17 08:40:30 +04:00
namespace bx { struct ReallocatorI; }
2012-11-11 07:59:23 +04:00
/// BGFX
2012-10-08 07:41:18 +04:00
namespace bgfx
{
struct Fatal
{
enum Enum
{
DebugCheck,
MinimumRequiredSpecs,
InvalidShader,
2012-12-09 02:30:41 +04:00
UnableToInitialize,
UnableToCreateTexture,
2012-10-08 07:41:18 +04:00
};
};
struct RendererType
{
enum Enum
{
Null,
2012-10-08 07:41:18 +04:00
Direct3D9,
Direct3D11,
OpenGLES,
2012-10-08 07:41:18 +04:00
OpenGL,
Count
2012-10-08 07:41:18 +04:00
};
};
2014-07-21 07:27:13 +04:00
struct Access
{
enum Enum
{
Read,
Write,
ReadWrite,
Count
};
};
2012-10-08 07:41:18 +04:00
struct Attrib
{
2013-03-21 09:57:07 +04:00
enum Enum // corresponds to vertex shader attribute:
2012-10-08 07:41:18 +04:00
{
2013-03-21 09:57:07 +04:00
Position, // a_position
Normal, // a_normal
Tangent, // a_tangent
Bitangent, // a_bitangent
2013-03-21 09:57:07 +04:00
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-08 07:41:18 +04:00
Count
2012-10-08 07:41:18 +04:00
};
};
struct AttribType
{
enum Enum
{
Uint8,
Int16,
2013-12-03 07:47:12 +04:00
Half, // Availability depends on: BGFX_CAPS_VERTEX_ATTRIB_HALF.
2012-10-08 07:41:18 +04:00
Float,
Count
2012-10-08 07:41:18 +04:00
};
};
struct TextureFormat
{
// Availability depends on Caps (see: formats).
2012-10-08 07:41:18 +04:00
enum Enum
{
2013-09-05 08:42:31 +04:00
BC1, // DXT1
BC2, // DXT3
BC3, // DXT5
BC4, // LATC1/ATI1
BC5, // LATC2/ATI2
2014-08-02 06:24:42 +04:00
BC6H, // BC6H
BC7, // BC7
2013-09-05 08: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 08:42:31 +04:00
PTC22, // PVRTC2 RGBA 2BPP
PTC24, // PVRTC2 RGBA 4BPP
2014-01-13 01:51:26 +04:00
Unknown, // compressed formats above
R1,
R8,
R16,
R16F,
2014-07-22 08:13:16 +04:00
R32,
R32F,
2014-07-26 10:16:11 +04:00
RG8,
2014-07-22 08:13:16 +04:00
RG16,
RG16F,
RG32,
RG32F,
2012-12-31 08:52:47 +04:00
BGRA8,
RGBA16,
2013-01-27 11:00:35 +04:00
RGBA16F,
2014-07-22 08:13:16 +04:00
RGBA32,
RGBA32F,
R5G6B5,
RGBA4,
RGB5A1,
RGB10A2,
2014-08-27 07:56:53 +04:00
R11G11B10F,
2014-01-09 10:08:37 +04:00
2014-01-13 01:51:26 +04:00
UnknownDepth, // depth formats below
D16,
D24,
D24S8,
D32,
D16F,
D24F,
D32F,
D0S8,
2012-10-08 07:41:18 +04:00
Count
};
};
2012-11-04 08:36:17 +04:00
struct UniformType
{
enum Enum
{
Uniform1i,
Uniform1f,
End,
Uniform1iv,
Uniform1fv,
Uniform2fv,
Uniform3fv,
Uniform4fv,
Uniform3x3fv,
Uniform4x4fv,
Count
};
};
2012-10-29 00:27:50 +04:00
static const uint16_t invalidHandle = UINT16_MAX;
BGFX_HANDLE(DynamicIndexBufferHandle);
BGFX_HANDLE(DynamicVertexBufferHandle);
BGFX_HANDLE(FrameBufferHandle);
2012-10-29 00:27:50 +04:00
BGFX_HANDLE(IndexBufferHandle);
BGFX_HANDLE(ProgramHandle);
BGFX_HANDLE(ShaderHandle);
2012-10-29 00:27:50 +04:00
BGFX_HANDLE(TextureHandle);
BGFX_HANDLE(UniformHandle);
BGFX_HANDLE(VertexBufferHandle);
BGFX_HANDLE(VertexDeclHandle);
2012-10-08 07:41:18 +04:00
2012-12-31 08:52:47 +04:00
/// Callback interface to implement application specific behavior.
2013-04-04 20:48:20 +04:00
/// Cached items are currently used only for OpenGL binary shaders.
2012-12-31 08:52:47 +04:00
///
2013-02-16 23:51:36 +04:00
/// NOTE:
/// 'fatal' callback can be called from any thread. Other callbacks
/// are called from the render thread.
///
2012-12-31 08:52:47 +04: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-31 08:52:47 +04:00
/// user and terminate application from this call.
virtual void fatal(Fatal::Enum _code, const char* _str) = 0;
/// Return size of for cached item. Return 0 if no cached item was
/// found.
virtual uint32_t cacheReadSize(uint64_t _id) = 0;
/// Read cached item.
virtual bool cacheRead(uint64_t _id, void* _data, uint32_t _size) = 0;
/// Write cached item.
virtual void cacheWrite(uint64_t _id, const void* _data, uint32_t _size) = 0;
/// Screenshot captured. Screenshot format is always 4-byte BGRA.
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.
2014-05-31 11:18:45 +04:00
virtual void captureBegin(uint32_t _width, uint32_t _height, uint32_t _pitch, TextureFormat::Enum _format, bool _yflip) = 0;
2012-12-31 08:52:47 +04:00
/// Called when capture ends.
virtual void captureEnd() = 0;
/// Captured frame.
virtual void captureFrame(const void* _data, uint32_t _size) = 0;
};
2013-02-17 03:38:52 +04:00
inline CallbackI::~CallbackI()
{
2012-12-31 08:52:47 +04:00
}
2012-11-04 08:36:17 +04:00
2012-10-08 07:41:18 +04:00
struct Memory
{
uint8_t* data;
uint32_t size;
};
2013-10-11 05:29:57 +04:00
/// Renderer capabilities.
struct Caps
{
/// Renderer backend type.
RendererType::Enum rendererType;
2014-01-09 10:08:37 +04:00
/// Supported functionality, it includes emulated functionality.
/// Checking supported and not emulated will give functionality
2013-10-11 05:29:57 +04:00
/// natively supported by renderer.
uint64_t supported;
2014-01-09 10:08:37 +04:00
/// Emulated functionality. For example some texture compression
2013-10-11 05:29:57 +04:00
/// modes are not natively supported by all renderers. The library
/// internally decompresses texture into supported format.
uint64_t emulated;
2014-02-06 11:07:11 +04:00
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[TextureFormat::Count];
2013-10-11 05:29:57 +04:00
};
2012-10-08 07:41:18 +04:00
struct TransientIndexBuffer
{
uint8_t* data;
uint32_t size;
IndexBufferHandle handle;
uint32_t startIndex;
};
struct TransientVertexBuffer
{
uint8_t* data;
uint32_t size;
uint32_t startVertex;
uint16_t stride;
VertexBufferHandle handle;
VertexDeclHandle decl;
};
struct InstanceDataBuffer
{
uint8_t* data;
uint32_t size;
uint32_t offset;
uint16_t stride;
uint16_t num;
VertexBufferHandle handle;
};
2012-11-04 08:36:17 +04:00
struct TextureInfo
2012-10-08 07:41:18 +04:00
{
2012-11-04 08:36:17 +04:00
TextureFormat::Enum format;
2013-01-06 02:33:05 +04:00
uint32_t storageSize;
2012-11-04 08:36:17 +04:00
uint16_t width;
uint16_t height;
uint16_t depth;
2013-01-06 02:33:05 +04:00
uint8_t numMips;
uint8_t bitsPerPixel;
2012-10-08 07:41:18 +04:00
};
2012-12-31 08:52:47 +04:00
/// Vertex declaration.
2012-10-08 07:41:18 +04:00
struct VertexDecl
{
VertexDecl();
/// Start VertexDecl.
VertexDecl& begin(RendererType::Enum _renderer = RendererType::Null);
/// End VertexDecl.
2012-10-08 07:41:18 +04:00
void end();
2013-02-16 23:51:36 +04:00
/// Add attribute to VertexDecl.
///
/// @param _attrib Attribute semantics.
/// @param _num Number of elements 1, 2, 3 or 4.
/// @param _type Element type.
2013-03-19 20:02:58 +04:00
/// @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.
///
2013-02-16 23:51:36 +04:00
/// NOTE:
/// Must be called between begin/end.
///
VertexDecl& add(Attrib::Enum _attrib, uint8_t _num, AttribType::Enum _type, bool _normalized = false, bool _asInt = false);
/// Skip _num bytes in vertex stream.
VertexDecl& skip(uint8_t _num);
/// Decode attribute.
2013-01-01 06:48:52 +04: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-08 07:41:18 +04:00
uint32_t m_hash;
uint16_t m_stride;
uint16_t m_offset[Attrib::Count];
uint8_t m_attributes[Attrib::Count];
};
2013-01-01 06:48:52 +04:00
/// Pack vec4 into vertex stream format.
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.
void vertexUnpack(float _output[4], Attrib::Enum _attr, const VertexDecl& _decl, const void* _data, uint32_t _index = 0);
2013-05-10 09:09:17 +04:00
/// 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.
///
void vertexConvert(const VertexDecl& _destDecl, void* _destData, const VertexDecl& _srcDecl, const void* _srcData, uint32_t _num = 1);
2013-11-03 10:00:31 +04:00
/// 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.
///
uint16_t weldVertices(uint16_t* _output, const VertexDecl& _decl, const void* _data, uint16_t _num, float _epsilon = 0.001f);
/// 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.
///
void imageSwizzleBgra8(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.
///
void imageRgba8Downsample2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
/// Returns supported backend API renderers.
uint8_t getSupportedRenderers(RendererType::Enum _enum[RendererType::Count]);
2012-10-08 07:41:18 +04:00
2014-05-28 07:05:13 +04:00
/// Returns name of renderer.
const char* getRendererName(RendererType::Enum _type);
/// Initialize bgfx library.
2013-04-04 20:48:20 +04:00
///
/// @param _type Select rendering backend. When set to RendererType::Count
/// default rendering backend will be selected.
///
2013-04-04 20:48:20 +04:00
/// @param _callback Provide application specific callback interface.
/// See: CallbackI
///
2013-09-17 08:40:30 +04:00
/// @param _reallocator Custom allocator. When custom allocator is not
2013-04-04 20:48:20 +04:00
/// specified, library uses default CRT allocator. The library assumes
/// custom allocator is thread safe.
///
void init(RendererType::Enum _type = RendererType::Count, CallbackI* _callback = NULL, bx::ReallocatorI* _reallocator = NULL);
2012-10-08 07:41:18 +04:00
/// Shutdown bgfx library.
2012-10-08 07:41:18 +04:00
void shutdown();
/// Reset graphic settings.
2012-10-08 07: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 10:08:37 +04:00
/// double/multi buffering data outside the library and passing it to
/// library via makeRef calls.
///
uint32_t frame();
2012-10-08 07:41:18 +04:00
/// Returns current renderer backend API type.
///
/// NOTE:
/// Library must be initialized.
///
RendererType::Enum getRendererType();
2013-10-11 05:29:57 +04:00
/// Returns renderer capabilities.
///
/// NOTE:
/// Library must be initialized.
///
2013-10-11 05:29:57 +04:00
const Caps* getCaps();
2012-10-08 07:41:18 +04:00
/// Allocate buffer to pass to bgfx calls. Data will be freed inside bgfx.
const Memory* alloc(uint32_t _size);
2014-04-17 09:24:31 +04:00
/// Allocate buffer and copy data into it. Data will be freed inside bgfx.
const Memory* copy(const void* _data, uint32_t _size);
2012-10-08 07:41:18 +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.
const Memory* makeRef(const void* _data, uint32_t _size);
/// Set debug flags.
///
2012-11-11 07:59:23 +04:00
/// @param _debug Available flags:
2012-10-08 07:41:18 +04:00
///
/// BGFX_DEBUG_IFH - Infinitely fast hardware. When this flag is set
2012-11-11 07:59:23 +04:00
/// all rendering calls will be skipped. It's useful when profiling
/// to quickly assess bottleneck between CPU and GPU.
2012-10-08 07:41:18 +04:00
///
/// 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.
///
void setDebug(uint32_t _debug);
2012-10-28 08:34:41 +04:00
/// Clear internal debug text buffer.
2012-10-08 07:41:18 +04:00
void dbgTextClear(uint8_t _attr = 0, bool _small = false);
2012-10-28 08:34:41 +04:00
/// Print into internal debug text buffer.
2012-10-08 07:41:18 +04:00
void dbgTextPrintf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ...);
/// Create static index buffer.
2014-05-20 09:08:35 +04:00
///
/// NOTE:
/// Only 16-bit index buffer is supported.
///
2012-10-08 07:41:18 +04:00
IndexBufferHandle createIndexBuffer(const Memory* _mem);
/// Destroy static index buffer.
2012-10-08 07:41:18 +04:00
void destroyIndexBuffer(IndexBufferHandle _handle);
/// Create static vertex buffer.
///
/// @param _mem Vertex buffer data.
/// @param _decl Vertex declaration.
/// @returns Static vertex buffer handle.
///
2012-10-08 07:41:18 +04:00
VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexDecl& _decl);
/// Destroy static vertex buffer.
///
/// @param _handle Static vertex buffer handle.
///
2012-10-08 07:41:18 +04:00
void destroyVertexBuffer(VertexBufferHandle _handle);
/// Create empty dynamic index buffer.
///
/// @param _num Number of indices.
///
2014-05-20 09:08:35 +04:00
/// NOTE:
/// Only 16-bit index buffer is supported.
///
DynamicIndexBufferHandle createDynamicIndexBuffer(uint32_t _num);
2012-10-08 07:41:18 +04:00
/// Create dynamic index buffer and initialized it.
///
/// @param _mem Index buffer data.
///
2014-05-20 09:08:35 +04:00
/// NOTE:
/// Only 16-bit index buffer is supported.
///
2012-10-08 07:41:18 +04:00
DynamicIndexBufferHandle createDynamicIndexBuffer(const Memory* _mem);
/// Update dynamic index buffer.
///
/// @param _handle Dynamic index buffer handle.
/// @param _mem Index buffer data.
///
2012-10-08 07:41:18 +04:00
void updateDynamicIndexBuffer(DynamicIndexBufferHandle _handle, const Memory* _mem);
/// Destroy dynamic index buffer.
///
/// @param _handle Dynamic index buffer handle.
///
2012-10-08 07:41:18 +04:00
void destroyDynamicIndexBuffer(DynamicIndexBufferHandle _handle);
/// Create empty dynamic vertex buffer.
///
/// @param _num Number of vertices.
/// @param _decl Vertex declaration.
///
2012-10-08 07:41:18 +04:00
DynamicVertexBufferHandle createDynamicVertexBuffer(uint16_t _num, const VertexDecl& _decl);
/// Create dynamic vertex buffer and initialize it.
///
/// @param _mem Vertex buffer data.
/// @param _decl Vertex declaration.
///
2012-10-08 07:41:18 +04:00
DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl);
/// Update dynamic vertex buffer.
2012-10-08 07:41:18 +04:00
void updateDynamicVertexBuffer(DynamicVertexBufferHandle _handle, const Memory* _mem);
/// Destroy dynamic vertex buffer.
2012-10-08 07:41:18 +04:00
void destroyDynamicVertexBuffer(DynamicVertexBufferHandle _handle);
2012-11-04 08:36:17 +04:00
/// Returns true if internal transient index buffer has enough space.
///
/// @param _num Number of indices.
///
bool checkAvailTransientIndexBuffer(uint32_t _num);
2012-10-08 07:41:18 +04:00
/// Returns true if internal transient vertex buffer has enough space.
///
/// @param _num Number of vertices.
/// @param _decl Vertex declaration.
///
bool checkAvailTransientVertexBuffer(uint32_t _num, const VertexDecl& _decl);
/// Returns true if internal instance data buffer has enough space.
///
/// @param _num Number of instances.
/// @param _stride Stride per instance.
///
bool checkAvailInstanceDataBuffer(uint32_t _num, uint16_t _stride);
/// 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.
///
bool checkAvailTransientBuffers(uint32_t _numVertices, const VertexDecl& _decl, uint32_t _numIndices);
2012-11-11 07:59:23 +04:00
/// Allocate transient index buffer.
2012-10-08 07:41:18 +04:00
///
2013-07-15 01: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.
/// @param _num Number of indices to allocate.
///
2013-07-30 06:01:29 +04:00
/// NOTE:
2014-05-20 09: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-30 06:01:29 +04:00
///
void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint32_t _num);
2012-10-08 07:41:18 +04:00
2012-11-11 07:59:23 +04:00
/// Allocate transient vertex buffer.
2012-10-08 07:41:18 +04:00
///
2013-07-15 01: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.
/// @param _num Number of vertices to allocate.
/// @param _decl Vertex declaration.
///
2013-07-30 06:01:29 +04:00
/// NOTE:
/// You must call setVertexBuffer after alloc in order to avoid memory
/// leak.
///
void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexDecl& _decl);
2012-10-08 07:41:18 +04:00
2014-05-20 09:08:35 +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 11:18:45 +04:00
bool allocTransientBuffers(TransientVertexBuffer* _tvb, const VertexDecl& _decl, uint16_t _numVertices, TransientIndexBuffer* _tib, uint16_t _numIndices);
2014-05-20 09:08:35 +04:00
/// Allocate instance data buffer.
2013-07-30 06:01:29 +04:00
///
/// NOTE:
/// You must call setInstanceDataBuffer after alloc in order to avoid
/// memory leak.
///
const InstanceDataBuffer* allocInstanceDataBuffer(uint32_t _num, uint16_t _stride);
2012-10-08 07:41:18 +04:00
/// Create shader from memory buffer.
ShaderHandle createShader(const Memory* _mem);
2012-10-08 07:41:18 +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.
///
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.
void destroyShader(ShaderHandle _handle);
2012-10-08 07:41:18 +04:00
2012-11-04 08:36:17 +04:00
/// Create program with vertex and fragment shaders.
///
2013-07-15 01:32:09 +04:00
/// @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
2013-02-16 23:51:36 +04:00
/// input are matching, otherwise returns invalid program handle.
///
ProgramHandle createProgram(ShaderHandle _vsh, ShaderHandle _fsh, bool _destroyShaders = false);
2012-10-08 07:41:18 +04:00
2012-11-04 08:36:17 +04:00
/// Destroy program.
2012-10-08 07:41:18 +04:00
void destroyProgram(ProgramHandle _handle);
2013-01-05 11:52:37 +04:00
/// Calculate amount of memory required for texture.
2013-01-06 02:33:05 +04:00
void calcTextureSize(TextureInfo& _info, uint16_t _width, uint16_t _height, uint16_t _depth, uint8_t _numMips, TextureFormat::Enum _format);
2013-01-05 11:52:37 +04:00
2013-02-17 03:38:52 +04:00
/// Create texture from memory buffer.
2013-04-28 23:47:20 +04:00
///
/// @param _mem DDS, KTX or PVR texture data.
2013-02-17 03:38:52 +04:00
/// @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.
2014-04-16 09:59:40 +04:00
/// @param _info Returns parsed texture information.
2013-02-17 03:38:52 +04:00
/// @returns Texture handle.
///
TextureHandle createTexture(const Memory* _mem, uint32_t _flags = BGFX_TEXTURE_NONE, uint8_t _skip = 0, TextureInfo* _info = NULL);
2012-10-08 07:41:18 +04:00
/// Create 2D texture.
///
/// @param _width
/// @param _height
/// @param _numMips
/// @param _format
/// @param _flags
/// @param _mem
///
2012-08-13 08: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-08 07:41:18 +04:00
/// Create 3D texture.
///
/// @param _width
/// @param _height
/// @param _depth
/// @param _numMips
/// @param _format
/// @param _flags
/// @param _mem
///
2012-08-13 08: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-08 07:41:18 +04:00
/// Create Cube texture.
///
/// @param _size
/// @param _numMips
/// @param _format
/// @param _flags
/// @param _mem
///
TextureHandle createTextureCube(uint16_t _size, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags = BGFX_TEXTURE_NONE, const Memory* _mem = NULL);
2012-10-08 07:41:18 +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.
///
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-08 07:41:18 +04:00
/// Update 3D texture.
///
/// @param _handle
/// @param _mip
/// @param _x
/// @param _y
/// @param _z
/// @param _width
/// @param _height
/// @param _depth
/// @param _mem
///
2012-10-08 07: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.
///
/// @param _handle
2013-04-04 20:51:42 +04:00
/// @param _side Cubemap side, where 0 is +X, 1 is -X, 2 is +Y, 3 is
/// -Y, 4 is +Z, and 5 is -Z.
///
2013-08-27 09:38:53 +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 |
/// +----------+
///
/// @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.
///
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-08 07:41:18 +04:00
/// Destroy texture.
2012-10-08 07:41:18 +04:00
void destroyTexture(TextureHandle _handle);
2014-02-06 11:07:11 +04:00
/// Create frame buffer (simple).
///
/// @param _width Texture width.
/// @param _height Texture height.
/// @param _format Texture format.
/// @param _textureFlags Texture flags.
///
FrameBufferHandle createFrameBuffer(uint16_t _width, uint16_t _height, TextureFormat::Enum _format, uint32_t _textureFlags = BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
/// Create frame buffer.
///
/// @param _num Number of texture attachments.
/// @param _handles Texture attachments.
/// @param _destroyTextures If true, textures will be destroyed when
/// frame buffer is destroyed.
2014-02-06 11:07:11 +04:00
///
FrameBufferHandle createFrameBuffer(uint8_t _num, TextureHandle* _handles, bool _destroyTextures = false);
2012-10-08 07:41:18 +04:00
2014-02-06 11:07:11 +04:00
/// Destroy frame buffer.
void destroyFrameBuffer(FrameBufferHandle _handle);
2012-10-08 07:41:18 +04:00
/// Create shader uniform parameter.
2013-09-29 21:42:41 +04:00
///
/// @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.
2013-09-29 21:42:41 +04:00
///
2012-10-28 08:34:41 +04:00
UniformHandle createUniform(const char* _name, UniformType::Enum _type, uint16_t _num = 1);
2012-10-08 07:41:18 +04:00
/// Destroy shader uniform parameter.
2012-10-08 07:41:18 +04:00
void destroyUniform(UniformHandle _handle);
2014-09-01 22:24:51 +04:00
/// Set clear color palette value.
///
/// @param _index Index into palette.
/// @param _rgba Packed 32-bit RGBA value.
///
void setClearColor(uint8_t _index, uint32_t _rgba);
/// Set clear color palette value.
///
/// @param _index Index into palette.
/// @param _r, _g, _b, _a RGBA floating point values.
///
void setClearColor(uint8_t _index, float _r, float _g, float _b, float _a);
/// Set clear color palette value.
///
/// @param _index Index into palette.
/// @param _rgba RGBA floating point value.
///
void setClearColor(uint8_t _index, const float _rgba[4]);
/// Set view name.
///
2013-07-07 22:59:43 +04:00
/// @param _id View id.
/// @param _name View name.
///
/// NOTE:
/// This is debug only feature.
///
void setViewName(uint8_t _id, const char* _name);
2012-10-28 08:34:41 +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.
///
2012-10-08 07:41:18 +04:00
void setViewRect(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
2013-07-15 01:32:09 +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.
///
2012-10-08 07:41:18 +04:00
void setViewRectMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
2013-07-15 01: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.
///
/// @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.
///
2013-07-15 01: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);
/// 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.
///
2013-07-15 01:32:09 +04:00
void setViewScissorMask(uint32_t _viewMask, uint16_t _x = 0, uint16_t _y = 0, uint16_t _width = 0, uint16_t _height = 0);
2012-10-28 08:34:41 +04:00
/// Set view clear flags.
2012-11-11 09:18:50 +04:00
///
2013-07-07 22:59:43 +04:00
/// @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.
///
2012-10-08 07:41:18 +04:00
void setViewClear(uint8_t _id, uint8_t _flags, uint32_t _rgba = 0x000000ff, float _depth = 1.0f, uint8_t _stencil = 0);
2014-09-01 22: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.
///
/// @param _id View id.
/// @param _flags Clear flags. Use BGFX_CLEAR_NONE to remove any clear
/// operation. See: BGFX_CLEAR_*.
/// @param _depth Depth clear value.
/// @param _stencil Stencil clear value.
///
void setViewClear(uint8_t _id, uint8_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);
/// Set view clear flags for multiple views.
2012-10-08 07:41:18 +04:00
void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba = 0x000000ff, float _depth = 1.0f, uint8_t _stencil = 0);
2012-10-28 08:34:41 +04:00
/// Set view into sequential mode. Draw calls will be sorted in the same
/// order in which submit calls were called.
2012-10-08 07:41:18 +04:00
void setViewSeq(uint8_t _id, bool _enabled);
/// Set multiple views into sequential mode.
2012-10-08 07:41:18 +04:00
void setViewSeqMask(uint32_t _viewMask, bool _enabled);
2014-02-06 11:07:11 +04:00
/// Set view frame buffer.
2013-07-07 22:59:43 +04:00
///
/// @param _id View id.
2014-02-06 11:07:11 +04:00
/// @param _handle Frame buffer handle. Passing BGFX_INVALID_HANDLE as
/// frame buffer handle will draw primitives from this view into
/// default back buffer.
2013-07-07 22:59:43 +04:00
///
2014-02-06 11:07:11 +04:00
void setViewFrameBuffer(uint8_t _id, FrameBufferHandle _handle);
2012-10-08 07:41:18 +04:00
2014-02-06 11:07:11 +04:00
/// Set view frame buffer for multiple views.
2013-07-07 22:59:43 +04:00
///
/// @param _viewMask View mask.
2014-02-06 11:07:11 +04:00
/// @param _handle Frame buffer handle. Passing BGFX_INVALID_HANDLE as
/// frame buffer handle will draw primitives from this view into
/// default back buffer.
2013-07-07 22:59:43 +04:00
///
2014-02-06 11:07:11 +04:00
void setViewFrameBufferMask(uint32_t _viewMask, FrameBufferHandle _handle);
2012-10-08 07:41:18 +04:00
2012-10-28 08:34:41 +04:00
/// Set view view and projection matrices, all draw primitives in this
/// view will use these matrices.
2014-05-31 11:18:45 +04:00
void setViewTransform(uint8_t _id, const void* _view, const void* _proj);
2012-10-08 07:41:18 +04:00
/// Set view view and projection matrices for multiple views.
2014-05-31 11:18:45 +04:00
void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj);
2012-10-08 07:41:18 +04:00
/// Sets debug marker.
void setMarker(const char* _marker);
2012-10-28 08:34:41 +04:00
/// Set render states for draw primitive.
2013-04-28 23:47:20 +04:00
///
2013-02-16 23:51:36 +04:00
/// @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.
2013-06-18 09:11:45 +04:00
/// BGFX_STATE_BLEND_* - See NOTE 1: BGFX_STATE_BLEND_FUNC.
/// BGFX_STATE_BLEND_EQUATION_* - See NOTE 2.
2013-02-16 23:51:36 +04:00
/// 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.
///
2013-02-16 23:51:36 +04:00
/// NOTE:
2013-06-18 09:11:45 +04:00
/// 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.
///
void setState(uint64_t _state, uint32_t _rgba = 0);
2012-10-08 07:41:18 +04:00
2012-11-11 07:59:23 +04:00
/// Set stencil test state.
///
/// @param _fstencil Front stencil state.
/// @param _bstencil Back stencil state. If back is set to BGFX_STENCIL_NONE
2013-02-16 23:51:36 +04:00
/// _fstencil is applied to both front and back facing primitives.
///
2012-11-11 07:59:23 +04:00
void setStencil(uint32_t _fstencil, uint32_t _bstencil = BGFX_STENCIL_NONE);
/// 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.
///
2013-07-15 01: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.
///
/// @param _cache Index in scissor cache. Passing UINT16_MAX unset primitive
/// scissor and primitive will use view scissor instead.
2013-07-15 01:32:09 +04:00
///
void setScissor(uint16_t _cache = UINT16_MAX);
2013-07-15 01:32:09 +04:00
2012-10-28 08: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-08 07:41:18 +04:00
///
2013-07-15 01:32:09 +04:00
/// @param _mtx Pointer to first matrix in array.
/// @param _num Number of matrices in array.
2013-04-04 20:51:42 +04:00
/// @returns index into matrix cache in case the same model matrix has
/// to be used for other draw primitive call.
///
2012-10-08 07:41:18 +04:00
uint32_t setTransform(const void* _mtx, uint16_t _num = 1);
2012-10-28 08:34:41 +04:00
/// Set model matrix from matrix cache for draw primitive.
2012-11-11 07:59:23 +04:00
///
2013-07-15 01:32:09 +04:00
/// @param _cache Index in matrix cache.
/// @param _num Number of matrices from cache.
///
2012-10-28 08:34:41 +04:00
void setTransform(uint32_t _cache, uint16_t _num = 1);
2012-10-08 07:41:18 +04:00
/// Set shader uniform parameter for draw primitive.
2012-10-08 07:41:18 +04:00
void setUniform(UniformHandle _handle, const void* _value, uint16_t _num = 1);
/// Set index buffer for draw primitive.
2012-12-29 05:09:34 +04:00
void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex = 0, uint32_t _numIndices = UINT32_MAX);
2012-10-08 07:41:18 +04:00
/// Set index buffer for draw primitive.
2012-12-29 05:09:34 +04:00
void setIndexBuffer(DynamicIndexBufferHandle _handle, uint32_t _firstIndex = 0, uint32_t _numIndices = UINT32_MAX);
2012-10-08 07:41:18 +04:00
/// Set index buffer for draw primitive.
2014-04-27 10:48:41 +04:00
void setIndexBuffer(const TransientIndexBuffer* _tib);
/// Set index buffer for draw primitive.
void setIndexBuffer(const TransientIndexBuffer* _tib, uint32_t _firstIndex, uint32_t _numIndices);
2012-10-08 07:41:18 +04:00
/// Set vertex buffer for draw primitive.
2014-04-17 09:11:14 +04:00
void setVertexBuffer(VertexBufferHandle _handle);
/// Set vertex buffer for draw primitive.
void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices);
2012-10-08 07:41:18 +04:00
/// Set vertex buffer for draw primitive.
2012-10-08 07:41:18 +04:00
void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices = UINT32_MAX);
/// Set vertex buffer for draw primitive.
2014-04-27 10:48:41 +04:00
void setVertexBuffer(const TransientVertexBuffer* _tvb);
/// Set vertex buffer for draw primitive.
void setVertexBuffer(const TransientVertexBuffer* _tvb, uint32_t _startVertex, uint32_t _numVertices);
2012-10-08 07:41:18 +04:00
/// Set instance data buffer for draw primitive.
2012-10-28 08:34:41 +04:00
void setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint16_t _num = UINT16_MAX);
2012-10-08 07:41:18 +04:00
/// Set program for draw primitive.
2012-10-08 07:41:18 +04:00
void setProgram(ProgramHandle _handle);
/// 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.
///
void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint32_t _flags = UINT32_MAX);
2012-10-08 07:41:18 +04:00
/// Set texture stage for draw primitive.
///
/// @param _stage Texture unit.
/// @param _sampler Program sampler.
2014-02-06 11:07:11 +04:00
/// @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-02-06 11:07:11 +04:00
void setTexture(uint8_t _stage, UniformHandle _sampler, FrameBufferHandle _handle, uint8_t _attachment = 0, uint32_t _flags = UINT32_MAX);
2012-10-08 07:41:18 +04:00
2012-10-15 02:02:38 +04:00
/// Submit primitive for rendering into single view.
2012-11-11 09:18:50 +04:00
///
/// @param _id View id.
2013-07-15 01:32:09 +04:00
/// @param _depth Depth for sorting.
/// @returns Number of draw calls.
///
uint32_t submit(uint8_t _id, int32_t _depth = 0);
2012-10-08 07:41:18 +04:00
2012-10-15 02:02:38 +04:00
/// Submit primitive for rendering into multiple views.
2012-11-11 09:18:50 +04:00
///
2013-07-15 01:32:09 +04:00
/// @param _viewMask Mask to which views to submit draw primitive calls.
/// @param _depth Depth for sorting.
/// @returns Number of draw calls.
///
uint32_t submitMask(uint32_t _viewMask, int32_t _depth = 0);
2012-10-08 07:41:18 +04:00
2014-07-21 07:27:13 +04:00
///
void setImage(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint8_t _mip, TextureFormat::Enum _format, Access::Enum _access);
///
void setImage(uint8_t _stage, UniformHandle _sampler, FrameBufferHandle _handle, uint8_t _attachment, TextureFormat::Enum _format, Access::Enum _access);
/// Dispatch compute.
void dispatch(uint8_t _id, ProgramHandle _handle, uint16_t _numX = 1, uint16_t _numY = 1, uint16_t _numZ = 1);
/// Discard all previously set state for draw or compute call.
2013-07-30 06:01:29 +04:00
void discard();
/// Request screen shot.
2013-08-18 11:00:14 +04:00
///
/// @param _filePath Will be passed to CallbackI::screenShot callback.
///
/// NOTE:
/// CallbackI::screenShot must be implemented.
///
2012-10-08 07:41:18 +04:00
void saveScreenShot(const char* _filePath);
} // namespace bgfx
#endif // BGFX_H_HEADER_GUARD