mirror of https://github.com/axmolengine/axmol.git
Merge pull request #4668 from dabingnn/develop_FixTestCase_Texture2dTest
Develop fix test case texture2d test
This commit is contained in:
commit
03c4b57f5b
|
@ -1,6 +1,8 @@
|
|||
// local import
|
||||
#include "Texture2dTest.h"
|
||||
#include "../testResource.h"
|
||||
#include "renderer/CCRenderer.h"
|
||||
#include "renderer/CCCustomCommand.h"
|
||||
|
||||
enum {
|
||||
kTagLabel = 1,
|
||||
|
@ -1766,11 +1768,24 @@ void TextureDrawAtPoint::draw()
|
|||
{
|
||||
TextureDemo::draw();
|
||||
|
||||
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
|
||||
cmd->init(0, _vertexZ);
|
||||
cmd->func = CC_CALLBACK_0(TextureDrawAtPoint::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(cmd);
|
||||
|
||||
}
|
||||
|
||||
void TextureDrawAtPoint::onDraw()
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
kmGLLoadMatrix(&_modelViewTransform);
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
_tex1->drawAtPoint(Point(s.width/2-50, s.height/2 - 50));
|
||||
_Tex2F->drawAtPoint(Point(s.width/2+50, s.height/2 - 50));
|
||||
|
||||
kmGLLoadMatrix(&oldMat);
|
||||
}
|
||||
|
||||
// TextureDrawInRect
|
||||
|
@ -1795,6 +1810,19 @@ void TextureDrawInRect::draw()
|
|||
{
|
||||
TextureDemo::draw();
|
||||
|
||||
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
|
||||
cmd->init(0, _vertexZ);
|
||||
cmd->func = CC_CALLBACK_0(TextureDrawInRect::onDraw, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(cmd);
|
||||
|
||||
}
|
||||
|
||||
void TextureDrawInRect::onDraw()
|
||||
{
|
||||
kmMat4 oldMat;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &oldMat);
|
||||
kmGLLoadMatrix(&_modelViewTransform);
|
||||
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
auto rect1 = Rect( s.width/2 - 80, 20, _tex1->getContentSize().width * 0.5f, _tex1->getContentSize().height *2 );
|
||||
|
@ -1803,6 +1831,7 @@ void TextureDrawInRect::draw()
|
|||
_tex1->drawInRect(rect1);
|
||||
_Tex2F->drawInRect(rect2);
|
||||
|
||||
kmGLLoadMatrix(&oldMat);
|
||||
}
|
||||
|
||||
std::string TextureDrawInRect::title() const
|
||||
|
|
|
@ -441,6 +441,8 @@ public:
|
|||
virtual std::string subtitle() const override;
|
||||
virtual void onEnter();
|
||||
virtual void draw();
|
||||
protected:
|
||||
void onDraw();
|
||||
private:
|
||||
Texture2D* _tex1, *_Tex2F;
|
||||
};
|
||||
|
@ -454,6 +456,8 @@ public:
|
|||
virtual std::string subtitle() const override;
|
||||
virtual void onEnter();
|
||||
virtual void draw();
|
||||
protected:
|
||||
void onDraw();
|
||||
private:
|
||||
Texture2D* _tex1, *_Tex2F;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue