mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
Added destroy shaders option when creating program.
This commit is contained in:
parent
877621105d
commit
7884a72df2
2 changed files with 15 additions and 5 deletions
|
@ -835,10 +835,12 @@ namespace bgfx
|
||||||
///
|
///
|
||||||
/// @param _vsh Vertex shader.
|
/// @param _vsh Vertex shader.
|
||||||
/// @param _fsh Fragment 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
|
/// @returns Program handle if vertex shader output and fragment shader
|
||||||
/// input are matching, otherwise returns invalid program handle.
|
/// input are matching, otherwise returns invalid program handle.
|
||||||
///
|
///
|
||||||
ProgramHandle createProgram(VertexShaderHandle _vsh, FragmentShaderHandle _fsh);
|
ProgramHandle createProgram(VertexShaderHandle _vsh, FragmentShaderHandle _fsh, bool _destroyShaders = false);
|
||||||
|
|
||||||
/// Destroy program.
|
/// Destroy program.
|
||||||
void destroyProgram(ProgramHandle _handle);
|
void destroyProgram(ProgramHandle _handle);
|
||||||
|
@ -974,8 +976,8 @@ namespace bgfx
|
||||||
///
|
///
|
||||||
/// @param _num Number of texture attachments.
|
/// @param _num Number of texture attachments.
|
||||||
/// @param _handles Texture attachments.
|
/// @param _handles Texture attachments.
|
||||||
/// @param _destroyTextures Destroy textures when frame buffer is
|
/// @param _destroyTextures If true, textures will be destroyed when
|
||||||
/// destroyed.
|
/// frame buffer is destroyed.
|
||||||
///
|
///
|
||||||
FrameBufferHandle createFrameBuffer(uint8_t _num, TextureHandle* _handles, bool _destroyTextures = false);
|
FrameBufferHandle createFrameBuffer(uint8_t _num, TextureHandle* _handles, bool _destroyTextures = false);
|
||||||
|
|
||||||
|
|
12
src/bgfx.cpp
12
src/bgfx.cpp
|
@ -1856,10 +1856,18 @@ namespace bgfx
|
||||||
s_ctx->destroyFragmentShader(_handle);
|
s_ctx->destroyFragmentShader(_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgramHandle createProgram(VertexShaderHandle _vsh, FragmentShaderHandle _fsh)
|
ProgramHandle createProgram(VertexShaderHandle _vsh, FragmentShaderHandle _fsh, bool _destroyShaders)
|
||||||
{
|
{
|
||||||
BGFX_CHECK_MAIN_THREAD();
|
BGFX_CHECK_MAIN_THREAD();
|
||||||
return s_ctx->createProgram(_vsh, _fsh);
|
ProgramHandle handle = s_ctx->createProgram(_vsh, _fsh);
|
||||||
|
|
||||||
|
if (_destroyShaders)
|
||||||
|
{
|
||||||
|
destroyVertexShader(_vsh);
|
||||||
|
destroyFragmentShader(_fsh);
|
||||||
|
}
|
||||||
|
|
||||||
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyProgram(ProgramHandle _handle)
|
void destroyProgram(ProgramHandle _handle)
|
||||||
|
|
Loading…
Reference in a new issue