Add JS and Lua bindings for CCCameraBackgroundBrush

This commit is contained in:
pandamicro 2015-08-21 12:18:36 +08:00
parent 350182c1aa
commit 006f300ac9
4 changed files with 55 additions and 6 deletions

View File

@ -203,6 +203,12 @@ CameraBackgroundColorBrush::~CameraBackgroundColorBrush()
}
bool CameraBackgroundColorBrush::init()
{
this->_clearColor = GL_TRUE;
return true;
}
void CameraBackgroundColorBrush::setColor(const Color4F& color)
{
_quad.bl.colors = _quad.br.colors = _quad.tl.colors = _quad.tr.colors = Color4B(color);
@ -212,7 +218,6 @@ CameraBackgroundColorBrush* CameraBackgroundColorBrush::create(const Color4F& co
{
auto ret = new (std::nothrow) CameraBackgroundColorBrush();
ret->init();
ret->_clearColor = GL_TRUE;
ret->setColor(color);
ret->setDepth(depth);

View File

@ -107,10 +107,10 @@ public:
CC_CONSTRUCTOR_ACCESS:
CameraBackgroundBrush();
virtual ~CameraBackgroundBrush();
protected:
virtual bool init() { return true; }
protected:
GLProgramState* _glProgramState;
};
@ -147,10 +147,10 @@ public:
CC_CONSTRUCTOR_ACCESS:
CameraBackgroundDepthBrush();
virtual ~CameraBackgroundDepthBrush();
protected:
virtual bool init() override;
protected:
float _depth;
GLboolean _clearColor;
@ -187,9 +187,10 @@ public:
CC_CONSTRUCTOR_ACCESS:
CameraBackgroundColorBrush();
virtual ~CameraBackgroundColorBrush();
virtual bool init() override;
protected:
Color4F _color;
};
@ -245,6 +246,7 @@ CC_CONSTRUCTOR_ACCESS:
*/
virtual bool init() override;
protected:
void initBuffer();
GLuint _vao;

View File

@ -39,6 +39,13 @@ cc.Camera.Mode = {
PERSPECTIVE : 1,
ORTHOGRAPHIC : 2
};
cc.CameraBackgroundBrush.BrushType = {
NONE : 0,
DEPTH : 1,
COLOR : 2,
SKYBOX : 3
};
cc.LightType = {
DIRECTIONAL : 0,
POINT : 1,
@ -464,6 +471,33 @@ cc.Camera.prototype._ctor = function(cameraMode, first, second, third, fourth){
}
}
cc.CameraBackgroundBrush.prototype._ctor = function () {
this.init();
}
cc.CameraBackgroundDepthBrush.prototype._ctor = function (depth) {
if (depth !== undefined)
this.setDepth(depth);
this.init();
}
cc.CameraBackgroundColorBrush.prototype._ctor = function (color, depth) {
this.init();
if (depth !== undefined) {
this.setColor(color);
this.setDepth(depth);
}
}
cc.CameraBackgroundSkyBoxBrush.prototype._ctor = function (positive_x, negative_x, positive_y, negative_y, positive_z, negative_z)
{
if (negative_z !== undefined) {
var texture = jsb.TextureCube.create(positive_x, negative_x, positive_y, negative_y, positive_z, negative_z);
if (texture) {
texture.setTexParameters(gl.LINEAR, gl.LINEAR, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE);
this.setTexture(texture);
}
}
this.init();
}
/**
* static Physics3DShape* createBox(const cocos2d::Vec3& extent);
* static Physics3DShape* createSphere(float radius);

View File

@ -550,6 +550,14 @@ cc.CameraFlag =
USER8 = 256,
}
cc.CameraBackgroundBrush.BrushType =
{
NONE = 0,
DEPTH = 1,
COLOR = 2,
SKYBOX = 3,
}
cc.BillBoard_Mode =
{
VIEW_POINT_ORIENTED = 0,