2018-01-29 16:25:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2022-02-24 18:45:25 +08:00
|
|
|
https://adxeproject.github.io/
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-04-08 14:16:29 +08:00
|
|
|
#include "RenderTextureTest.h"
|
|
|
|
|
2015-04-09 12:23:47 +08:00
|
|
|
USING_NS_CC;
|
|
|
|
using namespace cocos2d::ui;
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
RenderTextureTests::RenderTextureTests()
|
|
|
|
{
|
|
|
|
ADD_TEST_CASE(RenderTextureSave);
|
|
|
|
ADD_TEST_CASE(RenderTextureIssue937);
|
|
|
|
ADD_TEST_CASE(RenderTextureZbuffer);
|
2019-06-19 09:04:56 +08:00
|
|
|
ADD_TEST_CASE(RenderTextureTestDepthStencil);
|
2015-04-03 14:31:03 +08:00
|
|
|
ADD_TEST_CASE(RenderTextureTargetNode);
|
|
|
|
ADD_TEST_CASE(SpriteRenderTextureBug);
|
|
|
|
ADD_TEST_CASE(RenderTexturePartTest);
|
2016-07-21 10:34:04 +08:00
|
|
|
ADD_TEST_CASE(Issue16113Test);
|
2021-12-28 16:06:23 +08:00
|
|
|
// ADD_TEST_CASE(RenderTextureWithSprite3DIssue16894); this Test makes no sense
|
2013-02-28 16:35:42 +08:00
|
|
|
};
|
2011-02-25 11:31:49 +08:00
|
|
|
|
2012-04-08 14:16:29 +08:00
|
|
|
/**
|
2021-12-28 16:06:23 +08:00
|
|
|
* Implementation of RenderTextureSave
|
|
|
|
*/
|
2012-04-08 14:16:29 +08:00
|
|
|
RenderTextureSave::RenderTextureSave()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// create a render texture, this is what we are going to draw into
|
2020-09-25 11:07:56 +08:00
|
|
|
_target = RenderTexture::create(s.width, s.height, backend::PixelFormat::RGBA8);
|
2013-06-15 14:03:30 +08:00
|
|
|
_target->retain();
|
2014-05-15 01:07:09 +08:00
|
|
|
_target->setPosition(Vec2(s.width / 2, s.height / 2));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2017-02-24 12:45:41 +08:00
|
|
|
// note that the render texture is a Node, and contains a sprite of its texture for convenience,
|
2013-06-20 14:17:10 +08:00
|
|
|
// so we can just parent it to the scene like any other Node
|
2013-06-15 14:03:30 +08:00
|
|
|
this->addChild(_target, -1);
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto listener = EventListenerTouchAllAtOnce::create();
|
2013-10-23 16:14:03 +08:00
|
|
|
listener->onTouchesMoved = CC_CALLBACK_2(RenderTextureSave::onTouchesMoved, this);
|
2013-10-26 15:04:01 +08:00
|
|
|
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// Save Image menu
|
2013-06-20 14:17:10 +08:00
|
|
|
MenuItemFont::setFontSize(16);
|
2021-12-28 16:06:23 +08:00
|
|
|
auto item1 =
|
|
|
|
MenuItemFont::create("Save Image PMA", CC_CALLBACK_1(RenderTextureSave::saveImageWithPremultipliedAlpha, this));
|
|
|
|
auto item2 = MenuItemFont::create("Save Image Non-PMA",
|
|
|
|
CC_CALLBACK_1(RenderTextureSave::saveImageWithNonPremultipliedAlpha, this));
|
2019-07-26 17:09:00 +08:00
|
|
|
auto item3 = MenuItemFont::create("Add Image", CC_CALLBACK_1(RenderTextureSave::addImage, this));
|
|
|
|
auto item4 = MenuItemFont::create("Clear to Random", CC_CALLBACK_1(RenderTextureSave::clearImage, this));
|
2021-12-28 16:06:23 +08:00
|
|
|
auto item5 =
|
|
|
|
MenuItemFont::create("Clear to Transparent", CC_CALLBACK_1(RenderTextureSave::clearImageTransparent, this));
|
2019-07-26 17:09:00 +08:00
|
|
|
auto menu = Menu::create(item1, item2, item3, item4, item5, nullptr);
|
2012-04-19 14:35:52 +08:00
|
|
|
this->addChild(menu);
|
|
|
|
menu->alignItemsVertically();
|
2019-07-26 17:09:00 +08:00
|
|
|
menu->setPosition(Vec2(VisibleRect::rightTop().x - 80, VisibleRect::rightTop().y - 100));
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string RenderTextureSave::title() const
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Touch the screen";
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string RenderTextureSave::subtitle() const
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Press 'Save Image' to create an snapshot of the render texture";
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
void RenderTextureSave::clearImage(cocos2d::Ref* sender)
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_target->clear(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1());
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
2019-07-26 17:09:00 +08:00
|
|
|
void RenderTextureSave::clearImageTransparent(cocos2d::Ref* sender)
|
|
|
|
{
|
|
|
|
_target->clear(0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RenderTextureSave::saveImageWithPremultipliedAlpha(cocos2d::Ref* sender)
|
|
|
|
{
|
|
|
|
static int counter = 0;
|
|
|
|
|
|
|
|
char png[20];
|
|
|
|
sprintf(png, "image-pma-%d.png", counter);
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto callback = [&](RenderTexture* rt, std::string_view path) {
|
2019-07-26 17:09:00 +08:00
|
|
|
auto sprite = Sprite::create(path);
|
|
|
|
addChild(sprite);
|
|
|
|
sprite->setScale(0.3f);
|
2019-09-24 11:31:35 +08:00
|
|
|
sprite->setPosition(Vec2(40.0f, 40.0f));
|
2019-07-26 17:09:00 +08:00
|
|
|
sprite->setRotation(counter * 3);
|
|
|
|
_target->release();
|
|
|
|
};
|
|
|
|
|
|
|
|
_target->retain();
|
|
|
|
_target->saveToFile(png, Image::Format::PNG, true, callback);
|
2021-12-28 16:06:23 +08:00
|
|
|
// Add this function to avoid crash if we switch to a new scene.
|
2019-07-26 17:09:00 +08:00
|
|
|
Director::getInstance()->getRenderer()->render();
|
|
|
|
CCLOG("Image saved %s", png);
|
|
|
|
|
|
|
|
counter++;
|
|
|
|
}
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
void RenderTextureSave::saveImageWithNonPremultipliedAlpha(cocos2d::Ref* sender)
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
static int counter = 0;
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
char png[20];
|
2019-07-26 17:09:00 +08:00
|
|
|
sprintf(png, "image-no-pma-%d.png", counter);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
auto callback = [&](RenderTexture* rt, std::string_view path) {
|
2014-08-12 10:50:57 +08:00
|
|
|
auto sprite = Sprite::create(path);
|
2014-03-07 17:41:51 +08:00
|
|
|
addChild(sprite);
|
|
|
|
sprite->setScale(0.3f);
|
2019-09-24 11:31:35 +08:00
|
|
|
sprite->setPosition(Vec2(40.0f, 40.0f));
|
2014-03-07 17:41:51 +08:00
|
|
|
sprite->setRotation(counter * 3);
|
2019-02-27 11:29:20 +08:00
|
|
|
rt->release();
|
2014-03-07 17:41:51 +08:00
|
|
|
};
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2019-02-27 11:29:20 +08:00
|
|
|
_target->retain();
|
2019-07-26 17:09:00 +08:00
|
|
|
_target->saveToFileAsNonPMA(png, Image::Format::PNG, true, callback);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
// Add this function to avoid crash if we switch to a new scene.
|
2015-03-19 16:39:45 +08:00
|
|
|
Director::getInstance()->getRenderer()->render();
|
2014-08-12 10:50:57 +08:00
|
|
|
CCLOG("Image saved %s", png);
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
counter++;
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
2019-07-26 17:09:00 +08:00
|
|
|
void RenderTextureSave::addImage(cocos2d::Ref* sender)
|
|
|
|
{
|
|
|
|
auto s = Director::getInstance()->getWinSize();
|
|
|
|
|
|
|
|
// begin drawing to the render texture
|
|
|
|
_target->begin();
|
|
|
|
|
|
|
|
Sprite* sprite = Sprite::create("Images/test-rgba1.png");
|
2021-12-28 16:06:23 +08:00
|
|
|
sprite->setPosition(
|
|
|
|
sprite->getContentSize().width + CCRANDOM_0_1() * (s.width - sprite->getContentSize().width),
|
|
|
|
sprite->getContentSize().height + CCRANDOM_0_1() * (s.height - sprite->getContentSize().height));
|
2019-07-26 17:09:00 +08:00
|
|
|
sprite->visit();
|
|
|
|
|
|
|
|
// finish drawing and return context back to the screen
|
|
|
|
_target->end();
|
|
|
|
}
|
|
|
|
|
2012-04-08 14:16:29 +08:00
|
|
|
RenderTextureSave::~RenderTextureSave()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_target->release();
|
2013-11-07 21:48:39 +08:00
|
|
|
Director::getInstance()->getTextureCache()->removeUnusedTextures();
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
2013-09-03 18:22:03 +08:00
|
|
|
void RenderTextureSave::onTouchesMoved(const std::vector<Touch*>& touches, Event* event)
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto touch = touches[0];
|
|
|
|
auto start = touch->getLocation();
|
|
|
|
auto end = touch->getPreviousLocation();
|
|
|
|
|
|
|
|
// begin drawing to the render texture
|
|
|
|
_target->begin();
|
|
|
|
|
|
|
|
// for extra points, we'll draw this smoothly from the last position and vary the sprite's
|
|
|
|
// scale/rotation/offset
|
|
|
|
float distance = start.getDistance(end);
|
|
|
|
if (distance > 1)
|
|
|
|
{
|
|
|
|
int d = (int)distance;
|
|
|
|
_brushs.clear();
|
|
|
|
for (int i = 0; i < d; ++i)
|
|
|
|
{
|
|
|
|
Sprite* sprite = Sprite::create("Images/fire.png");
|
|
|
|
sprite->setColor(Color3B::RED);
|
|
|
|
sprite->setOpacity(20);
|
|
|
|
_brushs.pushBack(sprite);
|
|
|
|
}
|
|
|
|
for (int i = 0; i < d; i++)
|
|
|
|
{
|
|
|
|
float difx = end.x - start.x;
|
|
|
|
float dify = end.y - start.y;
|
|
|
|
float delta = (float)i / distance;
|
|
|
|
_brushs.at(i)->setPosition(Vec2(start.x + (difx * delta), start.y + (dify * delta)));
|
|
|
|
_brushs.at(i)->setRotation(rand() % 360);
|
|
|
|
float r = (float)(rand() % 50 / 50.f) + 0.25f;
|
|
|
|
_brushs.at(i)->setScale(r);
|
|
|
|
/*_brush->setColor(Color3B(CCRANDOM_0_1() * 127 + 128, 255, 255));*/
|
|
|
|
// Use CCRANDOM_0_1() will cause error when loading libtests.so on android, I don't know why.
|
|
|
|
_brushs.at(i)->setColor(Color3B(rand() % 127 + 128, 255, 255));
|
|
|
|
// Call visit to draw the brush, don't call draw..
|
|
|
|
_brushs.at(i)->visit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// finish drawing and return context back to the screen
|
|
|
|
_target->end();
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-02-10 10:35:52 +08:00
|
|
|
* Implementation of RenderTextureIssue937
|
2012-04-08 14:16:29 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
RenderTextureIssue937::RenderTextureIssue937()
|
|
|
|
{
|
|
|
|
/*
|
2021-12-28 16:06:23 +08:00
|
|
|
* 1 2
|
|
|
|
* A: A1 A2
|
|
|
|
*
|
|
|
|
* B: B1 B2
|
|
|
|
*
|
|
|
|
* A1: premulti sprite
|
|
|
|
* A2: premulti render
|
|
|
|
*
|
|
|
|
* B1: non-premulti sprite
|
|
|
|
* B2: non-premulti render
|
|
|
|
*/
|
|
|
|
auto background = LayerColor::create(Color4B(200, 200, 200, 255));
|
2012-04-08 14:16:29 +08:00
|
|
|
addChild(background);
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto spr_premulti = Sprite::create("Images/fire.png");
|
2021-12-28 16:06:23 +08:00
|
|
|
spr_premulti->setPosition(Vec2(s.width / 2 - 16, s.height / 2 + 16));
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto spr_nonpremulti = Sprite::create("Images/fire.png");
|
2021-12-28 16:06:23 +08:00
|
|
|
spr_nonpremulti->setPosition(Vec2(s.width / 2 - 16, s.height / 2 - 16));
|
|
|
|
|
2012-04-08 14:16:29 +08:00
|
|
|
/* A2 & B2 setup */
|
2020-09-25 11:07:56 +08:00
|
|
|
auto rend = RenderTexture::create(32, 64, backend::PixelFormat::RGBA8);
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2014-07-10 00:45:27 +08:00
|
|
|
if (nullptr == rend)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2014-04-09 13:40:43 +08:00
|
|
|
auto spr_size = spr_premulti->getContentSize();
|
|
|
|
rend->setKeepMatrix(true);
|
|
|
|
Size pixelSize = Director::getInstance()->getWinSizeInPixels();
|
2021-12-28 16:06:23 +08:00
|
|
|
rend->setVirtualViewport(Vec2(s.width / 2 - 32, s.height / 2 - 32), Rect(0, 0, s.width, s.height),
|
|
|
|
Rect(0, 0, pixelSize.width, pixelSize.height));
|
2014-04-09 13:40:43 +08:00
|
|
|
|
2012-04-08 14:16:29 +08:00
|
|
|
// It's possible to modify the RenderTexture blending function by
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
// [[rend sprite] setBlendFunc:(BlendFunc) {BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA}];
|
2012-04-08 14:16:29 +08:00
|
|
|
rend->begin();
|
|
|
|
spr_premulti->visit();
|
|
|
|
spr_nonpremulti->visit();
|
2014-04-09 13:40:43 +08:00
|
|
|
rend->end();
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
rend->setPosition(Vec2(s.width / 2 + 16, s.height / 2));
|
2012-04-08 14:16:29 +08:00
|
|
|
|
|
|
|
addChild(spr_nonpremulti);
|
|
|
|
addChild(spr_premulti);
|
|
|
|
addChild(rend);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string RenderTextureIssue937::title() const
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
|
|
|
return "Testing issue #937";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string RenderTextureIssue937::subtitle() const
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
|
|
|
return "All images should be equal...";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-12-28 16:06:23 +08:00
|
|
|
* Implementation of RenderTextureZbuffer
|
|
|
|
*/
|
2012-04-08 14:16:29 +08:00
|
|
|
|
|
|
|
RenderTextureZbuffer::RenderTextureZbuffer()
|
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto listener = EventListenerTouchAllAtOnce::create();
|
2013-10-23 16:14:03 +08:00
|
|
|
listener->onTouchesBegan = CC_CALLBACK_2(RenderTextureZbuffer::onTouchesBegan, this);
|
|
|
|
listener->onTouchesMoved = CC_CALLBACK_2(RenderTextureZbuffer::onTouchesMoved, this);
|
|
|
|
listener->onTouchesEnded = CC_CALLBACK_2(RenderTextureZbuffer::onTouchesEnded, this);
|
2013-10-26 15:04:01 +08:00
|
|
|
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
auto size = Director::getInstance()->getWinSize();
|
2014-04-09 23:31:05 +08:00
|
|
|
auto label = Label::createWithTTF("vertexZ = 50", "fonts/Marker Felt.ttf", 64);
|
2014-05-15 01:07:09 +08:00
|
|
|
label->setPosition(Vec2(size.width / 2, size.height * 0.25f));
|
2012-04-19 14:35:52 +08:00
|
|
|
this->addChild(label);
|
|
|
|
|
2014-04-09 23:31:05 +08:00
|
|
|
auto label2 = Label::createWithTTF("vertexZ = 0", "fonts/Marker Felt.ttf", 64);
|
2014-05-15 01:07:09 +08:00
|
|
|
label2->setPosition(Vec2(size.width / 2, size.height * 0.5f));
|
2012-04-19 14:35:52 +08:00
|
|
|
this->addChild(label2);
|
|
|
|
|
2014-04-09 23:31:05 +08:00
|
|
|
auto label3 = Label::createWithTTF("vertexZ = -50", "fonts/Marker Felt.ttf", 64);
|
2014-05-15 01:07:09 +08:00
|
|
|
label3->setPosition(Vec2(size.width / 2, size.height * 0.75f));
|
2012-04-19 14:35:52 +08:00
|
|
|
this->addChild(label3);
|
|
|
|
|
2014-03-24 10:12:40 +08:00
|
|
|
label->setPositionZ(50);
|
|
|
|
label2->setPositionZ(0);
|
|
|
|
label3->setPositionZ(-50);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Images/bugs/circle.plist");
|
2013-06-20 14:17:10 +08:00
|
|
|
mgr = SpriteBatchNode::create("Images/bugs/circle.png", 9);
|
2012-04-19 14:35:52 +08:00
|
|
|
this->addChild(mgr);
|
2013-06-20 14:17:10 +08:00
|
|
|
sp1 = Sprite::createWithSpriteFrameName("circle.png");
|
|
|
|
sp2 = Sprite::createWithSpriteFrameName("circle.png");
|
|
|
|
sp3 = Sprite::createWithSpriteFrameName("circle.png");
|
|
|
|
sp4 = Sprite::createWithSpriteFrameName("circle.png");
|
|
|
|
sp5 = Sprite::createWithSpriteFrameName("circle.png");
|
|
|
|
sp6 = Sprite::createWithSpriteFrameName("circle.png");
|
|
|
|
sp7 = Sprite::createWithSpriteFrameName("circle.png");
|
|
|
|
sp8 = Sprite::createWithSpriteFrameName("circle.png");
|
|
|
|
sp9 = Sprite::createWithSpriteFrameName("circle.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
mgr->addChild(sp1, 9);
|
|
|
|
mgr->addChild(sp2, 8);
|
|
|
|
mgr->addChild(sp3, 7);
|
|
|
|
mgr->addChild(sp4, 6);
|
|
|
|
mgr->addChild(sp5, 5);
|
|
|
|
mgr->addChild(sp6, 4);
|
|
|
|
mgr->addChild(sp7, 3);
|
|
|
|
mgr->addChild(sp8, 2);
|
|
|
|
mgr->addChild(sp9, 1);
|
|
|
|
|
2014-03-24 10:12:40 +08:00
|
|
|
sp1->setPositionZ(400);
|
|
|
|
sp2->setPositionZ(300);
|
|
|
|
sp3->setPositionZ(200);
|
|
|
|
sp4->setPositionZ(100);
|
|
|
|
sp5->setPositionZ(0);
|
|
|
|
sp6->setPositionZ(-100);
|
|
|
|
sp7->setPositionZ(-200);
|
|
|
|
sp8->setPositionZ(-300);
|
|
|
|
sp9->setPositionZ(-400);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
sp9->setScale(2);
|
2013-07-08 18:11:32 +08:00
|
|
|
sp9->setColor(Color3B::YELLOW);
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string RenderTextureZbuffer::title() const
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Testing Z Buffer in Render Texture";
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string RenderTextureZbuffer::subtitle() const
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Touch screen. It should be green";
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
void RenderTextureZbuffer::onTouchesBegan(const std::vector<Touch*>& touches, Event* event)
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2013-06-22 11:02:43 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
for (auto& item : touches)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto touch = static_cast<Touch*>(item);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto location = touch->getLocation();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
sp1->setPosition(location);
|
|
|
|
sp2->setPosition(location);
|
|
|
|
sp3->setPosition(location);
|
|
|
|
sp4->setPosition(location);
|
|
|
|
sp5->setPosition(location);
|
|
|
|
sp6->setPosition(location);
|
|
|
|
sp7->setPosition(location);
|
|
|
|
sp8->setPosition(location);
|
|
|
|
sp9->setPosition(location);
|
|
|
|
}
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
2013-09-03 18:22:03 +08:00
|
|
|
void RenderTextureZbuffer::onTouchesMoved(const std::vector<Touch*>& touches, Event* event)
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
for (auto& item : touches)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto touch = static_cast<Touch*>(item);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto location = touch->getLocation();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
sp1->setPosition(location);
|
|
|
|
sp2->setPosition(location);
|
|
|
|
sp3->setPosition(location);
|
|
|
|
sp4->setPosition(location);
|
|
|
|
sp5->setPosition(location);
|
|
|
|
sp6->setPosition(location);
|
|
|
|
sp7->setPosition(location);
|
|
|
|
sp8->setPosition(location);
|
|
|
|
sp9->setPosition(location);
|
|
|
|
}
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
2013-09-03 18:22:03 +08:00
|
|
|
void RenderTextureZbuffer::onTouchesEnded(const std::vector<Touch*>& touches, Event* event)
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
this->renderScreenShot();
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void RenderTextureZbuffer::renderScreenShot()
|
|
|
|
{
|
2013-12-23 17:13:41 +08:00
|
|
|
auto texture = RenderTexture::create(512, 512);
|
2014-07-10 00:45:27 +08:00
|
|
|
if (nullptr == texture)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
texture->begin();
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
this->visit();
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
texture->end();
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite = Sprite::createWithTexture(texture->getSprite()->getTexture());
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
sprite->setPosition(Vec2(256, 256));
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->setOpacity(182);
|
2013-09-16 20:38:03 +08:00
|
|
|
sprite->setFlippedY(1);
|
2012-04-19 14:35:52 +08:00
|
|
|
this->addChild(sprite, 999999);
|
2013-07-08 18:11:32 +08:00
|
|
|
sprite->setColor(Color3B::GREEN);
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
sprite->runAction(Sequence::create(FadeTo::create(2, 0), Hide::create(), nullptr));
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
2014-03-04 15:07:54 +08:00
|
|
|
RenderTexturePartTest::RenderTexturePartTest()
|
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto sprite1 = Sprite::create("Images/grossini.png");
|
|
|
|
auto sprite11 = Sprite::create("Images/grossini.png");
|
|
|
|
auto sprite2 = Sprite::create("Images/grossinis_sister1.png");
|
|
|
|
auto sprite22 = Sprite::create("Images/grossinis_sister1.png");
|
|
|
|
Size size = Director::getInstance()->getWinSize();
|
2014-03-04 15:07:54 +08:00
|
|
|
Size sprite1Size = sprite1->getContentSize();
|
2021-12-28 16:06:23 +08:00
|
|
|
sprite1->setPosition((size.width - sprite1Size.width) / 2 - 20, (size.height - sprite1Size.height) / 2 - 20);
|
|
|
|
sprite11->setPosition(size.width / 2 + 20, (size.height - sprite1Size.height) / 2 - 20);
|
|
|
|
|
|
|
|
sprite2->setPosition((size.width - sprite1Size.width) / 2 - 20, size.height / 2 + 20);
|
|
|
|
sprite22->setPosition(size.width / 2 + 20, size.height / 2 + 20);
|
|
|
|
|
2014-03-04 15:07:54 +08:00
|
|
|
addChild(sprite1);
|
|
|
|
addChild(sprite11);
|
|
|
|
addChild(sprite2);
|
|
|
|
addChild(sprite22);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2020-09-25 11:07:56 +08:00
|
|
|
_rend = RenderTexture::create(200, 200, backend::PixelFormat::RGBA8);
|
2014-03-04 15:07:54 +08:00
|
|
|
_rend->retain();
|
|
|
|
_rend->setKeepMatrix(true);
|
|
|
|
Size pixelSize = Director::getInstance()->getWinSizeInPixels();
|
2021-12-28 16:06:23 +08:00
|
|
|
_rend->setVirtualViewport(Vec2(size.width / 2 - 150, size.height / 2 - 150), Rect(0, 0, size.width, size.height),
|
|
|
|
Rect(0, 0, pixelSize.width, pixelSize.height));
|
|
|
|
|
2014-03-04 15:07:54 +08:00
|
|
|
_rend->beginWithClear(1, 0, 0, 1);
|
|
|
|
sprite1->visit();
|
|
|
|
sprite11->visit();
|
|
|
|
sprite2->visit();
|
|
|
|
sprite22->visit();
|
|
|
|
_rend->end();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
_spriteDraw = Sprite::createWithTexture(_rend->getSprite()->getTexture());
|
|
|
|
FiniteTimeAction* baseAction = MoveBy::create(1, Vec2(size.width, 0.0f));
|
|
|
|
_spriteDraw->setPosition(0, size.height / 2);
|
2014-03-04 15:24:06 +08:00
|
|
|
_spriteDraw->setScaleY(-1);
|
2021-12-28 16:06:23 +08:00
|
|
|
_spriteDraw->runAction(RepeatForever::create(Sequence::create(baseAction, baseAction->reverse(), nullptr)));
|
2014-03-04 15:07:54 +08:00
|
|
|
addChild(_spriteDraw);
|
|
|
|
}
|
|
|
|
|
|
|
|
RenderTexturePartTest::~RenderTexturePartTest()
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE(_rend);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string RenderTexturePartTest::title() const
|
|
|
|
{
|
|
|
|
return "Render Texture Part Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string RenderTexturePartTest::subtitle() const
|
|
|
|
{
|
|
|
|
return "Only Grabbing a sub region of fullscreen";
|
|
|
|
}
|
|
|
|
|
2012-06-14 18:37:57 +08:00
|
|
|
// RenderTextureTestDepthStencil
|
|
|
|
|
|
|
|
RenderTextureTestDepthStencil::RenderTextureTestDepthStencil()
|
|
|
|
{
|
2021-01-31 22:22:52 +08:00
|
|
|
auto s = _director->getWinSize();
|
|
|
|
|
|
|
|
_renderer = _director->getRenderer();
|
|
|
|
|
|
|
|
/// store old depth stencil desc
|
|
|
|
_dsDesc = _renderer->getDepthStencilDesc();
|
2012-06-14 18:37:57 +08:00
|
|
|
|
2013-12-31 14:48:07 +08:00
|
|
|
_spriteDS = Sprite::create("Images/fire.png");
|
|
|
|
_spriteDS->retain();
|
2019-09-24 11:31:35 +08:00
|
|
|
_spriteDS->setPosition(Vec2(s.width * 0.25f, 0.0f));
|
2013-12-31 14:48:07 +08:00
|
|
|
_spriteDS->setScale(10);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-12-31 14:48:07 +08:00
|
|
|
_spriteDraw = Sprite::create("Images/fire.png");
|
|
|
|
_spriteDraw->retain();
|
2019-09-24 11:31:35 +08:00
|
|
|
_spriteDraw->setPosition(Vec2(s.width * 0.25f, 0.0f));
|
2013-12-31 14:48:07 +08:00
|
|
|
_spriteDraw->setScale(10);
|
|
|
|
//! move sprite half width and height, and draw only where not marked
|
2021-12-28 16:06:23 +08:00
|
|
|
_spriteDraw->setPosition(_spriteDraw->getPosition() +
|
|
|
|
Vec2(_spriteDraw->getContentSize().width * _spriteDraw->getScale() * 0.5f,
|
|
|
|
_spriteDraw->getContentSize().height * _spriteDraw->getScale() * 0.5f));
|
|
|
|
|
2021-01-31 22:22:52 +08:00
|
|
|
_rtx = RenderTexture::create(s.width, s.height, backend::PixelFormat::RGBA4, PixelFormat::D24S8);
|
2013-12-31 14:48:07 +08:00
|
|
|
|
2021-01-31 22:22:52 +08:00
|
|
|
_rtx->setPosition(Vec2(s.width * 0.5f, s.height * 0.5f));
|
2013-12-31 14:48:07 +08:00
|
|
|
|
2021-01-31 22:22:52 +08:00
|
|
|
this->addChild(_rtx);
|
2013-12-31 14:48:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
RenderTextureTestDepthStencil::~RenderTextureTestDepthStencil()
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE(_spriteDraw);
|
|
|
|
CC_SAFE_RELEASE(_spriteDS);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2021-01-31 22:22:52 +08:00
|
|
|
// restore depth stencil desc
|
|
|
|
_renderer->setDepthStencilDesc(_dsDesc);
|
|
|
|
_renderer->setStencilTest(bitmask::any(_dsDesc.flags, DepthStencilFlags::STENCIL_TEST));
|
2013-12-31 14:48:07 +08:00
|
|
|
}
|
2012-06-14 18:37:57 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
void RenderTextureTestDepthStencil::draw(Renderer* renderer, const Mat4& transform, uint32_t flags)
|
2013-12-31 14:48:07 +08:00
|
|
|
{
|
2021-01-31 22:22:52 +08:00
|
|
|
_rtx->beginWithClear(0, 0, 0, 0, 0, 0);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2022-06-24 14:18:48 +08:00
|
|
|
// _renderCmds[0].init(_globalZOrder);
|
|
|
|
// _renderCmds[0].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeClear, this);
|
|
|
|
renderer->addCallbackCommand(CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeClear, this), _globalZOrder);
|
2014-03-01 08:10:48 +08:00
|
|
|
|
2022-06-24 14:18:48 +08:00
|
|
|
// _renderCmds[1].init(_globalZOrder);
|
|
|
|
// _renderCmds[1].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeStencil, this);
|
|
|
|
renderer->addCallbackCommand(CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeStencil, this), _globalZOrder);
|
2014-03-01 08:10:48 +08:00
|
|
|
|
2013-12-31 14:48:07 +08:00
|
|
|
_spriteDS->visit();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2022-06-24 14:18:48 +08:00
|
|
|
// _renderCmds[2].init(_globalZOrder);
|
|
|
|
// _renderCmds[2].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeDraw, this);
|
|
|
|
renderer->addCallbackCommand(CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeDraw, this), _globalZOrder);
|
2014-03-01 08:10:48 +08:00
|
|
|
|
2013-12-31 14:48:07 +08:00
|
|
|
_spriteDraw->visit();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2022-06-24 14:18:48 +08:00
|
|
|
// _renderCmds[3].init(_globalZOrder);
|
|
|
|
// _renderCmds[3].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onAfterDraw, this);
|
|
|
|
renderer->addCallbackCommand(CC_CALLBACK_0(RenderTextureTestDepthStencil::onAfterDraw, this), _globalZOrder);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2021-01-31 22:22:52 +08:00
|
|
|
/// !!!end will set current render target to default renderTarget
|
|
|
|
/// !!!all render target share one depthStencilDesc, TODO: optimize me?
|
|
|
|
_rtx->end();
|
2012-06-14 18:37:57 +08:00
|
|
|
}
|
|
|
|
|
2013-12-31 11:49:46 +08:00
|
|
|
void RenderTextureTestDepthStencil::onBeforeClear()
|
|
|
|
{
|
2021-01-31 22:22:52 +08:00
|
|
|
_renderer->setStencilWriteMask(0xFF);
|
2013-12-31 11:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void RenderTextureTestDepthStencil::onBeforeStencil()
|
|
|
|
{
|
|
|
|
//! mark sprite quad into stencil buffer
|
2021-01-31 22:22:52 +08:00
|
|
|
_renderer->setStencilTest(true);
|
|
|
|
_renderer->setStencilCompareFunction(backend::CompareFunction::NEVER, 1, 0xFF);
|
2021-12-28 16:06:23 +08:00
|
|
|
_renderer->setStencilOperation(backend::StencilOperation::REPLACE, backend::StencilOperation::REPLACE,
|
|
|
|
backend::StencilOperation::REPLACE);
|
2013-12-31 11:49:46 +08:00
|
|
|
}
|
|
|
|
|
2017-03-23 09:30:42 +08:00
|
|
|
void RenderTextureTestDepthStencil::onBeforeDraw()
|
2013-12-31 11:49:46 +08:00
|
|
|
{
|
2021-01-31 22:22:52 +08:00
|
|
|
_renderer->setStencilCompareFunction(backend::CompareFunction::NOT_EQUAL, 1, 0xFF);
|
2013-12-31 11:49:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void RenderTextureTestDepthStencil::onAfterDraw()
|
|
|
|
{
|
2021-01-31 22:22:52 +08:00
|
|
|
_renderer->setStencilTest(false);
|
2013-12-31 11:49:46 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string RenderTextureTestDepthStencil::title() const
|
2012-06-12 15:55:23 +08:00
|
|
|
{
|
|
|
|
return "Testing depthStencil attachment";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string RenderTextureTestDepthStencil::subtitle() const
|
2012-06-14 18:37:57 +08:00
|
|
|
{
|
|
|
|
return "Circle should be missing 1/4 of its region";
|
|
|
|
}
|
2012-06-12 15:55:23 +08:00
|
|
|
|
2012-11-20 16:45:59 +08:00
|
|
|
// RenderTextureTest
|
|
|
|
RenderTextureTargetNode::RenderTextureTargetNode()
|
|
|
|
{
|
|
|
|
/*
|
2021-12-28 16:06:23 +08:00
|
|
|
* 1 2
|
|
|
|
* A: A1 A2
|
|
|
|
*
|
|
|
|
* B: B1 B2
|
|
|
|
*
|
|
|
|
* A1: premulti sprite
|
|
|
|
* A2: premulti render
|
|
|
|
*
|
|
|
|
* B1: non-premulti sprite
|
|
|
|
* B2: non-premulti render
|
|
|
|
*/
|
|
|
|
auto background = LayerColor::create(Color4B(40, 40, 40, 255));
|
2012-11-20 16:45:59 +08:00
|
|
|
addChild(background);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-11-20 16:45:59 +08:00
|
|
|
// sprite 1
|
2013-06-20 14:17:10 +08:00
|
|
|
sprite1 = Sprite::create("Images/fire.png");
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-11-20 16:45:59 +08:00
|
|
|
// sprite 2
|
2013-06-20 14:17:10 +08:00
|
|
|
sprite2 = Sprite::create("Images/fire_rgba8888.pvr");
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-11-20 16:45:59 +08:00
|
|
|
/* Create the render texture */
|
2021-12-28 16:06:23 +08:00
|
|
|
auto renderTexture = RenderTexture::create(s.width, s.height, backend::PixelFormat::RGBA4);
|
2012-11-20 16:45:59 +08:00
|
|
|
this->renderTexture = renderTexture;
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
renderTexture->setPosition(Vec2(s.width / 2, s.height / 2));
|
2014-05-07 16:37:21 +08:00
|
|
|
// renderTexture->setScale(2.0f);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-11-20 16:45:59 +08:00
|
|
|
/* add the sprites to the render texture */
|
|
|
|
renderTexture->addChild(sprite1);
|
|
|
|
renderTexture->addChild(sprite2);
|
2013-07-05 16:49:22 +08:00
|
|
|
renderTexture->setClearColor(Color4F(0, 0, 0, 0));
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
renderTexture->setClearFlags(ClearFlag::COLOR);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-11-20 16:45:59 +08:00
|
|
|
/* add the render texture to the scene */
|
|
|
|
addChild(renderTexture);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-11-20 16:45:59 +08:00
|
|
|
renderTexture->setAutoDraw(true);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-11-20 16:45:59 +08:00
|
|
|
scheduleUpdate();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-11-20 16:45:59 +08:00
|
|
|
// Toggle clear on / off
|
2013-08-16 16:05:27 +08:00
|
|
|
auto item = MenuItemFont::create("Clear On/Off", CC_CALLBACK_1(RenderTextureTargetNode::touched, this));
|
2014-07-10 00:45:27 +08:00
|
|
|
auto menu = Menu::create(item, nullptr);
|
2012-11-20 16:45:59 +08:00
|
|
|
addChild(menu);
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
menu->setPosition(Vec2(s.width / 2, s.height / 2));
|
2012-11-20 16:45:59 +08:00
|
|
|
}
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void RenderTextureTargetNode::touched(Ref* sender)
|
2012-11-20 16:45:59 +08:00
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
// TODO: minggo
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
if (renderTexture->getClearFlags() == ClearFlag::NONE)
|
2012-11-20 16:45:59 +08:00
|
|
|
{
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
renderTexture->setClearFlags(ClearFlag::COLOR);
|
2012-11-20 16:45:59 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
renderTexture->setClearFlags(ClearFlag::NONE);
|
2021-12-28 16:06:23 +08:00
|
|
|
renderTexture->setClearColor(Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1));
|
2012-11-20 16:45:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RenderTextureTargetNode::update(float dt)
|
|
|
|
{
|
|
|
|
static float time = 0;
|
2021-12-28 16:06:23 +08:00
|
|
|
float r = 80;
|
2014-05-15 01:07:09 +08:00
|
|
|
sprite1->setPosition(Vec2(cosf(time * 2) * r, sinf(time * 2) * r));
|
|
|
|
sprite2->setPosition(Vec2(sinf(time * 2) * r, cosf(time * 2) * r));
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-11-20 16:45:59 +08:00
|
|
|
time += dt;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string RenderTextureTargetNode::title() const
|
2012-11-20 16:45:59 +08:00
|
|
|
{
|
|
|
|
return "Testing Render Target Node";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string RenderTextureTargetNode::subtitle() const
|
2012-11-20 16:45:59 +08:00
|
|
|
{
|
|
|
|
return "Sprites should be equal and move with each frame";
|
|
|
|
}
|
|
|
|
|
2013-02-28 16:35:42 +08:00
|
|
|
// SpriteRenderTextureBug
|
|
|
|
|
2013-11-15 08:33:43 +08:00
|
|
|
SpriteRenderTextureBug::SimpleSprite::SimpleSprite() : _rt(nullptr) {}
|
2014-04-11 16:05:22 +08:00
|
|
|
SpriteRenderTextureBug::SimpleSprite::~SimpleSprite()
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE(_rt);
|
|
|
|
}
|
2013-02-28 16:35:42 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::SimpleSprite::create(const char* filename,
|
|
|
|
const Rect& rect)
|
2013-02-28 16:35:42 +08:00
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
auto sprite = new SimpleSprite();
|
|
|
|
if (sprite->initWithFile(filename, rect))
|
2013-02-28 16:35:42 +08:00
|
|
|
{
|
|
|
|
sprite->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(sprite);
|
|
|
|
}
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-02-28 16:35:42 +08:00
|
|
|
return sprite;
|
|
|
|
}
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
void SpriteRenderTextureBug::SimpleSprite::draw(Renderer* renderer, const Mat4& transform, uint32_t flags)
|
2013-02-28 16:35:42 +08:00
|
|
|
{
|
2013-11-15 08:33:43 +08:00
|
|
|
if (_rt == nullptr)
|
2013-02-28 16:35:42 +08:00
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
|
|
|
_rt = RenderTexture::create(s.width, s.height, backend::PixelFormat::RGBA8);
|
2013-11-15 08:33:43 +08:00
|
|
|
_rt->retain();
|
2021-12-28 16:06:23 +08:00
|
|
|
}
|
|
|
|
_rt->beginWithClear(0.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
_rt->end();
|
2014-04-11 16:05:22 +08:00
|
|
|
|
2014-05-31 07:42:05 +08:00
|
|
|
Sprite::draw(renderer, transform, flags);
|
2013-02-28 16:35:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SpriteRenderTextureBug::SpriteRenderTextureBug()
|
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto listener = EventListenerTouchAllAtOnce::create();
|
2013-10-23 16:14:03 +08:00
|
|
|
listener->onTouchesEnded = CC_CALLBACK_2(SpriteRenderTextureBug::onTouchesEnded, this);
|
2013-10-26 15:04:01 +08:00
|
|
|
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2021-12-28 16:06:23 +08:00
|
|
|
addNewSpriteWithCoords(Vec2(s.width / 2, s.height / 2));
|
2013-02-28 16:35:42 +08:00
|
|
|
}
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::addNewSpriteWithCoords(const Vec2& p)
|
2013-02-28 16:35:42 +08:00
|
|
|
{
|
|
|
|
int idx = CCRANDOM_0_1() * 1400 / 100;
|
2021-12-28 16:06:23 +08:00
|
|
|
int x = (idx % 5) * 85;
|
|
|
|
int y = (idx / 5) * 121;
|
|
|
|
|
|
|
|
auto sprite = SpriteRenderTextureBug::SimpleSprite::create("Images/grossini_dance_atlas.png", Rect(x, y, 85, 121));
|
2013-02-28 16:35:42 +08:00
|
|
|
addChild(sprite);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-02-28 16:35:42 +08:00
|
|
|
sprite->setPosition(p);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
FiniteTimeAction* action = nullptr;
|
|
|
|
float rd = CCRANDOM_0_1();
|
|
|
|
|
|
|
|
if (rd < 0.20)
|
2013-06-20 14:17:10 +08:00
|
|
|
action = ScaleBy::create(3, 2);
|
2021-12-28 16:06:23 +08:00
|
|
|
else if (rd < 0.40)
|
|
|
|
action = RotateBy::create(3, 360);
|
|
|
|
else if (rd < 0.60)
|
|
|
|
action = Blink::create(1, 3);
|
|
|
|
else if (rd < 0.8)
|
|
|
|
action = TintBy::create(2, 0, -255, -255);
|
|
|
|
else
|
|
|
|
action = FadeOut::create(2);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto action_back = action->reverse();
|
2021-12-28 16:06:23 +08:00
|
|
|
auto seq = Sequence::create(action, action_back, nullptr);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
sprite->runAction(RepeatForever::create(seq));
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
// return sprite;
|
2014-07-10 00:45:27 +08:00
|
|
|
return nullptr;
|
2013-02-28 16:35:42 +08:00
|
|
|
}
|
|
|
|
|
2013-09-03 18:22:03 +08:00
|
|
|
void SpriteRenderTextureBug::onTouchesEnded(const std::vector<Touch*>& touches, Event* event)
|
2013-02-28 16:35:42 +08:00
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
for (auto& touch : touches)
|
2013-02-28 16:35:42 +08:00
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto location = touch->getLocation();
|
2013-02-28 16:35:42 +08:00
|
|
|
addNewSpriteWithCoords(location);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string SpriteRenderTextureBug::title() const
|
2013-02-28 16:35:42 +08:00
|
|
|
{
|
|
|
|
return "SpriteRenderTextureBug";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string SpriteRenderTextureBug::subtitle() const
|
2013-02-28 16:35:42 +08:00
|
|
|
{
|
|
|
|
return "Touch the screen. Sprite should appear on under the touch";
|
|
|
|
}
|
2016-07-21 10:34:04 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Issue16113Test
|
|
|
|
//
|
|
|
|
Issue16113Test::Issue16113Test()
|
|
|
|
{
|
|
|
|
auto s = Director::getInstance()->getWinSize();
|
|
|
|
|
|
|
|
// Save Image menu
|
|
|
|
MenuItemFont::setFontSize(16);
|
2021-12-28 16:06:23 +08:00
|
|
|
auto item1 = MenuItemFont::create("Save Image", [&](Ref* ref) {
|
2016-07-21 10:34:04 +08:00
|
|
|
auto winSize = Director::getInstance()->getVisibleSize();
|
2021-12-28 16:06:23 +08:00
|
|
|
auto text = Label::createWithTTF("hello world", "fonts/Marker Felt.ttf", 40);
|
2016-07-21 10:34:04 +08:00
|
|
|
text->setTextColor(Color4B::RED);
|
2020-09-25 11:07:56 +08:00
|
|
|
auto target = RenderTexture::create(winSize.width, winSize.height, backend::PixelFormat::RGBA8);
|
2021-12-28 16:06:23 +08:00
|
|
|
target->beginWithClear(0, 0, 0, 0);
|
|
|
|
text->setPosition(winSize.width / 2, winSize.height / 2);
|
2016-07-21 10:34:04 +08:00
|
|
|
text->Node::visit();
|
|
|
|
target->end();
|
2021-12-28 16:06:23 +08:00
|
|
|
auto callback = [&](RenderTexture* rt, std::string_view path) { rt->release(); };
|
2019-02-27 11:29:20 +08:00
|
|
|
target->retain();
|
|
|
|
target->saveToFile("issue16113.png", Image::Format::PNG, true, callback);
|
2016-07-21 10:34:04 +08:00
|
|
|
});
|
2021-12-28 16:06:23 +08:00
|
|
|
auto menu = Menu::create(item1, nullptr);
|
2016-07-21 10:34:04 +08:00
|
|
|
this->addChild(menu);
|
2021-12-28 16:06:23 +08:00
|
|
|
menu->setPosition(s.width / 2, s.height / 2);
|
2016-07-21 10:34:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue16113Test::title() const
|
|
|
|
{
|
|
|
|
return "Github Issue 16113";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Issue16113Test::subtitle() const
|
|
|
|
{
|
|
|
|
return "aaa.png file without white border on iOS";
|
|
|
|
}
|
2016-11-28 09:50:45 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// RenderTextureWithSprite3DIssue16894
|
|
|
|
//
|
|
|
|
RenderTextureWithSprite3DIssue16894::RenderTextureWithSprite3DIssue16894()
|
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto visibleSize = Director::getInstance()->getVisibleSize();
|
|
|
|
Vec2 origin = Director::getInstance()->getVisibleOrigin();
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
{
|
|
|
|
// Ship - Model is from cocos2d-x test project
|
|
|
|
auto ship = Sprite3D::create("Sprite3DTest/boss.c3b");
|
|
|
|
ship->setScale(6);
|
|
|
|
ship->setRotation3D(Vec3(180.0f, 45.0f, 0.0f));
|
|
|
|
ship->setPosition(Vec2(visibleSize.width / 4 + origin.x, visibleSize.height / 2 + origin.y));
|
|
|
|
ship->setForce2DQueue(true);
|
|
|
|
ship->retain();
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
addChild(ship, 1);
|
|
|
|
//// Rotate Ship
|
|
|
|
auto spin = RotateBy::create(4, Vec3(0.0f, 180.0f, 0.0f));
|
|
|
|
auto repeatspin = RepeatForever::create(spin);
|
|
|
|
ship->runAction(repeatspin);
|
|
|
|
}
|
|
|
|
_ship[i] = ship;
|
|
|
|
}
|
|
|
|
|
|
|
|
// RenderTextures
|
|
|
|
_renderTexDefault = RenderTexture::create(visibleSize.width, visibleSize.height, backend::PixelFormat::RGBA8);
|
|
|
|
_renderTexDefault->setKeepMatrix(true);
|
|
|
|
addChild(_renderTexDefault);
|
|
|
|
_renderTexDefault->setPosition(visibleSize.width / 4 * 3, visibleSize.height / 2);
|
|
|
|
|
|
|
|
_renderTexWithBuffer = RenderTexture::create(visibleSize.width, visibleSize.height, backend::PixelFormat::RGBA8,
|
|
|
|
backend::PixelFormat::D24S8);
|
|
|
|
_renderTexWithBuffer->setKeepMatrix(true);
|
|
|
|
addChild(_renderTexWithBuffer);
|
|
|
|
_renderTexWithBuffer->setPosition(visibleSize.width / 4 * 4, visibleSize.height / 2);
|
|
|
|
|
|
|
|
// Update
|
|
|
|
scheduleUpdate();
|
|
|
|
|
|
|
|
auto label1 = Label::createWithTTF("Normal Sprite3D\n", "fonts/arial.ttf", 10);
|
|
|
|
label1->setPosition(Vec2(visibleSize.width / 4 * 1, 60.0f));
|
|
|
|
this->addChild(label1, 1);
|
|
|
|
|
|
|
|
auto label2 = Label::createWithTTF("RenderTexture\nDefault - No depth buffer", "fonts/arial.ttf", 10);
|
|
|
|
label2->setPosition(Vec2(visibleSize.width / 4 * 2, 60.0f));
|
|
|
|
this->addChild(label2, 1);
|
|
|
|
|
|
|
|
auto label3 = Label::createWithTTF("RenderTexture\nGL_DEPTH24_STENCIL8", "fonts/arial.ttf", 10);
|
|
|
|
label3->setPosition(Vec2(visibleSize.width / 4 * 3, 60.0f));
|
|
|
|
this->addChild(label3, 1);
|
2016-11-28 09:50:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
RenderTextureWithSprite3DIssue16894::~RenderTextureWithSprite3DIssue16894()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
{
|
|
|
|
_ship[i]->release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
void RenderTextureWithSprite3DIssue16894::visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags)
|
2016-11-28 09:50:45 +08:00
|
|
|
{
|
|
|
|
RenderTextureTest::visit(renderer, parentTransform, parentFlags);
|
|
|
|
|
|
|
|
_ship[1]->setRotation3D(_ship[0]->getRotation3D());
|
|
|
|
_ship[2]->setRotation3D(_ship[0]->getRotation3D());
|
|
|
|
|
|
|
|
_renderTexDefault->beginWithClear(0, 0, 0, 0, 0, 0);
|
|
|
|
_ship[1]->visit(Director::getInstance()->getRenderer(), Mat4::IDENTITY, 0);
|
|
|
|
_renderTexDefault->end();
|
|
|
|
|
|
|
|
_renderTexWithBuffer->beginWithClear(0, 0, 0, 0, 1, 0);
|
|
|
|
_ship[2]->visit(Director::getInstance()->getRenderer(), Mat4::IDENTITY, 0);
|
|
|
|
_renderTexWithBuffer->end();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string RenderTextureWithSprite3DIssue16894::title() const
|
|
|
|
{
|
|
|
|
return "Issue16894: Render Sprite3D to texture";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string RenderTextureWithSprite3DIssue16894::subtitle() const
|
|
|
|
{
|
|
|
|
return "3 ships, 1st & 3rd are the same";
|
|
|
|
}
|