PuzzleSDK
Texture2dTest.cpp
浏览该文件的文档.
1/****************************************************************************
2 Copyright (c) 2012 cocos2d-x.org
3 Copyright (c) 2013-2016 Chukong Technologies Inc.
4 Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
5
6 http://www.cocos2d-x.org
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 ****************************************************************************/
26
27// local import
28#include "Texture2dTest.h"
29#include "../testResource.h"
30
32
33enum {
37};
38
39Texture2DTests::Texture2DTests()
40{
75
77
93
95
100
104
109};
110
111//------------------------------------------------------------------
112//
113// TextureDemo
114//
115//------------------------------------------------------------------
117{
119
120 auto col = LayerColor::create(Color4B(128,128,128,255));
121 addChild(col, -10);
122
123 auto textureCache = Director::getInstance()->getTextureCache();
124 log("%s\n", textureCache->getCachedTextureInfo().c_str());
125}
126
128{
129 auto textureCache = Director::getInstance()->getTextureCache();
130 textureCache->removeUnusedTextures();
131 log("%s\n", textureCache->getCachedTextureInfo().c_str());
132}
133
134
135//------------------------------------------------------------------
136//
137// TextureTGA
138//
139//------------------------------------------------------------------
140
142{
144 auto s = Director::getInstance()->getWinSize();
145
146 auto img = Sprite::create("TileMaps/levelmap.tga");
147 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
148 this->addChild(img);
149 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
150}
151
152std::string TextureTGA::title() const
153{
154 return "TGA Test";
155}
156
157//------------------------------------------------------------------
158//
159// TexturePNG
160//
161//------------------------------------------------------------------
163{
165
166 auto s = Director::getInstance()->getWinSize();
167
168 auto img = Sprite::create("Images/test_image.png");
169 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
170 addChild(img);
171 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
172
173 // Test PNG files with different pixel formats
174 // grayscale without alpha
175 auto i8 = Sprite::create("Images/test_image_i8.png");
176 i8->setPosition(s.width/4.0f, s.height/4.0f);
177 addChild(i8);
178
179 // grayscale with alpha
180 auto ai88 = Sprite::create("Images/test_image_ai88.png");
181 ai88->setPosition(s.width / 4.0f, s.height * 3.0f / 4.0f);
182 addChild(ai88);
183
184 // rgb without alpha
185 auto rgb888 = Sprite::create("Images/test_image_rgb888.png");
186 rgb888->setPosition(s.width * 3.0f / 4.0f, s.height / 4.0f);
187 addChild(rgb888);
188
189 // rgba with alpha
190 auto rgba8888 = Sprite::create("Images/test_image_rgba8888.png");
191 rgba8888->setPosition(s.width * 3.0f / 4.0f, s.height * 3.0f / 4.0f);
192 addChild(rgba8888);
193}
194
195std::string TexturePNG::title() const
196{
197 return "PNG Test";
198}
199
200std::string TexturePNG::subtitle() const
201{
202 return "LB:I8, LT:AI8\nRB:RGB888, RT: RGBA8888";
203}
204
205//------------------------------------------------------------------
206//
207// TextureJPEG
208//
209//------------------------------------------------------------------
211{
213 auto s = Director::getInstance()->getWinSize();
214
215 auto img = Sprite::create("Images/test_image.jpeg");
216 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
217 addChild(img);
218 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
219}
220
221std::string TextureJPEG::title() const
222{
223 return "JPEG Test";
224}
225
226//------------------------------------------------------------------
227//
228// TextureWEBP
229//
230//------------------------------------------------------------------
232{
234 auto s = Director::getInstance()->getWinSize();
235
236 auto img = Sprite::create("Images/test_image.webp");
237 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
238 addChild(img);
239 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
240 Texture2D* texture = Director::getInstance()->getTextureCache()->getTextureForKey("Images/test_image.webp");
241 log("pixel format:%d, premultiplied alpha:%d\n", static_cast<int>(texture->getPixelFormat()), texture->hasPremultipliedAlpha());
242}
243
244std::string TextureWEBP::title() const
245{
246 return "WEBP with alpha Test";
247}
248
249//------------------------------------------------------------------
250//
251// TextureWEBPNoAlpha
252//
253//------------------------------------------------------------------
255{
257 auto s = Director::getInstance()->getWinSize();
258
259 auto img = Sprite::create("Images/test_image_no_alpha.webp");
260 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
261 addChild(img);
262 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
263 Texture2D* texture = Director::getInstance()->getTextureCache()->getTextureForKey("Images/test_image_no_alpha.webp");
264 log("pixel format:%d, premultiplied alpha:%d\n", static_cast<int>(texture->getPixelFormat()), texture->hasPremultipliedAlpha());
265}
266
267std::string TextureWEBPNoAlpha::title() const
268{
269 return "WEBP without alpha Test";
270}
271
272//------------------------------------------------------------------
273//
274// TextureMipMap
275//
276//------------------------------------------------------------------
278{
280 auto s = Director::getInstance()->getWinSize();
281
282 auto texture0 = Director::getInstance()->getTextureCache()->addImage("Images/grossini_dance_atlas.png");
283 texture0->generateMipmap();
284 Texture2D::TexParams texParams = {
285 backend::SamplerFilter::LINEAR_MIPMAP_LINEAR,
286 backend::SamplerFilter::LINEAR,
287 backend::SamplerAddressMode::CLAMP_TO_EDGE,
288 backend::SamplerAddressMode::CLAMP_TO_EDGE };
289 texture0->setTexParameters(texParams);
290
291 auto texture1 = Director::getInstance()->getTextureCache()->addImage("Images/grossini_dance_atlas_nomipmap.png");
292
293 auto img0 = Sprite::createWithTexture(texture0);
294 img0->setTextureRect(Rect(85, 121, 85, 121));
295 img0->setPosition(Vec2( s.width/3.0f, s.height/2.0f));
296 addChild(img0);
297
298 auto img1 = Sprite::createWithTexture(texture1);
299 img1->setTextureRect(Rect(85, 121, 85, 121));
300 img1->setPosition(Vec2( 2*s.width/3.0f, s.height/2.0f));
301 addChild(img1);
302
303
304 auto scale1 = EaseOut::create(ScaleBy::create(4, 0.01f), 3);
305 auto sc_back = scale1->reverse();
306
307 auto scale2 = scale1->clone();
308 auto sc_back2 = scale2->reverse();
309
310 img0->runAction(RepeatForever::create(Sequence::create(scale1, sc_back, nullptr)));
311 img1->runAction(RepeatForever::create(Sequence::create(scale2, sc_back2, nullptr)));
312 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
313}
314
315std::string TextureMipMap::title() const
316{
317 return "Texture Mipmap";
318}
319
320std::string TextureMipMap::subtitle() const
321{
322 return "Left image uses mipmap. Right image doesn't";
323}
324
325//------------------------------------------------------------------
326//
327// TexturePVRMipMap
328// To generate PVR images read this article:
329// http://developer.apple.com/iphone/library/qa/qa2008/qa1611.html
330//
331//------------------------------------------------------------------
333{
335 auto s = Director::getInstance()->getWinSize();
336
337 auto imgMipMap = Sprite::create("Images/logo-mipmap.pvr");
338 if( imgMipMap )
339 {
340 imgMipMap->setPosition(Vec2( s.width/2.0f-100, s.height/2.0f));
341 addChild(imgMipMap);
342
343 // support mipmap filtering
344 Texture2D::TexParams texParams = {
345 backend::SamplerFilter::LINEAR_MIPMAP_LINEAR,
346 backend::SamplerFilter::LINEAR,
347 backend::SamplerAddressMode::CLAMP_TO_EDGE,
348 backend::SamplerAddressMode::CLAMP_TO_EDGE };
349 imgMipMap->getTexture()->setTexParameters(texParams);
350 }
351
352 auto img = Sprite::create("Images/logo-nomipmap.pvr");
353 if( img )
354 {
355 img->setPosition(Vec2( s.width/2.0f+100, s.height/2.0f));
356 addChild(img);
357
358 auto scale1 = EaseOut::create(ScaleBy::create(4, 0.01f), 3);
359 auto sc_back = scale1->reverse();
360
361 auto scale2 = scale1->clone();
362 auto sc_back2 = scale2->reverse();
363
364 imgMipMap->runAction(RepeatForever::create(Sequence::create(scale1, sc_back, nullptr)));
365 img->runAction(RepeatForever::create(Sequence::create(scale2, sc_back2, nullptr)));
366 }
367 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
368}
369
370std::string TexturePVRMipMap::title() const
371{
372 return "PVRTC MipMap Test";
373}
374std::string TexturePVRMipMap::subtitle() const
375{
376 return "Left image uses mipmap. Right image doesn't";
377}
378
379//------------------------------------------------------------------
380//
381// TexturePVRMipMap2
382//
383//------------------------------------------------------------------
385{
387 auto s = Director::getInstance()->getWinSize();
388
389 auto imgMipMap = Sprite::create("Images/test_image_rgba4444_mipmap.pvr");
390 imgMipMap->setPosition(Vec2( s.width/2.0f-100, s.height/2.0f));
391 addChild(imgMipMap);
392
393 // support mipmap filtering
394 Texture2D::TexParams texParams = {
395 backend::SamplerFilter::LINEAR_MIPMAP_LINEAR,
396 backend::SamplerFilter::LINEAR,
397 backend::SamplerAddressMode::CLAMP_TO_EDGE,
398 backend::SamplerAddressMode::CLAMP_TO_EDGE };
399 imgMipMap->getTexture()->setTexParameters(texParams);
400
401 auto img = Sprite::create("Images/test_image.png");
402 img->setPosition(Vec2( s.width/2.0f+100, s.height/2.0f));
403 addChild(img);
404
405 auto scale1 = EaseOut::create(ScaleBy::create(4, 0.01f), 3);
406 auto sc_back = scale1->reverse();
407
408 auto scale2 = scale1->clone();
409 auto sc_back2 = scale2->reverse();
410
411 imgMipMap->runAction(RepeatForever::create(Sequence::create(scale1, sc_back, nullptr)));
412 img->runAction(RepeatForever::create(Sequence::create(scale2, sc_back2, nullptr)));
413 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
414}
415
416std::string TexturePVRMipMap2::title() const
417{
418 return "PVR MipMap Test #2";
419}
420
422{
423 return "Left image uses mipmap. Right image doesn't";
424}
425
426//------------------------------------------------------------------
427//
428// TexturePVR2BPP
429// Image generated using PVRTexTool:
430// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
431//
432//------------------------------------------------------------------
434{
436 auto s = Director::getInstance()->getWinSize();
437
438 auto img = Sprite::create("Images/test_image_pvrtc2bpp.pvr");
439
440 if( img )
441 {
442 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
443 addChild(img);
444 }
445 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
446}
447
448std::string TexturePVR2BPP::title() const
449{
450 return "PVR TC 2bpp Test";
451}
452
453//------------------------------------------------------------------
454//
455// TexturePVR
456// To generate PVR images read this article:
457// http://developer.apple.com/iphone/library/qa/qa2008/qa1611.html
458//
459//------------------------------------------------------------------
461{
463 auto s = Director::getInstance()->getWinSize();
464
465 auto img = Sprite::create("Images/test_image.pvr");
466
467 if( img )
468 {
469 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
470 addChild(img);
471 }
472 else
473 {
474 log("This test is not supported.");
475 }
476 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
477
478}
479
480std::string TexturePVRTest::title() const
481{
482 return "PVR TC 4bpp Test #2";
483}
484
485//------------------------------------------------------------------
486//
487// TexturePVR4BPP
488// Image generated using PVRTexTool:
489// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
490//
491//------------------------------------------------------------------
493{
495 auto s = Director::getInstance()->getWinSize();
496
497 auto img = Sprite::create("Images/test_image_pvrtc4bpp.pvr");
498
499 if( img )
500 {
501 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
502 addChild(img);
503 }
504 else
505 {
506 log("This test is not supported in cocos2d-mac");
507 }
508 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
509}
510
511std::string TexturePVR4BPP::title() const
512{
513 return "PVR TC 4bpp Test #3";
514}
515
516//------------------------------------------------------------------
517//
518// TexturePVRRGBA8888
519// Image generated using PVRTexTool:
520// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
521//
522//------------------------------------------------------------------
524{
526 auto s = Director::getInstance()->getWinSize();
527
528 auto img = Sprite::create("Images/test_image_rgba8888.pvr");
529 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
530 addChild(img);
531 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
532}
533
534std::string TexturePVRRGBA8888::title() const
535{
536 return "PVR + RGBA 8888 Test";
537}
538
539//------------------------------------------------------------------
540//
541// TexturePVRBGRA8888
542// Image generated using PVRTexTool:
543// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
544//
545//------------------------------------------------------------------
547{
549 auto s = Director::getInstance()->getWinSize();
550
551 auto img = Sprite::create("Images/test_image_bgra8888.pvr");
552 if( img )
553 {
554 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
555 addChild(img);
556 }
557 else
558 {
559 log("BGRA8888 images are not supported");
560 }
561 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
562}
563
564std::string TexturePVRBGRA8888::title() const
565{
566 return "PVR + BGRA 8888 Test";
567}
568
569//------------------------------------------------------------------
570//
571// TexturePVRRGBA5551
572// Image generated using PVRTexTool:
573// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
574//
575//------------------------------------------------------------------
577{
579 auto s = Director::getInstance()->getWinSize();
580 auto img = Sprite::create("Images/test_image_rgba5551.pvr");
581 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
582 addChild(img);
583 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
584}
585
586std::string TexturePVRRGBA5551::title() const
587{
588 return "PVR + RGBA 5551 Test";
589}
590
591//------------------------------------------------------------------
592//
593// TexturePVRRGBA4444
594// Image generated using PVRTexTool:
595// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
596//
597//------------------------------------------------------------------
599{
601 auto s = Director::getInstance()->getWinSize();
602
603 auto img = Sprite::create("Images/test_image_rgba4444.pvr");
604 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
605 addChild(img);
606 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
607}
608
609std::string TexturePVRRGBA4444::title() const
610{
611 return "PVR + RGBA 4444 Test";
612}
613
614//------------------------------------------------------------------
615//
616// TexturePVRRGBA4444GZ
617// Image generated using PVRTexTool:
618// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
619//
620//------------------------------------------------------------------
622{
624 auto s = Director::getInstance()->getWinSize();
625
626#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
627 // android can not pack .gz file into apk file
628 auto img = Sprite::create("Images/test_image_rgba4444.pvr");
629#else
630 auto img = Sprite::create("Images/test_image_rgba4444.pvr.gz");
631#endif
632 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
633 addChild(img);
634 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
635}
636
638{
639 return "PVR + RGBA 4444 + GZ Test";
640}
641
643{
644 return "This is a gzip PVR image";
645}
646
647//------------------------------------------------------------------
648//
649// TexturePVRRGBA4444CCZ
650// Image generated using PVRTexTool:
651// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
652//
653//------------------------------------------------------------------
655{
657 auto s = Director::getInstance()->getWinSize();
658
659 auto img = Sprite::create("Images/test_image_rgba4444.pvr.ccz");
660 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
661 addChild(img);
662 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
663}
664
666{
667 return "PVR + RGBA 4444 + CCZ Test";
668}
669
671{
672 return "This is a ccz PVR image";
673}
674
675//------------------------------------------------------------------
676//
677// TexturePVRRGB565
678// Image generated using PVRTexTool:
679// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
680//
681//------------------------------------------------------------------
683{
685 auto s = Director::getInstance()->getWinSize();
686
687 auto img = Sprite::create("Images/test_image_rgb565.pvr");
688 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
689 addChild(img);
690 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
691}
692
693std::string TexturePVRRGB565::title() const
694{
695 return "PVR + RGB 565 Test";
696}
697
698// TexturePVR RGB888
699// Image generated using PVRTexTool:
700// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
702{
704 auto s = Director::getInstance()->getWinSize();
705
706 auto img = Sprite::create("Images/test_image_rgb888.pvr");
707 if (img != nullptr)
708 {
709 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
710 addChild(img);
711 }
712
713 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
714
715}
716std::string TexturePVRRGB888::title() const
717{
718 return "PVR + RGB 888 Test";
719}
720
721//------------------------------------------------------------------
722//
723// TexturePVRA8
724// Image generated using PVRTexTool:
725// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
726//
727//------------------------------------------------------------------
729{
731 auto s = Director::getInstance()->getWinSize();
732
733 auto img = Sprite::create("Images/test_image_a8.pvr");
734 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
735 addChild(img);
736 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
737
738}
739
740std::string TexturePVRA8::title() const
741{
742 return "PVR + A8 Test";
743}
744
745//------------------------------------------------------------------
746//
747// TexturePVRI8
748// Image generated using PVRTexTool:
749// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
750//
751//------------------------------------------------------------------
753{
755 auto s = Director::getInstance()->getWinSize();
756
757 auto img = Sprite::create("Images/test_image_i8.pvr");
758 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
759 addChild(img);
760 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
761}
762
763std::string TexturePVRI8::title() const
764{
765 return "PVR + I8 Test";
766}
767
768//------------------------------------------------------------------
769//
770// TexturePVRAI88
771// Image generated using PVRTexTool:
772// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
773//
774//------------------------------------------------------------------
776{
778 auto s = Director::getInstance()->getWinSize();
779
780 auto img = Sprite::create("Images/test_image_ai88.pvr");
781 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
782 addChild(img);
783 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
784}
785
786std::string TexturePVRAI88::title() const
787{
788 return "PVR + AI88 Test";
789}
790
791// TexturePVR2BPPv3
793{
795 auto s = Director::getInstance()->getWinSize();
796
797 auto img = Sprite::create("Images/test_image_pvrtc2bpp_v3.pvr");
798
799 if (img)
800 {
801 img->setPosition(Vec2(s.width/2.0f, s.height/2.0f));
802 addChild(img);
803 }
804
805 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
806}
807
808std::string TexturePVR2BPPv3::title() const
809{
810 return "PVR TC 2bpp Test";
811}
812
813std::string TexturePVR2BPPv3::subtitle() const
814{
815 return "Testing PVR File Format v3";
816}
817
818// TexturePVRII2BPPv3
820{
822 auto s = Director::getInstance()->getWinSize();
823
824 auto img = Sprite::create("Images/test_image_pvrtcii2bpp_v3.pvr");
825
826 if (img)
827 {
828 img->setPosition(Vec2(s.width/2.0f, s.height/2.0f));
829 addChild(img);
830 }
831
832 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
833}
834
835std::string TexturePVRII2BPPv3::title() const
836{
837 return "PVR TC II 2bpp Test";
838}
839
841{
842 return "Testing PVR File Format v3";
843}
844
845// TexturePVR4BPPv3
847{
849 auto s = Director::getInstance()->getWinSize();
850
851 auto img = Sprite::create("Images/test_image_pvrtc4bpp_v3.pvr");
852
853 if (img)
854 {
855 img->setPosition(Vec2(s.width/2.0f, s.height/2.0f));
856 addChild(img);
857 }
858 else
859 {
860 log("This test is not supported");
861 }
862
863 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
864}
865
866std::string TexturePVR4BPPv3::title() const
867{
868 return "PVR TC 4bpp Test";
869}
870
871std::string TexturePVR4BPPv3::subtitle() const
872{
873 return "Testing PVR File Format v3";
874}
875
876// TexturePVRII4BPPv3
877
878// Image generated using PVRTexTool:
879// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
880
882{
884 auto s = Director::getInstance()->getWinSize();
885
886 auto img = Sprite::create("Images/test_image_pvrtcii4bpp_v3.pvr");
887
888 if (img)
889 {
890 img->setPosition(Vec2(s.width/2.0f, s.height/2.0f));
891 addChild(img);
892 }
893 else
894 {
895 log("This test is not supported");
896 }
897
898 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
899}
900
901std::string TexturePVRII4BPPv3::title() const
902{
903 return "PVR TC II 4bpp Test";
904}
905
907{
908 return "Testing PVR File Format v3";
909}
910
911// TexturePVRRGBA8888v3
913{
915 auto s = Director::getInstance()->getWinSize();
916
917 auto img = Sprite::create("Images/test_image_rgba8888_v3.pvr");
918
919 if (img)
920 {
921 img->setPosition(Vec2(s.width/2.0f, s.height/2.0f));
922 addChild(img);
923 }
924
925 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
926}
927
929{
930 return "PVR + RGBA 8888 Test";
931}
932
934{
935 return "Testing PVR File Format v3";
936}
937
938// TexturePVRBGRA8888v3
940{
942 auto s = Director::getInstance()->getWinSize();
943
944 auto img = Sprite::create("Images/test_image_bgra8888_v3.pvr");
945
946 if (img)
947 {
948 img->setPosition(Vec2(s.width/2.0f, s.height/2.0f));
949 addChild(img);
950 }
951 else
952 {
953 log("BGRA images are not supported");
954 }
955
956 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
957}
958
960{
961 return "PVR + BGRA 8888 Test";
962}
963
965{
966 return "Testing PVR File Format v3";
967}
968
969// TexturePVRRGBA5551v3
971{
973 auto s = Director::getInstance()->getWinSize();
974
975 auto img = Sprite::create("Images/test_image_rgba5551_v3.pvr");
976
977 if (img)
978 {
979 img->setPosition(Vec2(s.width/2.0f, s.height/2.0f));
980 addChild(img);
981 }
982
983 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
984}
985
987{
988 return "PVR + RGBA 5551 Test";
989}
990
992{
993 return "Testing PVR File Format v3";
994}
995
996// TexturePVRRGBA4444v3
998{
1000 auto s = Director::getInstance()->getWinSize();
1001
1002 auto img = Sprite::create("Images/test_image_rgba4444_v3.pvr");
1003
1004 if (img)
1005 {
1006 img->setPosition(Vec2(s.width/2.0f, s.height/2.0f));
1007 addChild(img);
1008 }
1009
1010 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
1011}
1012
1014{
1015 return "PVR + RGBA 4444 Test";
1016}
1017
1019{
1020 return "Testing PVR File Format v3";
1021}
1022
1023// TexturePVRRGB565v3
1025{
1027 auto s = Director::getInstance()->getWinSize();
1028
1029 auto img = Sprite::create("Images/test_image_rgb565_v3.pvr");
1030
1031 if (img)
1032 {
1033 img->setPosition(Vec2(s.width/2.0f, s.height/2.0f));
1034 addChild(img);
1035 }
1036
1037 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
1038}
1039
1040std::string TexturePVRRGB565v3::title() const
1041{
1042 return "PVR + RGB 565 Test";
1043}
1044
1046{
1047 return "Testing PVR File Format v3";
1048}
1049
1050// TexturePVRRGB888v3
1052{
1054 auto s = Director::getInstance()->getWinSize();
1055
1056 auto img = Sprite::create("Images/test_image_rgb888_v3.pvr");
1057
1058 if (img)
1059 {
1060 img->setPosition(Vec2(s.width/2.0f, s.height/2.0f));
1061 addChild(img);
1062 }
1063
1064 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
1065}
1066
1067std::string TexturePVRRGB888v3::title() const
1068{
1069 return "PVR + RGB 888 Test";
1070}
1071
1073{
1074 return "Testing PVR File Format v3";
1075}
1076
1077// TexturePVRA8v3
1079{
1081 auto s = Director::getInstance()->getWinSize();
1082
1083 auto img = Sprite::create("Images/test_image_a8_v3.pvr");
1084
1085 if (img)
1086 {
1087 img->setPosition(Vec2(s.width/2.0f, s.height/2.0f));
1088 addChild(img);
1089 }
1090
1091 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
1092}
1093
1094std::string TexturePVRA8v3::title() const
1095{
1096 return "PVR + A8 Test";
1097}
1098
1099std::string TexturePVRA8v3::subtitle() const
1100{
1101 return "Testing PVR File Format v3";
1102}
1103
1104// TexturePVRI8v3
1106{
1108 auto s = Director::getInstance()->getWinSize();
1109
1110 auto img = Sprite::create("Images/test_image_i8_v3.pvr");
1111
1112 if (img)
1113 {
1114 img->setPosition(Vec2(s.width/2.0f, s.height/2.0f));
1115 addChild(img);
1116 }
1117
1118 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
1119}
1120
1121std::string TexturePVRI8v3::title() const
1122{
1123 return "PVR + I8 Test";
1124}
1125
1126std::string TexturePVRI8v3::subtitle() const
1127{
1128 return "Testing PVR File Format v3";
1129}
1130
1131// TexturePVRAI88v3
1133{
1135 auto s = Director::getInstance()->getWinSize();
1136
1137 auto img = Sprite::create("Images/test_image_ai88_v3.pvr");
1138
1139 if (img)
1140 {
1141 img->setPosition(Vec2(s.width/2.0f, s.height/2.0f));
1142 addChild(img);
1143 }
1144
1145 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
1146}
1147
1148std::string TexturePVRAI88v3::title() const
1149{
1150 return "PVR + AI88 Test";
1151}
1152
1154{
1155 return "Testing PVR File Format v3";
1156}
1157
1158//------------------------------------------------------------------
1159//
1160// TexturePVRBadEncoding
1161// Image generated using PVRTexTool:
1162// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
1163//
1164//------------------------------------------------------------------
1166{
1168 auto s = Director::getInstance()->getWinSize();
1169
1170 auto img = Sprite::create("Images/test_image-bad_encoding.pvr");
1171 if( img )
1172 {
1173 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
1174 addChild(img);
1175 }
1176}
1177
1179{
1180 return "PVR Unsupported encoding";
1181}
1182
1184{
1185 return "You should not see any image";
1186}
1187
1188//------------------------------------------------------------------
1189//
1190// TexturePVRNonSquare
1191//
1192//------------------------------------------------------------------
1194{
1196 auto s = Director::getInstance()->getWinSize();
1197
1198 auto img = Sprite::create("Images/grossini_128x256_mipmap.pvr");
1199 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
1200 addChild(img);
1201 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
1202}
1203
1205{
1206 return "PVR + Non square texture";
1207}
1208
1210{
1211 return "Loading a 128x256 texture";
1212}
1213
1214//------------------------------------------------------------------
1215//
1216// TexturePVRNPOT4444
1217//
1218//------------------------------------------------------------------
1220{
1222 auto s = Director::getInstance()->getWinSize();
1223
1224 auto img = Sprite::create("Images/grossini_pvr_rgba4444.pvr");
1225 if ( img )
1226 {
1227 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
1228 addChild(img);
1229 }
1230 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
1231}
1232
1233std::string TexturePVRNPOT4444::title() const
1234{
1235 return "PVR RGBA4 + NPOT texture";
1236}
1237
1239{
1240 return "Loading a 81x121 RGBA4444 texture.";
1241}
1242
1243//------------------------------------------------------------------
1244//
1245// TexturePVRNPOT8888
1246//
1247//------------------------------------------------------------------
1249{
1251 auto s = Director::getInstance()->getWinSize();
1252
1253 auto img = Sprite::create("Images/grossini_pvr_rgba8888.pvr");
1254 if( img )
1255 {
1256 img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
1257 addChild(img);
1258 }
1259 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
1260}
1261
1262std::string TexturePVRNPOT8888::title() const
1263{
1264 return "PVR RGBA8 + NPOT texture";
1265}
1266
1268{
1269 return "Loading a 81x121 RGBA8888 texture.";
1270}
1271
1272//------------------------------------------------------------------
1273//
1274// TextureAlias
1275//
1276//------------------------------------------------------------------
1278{
1280 auto s = Director::getInstance()->getWinSize();
1281
1282 //
1283 // Sprite 1: GL_LINEAR
1284 //
1285 // Default filter is GL_LINEAR
1286
1287 auto sprite = Sprite::create("Images/grossinis_sister1.png");
1288 sprite->setPosition(Vec2( s.width/3.0f, s.height/2.0f));
1289 addChild(sprite);
1290
1291 // this is the default filtering
1292 sprite->getTexture()->setAntiAliasTexParameters();
1293
1294 //
1295 // Sprite 1: GL_NEAREST
1296 //
1297
1298 auto sprite2 = Sprite::create("Images/grossinis_sister2.png");
1299 sprite2->setPosition(Vec2( 2*s.width/3.0f, s.height/2.0f));
1300 addChild(sprite2);
1301
1302 // Use Nearest in this one
1303 sprite2->getTexture()->setAliasTexParameters();
1304
1305 // scale them to show
1306 auto sc = ScaleBy::create(3, 8.0f);
1307 auto sc_back = sc->reverse();
1308 auto scaleforever = RepeatForever::create(Sequence::create(sc, sc_back, nullptr));
1309 auto scaleToo = scaleforever->clone();
1310
1311 sprite2->runAction(scaleforever);
1312 sprite->runAction(scaleToo);
1313 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
1314}
1315
1316std::string TextureAlias::title() const
1317{
1318 return "AntiAlias / Alias textures";
1319}
1320
1321std::string TextureAlias::subtitle() const
1322{
1323 return "Left image is antialiased. Right image is aliases";
1324}
1325
1326//------------------------------------------------------------------
1327//
1328// TexturePixelFormat
1329//
1330//------------------------------------------------------------------
1332{
1333 //
1334 // This example displays 1 png images 4 times.
1335 // Each time the image is generated using:
1336 // 1- 32-bit RGBA8
1337 // 2- 16-bit RGBA4
1338 // 3- 16-bit RGB5A1
1339 // 4- 16-bit RGB565
1341
1342 auto s = Director::getInstance()->getWinSize();
1343
1344 auto background = LayerColor::create(Color4B(128,128,128,255), s.width, s.height);
1345 addChild(background, -1);
1346
1347 // RGBA 8888 image (32-bit)
1348 Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGBA8888);
1349 auto sprite1 = Sprite::create("Images/test-rgba1.png");
1350 sprite1->setPosition(Vec2(1*s.width/7, s.height/2+32));
1351 addChild(sprite1, 0);
1352
1353 // remove texture from texture manager
1354 Director::getInstance()->getTextureCache()->removeTexture(sprite1->getTexture());
1355
1356 // RGBA 4444 image (16-bit)
1357 Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGBA4444);
1358 auto sprite2 = Sprite::create("Images/test-rgba1.png");
1359 sprite2->setPosition(Vec2(2*s.width/7, s.height/2-32));
1360 addChild(sprite2, 0);
1361
1362 // remove texture from texture manager
1363 Director::getInstance()->getTextureCache()->removeTexture(sprite2->getTexture());
1364
1365 // RGB5A1 image (16-bit)
1366 Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGB5A1);
1367 auto sprite3 = Sprite::create("Images/test-rgba1.png");
1368 sprite3->setPosition(Vec2(3*s.width/7, s.height/2+32));
1369 addChild(sprite3, 0);
1370
1371 // remove texture from texture manager
1372 Director::getInstance()->getTextureCache()->removeTexture(sprite3->getTexture());
1373
1374 // RGB888 image
1375 Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGB888);
1376 auto sprite4 = Sprite::create("Images/test-rgba1.png");
1377 sprite4->setPosition(Vec2(4*s.width/7, s.height/2-32));
1378 addChild(sprite4, 0);
1379
1380 // remove texture from texture manager
1381 Director::getInstance()->getTextureCache()->removeTexture(sprite4->getTexture());
1382
1383 // RGB565 image (16-bit)
1384 Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGB565);
1385 auto sprite5 = Sprite::create("Images/test-rgba1.png");
1386 sprite5->setPosition(Vec2(5*s.width/7, s.height/2+32));
1387 addChild(sprite5, 0);
1388
1389 // remove texture from texture manager
1390 Director::getInstance()->getTextureCache()->removeTexture(sprite5->getTexture());
1391
1392 // A8 image (8-bit)
1393 Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::A8);
1394 auto sprite6 = Sprite::create("Images/test-rgba1.png");
1395 sprite6->setPosition(Vec2(6*s.width/7, s.height/2-32));
1396 addChild(sprite6, 0);
1397
1398 // remove texture from texture manager
1399 Director::getInstance()->getTextureCache()->removeTexture(sprite6->getTexture());
1400
1401 auto fadeout = FadeOut::create(2);
1402 auto fadein = FadeIn::create(2);
1403 auto seq = Sequence::create(DelayTime::create(2), fadeout, fadein, nullptr);
1404 auto seq_4ever = RepeatForever::create(seq);
1405 auto seq_4ever2 = seq_4ever->clone();
1406 auto seq_4ever3 = seq_4ever->clone();
1407 auto seq_4ever4 = seq_4ever->clone();
1408 auto seq_4ever5 = seq_4ever->clone();
1409
1410 sprite1->runAction(seq_4ever);
1411 sprite2->runAction(seq_4ever2);
1412 sprite3->runAction(seq_4ever3);
1413 sprite4->runAction(seq_4ever4);
1414 sprite5->runAction(seq_4ever5);
1415
1416 // restore default
1417 Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::DEFAULT);
1418 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
1419}
1420
1421std::string TexturePixelFormat::title() const
1422{
1423 return "Texture Pixel Formats";
1424}
1425
1427{
1428 return "Textures: RGBA8888, RGBA4444, RGB5A1, RGB888, RGB565, A8";
1429}
1430
1431//------------------------------------------------------------------
1432//
1433// TextureBlend
1434//
1435//------------------------------------------------------------------
1437{
1439
1440 for( int i=0;i < 15;i++ )
1441 {
1442 // BOTTOM sprites have alpha pre-multiplied
1443 // they use by default BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA
1444 auto cloud = Sprite::create("Images/test_blend.png");
1445 addChild(cloud, i+1, 100+i);
1446 cloud->setPosition(Vec2(50+25*i, 80));
1447 cloud->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED );
1448
1449 // CENTER sprites have also alpha pre-multiplied
1450 // they use by default BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA
1451 cloud = Sprite::create("Images/test_blend.png");
1452 addChild(cloud, i+1, 200+i);
1453 cloud->setPosition(Vec2(50+25*i, 160));
1454 BlendFunc blendFunc2 = { backend::BlendFactor::ONE_MINUS_DST_COLOR, backend::BlendFactor::ZERO };
1455 cloud->setBlendFunc(blendFunc2);
1456
1457 // UPPER sprites are using custom blending function
1458 // You can set any blend function to your sprites
1459 cloud = Sprite::create("Images/test_blend.png");
1460 addChild(cloud, i+1, 200+i);
1461 cloud->setPosition(Vec2(50+25*i, 320-80));
1462 BlendFunc blendFunc3 = { backend::BlendFactor::SRC_ALPHA, backend::BlendFactor::ONE };
1463 cloud->setBlendFunc(blendFunc3); // additive blending
1464 }
1465}
1466
1467std::string TextureBlend::title() const
1468{
1469 return "Texture Blending";
1470}
1471
1472std::string TextureBlend::subtitle() const
1473{
1474 return "Testing 3 different blending modes";
1475}
1476
1477
1478//------------------------------------------------------------------
1479//
1480// TextureAsync
1481//
1482//------------------------------------------------------------------
1483
1485{
1487
1488 _imageOffset = 0;
1489
1490 auto size = Director::getInstance()->getWinSize();
1491
1492 auto label = Label::createWithTTF("Loading...", "fonts/Marker Felt.ttf", 32);
1493 label->setPosition(Vec2( size.width/2, size.height/2));
1494 addChild(label, 10);
1495
1496 auto scale = ScaleBy::create(0.3f, 2);
1497 auto scale_back = scale->reverse();
1498 auto seq = Sequence::create(scale, scale_back, nullptr);
1499 label->runAction(RepeatForever::create(seq));
1500
1501 scheduleOnce(CC_SCHEDULE_SELECTOR(TextureAsync::loadImages), 1.0f);
1502}
1503
1505{
1506 auto textureCache = Director::getInstance()->getTextureCache();
1507 textureCache->unbindAllImageAsync();
1508 textureCache->removeAllTextures();
1509}
1510
1512{
1513 auto textureCache = Director::getInstance()->getTextureCache();
1514 for( int i=0;i < 8;i++) {
1515 for( int j=0;j < 8; j++) {
1516 char szSpriteName[100] = {0};
1517 sprintf(szSpriteName, "Images/sprites_test/sprite-%d-%d.png", i, j);
1518 textureCache->addImageAsync(szSpriteName, CC_CALLBACK_1(TextureAsync::imageLoaded, this));
1519 }
1520 }
1521
1522 textureCache->addImageAsync("Images/background1.jpg", CC_CALLBACK_1(TextureAsync::imageLoaded, this));
1523 textureCache->addImageAsync("Images/background2.jpg", CC_CALLBACK_1(TextureAsync::imageLoaded, this));
1524 textureCache->addImageAsync("Images/background.png", CC_CALLBACK_1(TextureAsync::imageLoaded, this));
1525 textureCache->addImageAsync("Images/atlastest.png", CC_CALLBACK_1(TextureAsync::imageLoaded, this));
1526 textureCache->addImageAsync("Images/grossini_dance_atlas.png", CC_CALLBACK_1(TextureAsync::imageLoaded, this));
1527}
1528
1529
1530void TextureAsync::imageLoaded(Texture2D* texture)
1531{
1532 auto director = Director::getInstance();
1533
1534 //CCASSERT( [NSThread currentThread] == [director runningThread], @"FAIL. Callback should be on cocos2d thread");
1535
1536 // IMPORTANT: The order on the callback is not guaranteed. Don't depend on the callback
1537
1538 // This test just creates a sprite based on the Texture
1539
1540 auto sprite = Sprite::createWithTexture(texture);
1541 sprite->setAnchorPoint(Vec2(0,0));
1542 addChild(sprite, -1);
1543
1544 auto size = director->getWinSize();
1545 int i = _imageOffset * 32;
1546 sprite->setPosition(Vec2( i % (int)size.width, (i / (int)size.width) * 32 ));
1547
1548 _imageOffset++;
1549
1550 log("Image loaded: %p", texture);
1551}
1552
1553std::string TextureAsync::title() const
1554{
1555 return "Texture Async Load";
1556}
1557
1558std::string TextureAsync::subtitle() const
1559{
1560 return "Textures should load while an animation is being run";
1561}
1562
1563
1564//------------------------------------------------------------------
1565//
1566// TextureGlClamp
1567//
1568//------------------------------------------------------------------
1570{
1572
1573 auto size = Director::getInstance()->getWinSize();
1574
1575 // The .png image MUST be power of 2 in order to create a continue effect.
1576 // eg: 32x64, 512x128, 256x1024, 64x64, etc..
1577 auto sprite = Sprite::create("Images/pattern1.png", Rect(0,0,512,256));
1578 addChild(sprite, -1, kTagSprite1);
1579 sprite->setPosition(Vec2(size.width/2,size.height/2));
1580 Texture2D::TexParams texParams(
1581 backend::SamplerFilter::LINEAR,
1582 backend::SamplerFilter::LINEAR,
1583 backend::SamplerAddressMode::CLAMP_TO_EDGE,
1584 backend::SamplerAddressMode::CLAMP_TO_EDGE
1585 );
1586 sprite->getTexture()->setTexParameters(texParams);
1587 auto rotate = RotateBy::create(4, 360);
1588 sprite->runAction(rotate);
1589 auto scale = ScaleBy::create(2, 0.04f);
1590 auto scaleBack = scale->reverse();
1591 auto seq = Sequence::create(scale, scaleBack, nullptr);
1592 sprite->runAction(seq);
1593}
1594
1595std::string TextureGlClamp::title() const
1596{
1597 return "Texture GL_CLAMP";
1598}
1599
1601{
1602 Director::getInstance()->getTextureCache()->removeUnusedTextures();
1603}
1604
1605//------------------------------------------------------------------
1606//
1607// TextureGlRepeat
1608//
1609//------------------------------------------------------------------
1611{
1613
1614 auto size = Director::getInstance()->getWinSize();
1615
1616 // The .png image MUST be power of 2 in order to create a continue effect.
1617 // eg: 32x64, 512x128, 256x1024, 64x64, etc..
1618 auto sprite = Sprite::create("Images/pattern1.png", Rect(0, 0, 4096, 4096));
1619 addChild(sprite, -1, kTagSprite1);
1620 sprite->setPosition(Vec2(size.width/2,size.height/2));
1621 Texture2D::TexParams descriptor = {
1622 backend::SamplerFilter::LINEAR,
1623 backend::SamplerFilter::LINEAR,
1624 backend::SamplerAddressMode::REPEAT,
1625 backend::SamplerAddressMode::REPEAT
1626 };
1627 sprite->getTexture()->setTexParameters(descriptor);
1628
1629 auto rotate = RotateBy::create(4, 360);
1630 sprite->runAction(rotate);
1631 auto scale = ScaleBy::create(2, 0.04f);
1632 auto scaleBack = scale->reverse();
1633 auto seq = Sequence::create(scale, scaleBack, nullptr);
1634 sprite->runAction(seq);
1635}
1636
1637std::string TextureGlRepeat::title() const
1638{
1639 return "Texture GL_REPEAT";
1640}
1641
1643{
1644 Director::getInstance()->getTextureCache()->removeUnusedTextures();
1645}
1646
1647//------------------------------------------------------------------
1648//
1649// TextureSizeTest
1650//
1651//------------------------------------------------------------------
1653{
1655 Sprite *sprite = nullptr;
1656
1657 log("Loading 512x512 image...");
1658 sprite = Sprite::create("Images/texture512x512.png");
1659 if( sprite )
1660 log("OK");
1661 else
1662 log("Error");
1663
1664 log("Loading 1024x1024 image...");
1665 sprite = Sprite::create("Images/texture1024x1024.png");
1666 if( sprite )
1667 log("OK");
1668 else
1669 log("Error");
1670// @todo
1671// log("Loading 2048x2048 image...");
1672// sprite = Sprite::create("Images/texture2048x2048.png");
1673// if( sprite )
1674// log("OK");
1675// else
1676// log("Error");
1677//
1678// log("Loading 4096x4096 image...");
1679// sprite = Sprite::create("Images/texture4096x4096.png");
1680// if( sprite )
1681// log("OK");
1682// else
1683// log("Error");
1684}
1685
1686std::string TextureSizeTest::title() const
1687{
1688 return "Different Texture Sizes";
1689}
1690
1691std::string TextureSizeTest::subtitle() const
1692{
1693 return "512x512, 1024x1024. See the console.";
1694}
1695
1696//------------------------------------------------------------------
1697//
1698// TextureCache1
1699//
1700//------------------------------------------------------------------
1702{
1704
1705 auto s = Director::getInstance()->getWinSize();
1706
1707 Sprite *sprite;
1708
1709 sprite = Sprite::create("Images/grossinis_sister1.png");
1710 sprite->setPosition(Vec2(s.width/5*1, s.height/2));
1711 sprite->getTexture()->setAliasTexParameters();
1712 sprite->setScale(2);
1713 addChild(sprite);
1714
1715 Director::getInstance()->getTextureCache()->removeTexture(sprite->getTexture());
1716
1717 sprite = Sprite::create("Images/grossinis_sister1.png");
1718 sprite->setPosition(Vec2(s.width/5*2, s.height/2));
1719 sprite->getTexture()->setAntiAliasTexParameters();
1720 sprite->setScale(2);
1721 addChild(sprite);
1722
1723 // 2nd set of sprites
1724
1725 sprite = Sprite::create("Images/grossinis_sister2.png");
1726 sprite->setPosition(Vec2(s.width/5*3, s.height/2));
1727 sprite->getTexture()->setAliasTexParameters();
1728 sprite->setScale(2);
1729 addChild(sprite);
1730
1731 Director::getInstance()->getTextureCache()->removeTextureForKey("Images/grossinis_sister2.png");
1732
1733 sprite = Sprite::create("Images/grossinis_sister2.png");
1734 sprite->setPosition(Vec2(s.width/5*4, s.height/2));
1735 sprite->getTexture()->setAntiAliasTexParameters();
1736 sprite->setScale(2);
1737 addChild(sprite);
1738}
1739
1740std::string TextureCache1::title() const
1741{
1742 return "CCTextureCache: remove";
1743}
1744
1745std::string TextureCache1::subtitle() const
1746{
1747 return "4 images should appear: alias, antialias, alias, antialias";
1748}
1749
1750// TextureDrawAtPoint
1752{
1754
1755 _tex1 = Director::getInstance()->getTextureCache()->addImage("Images/grossinis_sister1.png");
1756 _Tex2F = Director::getInstance()->getTextureCache()->addImage("Images/grossinis_sister2.png");
1757
1758 _tex1->retain();
1759 _Tex2F->retain();
1760}
1761
1763{
1764 _tex1->release();
1765 _Tex2F->release();
1766}
1767
1768std::string TextureDrawAtPoint::title() const
1769{
1770 return "CCTexture2D: drawAtPoint";
1771}
1772
1774{
1775 return "draws 2 textures using drawAtPoint";
1776}
1777
1778void TextureDrawAtPoint::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
1779{
1780 TextureDemo::draw(renderer, transform, flags);
1781
1782 onDraw(transform, flags);
1783}
1784
1785void TextureDrawAtPoint::onDraw(const Mat4 &transform, uint32_t flags)
1786{
1787 Director* director = Director::getInstance();
1788 CCASSERT(nullptr != director, "Director is null when setting matrix stack");
1789 director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
1790 director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform);
1791
1792 auto s = Director::getInstance()->getWinSize();
1793
1794 _tex1->drawAtPoint(Vec2(s.width/2-50, s.height/2 - 50), _globalZOrder);
1795 _Tex2F->drawAtPoint(Vec2(s.width/2+50, s.height/2 - 50), _globalZOrder);
1796
1797 director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
1798}
1799
1800// TextureDrawInRect
1801
1803{
1805 _tex1 = Director::getInstance()->getTextureCache()->addImage("Images/grossinis_sister1.png");
1806 _Tex2F = Director::getInstance()->getTextureCache()->addImage("Images/grossinis_sister2.png");
1807
1808 _tex1->retain();
1809 _Tex2F->retain();
1810}
1811
1813{
1814 _tex1->release();
1815 _Tex2F->release();
1816}
1817
1818void TextureDrawInRect::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
1819{
1820 TextureDemo::draw(renderer, transform, flags);
1821 onDraw(transform, flags);
1822}
1823
1824void TextureDrawInRect::onDraw(const Mat4 &transform, uint32_t flags)
1825{
1826 Director* director = Director::getInstance();
1827 CCASSERT(nullptr != director, "Director is null when setting matrix stack");
1828 director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
1829 director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform);
1830
1831 auto s = Director::getInstance()->getWinSize();
1832
1833 auto rect1 = Rect( s.width/2 - 80, 20, _tex1->getContentSize().width * 0.5f, _tex1->getContentSize().height *2 );
1834 auto rect2 = Rect( s.width/2 + 80, s.height/2, _tex1->getContentSize().width * 2, _tex1->getContentSize().height * 0.5f );
1835
1836 _tex1->drawInRect(rect1, _globalZOrder);
1837 _Tex2F->drawInRect(rect2, _globalZOrder);
1838
1839 director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
1840}
1841
1842std::string TextureDrawInRect::title() const
1843{
1844 return "CCTexture2D: drawInRect";
1845}
1846
1848{
1849 return "draws 2 textures using drawInRect";
1850}
1851
1852//------------------------------------------------------------------
1853//
1854// TextureMemoryAlloc
1855//
1856//------------------------------------------------------------------
1858{
1860 _background = nullptr;
1861
1862 MenuItemFont::setFontSize(24);
1863
1864 auto item1 = MenuItemFont::create("PNG", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
1865 item1->setTag(0);
1866
1867 auto item2 = MenuItemFont::create("RGBA8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
1868 item2->setTag(1);
1869
1870 auto item3 = MenuItemFont::create("RGB8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
1871 item3->setTag(2);
1872
1873 auto item4 = MenuItemFont::create("RGBA4", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
1874 item4->setTag(3);
1875
1876 auto item5 = MenuItemFont::create("A8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
1877 item5->setTag(4);
1878
1879 auto menu = Menu::create(item1, item2, item3, item4, item5, nullptr);
1880 menu->alignItemsHorizontally();
1881
1882 addChild(menu);
1883
1884 auto warmup = MenuItemFont::create("warm up texture", CC_CALLBACK_1(TextureMemoryAlloc::changeBackgroundVisible, this));
1885
1886 auto menu2 = Menu::create(warmup, nullptr);
1887
1888 menu2->alignItemsHorizontally();
1889
1890 addChild(menu2);
1891 auto s = Director::getInstance()->getWinSize();
1892
1893 menu2->setPosition(Vec2(s.width/2, s.height/4));
1894}
1895
1897{
1898 if (_background)
1899 {
1900 _background->setVisible(true);
1901 }
1902}
1903
1904void TextureMemoryAlloc::updateImage(cocos2d::Ref *sender)
1905{
1906 if (_background)
1907 {
1908 _background->removeFromParentAndCleanup(true);
1909 }
1910
1911 Director::getInstance()->getTextureCache()->removeUnusedTextures();
1912
1913 int tag = ((Node*)sender)->getTag();
1914 std::string file;
1915 switch (tag)
1916 {
1917 case 0:
1918 file = "Images/test_image.png";
1919 break;
1920 case 1:
1921 file = "Images/test_image_rgba8888.pvr";
1922 break;
1923 case 2:
1924 file = "Images/test_image_rgb888.pvr";
1925 break;
1926 case 3:
1927 file = "Images/test_image_rgba4444.pvr";
1928 break;
1929 case 4:
1930 file = "Images/test_image_a8.pvr";
1931 break;
1932 }
1933
1934 _background = Sprite::create(file.c_str());
1935 addChild(_background, -10);
1936
1937 _background->setVisible(false);
1938
1939 auto s = Director::getInstance()->getWinSize();
1940 _background->setPosition(Vec2(s.width/2, s.height/2));
1941}
1942
1943std::string TextureMemoryAlloc::title() const
1944{
1945 return "Texture memory";
1946}
1947
1949{
1950 return "Testing Texture Memory allocation. Use Instruments + VM Tracker";
1951}
1952
1953// TexturePVRv3Premult
1955{
1956 auto size = Director::getInstance()->getWinSize();
1957
1958 auto background = LayerColor::create(Color4B(128,128,128,255), size.width, size.height);
1959 addChild(background, -1);
1960
1961
1962 // PVR premultiplied
1963 auto pvr1 = Sprite::create("Images/grossinis_sister1-testalpha_premult.pvr");
1964 addChild(pvr1, 0);
1965 pvr1->setPosition(Vec2(size.width/4*1, size.height/2));
1966 transformSprite(pvr1);
1967
1968 // PVR non-premultiplied
1969 auto pvr2 = Sprite::create("Images/grossinis_sister1-testalpha_nopremult.pvr");
1970 addChild(pvr2, 0);
1971 pvr2->setPosition(Vec2(size.width/4*2, size.height/2));
1972 transformSprite(pvr2);
1973
1974 // PNG
1975 Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGBA8888);
1976 Director::getInstance()->getTextureCache()->removeTextureForKey("Images/grossinis_sister1-testalpha.png");
1977 auto png = Sprite::create("Images/grossinis_sister1-testalpha.png");
1978 addChild(png, 0);
1979 png->setPosition(Vec2(size.width/4*3, size.height/2));
1980 transformSprite(png);
1981}
1982
1984{
1985 return "PVRv3 Premult Flag";
1986}
1987
1989{
1990 return "All images should look exactly the same";
1991}
1992
1993void TexturePVRv3Premult::transformSprite(cocos2d::Sprite *sprite)
1994{
1995 auto fade = FadeOut::create(2);
1996 auto dl = DelayTime::create(2);
1997 auto fadein = fade->reverse();
1998 auto seq = Sequence::create(fade, fadein, dl, nullptr);
1999 auto repeat = RepeatForever::create(seq);
2000 sprite->runAction(repeat);
2001}
2002
2003// Implementation of ETC1
2005{
2006 auto sprite = Sprite::create("Images/ETC1.pkm");
2007
2008 auto size = Director::getInstance()->getWinSize();
2009 sprite->setPosition(Vec2(size.width/2, size.height/2));
2010
2011 addChild(sprite);
2012}
2013
2014std::string TextureETC1::title() const
2015{
2016 return "ETC1 texture";
2017}
2018
2019std::string TextureETC1::subtitle() const
2020{
2021 bool isSupportETCHardwareDecode = Configuration::getInstance()->supportsETC();
2022 Application::Platform platform = Application::getInstance()->getTargetPlatform();
2023 std::string ret;
2024
2025 static std::unordered_map<int, const char*> platformMap = {
2026 {(int)Application::Platform::OS_WINDOWS, "Windows"},
2027 {(int)Application::Platform::OS_LINUX, "Linux"},
2028 {(int)Application::Platform::OS_MAC, "macOS"},
2029 {(int)Application::Platform::OS_ANDROID, "Android"},
2030 {(int)Application::Platform::OS_IPHONE, "iPhone"},
2031 {(int)Application::Platform::OS_IPAD, "iPad"},
2032 };
2033
2034 if (isSupportETCHardwareDecode)
2035 {
2036 ret += "Hardware decode ETC1 on ";
2037
2038 }
2039 else
2040 {
2041 ret += "Software decode ETC1 on ";
2042 }
2043
2044 auto iter = platformMap.find((int)platform);
2045 if (iter != platformMap.end())
2046 {
2047 ret += iter->second;
2048 }
2049 else
2050 {
2051 ret += "Unknown Platform";
2052 }
2053
2054 return ret;
2055}
2056
2057//Implement of S3TC Dxt1
2059{
2060 auto sprite = Sprite::create("Images/test_256x256_s3tc_dxt1_mipmaps.dds");
2061 //auto sprite = Sprite::create("Images/water_2_dxt1.dds");
2062 auto size = Director::getInstance()->getWinSize();
2063 sprite->setPosition(Vec2(size.width / 2, size.height / 2));
2064
2065 addChild(sprite);
2066}
2067std::string TextureS3TCDxt1::title() const
2068{
2069 return "S3TC texture test#1";
2070}
2071std::string TextureS3TCDxt1::subtitle() const
2072{
2073 return "S3TC dxt1 decode,one bit for Alpha";
2074}
2075
2076//Implement of S3TC Dxt3
2078{
2079 auto sprite = Sprite::create("Images/test_256x256_s3tc_dxt3_mipmaps.dds");
2080 //auto sprite = Sprite::create("Images/water_2_dxt3.dds");
2081 auto size = Director::getInstance()->getWinSize();
2082 sprite->setPosition(Vec2(size.width / 2, size.height / 2));
2083
2084 addChild(sprite);
2085}
2086std::string TextureS3TCDxt3::title() const
2087{
2088 return "S3TC texture test#2";
2089}
2090std::string TextureS3TCDxt3::subtitle() const
2091{
2092 return "S3TC dxt3 decode";
2093}
2094
2095//Implement of S3TC Dxt5
2097{
2098 auto sprite = Sprite::create("Images/test_256x256_s3tc_dxt5_mipmaps.dds");
2099 //auto sprite = Sprite::create("Images/water_2_dxt5.dds");
2100 auto size = Director::getInstance()->getWinSize();
2101 sprite->setPosition(Vec2(size.width / 2, size.height / 2));
2102
2103 addChild(sprite);
2104}
2105std::string TextureS3TCDxt5::title() const
2106{
2107 return "S3TC texture test#3";
2108}
2109std::string TextureS3TCDxt5::subtitle() const
2110{
2111 return "S3TC dxt5 decode";
2112}
2113
2114//Implement of S3TC with no mipmaps
2116{
2117 auto sprite = Sprite::create("Images/test_512x512_s3tc_dxt5_with_no_mipmaps.dds");
2118 auto size = Director::getInstance()->getWinSize();
2119 sprite->setPosition(Vec2(size.width / 2, size.height / 2));
2120
2121 addChild(sprite);
2122}
2124{
2125 return "S3TC with no mipmaps";
2126}
2127
2128//Implement of ATITC
2130{
2131 auto sprite = Sprite::create("Images/test_256x256_ATC_RGB_mipmaps.ktx");
2132
2133 auto size = Director::getInstance()->getWinSize();
2134 sprite->setPosition(Vec2(size.width / 2, size.height / 2));
2135
2136 addChild(sprite);
2137}
2138std::string TextureATITCRGB::title() const
2139{
2140 return "ATITC texture (*.ktx file) test#1";
2141}
2142std::string TextureATITCRGB::subtitle() const
2143{
2144 return "ATITC RGB (no Alpha channel) compressed texture test";
2145}
2146
2148{
2149 auto sprite = Sprite::create("Images/test_256x256_ATC_RGBA_Explicit_mipmaps.ktx");
2150
2151 auto size = Director::getInstance()->getWinSize();
2152 sprite->setPosition(Vec2(size.width / 2, size.height / 2));
2153
2154 addChild(sprite);
2155}
2157{
2158 return "ATITC texture (*.ktx file) test#2";
2159}
2161{
2162 return "ATITC RGBA explicit Alpha compressed texture test";
2163}
2164
2166{
2167 auto sprite = Sprite::create("Images/test_256x256_ATC_RGBA_Interpolated_mipmaps.ktx");
2168
2169 auto size = Director::getInstance()->getWinSize();
2170 sprite->setPosition(Vec2(size.width / 2, size.height /2));
2171
2172 addChild(sprite);
2173}
2175{
2176 return "ATITC texture (*.ktx file) test#3";
2177}
2179{
2180 return "ATITC RGBA Interpolated Alpha compressed texture test";
2181}
2182
2183static void addImageToDemo(TextureDemo& demo, float x, float y, const char* path, backend::PixelFormat format)
2184{
2185 Texture2D::setDefaultAlphaPixelFormat(format);
2186 auto sprite = Sprite::create(path);
2187 sprite->setPosition(Vec2(x, y));
2188 demo.addChild(sprite, 0);
2189
2190 //remove texture from texture manager
2191 Director::getInstance()->getTextureCache()->removeTexture(sprite->getTexture());
2192}
2193
2194//TextureConvertRGB888
2196{
2198
2199 auto s = Director::getInstance()->getWinSize();
2200
2201 auto background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height);
2202 addChild(background, -1);
2203
2204 const char* img = "Images/test_image_rgb888.png";
2205 addImageToDemo(*this, 1*s.width/9, s.height/2+32, img, backend::PixelFormat::RGBA8888);
2206 addImageToDemo(*this, 2*s.width/9, s.height/2-32, img, backend::PixelFormat::RGB888);
2207 addImageToDemo(*this, 3*s.width/9, s.height/2+32, img, backend::PixelFormat::RGB565);
2208 addImageToDemo(*this, 4*s.width/9, s.height/2-32, img, backend::PixelFormat::A8);
2209 addImageToDemo(*this, 5*s.width/9, s.height/2+32, img, backend::PixelFormat::I8);
2210 addImageToDemo(*this, 6*s.width/9, s.height/2-32, img, backend::PixelFormat::AI88);
2211 addImageToDemo(*this, 7*s.width/9, s.height/2+32, img, backend::PixelFormat::RGBA4444);
2212 addImageToDemo(*this, 8*s.width/9, s.height/2-32, img, backend::PixelFormat::RGB5A1);
2213
2214 // restore default
2215 Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::DEFAULT);
2216 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
2217}
2218
2220{
2221 return "RGB888 convert test";
2222}
2223
2225{
2226 return "RGBA8888,RGB888,RGB565,A8,I8,AI88,RGBA4444,RGB5A1";
2227}
2228//TextureConvertRGBA8888
2230{
2232
2233 auto s = Director::getInstance()->getWinSize();
2234
2235 auto background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height);
2236 addChild(background, -1);
2237
2238 const char* img = "Images/test_image_rgba8888.png";
2239 addImageToDemo(*this, 1*s.width/9, s.height/2+32, img, backend::PixelFormat::RGBA8888);
2240 addImageToDemo(*this, 2*s.width/9, s.height/2-32, img, backend::PixelFormat::RGB888);
2241 addImageToDemo(*this, 3*s.width/9, s.height/2+32, img, backend::PixelFormat::RGB565);
2242 addImageToDemo(*this, 4*s.width/9, s.height/2-32, img, backend::PixelFormat::A8);
2243 addImageToDemo(*this, 5*s.width/9, s.height/2+32, img, backend::PixelFormat::I8);
2244 addImageToDemo(*this, 6*s.width/9, s.height/2-32, img, backend::PixelFormat::AI88);
2245 addImageToDemo(*this, 7*s.width/9, s.height/2+32, img, backend::PixelFormat::RGBA4444);
2246 addImageToDemo(*this, 8*s.width/9, s.height/2-32, img, backend::PixelFormat::RGB5A1);
2247
2248 // restore default
2249 Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::DEFAULT);
2250 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
2251}
2252
2254{
2255 return "RGBA8888 convert test";
2256}
2257
2259{
2260 return "RGBA8888,RGB888,RGB565,A8,I8,AI88,RGBA4444,RGB5A1";
2261}
2262//TextureConvertI8
2264{
2266
2267 auto s = Director::getInstance()->getWinSize();
2268
2269 auto background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height);
2270 addChild(background, -1);
2271
2272 const char* img = "Images/test_image_i8.png";
2273 addImageToDemo(*this, 1*s.width/9, s.height/2+32, img, backend::PixelFormat::RGBA8888);
2274 addImageToDemo(*this, 2*s.width/9, s.height/2-32, img, backend::PixelFormat::RGB888);
2275 addImageToDemo(*this, 3*s.width/9, s.height/2+32, img, backend::PixelFormat::RGB565);
2276 addImageToDemo(*this, 4*s.width/9, s.height/2-32, img, backend::PixelFormat::A8);
2277 addImageToDemo(*this, 5*s.width/9, s.height/2+32, img, backend::PixelFormat::I8);
2278 addImageToDemo(*this, 6*s.width/9, s.height/2-32, img, backend::PixelFormat::AI88);
2279 addImageToDemo(*this, 7*s.width/9, s.height/2+32, img, backend::PixelFormat::RGBA4444);
2280 addImageToDemo(*this, 8*s.width/9, s.height/2-32, img, backend::PixelFormat::RGB5A1);
2281
2282 // restore default
2283 Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::DEFAULT);
2284 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
2285}
2286
2287std::string TextureConvertI8::title() const
2288{
2289 return "I8 convert test";
2290}
2291
2293{
2294 return "RGBA8888,RGB888,RGB565,A8,I8,AI88,RGBA4444,RGB5A1";
2295}
2296//TextureConvertAI88
2298{
2300
2301 auto s = Director::getInstance()->getWinSize();
2302
2303 auto background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height);
2304 addChild(background, -1);
2305
2306 const char* img = "Images/test_image_ai88.png";
2307 addImageToDemo(*this, 1*s.width/9, s.height/2+32, img, backend::PixelFormat::RGBA8888);
2308 addImageToDemo(*this, 2*s.width/9, s.height/2-32, img, backend::PixelFormat::RGB888);
2309 addImageToDemo(*this, 3*s.width/9, s.height/2+32, img, backend::PixelFormat::RGB565);
2310 addImageToDemo(*this, 4*s.width/9, s.height/2-32, img, backend::PixelFormat::A8);
2311 addImageToDemo(*this, 5*s.width/9, s.height/2+32, img, backend::PixelFormat::I8);
2312 addImageToDemo(*this, 6*s.width/9, s.height/2-32, img, backend::PixelFormat::AI88);
2313 addImageToDemo(*this, 7*s.width/9, s.height/2+32, img, backend::PixelFormat::RGBA4444);
2314 addImageToDemo(*this, 8*s.width/9, s.height/2-32, img, backend::PixelFormat::RGB5A1);
2315
2316 // restore default
2317 Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::DEFAULT);
2318 log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
2319}
2320
2321std::string TextureConvertAI88::title() const
2322{
2323 return "AI88 convert test";
2324}
2325
2327{
2328 return "RGBA8888,RGB888,RGB565,A8,I8,AI88,RGBA4444,RGB5A1";
2329}
#define ADD_TEST_CASE(__className__)
Definition: BaseTest.h:211
USING_NS_CC
@ kTagSprite2
@ kTagSprite1
@ kTagLabel
static void addImageToDemo(TextureDemo &demo, float x, float y, const char *path, backend::PixelFormat format)
virtual void onEnter() override
Definition: BaseTest.cpp:430
virtual std::string title() const override
virtual std::string subtitle() const override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string title() const override
void imageLoaded(cocos2d::Texture2D *texture)
virtual void onEnter() override
virtual ~TextureAsync()
virtual std::string subtitle() const override
void loadImages(float dt)
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual void onEnter() override
virtual ~TextureDemo()
void onDraw(const cocos2d::Mat4 &transform, uint32_t flags)
virtual void onEnter() override
cocos2d::Texture2D * _tex1
virtual std::string title() const override
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override
cocos2d::Texture2D * _Tex2F
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
cocos2d::Texture2D * _Tex2F
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override
virtual std::string subtitle() const override
cocos2d::Texture2D * _tex1
void onDraw(const cocos2d::Mat4 &transform, uint32_t flags)
virtual std::string subtitle() const override
virtual std::string title() const override
virtual void onEnter() override
virtual ~TextureGlClamp()
virtual std::string title() const override
virtual ~TextureGlRepeat()
virtual std::string title() const override
virtual void onEnter() override
virtual void onEnter() override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string subtitle() const override
cocos2d::Sprite * _background
void updateImage(cocos2d::Ref *sender)
void changeBackgroundVisible(cocos2d::Ref *sender)
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual void onEnter() override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string subtitle() const override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual void onEnter() override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual void onEnter() override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual void onEnter() override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string title() const override
void transformSprite(cocos2d::Sprite *sprite)
virtual std::string subtitle() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string title() const override
virtual void onEnter() override
virtual void onEnter() override
virtual std::string title() const override