First cut at custom pipelines

This commit is contained in:
Atlante45 2015-12-16 17:20:51 -08:00
parent 9d6618c341
commit d8a389ff92
2 changed files with 13 additions and 3 deletions

View file

@ -11,6 +11,8 @@
#include "DebugDeferredBuffer.h"
#include <QFile>
#include <gpu/Batch.h>
#include <gpu/Context.h>
#include <render/Scene.h>
@ -32,6 +34,14 @@ enum Slots {
Lighting
};
static std::string getFileContent(std::string fileName, std::string defaultContent = std::string()) {
QFile customFile(QString::fromStdString(fileName));
if (customFile.open(QIODevice::ReadOnly)) {
return customFile.readAll().toStdString();
}
return defaultContent;
}
std::string DebugDeferredBuffer::getShaderSourceCode(Modes mode) {
switch (mode) {
case DiffuseMode:
@ -49,7 +59,7 @@ std::string DebugDeferredBuffer::getShaderSourceCode(Modes mode) {
case LightingMode:
return "vec4 getFragmentColor() { return vec4(pow(texture(lightingMap, uv).xyz, vec3(1.0 / 2.2)), 1.0); }";
case CustomMode:
return "vec4 getFragmentColor() { return vec4(1.0); }";
return getFileContent(CUSTOM_FILE, "vec4 getFragmentColor() { return vec4(1.0); }");
}
}
@ -58,8 +68,6 @@ bool DebugDeferredBuffer::pipelineNeedsUpdate(Modes mode) const {
return !_pipelines[mode];
}
return true;
}

View file

@ -33,6 +33,8 @@ private:
CustomMode // Needs to stay last
};
const std::string CUSTOM_FILE { "/Users/clement/Desktop/custom.slh" };
bool pipelineNeedsUpdate(Modes mode) const;
const gpu::PipelinePointer& getPipeline(Modes mode);
std::string getShaderSourceCode(Modes mode);