summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/ps/particle_system.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/examples/common/ps/particle_system.cpp')
-rw-r--r--3rdparty/bgfx/examples/common/ps/particle_system.cpp85
1 files changed, 19 insertions, 66 deletions
diff --git a/3rdparty/bgfx/examples/common/ps/particle_system.cpp b/3rdparty/bgfx/examples/common/ps/particle_system.cpp
index 34ea0261969..7ad93331a37 100644
--- a/3rdparty/bgfx/examples/common/ps/particle_system.cpp
+++ b/3rdparty/bgfx/examples/common/ps/particle_system.cpp
@@ -11,7 +11,6 @@
#include "../packrect.h"
#include <bx/easing.h>
-#include <bx/crtimpl.h>
#include <bx/handlealloc.h>
#include "vs_particle.bin.h"
@@ -25,52 +24,6 @@ static const bgfx::EmbeddedShader s_embeddedShaders[] =
BGFX_EMBEDDED_SHADER_END()
};
-static const bx::EaseFn s_easeFunc[] =
-{
- bx::easeLinear,
- bx::easeInQuad,
- bx::easeOutQuad,
- bx::easeInOutQuad,
- bx::easeOutInQuad,
- bx::easeInCubic,
- bx::easeOutCubic,
- bx::easeInOutCubic,
- bx::easeOutInCubic,
- bx::easeInQuart,
- bx::easeOutQuart,
- bx::easeInOutQuart,
- bx::easeOutInQuart,
- bx::easeInQuint,
- bx::easeOutQuint,
- bx::easeInOutQuint,
- bx::easeOutInQuint,
- bx::easeInSine,
- bx::easeOutSine,
- bx::easeInOutSine,
- bx::easeOutInSine,
- bx::easeInExpo,
- bx::easeOutExpo,
- bx::easeInOutExpo,
- bx::easeOutInExpo,
- bx::easeInCirc,
- bx::easeOutCirc,
- bx::easeInOutCirc,
- bx::easeOutInCirc,
- bx::easeInElastic,
- bx::easeOutElastic,
- bx::easeInOutElastic,
- bx::easeOutInElastic,
- bx::easeInBack,
- bx::easeOutBack,
- bx::easeInOutBack,
- bx::easeOutInBack,
- bx::easeInBounce,
- bx::easeOutBounce,
- bx::easeInOutBounce,
- bx::easeOutInBounce,
-};
-BX_STATIC_ASSERT(BX_COUNTOF(s_easeFunc) == bx::Easing::Count);
-
struct PosColorTexCoord0Vertex
{
float m_x;
@@ -195,7 +148,7 @@ namespace ps
EmitterSpriteHandle create(uint16_t _width, uint16_t _height)
{
- EmitterSpriteHandle handle = { bx::HandleAlloc::invalid };
+ EmitterSpriteHandle handle = { bx::kInvalidHandle };
if (m_handleAlloc.getNumHandles() < m_handleAlloc.getMaxHandles() )
{
@@ -234,8 +187,12 @@ namespace ps
void reset()
{
+ m_dt = 0.0f;
+ m_uniforms.reset();
m_num = 0;
bx::memSet(&m_aabb, 0, sizeof(Aabb) );
+
+ m_rng.reset();
}
void update(float _dt)
@@ -368,15 +325,15 @@ namespace ps
uint32_t render(const float _uv[4], const float* _mtxView, const float* _eye, uint32_t _first, uint32_t _max, ParticleSort* _outSort, PosColorTexCoord0Vertex* _outVertices)
{
- bx::EaseFn easeRgba = s_easeFunc[m_uniforms.m_easeRgba];
- bx::EaseFn easePos = s_easeFunc[m_uniforms.m_easePos];
- bx::EaseFn easeBlend = s_easeFunc[m_uniforms.m_easeBlend];
- bx::EaseFn easeScale = s_easeFunc[m_uniforms.m_easeScale];
+ bx::EaseFn easeRgba = bx::getEaseFunc(m_uniforms.m_easeRgba);
+ bx::EaseFn easePos = bx::getEaseFunc(m_uniforms.m_easePos);
+ bx::EaseFn easeBlend = bx::getEaseFunc(m_uniforms.m_easeBlend);
+ bx::EaseFn easeScale = bx::getEaseFunc(m_uniforms.m_easeScale);
Aabb aabb =
{
- { bx::huge, bx::huge, bx::huge },
- { -bx::huge, -bx::huge, -bx::huge },
+ { bx::kHuge, bx::kHuge, bx::kHuge },
+ { -bx::kHuge, -bx::kHuge, -bx::kHuge },
};
for (uint32_t jj = 0, num = m_num, current = _first
@@ -494,13 +451,11 @@ namespace ps
{
m_allocator = _allocator;
-#if BX_CONFIG_ALLOCATOR_CRT
if (NULL == _allocator)
{
- static bx::CrtAllocator allocator;
+ static bx::DefaultAllocator allocator;
m_allocator = &allocator;
}
-#endif // BX_CONFIG_ALLOCATOR_CRT
m_emitterAlloc = bx::createHandleAlloc(m_allocator, _maxEmitters);
m_emitter = (Emitter*)BX_ALLOC(m_allocator, sizeof(Emitter)*_maxEmitters);
@@ -528,9 +483,9 @@ namespace ps
void shutdown()
{
- bgfx::destroyProgram(m_particleProgram);
- bgfx::destroyTexture(m_texture);
- bgfx::destroyUniform(s_texColor);
+ bgfx::destroy(m_particleProgram);
+ bgfx::destroy(m_texture);
+ bgfx::destroy(s_texColor);
bx::destroyHandleAlloc(m_allocator, m_emitterAlloc);
BX_FREE(m_allocator, m_emitter);
@@ -655,7 +610,7 @@ namespace ps
| BGFX_STATE_CULL_CW
| BGFX_STATE_BLEND_NORMAL
);
- bgfx::setVertexBuffer(&tvb);
+ bgfx::setVertexBuffer(0, &tvb);
bgfx::setIndexBuffer(&tib);
bgfx::setTexture(0, s_texColor, m_texture);
bgfx::submit(_view, m_particleProgram);
@@ -733,13 +688,11 @@ namespace ps
void Emitter::create(EmitterShape::Enum _shape, EmitterDirection::Enum _direction, uint32_t _maxParticles)
{
- m_dt = 0.0f;
- m_uniforms.reset();
+ reset();
+
m_shape = _shape;
m_direction = _direction;
-
- m_num = 0;
- m_max = _maxParticles;
+ m_max = _maxParticles;
m_particles = (Particle*)BX_ALLOC(s_ctx.m_allocator, m_max*sizeof(Particle) );
}