mirror of https://github.com/axmolengine/axmol.git
readied director::getMatrix again. remove kmGLgetMatrix
This commit is contained in:
parent
5e76c6713d
commit
67e62ce73d
|
@ -579,38 +579,42 @@ void Director::pushMatrix(MATRIX_STACK_TYPE type)
|
|||
}
|
||||
}
|
||||
|
||||
//kmMat4 Director::getMatrix(MATRIX_STACK_TYPE type)
|
||||
//{
|
||||
// if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type)
|
||||
// {
|
||||
// kmMat4 result;
|
||||
// kmGLGetMatrix(KM_GL_MODELVIEW, &result);
|
||||
// return result;
|
||||
// return _modelViewMatrixStack.top();
|
||||
// }
|
||||
// else if(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION == type)
|
||||
// {
|
||||
// kmMat4 result;
|
||||
// kmGLGetMatrix(KM_GL_PROJECTION, &result);
|
||||
// return result;
|
||||
// return _projectionMatrixStack.top();
|
||||
// }
|
||||
// else if(MATRIX_STACK_TYPE::MATRIX_STACK_TEXTURE == type)
|
||||
// {
|
||||
// kmMat4 result;
|
||||
// kmGLGetMatrix(KM_GL_TEXTURE, &result);
|
||||
// return result;
|
||||
// return _textureMatrixStack.top();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// CCASSERT(false, "unknow matrix stack type, will return modelview matrix instead");
|
||||
// kmMat4 result;
|
||||
// kmGLGetMatrix(KM_GL_MODELVIEW, &result);
|
||||
// return result;
|
||||
// return _modelViewMatrixStack.top();
|
||||
// }
|
||||
//}
|
||||
kmMat4 Director::getMatrix(MATRIX_STACK_TYPE type)
|
||||
{
|
||||
kmMat4 result;
|
||||
kmMat4 result2;
|
||||
if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type)
|
||||
{
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &result2);
|
||||
result = _modelViewMatrixStack.top();
|
||||
}
|
||||
else if(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION == type)
|
||||
{
|
||||
kmGLGetMatrix(KM_GL_PROJECTION, &result2);
|
||||
result = _projectionMatrixStack.top();
|
||||
}
|
||||
else if(MATRIX_STACK_TYPE::MATRIX_STACK_TEXTURE == type)
|
||||
{
|
||||
kmGLGetMatrix(KM_GL_TEXTURE, &result2);
|
||||
result = _textureMatrixStack.top();
|
||||
}
|
||||
else
|
||||
{
|
||||
CCASSERT(false, "unknow matrix stack type, will return modelview matrix instead");
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &result2);
|
||||
result = _modelViewMatrixStack.top();
|
||||
}
|
||||
float diffResult(0);
|
||||
for (int index = 0; index <16; ++index)
|
||||
{
|
||||
diffResult += abs(result2.mat[index] - result.mat[index]);
|
||||
}
|
||||
if(diffResult > 1e-30)
|
||||
{
|
||||
CCASSERT(false, "Error in director matrix stack");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Director::setProjection(Projection projection)
|
||||
{
|
||||
|
@ -741,8 +745,7 @@ static void GLToClipTransform(kmMat4 *transformOut)
|
|||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
|
||||
kmMat4 projection;
|
||||
//projection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
kmGLGetMatrix(KM_GL_PROJECTION, &projection);
|
||||
projection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8
|
||||
//if needed, we need to undo the rotation for Landscape orientation in order to get the correct positions
|
||||
|
@ -750,8 +753,7 @@ static void GLToClipTransform(kmMat4 *transformOut)
|
|||
#endif
|
||||
|
||||
kmMat4 modelview;
|
||||
//modelview = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &modelview);
|
||||
modelview = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
kmMat4Multiply(transformOut, &projection, &modelview);
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ public:
|
|||
void loadIdentityMatrix(MATRIX_STACK_TYPE type);
|
||||
void loadMatrix(MATRIX_STACK_TYPE type, const kmMat4& mat);
|
||||
void multiplyMatrix(MATRIX_STACK_TYPE type, const kmMat4& mat);
|
||||
//kmMat4 getMatrix(MATRIX_STACK_TYPE type);
|
||||
kmMat4 getMatrix(MATRIX_STACK_TYPE type);
|
||||
public:
|
||||
static const char *EVENT_PROJECTION_CHANGED;
|
||||
static const char* EVENT_AFTER_UPDATE;
|
||||
|
|
|
@ -633,18 +633,14 @@ void GLProgram::setUniformsForBuiltins()
|
|||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
|
||||
kmMat4 matrixMV;
|
||||
//matrixMV = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &matrixMV);
|
||||
|
||||
matrixMV = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
setUniformsForBuiltins(matrixMV);
|
||||
}
|
||||
|
||||
void GLProgram::setUniformsForBuiltins(const kmMat4 &matrixMV)
|
||||
{
|
||||
kmMat4 matrixP;
|
||||
//= Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
kmGLGetMatrix(KM_GL_PROJECTION, &matrixP);
|
||||
kmMat4 matrixP = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
|
||||
if(_flags.usesP)
|
||||
setUniformLocationWithMatrix4fv(_uniforms[UNIFORM_P_MATRIX], matrixP.mat, 1);
|
||||
|
|
|
@ -933,8 +933,7 @@ void Node::draw(Renderer* renderer, const kmMat4 &transform, bool transformUpdat
|
|||
void Node::visit()
|
||||
{
|
||||
auto renderer = Director::getInstance()->getRenderer();
|
||||
kmMat4 parentTransform;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &parentTransform);
|
||||
kmMat4 parentTransform = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
visit(renderer, parentTransform, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -524,10 +524,10 @@ void RenderTexture::onBegin()
|
|||
//
|
||||
Director *director = Director::getInstance();
|
||||
Size size = director->getWinSizeInPixels();
|
||||
kmGLGetMatrix(KM_GL_PROJECTION, &_oldProjMatrix);
|
||||
_oldProjMatrix = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, _projectionMatrix);
|
||||
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_oldTransMatrix);
|
||||
_oldTransMatrix = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _transformMatrix);
|
||||
|
||||
if(!_keepMatrix)
|
||||
|
@ -678,10 +678,10 @@ void RenderTexture::begin()
|
|||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
|
||||
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
kmGLGetMatrix(KM_GL_PROJECTION, &_projectionMatrix);
|
||||
_projectionMatrix = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
|
||||
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_transformMatrix);
|
||||
_transformMatrix = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
if(!_keepMatrix)
|
||||
{
|
||||
|
|
|
@ -610,7 +610,7 @@ void Sprite::drawDebugData()
|
|||
Director* director = Director::getInstance();
|
||||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
kmMat4 oldModelView;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldModelView);
|
||||
oldModelView = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
|
||||
// draw bounding box
|
||||
Point vertices[4] = {
|
||||
|
|
|
@ -221,8 +221,7 @@ kmMat4 Skin::getNodeToWorldTransformAR() const
|
|||
|
||||
void Skin::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
kmMat4 mv;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &mv);
|
||||
kmMat4 mv = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
//TODO implement z order
|
||||
_quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv);
|
||||
|
|
|
@ -1671,10 +1671,9 @@ void ActionCatmullRomStacked::draw(Renderer *renderer, const kmMat4 &transform,
|
|||
kmMat4Translation(&translation,50,50,0);
|
||||
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation);
|
||||
|
||||
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV1);
|
||||
_modelViewMV1 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
|
||||
_modelViewMV2 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this, transform, transformUpdated);
|
||||
|
@ -1687,7 +1686,7 @@ void ActionCatmullRomStacked::onDraw(const kmMat4 &transform, bool transformUpda
|
|||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
oldMat = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV1);
|
||||
DrawPrimitives::drawCatmullRom(_array1,50);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV2);
|
||||
|
@ -1792,7 +1791,7 @@ void ActionCardinalSplineStacked::draw(Renderer *renderer, const kmMat4 &transfo
|
|||
kmMat4Translation(&translation,50,50,0);
|
||||
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation);
|
||||
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV1);
|
||||
_modelViewMV1 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
@ -1803,7 +1802,7 @@ void ActionCardinalSplineStacked::draw(Renderer *renderer, const kmMat4 &transfo
|
|||
kmMat4Translation(&translation,s.width/2,50,0);
|
||||
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation);
|
||||
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
|
||||
_modelViewMV2 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
_customCommand.init(_globalZOrder);
|
||||
|
@ -1817,7 +1816,7 @@ void ActionCardinalSplineStacked::onDraw(const kmMat4 &transform, bool transform
|
|||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
oldMat = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV1);
|
||||
DrawPrimitives::drawCardinalSpline(_array, 0, 100);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV2);
|
||||
|
@ -2173,10 +2172,10 @@ void ActionCatmullRom::draw(Renderer *renderer, const kmMat4 &transform, bool tr
|
|||
//Create a rotation matrix using the axis and the angle
|
||||
kmMat4Translation(&translation,50,50,0);
|
||||
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation);
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV1);
|
||||
_modelViewMV1 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
|
||||
_modelViewMV2 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this, transform, transformUpdated);
|
||||
|
@ -2190,7 +2189,7 @@ void ActionCatmullRom::onDraw(const kmMat4 &transform, bool transformUpdated)
|
|||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
oldMat = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV1);
|
||||
DrawPrimitives::drawCatmullRom(_array1, 50);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV2);
|
||||
|
@ -2278,7 +2277,7 @@ void ActionCardinalSpline::draw(Renderer *renderer, const kmMat4 &transform, boo
|
|||
//Create a rotation matrix using the axis and the angle
|
||||
kmMat4Translation(&translation,50,50,0);
|
||||
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation);
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV1);
|
||||
_modelViewMV1 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
@ -2288,7 +2287,7 @@ void ActionCardinalSpline::draw(Renderer *renderer, const kmMat4 &transform, boo
|
|||
//Create a rotation matrix using the axis and the angle
|
||||
kmMat4Translation(&translation,s.width/2,50,0);
|
||||
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, translation);
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
|
||||
_modelViewMV2 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
_customCommand.init(_globalZOrder);
|
||||
|
@ -2302,7 +2301,7 @@ void ActionCardinalSpline::onDraw(const kmMat4 &transform, bool transformUpdated
|
|||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
oldMat = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV1);
|
||||
DrawPrimitives::drawCardinalSpline(_array, 0, 100);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV2);
|
||||
|
|
|
@ -152,7 +152,7 @@ void Box2DTestLayer::draw(Renderer *renderer, const kmMat4 &transform, bool tran
|
|||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV);
|
||||
_modelViewMV = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Box2DTestLayer::onDraw, this);
|
||||
|
@ -169,7 +169,7 @@ void Box2DTestLayer::onDraw()
|
|||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
|
||||
kmMat4 oldMV;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMV);
|
||||
oldMV = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewMV);
|
||||
world->DrawDebugData();
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, oldMV);
|
||||
|
|
Loading…
Reference in New Issue