mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 10:35:43 -05:00
Added aditional render target color formats.
This commit is contained in:
parent
eb8ab50281
commit
365f2655b3
7 changed files with 215 additions and 181 deletions
|
@ -478,20 +478,20 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
Mesh mesh;
|
||||
mesh.load("meshes/bunny.bin");
|
||||
|
||||
bgfx::RenderTargetHandle rt = bgfx::createRenderTarget(width, height, BGFX_RENDER_TARGET_COLOR_RGBA|BGFX_RENDER_TARGET_DEPTH|BGFX_RENDER_TARGET_MSAA_X8);
|
||||
bgfx::RenderTargetHandle rt = bgfx::createRenderTarget(width, height, BGFX_RENDER_TARGET_COLOR_RGBA8|BGFX_RENDER_TARGET_DEPTH);
|
||||
|
||||
bgfx::RenderTargetHandle lum[5];
|
||||
lum[0] = bgfx::createRenderTarget(128, 128, BGFX_RENDER_TARGET_COLOR_RGBA);
|
||||
lum[1] = bgfx::createRenderTarget( 64, 64, BGFX_RENDER_TARGET_COLOR_RGBA);
|
||||
lum[2] = bgfx::createRenderTarget( 16, 16, BGFX_RENDER_TARGET_COLOR_RGBA);
|
||||
lum[3] = bgfx::createRenderTarget( 4, 4, BGFX_RENDER_TARGET_COLOR_RGBA);
|
||||
lum[4] = bgfx::createRenderTarget( 1, 1, BGFX_RENDER_TARGET_COLOR_RGBA);
|
||||
lum[0] = bgfx::createRenderTarget(128, 128, BGFX_RENDER_TARGET_COLOR_RGBA8);
|
||||
lum[1] = bgfx::createRenderTarget( 64, 64, BGFX_RENDER_TARGET_COLOR_RGBA8);
|
||||
lum[2] = bgfx::createRenderTarget( 16, 16, BGFX_RENDER_TARGET_COLOR_RGBA8);
|
||||
lum[3] = bgfx::createRenderTarget( 4, 4, BGFX_RENDER_TARGET_COLOR_RGBA8);
|
||||
lum[4] = bgfx::createRenderTarget( 1, 1, BGFX_RENDER_TARGET_COLOR_RGBA8);
|
||||
|
||||
bgfx::RenderTargetHandle bright;
|
||||
bright = bgfx::createRenderTarget(width/2, height/2, BGFX_RENDER_TARGET_COLOR_RGBA);
|
||||
bright = bgfx::createRenderTarget(width/2, height/2, BGFX_RENDER_TARGET_COLOR_RGBA8);
|
||||
|
||||
bgfx::RenderTargetHandle blur;
|
||||
blur = bgfx::createRenderTarget(width/8, height/8, BGFX_RENDER_TARGET_COLOR_RGBA);
|
||||
blur = bgfx::createRenderTarget(width/8, height/8, BGFX_RENDER_TARGET_COLOR_RGBA8);
|
||||
|
||||
uint32_t oldWidth = 0;
|
||||
uint32_t oldHeight = 0;
|
||||
|
@ -508,9 +508,9 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
bgfx::destroyRenderTarget(bright);
|
||||
bgfx::destroyRenderTarget(blur);
|
||||
|
||||
rt = bgfx::createRenderTarget(width, height, BGFX_RENDER_TARGET_COLOR_RGBA|BGFX_RENDER_TARGET_DEPTH|BGFX_RENDER_TARGET_MSAA_X8);
|
||||
bright = bgfx::createRenderTarget(width/2, height/2, BGFX_RENDER_TARGET_COLOR_RGBA);
|
||||
blur = bgfx::createRenderTarget(width/8, height/8, BGFX_RENDER_TARGET_COLOR_RGBA);
|
||||
rt = bgfx::createRenderTarget(width, height, BGFX_RENDER_TARGET_COLOR_RGBA8|BGFX_RENDER_TARGET_DEPTH);
|
||||
bright = bgfx::createRenderTarget(width/2, height/2, BGFX_RENDER_TARGET_COLOR_RGBA8);
|
||||
blur = bgfx::createRenderTarget(width/8, height/8, BGFX_RENDER_TARGET_COLOR_RGBA8);
|
||||
}
|
||||
|
||||
// This dummy draw call is here to make sure that view 0 is cleared
|
||||
|
|
310
include/bgfx.h
310
include/bgfx.h
|
@ -10,61 +10,61 @@
|
|||
#include <stdlib.h> // size_t
|
||||
|
||||
///
|
||||
#define BGFX_STATE_DEPTH_WRITE UINT64_C(0x0000000000000001)
|
||||
#define BGFX_STATE_DEPTH_WRITE UINT64_C(0x0000000000000001)
|
||||
|
||||
#define BGFX_STATE_ALPHA_WRITE UINT64_C(0x0000000000000008)
|
||||
#define BGFX_STATE_ALPHA_MASK UINT64_C(0x000000000000000c)
|
||||
#define BGFX_STATE_ALPHA_WRITE UINT64_C(0x0000000000000008)
|
||||
#define BGFX_STATE_ALPHA_MASK UINT64_C(0x000000000000000c)
|
||||
|
||||
#define BGFX_STATE_DEPTH_TEST_LESS UINT64_C(0x0000000000000010)
|
||||
#define BGFX_STATE_DEPTH_TEST_LEQUAL UINT64_C(0x0000000000000020)
|
||||
#define BGFX_STATE_DEPTH_TEST_EQUAL UINT64_C(0x0000000000000030)
|
||||
#define BGFX_STATE_DEPTH_TEST_GEQUAL UINT64_C(0x0000000000000040)
|
||||
#define BGFX_STATE_DEPTH_TEST_GREATER UINT64_C(0x0000000000000050)
|
||||
#define BGFX_STATE_DEPTH_TEST_NOTEQUAL UINT64_C(0x0000000000000060)
|
||||
#define BGFX_STATE_DEPTH_TEST_NEVER UINT64_C(0x0000000000000070)
|
||||
#define BGFX_STATE_DEPTH_TEST_ALWAYS UINT64_C(0x0000000000000080)
|
||||
#define BGFX_STATE_DEPTH_TEST_SHIFT 4
|
||||
#define BGFX_STATE_DEPTH_TEST_MASK UINT64_C(0x00000000000000f0)
|
||||
#define BGFX_STATE_DEPTH_TEST_LESS UINT64_C(0x0000000000000010)
|
||||
#define BGFX_STATE_DEPTH_TEST_LEQUAL UINT64_C(0x0000000000000020)
|
||||
#define BGFX_STATE_DEPTH_TEST_EQUAL UINT64_C(0x0000000000000030)
|
||||
#define BGFX_STATE_DEPTH_TEST_GEQUAL UINT64_C(0x0000000000000040)
|
||||
#define BGFX_STATE_DEPTH_TEST_GREATER UINT64_C(0x0000000000000050)
|
||||
#define BGFX_STATE_DEPTH_TEST_NOTEQUAL UINT64_C(0x0000000000000060)
|
||||
#define BGFX_STATE_DEPTH_TEST_NEVER UINT64_C(0x0000000000000070)
|
||||
#define BGFX_STATE_DEPTH_TEST_ALWAYS UINT64_C(0x0000000000000080)
|
||||
#define BGFX_STATE_DEPTH_TEST_SHIFT 4
|
||||
#define BGFX_STATE_DEPTH_TEST_MASK UINT64_C(0x00000000000000f0)
|
||||
|
||||
#define BGFX_STATE_BLEND_ZERO UINT64_C(0x0000000000001000)
|
||||
#define BGFX_STATE_BLEND_ONE UINT64_C(0x0000000000002000)
|
||||
#define BGFX_STATE_BLEND_SRC_COLOR UINT64_C(0x0000000000003000)
|
||||
#define BGFX_STATE_BLEND_INV_SRC_COLOR UINT64_C(0x0000000000004000)
|
||||
#define BGFX_STATE_BLEND_SRC_ALPHA UINT64_C(0x0000000000005000)
|
||||
#define BGFX_STATE_BLEND_INV_SRC_ALPHA UINT64_C(0x0000000000006000)
|
||||
#define BGFX_STATE_BLEND_DST_ALPHA UINT64_C(0x0000000000007000)
|
||||
#define BGFX_STATE_BLEND_INV_DST_ALPHA UINT64_C(0x0000000000008000)
|
||||
#define BGFX_STATE_BLEND_DST_COLOR UINT64_C(0x0000000000009000)
|
||||
#define BGFX_STATE_BLEND_INV_DST_COLOR UINT64_C(0x000000000000a000)
|
||||
#define BGFX_STATE_BLEND_SRC_ALPHA_SAT UINT64_C(0x000000000000b000)
|
||||
#define BGFX_STATE_BLEND_SHIFT 12
|
||||
#define BGFX_STATE_BLEND_MASK UINT64_C(0x000000000ffff000)
|
||||
#define BGFX_STATE_BLEND_ZERO UINT64_C(0x0000000000001000)
|
||||
#define BGFX_STATE_BLEND_ONE UINT64_C(0x0000000000002000)
|
||||
#define BGFX_STATE_BLEND_SRC_COLOR UINT64_C(0x0000000000003000)
|
||||
#define BGFX_STATE_BLEND_INV_SRC_COLOR UINT64_C(0x0000000000004000)
|
||||
#define BGFX_STATE_BLEND_SRC_ALPHA UINT64_C(0x0000000000005000)
|
||||
#define BGFX_STATE_BLEND_INV_SRC_ALPHA UINT64_C(0x0000000000006000)
|
||||
#define BGFX_STATE_BLEND_DST_ALPHA UINT64_C(0x0000000000007000)
|
||||
#define BGFX_STATE_BLEND_INV_DST_ALPHA UINT64_C(0x0000000000008000)
|
||||
#define BGFX_STATE_BLEND_DST_COLOR UINT64_C(0x0000000000009000)
|
||||
#define BGFX_STATE_BLEND_INV_DST_COLOR UINT64_C(0x000000000000a000)
|
||||
#define BGFX_STATE_BLEND_SRC_ALPHA_SAT UINT64_C(0x000000000000b000)
|
||||
#define BGFX_STATE_BLEND_SHIFT 12
|
||||
#define BGFX_STATE_BLEND_MASK UINT64_C(0x000000000ffff000)
|
||||
|
||||
#define BGFX_STATE_CULL_CW UINT64_C(0x0000000010000000)
|
||||
#define BGFX_STATE_CULL_CCW UINT64_C(0x0000000020000000)
|
||||
#define BGFX_STATE_CULL_SHIFT 28
|
||||
#define BGFX_STATE_CULL_MASK UINT64_C(0x0000000030000000)
|
||||
#define BGFX_STATE_CULL_CW UINT64_C(0x0000000010000000)
|
||||
#define BGFX_STATE_CULL_CCW UINT64_C(0x0000000020000000)
|
||||
#define BGFX_STATE_CULL_SHIFT 28
|
||||
#define BGFX_STATE_CULL_MASK UINT64_C(0x0000000030000000)
|
||||
|
||||
#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000040000000)
|
||||
#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000040000000)
|
||||
|
||||
#define BGFX_STATE_ALPHA_REF_SHIFT 32
|
||||
#define BGFX_STATE_ALPHA_REF_MASK UINT64_C(0x000000ff00000000)
|
||||
#define BGFX_STATE_ALPHA_REF_SHIFT 32
|
||||
#define BGFX_STATE_ALPHA_REF_MASK UINT64_C(0x000000ff00000000)
|
||||
|
||||
#define BGFX_STATE_PT_LINES UINT64_C(0x0000010000000000)
|
||||
#define BGFX_STATE_PT_POINTS UINT64_C(0x0000020000000000)
|
||||
#define BGFX_STATE_PT_SHIFT 40
|
||||
#define BGFX_STATE_PT_MASK UINT64_C(0x0000030000000000)
|
||||
#define BGFX_STATE_PT_LINES UINT64_C(0x0000010000000000)
|
||||
#define BGFX_STATE_PT_POINTS UINT64_C(0x0000020000000000)
|
||||
#define BGFX_STATE_PT_SHIFT 40
|
||||
#define BGFX_STATE_PT_MASK UINT64_C(0x0000030000000000)
|
||||
|
||||
#define BGFX_STATE_POINT_SIZE_SHIFT 44
|
||||
#define BGFX_STATE_POINT_SIZE_MASK UINT64_C(0x000ff00000000000)
|
||||
#define BGFX_STATE_POINT_SIZE_SHIFT 44
|
||||
#define BGFX_STATE_POINT_SIZE_MASK UINT64_C(0x000ff00000000000)
|
||||
|
||||
#define BGFX_STATE_SRGBWRITE UINT64_C(0x0010000000000000)
|
||||
#define BGFX_STATE_MSAA UINT64_C(0x0020000000000000)
|
||||
#define BGFX_STATE_SRGBWRITE UINT64_C(0x0010000000000000)
|
||||
#define BGFX_STATE_MSAA UINT64_C(0x0020000000000000)
|
||||
|
||||
#define BGFX_STATE_RESERVED UINT64_C(0xff00000000000000)
|
||||
#define BGFX_STATE_RESERVED UINT64_C(0xff00000000000000)
|
||||
|
||||
#define BGFX_STATE_NONE UINT64_C(0x0000000000000000)
|
||||
#define BGFX_STATE_MASK UINT64_C(0xffffffffffffffff)
|
||||
#define BGFX_STATE_NONE UINT64_C(0x0000000000000000)
|
||||
#define BGFX_STATE_MASK UINT64_C(0xffffffffffffffff)
|
||||
#define BGFX_STATE_DEFAULT (0 \
|
||||
| BGFX_STATE_RGB_WRITE \
|
||||
| BGFX_STATE_ALPHA_WRITE \
|
||||
|
@ -79,132 +79,136 @@
|
|||
#define BGFX_STATE_BLEND_FUNC(_src, _dst) ( uint64_t(_src)|( uint64_t(_dst)<<4) )
|
||||
|
||||
///
|
||||
#define BGFX_STENCIL_FUNC_REF_SHIFT 0
|
||||
#define BGFX_STENCIL_FUNC_REF_MASK UINT32_C(0x000000ff)
|
||||
#define BGFX_STENCIL_FUNC_RMASK_SHIFT 8
|
||||
#define BGFX_STENCIL_FUNC_RMASK_MASK UINT32_C(0x0000ff00)
|
||||
#define BGFX_STENCIL_FUNC_REF_SHIFT 0
|
||||
#define BGFX_STENCIL_FUNC_REF_MASK UINT32_C(0x000000ff)
|
||||
#define BGFX_STENCIL_FUNC_RMASK_SHIFT 8
|
||||
#define BGFX_STENCIL_FUNC_RMASK_MASK UINT32_C(0x0000ff00)
|
||||
|
||||
#define BGFX_STENCIL_TEST_LESS UINT32_C(0x00010000)
|
||||
#define BGFX_STENCIL_TEST_LEQUAL UINT32_C(0x00020000)
|
||||
#define BGFX_STENCIL_TEST_EQUAL UINT32_C(0x00030000)
|
||||
#define BGFX_STENCIL_TEST_GEQUAL UINT32_C(0x00040000)
|
||||
#define BGFX_STENCIL_TEST_GREATER UINT32_C(0x00050000)
|
||||
#define BGFX_STENCIL_TEST_NOTEQUAL UINT32_C(0x00060000)
|
||||
#define BGFX_STENCIL_TEST_NEVER UINT32_C(0x00070000)
|
||||
#define BGFX_STENCIL_TEST_ALWAYS UINT32_C(0x00080000)
|
||||
#define BGFX_STENCIL_TEST_SHIFT 16
|
||||
#define BGFX_STENCIL_TEST_MASK UINT32_C(0x000f0000)
|
||||
#define BGFX_STENCIL_TEST_LESS UINT32_C(0x00010000)
|
||||
#define BGFX_STENCIL_TEST_LEQUAL UINT32_C(0x00020000)
|
||||
#define BGFX_STENCIL_TEST_EQUAL UINT32_C(0x00030000)
|
||||
#define BGFX_STENCIL_TEST_GEQUAL UINT32_C(0x00040000)
|
||||
#define BGFX_STENCIL_TEST_GREATER UINT32_C(0x00050000)
|
||||
#define BGFX_STENCIL_TEST_NOTEQUAL UINT32_C(0x00060000)
|
||||
#define BGFX_STENCIL_TEST_NEVER UINT32_C(0x00070000)
|
||||
#define BGFX_STENCIL_TEST_ALWAYS UINT32_C(0x00080000)
|
||||
#define BGFX_STENCIL_TEST_SHIFT 16
|
||||
#define BGFX_STENCIL_TEST_MASK UINT32_C(0x000f0000)
|
||||
|
||||
#define BGFX_STENCIL_OP_FAIL_S_ZERO UINT32_C(0x00000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_KEEP UINT32_C(0x00100000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_REPLACE UINT32_C(0x00200000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_INCR UINT32_C(0x00300000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_INCRSAT UINT32_C(0x00400000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_DECR UINT32_C(0x00500000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_DECRSAT UINT32_C(0x00600000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_INVERT UINT32_C(0x00700000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_SHIFT 20
|
||||
#define BGFX_STENCIL_OP_FAIL_S_MASK UINT32_C(0x00f00000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_ZERO UINT32_C(0x00000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_KEEP UINT32_C(0x00100000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_REPLACE UINT32_C(0x00200000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_INCR UINT32_C(0x00300000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_INCRSAT UINT32_C(0x00400000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_DECR UINT32_C(0x00500000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_DECRSAT UINT32_C(0x00600000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_INVERT UINT32_C(0x00700000)
|
||||
#define BGFX_STENCIL_OP_FAIL_S_SHIFT 20
|
||||
#define BGFX_STENCIL_OP_FAIL_S_MASK UINT32_C(0x00f00000)
|
||||
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_ZERO UINT32_C(0x00000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_KEEP UINT32_C(0x01000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_REPLACE UINT32_C(0x02000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_INCR UINT32_C(0x03000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_INCRSAT UINT32_C(0x04000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_DECR UINT32_C(0x05000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_DECRSAT UINT32_C(0x06000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_INVERT UINT32_C(0x07000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_SHIFT 24
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_MASK UINT32_C(0x0f000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_ZERO UINT32_C(0x00000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_KEEP UINT32_C(0x01000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_REPLACE UINT32_C(0x02000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_INCR UINT32_C(0x03000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_INCRSAT UINT32_C(0x04000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_DECR UINT32_C(0x05000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_DECRSAT UINT32_C(0x06000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_INVERT UINT32_C(0x07000000)
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_SHIFT 24
|
||||
#define BGFX_STENCIL_OP_FAIL_Z_MASK UINT32_C(0x0f000000)
|
||||
|
||||
#define BGFX_STENCIL_OP_PASS_Z_ZERO UINT32_C(0x00000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_KEEP UINT32_C(0x10000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_REPLACE UINT32_C(0x20000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_INCR UINT32_C(0x30000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_INCRSAT UINT32_C(0x40000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_DECR UINT32_C(0x50000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_DECRSAT UINT32_C(0x60000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_INVERT UINT32_C(0x70000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_SHIFT 28
|
||||
#define BGFX_STENCIL_OP_PASS_Z_MASK UINT32_C(0xf0000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_ZERO UINT32_C(0x00000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_KEEP UINT32_C(0x10000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_REPLACE UINT32_C(0x20000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_INCR UINT32_C(0x30000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_INCRSAT UINT32_C(0x40000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_DECR UINT32_C(0x50000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_DECRSAT UINT32_C(0x60000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_INVERT UINT32_C(0x70000000)
|
||||
#define BGFX_STENCIL_OP_PASS_Z_SHIFT 28
|
||||
#define BGFX_STENCIL_OP_PASS_Z_MASK UINT32_C(0xf0000000)
|
||||
|
||||
#define BGFX_STENCIL_NONE UINT32_C(0x00000000)
|
||||
#define BGFX_STENCIL_MASK UINT32_C(0xffffffff)
|
||||
#define BGFX_STENCIL_DEFAULT UINT32_C(0x00000000)
|
||||
#define BGFX_STENCIL_NONE UINT32_C(0x00000000)
|
||||
#define BGFX_STENCIL_MASK UINT32_C(0xffffffff)
|
||||
#define BGFX_STENCIL_DEFAULT UINT32_C(0x00000000)
|
||||
|
||||
#define BGFX_STENCIL_FUNC_REF(_ref) ( (uint32_t(_ref)<<BGFX_STENCIL_FUNC_REF_SHIFT)&BGFX_STENCIL_FUNC_REF_MASK)
|
||||
#define BGFX_STENCIL_FUNC_RMASK(_mask) ( (uint32_t(_mask)<<BGFX_STENCIL_FUNC_RMASK_SHIFT)&BGFX_STENCIL_FUNC_RMASK_MASK)
|
||||
|
||||
///
|
||||
#define BGFX_CLEAR_NONE UINT8_C(0x00)
|
||||
#define BGFX_CLEAR_COLOR_BIT UINT8_C(0x01)
|
||||
#define BGFX_CLEAR_DEPTH_BIT UINT8_C(0x02)
|
||||
#define BGFX_CLEAR_STENCIL_BIT UINT8_C(0x04)
|
||||
#define BGFX_CLEAR_NONE UINT8_C(0x00)
|
||||
#define BGFX_CLEAR_COLOR_BIT UINT8_C(0x01)
|
||||
#define BGFX_CLEAR_DEPTH_BIT UINT8_C(0x02)
|
||||
#define BGFX_CLEAR_STENCIL_BIT UINT8_C(0x04)
|
||||
|
||||
///
|
||||
#define BGFX_DEBUG_NONE UINT32_C(0x00000000)
|
||||
#define BGFX_DEBUG_WIREFRAME UINT32_C(0x00000001)
|
||||
#define BGFX_DEBUG_IFH UINT32_C(0x00000002)
|
||||
#define BGFX_DEBUG_STATS UINT32_C(0x00000004)
|
||||
#define BGFX_DEBUG_TEXT UINT32_C(0x00000008)
|
||||
#define BGFX_DEBUG_NONE UINT32_C(0x00000000)
|
||||
#define BGFX_DEBUG_WIREFRAME UINT32_C(0x00000001)
|
||||
#define BGFX_DEBUG_IFH UINT32_C(0x00000002)
|
||||
#define BGFX_DEBUG_STATS UINT32_C(0x00000004)
|
||||
#define BGFX_DEBUG_TEXT UINT32_C(0x00000008)
|
||||
|
||||
///
|
||||
#define BGFX_TEXTURE_NONE UINT32_C(0x00000000)
|
||||
#define BGFX_TEXTURE_U_MIRROR UINT32_C(0x00000001)
|
||||
#define BGFX_TEXTURE_U_CLAMP UINT32_C(0x00000002)
|
||||
#define BGFX_TEXTURE_U_SHIFT 0
|
||||
#define BGFX_TEXTURE_U_MASK UINT32_C(0x00000003)
|
||||
#define BGFX_TEXTURE_V_MIRROR UINT32_C(0x00000010)
|
||||
#define BGFX_TEXTURE_V_CLAMP UINT32_C(0x00000020)
|
||||
#define BGFX_TEXTURE_V_SHIFT 4
|
||||
#define BGFX_TEXTURE_V_MASK UINT32_C(0x00000030)
|
||||
#define BGFX_TEXTURE_W_MIRROR UINT32_C(0x00000100)
|
||||
#define BGFX_TEXTURE_W_CLAMP UINT32_C(0x00000200)
|
||||
#define BGFX_TEXTURE_W_SHIFT 8
|
||||
#define BGFX_TEXTURE_W_MASK UINT32_C(0x00000300)
|
||||
#define BGFX_TEXTURE_MIN_POINT UINT32_C(0x00001000)
|
||||
#define BGFX_TEXTURE_MIN_ANISOTROPIC UINT32_C(0x00002000)
|
||||
#define BGFX_TEXTURE_MIN_SHIFT 12
|
||||
#define BGFX_TEXTURE_MIN_MASK UINT32_C(0x00003000)
|
||||
#define BGFX_TEXTURE_MAG_POINT UINT32_C(0x00010000)
|
||||
#define BGFX_TEXTURE_MAG_ANISOTROPIC UINT32_C(0x00020000)
|
||||
#define BGFX_TEXTURE_MAG_SHIFT 16
|
||||
#define BGFX_TEXTURE_MAG_MASK UINT32_C(0x00030000)
|
||||
#define BGFX_TEXTURE_MIP_POINT UINT32_C(0x00100000)
|
||||
#define BGFX_TEXTURE_MIP_SHIFT 20
|
||||
#define BGFX_TEXTURE_MIP_MASK UINT32_C(0x00100000)
|
||||
#define BGFX_TEXTURE_SRGB UINT32_C(0x00200000)
|
||||
#define BGFX_TEXTURE_NONE UINT32_C(0x00000000)
|
||||
#define BGFX_TEXTURE_U_MIRROR UINT32_C(0x00000001)
|
||||
#define BGFX_TEXTURE_U_CLAMP UINT32_C(0x00000002)
|
||||
#define BGFX_TEXTURE_U_SHIFT 0
|
||||
#define BGFX_TEXTURE_U_MASK UINT32_C(0x00000003)
|
||||
#define BGFX_TEXTURE_V_MIRROR UINT32_C(0x00000010)
|
||||
#define BGFX_TEXTURE_V_CLAMP UINT32_C(0x00000020)
|
||||
#define BGFX_TEXTURE_V_SHIFT 4
|
||||
#define BGFX_TEXTURE_V_MASK UINT32_C(0x00000030)
|
||||
#define BGFX_TEXTURE_W_MIRROR UINT32_C(0x00000100)
|
||||
#define BGFX_TEXTURE_W_CLAMP UINT32_C(0x00000200)
|
||||
#define BGFX_TEXTURE_W_SHIFT 8
|
||||
#define BGFX_TEXTURE_W_MASK UINT32_C(0x00000300)
|
||||
#define BGFX_TEXTURE_MIN_POINT UINT32_C(0x00001000)
|
||||
#define BGFX_TEXTURE_MIN_ANISOTROPIC UINT32_C(0x00002000)
|
||||
#define BGFX_TEXTURE_MIN_SHIFT 12
|
||||
#define BGFX_TEXTURE_MIN_MASK UINT32_C(0x00003000)
|
||||
#define BGFX_TEXTURE_MAG_POINT UINT32_C(0x00010000)
|
||||
#define BGFX_TEXTURE_MAG_ANISOTROPIC UINT32_C(0x00020000)
|
||||
#define BGFX_TEXTURE_MAG_SHIFT 16
|
||||
#define BGFX_TEXTURE_MAG_MASK UINT32_C(0x00030000)
|
||||
#define BGFX_TEXTURE_MIP_POINT UINT32_C(0x00100000)
|
||||
#define BGFX_TEXTURE_MIP_SHIFT 20
|
||||
#define BGFX_TEXTURE_MIP_MASK UINT32_C(0x00100000)
|
||||
#define BGFX_TEXTURE_SRGB UINT32_C(0x00200000)
|
||||
|
||||
///
|
||||
#define BGFX_RENDER_TARGET_NONE UINT32_C(0x00000000)
|
||||
#define BGFX_RENDER_TARGET_COLOR_RGBA UINT32_C(0x00000001)
|
||||
#define BGFX_RENDER_TARGET_COLOR_R32F UINT32_C(0x00000002)
|
||||
#define BGFX_RENDER_TARGET_COLOR_SHIFT 0
|
||||
#define BGFX_RENDER_TARGET_COLOR_MASK UINT32_C(0x000000ff)
|
||||
#define BGFX_RENDER_TARGET_DEPTH UINT32_C(0x00000100)
|
||||
#define BGFX_RENDER_TARGET_DEPTH_SHIFT 8
|
||||
#define BGFX_RENDER_TARGET_DEPTH_MASK UINT32_C(0x0000ff00)
|
||||
#define BGFX_RENDER_TARGET_MSAA_X2 UINT32_C(0x00010000)
|
||||
#define BGFX_RENDER_TARGET_MSAA_X4 UINT32_C(0x00020000)
|
||||
#define BGFX_RENDER_TARGET_MSAA_X8 UINT32_C(0x00030000)
|
||||
#define BGFX_RENDER_TARGET_MSAA_X16 UINT32_C(0x00040000)
|
||||
#define BGFX_RENDER_TARGET_MSAA_SHIFT 16
|
||||
#define BGFX_RENDER_TARGET_MSAA_MASK UINT32_C(0x00070000)
|
||||
#define BGFX_RENDER_TARGET_SRGBWRITE UINT32_C(0x00080000)
|
||||
#define BGFX_RENDER_TARGET_NONE UINT32_C(0x00000000)
|
||||
#define BGFX_RENDER_TARGET_COLOR_RGBA8 UINT32_C(0x00000001)
|
||||
#define BGFX_RENDER_TARGET_COLOR_RGB10A2 UINT32_C(0x00000002)
|
||||
#define BGFX_RENDER_TARGET_COLOR_RGBA16 UINT32_C(0x00000003)
|
||||
#define BGFX_RENDER_TARGET_COLOR_RGBA16F UINT32_C(0x00000004)
|
||||
#define BGFX_RENDER_TARGET_COLOR_R16F UINT32_C(0x00000005)
|
||||
#define BGFX_RENDER_TARGET_COLOR_R32F UINT32_C(0x00000006)
|
||||
#define BGFX_RENDER_TARGET_COLOR_SHIFT 0
|
||||
#define BGFX_RENDER_TARGET_COLOR_MASK UINT32_C(0x000000ff)
|
||||
#define BGFX_RENDER_TARGET_DEPTH UINT32_C(0x00000100)
|
||||
#define BGFX_RENDER_TARGET_DEPTH_SHIFT 8
|
||||
#define BGFX_RENDER_TARGET_DEPTH_MASK UINT32_C(0x0000ff00)
|
||||
#define BGFX_RENDER_TARGET_MSAA_X2 UINT32_C(0x00010000)
|
||||
#define BGFX_RENDER_TARGET_MSAA_X4 UINT32_C(0x00020000)
|
||||
#define BGFX_RENDER_TARGET_MSAA_X8 UINT32_C(0x00030000)
|
||||
#define BGFX_RENDER_TARGET_MSAA_X16 UINT32_C(0x00040000)
|
||||
#define BGFX_RENDER_TARGET_MSAA_SHIFT 16
|
||||
#define BGFX_RENDER_TARGET_MSAA_MASK UINT32_C(0x00070000)
|
||||
#define BGFX_RENDER_TARGET_SRGBWRITE UINT32_C(0x00080000)
|
||||
|
||||
///
|
||||
#define BGFX_RESET_NONE UINT32_C(0x00000000)
|
||||
#define BGFX_RESET_FULLSCREEN UINT32_C(0x00000001)
|
||||
#define BGFX_RESET_FULLSCREEN_SHIFT 0
|
||||
#define BGFX_RESET_FULLSCREEN_MASK UINT32_C(0x00000001)
|
||||
#define BGFX_RESET_MSAA_X2 UINT32_C(0x00000010)
|
||||
#define BGFX_RESET_MSAA_X4 UINT32_C(0x00000020)
|
||||
#define BGFX_RESET_MSAA_X8 UINT32_C(0x00000030)
|
||||
#define BGFX_RESET_MSAA_X16 UINT32_C(0x00000040)
|
||||
#define BGFX_RESET_MSAA_SHIFT 4
|
||||
#define BGFX_RESET_MSAA_MASK UINT32_C(0x00000070)
|
||||
#define BGFX_RESET_VSYNC UINT32_C(0x00000080)
|
||||
#define BGFX_RESET_CAPTURE UINT32_C(0x00000100)
|
||||
#define BGFX_RESET_NONE UINT32_C(0x00000000)
|
||||
#define BGFX_RESET_FULLSCREEN UINT32_C(0x00000001)
|
||||
#define BGFX_RESET_FULLSCREEN_SHIFT 0
|
||||
#define BGFX_RESET_FULLSCREEN_MASK UINT32_C(0x00000001)
|
||||
#define BGFX_RESET_MSAA_X2 UINT32_C(0x00000010)
|
||||
#define BGFX_RESET_MSAA_X4 UINT32_C(0x00000020)
|
||||
#define BGFX_RESET_MSAA_X8 UINT32_C(0x00000030)
|
||||
#define BGFX_RESET_MSAA_X16 UINT32_C(0x00000040)
|
||||
#define BGFX_RESET_MSAA_SHIFT 4
|
||||
#define BGFX_RESET_MSAA_MASK UINT32_C(0x00000070)
|
||||
#define BGFX_RESET_VSYNC UINT32_C(0x00000080)
|
||||
#define BGFX_RESET_CAPTURE UINT32_C(0x00000100)
|
||||
|
||||
///
|
||||
#define BGFX_HANDLE(_name) struct _name { uint16_t idx; }
|
||||
|
@ -656,7 +660,7 @@ namespace bgfx
|
|||
void destroyTexture(TextureHandle _handle);
|
||||
|
||||
/// Create render target.
|
||||
RenderTargetHandle createRenderTarget(uint16_t _width, uint16_t _height, uint32_t _flags = BGFX_RENDER_TARGET_COLOR_RGBA, uint32_t _textureFlags = BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
|
||||
RenderTargetHandle createRenderTarget(uint16_t _width, uint16_t _height, uint32_t _flags = BGFX_RENDER_TARGET_COLOR_RGBA8, uint32_t _textureFlags = BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
|
||||
|
||||
/// Destroy render target.
|
||||
void destroyRenderTarget(RenderTargetHandle _handle);
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace bgfx
|
|||
# include "glimports.h"
|
||||
# undef GL_IMPORT
|
||||
|
||||
void GlContext::create(uint32_t _width, uint32_t _height)
|
||||
void GlContext::create(uint32_t /*_width*/, uint32_t /*_height*/)
|
||||
{
|
||||
EGLNativeDisplayType ndt = EGL_DEFAULT_DISPLAY;
|
||||
EGLNativeWindowType nwt = (EGLNativeWindowType)NULL;
|
||||
|
@ -86,7 +86,7 @@ namespace bgfx
|
|||
m_context = NULL;
|
||||
}
|
||||
|
||||
void GlContext::resize(uint32_t _width, uint32_t _height)
|
||||
void GlContext::resize(uint32_t /*_width*/, uint32_t /*_height*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,10 @@ namespace bgfx
|
|||
{
|
||||
DXGI_FORMAT_UNKNOWN, // ignored
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||
DXGI_FORMAT_R10G10B10A2_UNORM,
|
||||
DXGI_FORMAT_R16G16B16A16_UNORM,
|
||||
DXGI_FORMAT_R16G16B16A16_FLOAT,
|
||||
DXGI_FORMAT_R16_FLOAT,
|
||||
DXGI_FORMAT_R32_FLOAT,
|
||||
};
|
||||
|
||||
|
|
|
@ -133,6 +133,10 @@ namespace bgfx
|
|||
{
|
||||
D3DFMT_UNKNOWN, // ignored
|
||||
D3DFMT_A8R8G8B8,
|
||||
D3DFMT_A2B10G10R10,
|
||||
D3DFMT_A16B16G16R16,
|
||||
D3DFMT_A16B16G16R16F,
|
||||
D3DFMT_R16F,
|
||||
D3DFMT_R32F,
|
||||
};
|
||||
|
||||
|
|
|
@ -57,6 +57,8 @@ namespace bgfx
|
|||
OES_vertex_array_object,
|
||||
ATI_meminfo,
|
||||
NVX_gpu_memory_info,
|
||||
OES_rgb8_rgba8,
|
||||
EXT_texture_storage,
|
||||
|
||||
Count
|
||||
};
|
||||
|
@ -109,8 +111,15 @@ namespace bgfx
|
|||
{ "OES_vertex_array_object", false, true },
|
||||
{ "GL_ATI_meminfo", false, true },
|
||||
{ "GL_NVX_gpu_memory_info", false, true },
|
||||
{ "GL_OES_rgb8_rgba8", false, true },
|
||||
{ "GL_EXT_texture_storage", false, true },
|
||||
};
|
||||
|
||||
#if BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
# define s_vertexAttribDivisor glVertexAttribDivisor
|
||||
# define s_drawArraysInstanced glDrawArraysInstanced
|
||||
# define s_drawElementsInstanced glDrawElementsInstanced
|
||||
#else
|
||||
static void GL_APIENTRY stubVertexAttribDivisor(GLuint /*_index*/, GLuint /*_divisor*/)
|
||||
{
|
||||
}
|
||||
|
@ -125,11 +134,6 @@ namespace bgfx
|
|||
GL_CHECK(glDrawElements(_mode, _count, _type, _indices) );
|
||||
}
|
||||
|
||||
#if BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
# define s_vertexAttribDivisor glVertexAttribDivisor
|
||||
# define s_drawArraysInstanced glDrawArraysInstanced
|
||||
# define s_drawElementsInstanced glDrawElementsInstanced
|
||||
#else
|
||||
static PFNGLVERTEXATTRIBDIVISORBGFXPROC s_vertexAttribDivisor = stubVertexAttribDivisor;
|
||||
static PFNGLDRAWARRAYSINSTANCEDBGFXPROC s_drawArraysInstanced = stubDrawArraysInstanced;
|
||||
static PFNGLDRAWELEMENTSINSTANCEDBGFXPROC s_drawElementsInstanced = stubDrawElementsInstanced;
|
||||
|
@ -246,6 +250,10 @@ namespace bgfx
|
|||
|
||||
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_backBufferFbo) );
|
||||
}
|
||||
#else
|
||||
BX_UNUSED(_width);
|
||||
BX_UNUSED(_height);
|
||||
BX_UNUSED(_msaa);
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
}
|
||||
|
||||
|
@ -610,11 +618,15 @@ namespace bgfx
|
|||
// Specifies the internal format of the texture.
|
||||
// Must be one of the following symbolic constants:
|
||||
// GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA.
|
||||
static const GLenum s_colorFormat[] =
|
||||
static const GLenum s_colorFormat[][2] =
|
||||
{
|
||||
0, // ignored
|
||||
GL_RGBA,
|
||||
GL_RGBA,
|
||||
{ 0, 0 }, // ignored
|
||||
{ GL_RGBA8, GL_UNSIGNED_BYTE },
|
||||
{ GL_RGB10_A2, GL_UNSIGNED_INT_2_10_10_10_REV },
|
||||
{ GL_RGBA16, GL_UNSIGNED_SHORT },
|
||||
{ GL_RGBA16F, GL_HALF_FLOAT },
|
||||
{ GL_R16F, GL_HALF_FLOAT },
|
||||
{ GL_R32F, GL_FLOAT },
|
||||
};
|
||||
|
||||
static const GLenum s_depthFormat[] =
|
||||
|
@ -1418,10 +1430,10 @@ namespace bgfx
|
|||
GL_CHECK(glBindTexture(m_target, 0) );
|
||||
}
|
||||
|
||||
void Texture::createColor(uint32_t _width, uint32_t _height, GLenum _min, GLenum _mag)
|
||||
void Texture::createColor(uint32_t _colorFormat, uint32_t _width, uint32_t _height, GLenum _min, GLenum _mag)
|
||||
{
|
||||
GLenum internalFormat = /*_fp ? GL_RGBA16F_ARB :*/ GL_RGBA;
|
||||
GLenum type = /*_fp ? GL_HALF_FLOAT_ARB :*/ GL_UNSIGNED_BYTE;
|
||||
GLenum internalFormat = s_colorFormat[_colorFormat][0];
|
||||
GLenum type = s_colorFormat[_colorFormat][1];
|
||||
m_target = GL_TEXTURE_2D;
|
||||
|
||||
GL_CHECK(glGenTextures(1, &m_id) );
|
||||
|
@ -1488,6 +1500,9 @@ namespace bgfx
|
|||
|
||||
void Texture::update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, const Memory* _mem)
|
||||
{
|
||||
BX_UNUSED(_z);
|
||||
BX_UNUSED(_depth);
|
||||
|
||||
GL_CHECK(glBindTexture(m_target, m_id) );
|
||||
GL_CHECK(glPixelStorei(GL_UNPACK_ALIGNMENT, 1) );
|
||||
|
||||
|
@ -1604,7 +1619,7 @@ namespace bgfx
|
|||
|
||||
if (0 < colorFormat)
|
||||
{
|
||||
m_color.createColor(_width, _height, minFilter, magFilter);
|
||||
m_color.createColor(colorFormat, _width, _height, minFilter, magFilter);
|
||||
}
|
||||
|
||||
#if 0 // GLES can't create texture with depth texture format...
|
||||
|
@ -1624,7 +1639,7 @@ namespace bgfx
|
|||
GL_CHECK(glGenRenderbuffers(1, &m_colorRbo) );
|
||||
BX_CHECK(0 != m_colorRbo, "Failed to generate color renderbuffer id.");
|
||||
GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, m_colorRbo) );
|
||||
GL_CHECK(glRenderbufferStorageMultisample(GL_RENDERBUFFER, m_msaa, GL_RGBA8, _width, _height) );
|
||||
GL_CHECK(glRenderbufferStorageMultisample(GL_RENDERBUFFER, m_msaa, s_colorFormat[colorFormat][0], _width, _height) );
|
||||
GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, 0) );
|
||||
|
||||
GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER
|
||||
|
|
|
@ -74,7 +74,10 @@
|
|||
# define glGenVertexArrays glGenVertexArraysOES
|
||||
# define GL_PROGRAM_BINARY_LENGTH GL_PROGRAM_BINARY_LENGTH_OES
|
||||
# define GL_HALF_FLOAT GL_HALF_FLOAT_OES
|
||||
# define GL_RGBA8 GL_RGBA8_OES
|
||||
# define GL_RGB10_A2 GL_RGB10_A2_EXT
|
||||
# define GL_R16F GL_R16F_EXT
|
||||
# define GL_R32F GL_R32F_EXT
|
||||
# define GL_UNSIGNED_INT_2_10_10_10_REV GL_UNSIGNED_INT_2_10_10_10_REV_EXT
|
||||
# define GL_SAMPLER_3D GL_SAMPLER_3D_OES
|
||||
# elif BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
|
@ -105,6 +108,10 @@ typedef void (*PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC)(GLuint shader, GLsizei b
|
|||
# define GL_BGRA_EXT 0x80E1
|
||||
# endif // GL_BGRA_EXT
|
||||
|
||||
# ifndef GL_R32F_EXT
|
||||
# define GL_R32F_EXT 0x822E
|
||||
# endif // GL_R32F_EXT
|
||||
|
||||
# ifndef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
|
||||
# define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
|
||||
# endif // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
|
||||
|
@ -438,7 +445,7 @@ namespace bgfx
|
|||
}
|
||||
|
||||
void create(const Memory* _mem, uint32_t _flags);
|
||||
void createColor(uint32_t _width, uint32_t _height, GLenum _min, GLenum _mag);
|
||||
void createColor(uint32_t _colorFormat, uint32_t _width, uint32_t _height, GLenum _min, GLenum _mag);
|
||||
void createDepth(uint32_t _width, uint32_t _height);
|
||||
void destroy();
|
||||
void update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, const Memory* _mem);
|
||||
|
|
Loading…
Reference in a new issue