Fix clearcolor overwrite bug

change test case for FrameBufferObject
This commit is contained in:
Huabing.Xu 2015-05-13 17:40:10 +08:00
parent 6097b4ddd2
commit 8311cf8920
2 changed files with 16 additions and 2 deletions

View File

@ -693,6 +693,7 @@ void Renderer::clear()
{
//Enable Depth mask to make sure glClear clear the depth buffer correctly
glDepthMask(true);
glClearColor(_clearColor.r, _clearColor.g, _clearColor.b, _clearColor.a);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDepthMask(false);
@ -1060,7 +1061,6 @@ bool Renderer::checkVisibility(const Mat4 &transform, const Size &size)
void Renderer::setClearColor(const Color4F &clearColor)
{
_clearColor = clearColor;
glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
}
NS_CC_END

View File

@ -1435,8 +1435,21 @@ void CameraFrameBufferObjectTest::onEnter()
auto fbo = FrameBufferObject::create(1, sizeInpixels.width, sizeInpixels.height);
CameraBaseTest::onEnter();
auto sprite = Sprite::createWithTexture(fbo);
//auto sprite = Sprite::createWithTexture(fbo);
//sprite->setPosition(Vec2(100,100));
std::string filename = "Sprite3DTest/girl.c3b";
auto sprite = Sprite3D::create(filename);
sprite->setScale(1.0);
auto animation = Animation3D::create(filename);
if (animation)
{
auto animate = Animate3D::create(animation);
sprite->runAction(RepeatForever::create(animate));
}
sprite->setPosition(Vec2(100,100));
sprite->setTexture(fbo);
addChild(sprite);
auto sprite2 = Sprite::create(s_pathGrossini);
@ -1455,5 +1468,6 @@ void CameraFrameBufferObjectTest::onEnter()
camera->setCameraFlag(CameraFlag::USER1);
camera->setDepth(-1);
camera->setFrameBufferObject(fbo);
fbo->setClearColor(Color4F(1,1,1,1));
addChild(camera);
}