Fixing the blackout when entering a zone with a skybox thatis not loaded yet or just a constant color skybox

This commit is contained in:
Sam Gateau 2015-06-10 01:50:52 -07:00
parent dd84bf010b
commit 2785f1a0e2
2 changed files with 56 additions and 53 deletions

View file

@ -44,7 +44,8 @@ void Skybox::setCubemap(const gpu::TexturePointer& cubemap) {
void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Skybox& skybox) {
if (skybox.getCubemap() && skybox.getCubemap()->isDefined()) {
if (skybox.getCubemap()) {
if (skybox.getCubemap()->isDefined()) {
static gpu::PipelinePointer thePipeline;
static gpu::BufferPointer theBuffer;
@ -104,10 +105,12 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky
batch.setInputFormat(theFormat);
batch.setUniformTexture(0, skybox.getCubemap());
batch.draw(gpu::TRIANGLE_STRIP, 4);
}
} else {
// skybox has no cubemap, just clear the color buffer
auto color = skybox.getColor();
batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(color, 1.0f), 0.f, 0);
batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(color, 0.0f), 0.f, 0);
}
}

View file

@ -218,7 +218,7 @@ public:
virtual void update(const UpdateFunctorPointer& functor) = 0;
virtual const model::MaterialKey& getMaterialKey() const = 0;
virtual const model::MaterialKey getMaterialKey() const = 0;
~PayloadInterface() {}
protected:
@ -283,7 +283,7 @@ template <class T> const Item::Bound payloadGetBound(const std::shared_ptr<T>& p
template <class T> void payloadRender(const std::shared_ptr<T>& payloadData, RenderArgs* args) { }
// Shape type interface
template <class T> const model::MaterialKey& shapeGetMaterialKey(const std::shared_ptr<T>& payloadData) { return model::MaterialKey(); }
template <class T> const model::MaterialKey shapeGetMaterialKey(const std::shared_ptr<T>& payloadData) { return model::MaterialKey(); }
template <class T> class Payload : public Item::PayloadInterface {
public:
@ -298,7 +298,7 @@ public:
virtual void render(RenderArgs* args) { payloadRender<T>(_data, args); }
// Shape Type interface
virtual const model::MaterialKey& getMaterialKey() const { return shapeGetMaterialKey<T>(_data); }
virtual const model::MaterialKey getMaterialKey() const { return shapeGetMaterialKey<T>(_data); }
Payload(const DataPointer& data) : _data(data) {}
protected: