Added TexturePacker console tool and updated to a new version of the Texture Atlas format.

More premake5 project refactor.
Fixed some Stysheet Properties types and fixed some StyleSheetProperty transitions.
This commit is contained in:
Martín Lucas Golini
2020-01-19 17:17:09 -03:00
parent 57c31ffcb4
commit 9d32e29ffb
30 changed files with 746 additions and 437 deletions

17
.gitignore vendored
View File

@@ -24,21 +24,8 @@ projects/android-project-ant/libs
src/examples/strobe
src/thirdparty/SDL2-2.0.10*
*.dll
eees*
eeew*
eetest*
eesound*
eesprite*
eefonts*
eevbo-fbo-batch*
eephysics*
eestrobe*
eeiv*
eehttp-request*
eepp-TextureAtlasEditor*
eepp-UIEditor*
bin/eeui-hello-world*
bin/eepp-MapEditor*
bin/ee*
bin/eepp-*
ee.tag
log.log
external_projects.lua

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -7,7 +7,7 @@ namespace EE { namespace Graphics { namespace Private {
#pragma pack( push, 1 )
#define HDR_NAME_SIZE 64
#define HDR_NAME_SIZE 128
struct sTextureRegionHdr {
char Name[HDR_NAME_SIZE];

View File

@@ -125,11 +125,17 @@ class EE_API TextureAtlasLoader {
/** @return True if the texture atlas is loading. */
const bool& isLoading() const;
/** @brief The function will check if the texture atlas is updated.
Checks if all the images inside the images path are inside the texture atlas, and if they
have the same date and size, otherwise it will recreate or update the texture atlas.
*/
bool updateTextureAtlas( std::string TextureAtlasPath, std::string ImagesPath );
/** The function will check if the texture atlas is updated. Checks if all the images inside the
* images path are inside the texture atlas, and if they have the same date and size, otherwise
* it will recreate or update the texture atlas.
*
* @param TextureAtlasPath The path to the texture atlas ( the ".eta" file )
* @param ImagesPath The directory where the source images are located.
* @param maxImageSize Maximum texture size allowed for the new texture atlas created. Default
* value will use the current image size.
*/
bool updateTextureAtlas( std::string TextureAtlasPath, std::string ImagesPath,
Sizei maxImageSize = Sizei::Zero );
/** Rewrites the texture atlas file. Usefull if the TextureRegions where modified and need to be
* updated inside the texture atlas. */

View File

@@ -50,41 +50,65 @@ class EE_API TexturePacker {
public:
static TexturePacker* New();
/** Creates a new instance of the texture packer indicating the maximum size of the texture
*atlas.
* @param maxWidth The maximum width that the texture atlas will use.
* @param maxHeight The maximum height that the texture atlas will use.
* @param pixelDensity Indicates the device pixel density that represents the resources that
*will the packer pack.
* @param textureFilter Indicates with texture filter should be used when the texture of the
*atlas is loaded.
* @param forcePowOfTwo Indicates that if the max with and height must be adjusted to fit a
*power of two texture.
* @param scalableSVG True if SVG images are scaled to the packer PixelDensity
* @param pixelBorder Indicates how many pixels will be added to separate one image to another
*in the texture atlas. Usefull to avoid artifacts when rendered scaled TextureRegions. Use at
*least 1 pixel to separate images if you will scale any TextureRegion.
* @param allowChilds When enabled if the atlas does not have enough space left in the image to
*put more resources it will create a new image atlas and add the rest of the images in that
*images, repeating this process recursivelly until using all source images.
* @param allowFlipping Indicates if the images can be flipped inside the texture atlas. This
*is not compatible with eepp ( since it can't flip the textures back to the original
*orientation ). So avoid it for eepp.
*/
static TexturePacker*
New( const Uint32& MaxWidth, const Uint32& MaxHeight,
const PixelDensitySize& PixelDensity = PixelDensitySize::MDPI,
const bool& ForcePowOfTwo = true, const bool& scalableSVG = false,
const Uint32& PixelBorder = 0,
New( const Uint32& maxWidth, const Uint32& maxHeight,
const PixelDensitySize& pixelDensity = PixelDensitySize::MDPI,
const bool& forcePowOfTwo = true, const bool& scalableSVG = false,
const Uint32& pixelBorder = 2,
const Texture::TextureFilter& textureFilter = Texture::TextureFilter::Linear,
const bool& AllowFlipping = false );
const bool& allowChilds = false, const bool& allowFlipping = false );
/** Creates a new texture packer ( you will need to call SetOptions before adding any texture or
* image ). */
TexturePacker();
/** Creates a new texture packer indicating the size of the texture atlas.
* @param MaxWidth The maximum width that the texture atlas will use.
* @param MaxHeight The maximum height that the texture atlas will use.
* @param PixelDensity Indicates the device pixel density that represents the resources that
/** Creates a new texture packer indicating the maximum size of the texture atlas.
* @param maxWidth The maximum width that the texture atlas will use.
* @param maxHeight The maximum height that the texture atlas will use.
* @param pixelDensity Indicates the device pixel density that represents the resources that
*will the packer pack.
* @param textureFilter Indicates with texture filter should be used when the texture of the
*atlas is loaded
* @param ForcePowOfTwo Indicates that if the max with and height must be adjusted to fit a
*atlas is loaded.
* @param forcePowOfTwo Indicates that if the max with and height must be adjusted to fit a
*power of two texture.
* @param scalableSVG True if SVG images are scaled to the packer PixelDensity
* @param PixelBorder Indicates how many pixels will be added to separate one image to another
* @param pixelBorder Indicates how many pixels will be added to separate one image to another
*in the texture atlas. Usefull to avoid artifacts when rendered scaled TextureRegions. Use at
*least 1 pixel to separate images if you will scale any TextureRegion.
* @param AllowFlipping Indicates if the images can be flipped inside the texture atlas. This
* @param allowChilds When enabled if the atlas does not have enough space left in the image to
*put more resources it will create a new image atlas and add the rest of the images in that
*images, repeating this process recursivelly until using all source images.
* @param allowFlipping Indicates if the images can be flipped inside the texture atlas. This
*is not compatible with eepp ( since it can't flip the textures back to the original
*orientation ). So avoid it for eepp.
*/
TexturePacker( const Uint32& MaxWidth, const Uint32& MaxHeight,
const PixelDensitySize& PixelDensity = PixelDensitySize::MDPI,
const bool& ForcePowOfTwo = true, const bool& scalableSVG = false,
const Uint32& PixelBorder = 0,
TexturePacker( const Uint32& maxWidth, const Uint32& maxHeight,
const PixelDensitySize& pixelDensity = PixelDensitySize::MDPI,
const bool& forcePowOfTwo = true, const bool& scalableSVG = false,
const Uint32& pixelBorder = 2,
const Texture::TextureFilter& textureFilter = Texture::TextureFilter::Linear,
const bool& AllowFlipping = false );
const bool& allowChilds = false, const bool& allowFlipping = false );
~TexturePacker();
@@ -102,12 +126,14 @@ class EE_API TexturePacker {
/** After adding all the images that will be used to create the texture atlas. Packing the
* textures will generate the texture atlas information ( it will fit the images inside the
* texture atlas, etc ). */
* texture atlas, etc ).
* @return The amount of pixels used for the new image or the total area used. 0 means it
* failed.
*/
Int32 packTextures();
/** @brief Save the texture atlas to a file, in the indicated format.
* If PackTexture() has not been called, it will be called automatically by the function ( so
*you don't need to call it ).
/** Save the texture atlas to a file, in the indicated format. If PackTexture() has not been
*called, it will be called automatically by the function ( so you don't need to call it ).
* @param Filepath The path were it will be saved the new texture atlas.
* @param Format The image format of the new texture atlas.
* @param SaveExtensions Indicates if the extensions of the image files must be saved. Usually
@@ -121,31 +147,34 @@ class EE_API TexturePacker {
/** Clear all the textures added */
void close();
/** First of all you need to set at least the max dimensions of the texture atlas.
* If the instance of the texture packer was created without indicating this data, this must be
*called before adding any texture or image.
* @param MaxWidth The maximum width that the texture atlas will use.
* @param MaxHeight The maximum height that the texture atlas will use.
* @param PixelDensity Indicates the device pixel density that represents the resources that
/** First of all you need to set at least the max dimensions of the texture atlas. If the
*instance of the texture packer was created without indicating this data, this must be called
*before adding any texture or image.
* @param maxWidth The maximum width that the texture atlas will use.
* @param maxHeight The maximum height that the texture atlas will use.
* @param pixelDensity Indicates the device pixel density that represents the resources that
*will the packer pack.
* @param scalableSVG True if SVG images are scaled to the packer PixelDensity
* @param textureFilter Indicates with texture filter should be used when the texture of the
*atlas is loaded
* @param PixelBorder Indicates how many pixels will be added to separate one image to another
*atlas is loaded.
* @param forcePowOfTwo Indicates that if the max with and height must be adjusted to fit a
*power of two texture.
* @param scalableSVG True if SVG images are scaled to the packer PixelDensity
* @param pixelBorder Indicates how many pixels will be added to separate one image to another
*in the texture atlas. Usefull to avoid artifacts when rendered scaled TextureRegions. Use at
*least 1 pixel to separate images if you will scale any TextureRegion.
* @param ForcePowOfTwo Indicates that if the max with and height must be adjusted to fit a
*power of two texture.
* @param AllowFlipping Indicates if the images can be flipped inside the texture atlas. This
* @param allowChilds When enabled if the atlas does not have enough space left in the image to
*put more resources it will create a new image atlas and add the rest of the images in that
*images, repeating this process recursivelly until using all source images.
* @param allowFlipping Indicates if the images can be flipped inside the texture atlas. This
*is not compatible with eepp ( since it can't flip the textures back to the original
*orientation ). So avoid it for eepp.
*/
void setOptions( const Uint32& MaxWidth, const Uint32& MaxHeight,
const PixelDensitySize& PixelDensity = PixelDensitySize::MDPI,
const bool& ForcePowOfTwo = true, const bool& scalableSVG = false,
const Uint32& PixelBorder = 0,
void setOptions( const Uint32& maxWidth, const Uint32& maxHeight,
const PixelDensitySize& pixelDensity = PixelDensitySize::MDPI,
const bool& forcePowOfTwo = true, const bool& scalableSVG = false,
const Uint32& pixelBorder = 2,
const Texture::TextureFilter& textureFilter = Texture::TextureFilter::Linear,
const bool& AllowFlipping = false );
const bool& allowChilds = false, const bool& allowFlipping = false );
/** @return The texture atlas to generate width. */
const Int32& getWidth() const;
@@ -169,6 +198,7 @@ class EE_API TexturePacker {
Sizei mMaxSize;
bool mPacked;
bool mAllowFlipping;
bool mAllowChilds;
TexturePacker* mChild;
Int32 mStrategy;
Int32 mCount;

View File

@@ -9,21 +9,12 @@ namespace EE { namespace UI { namespace CSS {
/** Media Queries support is based on the litehtml implementation:
* https://github.com/litehtml/litehtml licensed under the New BSD License.
*/
#define media_orientation_strings "portrait;landscape"
enum MediaOrientation {
media_orientation_portrait,
media_orientation_landscape,
};
#define media_feature_strings \
"none;width;min-width;max-width;height;min-height;max-height;device-width;min-device-" \
"width;max-device-width;device-height;min-device-height;max-device-height;orientation;" \
"aspect-ratio;min-aspect-ratio;max-aspect-ratio;device-aspect-ratio;min-device-aspect-" \
"ratio;max-device-aspect-ratio;color;min-color;max-color;color-index;min-color-index;max-" \
"color-index;monochrome;min-monochrome;max-monochrome;resolution;min-resolution;max-" \
"resolution"
enum MediaFeature {
media_feature_none,
@@ -70,9 +61,6 @@ enum MediaFeature {
media_feature_max_resolution,
};
#define media_type_strings \
"none;all;screen;print;braille;embossed;handheld;projection;speech;tty;tv"
enum MediaType {
media_type_none,
media_type_all,

View File

@@ -299,7 +299,7 @@ function build_base_configuration( package_name )
set_ios_config()
set_xcode_config()
configuration "debug"
defines { "DEBUG" }
flags { "Symbols" }
@@ -417,7 +417,7 @@ function build_link_configuration( package_name, use_ee_icon )
if _OPTIONS.platform == "ios-cross-x86" then
extension = ".x86.ios"
end
if _OPTIONS.platform == "ios-cross-x86_64" then
extension = ".x86_64.ios"
end
@@ -455,7 +455,7 @@ function build_link_configuration( package_name, use_ee_icon )
add_cross_config_links()
configuration "emscripten"
linkoptions{ "-O2 -s TOTAL_MEMORY=67108864 -s ASM_JS=1 -s VERBOSE=1 -s DISABLE_EXCEPTION_CATCHING=0 -s USE_SDL=2 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ERROR_ON_MISSING_LIBRARIES=0 -s FULL_ES3=1 -s \"BINARYEN_TRAP_MODE='clamp'\"" }
linkoptions{ "-O2 -s TOTAL_MEMORY=67108864 -s ASM_JS=1 -s VERBOSE=1 -s DISABLE_EXCEPTION_CATCHING=0 -s USE_SDL=2 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s FULL_ES3=1 -s \"BINARYEN_TRAP_MODE='clamp'\"" }
buildoptions { "-fno-strict-aliasing -O2 -s USE_SDL=2 -s PRECISE_F32=1 -s ENVIRONMENT=web" }
if _OPTIONS["with-gles1"] and ( not _OPTIONS["with-gles2"] or _OPTIONS["force-gles1"] ) then
@@ -567,7 +567,9 @@ function add_sdl2()
defines { "EE_BACKEND_SDL_ACTIVE", "EE_SDL_VERSION_2" }
if not can_add_static_backend("SDL2") then
table.insert( link_list, get_backend_link_name( "SDL2" ) )
if not os.is_real("emscripten") then
table.insert( link_list, get_backend_link_name( "SDL2" ) )
end
else
insert_static_backend( "SDL2" )
end
@@ -923,17 +925,44 @@ solution "eepp"
files { "src/thirdparty/efsw/src/efsw/*.cpp", osfiles }
if os.is("windows") then
excludes { "src/thirdparty/efsw/src/efsw/WatcherKqueue.cpp", "src/thirdparty/efsw/src/efsw/WatcherFSEvents.cpp", "src/thirdparty/efsw/src/efsw/WatcherInotify.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherKqueue.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherInotify.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherFSEvents.cpp" }
excludes {
"src/thirdparty/efsw/src/efsw/WatcherKqueue.cpp",
"src/thirdparty/efsw/src/efsw/WatcherFSEvents.cpp",
"src/thirdparty/efsw/src/efsw/WatcherInotify.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherKqueue.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherInotify.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherFSEvents.cpp"
}
elseif os.is("linux") then
excludes { "src/thirdparty/efsw/src/efsw/WatcherKqueue.cpp", "src/thirdparty/efsw/src/efsw/WatcherFSEvents.cpp", "src/thirdparty/efsw/src/efsw/WatcherWin32.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherKqueue.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherWin32.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherFSEvents.cpp" }
excludes {
"src/thirdparty/efsw/src/efsw/WatcherKqueue.cpp",
"src/thirdparty/efsw/src/efsw/WatcherFSEvents.cpp",
"src/thirdparty/efsw/src/efsw/WatcherWin32.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherKqueue.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherWin32.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherFSEvents.cpp"
}
elseif os.is("macosx") then
excludes { "src/thirdparty/efsw/src/efsw/WatcherInotify.cpp", "src/thirdparty/efsw/src/efsw/WatcherWin32.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherInotify.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherWin32.cpp" }
excludes {
"src/thirdparty/efsw/src/efsw/WatcherInotify.cpp",
"src/thirdparty/efsw/src/efsw/WatcherWin32.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherInotify.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherWin32.cpp"
}
elseif os.is("freebsd") then
excludes { "src/thirdparty/efsw/src/efsw/WatcherInotify.cpp", "src/thirdparty/efsw/src/efsw/WatcherWin32.cpp", "src/thirdparty/efsw/src/efsw/WatcherFSEvents.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherInotify.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherWin32.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherFSEvents.cpp" }
excludes {
"src/thirdparty/efsw/src/efsw/WatcherInotify.cpp",
"src/thirdparty/efsw/src/efsw/WatcherWin32.cpp",
"src/thirdparty/efsw/src/efsw/WatcherFSEvents.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherInotify.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherWin32.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherFSEvents.cpp"
}
end
build_base_cpp_configuration( "efsw" )
-- Library
project "eepp-main"
kind "StaticLib"
language "C++"
@@ -957,63 +986,63 @@ solution "eepp"
set_kind()
language "C++"
files { "src/test/*.cpp" }
build_link_configuration( "eetest", true )
build_link_configuration( "eepp-test", true )
project "eepp-es"
project "eepp-external-shader"
set_kind()
language "C++"
files { "src/examples/external_shader/*.cpp" }
build_link_configuration( "eees", true )
build_link_configuration( "eepp-external-shader", true )
project "eepp-ew"
project "eepp-empty-window"
set_kind()
language "C++"
files { "src/examples/empty_window/*.cpp" }
build_link_configuration( "eeew", true )
build_link_configuration( "eepp-empty-window", true )
project "eepp-sound"
kind "ConsoleApp"
language "C++"
files { "src/examples/sound/*.cpp" }
build_link_configuration( "eesound", true )
build_link_configuration( "eepp-sound", true )
project "eepp-sprites"
set_kind()
language "C++"
files { "src/examples/sprites/*.cpp" }
build_link_configuration( "eesprites", true )
build_link_configuration( "eepp-sprites", true )
project "eepp-fonts"
set_kind()
language "C++"
files { "src/examples/fonts/*.cpp" }
build_link_configuration( "eefonts", true )
build_link_configuration( "eepp-fonts", true )
project "eepp-vbo-fbo-batch"
set_kind()
language "C++"
files { "src/examples/vbo_fbo_batch/*.cpp" }
build_link_configuration( "eevbo-fbo-batch", true )
build_link_configuration( "eepp-vbo-fbo-batch", true )
project "eepp-physics"
set_kind()
language "C++"
files { "src/examples/physics/*.cpp" }
build_link_configuration( "eephysics", true )
build_link_configuration( "eepp-physics", true )
project "eepp-http-request"
kind "ConsoleApp"
language "C++"
files { "src/examples/http_request/*.cpp" }
includedirs { "src/thirdparty" }
build_link_configuration( "eehttp-request", true )
build_link_configuration( "eepp-http-request", true )
project "eepp-ui-hello-world"
set_kind()
language "C++"
files { "src/examples/ui_hello_world/*.cpp" }
includedirs { "src/thirdparty" }
build_link_configuration( "eeui-hello-world", true )
build_link_configuration( "eepp-ui-hello-world", true )
-- Tools
project "eepp-textureatlaseditor"
@@ -1041,6 +1070,13 @@ solution "eepp"
files { "src/tools/uieditor/*.cpp" }
build_link_configuration( "eepp-UIEditor", true )
project "eepp-texturepacker"
kind "ConsoleApp"
language "C++"
includedirs { "src/thirdparty" }
files { "src/tools/texturepacker/*.cpp" }
build_link_configuration( "eepp-TexturePacker", true )
if os.isfile("external_projects.lua") then
dofile("external_projects.lua")
end

View File

@@ -35,11 +35,6 @@ function multiple_insert( parent_table, insert_table )
end
end
function get_ios_arch()
local archs = string.explode( os.target(), "-" )
return archs[ table_length( archs ) ]
end
function os_findlib( name )
if os.istarget("macosx") and ( is_xcode() or _OPTIONS["use-frameworks"] ) then
local path = "/Library/Frameworks/" .. name .. ".framework"
@@ -137,7 +132,7 @@ function build_base_configuration( package_name )
filter "action:not vs*"
cdialect "gnu99"
buildoptions{ "-Wall" }
buildoptions { "-Wall" }
filter "action:vs*"
incdirs { "src/thirdparty/libzip/vs" }
@@ -151,37 +146,21 @@ function build_base_cpp_configuration( package_name )
set_ios_config()
set_xcode_config()
filter "action:not vs*"
buildoptions { "-Wall" }
filter "configurations:debug"
defines { "DEBUG" }
symbols "On"
if not is_vs() then
buildoptions{ "-Wall" }
end
targetname ( package_name .. "-debug" )
filter "configurations:release"
optimize "Speed"
if not is_vs() then
buildoptions{ "-Wall" }
end
targetname ( package_name )
end
function add_cross_config_links()
if not is_vs() then
if os.istarget("mingw32") or os.istarget("windows") or os.istarget("ios") then -- if is crosscompiling from *nix
linkoptions { "-static-libgcc", "-static-libstdc++" }
end
if os.istarget("mingw32") then
linkoptions { "-Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic" }
end
end
end
function build_link_configuration( package_name, use_ee_icon )
incdirs { "include" }
local extension = "";
if package_name == "eepp" then
@@ -190,10 +169,6 @@ function build_link_configuration( package_name, use_ee_icon )
defines { "EE_STATIC" }
end
if not is_vs() then
buildoptions{ "-std=c++14" }
end
if package_name ~= "eepp" and package_name ~= "eepp-static" then
if not _OPTIONS["with-static-eepp"] then
links { "eepp-shared" }
@@ -203,64 +178,47 @@ function build_link_configuration( package_name, use_ee_icon )
add_static_links()
links { link_list }
end
if os.istarget("windows") and not is_vs() then
if ( true == use_ee_icon ) then
linkoptions { "../../bin/assets/icon/ee.res" }
end
end
if os.istarget("emscripten") then
extension = ".html"
if ( package_name ~= "eeew" and
package_name ~= "eees" and
package_name ~= "eehttp-request" and
package_name ~= "eephysics" and
package_name ~= "eevbo-fbo-batch"
) then
linkoptions { "--preload-file assets/" }
end
end
end
set_ios_config()
set_xcode_config()
filter "configurations:debug"
defines { "DEBUG", "EE_DEBUG", "EE_MEMORY_MANAGER" }
symbols "On"
if not is_vs() and not os.istarget("emscripten") then
buildoptions{ "-Wall -Wno-long-long" }
filter { "system:windows", "action:not vs*" }
if ( true == use_ee_icon ) then
linkoptions { "../../bin/assets/icon/ee.res" }
end
filter "action:not vs*"
cppdialect "C++14"
buildoptions { "-Wall" }
filter { "configurations:debug", "action:not vs*" }
buildoptions{ "-Wno-long-long" }
filter { "configurations:release", "action:not vs*" }
buildoptions { "-fno-strict-aliasing -ffast-math" }
filter { "configurations:release", "action:not vs*", "system:not macosx" }
buildoptions { "-s" }
filter "configurations:debug"
defines { "DEBUG", "EE_DEBUG", "EE_MEMORY_MANAGER" }
targetname ( package_name .. "-debug" .. extension )
filter "configurations:release"
optimize "Speed"
if not is_vs() and not os.istarget("emscripten") then
buildoptions { "-fno-strict-aliasing -ffast-math" }
end
if not is_vs() and not os.istarget("emscripten") and not os.istarget("macosx") then
buildoptions { "-s" }
end
targetname ( package_name .. extension )
filter "system:windows"
add_cross_config_links()
filter { "system:windows or system:ios", "action:not vs*" }
linkoptions { "-static-libgcc", "-static-libstdc++" }
if _OPTIONS["windows-vc-build"] then
syslibdirs { "src/thirdparty/" .. remote_sdl2_version .."/lib/x86" }
end
if is_vs() and table.contains( backends, "SDL2" ) then
filter { "system:windows", "action:vs*" }
if table.contains( backends, "SDL2" ) then
links { "SDL2", "SDL2main" }
end
filter { "options:windows-vc-build", "system:windows" }
syslibdirs { "src/thirdparty/" .. remote_sdl2_version .."/lib/x86" }
filter "system:emscripten"
linkoptions{ "-O2 -s TOTAL_MEMORY=67108864 -s ASM_JS=1 -s VERBOSE=1 -s DISABLE_EXCEPTION_CATCHING=0 -s USE_SDL=2 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ERROR_ON_MISSING_LIBRARIES=0 -s FULL_ES3=1 -s \"BINARYEN_TRAP_MODE='clamp'\"" }
buildoptions { "-fno-strict-aliasing -O2 -s USE_SDL=2 -s PRECISE_F32=1 -s ENVIRONMENT=web" }
@@ -390,7 +348,7 @@ function set_xcode_config()
end
function set_ios_config()
if _OPTIONS.platform == "ios-arm7" or _OPTIONS.platform == "ios-x86" then
if os.istarget("ios") then
local err = false
if nil == os.getenv("TOOLCHAINPATH") then
@@ -495,50 +453,7 @@ function check_ssl_support()
defines { "EE_SSL_SUPPORT" }
end
function set_macos_and_ios_config()
if os.istarget("macosx") and ( is_xcode() or _OPTIONS["use-frameworks"] ) then
libdirs { "/System/Library/Frameworks", "/Library/Frameworks" }
end
if _OPTIONS["use-frameworks"] then
defines { "EE_USE_FRAMEWORKS" }
end
end
function build_eepp( build_name )
incdirs { "include", "src", "src/thirdparty", "include/eepp/thirdparty", "src/thirdparty/freetype2/include", "src/thirdparty/zlib", "src/thirdparty/libogg/include", "src/thirdparty/libvorbis/include", "src/thirdparty/mbedtls/include" }
if _OPTIONS["with-mojoal"] then
defines( "AL_LIBTYPE_STATIC" )
incdirs { "src/thirdparty/mojoAL" }
end
if _OPTIONS["windows-vc-build"] then
incdirs { "src/thirdparty/" .. remote_sdl2_version .. "/include" }
end
set_macos_and_ios_config()
set_ios_config()
set_xcode_config()
add_static_links()
if is_vs() then
incdirs { "src/thirdparty/libzip/vs" }
end
if not is_vs() then
buildoptions{ "-std=c++14" }
end
if os.istarget("windows") then
files { "src/eepp/system/platform/win/*.cpp" }
files { "src/eepp/network/platform/win/*.cpp" }
else
files { "src/eepp/system/platform/posix/*.cpp" }
files { "src/eepp/network/platform/unix/*.cpp" }
end
files { "src/eepp/core/*.cpp",
"src/eepp/math/*.cpp",
"src/eepp/system/*.cpp",
@@ -561,57 +476,74 @@ function build_eepp( build_name )
"src/eepp/maps/mapeditor/*.cpp"
}
incdirs { "include",
"src",
"src/thirdparty",
"include/eepp/thirdparty",
"src/thirdparty/freetype2/include",
"src/thirdparty/zlib",
"src/thirdparty/libogg/include",
"src/thirdparty/libvorbis/include",
"src/thirdparty/mbedtls/include"
}
add_static_links()
check_ssl_support()
select_backend()
if _OPTIONS["with-dynamic-freetype"] and os_findlib("freetype") then
table.insert( link_list, get_backend_link_name( "freetype" ) )
end
multiple_insert( link_list, os_links )
links { link_list }
build_link_configuration( build_name )
configuration "emscripten"
if _OPTIONS["force-gles1"] then
defines{ "EE_GLES1_DEFAULT" }
end
end
filter "options:use-frameworks"
defines { "EE_USE_FRAMEWORKS" }
function set_targetdir( dir )
if os.istarget("ios") then
targetdir(dir .. get_ios_arch() .. "/" )
else
targetdir(dir)
end
filter { "system:macosx", "action:xcode* or options:use-frameworks" }
libdirs { "/System/Library/Frameworks", "/Library/Frameworks" }
filter "with-dynamic-freetype"
if os_findlib("freetype") then
table.insert( link_list, get_backend_link_name( "freetype" ) )
end
filter "system:windows"
files { "src/eepp/system/platform/win/*.cpp" }
files { "src/eepp/network/platform/win/*.cpp" }
filter "system:not windows"
files { "src/eepp/system/platform/posix/*.cpp" }
files { "src/eepp/network/platform/unix/*.cpp" }
filter "with-mojoal"
defines( "AL_LIBTYPE_STATIC" )
incdirs { "src/thirdparty/mojoAL" }
filter "options:windows-vc-build"
incdirs { "src/thirdparty/" .. remote_sdl2_version .. "/include" }
filter "action:vs*"
incdirs { "src/thirdparty/libzip/vs" }
filter "action:not vs*"
cppdialect "C++14"
end
workspace "eepp"
targetdir("./bin/")
configurations { "debug", "release" }
rtti "On"
download_and_extract_dependencies()
generate_os_links()
parse_args()
location("./make/" .. os.target() .. "/")
objdir("obj/" .. os.target() .. "/")
if os.istarget("android") then
filter "system:android"
ndkabi "arm64-v8a"
ndkplatform "android-28"
ndkstl "c++_static"
end
if os.istarget("ios") then
location("./make/" .. os.target() .. "/" )
objdir("obj/" .. os.target() .. "/" .. get_ios_arch() .. "/" )
else
location("./make/" .. os.target() .. "/")
objdir("obj/" .. os.target() .. "/")
end
generate_os_links()
parse_args()
filter "configurations:debug"
defines { "DEBUG" }
@@ -621,7 +553,7 @@ workspace "eepp"
project "SOIL2-static"
kind "StaticLib"
set_targetdir("libs/" .. os.target() .. "/thirdparty/")
targetdir("libs/" .. os.target() .. "/thirdparty/")
files { "src/thirdparty/SOIL2/src/SOIL2/*.c" }
incdirs { "src/thirdparty/SOIL2" }
build_base_configuration( "SOIL2" )
@@ -635,7 +567,7 @@ workspace "eepp"
kind "StaticLib"
language "C"
defines { "GLEW_NO_GLU", "GLEW_STATIC" }
set_targetdir("libs/" .. os.target() .. "/thirdparty/")
targetdir("libs/" .. os.target() .. "/thirdparty/")
files { "src/thirdparty/glew/*.c" }
incdirs { "include/thirdparty/glew" }
build_base_configuration( "glew" )
@@ -643,7 +575,7 @@ workspace "eepp"
project "mbedtls-static"
kind "StaticLib"
language "C"
set_targetdir("libs/" .. os.target() .. "/thirdparty/")
targetdir("libs/" .. os.target() .. "/thirdparty/")
incdirs { "src/thirdparty/mbedtls/include/" }
files { "src/thirdparty/mbedtls/library/*.c" }
build_base_cpp_configuration( "mbedtls" )
@@ -651,7 +583,7 @@ workspace "eepp"
project "vorbis-static"
kind "StaticLib"
language "C"
set_targetdir("libs/" .. os.target() .. "/thirdparty/")
targetdir("libs/" .. os.target() .. "/thirdparty/")
incdirs { "src/thirdparty/libvorbis/lib/", "src/thirdparty/libogg/include", "src/thirdparty/libvorbis/include" }
files { "src/thirdparty/libogg/**.c", "src/thirdparty/libvorbis/**.c" }
build_base_cpp_configuration( "vorbis" )
@@ -659,21 +591,21 @@ workspace "eepp"
project "pugixml-static"
kind "StaticLib"
language "C++"
set_targetdir("libs/" .. os.target() .. "/thirdparty/")
targetdir("libs/" .. os.target() .. "/thirdparty/")
files { "src/thirdparty/pugixml/*.cpp" }
build_base_cpp_configuration( "pugixml" )
project "zlib-static"
kind "StaticLib"
language "C"
set_targetdir("libs/" .. os.target() .. "/thirdparty/")
targetdir("libs/" .. os.target() .. "/thirdparty/")
files { "src/thirdparty/zlib/*.c" }
build_base_configuration( "zlib" )
project "libzip-static"
kind "StaticLib"
language "C"
set_targetdir("libs/" .. os.target() .. "/thirdparty/")
targetdir("libs/" .. os.target() .. "/thirdparty/")
files { "src/thirdparty/libzip/*.c" }
incdirs { "src/thirdparty/zlib" }
build_base_configuration( "libzip" )
@@ -681,7 +613,7 @@ workspace "eepp"
project "freetype-static"
kind "StaticLib"
language "C"
set_targetdir("libs/" .. os.target() .. "/thirdparty/")
targetdir("libs/" .. os.target() .. "/thirdparty/")
defines { "FT2_BUILD_LIBRARY" }
files { "src/thirdparty/freetype2/src/**.c" }
incdirs { "src/thirdparty/freetype2/include" }
@@ -689,7 +621,7 @@ workspace "eepp"
project "chipmunk-static"
kind "StaticLib"
set_targetdir("libs/" .. os.target() .. "/thirdparty/")
targetdir("libs/" .. os.target() .. "/thirdparty/")
files { "src/thirdparty/chipmunk/*.c", "src/thirdparty/chipmunk/constraints/*.c" }
incdirs { "include/eepp/thirdparty/chipmunk" }
build_base_configuration( "chipmunk" )
@@ -702,21 +634,21 @@ workspace "eepp"
project "jpeg-compressor-static"
kind "StaticLib"
language "C++"
set_targetdir("libs/" .. os.target() .. "/thirdparty/")
targetdir("libs/" .. os.target() .. "/thirdparty/")
files { "src/thirdparty/jpeg-compressor/*.cpp" }
build_base_cpp_configuration( "jpeg-compressor" )
project "imageresampler-static"
kind "StaticLib"
language "C++"
set_targetdir("libs/" .. os.target() .. "/thirdparty/")
targetdir("libs/" .. os.target() .. "/thirdparty/")
files { "src/thirdparty/imageresampler/*.cpp" }
build_base_cpp_configuration( "imageresampler" )
project "mojoal-static"
kind "StaticLib"
language "C"
set_targetdir("libs/" .. os.target() .. "/thirdparty/")
targetdir("libs/" .. os.target() .. "/thirdparty/")
incdirs { "include/eepp/thirdparty/mojoAL" }
defines( "AL_LIBTYPE_STATIC" )
files { "src/thirdparty/mojoAL/*.c" }
@@ -727,38 +659,65 @@ workspace "eepp"
project "efsw-static"
kind "StaticLib"
language "C++"
set_targetdir("libs/" .. os.target() .. "/thirdparty/")
targetdir("libs/" .. os.target() .. "/thirdparty/")
incdirs { "src/thirdparty/efsw/include", "src/thirdparty/efsw/src" }
files { "src/thirdparty/efsw/src/efsw/*.cpp" }
build_base_cpp_configuration( "efsw" )
filter "system:windows"
files { "src/thirdparty/efsw/src/efsw/platform/win/*.cpp" }
excludes { "src/thirdparty/efsw/src/efsw/WatcherKqueue.cpp", "src/thirdparty/efsw/src/efsw/WatcherFSEvents.cpp", "src/thirdparty/efsw/src/efsw/WatcherInotify.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherKqueue.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherInotify.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherFSEvents.cpp" }
excludes {
"src/thirdparty/efsw/src/efsw/WatcherKqueue.cpp",
"src/thirdparty/efsw/src/efsw/WatcherFSEvents.cpp",
"src/thirdparty/efsw/src/efsw/WatcherInotify.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherKqueue.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherInotify.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherFSEvents.cpp"
}
filter "system:linux"
excludes { "src/thirdparty/efsw/src/efsw/WatcherKqueue.cpp", "src/thirdparty/efsw/src/efsw/WatcherFSEvents.cpp", "src/thirdparty/efsw/src/efsw/WatcherWin32.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherKqueue.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherWin32.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherFSEvents.cpp" }
excludes {
"src/thirdparty/efsw/src/efsw/WatcherKqueue.cpp",
"src/thirdparty/efsw/src/efsw/WatcherFSEvents.cpp",
"src/thirdparty/efsw/src/efsw/WatcherWin32.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherKqueue.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherWin32.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherFSEvents.cpp"
}
filter "system:macosx"
excludes { "src/thirdparty/efsw/src/efsw/WatcherInotify.cpp", "src/thirdparty/efsw/src/efsw/WatcherWin32.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherInotify.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherWin32.cpp" }
excludes {
"src/thirdparty/efsw/src/efsw/WatcherInotify.cpp",
"src/thirdparty/efsw/src/efsw/WatcherWin32.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherInotify.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherWin32.cpp"
}
filter "system:bsd"
excludes { "src/thirdparty/efsw/src/efsw/WatcherInotify.cpp", "src/thirdparty/efsw/src/efsw/WatcherWin32.cpp", "src/thirdparty/efsw/src/efsw/WatcherFSEvents.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherInotify.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherWin32.cpp", "src/thirdparty/efsw/src/efsw/FileWatcherFSEvents.cpp" }
excludes {
"src/thirdparty/efsw/src/efsw/WatcherInotify.cpp",
"src/thirdparty/efsw/src/efsw/WatcherWin32.cpp",
"src/thirdparty/efsw/src/efsw/WatcherFSEvents.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherInotify.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherWin32.cpp",
"src/thirdparty/efsw/src/efsw/FileWatcherFSEvents.cpp"
}
filter "system:not windows"
files { "src/thirdparty/efsw/src/efsw/platform/posix/*.cpp" }
-- Library
project "eepp-main"
kind "StaticLib"
language "C++"
set_targetdir("libs/" .. os.target() .. "/")
targetdir("libs/" .. os.target() .. "/")
files { "src/eepp/main/eepp_main.cpp" }
project "eepp-static"
kind "StaticLib"
language "C++"
set_targetdir("libs/" .. os.target() .. "/")
targetdir("libs/" .. os.target() .. "/")
build_eepp( "eepp-static" )
project "eepp-shared"
kind "SharedLib"
language "C++"
set_targetdir("libs/" .. os.target() .. "/")
targetdir("libs/" .. os.target() .. "/")
build_eepp( "eepp" )
-- Examples
@@ -766,63 +725,63 @@ workspace "eepp"
set_kind()
language "C++"
files { "src/test/*.cpp" }
build_link_configuration( "eetest", true )
build_link_configuration( "eepp-test", true )
project "eepp-es"
project "eepp-external-shader"
set_kind()
language "C++"
files { "src/examples/external_shader/*.cpp" }
build_link_configuration( "eees", true )
build_link_configuration( "eepp-external-shader", true )
project "eepp-ew"
project "eepp-empty-window"
set_kind()
language "C++"
files { "src/examples/empty_window/*.cpp" }
build_link_configuration( "eeew", true )
build_link_configuration( "eepp-empty-window", true )
project "eepp-sound"
kind "ConsoleApp"
language "C++"
files { "src/examples/sound/*.cpp" }
build_link_configuration( "eesound", true )
build_link_configuration( "eepp-sound", true )
project "eepp-sprites"
set_kind()
language "C++"
files { "src/examples/sprites/*.cpp" }
build_link_configuration( "eesprites", true )
build_link_configuration( "eepp-sprites", true )
project "eepp-fonts"
set_kind()
language "C++"
files { "src/examples/fonts/*.cpp" }
build_link_configuration( "eefonts", true )
build_link_configuration( "eepp-fonts", true )
project "eepp-vbo-fbo-batch"
set_kind()
language "C++"
files { "src/examples/vbo_fbo_batch/*.cpp" }
build_link_configuration( "eevbo-fbo-batch", true )
build_link_configuration( "eepp-vbo-fbo-batch", true )
project "eepp-physics"
set_kind()
language "C++"
files { "src/examples/physics/*.cpp" }
build_link_configuration( "eephysics", true )
build_link_configuration( "eepp-physics", true )
project "eepp-http-request"
kind "ConsoleApp"
language "C++"
files { "src/examples/http_request/*.cpp" }
incdirs { "src/thirdparty" }
build_link_configuration( "eehttp-request", true )
build_link_configuration( "eepp-http-request", true )
project "eepp-ui-hello-world"
set_kind()
language "C++"
files { "src/examples/ui_hello_world/*.cpp" }
incdirs { "src/thirdparty" }
build_link_configuration( "eeui-hello-world", true )
build_link_configuration( "eepp-ui-hello-world", true )
-- Tools
project "eepp-textureatlaseditor"
@@ -849,6 +808,13 @@ workspace "eepp"
filter { "system:not windows", "system:not haiku" }
links { "pthread" }
project "eepp-texturepacker"
kind "ConsoleApp"
language "C++"
incdirs { "src/thirdparty" }
files { "src/tools/texturepacker/*.cpp" }
build_link_configuration( "eepp-TexturePacker", true )
if os.isfile("external_projects.lua") then
dofile("external_projects.lua")
end

View File

@@ -1,5 +1,7 @@
#!/bin/sh
# Currently latest emsdk tested and working version: 1.38.33
# Currently latest emsdk tested and working version: latest-fastcomp
# remember to first set the environment
# source /path/to/emsdk/emsdk_env.sh
cd $(dirname "$0")
premake4 --file=../../premake4.lua --with-gles1 --with-gles2 --with-static-eepp --platform=emscripten --with-backend=SDL2 gmake
cd ../../make/emscripten/
@@ -7,4 +9,4 @@ ln -sf ../../bin/assets/ ./
sed -i 's/-rcs/rcs/g' *.make
emmake make -j`nproc` $@
# Fix a bug in emscripten, see my patch: https://github.com/emscripten-core/emscripten/pull/10208
sed 's/function _alGetSource3f(source,/function _alGetSource3f(sourceId,/' ../../bin/*.js
sed -i 's/function _alGetSource3f(source,/function _alGetSource3f(sourceId,/' ../../bin/*.js

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.0, 2020-01-18T19:39:43. -->
<!-- Written by QtCreator 4.11.0, 2020-01-19T14:35:00. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@@ -77,9 +77,9 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{6d057187-158a-4883-8d5b-d470a6b6b025}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">12</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">10</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">15</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">17</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">../../make/linux</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
@@ -995,8 +995,8 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eetest-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eetest-debug</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eepp-test-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-test-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments"></value>
@@ -1071,8 +1071,8 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eetest</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eetest-release</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eepp-test</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-test-release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments"></value>
@@ -1147,8 +1147,8 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eephysics-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eephysics-debug</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eepp-physics-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-physics-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments"></value>
@@ -1223,8 +1223,8 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eehttp-request-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eehttp-request-debug</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eepp-http-request-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-http-request-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments"></value>
@@ -1603,8 +1603,8 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eeui-hello-world-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eeui-hello-world-debug</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eepp-ui-hello-world-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-ui-hello-world-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments"></value>
@@ -1619,6 +1619,82 @@
<value type="QString" key="RunConfiguration.WorkingDirectory">%{buildDir}../../../bin/</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.17">
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
<value type="QString">cpu-cycles</value>
</valuelist>
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
<value type="int" key="Analyzer.Perf.Frequency">250</value>
<valuelist type="QVariantList" key="Analyzer.Perf.RecordArguments">
<value type="QString">-e</value>
<value type="QString">cpu-cycles</value>
<value type="QString">--call-graph</value>
<value type="QString">dwarf,4096</value>
<value type="QString">-F</value>
<value type="QString">250</value>
</valuelist>
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">0</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eepp-TexturePacker-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-TexturePacker-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments">-p assets/ui/uitheme/ -o textureatlas.eta -u --allow-childs</value>
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
<value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
<value type="bool" key="RunConfiguration.UseTerminal">false</value>
<value type="QString" key="RunConfiguration.WorkingDirectory">%{buildDir}../../../bin/</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.2">
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
@@ -1679,8 +1755,8 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eeew-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eeew-debug</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eepp-empty-window-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-empty-window-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments"></value>
@@ -1755,8 +1831,8 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eeew</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eeew-release</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eepp-empty-window</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-empty-window-release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments"></value>
@@ -1831,8 +1907,8 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eees-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eees-debug</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eepp-external-shader-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-external-shader-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments"></value>
@@ -1907,8 +1983,8 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eees</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eees-release</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eepp-external-shader</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-external-shader-release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments"></value>
@@ -1983,8 +2059,8 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eesound-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eesound-debug</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eepp-sound-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-sound-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments"></value>
@@ -2059,8 +2135,8 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eesprites-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eesprites-debug</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eepp-sprites-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-sprites-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments"></value>
@@ -2135,8 +2211,8 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eefonts-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eefonts-debug</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eepp-fonts-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-fonts-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments"></value>
@@ -2211,8 +2287,8 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eevbo-fbo-batch-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eevbo-fbo-batch-debug</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}../../../bin/eepp-vbo-fbo-batch-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-vbo-fbo-batch-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments"></value>
@@ -2227,7 +2303,7 @@
<value type="QString" key="RunConfiguration.WorkingDirectory">%{buildDir}../../../bin/</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">17</value>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">18</value>
</valuemap>
</data>
<data>

View File

@@ -911,4 +911,5 @@
../../src/thirdparty/SOIL2/src/SOIL2/stbi_pvr.h
../../src/tools/mapeditor/mapeditor.cpp
../../src/tools/textureatlaseditor/textureatlaseditor.cpp
../../src/tools/texturepacker/texturepacker.cpp
../../src/tools/uieditor/uieditor.cpp

View File

@@ -28,7 +28,22 @@ unsigned long read( FT_Stream rec, unsigned long offset, unsigned char* buffer,
} else
return count > 0 ? 0 : 1; // error code is 0 if we're reading, or nonzero if we're seeking
}
void close( FT_Stream ) {}
// Helper to intepret memory as a specific type
template <typename T, typename U> inline T reinterpret( const U& input ) {
T output;
std::memcpy( &output, &input, sizeof( U ) );
return output;
}
// Combine outline thickness, boldness and font glyph index into a single 64-bit key
EE::Uint64 combine( float outlineThickness, bool bold, EE::Uint32 index ) {
return ( static_cast<EE::Uint64>( reinterpret<EE::Uint32>( outlineThickness ) ) << 32 ) |
( static_cast<EE::Uint64>( bold ) << 31 ) | index;
}
} // namespace
namespace EE { namespace Graphics {
@@ -273,8 +288,8 @@ const Glyph& FontTrueType::getGlyph( Uint32 codePoint, unsigned int characterSiz
GlyphTable& glyphs = mPages[characterSize].glyphs;
// Build the key by combining the code point, bold flag, and outline thickness
Uint64 key = ( static_cast<Uint64>( *reinterpret_cast<Uint32*>( &outlineThickness ) ) << 32 ) |
( static_cast<Uint64>( bold ? 1 : 0 ) << 31 ) | static_cast<Uint64>( codePoint );
Uint64 key = combine( outlineThickness, bold,
FT_Get_Char_Index( static_cast<FT_Face>( mFace ), codePoint ) );
// Search the glyph into the cache
GlyphTable::const_iterator it = glyphs.find( key );

View File

@@ -233,9 +233,6 @@ void TextureAtlasLoader::createTextureRegions() {
// Create the Texture Atlas with the name of the real texture, not the Childs ( example
// load 1.png and not 1_ch1.png )
if ( 0 == z ) {
if ( mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_REMOVE_EXTENSION )
name = FileSystem::fileRemoveExtension( name );
std::string etapath =
FileSystem::fileRemoveExtension( path ) + EE_TEXTURE_ATLAS_EXTENSION;
@@ -260,10 +257,6 @@ void TextureAtlasLoader::createTextureRegions() {
sTextureRegionHdr* tSh = &tTexAtlas->TextureRegions[i];
std::string TextureRegionName( &tSh->Name[0] );
if ( mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_REMOVE_EXTENSION )
TextureRegionName = FileSystem::fileRemoveExtension( TextureRegionName );
Rect tRect( tSh->X, tSh->Y, tSh->X + tSh->Width, tSh->Y + tSh->Height );
TextureRegion* tTextureRegion = TextureRegion::New(
@@ -372,8 +365,8 @@ bool TextureAtlasLoader::updateTextureAtlas() {
return false;
}
bool TextureAtlasLoader::updateTextureAtlas( std::string TextureAtlasPath,
std::string ImagesPath ) {
bool TextureAtlasLoader::updateTextureAtlas( std::string TextureAtlasPath, std::string ImagesPath,
Sizei maxImageSize ) {
if ( !TextureAtlasPath.size() || !ImagesPath.size() ||
!FileSystem::fileExists( TextureAtlasPath ) || !FileSystem::isDirectory( ImagesPath ) )
return false;
@@ -464,16 +457,19 @@ bool TextureAtlasLoader::updateTextureAtlas( std::string TextureAtlasPath,
Image::saveTypeToExtension( mTexGrHdr.Format ) );
if ( 2 == NeedUpdate ) {
TexturePacker tp( mTexGrHdr.Width, mTexGrHdr.Height, pixelDensity,
0 != ( mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_POW_OF_TWO ),
0 != ( mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_SCALABLE_SVG ),
mTexGrHdr.PixelBorder,
(Texture::TextureFilter)mTexGrHdr.TextureFilter,
mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_ALLOW_FLIPPING );
TexturePacker tp(
maxImageSize.getWidth() == 0 ? mTexGrHdr.Width : maxImageSize.getWidth(),
maxImageSize.getHeight() == 0 ? mTexGrHdr.Height : maxImageSize.getHeight(),
pixelDensity, 0 != ( mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_POW_OF_TWO ),
0 != ( mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_SCALABLE_SVG ), mTexGrHdr.PixelBorder,
(Texture::TextureFilter)mTexGrHdr.TextureFilter,
mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_ALLOW_FLIPPING );
tp.addTexturesPath( ImagesPath );
tp.packTextures();
if ( tp.packTextures() <= 0 ) {
return false;
}
tp.save( tapath, (Image::SaveType)mTexGrHdr.Format );
} else if ( 1 == NeedUpdate ) {

View File

@@ -12,26 +12,27 @@ TexturePacker* TexturePacker::New() {
return eeNew( TexturePacker, () );
}
TexturePacker* TexturePacker::New( const Uint32& MaxWidth, const Uint32& MaxHeight,
const PixelDensitySize& PixelDensity, const bool& ForcePowOfTwo,
const bool& scalableSVG, const Uint32& PixelBorder,
TexturePacker* TexturePacker::New( const Uint32& maxWidth, const Uint32& maxHeight,
const PixelDensitySize& pixelDensity, const bool& forcePowOfTwo,
const bool& scalableSVG, const Uint32& pixelBorder,
const Texture::TextureFilter& textureFilter,
const bool& AllowFlipping ) {
return eeNew( TexturePacker, ( MaxWidth, MaxHeight, PixelDensity, ForcePowOfTwo, scalableSVG,
PixelBorder, textureFilter, AllowFlipping ) );
const bool& allowChilds, const bool& allowFlipping ) {
return eeNew( TexturePacker, ( maxWidth, maxHeight, pixelDensity, forcePowOfTwo, scalableSVG,
pixelBorder, textureFilter, allowChilds, allowFlipping ) );
}
TexturePacker::TexturePacker( const Uint32& MaxWidth, const Uint32& MaxHeight,
const PixelDensitySize& PixelDensity, const bool& ForcePowOfTwo,
const bool& scalableSVG, const Uint32& PixelBorder,
const Texture::TextureFilter& textureFilter,
const bool& AllowFlipping ) :
TexturePacker::TexturePacker( const Uint32& maxWidth, const Uint32& maxHeight,
const PixelDensitySize& pixelDensity, const bool& forcePowOfTwo,
const bool& scalableSVG, const Uint32& pixelBorder,
const Texture::TextureFilter& textureFilter, const bool& allowChilds,
const bool& allowFlipping ) :
mTotalArea( 0 ),
mFreeList( NULL ),
mWidth( 128 ),
mHeight( 128 ),
mPacked( false ),
mAllowFlipping( false ),
mAllowFlipping( allowFlipping ),
mAllowChilds( allowChilds ),
mChild( NULL ),
mStrategy( PackBig ),
mCount( 0 ),
@@ -39,13 +40,13 @@ TexturePacker::TexturePacker( const Uint32& MaxWidth, const Uint32& MaxHeight,
mPlacedCount( 0 ),
mForcePowOfTwo( true ),
mPixelBorder( 0 ),
mPixelDensity( PixelDensity ),
mPixelDensity( pixelDensity ),
mTextureFilter( textureFilter ),
mSaveExtensions( false ),
mScalableSVG( scalableSVG ),
mFormat( Image::SaveType::SAVE_TYPE_PNG ) {
setOptions( MaxWidth, MaxHeight, PixelDensity, ForcePowOfTwo, scalableSVG, PixelBorder,
textureFilter, AllowFlipping );
setOptions( maxWidth, maxHeight, pixelDensity, forcePowOfTwo, scalableSVG, pixelBorder,
textureFilter, allowChilds, allowFlipping );
}
TexturePacker::TexturePacker() :
@@ -131,25 +132,26 @@ Uint32 TexturePacker::getAtlasNumChannels() {
return maxChannels;
}
void TexturePacker::setOptions( const Uint32& MaxWidth, const Uint32& MaxHeight,
const PixelDensitySize& PixelDensity, const bool& ForcePowOfTwo,
const bool& scalableSVG, const Uint32& PixelBorder,
void TexturePacker::setOptions( const Uint32& maxWidth, const Uint32& maxHeight,
const PixelDensitySize& pixelDensity, const bool& forcePowOfTwo,
const bool& scalableSVG, const Uint32& pixelBorder,
const Texture::TextureFilter& textureFilter,
const bool& AllowFlipping ) {
const bool& allowChilds, const bool& allowFlipping ) {
if ( !mTextures.size() ) { // only can change the dimensions before adding any texture
mMaxSize.x = MaxWidth;
mMaxSize.y = MaxHeight;
mMaxSize.x = maxWidth;
mMaxSize.y = maxHeight;
if ( ForcePowOfTwo && !Math::isPow2( mMaxSize.x ) )
if ( forcePowOfTwo && !Math::isPow2( mMaxSize.x ) )
mMaxSize.x = Math::nextPowOfTwo( mMaxSize.x );
if ( ForcePowOfTwo && !Math::isPow2( mMaxSize.y ) )
if ( forcePowOfTwo && !Math::isPow2( mMaxSize.y ) )
mMaxSize.y = Math::nextPowOfTwo( mMaxSize.y );
mForcePowOfTwo = ForcePowOfTwo;
mAllowFlipping = AllowFlipping;
mPixelBorder = PixelBorder;
mPixelDensity = PixelDensity;
mForcePowOfTwo = forcePowOfTwo;
mAllowFlipping = allowFlipping;
mAllowChilds = allowChilds;
mPixelBorder = pixelBorder;
mPixelDensity = pixelDensity;
mTextureFilter = textureFilter;
mScalableSVG = scalableSVG;
}
@@ -397,8 +399,8 @@ void TexturePacker::insertTexture( TexturePackerTex* t, TexturePackerNode* bestF
}
void TexturePacker::createChild() {
mChild = eeNew( TexturePacker, ( mWidth, mHeight, mPixelDensity, mForcePowOfTwo, mScalableSVG,
mPixelBorder, mTextureFilter, mAllowFlipping ) );
mChild = TexturePacker::New( mWidth, mHeight, mPixelDensity, mForcePowOfTwo, mScalableSVG,
mPixelBorder, mTextureFilter, mAllowFlipping );
std::list<TexturePackerTex*>::iterator it;
std::list<std::list<TexturePackerTex*>::iterator> remove;
@@ -504,8 +506,7 @@ bool TexturePacker::addTexture( const std::string& TexturePath ) {
return false;
}
Int32 TexturePacker::packTextures() { // pack the textures, the return code is the amount of
// wasted/unused area.
Int32 TexturePacker::packTextures() {
TexturePackerTex* t = NULL;
addBorderToTextures( (Int32)mPixelBorder );
@@ -569,8 +570,9 @@ Int32 TexturePacker::packTextures() { // pack the textures, the return code is t
return packTextures();
} else {
eePRINTL( "Creating a new image as a child." );
createChild();
if ( !mAllowChilds ) {
return 0;
}
}
break;
@@ -578,8 +580,13 @@ Int32 TexturePacker::packTextures() { // pack the textures, the return code is t
}
if ( mCount > 0 ) {
eePRINTL( "Creating a new image as a child. Some textures couldn't get it: %d", mCount );
createChild();
if ( mAllowChilds ) {
eePRINTL( "Creating a new image as a child. Some textures couldn't get it: %d",
mCount );
createChild();
} else {
return 0;
}
}
addBorderToTextures( -( (Int32)mPixelBorder ) );
@@ -594,7 +601,7 @@ Int32 TexturePacker::packTextures() { // pack the textures, the return code is t
eePRINTL( "Total Area Used: %d. This represents the %4.3f percent", mTotalArea,
( (double)mTotalArea / (double)( mWidth * mHeight ) ) * 100.0 );
return ( mWidth * mHeight ) - mTotalArea;
return mTotalArea;
}
void TexturePacker::save( const std::string& Filepath, const Image::SaveType& Format,
@@ -671,15 +678,12 @@ Int32 TexturePacker::getChildCount() {
}
void TexturePacker::saveTextureRegions() {
if ( NULL != mParent )
return;
sTextureAtlasHdr TexGrHdr;
TexGrHdr.Magic = EE_TEXTURE_ATLAS_MAGIC;
TexGrHdr.Version = 1000;
TexGrHdr.Version = 2000;
TexGrHdr.Date = static_cast<Uint64>( Sys::getSystemTime() );
TexGrHdr.TextureCount = 1 + getChildCount();
TexGrHdr.TextureCount = 1;
TexGrHdr.Format = mFormat;
TexGrHdr.Width = mWidth;
TexGrHdr.Height = mHeight;
@@ -706,15 +710,6 @@ void TexturePacker::saveTextureRegions() {
TexHdr[0] = createTextureHdr( this );
Int32 HdrPos = 1;
TexturePacker* Child = mChild;
while ( NULL != Child ) {
TexHdr[HdrPos] = createTextureHdr( Child );
Child = Child->getChild();
HdrPos++;
}
std::vector<sTextureRegionHdr> tTextureRegionsHdr;
std::string path = FileSystem::fileRemoveExtension( mFilepath ) + EE_TEXTURE_ATLAS_EXTENSION;
@@ -730,24 +725,6 @@ void TexturePacker::saveTextureRegions() {
if ( tTextureRegionsHdr.size() )
fs.write( reinterpret_cast<const char*>( &tTextureRegionsHdr[0] ),
sizeof( sTextureRegionHdr ) * (std::streamsize)tTextureRegionsHdr.size() );
Int32 HdrPos = 1;
TexturePacker* Child = mChild;
while ( NULL != Child ) {
fs.write( reinterpret_cast<const char*>( &TexHdr[HdrPos] ), sizeof( sTextureHdr ) );
createTextureRegionsHdr( Child, tTextureRegionsHdr );
if ( tTextureRegionsHdr.size() )
fs.write( reinterpret_cast<const char*>( &tTextureRegionsHdr[0] ),
sizeof( sTextureRegionHdr ) *
(std::streamsize)tTextureRegionsHdr.size() );
Child = Child->getChild();
HdrPos++;
}
}
}
@@ -770,13 +747,16 @@ void TexturePacker::createTextureRegionsHdr( TexturePacker* Packer,
if ( tTex->placed() ) {
std::string name = FileSystem::fileNameFromPath( tTex->name() );
if ( !mSaveExtensions )
name = FileSystem::fileRemoveExtension( name );
if ( name.size() > HDR_NAME_SIZE )
name.resize( HDR_NAME_SIZE );
memset( tTextureRegionHdr.Name, 0, HDR_NAME_SIZE );
String::strCopy( tTextureRegionHdr.Name, name.c_str(), HDR_NAME_SIZE );
if ( !mSaveExtensions )
name = FileSystem::fileRemoveExtension( name );
tTextureRegionHdr.ResourceID = String::hash( name );
tTextureRegionHdr.Width = tTex->width();
tTextureRegionHdr.Height = tTex->height();
@@ -833,7 +813,7 @@ void TexturePacker::childSave( const Image::SaveType& Format ) {
if ( NULL != LastParent ) {
std::string fFpath = FileSystem::fileRemoveExtension( LastParent->getFilepath() );
std::string fExt = FileSystem::fileExtension( LastParent->getFilepath() );
std::string fName = fFpath + "_ch" + String::toStr( ParentCount ) + "." + fExt;
std::string fName = fFpath + "-ch" + String::toStr( ParentCount ) + "." + fExt;
mChild->save( fName, Format, mSaveExtensions );
}

View File

@@ -27,7 +27,7 @@ std::string Time::toString() {
if ( asSeconds() < 1 ) {
return String::format( "%4.2fms", asMilliseconds() );
} else if ( totalSeconds < 60 ) {
return String::format( "%llus", totalSeconds );
return String::format( "%lus", static_cast<unsigned long>( totalSeconds ) );
}
long minutesLeft = totalSeconds / 60;

View File

@@ -8,6 +8,19 @@ using namespace EE::Window;
namespace EE { namespace UI { namespace CSS {
#define MediaOrientationStrings "portrait;landscape"
#define MediaFeatureStrings \
"none;width;min-width;max-width;height;min-height;max-height;device-width;min-device-" \
"width;max-device-width;device-height;min-device-height;max-device-height;orientation;" \
"aspect-ratio;min-aspect-ratio;max-aspect-ratio;device-aspect-ratio;min-device-aspect-" \
"ratio;max-device-aspect-ratio;color;min-color;max-color;color-index;min-color-index;max-" \
"color-index;monochrome;min-monochrome;max-monochrome;resolution;min-resolution;max-" \
"resolution"
#define MediaTypeStrings \
"none;all;screen;print;braille;embossed;handheld;projection;speech;tty;tv"
MediaQuery::MediaQuery() {
mMediaType = media_type_all;
mNot = false;
@@ -44,7 +57,7 @@ MediaQuery::ptr MediaQuery::parse( const std::string& str ) {
String::trimInPlace( exprTokens[0] );
expr.feature = (MediaFeature)String::valueIndex(
exprTokens[0], media_feature_strings, media_feature_none );
exprTokens[0], MediaFeatureStrings, media_feature_none );
if ( expr.feature != media_feature_none ) {
if ( exprTokens.size() == 1 ) {
@@ -54,7 +67,7 @@ MediaQuery::ptr MediaQuery::parse( const std::string& str ) {
expr.checkAsBool = false;
if ( expr.feature == media_feature_orientation ) {
expr.val = String::valueIndex( exprTokens[1], media_orientation_strings,
expr.val = String::valueIndex( exprTokens[1], MediaOrientationStrings,
media_orientation_landscape );
} else {
std::string::size_type slash_pos = exprTokens[1].find( '/' );
@@ -89,7 +102,7 @@ MediaQuery::ptr MediaQuery::parse( const std::string& str ) {
}
} else {
query->mMediaType =
(MediaType)String::valueIndex( tok, media_type_strings, media_type_all );
(MediaType)String::valueIndex( tok, MediaTypeStrings, media_type_all );
}
}

View File

@@ -95,10 +95,10 @@ void StyleSheetPropertyTransition::onUpdate( const Time& ) {
mDuration.asMilliseconds() );
if ( mProperty->getType() == PropertyType::NumberFloat ) {
node->applyProperty(
StyleSheetProperty( mProperty, String::fromFloat( value, "px" ) ) );
StyleSheetProperty( mProperty, String::fromFloat( value ) ) );
} else {
node->applyProperty( StyleSheetProperty(
mProperty, String::format( "%dpx", static_cast<int>( value ) ) ) );
mProperty, String::format( "%d", static_cast<int>( value ) ) ) );
}
break;
}

View File

@@ -50,8 +50,8 @@ bool StyleSheetSpecification::isShorthand( const std::string& name ) const {
void StyleSheetSpecification::registerDefaultProperties() {
registerProperty( "id", "", false ).setType( PropertyType::String );
registerProperty( "class", "", false ).setType( PropertyType::String );
registerProperty( "x", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "y", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "x", "", false ).setType( PropertyType::NumberLength );
registerProperty( "y", "", false ).setType( PropertyType::NumberLength );
registerProperty( "width", "", false )
.setType( PropertyType::NumberLength )
.setRelativeTarget( PropertyRelativeTarget::ContainingBlockWidth );
@@ -78,10 +78,10 @@ void StyleSheetSpecification::registerDefaultProperties() {
.setType( PropertyType::NumberLength );
registerProperty( "foreground-repeat", "no-repeat", false );
registerProperty( "foreground-size", "", false ).setType( PropertyType::ForegroundSize );
registerProperty( "foreground-radius", "0px", false ).setType( PropertyType::NumberInt );
registerProperty( "foreground-radius", "0px", false ).setType( PropertyType::NumberLength );
registerProperty( "border-color", "", false ).setType( PropertyType::Color );
registerProperty( "border-width", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "border-radius", "0px", false ).setType( PropertyType::NumberInt );
registerProperty( "border-width", "", false ).setType( PropertyType::NumberLength );
registerProperty( "border-radius", "0px", false ).setType( PropertyType::NumberLength );
registerProperty( "visible", "true", false ).setType( PropertyType::Bool );
registerProperty( "enabled", "true", false ).setType( PropertyType::Bool );
registerProperty( "theme", "", false );
@@ -166,14 +166,14 @@ void StyleSheetSpecification::registerDefaultProperties() {
.addAlias( "font-name" )
.setType( PropertyType::String );
registerProperty( "font-size", "", false )
.setType( PropertyType::NumberFloat )
.setType( PropertyType::NumberLength )
.addAlias( "text-size" )
.addAlias( "textsize" );
registerProperty( "font-style", "", false )
.addAlias( "text-style" )
.addAlias( "text-decoration" );
registerProperty( "text-stroke-width", "", false )
.setType( PropertyType::NumberFloat )
.setType( PropertyType::NumberLength )
.addAlias( "fontoutlinethickness" );
registerProperty( "text-stroke-color", "", false )
.setType( PropertyType::Color )
@@ -182,8 +182,8 @@ void StyleSheetSpecification::registerDefaultProperties() {
registerProperty( "text-align", "", false );
registerProperty( "icon", "", false );
registerProperty( "min-icon-size", "", false ).setType( PropertyType::Vector2 );
registerProperty( "icon-horizontal-margin", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "icon-auto-margin", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "icon-horizontal-margin", "", false ).setType( PropertyType::NumberLength );
registerProperty( "icon-auto-margin", "", false ).setType( PropertyType::NumberLength );
registerProperty( "src", "", false ).setType( PropertyType::String );
registerProperty( "scale-type", "", false );
registerProperty( "tint", "", false ).setType( PropertyType::Color );
@@ -195,15 +195,15 @@ void StyleSheetSpecification::registerDefaultProperties() {
registerProperty( "special-border-tabs", "", false ).setType( PropertyType::Bool );
registerProperty( "line-below-tabs", "", false ).setType( PropertyType::Bool );
registerProperty( "line-below-tabs-color", "", false ).setType( PropertyType::Color );
registerProperty( "line-below-tabs-y-offset", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "tab-separation", "", false ).setType( PropertyType::NumberInt );
registerProperty( "line-below-tabs-y-offset", "", false ).setType( PropertyType::NumberLength );
registerProperty( "tab-separation", "", false ).setType( PropertyType::NumberLength );
registerProperty( "selected", "", false ).setType( PropertyType::Bool ).addAlias( "active" );
registerProperty( "popup-to-main-control", "", false ).setType( PropertyType::Bool );
registerProperty( "max-visible-items", "", false ).setType( PropertyType::NumberInt );
registerProperty( "selected-index", "", false );
registerProperty( "selected-text", "", false );
registerProperty( "scrollbar-type", "", false );
registerProperty( "row-height", "", false ).setType( PropertyType::NumberInt );
registerProperty( "row-height", "", false ).setType( PropertyType::NumberLength );
registerProperty( "vscroll-mode", "", false );
registerProperty( "hscroll-mode", "", false );
@@ -222,21 +222,21 @@ void StyleSheetSpecification::registerDefaultProperties() {
registerProperty( "max-progress", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "progress", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "fill-color", "", false ).setType( PropertyType::Color );
registerProperty( "radius", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "outline-thickness", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "radius", "", false ).setType( PropertyType::NumberLength );
registerProperty( "outline-thickness", "", false ).setType( PropertyType::NumberLength );
registerProperty( "animation-speed", "", false ).setType( PropertyType::Vector2 );
registerProperty( "arc-start-angle", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "min-width", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "min-margin-right", "", false ).setType( PropertyType::NumberInt );
registerProperty( "min-icon-space", "", false ).setType( PropertyType::NumberInt );
registerProperty( "min-width", "", false ).setType( PropertyType::NumberLength );
registerProperty( "min-margin-right", "", false ).setType( PropertyType::NumberLength );
registerProperty( "min-icon-space", "", false ).setType( PropertyType::NumberLength );
registerProperty( "total-steps", "", false ).setType( PropertyType::NumberInt );
registerProperty( "vertical-expand", "", false ).setType( PropertyType::Bool );
registerProperty( "display-percent", "", false ).setType( PropertyType::Bool );
registerProperty( "filler-padding-left", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "filler-padding-top", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "filler-padding-right", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "filler-padding-bottom", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "filler-padding-left", "", false ).setType( PropertyType::NumberLength );
registerProperty( "filler-padding-top", "", false ).setType( PropertyType::NumberLength );
registerProperty( "filler-padding-right", "", false ).setType( PropertyType::NumberLength );
registerProperty( "filler-padding-bottom", "", false ).setType( PropertyType::NumberLength );
registerProperty( "movement-speed", "", false ).setType( PropertyType::Vector2 );
registerProperty( "min-value", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "max-value", "", false ).setType( PropertyType::NumberFloat );
@@ -257,20 +257,20 @@ void StyleSheetSpecification::registerDefaultProperties() {
registerProperty( "touch-drag-deceleration", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "base-alpha", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "buttons-position-offset", "", false ).setType( PropertyType::NumberInt );
registerProperty( "buttons-position-offset", "", false ).setType( PropertyType::NumberLength );
registerProperty( "window-flags", "", false ).addAlias( "winflags" );
registerProperty( "decoration-size", "", false ).setType( PropertyType::Vector2 );
registerProperty( "border-size", "", false ).setType( PropertyType::Vector2 );
registerProperty( "min-window-size", "", false ).setType( PropertyType::Vector2 );
registerProperty( "buttons-separation", "", false ).setType( PropertyType::NumberInt );
registerProperty( "buttons-separation", "", false ).setType( PropertyType::NumberLength );
registerProperty( "min-corner-distance", "", false );
registerProperty( "decoration-auto-size", "", false ).setType( PropertyType::Bool );
registerProperty( "border-auto-size", "", false ).setType( PropertyType::Bool );
registerProperty( "margin-between-buttons", "", false ).setType( PropertyType::NumberInt );
registerProperty( "button-margin", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "menu-height", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "first-button-margin-left", "", false ).setType( PropertyType::NumberInt );
registerProperty( "margin-between-buttons", "", false ).setType( PropertyType::NumberLength );
registerProperty( "button-margin", "", false ).setType( PropertyType::NumberLength );
registerProperty( "menu-height", "", false ).setType( PropertyType::NumberLength );
registerProperty( "first-button-margin-left", "", false ).setType( PropertyType::NumberLength );
registerProperty( "scale-origin-point", "", false ).setType( PropertyType::Vector2 );
@@ -279,10 +279,10 @@ void StyleSheetSpecification::registerDefaultProperties() {
registerProperty( "hint", "", false ).setType( PropertyType::String );
registerProperty( "hint-color", "", false ).setType( PropertyType::Color );
registerProperty( "hint-shadow-color", "", false ).setType( PropertyType::Color );
registerProperty( "hint-font-size", "", false ).setType( PropertyType::NumberFloat );
registerProperty( "hint-font-size", "", false ).setType( PropertyType::NumberLength );
registerProperty( "hint-font-style", "", false ).setType( PropertyType::String );
registerProperty( "hint-stroke-width", "", false )
.setType( PropertyType::NumberFloat )
.setType( PropertyType::NumberLength )
.addAlias( "hintoutlinethickness" );
registerProperty( "hint-stroke-color", "", false ).setType( PropertyType::Color );
registerProperty( "hint-font-family", "", false ).addAlias( "hint-font-name" );

View File

@@ -404,13 +404,13 @@ void UISceneNode::loadFontFaces( const StyleSheetStyleVector& styles ) {
mFontFaces.push_back( font );
} else if ( String::startsWith( path, "http://" ) ||
String::startsWith( path, "https://" ) ) {
FontTrueType* font =
FontTrueType::New( String::trim( familyProp.getValue(), '"' ) );
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
std::string familyName = familyProp.getValue();
Http::getAsync(
[&, font]( const Http&, Http::Request&, Http::Response& response ) {
[&, familyName]( const Http&, Http::Request&, Http::Response& response ) {
FontTrueType* font =
FontTrueType::New( String::trim( familyName , '"' ) );
if ( !response.getBody().empty() ) {
font->loadFromMemory( &response.getBody()[0],
response.getBody().size() );

View File

@@ -989,7 +989,7 @@ std::string UIWidget::getPropertyString( const PropertyDefinition* propertyDef )
case PropertyId::Scale:
return String::fromFloat( getScale().x ) + " " + String::fromFloat( getScale().y );
case PropertyId::Opacity:
return String::fromFloat( getAlpha() );
return String::fromFloat( getAlpha() / 255.f );
case PropertyId::Cursor:
return "arrow";
case PropertyId::Visible:

View File

@@ -1,6 +1,10 @@
#include <eepp/window/backend/SDL2/base.hpp>
#include <eepp/window/backend/SDL2/displaymanagersdl2.hpp>
#if EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN
#include <emscripten.h>
#endif
namespace EE { namespace Window { namespace Backend { namespace SDL2 {
DisplaySDL2::DisplaySDL2( int index ) : Display( index ) {}
@@ -17,12 +21,16 @@ Rect DisplaySDL2::getBounds() {
}
Float DisplaySDL2::getDPI() {
#if EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN
return 96.f * emscripten_get_device_pixel_ratio();
#else
#if SDL_VERSION_ATLEAST( 2, 0, 4 )
float ddpi, hdpi, vdpi;
if ( 0 == SDL_GetDisplayDPI( 0, &ddpi, &hdpi, &vdpi ) )
return ddpi;
#endif
return 92.f;
return 96.f;
#endif
}
const int& DisplaySDL2::getIndex() const {

View File

@@ -23,8 +23,8 @@
#endif
#if EE_PLATFORM == EE_PLATFORM_WIN
#include <objbase.h>
#include <initguid.h>
#include <objbase.h>
#include <shellapi.h>
#include <tlhelp32.h>
@@ -266,7 +266,8 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) {
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, mWindow.ContextConfig.Multisamples );
}
#if EE_PLATFORM != EE_PLATFORM_MACOSX && EE_PLATFORM != EE_PLATFORM_IOS
#if EE_PLATFORM != EE_PLATFORM_MACOSX && EE_PLATFORM != EE_PLATFORM_IOS && \
EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
mWindow.WindowConfig.Width *= mWindow.WindowConfig.PixelDensity;
mWindow.WindowConfig.Height *= mWindow.WindowConfig.PixelDensity;
#endif

View File

@@ -1,4 +1,20 @@
#include <eepp/ee.hpp>
#include <eepp/graphics/fonttruetype.hpp>
#include <eepp/maps/mapeditor/mapeditor.hpp>
#include <eepp/scene/scenemanager.hpp>
#include <eepp/ui/uimessagebox.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <eepp/ui/uitheme.hpp>
#include <eepp/ui/uithememanager.hpp>
#include <eepp/window/engine.hpp>
#include <eepp/window/window.hpp>
using namespace EE;
using namespace EE::Graphics;
using namespace EE::Maps;
using namespace EE::Scene;
using namespace EE::Window;
using namespace EE::UI;
using namespace EE::UI::Tools;
EE::Window::Window* win = NULL;
UIMessageBox* MsgBox = NULL;

View File

@@ -1,4 +1,19 @@
#include <eepp/ee.hpp>
#include <eepp/graphics/fonttruetype.hpp>
#include <eepp/scene/scenemanager.hpp>
#include <eepp/ui/tools/textureatlaseditor.hpp>
#include <eepp/ui/uimessagebox.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <eepp/ui/uitheme.hpp>
#include <eepp/ui/uithememanager.hpp>
#include <eepp/window/engine.hpp>
#include <eepp/window/window.hpp>
using namespace EE;
using namespace EE::Graphics;
using namespace EE::Scene;
using namespace EE::Window;
using namespace EE::UI;
using namespace EE::UI::Tools;
EE::Window::Window* win = NULL;
UIMessageBox* MsgBox = NULL;

View File

@@ -0,0 +1,173 @@
#include <args/args.hxx>
#include <eepp/graphics/textureatlasloader.hpp>
#include <eepp/graphics/texturepacker.hpp>
#include <eepp/system/filesystem.hpp>
#include <iostream>
#include <map>
using namespace EE;
using namespace EE::System;
using namespace EE::Graphics;
int main( int argc, char* argv[] ) {
args::ArgumentParser parser( "Texture Packer - eepp texture atlas creator." );
args::HelpFlag help( parser, "help", "Display this help menu", {'h', "help"} );
args::ValueFlag<std::string> texturesPath( parser, "textures-path", "Textures directory path.",
{'p', "textures-path"} );
args::ValueFlagList<std::string> images( parser, "image-path", "Input image path.",
{'i', "image-path"} );
args::ValueFlag<std::string> outputFile(
parser, "output-file", "Texture atlas file output path. Extension must be: \".eta\"",
{'o', "output-file"}, "", args::Options::Required | args::Options::Single );
std::unordered_map<std::string, Image::SaveType> saveTypeFormat{
{"PNG", Image::SaveType::SAVE_TYPE_PNG},
{"DDS", Image::SaveType::SAVE_TYPE_DDS},
{"TGA", Image::SaveType::SAVE_TYPE_TGA},
{"BMP", Image::SaveType::SAVE_TYPE_BMP},
{"JPG", Image::SaveType::SAVE_TYPE_JPG}};
args::MapFlag<std::string, Image::SaveType> saveType(
parser, "image-format", "Output image format.", {'f', "image-format"}, saveTypeFormat,
Image::SaveType::SAVE_TYPE_PNG, args::Options::Single );
std::unordered_map<std::string, PixelDensitySize> pixelDensityMap{
{"MDPI", PixelDensitySize::MDPI},
{"HDPI", PixelDensitySize::HDPI},
{"XHDPI", PixelDensitySize::XHDPI},
{"XXHDPI", PixelDensitySize::XXHDPI},
{"XXXHDPI", PixelDensitySize::XXXHDPI}};
args::MapFlag<std::string, PixelDensitySize> pixelDensity(
parser, "pixel-density",
"Source images pixel density size. Valid values are: MDPI (1dp = 1px), HDPI (1dp = 1.5px), "
"XHDPI (1dp = 2px), XXHDPI (1dp = 3px) and XXXHDPI (1dp = 4px).",
{'d', "pixel-density"}, pixelDensityMap, PixelDensitySize::MDPI, args::Options::Single );
args::Flag forcePow2( parser, "force-power-of-two-texture", "Force power of two texture.",
{"force-power-of-two"}, args::Options::Single );
args::Flag scalableSVG( parser, "scalable-svg",
"Scale SVG source files using the pixel-density provided.",
{"scalable-svg"}, args::Options::Single );
args::Flag saveExtensions( parser, "save-extensions",
"Save the file extensions as part of the texture regions names.",
{"save-extensions"} );
args::Flag allowChilds(
parser, "allow-childs",
"When enabled in the case of an atlas not having enough space in the image to fit all the "
"source input images it will create new child atlas images to save them.",
{"allow-childs"} );
args::ValueFlag<Uint32> height( parser, "max-width", "Texture Atlas maximum allowed height.",
{'h', "max-height"}, 4096, args::Options::Single );
args::ValueFlag<Uint32> width( parser, "max-width", "Texture Atlas maximum allowed width.",
{'w', "max-width"}, 4096, args::Options::Single );
args::ValueFlag<Uint32> pixelsBorder(
parser, "pixels-border",
"Number of pixels used as border of each image. The border is the separator between images "
"and it's recommended that at least there's a 2 pixel border (default value) to avoid "
"rendering problems.",
{'b', "pixels-border"}, 2, args::Options::Single );
args::Flag update( parser, "update", "Update texture atlas if output file already exists.",
{'u', "update"}, args::Options::Single );
std::unordered_map<std::string, Texture::TextureFilter> textureFilterMap{
{"linear", Texture::TextureFilter::Linear}, {"nearest", Texture::TextureFilter::Nearest}};
args::MapFlag<std::string, Texture::TextureFilter> textureFilter(
parser, "texture-filter",
"Texture filter to use with the texture atlas. Available filters: \"linear\" or "
"\"nearest\".",
{"texture-filter"}, textureFilterMap, Texture::TextureFilter::Linear,
args::Options::Single );
try {
parser.ParseCLI( argc, argv );
} catch ( const args::Help& ) {
std::cout << parser;
return EXIT_SUCCESS;
} catch ( const args::ParseError& e ) {
std::cerr << e.what() << std::endl;
std::cerr << parser;
return EXIT_FAILURE;
} catch ( args::ValidationError& e ) {
std::cerr << e.what() << std::endl;
std::cerr << parser;
return EXIT_FAILURE;
}
bool hasImages = false;
auto imagesPaths = args::get( images );
std::map<std::string, std::unique_ptr<Image>> imagesList;
if ( !imagesPaths.empty() ) {
for ( auto image : images ) {
if ( !Image::isImage( image ) ) {
std::cout << "Image: \"" << image << "\" is invalid." << std::endl
<< "Operation cancelled." << std::endl;
return EXIT_FAILURE;
}
if ( imagesList.find( image ) == imagesList.end() ) {
imagesList[image] = std::make_unique<Image>( image );
}
}
hasImages = true;
}
std::string texturesPathSafe( texturesPath.Get() );
FileSystem::dirPathAddSlashAtEnd( texturesPathSafe );
if ( !FileSystem::isDirectory( texturesPathSafe ) && !hasImages ) {
std::cout << "textures-path is invalid.";
return EXIT_FAILURE;
}
auto filesInPath = FileSystem::filesGetInPath( texturesPathSafe );
if ( !hasImages ) {
for ( auto& file : filesInPath ) {
if ( Image::isImage( texturesPathSafe + file ) ) {
hasImages = true;
break;
}
}
if ( !hasImages ) {
std::cout << "textures-path must contain at least one image.";
return EXIT_FAILURE;
}
}
if ( pixelsBorder.Get() > 32 ) {
std::cout << "pixels-border value invalid, try a smaller number." << std::endl;
return EXIT_FAILURE;
}
if ( FileSystem::fileExtension( outputFile.Get() ).empty() ||
FileSystem::fileExtension( outputFile.Get() ) != "eta" ) {
std::cout << "output-file must have an extension.";
return EXIT_FAILURE;
}
if ( !FileSystem::fileExists( outputFile.Get() ) ) {
TexturePacker tp( width.Get(), height.Get(), pixelDensity.Get(), forcePow2.Get(),
scalableSVG.Get(), pixelsBorder.Get(), textureFilter.Get(),
allowChilds.Get() );
std::cout << "Packing directory: " << texturesPathSafe << std::endl;
tp.addTexturesPath( texturesPathSafe );
for ( auto& image : imagesList ) {
tp.addImage( image.second.get(), image.first );
}
if ( tp.packTextures() <= 0 ) {
goto exit_error;
}
std::string outputTexturePath( FileSystem::fileRemoveExtension( outputFile.Get() ) + "." +
Image::saveTypeToExtension( saveType.Get() ) );
tp.save( outputTexturePath, saveType.Get(), saveExtensions.Get() );
std::cout << "Texture Atlas created." << std::endl;
} else if ( update.Get() ) {
TextureAtlasLoader tgl;
std::cout << "Texture Atlas is already present, updating it." << std::endl;
if ( !tgl.updateTextureAtlas( outputFile.Get(), texturesPathSafe,
Sizei( width, height ) ) ) {
goto exit_error;
}
std::cout << "Texture Atlas updated." << std::endl;
}
return EXIT_SUCCESS;
exit_error:
std::cout << "Texture Atlas creation failed.\nTry allowing bigger images modifying the "
"max-width and max-height, or try removing some images from the images "
"directory."
<< std::endl;
return EXIT_FAILURE;
}