Cogs.Core
BasicBlueNoiseManager.cpp
1#include "BasicBlueNoiseManager.h"
2
3#include "TextureManager.h"
4
5#include "Services/Random.h"
6#include "Services/Variables.h"
7
8#include "Foundation/Logging/Logger.h"
9
10namespace
11{
12 Cogs::Logging::Log logger = Cogs::Logging::getLogger("BasicBlueNoiseManager");
13}
14
15namespace Cogs::Core
16{
17 BasicBlueNoiseManager::BasicBlueNoiseManager(Context *context):
18 ResourceManager(context)
19 {
20 blueNoise = BlueNoiseHandle::NoHandle;
21 }
22 BasicBlueNoiseManager::~BasicBlueNoiseManager()
23 {
24 reportLeaks("BasicBlueNoise");
25 }
26
27 void BasicBlueNoiseManager::initialize()
28 {
29 ResourceManager::initialize();
30 }
31
32 void BasicBlueNoiseManager::handleEnable()
33 {
34 enabled = true;
35 std::string name = "Textures/BlueNoise/LDR_RGBA.png";
36 blueNoise = loadBlueNoise(name.c_str(), getNextResourceId());
37 LOG_DEBUG(logger, "Enabled basic blue noise manager.");
38 }
39
40 void BasicBlueNoiseManager::clear()
41 {
42 blueNoise = BlueNoiseHandle::NoHandle;
43 ResourceManager::clear();
44 enabled = false;
45 }
46
47 BlueNoiseHandle BasicBlueNoiseManager::loadBlueNoise(const std::string & name, const ResourceId resourceId)
48 {
49 auto textureManager = context->textureManager;
50
51 BlueNoiseHandle handle = getOrCreate(resourceId);
52
53 auto texture = textureManager->loadTexture(name, textureManager->getNextResourceId(), TextureLoadFlags::NoMipMaps);
54 if(HandleIsValid(texture)){
55 handle->texture = texture;
56 //texture->setName("BlueNoise:" + blueNoise->getName());
57 }
58
59 return handle;
60 }
61
62 BlueNoiseHandle BasicBlueNoiseManager::getBlueNoiseHandle(bool /*stable*/) {
63 return blueNoise;
64 }
65}
Log implementation class.
Definition: LogManager.h:139
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
bool HandleIsValid(const ResourceHandle_t< T > &handle)
Check if the given resource is valid, that is not equal to NoHandle or InvalidHandle.
constexpr Log getLogger(const char(&name)[LEN]) noexcept
Definition: LogManager.h:180