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
|
// local import
|
||||||
#include "Texture2dTest.h"
|
#include "Texture2dTest.h"
|
||||||
#include "../testResource.h"
|
#include "../testResource.h"
|
||||||
|
#include "renderer/CCRenderer.h"
|
||||||
|
#include "renderer/CCCustomCommand.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kTagLabel = 1,
|
kTagLabel = 1,
|
||||||
|
@ -1765,12 +1767,25 @@ std::string TextureDrawAtPoint::subtitle() const
|
||||||
void TextureDrawAtPoint::draw()
|
void TextureDrawAtPoint::draw()
|
||||||
{
|
{
|
||||||
TextureDemo::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();
|
auto s = Director::getInstance()->getWinSize();
|
||||||
|
|
||||||
_tex1->drawAtPoint(Point(s.width/2-50, s.height/2 - 50));
|
_tex1->drawAtPoint(Point(s.width/2-50, s.height/2 - 50));
|
||||||
_Tex2F->drawAtPoint(Point(s.width/2+50, s.height/2 - 50));
|
_Tex2F->drawAtPoint(Point(s.width/2+50, s.height/2 - 50));
|
||||||
|
|
||||||
|
kmGLLoadMatrix(&oldMat);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextureDrawInRect
|
// TextureDrawInRect
|
||||||
|
@ -1795,14 +1810,28 @@ void TextureDrawInRect::draw()
|
||||||
{
|
{
|
||||||
TextureDemo::draw();
|
TextureDemo::draw();
|
||||||
|
|
||||||
auto s = Director::getInstance()->getWinSize();
|
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 );
|
auto rect1 = Rect( s.width/2 - 80, 20, _tex1->getContentSize().width * 0.5f, _tex1->getContentSize().height *2 );
|
||||||
auto rect2 = Rect( s.width/2 + 80, s.height/2, _tex1->getContentSize().width * 2, _tex1->getContentSize().height * 0.5f );
|
auto rect2 = Rect( s.width/2 + 80, s.height/2, _tex1->getContentSize().width * 2, _tex1->getContentSize().height * 0.5f );
|
||||||
|
|
||||||
_tex1->drawInRect(rect1);
|
_tex1->drawInRect(rect1);
|
||||||
_Tex2F->drawInRect(rect2);
|
_Tex2F->drawInRect(rect2);
|
||||||
|
|
||||||
|
kmGLLoadMatrix(&oldMat);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TextureDrawInRect::title() const
|
std::string TextureDrawInRect::title() const
|
||||||
|
|
|
@ -441,6 +441,8 @@ public:
|
||||||
virtual std::string subtitle() const override;
|
virtual std::string subtitle() const override;
|
||||||
virtual void onEnter();
|
virtual void onEnter();
|
||||||
virtual void draw();
|
virtual void draw();
|
||||||
|
protected:
|
||||||
|
void onDraw();
|
||||||
private:
|
private:
|
||||||
Texture2D* _tex1, *_Tex2F;
|
Texture2D* _tex1, *_Tex2F;
|
||||||
};
|
};
|
||||||
|
@ -454,6 +456,8 @@ public:
|
||||||
virtual std::string subtitle() const override;
|
virtual std::string subtitle() const override;
|
||||||
virtual void onEnter();
|
virtual void onEnter();
|
||||||
virtual void draw();
|
virtual void draw();
|
||||||
|
protected:
|
||||||
|
void onDraw();
|
||||||
private:
|
private:
|
||||||
Texture2D* _tex1, *_Tex2F;
|
Texture2D* _tex1, *_Tex2F;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue