View BasicParticleUpdaters.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "particleUpdaters.h" | |
#include <assert.h> | |
#include <algorithm> | |
#include <glm/common.hpp> | |
#include <glm/gtc/random.hpp> | |
namespace particles | |
{ | |
namespace updaters | |
{ |
View dbgheap.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// simple perf test for memory allocations | |
// bfilipek.com | |
#include <iostream> | |
#include <memory> | |
#include <vector> | |
#include <chrono> | |
int main() | |
{ |
View CalcTexPixels.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void CalculateTextureObjectPixels(GLuint texID, unsigned long *pixelCount, unsigned long *memoryUsed) | |
{ | |
int baseLevel = 0, maxLevel = 0; | |
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, &baseLevel); | |
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, &maxLevel); | |
long pixels = 0, bytes = 0, bpp = 0; | |
int texW = 0, texH = 0, texFmt = 0, compressed = 0, compressedBytes = 0; | |
for (int level = baseLevel; level <= maxLevel; ++level) | |
{ |
View LegacySinkAndUniquePtr.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// compile at https://godbolt.org/g/yb47Aq | |
// | |
#include <iostream> | |
#include <memory> | |
class Widget | |
{ | |
public: | |
void DoStuff() { } |
View glParticleRenderer.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "glParticleRenderer.h" | |
#include "particles.h" | |
#include <assert.h> | |
#include "gl_includes.h" | |
namespace particles | |
{ | |
void GLParticleRenderer::generate(ParticleSystem *sys, bool) | |
{ |
View HasToString.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
class HasToString | |
{ | |
private: | |
typedef char YesType[1]; | |
typedef char NoType[2]; | |
template <typename C> static YesType& test( decltype(&C::ToString) ) ; | |
template <typename C> static NoType& test(...); |
View smart_ptr_deleters.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// smart_ptr_deleters.cpp | |
// shows how to use custom deleters with unique_ptr and shared_ptr | |
// Bartlomiej Filipek, April 2016, bfilipek.com | |
#include <iostream> | |
#include <memory> | |
#include <functional> | |
#include <cassert> | |
// This class cannot be changed, might come from 3rd party library |
View BasicParticles.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "particles.h" | |
#include <assert.h> | |
#include <algorithm> | |
namespace particles | |
{ | |
void ParticleData::generate(size_t maxSize) | |
{ | |
m_count = maxSize; | |
m_countAlive = 0; |
View BasicParticleGenerators.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "particleGenerators.h" | |
#include <assert.h> | |
#include <algorithm> | |
#include <glm/common.hpp> | |
#include <glm/gtc/random.hpp> | |
namespace particles | |
{ | |
namespace generators | |
{ |
View ParticleUpdaters.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace updaters | |
{ | |
void EulerUpdater::update(double dt, ParticleData *p) | |
{ | |
const glm::vec4 globalA{ dt * m_globalAcceleration.x, dt * m_globalAcceleration.y, dt * m_globalAcceleration.z, 0.0 }; | |
const float localDT = (float)dt; | |
const unsigned int endId = p->m_countAlive; | |
for (size_t i = 0; i < endId; ++i) | |
p->m_acc[i] += globalA; |
OlderNewer