mirror of https://github.com/axmolengine/axmol.git
Improvements and bug fixes
Improve ResizableBufferAdapter style Improve extesnion adxelua Improve code quality Fix lua-tests BillBoardTest Sync texture pixel format enum values for adxelua Fix luaval_to_vec2 parameter location Improve windows workflow Improve cmake scripts Take care Texture2D::setDefaultAlphaPixelFormat use
This commit is contained in:
parent
810b0f563d
commit
30a164c31a
|
@ -348,7 +348,7 @@ function(setup_cocos_app_config app_name)
|
||||||
if(BUILD_SHARED_LIBS)
|
if(BUILD_SHARED_LIBS)
|
||||||
target_compile_definitions(${app_name} PRIVATE SPINEPLUGIN_API=DLLIMPORT) # spine dll
|
target_compile_definitions(${app_name} PRIVATE SPINEPLUGIN_API=DLLIMPORT) # spine dll
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(${app_name} ${CC_EXTENSION_LIBS})
|
target_link_libraries(${app_name} ${_AX_EXTENSION_LIBS})
|
||||||
|
|
||||||
if(XCODE AND AX_USE_ALSOFT AND ALSOFT_OSX_FRAMEWORK)
|
if(XCODE AND AX_USE_ALSOFT AND ALSOFT_OSX_FRAMEWORK)
|
||||||
# Embedded soft_oal embedded framework
|
# Embedded soft_oal embedded framework
|
||||||
|
|
|
@ -32,7 +32,7 @@ message(STATUS "HOST_SYSTEM:" ${CMAKE_HOST_SYSTEM_NAME})
|
||||||
option(AX_ENABLE_EXT_LUA "Build lua libraries" OFF)
|
option(AX_ENABLE_EXT_LUA "Build lua libraries" OFF)
|
||||||
|
|
||||||
# hold the extensions list to auto link to app
|
# hold the extensions list to auto link to app
|
||||||
set(CC_EXTENSION_LIBS "" CACHE INTERNAL "extensions for auto link to target application")
|
set(_AX_EXTENSION_LIBS "" CACHE INTERNAL "extensions for auto link to target application")
|
||||||
|
|
||||||
# include helper functions
|
# include helper functions
|
||||||
include(CocosBuildHelpers)
|
include(CocosBuildHelpers)
|
||||||
|
|
|
@ -354,10 +354,7 @@ void PlistSpriteSheetLoader::addSpriteFramesWithDictionary(ValueMap& dict,
|
||||||
if (pixelFormatIt != pixelFormats.end())
|
if (pixelFormatIt != pixelFormats.end())
|
||||||
{
|
{
|
||||||
const backend::PixelFormat pixelFormat = (*pixelFormatIt).second;
|
const backend::PixelFormat pixelFormat = (*pixelFormatIt).second;
|
||||||
const backend::PixelFormat currentPixelFormat = Texture2D::getDefaultAlphaPixelFormat();
|
texture = Director::getInstance()->getTextureCache()->addImage(texturePath, pixelFormat);
|
||||||
Texture2D::setDefaultAlphaPixelFormat(pixelFormat);
|
|
||||||
texture = Director::getInstance()->getTextureCache()->addImage(texturePath);
|
|
||||||
Texture2D::setDefaultAlphaPixelFormat(currentPixelFormat);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,8 @@ Copyright (c) 2010-2012 cocos2d-x.org
|
||||||
Copyright (c) 2011 Zynga Inc.
|
Copyright (c) 2011 Zynga Inc.
|
||||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||||
Copyright (c) 2021 Bytedance Inc.
|
Copyright (c) 2020 C4games Ltd.
|
||||||
|
Copyright (c) 2021-2022 Bytedance Inc.
|
||||||
|
|
||||||
https://adxeproject.github.io/
|
https://adxeproject.github.io/
|
||||||
|
|
||||||
|
@ -73,9 +74,14 @@ Sprite* Sprite::createWithTexture(Texture2D* texture, const Rect& rect, bool rot
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprite* Sprite::create(std::string_view filename)
|
Sprite* Sprite::create(std::string_view filename)
|
||||||
|
{
|
||||||
|
return Sprite::create(filename, Texture2D::getDefaultAlphaPixelFormat());
|
||||||
|
}
|
||||||
|
|
||||||
|
Sprite* Sprite::create(std::string_view filename, PixelFormat format)
|
||||||
{
|
{
|
||||||
Sprite* sprite = new Sprite();
|
Sprite* sprite = new Sprite();
|
||||||
if (sprite->initWithFile(filename))
|
if (sprite->initWithFile(filename, format))
|
||||||
{
|
{
|
||||||
sprite->autorelease();
|
sprite->autorelease();
|
||||||
return sprite;
|
return sprite;
|
||||||
|
@ -168,6 +174,11 @@ bool Sprite::initWithTexture(Texture2D* texture, const Rect& rect)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sprite::initWithFile(std::string_view filename)
|
bool Sprite::initWithFile(std::string_view filename)
|
||||||
|
{
|
||||||
|
return initWithFile(filename, Texture2D::getDefaultAlphaPixelFormat());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Sprite::initWithFile(std::string_view filename, PixelFormat format)
|
||||||
{
|
{
|
||||||
if (filename.empty())
|
if (filename.empty())
|
||||||
{
|
{
|
||||||
|
@ -177,7 +188,7 @@ bool Sprite::initWithFile(std::string_view filename)
|
||||||
|
|
||||||
_fileName = filename;
|
_fileName = filename;
|
||||||
|
|
||||||
Texture2D* texture = _director->getTextureCache()->addImage(filename);
|
Texture2D* texture = _director->getTextureCache()->addImage(filename, format);
|
||||||
if (texture)
|
if (texture)
|
||||||
{
|
{
|
||||||
Rect rect = Rect::ZERO;
|
Rect rect = Rect::ZERO;
|
||||||
|
|
|
@ -4,6 +4,8 @@ Copyright (c) 2010-2012 cocos2d-x.org
|
||||||
Copyright (c) 2011 Zynga Inc.
|
Copyright (c) 2011 Zynga Inc.
|
||||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||||
|
Copyright (c) 2020 C4games Ltd.
|
||||||
|
Copyright (c) 2021-2022 Bytedance Inc.
|
||||||
|
|
||||||
https://adxeproject.github.io/
|
https://adxeproject.github.io/
|
||||||
|
|
||||||
|
@ -130,6 +132,7 @@ public:
|
||||||
* @return An autoreleased sprite object.
|
* @return An autoreleased sprite object.
|
||||||
*/
|
*/
|
||||||
static Sprite* create(std::string_view filename);
|
static Sprite* create(std::string_view filename);
|
||||||
|
static Sprite* create(std::string_view filename, PixelFormat format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a polygon sprite with a polygon info.
|
* Creates a polygon sprite with a polygon info.
|
||||||
|
@ -601,6 +604,7 @@ public:
|
||||||
* @lua init
|
* @lua init
|
||||||
*/
|
*/
|
||||||
virtual bool initWithFile(std::string_view filename);
|
virtual bool initWithFile(std::string_view filename);
|
||||||
|
virtual bool initWithFile(std::string_view filename, PixelFormat format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a sprite with an image filename, and a rect.
|
* Initializes a sprite with an image filename, and a rect.
|
||||||
|
|
|
@ -196,10 +196,10 @@ endif()
|
||||||
# engine extensions
|
# engine extensions
|
||||||
add_subdirectory(${ADXE_ROOT_PATH}/extensions ${ENGINE_BINARY_PATH}/extensions)
|
add_subdirectory(${ADXE_ROOT_PATH}/extensions ${ENGINE_BINARY_PATH}/extensions)
|
||||||
|
|
||||||
if(MSVC_IDE)
|
if(MSVC)
|
||||||
target_sources(${ADXE_CORE_LIB} PRIVATE ../thirdparty/yasio/yasio.natvis)
|
target_sources(${ADXE_CORE_LIB} PRIVATE ../thirdparty/yasio/yasio.natvis)
|
||||||
target_sources(${ADXE_CORE_LIB} PRIVATE ../thirdparty/robin-map/tsl-robin-map.natvis)
|
target_sources(${ADXE_CORE_LIB} PRIVATE ../thirdparty/robin-map/tsl-robin-map.natvis)
|
||||||
target_compile_options(${ADXE_CORE_LIB} PRIVATE "/Zm2000")
|
target_compile_options(${ADXE_CORE_LIB} PUBLIC "/Zm2000")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# copy all thirdparty libraries to ${CMAKE_BINARY_DIR}/lib/$<CONFIG>
|
# copy all thirdparty libraries to ${CMAKE_BINARY_DIR}/lib/$<CONFIG>
|
||||||
|
|
|
@ -44,6 +44,12 @@ class CC_DLL Data
|
||||||
friend class Properties;
|
friend class Properties;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/* stl compatible */
|
||||||
|
using value_type = uint8_t;
|
||||||
|
size_t size() const { return _size; }
|
||||||
|
uint8_t* data() const { return _bytes; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This parameter is defined for convenient reference if a null Data object is needed.
|
* This parameter is defined for convenient reference if a null Data object is needed.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1261,8 +1261,6 @@ void Director::createStatsLabel()
|
||||||
FileUtils::getInstance()->purgeCachedEntries();
|
FileUtils::getInstance()->purgeCachedEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
backend::PixelFormat currentFormat = Texture2D::getDefaultAlphaPixelFormat();
|
|
||||||
Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGBA4);
|
|
||||||
unsigned char* data = nullptr;
|
unsigned char* data = nullptr;
|
||||||
ssize_t dataLength = 0;
|
ssize_t dataLength = 0;
|
||||||
getFPSImageData(&data, &dataLength);
|
getFPSImageData(&data, &dataLength);
|
||||||
|
@ -1277,7 +1275,7 @@ void Director::createStatsLabel()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
texture = _textureCache->addImage(image, "/cc_fps_images");
|
texture = _textureCache->addImage(image, "/cc_fps_images", PixelFormat::RGBA4);
|
||||||
CC_SAFE_RELEASE(image);
|
CC_SAFE_RELEASE(image);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1305,8 +1303,6 @@ void Director::createStatsLabel()
|
||||||
_drawnVerticesLabel->setIgnoreContentScaleFactor(true);
|
_drawnVerticesLabel->setIgnoreContentScaleFactor(true);
|
||||||
_drawnVerticesLabel->setScale(scaleFactor);
|
_drawnVerticesLabel->setScale(scaleFactor);
|
||||||
|
|
||||||
Texture2D::setDefaultAlphaPixelFormat(currentFormat);
|
|
||||||
|
|
||||||
auto safeOrigin = getSafeAreaRect().origin;
|
auto safeOrigin = getSafeAreaRect().origin;
|
||||||
const int height_spacing = (int)(22 / CC_CONTENT_SCALE_FACTOR());
|
const int height_spacing = (int)(22 / CC_CONTENT_SCALE_FACTOR());
|
||||||
_drawnVerticesLabel->setPosition(Vec2(0, height_spacing * 2.0f) + safeOrigin);
|
_drawnVerticesLabel->setPosition(Vec2(0, height_spacing * 2.0f) + safeOrigin);
|
||||||
|
|
|
@ -58,7 +58,8 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#define DECLARE_GUARD (void)0
|
#define DECLARE_GUARD (void)0
|
||||||
|
|
||||||
#if CC_TARGET_PLATFORM != CC_PLATFORM_IOS && (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID || (defined(__NDK_MAJOR__) && __NDK_MAJOR__ >= 22) )
|
#if CC_TARGET_PLATFORM != CC_PLATFORM_IOS && \
|
||||||
|
(CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID || (defined(__NDK_MAJOR__) && __NDK_MAJOR__ >= 22))
|
||||||
# define ADXE_HAVE_STDFS 1
|
# define ADXE_HAVE_STDFS 1
|
||||||
# include <filesystem>
|
# include <filesystem>
|
||||||
namespace stdfs = std::filesystem;
|
namespace stdfs = std::filesystem;
|
||||||
|
@ -989,7 +990,7 @@ void FileUtils::loadFilenameLookupDictionaryFromFile(std::string_view filename)
|
||||||
const std::string fullPath = fullPathForFilename(filename);
|
const std::string fullPath = fullPathForFilename(filename);
|
||||||
if (!fullPath.empty())
|
if (!fullPath.empty())
|
||||||
{
|
{
|
||||||
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath);
|
ValueMap dict = getValueMapFromFile(fullPath);
|
||||||
if (!dict.empty())
|
if (!dict.empty())
|
||||||
{
|
{
|
||||||
ValueMap& metadata = dict["metadata"].asValueMap();
|
ValueMap& metadata = dict["metadata"].asValueMap();
|
||||||
|
|
|
@ -58,62 +58,22 @@ public:
|
||||||
virtual ~ResizableBuffer() {}
|
virtual ~ResizableBuffer() {}
|
||||||
virtual void resize(size_t size) = 0;
|
virtual void resize(size_t size) = 0;
|
||||||
virtual void* buffer() const = 0;
|
virtual void* buffer() const = 0;
|
||||||
|
virtual size_t size() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class ResizableBufferAdapter
|
class ResizableBufferAdapter : public ResizableBuffer
|
||||||
{};
|
|
||||||
|
|
||||||
template <typename CharT, typename Traits, typename Allocator>
|
|
||||||
class ResizableBufferAdapter<std::basic_string<CharT, Traits, Allocator>> : public ResizableBuffer
|
|
||||||
{
|
{
|
||||||
typedef std::basic_string<CharT, Traits, Allocator> BufferType;
|
T* _buffer;
|
||||||
BufferType* _buffer;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ResizableBufferAdapter(BufferType* buffer) : _buffer(buffer) {}
|
explicit ResizableBufferAdapter(T* buffer) : _buffer(buffer) {}
|
||||||
virtual void resize(size_t size) override { _buffer->resize((size + sizeof(CharT) - 1) / sizeof(CharT)); }
|
virtual void resize(size_t size) override
|
||||||
virtual void* buffer() const override
|
|
||||||
{
|
{
|
||||||
// can not invoke string::front() if it is empty
|
_buffer->resize((size + sizeof(typename T::value_type) - 1) / sizeof(typename T::value_type));
|
||||||
|
|
||||||
if (_buffer->empty())
|
|
||||||
return nullptr;
|
|
||||||
else
|
|
||||||
return &_buffer->front();
|
|
||||||
}
|
}
|
||||||
};
|
virtual void* buffer() const override { return _buffer->data(); }
|
||||||
|
virtual size_t size() const override { return _buffer->size() * sizeof(typename T::value_type); }
|
||||||
template <typename T, typename Allocator>
|
|
||||||
class ResizableBufferAdapter<std::vector<T, Allocator>> : public ResizableBuffer
|
|
||||||
{
|
|
||||||
typedef std::vector<T, Allocator> BufferType;
|
|
||||||
BufferType* _buffer;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit ResizableBufferAdapter(BufferType* buffer) : _buffer(buffer) {}
|
|
||||||
virtual void resize(size_t size) override { _buffer->resize((size + sizeof(T) - 1) / sizeof(T)); }
|
|
||||||
virtual void* buffer() const override
|
|
||||||
{
|
|
||||||
// can not invoke vector::front() if it is empty
|
|
||||||
|
|
||||||
if (_buffer->empty())
|
|
||||||
return nullptr;
|
|
||||||
else
|
|
||||||
return &_buffer->front();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
class ResizableBufferAdapter<Data> : public ResizableBuffer
|
|
||||||
{
|
|
||||||
typedef Data BufferType;
|
|
||||||
BufferType* _buffer;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit ResizableBufferAdapter(BufferType* buffer) : _buffer(buffer) {}
|
|
||||||
virtual void resize(size_t size) override { _buffer->resize(size); }
|
|
||||||
virtual void* buffer() const override { return _buffer->getBytes(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Helper class to handle file operations. */
|
/** Helper class to handle file operations. */
|
||||||
|
@ -240,7 +200,6 @@ public:
|
||||||
* virtual void* buffer() const override {
|
* virtual void* buffer() const override {
|
||||||
* // your code here
|
* // your code here
|
||||||
* }
|
* }
|
||||||
* };
|
|
||||||
* NS_CC_END
|
* NS_CC_END
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
|
@ -255,13 +214,11 @@ public:
|
||||||
* - Status::TooLarge when there file to be read is too large (> 2^32-1), the buffer will not changed.
|
* - Status::TooLarge when there file to be read is too large (> 2^32-1), the buffer will not changed.
|
||||||
* - Status::ObtainSizeFailed when failed to obtain the file size, the buffer will not changed.
|
* - Status::ObtainSizeFailed when failed to obtain the file size, the buffer will not changed.
|
||||||
*/
|
*/
|
||||||
template <typename T,
|
template <typename T>
|
||||||
typename Enable =
|
|
||||||
typename std::enable_if<std::is_base_of<ResizableBuffer, ResizableBufferAdapter<T>>::value>::type>
|
|
||||||
Status getContents(std::string_view filename, T* buffer) const
|
Status getContents(std::string_view filename, T* buffer) const
|
||||||
{
|
{
|
||||||
ResizableBufferAdapter<T> buf(buffer);
|
ResizableBufferAdapter<T> buf(buffer);
|
||||||
return getContents(filename, &buf);
|
return getContents(filename, static_cast<ResizableBuffer*>(&buf));
|
||||||
}
|
}
|
||||||
virtual Status getContents(std::string_view filename, ResizableBuffer* buffer) const;
|
virtual Status getContents(std::string_view filename, ResizableBuffer* buffer) const;
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ bool FileUtilsWin32::init()
|
||||||
_checkExePath();
|
_checkExePath();
|
||||||
|
|
||||||
bool startedFromSelfLocation = s_workingDir == s_exeDir;
|
bool startedFromSelfLocation = s_workingDir == s_exeDir;
|
||||||
if (!startedFromSelfLocation)
|
if (!startedFromSelfLocation || !isDirectoryExistInternal(AX_PC_RESOURCES_DIR))
|
||||||
_defaultResRootPath = s_workingDir;
|
_defaultResRootPath = s_workingDir;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@ Copyright (c) 2008 Apple Inc. All Rights Reserved.
|
||||||
Copyright (c) 2010-2012 cocos2d-x.org
|
Copyright (c) 2010-2012 cocos2d-x.org
|
||||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||||
Copyright (c) 2020 C4games Ltd
|
Copyright (c) 2020 C4games Ltd.
|
||||||
Copyright (c) 2021-2022 Bytedance Inc.
|
Copyright (c) 2021-2022 Bytedance Inc.
|
||||||
|
|
||||||
https://adxeproject.github.io/
|
https://adxeproject.github.io/
|
||||||
|
@ -60,7 +60,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
// If the image has alpha, you can create RGBA8 (32-bit) or RGBA4 (16-bit) or RGB5A1 (16-bit)
|
// If the image has alpha, you can create RGBA8 (32-bit) or RGBA4 (16-bit) or RGB5A1 (16-bit)
|
||||||
// Default is: RGBA8888 (32-bit textures)
|
// Default is: RGBA8888 (32-bit textures)
|
||||||
static backend::PixelFormat g_defaultAlphaPixelFormat = backend::PixelFormat::BGRA8;
|
static backend::PixelFormat g_defaultAlphaPixelFormat = backend::PixelFormat::RGBA8;
|
||||||
|
|
||||||
Texture2D::Texture2D()
|
Texture2D::Texture2D()
|
||||||
: _pixelFormat(backend::PixelFormat::NONE)
|
: _pixelFormat(backend::PixelFormat::NONE)
|
||||||
|
|
|
@ -4,7 +4,8 @@ Copyright (c) 2010-2012 cocos2d-x.org
|
||||||
Copyright (c) 2011 Zynga Inc.
|
Copyright (c) 2011 Zynga Inc.
|
||||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||||
Copyright (c) 2020 C4games Ltd
|
Copyright (c) 2020 C4games Ltd.
|
||||||
|
Copyright (c) 2021-2022 Bytedance Inc.
|
||||||
|
|
||||||
https://adxeproject.github.io/
|
https://adxeproject.github.io/
|
||||||
|
|
||||||
|
@ -355,7 +356,7 @@ void TextureCache::addImageAsyncCallBack(float /*dt*/)
|
||||||
// ETC1 ALPHA supports.
|
// ETC1 ALPHA supports.
|
||||||
if (asyncStruct->imageAlpha.getFileType() == Image::Format::ETC1)
|
if (asyncStruct->imageAlpha.getFileType() == Image::Format::ETC1)
|
||||||
{
|
{
|
||||||
texture->updateWithImage(&asyncStruct->imageAlpha, Texture2D::getDefaultAlphaPixelFormat(), 1);
|
texture->updateWithImage(&asyncStruct->imageAlpha, asyncStruct->pixelFormat, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -384,6 +385,11 @@ void TextureCache::addImageAsyncCallBack(float /*dt*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D* TextureCache::addImage(std::string_view path)
|
Texture2D* TextureCache::addImage(std::string_view path)
|
||||||
|
{
|
||||||
|
return addImage(path, Texture2D::getDefaultAlphaPixelFormat());
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture2D* TextureCache::addImage(std::string_view path, PixelFormat format)
|
||||||
{
|
{
|
||||||
Texture2D* texture = nullptr;
|
Texture2D* texture = nullptr;
|
||||||
Image* image = nullptr;
|
Image* image = nullptr;
|
||||||
|
@ -412,7 +418,7 @@ Texture2D* TextureCache::addImage(std::string_view path)
|
||||||
|
|
||||||
texture = new Texture2D();
|
texture = new Texture2D();
|
||||||
|
|
||||||
if (texture->initWithImage(image))
|
if (texture->initWithImage(image, format))
|
||||||
{
|
{
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
// cache the texture file name
|
// cache the texture file name
|
||||||
|
@ -430,7 +436,7 @@ Texture2D* TextureCache::addImage(std::string_view path)
|
||||||
Image imageAlpha;
|
Image imageAlpha;
|
||||||
if (imageAlpha.initWithImageFile(alphaFullPath))
|
if (imageAlpha.initWithImageFile(alphaFullPath))
|
||||||
{
|
{
|
||||||
texture->updateWithImage(&imageAlpha, Texture2D::getDefaultAlphaPixelFormat(), 1);
|
texture->updateWithImage(&imageAlpha, format, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,6 +468,11 @@ void TextureCache::parseNinePatchImage(cocos2d::Image* image, cocos2d::Texture2D
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D* TextureCache::addImage(Image* image, std::string_view key)
|
Texture2D* TextureCache::addImage(Image* image, std::string_view key)
|
||||||
|
{
|
||||||
|
return addImage(image, key, Texture2D::getDefaultAlphaPixelFormat());
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture2D* TextureCache::addImage(Image* image, std::string_view key, PixelFormat format)
|
||||||
{
|
{
|
||||||
CCASSERT(image != nullptr, "TextureCache: image MUST not be nil");
|
CCASSERT(image != nullptr, "TextureCache: image MUST not be nil");
|
||||||
CCASSERT(image->getData() != nullptr, "TextureCache: image MUST not be nil");
|
CCASSERT(image->getData() != nullptr, "TextureCache: image MUST not be nil");
|
||||||
|
@ -478,7 +489,7 @@ Texture2D* TextureCache::addImage(Image* image, std::string_view key)
|
||||||
}
|
}
|
||||||
|
|
||||||
texture = new Texture2D();
|
texture = new Texture2D();
|
||||||
if (texture->initWithImage(image))
|
if (texture->initWithImage(image, format))
|
||||||
{
|
{
|
||||||
_textures.emplace(key, texture);
|
_textures.emplace(key, texture);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ Copyright (c) 2010-2012 cocos2d-x.org
|
||||||
Copyright (c) 2011 Zynga Inc.
|
Copyright (c) 2011 Zynga Inc.
|
||||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||||
|
Copyright (c) 2020 C4games Ltd.
|
||||||
|
Copyright (c) 2021-2022 Bytedance Inc.
|
||||||
|
|
||||||
https://adxeproject.github.io/
|
https://adxeproject.github.io/
|
||||||
|
|
||||||
|
@ -93,16 +95,19 @@ public:
|
||||||
@param filepath The file path.
|
@param filepath The file path.
|
||||||
*/
|
*/
|
||||||
Texture2D* addImage(std::string_view filepath);
|
Texture2D* addImage(std::string_view filepath);
|
||||||
|
Texture2D* addImage(std::string_view filepath, PixelFormat format);
|
||||||
|
|
||||||
/** Returns a Texture2D object given a file image.
|
/** Returns a Texture2D object given a file image.
|
||||||
* If the file image was not previously loaded, it will create a new Texture2D object and it will return it.
|
* If the file image was not previously loaded, it will create a new Texture2D object and it will return it.
|
||||||
* Otherwise it will load a texture in a new thread, and when the image is loaded, the callback will be called with
|
* Otherwise it will load a texture in a offthread, and when the image is loaded, the callback will be called with
|
||||||
the Texture2D as a parameter.
|
the Texture2D as a parameter.
|
||||||
* The callback will be called from the main thread, so it is safe to create any cocos2d object from the callback.
|
* The callback will be called from the main thread, so it is safe to create any cocos2d object from the callback.
|
||||||
* Supported image extensions: .png, .jpg
|
* Supported image extensions: .png, .jpg
|
||||||
@param filepath The file path.
|
@param filepath The file path.
|
||||||
@param callback A callback function would be invoked after the image is loaded.
|
@param callback A callback function would be invoked after the image is loaded.
|
||||||
@since v0.8
|
@since v0.8
|
||||||
|
|
||||||
|
@remark Please don't invoke Texture2D::setDefaultAlphaPixelFormat in main GL thread before invoke this API.
|
||||||
*/
|
*/
|
||||||
virtual void addImageAsync(std::string_view filepath, const std::function<void(Texture2D*)>& callback);
|
virtual void addImageAsync(std::string_view filepath, const std::function<void(Texture2D*)>& callback);
|
||||||
|
|
||||||
|
@ -130,6 +135,7 @@ public:
|
||||||
* If "key" is nil, then a new texture will be created each time.
|
* If "key" is nil, then a new texture will be created each time.
|
||||||
*/
|
*/
|
||||||
Texture2D* addImage(Image* image, std::string_view key);
|
Texture2D* addImage(Image* image, std::string_view key);
|
||||||
|
Texture2D* addImage(Image* image, std::string_view key, PixelFormat format);
|
||||||
|
|
||||||
/** Returns an already created texture. Returns nil if the texture doesn't exist.
|
/** Returns an already created texture. Returns nil if the texture doesn't exist.
|
||||||
@param key It's the related/absolute path of the file image.
|
@param key It's the related/absolute path of the file image.
|
||||||
|
|
|
@ -53,7 +53,7 @@ function(setup_cocos_extension_config target_name)
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT opt_DNTLINK)
|
if(NOT opt_DNTLINK)
|
||||||
set(CC_EXTENSION_LIBS "${target_name};${CC_EXTENSION_LIBS}" CACHE INTERNAL "extensions for auto link to target application")
|
set(_AX_EXTENSION_LIBS "${target_name};${_AX_EXTENSION_LIBS}" CACHE INTERNAL "extensions for auto link to target application")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(XCODE OR VS)
|
if(XCODE OR VS)
|
||||||
|
@ -122,4 +122,4 @@ if(AX_ENABLE_EXT_LUA)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
message(STATUS "CC_EXTENSION_LIBS:${CC_EXTENSION_LIBS}")
|
message(STATUS "Enabled adxe extensions:${_AX_EXTENSION_LIBS}")
|
||||||
|
|
|
@ -96,12 +96,7 @@ TextureAtlasData* CCFactory::_buildTextureAtlasData(TextureAtlasData* textureAtl
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cocos2d::Texture2D::setDefaultAlphaPixelFormat(pixelFormat);
|
texture = textureCache->addImage(textureAtlasData->imagePath, pixelFormat);
|
||||||
texture = textureCache->addImage(textureAtlasData->imagePath);
|
|
||||||
if (texture != nullptr)
|
|
||||||
{
|
|
||||||
cocos2d::Texture2D::setDefaultAlphaPixelFormat(defaultPixelFormat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static_cast<CCTextureAtlasData*>(textureAtlasData)->setRenderTexture(texture);
|
static_cast<CCTextureAtlasData*>(textureAtlasData)->setRenderTexture(texture);
|
||||||
|
|
|
@ -263,6 +263,20 @@ private:
|
||||||
void copy(const LuaValue& rhs);
|
void copy(const LuaValue& rhs);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline std::string adxelua_tostr(lua_State* L, int arg)
|
||||||
|
{
|
||||||
|
size_t l = 0;
|
||||||
|
const char* s = lua_tolstring(L, arg, &l);
|
||||||
|
return std::string{s, l};
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string_view adxelua_tosv(lua_State* L, int arg)
|
||||||
|
{
|
||||||
|
size_t l = 0;
|
||||||
|
const char* s = lua_tolstring(L, arg, &l);
|
||||||
|
return std::string_view{s, l};
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
// end group
|
// end group
|
||||||
|
|
|
@ -35,20 +35,6 @@ THE SOFTWARE.
|
||||||
|
|
||||||
using namespace cocos2d;
|
using namespace cocos2d;
|
||||||
|
|
||||||
static std::string adxelua_tostr(lua_State* L, int arg)
|
|
||||||
{
|
|
||||||
size_t l = 0;
|
|
||||||
const char* s = lua_tolstring(L, arg, &l);
|
|
||||||
return std::string{s, l};
|
|
||||||
}
|
|
||||||
|
|
||||||
static cxx17::string_view adxelua_tosv(lua_State* L, int arg)
|
|
||||||
{
|
|
||||||
size_t l = 0;
|
|
||||||
const char* s = lua_tolstring(L, arg, &l);
|
|
||||||
return cxx17::string_view{s, l};
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
int cocos2dx_lua_loader(lua_State* L)
|
int cocos2dx_lua_loader(lua_State* L)
|
||||||
{
|
{
|
||||||
|
|
|
@ -360,8 +360,8 @@ bool luaval_to_vec2(lua_State* L, int lo, cocos2d::Vec2* outValue, const char* f
|
||||||
}
|
}
|
||||||
|
|
||||||
// assertion: since we only have vec2, you should never passing rect as vec2 to native
|
// assertion: since we only have vec2, you should never passing rect as vec2 to native
|
||||||
const auto objlen = lua_objlen(L, -1);
|
const auto objlen = lua_objlen(L, lo);
|
||||||
assert(objlen == 2);
|
assert(objlen != 4);
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||||
Copyright (c) 2021 Bytedance Inc.
|
Copyright (c) 2021-2022 Bytedance Inc.
|
||||||
|
|
||||||
https://adxeproject.github.io/
|
https://adxeproject.github.io/
|
||||||
|
|
||||||
|
@ -245,11 +245,11 @@ static int tolua_cocos2d_MenuItemImage_create(lua_State* tolua_S)
|
||||||
ok = true;
|
ok = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const std::string normalImage = ((const std::string)tolua_tocppstring(tolua_S, 2, 0));
|
auto normalImage = adxelua_tosv(tolua_S, 2);
|
||||||
const std::string selectedImage = ((const std::string)tolua_tocppstring(tolua_S, 3, 0));
|
auto selectedImage = adxelua_tosv(tolua_S, 3);
|
||||||
MenuItemImage* tolua_ret = (MenuItemImage*)MenuItemImage::create(normalImage, selectedImage);
|
MenuItemImage* tolua_ret = (MenuItemImage*)MenuItemImage::create(normalImage, selectedImage);
|
||||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "cc.MenuItemImage");
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "cc.MenuItemImage");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -266,9 +266,9 @@ static int tolua_cocos2d_MenuItemImage_create(lua_State* tolua_S)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
const std::string normalImage = ((const std::string)tolua_tocppstring(tolua_S, 2, 0));
|
auto normalImage = adxelua_tosv(tolua_S, 2);
|
||||||
const std::string selectedImage = ((const std::string)tolua_tocppstring(tolua_S, 3, 0));
|
auto selectedImage = adxelua_tosv(tolua_S, 3);
|
||||||
const std::string disabledImage = ((const std::string)tolua_tocppstring(tolua_S, 4, 0));
|
auto disabledImage = adxelua_tosv(tolua_S, 4);
|
||||||
|
|
||||||
MenuItemImage* tolua_ret = (MenuItemImage*)MenuItemImage::create(normalImage, selectedImage, disabledImage);
|
MenuItemImage* tolua_ret = (MenuItemImage*)MenuItemImage::create(normalImage, selectedImage, disabledImage);
|
||||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||||
|
@ -352,7 +352,7 @@ static int tolua_cocos2d_MenuItemFont_create(lua_State* tolua_S)
|
||||||
goto tolua_lerror;
|
goto tolua_lerror;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
const std::string value = ((const std::string)tolua_tocppstring(tolua_S, 2, 0));
|
auto value = adxelua_tosv(tolua_S, 2);
|
||||||
MenuItemFont* tolua_ret = (MenuItemFont*)MenuItemFont::create(value);
|
MenuItemFont* tolua_ret = (MenuItemFont*)MenuItemFont::create(value);
|
||||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||||
|
@ -2293,7 +2293,7 @@ static int lua_cocos2dx_Node_enumerateChildren(lua_State* tolua_S)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string name = (std::string)tolua_tocppstring(tolua_S, 2, 0);
|
std::string name = adxelua_tostr(tolua_S, 2);
|
||||||
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 3, 0);
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 3, 0);
|
||||||
|
|
||||||
cobj->enumerateChildren(name, [=](Node* node) -> bool {
|
cobj->enumerateChildren(name, [=](Node* node) -> bool {
|
||||||
|
@ -4631,7 +4631,7 @@ static int tolua_cocos2d_LuaEventListenerCustom_create(lua_State* tolua_S)
|
||||||
goto tolua_lerror;
|
goto tolua_lerror;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
const std::string eventName = ((const std::string)tolua_tocppstring(tolua_S, 2, 0));
|
auto eventName = adxelua_tosv(tolua_S, 2);
|
||||||
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 3, 0);
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 3, 0);
|
||||||
cocos2d::EventListenerCustom* tolua_ret = LuaEventListenerCustom::create(eventName);
|
cocos2d::EventListenerCustom* tolua_ret = LuaEventListenerCustom::create(eventName);
|
||||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)tolua_ret, handler,
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)tolua_ret, handler,
|
||||||
|
@ -7428,7 +7428,7 @@ static int tolua_cocos2d_utils_captureScreen(lua_State* tolua_S)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
||||||
std::string fileName = tolua_tocppstring(tolua_S, 3, "");
|
auto fileName = adxelua_tosv(tolua_S, 3);
|
||||||
cocos2d::utils::captureScreen(
|
cocos2d::utils::captureScreen(
|
||||||
[=](bool succeed, std::string_view name) {
|
[=](bool succeed, std::string_view name) {
|
||||||
auto stack = LuaEngine::getInstance()->getLuaStack();
|
auto stack = LuaEngine::getInstance()->getLuaStack();
|
||||||
|
@ -7460,7 +7460,7 @@ static int tolua_cocos2d_utils_findChildren(lua_State* tolua_S)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
cocos2d::Node* node = static_cast<Node*>(tolua_tousertype(tolua_S, 2, nullptr));
|
cocos2d::Node* node = static_cast<Node*>(tolua_tousertype(tolua_S, 2, nullptr));
|
||||||
std::string name = tolua_tocppstring(tolua_S, 3, "");
|
auto name = adxelua_tosv(tolua_S, 3);
|
||||||
std::vector<Node*> children = cocos2d::utils::findChildren(*node, name);
|
std::vector<Node*> children = cocos2d::utils::findChildren(*node, name);
|
||||||
lua_newtable(tolua_S);
|
lua_newtable(tolua_S);
|
||||||
int index = 1;
|
int index = 1;
|
||||||
|
@ -7495,7 +7495,7 @@ static int tolua_cocos2d_utils_findChild(lua_State* tolua_S)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
cocos2d::Node* node = static_cast<Node*>(tolua_tousertype(tolua_S, 1, nullptr));
|
cocos2d::Node* node = static_cast<Node*>(tolua_tousertype(tolua_S, 1, nullptr));
|
||||||
std::string name = tolua_tocppstring(tolua_S, 2, "");
|
auto name = adxelua_tosv(tolua_S, 2);
|
||||||
auto obj = cocos2d::utils::findChild(node, name);
|
auto obj = cocos2d::utils::findChild(node, name);
|
||||||
int ID = (obj) ? (int)obj->_ID : -1;
|
int ID = (obj) ? (int)obj->_ID : -1;
|
||||||
int* luaID = (obj) ? &obj->_luaID : NULL;
|
int* luaID = (obj) ? &obj->_luaID : NULL;
|
||||||
|
|
|
@ -90,25 +90,39 @@ cc.TEXT_ALIGNMENT_CENTER = 0x1
|
||||||
cc.TEXT_ALIGNMENT_LEFT = 0x0
|
cc.TEXT_ALIGNMENT_LEFT = 0x0
|
||||||
cc.TEXT_ALIGNMENT_RIGHT = 0x2
|
cc.TEXT_ALIGNMENT_RIGHT = 0x2
|
||||||
|
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_AUTO = 0x0
|
cc.TEXTURE_PF_PVRTC4 = 0
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_BGR_A8888 = 0x1
|
cc.TEXTURE_PF_PVRTC4A = 1
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 = 0x2
|
cc.TEXTURE_PF_PVRTC2 = 2
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 = 0x3
|
cc.TEXTURE_PF_PVRTC2A = 3
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 = 0x4
|
cc.TEXTURE_PF_ETC1 = 4
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_A8 = 0x5
|
cc.TEXTURE_PF_ETC2_RGB = 5
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_I8 = 0x6
|
cc.TEXTURE_PF_ETC2_RGBA = 6
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 = 0x7
|
cc.TEXTURE_PF_S3TC_DXT1 = 7
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 = 0x8
|
cc.TEXTURE_PF_S3TC_DXT3 = 8
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 = 0x9
|
cc.TEXTURE_PF_S3TC_DXT5 = 9
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 = 0xa
|
cc.TEXTURE_PF_ATC_RGB = 10
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4A = 0xb
|
cc.TEXTURE_PF_ATC_EXPLICIT_ALPHA = 11
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 = 0xc
|
cc.TEXTURE_PF_ATC_INTERPOLATED_ALPHA = 12
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2A = 0xd
|
cc.TEXTURE_PF_ASTC4x4 = 13 --!< ASTC 4x4 8.0 BPP
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_ETC = 0xe
|
cc.TEXTURE_PF_ASTC5x5 = 14 --!< ASTC 5x5 5.12 BPP
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT1 = 0xf
|
cc.TEXTURE_PF_ASTC6x6 = 15 --!< ASTC 6x6 3.56 BPP
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT3 = 0x10
|
cc.TEXTURE_PF_ASTC8x5 = 16 --!< ASTC 8x5 3.20 BPP
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT5 = 0x11
|
cc.TEXTURE_PF_ASTC8x6 = 17 --!< ASTC 8x6 2.67 BPP
|
||||||
cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT = 0x0
|
cc.TEXTURE_PF_ASTC8x8 = 18 --!< ASTC 8x8 2.0 BPP
|
||||||
|
cc.TEXTURE_PF_ASTC10x5 = 19 --!< ASTC 10x5 2.56 BPP
|
||||||
|
cc.TEXTURE_PF_RGBA8 = 20
|
||||||
|
cc.TEXTURE_PF_BGRA8 = 21
|
||||||
|
cc.TEXTURE_PF_RGB8 = 22
|
||||||
|
cc.TEXTURE_PF_RGB565 = 23 -- !render as BGR565
|
||||||
|
cc.TEXTURE_PF_RGBA4 = 24 -- !render as ABGR4
|
||||||
|
cc.TEXTURE_PF_RGB5A1 = 25 -- !render as BGR5A1
|
||||||
|
cc.TEXTURE_PF_A8 = 26
|
||||||
|
cc.TEXTURE_PF_L8 = 27
|
||||||
|
cc.TEXTURE_PF_LA8 = 28
|
||||||
|
cc.TEXTURE_PF_D24S8 = 29
|
||||||
|
cc.TEXTURE_PF_COUNT = 30
|
||||||
|
cc.TEXTURE_PF_NONE = 0xffff
|
||||||
|
|
||||||
cc.TOUCHES_ALL_AT_ONCE = 0x0
|
cc.TOUCHES_ALL_AT_ONCE = 0x0
|
||||||
cc.TOUCHES_ONE_BY_ONE = 0x1
|
cc.TOUCHES_ONE_BY_ONE = 0x1
|
||||||
cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1
|
cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1
|
||||||
|
|
|
@ -13,17 +13,17 @@ _G.kCCDirectorProjectionDefault = cc.DIRECTOR_PROJECTION_DEFAULT
|
||||||
_G.kCCNodeTagInvalid = cc.NODE_TAG_INVALID
|
_G.kCCNodeTagInvalid = cc.NODE_TAG_INVALID
|
||||||
_G.kCCNodeOnEnter = cc.NODE_ON_ENTER
|
_G.kCCNodeOnEnter = cc.NODE_ON_ENTER
|
||||||
_G.kCCNodeOnExit = cc.NODE_ON_EXIT
|
_G.kCCNodeOnExit = cc.NODE_ON_EXIT
|
||||||
_G.kCCTexture2DPixelFormat_RGBA8888 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888
|
-- _G.kCCTexture2DPixelFormat_RGBA8888 = cc.TEXTURE_PF_RGBA8
|
||||||
_G.kCCTexture2DPixelFormat_RGB888 = cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888
|
-- _G.kCCTexture2DPixelFormat_RGB888 = cc.TEXTURE_PF_RGB8
|
||||||
_G.kCCTexture2DPixelFormat_RGB565 = cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565
|
-- _G.kCCTexture2DPixelFormat_RGB565 = cc.TEXTURE_PF_RGB565
|
||||||
_G.kCCTexture2DPixelFormat_A8 = cc.TEXTURE2_D_PIXEL_FORMAT_A8
|
-- _G.kCCTexture2DPixelFormat_A8 = cc.TEXTURE_PF_A8
|
||||||
_G.kCCTexture2DPixelFormat_I8 = cc.TEXTURE2_D_PIXEL_FORMAT_I8
|
-- _G.kCCTexture2DPixelFormat_I8 = cc.TEXTURE_PF_I8
|
||||||
_G.kCCTexture2DPixelFormat_AI88 = cc.TEXTURE2_D_PIXEL_FORMAT_A_I88
|
-- _G.kCCTexture2DPixelFormat_AI88 = cc.TEXTURE_PF_LA8
|
||||||
_G.kCCTexture2DPixelFormat_RGBA4444 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444
|
-- _G.kCCTexture2DPixelFormat_RGBA4444 = cc.TEXTURE_PF_RGBA4
|
||||||
_G.kCCTexture2DPixelFormat_RGB5A1 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1
|
-- _G.kCCTexture2DPixelFormat_RGB5A1 = cc.TEXTURE_PF_RGB5A1
|
||||||
_G.kCCTexture2DPixelFormat_PVRTC4 = cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4
|
-- _G.kCCTexture2DPixelFormat_PVRTC4 = cc.TEXTURE_PF_PVRTC4
|
||||||
_G.kCCTexture2DPixelFormat_PVRTC2 = cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2
|
-- _G.kCCTexture2DPixelFormat_PVRTC2 = cc.TEXTURE_PF_PVRTC2
|
||||||
_G.kCCTexture2DPixelFormat_Default = cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT
|
-- _G.kCCTexture2DPixelFormat_Default = cc.TEXTURE_PF_RGBA8
|
||||||
_G.kCCImageFormatPNG = cc.IMAGE_FORMAT_PNG
|
_G.kCCImageFormatPNG = cc.IMAGE_FORMAT_PNG
|
||||||
_G.kCCImageFormatJPEG = cc.IMAGE_FORMAT_JPEG
|
_G.kCCImageFormatJPEG = cc.IMAGE_FORMAT_JPEG
|
||||||
_G.kCCTouchesOneByOne = cc.TOUCHES_ONE_BY_ONE
|
_G.kCCTouchesOneByOne = cc.TOUCHES_ONE_BY_ONE
|
||||||
|
@ -73,4 +73,4 @@ _G.kTargetIphone = cc.PLATFORM_OS_IPHONE
|
||||||
_G.kTargetIpad = cc.PLATFORM_OS_IPAD
|
_G.kTargetIpad = cc.PLATFORM_OS_IPAD
|
||||||
_G.kTargetBlackBerry = cc.PLATFORM_OS_BLACKBERRY
|
_G.kTargetBlackBerry = cc.PLATFORM_OS_BLACKBERRY
|
||||||
|
|
||||||
cc.TEXTURE_PIXELFORMAT_DEFAULT = cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT
|
cc.TEXTURE_PIXELFORMAT_DEFAULT = cc.TEXTURE_PF_RGBA8
|
||||||
|
|
|
@ -378,7 +378,7 @@ function display.newSprite(source, x, y, params)
|
||||||
sprite = spriteClass:create(source, params.rect, params.capInsets)
|
sprite = spriteClass:create(source, params.rect, params.capInsets)
|
||||||
end
|
end
|
||||||
if display.TEXTURES_PIXEL_FORMAT[source] then
|
if display.TEXTURES_PIXEL_FORMAT[source] then
|
||||||
cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_BGR_A8888)
|
cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE_PF_BGRA8)
|
||||||
end
|
end
|
||||||
break
|
break
|
||||||
elseif sourceType ~= "userdata" then
|
elseif sourceType ~= "userdata" then
|
||||||
|
@ -503,7 +503,7 @@ function display.loadSpriteFrames(dataFilename, imageFilename, callback)
|
||||||
spriteFrameCache:addSpriteFramesAsync(dataFilename, imageFilename, callback)
|
spriteFrameCache:addSpriteFramesAsync(dataFilename, imageFilename, callback)
|
||||||
end
|
end
|
||||||
if display.TEXTURES_PIXEL_FORMAT[imageFilename] then
|
if display.TEXTURES_PIXEL_FORMAT[imageFilename] then
|
||||||
cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_BGR_A8888)
|
cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE_PF_BGRA8)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,15 @@ cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
set(APP_NAME cpp-tests)
|
set(APP_NAME cpp-tests)
|
||||||
|
|
||||||
|
|
||||||
|
# "too large PDB" error often occurs in cpp-tests when using default "/Zi"
|
||||||
|
if (MSVC)
|
||||||
|
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
|
||||||
|
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
||||||
|
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
||||||
|
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||||
|
endif()
|
||||||
|
|
||||||
project(${APP_NAME})
|
project(${APP_NAME})
|
||||||
|
|
||||||
if(NOT DEFINED BUILD_ENGINE_DONE)
|
if(NOT DEFINED BUILD_ENGINE_DONE)
|
||||||
|
@ -503,15 +512,15 @@ if(WINDOWS OR MACOSX OR LINUX)
|
||||||
Classes/ChipmunkTestBed/demo/Slice.c
|
Classes/ChipmunkTestBed/demo/Slice.c
|
||||||
Classes/ChipmunkTestBed/demo/Unicycle.c
|
Classes/ChipmunkTestBed/demo/Unicycle.c
|
||||||
Classes/ChipmunkTestBed/demo/Tumble.c)
|
Classes/ChipmunkTestBed/demo/Tumble.c)
|
||||||
if(WINDOWS)
|
if(WINDOWS)
|
||||||
set_source_files_properties(${TESTBED_C_SORUCES} PROPERTIES COMPILE_FLAGS "/TP")
|
set_source_files_properties(${TESTBED_C_SORUCES} PROPERTIES COMPILE_FLAGS "/TP")
|
||||||
else()
|
else()
|
||||||
set_source_files_properties(${TESTBED_C_SORUCES} PROPERTIES LANGUAGE CXX)
|
set_source_files_properties(${TESTBED_C_SORUCES} PROPERTIES LANGUAGE CXX)
|
||||||
endif()
|
endif()
|
||||||
list(APPEND GAME_SOURCE
|
list(APPEND GAME_SOURCE
|
||||||
${TESTBED_C_SORUCES}
|
${TESTBED_C_SORUCES}
|
||||||
Classes/ChipmunkTestBed/ChipmunkTestBed.cpp
|
Classes/ChipmunkTestBed/ChipmunkTestBed.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
@ -566,8 +575,6 @@ if(APPLE)
|
||||||
# For code-signing, set the DEVELOPMENT_TEAM:
|
# For code-signing, set the DEVELOPMENT_TEAM:
|
||||||
#set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "GRLXXXX2K9")
|
#set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "GRLXXXX2K9")
|
||||||
elseif(WINDOWS)
|
elseif(WINDOWS)
|
||||||
# "too large PDB" error often occurs in cpp-tests when using default "/Zi"
|
|
||||||
target_compile_options(${APP_NAME} PRIVATE /Z7)
|
|
||||||
cocos_copy_target_dll(${APP_NAME})
|
cocos_copy_target_dll(${APP_NAME})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
Copyright (c) 2012 cocos2d-x.org
|
Copyright (c) 2012 cocos2d-x.org
|
||||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||||
|
Copyright (c) 2020 C4games Ltd.
|
||||||
|
Copyright (c) 2021-2022 Bytedance Inc.
|
||||||
|
|
||||||
https://adxeproject.github.io/
|
https://adxeproject.github.io/
|
||||||
|
|
||||||
|
@ -322,10 +324,7 @@ protected:
|
||||||
if (pixelFormatIt != pixelFormats.end())
|
if (pixelFormatIt != pixelFormats.end())
|
||||||
{
|
{
|
||||||
const backend::PixelFormat pixelFormat = (*pixelFormatIt).second;
|
const backend::PixelFormat pixelFormat = (*pixelFormatIt).second;
|
||||||
const backend::PixelFormat currentPixelFormat = Texture2D::getDefaultAlphaPixelFormat();
|
texture = Director::getInstance()->getTextureCache()->addImage(texturePath, pixelFormat);
|
||||||
Texture2D::setDefaultAlphaPixelFormat(pixelFormat);
|
|
||||||
texture = Director::getInstance()->getTextureCache()->addImage(texturePath);
|
|
||||||
Texture2D::setDefaultAlphaPixelFormat(currentPixelFormat);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
Copyright (c) 2012 cocos2d-x.org
|
Copyright (c) 2012 cocos2d-x.org
|
||||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||||
|
Copyright (c) 2020 C4games Ltd.
|
||||||
|
Copyright (c) 2021-2022 Bytedance Inc.
|
||||||
|
|
||||||
https://adxeproject.github.io/
|
https://adxeproject.github.io/
|
||||||
|
|
||||||
|
@ -1593,8 +1595,7 @@ void TexturePixelFormat::onEnter()
|
||||||
addChild(background, -1);
|
addChild(background, -1);
|
||||||
|
|
||||||
// RGBA 8888 image (32-bit)
|
// RGBA 8888 image (32-bit)
|
||||||
Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGBA8);
|
auto sprite1 = Sprite::create("Images/test-rgba1.png", PixelFormat::RGBA8);
|
||||||
auto sprite1 = Sprite::create("Images/test-rgba1.png");
|
|
||||||
sprite1->setPosition(Vec2(1 * s.width / 7, s.height / 2 + 32));
|
sprite1->setPosition(Vec2(1 * s.width / 7, s.height / 2 + 32));
|
||||||
addChild(sprite1, 0);
|
addChild(sprite1, 0);
|
||||||
|
|
||||||
|
@ -1602,8 +1603,7 @@ void TexturePixelFormat::onEnter()
|
||||||
Director::getInstance()->getTextureCache()->removeTexture(sprite1->getTexture());
|
Director::getInstance()->getTextureCache()->removeTexture(sprite1->getTexture());
|
||||||
|
|
||||||
// RGBA 4444 image (16-bit)
|
// RGBA 4444 image (16-bit)
|
||||||
Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGBA4);
|
auto sprite2 = Sprite::create("Images/test-rgba1.png", PixelFormat::RGBA4);
|
||||||
auto sprite2 = Sprite::create("Images/test-rgba1.png");
|
|
||||||
sprite2->setPosition(Vec2(2 * s.width / 7, s.height / 2 - 32));
|
sprite2->setPosition(Vec2(2 * s.width / 7, s.height / 2 - 32));
|
||||||
addChild(sprite2, 0);
|
addChild(sprite2, 0);
|
||||||
|
|
||||||
|
@ -1611,8 +1611,7 @@ void TexturePixelFormat::onEnter()
|
||||||
Director::getInstance()->getTextureCache()->removeTexture(sprite2->getTexture());
|
Director::getInstance()->getTextureCache()->removeTexture(sprite2->getTexture());
|
||||||
|
|
||||||
// RGB5A1 image (16-bit)
|
// RGB5A1 image (16-bit)
|
||||||
Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGB5A1);
|
auto sprite3 = Sprite::create("Images/test-rgba1.png", PixelFormat::RGB5A1);
|
||||||
auto sprite3 = Sprite::create("Images/test-rgba1.png");
|
|
||||||
sprite3->setPosition(Vec2(3 * s.width / 7, s.height / 2 + 32));
|
sprite3->setPosition(Vec2(3 * s.width / 7, s.height / 2 + 32));
|
||||||
addChild(sprite3, 0);
|
addChild(sprite3, 0);
|
||||||
|
|
||||||
|
@ -1620,8 +1619,7 @@ void TexturePixelFormat::onEnter()
|
||||||
Director::getInstance()->getTextureCache()->removeTexture(sprite3->getTexture());
|
Director::getInstance()->getTextureCache()->removeTexture(sprite3->getTexture());
|
||||||
|
|
||||||
// RGB888 image
|
// RGB888 image
|
||||||
Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGB8);
|
auto sprite4 = Sprite::create("Images/test-rgba1.png", PixelFormat::RGB8);
|
||||||
auto sprite4 = Sprite::create("Images/test-rgba1.png");
|
|
||||||
sprite4->setPosition(Vec2(4 * s.width / 7, s.height / 2 - 32));
|
sprite4->setPosition(Vec2(4 * s.width / 7, s.height / 2 - 32));
|
||||||
addChild(sprite4, 0);
|
addChild(sprite4, 0);
|
||||||
|
|
||||||
|
@ -1629,8 +1627,7 @@ void TexturePixelFormat::onEnter()
|
||||||
Director::getInstance()->getTextureCache()->removeTexture(sprite4->getTexture());
|
Director::getInstance()->getTextureCache()->removeTexture(sprite4->getTexture());
|
||||||
|
|
||||||
// RGB565 image (16-bit)
|
// RGB565 image (16-bit)
|
||||||
Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGB565);
|
auto sprite5 = Sprite::create("Images/test-rgba1.png", PixelFormat::RGB565);
|
||||||
auto sprite5 = Sprite::create("Images/test-rgba1.png");
|
|
||||||
sprite5->setPosition(Vec2(5 * s.width / 7, s.height / 2 + 32));
|
sprite5->setPosition(Vec2(5 * s.width / 7, s.height / 2 + 32));
|
||||||
addChild(sprite5, 0);
|
addChild(sprite5, 0);
|
||||||
|
|
||||||
|
@ -1638,8 +1635,7 @@ void TexturePixelFormat::onEnter()
|
||||||
Director::getInstance()->getTextureCache()->removeTexture(sprite5->getTexture());
|
Director::getInstance()->getTextureCache()->removeTexture(sprite5->getTexture());
|
||||||
|
|
||||||
// A8 image (8-bit)
|
// A8 image (8-bit)
|
||||||
Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::A8);
|
auto sprite6 = Sprite::create("Images/test-rgba1.png", PixelFormat::A8);
|
||||||
auto sprite6 = Sprite::create("Images/test-rgba1.png");
|
|
||||||
sprite6->setPosition(Vec2(6 * s.width / 7, s.height / 2 - 32));
|
sprite6->setPosition(Vec2(6 * s.width / 7, s.height / 2 - 32));
|
||||||
addChild(sprite6, 0);
|
addChild(sprite6, 0);
|
||||||
|
|
||||||
|
@ -1661,8 +1657,6 @@ void TexturePixelFormat::onEnter()
|
||||||
sprite4->runAction(seq_4ever4);
|
sprite4->runAction(seq_4ever4);
|
||||||
sprite5->runAction(seq_4ever5);
|
sprite5->runAction(seq_4ever5);
|
||||||
|
|
||||||
// restore default
|
|
||||||
Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGBA8);
|
|
||||||
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2212,8 +2206,6 @@ TexturePVRv3Premult::TexturePVRv3Premult()
|
||||||
pvr2->setPosition(Vec2(size.width / 4 * 2, size.height / 2));
|
pvr2->setPosition(Vec2(size.width / 4 * 2, size.height / 2));
|
||||||
transformSprite(pvr2);
|
transformSprite(pvr2);
|
||||||
|
|
||||||
// PNG
|
|
||||||
Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGBA8);
|
|
||||||
Director::getInstance()->getTextureCache()->removeTextureForKey("Images/grossinis_sister1-testalpha.png");
|
Director::getInstance()->getTextureCache()->removeTextureForKey("Images/grossinis_sister1-testalpha.png");
|
||||||
auto png = Sprite::create("Images/grossinis_sister1-testalpha.png");
|
auto png = Sprite::create("Images/grossinis_sister1-testalpha.png");
|
||||||
addChild(png, 0);
|
addChild(png, 0);
|
||||||
|
@ -2369,8 +2361,7 @@ std::string TextureATITCInterpolated::subtitle() const
|
||||||
|
|
||||||
static void addImageToDemo(TextureDemo& demo, float x, float y, const char* path, backend::PixelFormat format)
|
static void addImageToDemo(TextureDemo& demo, float x, float y, const char* path, backend::PixelFormat format)
|
||||||
{
|
{
|
||||||
Texture2D::setDefaultAlphaPixelFormat(format);
|
auto sprite = Sprite::create(path, format);
|
||||||
auto sprite = Sprite::create(path);
|
|
||||||
sprite->setPosition(Vec2(x, y));
|
sprite->setPosition(Vec2(x, y));
|
||||||
demo.addChild(sprite, 0);
|
demo.addChild(sprite, 0);
|
||||||
|
|
||||||
|
@ -2398,8 +2389,6 @@ void TextureConvertRGB888::onEnter()
|
||||||
addImageToDemo(*this, 7 * s.width / 9, s.height / 2 + 32, img, backend::PixelFormat::RGBA4);
|
addImageToDemo(*this, 7 * s.width / 9, s.height / 2 + 32, img, backend::PixelFormat::RGBA4);
|
||||||
addImageToDemo(*this, 8 * s.width / 9, s.height / 2 - 32, img, backend::PixelFormat::RGB5A1);
|
addImageToDemo(*this, 8 * s.width / 9, s.height / 2 - 32, img, backend::PixelFormat::RGB5A1);
|
||||||
|
|
||||||
// restore default
|
|
||||||
Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGBA8);
|
|
||||||
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2432,8 +2421,6 @@ void TextureConvertRGBA8888::onEnter()
|
||||||
addImageToDemo(*this, 7 * s.width / 9, s.height / 2 + 32, img, backend::PixelFormat::RGBA4);
|
addImageToDemo(*this, 7 * s.width / 9, s.height / 2 + 32, img, backend::PixelFormat::RGBA4);
|
||||||
addImageToDemo(*this, 8 * s.width / 9, s.height / 2 - 32, img, backend::PixelFormat::RGB5A1);
|
addImageToDemo(*this, 8 * s.width / 9, s.height / 2 - 32, img, backend::PixelFormat::RGB5A1);
|
||||||
|
|
||||||
// restore default
|
|
||||||
Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGBA8);
|
|
||||||
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2466,8 +2453,6 @@ void TextureConvertL8::onEnter()
|
||||||
addImageToDemo(*this, 7 * s.width / 9, s.height / 2 + 32, img, backend::PixelFormat::RGBA4);
|
addImageToDemo(*this, 7 * s.width / 9, s.height / 2 + 32, img, backend::PixelFormat::RGBA4);
|
||||||
addImageToDemo(*this, 8 * s.width / 9, s.height / 2 - 32, img, backend::PixelFormat::RGB5A1);
|
addImageToDemo(*this, 8 * s.width / 9, s.height / 2 - 32, img, backend::PixelFormat::RGB5A1);
|
||||||
|
|
||||||
// restore default
|
|
||||||
Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGBA8);
|
|
||||||
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2500,8 +2485,6 @@ void TextureConvertLA8::onEnter()
|
||||||
addImageToDemo(*this, 7 * s.width / 9, s.height / 2 + 32, img, backend::PixelFormat::RGBA4);
|
addImageToDemo(*this, 7 * s.width / 9, s.height / 2 + 32, img, backend::PixelFormat::RGBA4);
|
||||||
addImageToDemo(*this, 8 * s.width / 9, s.height / 2 - 32, img, backend::PixelFormat::RGB5A1);
|
addImageToDemo(*this, 8 * s.width / 9, s.height / 2 - 32, img, backend::PixelFormat::RGB5A1);
|
||||||
|
|
||||||
// restore default
|
|
||||||
Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGBA8);
|
|
||||||
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,8 +82,8 @@ function BillBoardTest:init()
|
||||||
cameraRightDir.y=0
|
cameraRightDir.y=0
|
||||||
|
|
||||||
local cameraPos= self._camera:getPosition3D()
|
local cameraPos= self._camera:getPosition3D()
|
||||||
cameraPos = cc.vec3add(cameraPos, cc.vec2mul(cameraDir, newPos.y * 0.5))
|
cameraPos = cc.vec3add(cameraPos, cc.vec3mul(cameraDir, newPos.y * 0.5))
|
||||||
cameraPos = cc.vec3add(cameraPos, cc.vec2mul(cameraRightDir, newPos.x * 0.5))
|
cameraPos = cc.vec3add(cameraPos, cc.vec3mul(cameraRightDir, newPos.x * 0.5))
|
||||||
self._camera:setPosition3D(cameraPos)
|
self._camera:setPosition3D(cameraPos)
|
||||||
end
|
end
|
||||||
end, cc.Handler.EVENT_TOUCHES_MOVED)
|
end, cc.Handler.EVENT_TOUCHES_MOVED)
|
||||||
|
@ -143,7 +143,7 @@ function BillBoardTest:init()
|
||||||
self:addNewAniBillBoardWithCoords(cc.vec3(-140,0,0))
|
self:addNewAniBillBoardWithCoords(cc.vec3(-140,0,0))
|
||||||
self:addNewAniBillBoardWithCoords(cc.vec3(-180,0,0))
|
self:addNewAniBillBoardWithCoords(cc.vec3(-180,0,0))
|
||||||
|
|
||||||
self._camera:setPosition(cc.vec3(0, 130, 230))
|
self._camera:setPosition3D(cc.vec3(0, 130, 230))
|
||||||
self._camera:lookAt(cc.vec3(0, 0, 100), cc.vec3(0, 1, 0))
|
self._camera:lookAt(cc.vec3(0, 0, 100), cc.vec3(0, 1, 0))
|
||||||
|
|
||||||
local ttfConfig = {}
|
local ttfConfig = {}
|
||||||
|
|
Loading…
Reference in New Issue