mirror of https://github.com/axmolengine/axmol.git
Director supports setting clear color
This commit is contained in:
parent
ca932a38e4
commit
b925689435
|
@ -158,6 +158,12 @@ bool Director::init(void)
|
||||||
|
|
||||||
_console = new (std::nothrow) Console;
|
_console = new (std::nothrow) Console;
|
||||||
|
|
||||||
|
// default clear color
|
||||||
|
_clearColor.r = 0;
|
||||||
|
_clearColor.g = 0;
|
||||||
|
_clearColor.b = 0;
|
||||||
|
_clearColor.a = 1.0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +248,7 @@ void Director::setGLDefaultValues()
|
||||||
setProjection(_projection);
|
setProjection(_projection);
|
||||||
|
|
||||||
// set other opengl default values
|
// set other opengl default values
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
glClearColor(_clearColor.r, _clearColor.g, _clearColor.b, _clearColor.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the Scene
|
// Draw the Scene
|
||||||
|
@ -705,6 +711,12 @@ void Director::setDepthTest(bool on)
|
||||||
CHECK_GL_ERROR_DEBUG();
|
CHECK_GL_ERROR_DEBUG();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Director::setClearColor(const Color4F& clearColor)
|
||||||
|
{
|
||||||
|
_clearColor = clearColor;
|
||||||
|
glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
|
||||||
|
}
|
||||||
|
|
||||||
static void GLToClipTransform(Mat4 *transformOut)
|
static void GLToClipTransform(Mat4 *transformOut)
|
||||||
{
|
{
|
||||||
if(nullptr == transformOut) return;
|
if(nullptr == transformOut) return;
|
||||||
|
|
|
@ -323,6 +323,9 @@ public:
|
||||||
/** enables/disables OpenGL alpha blending */
|
/** enables/disables OpenGL alpha blending */
|
||||||
void setAlphaBlending(bool on);
|
void setAlphaBlending(bool on);
|
||||||
|
|
||||||
|
/** set clear values for the color buffers, value range of each element is [0.0, 1.0] */
|
||||||
|
void setClearColor(const Color4F& clearColor);
|
||||||
|
|
||||||
/** enables/disables OpenGL depth test */
|
/** enables/disables OpenGL depth test */
|
||||||
void setDepthTest(bool on);
|
void setDepthTest(bool on);
|
||||||
|
|
||||||
|
@ -463,6 +466,9 @@ protected:
|
||||||
unsigned int _totalFrames;
|
unsigned int _totalFrames;
|
||||||
float _secondsPerFrame;
|
float _secondsPerFrame;
|
||||||
|
|
||||||
|
/* clear color set outside be used in setGLDefaultValues() */
|
||||||
|
Color4F _clearColor;
|
||||||
|
|
||||||
/* The running scene */
|
/* The running scene */
|
||||||
Scene *_runningScene;
|
Scene *_runningScene;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue