mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Added premake4.lua file, to create projects more easily, still WIP.
Cleaned up a little bit the MemoryManager, i'm looking how to make it work when eepp is compiled as a shared library.
This commit is contained in:
@@ -346,15 +346,9 @@ class EE_API cWindow {
|
||||
cTimeElapsed * FrameElapsed;
|
||||
eeFloat ElapsedTime;
|
||||
|
||||
cFrameData() :
|
||||
FrameElapsed(NULL),
|
||||
ElapsedTime(0)
|
||||
{}
|
||||
cFrameData();
|
||||
|
||||
~cFrameData()
|
||||
{
|
||||
eeSAFE_DELETE( FrameElapsed );
|
||||
}
|
||||
~cFrameData();
|
||||
};
|
||||
|
||||
cFrameData mFrameData;
|
||||
|
||||
331
premake4.lua
Normal file
331
premake4.lua
Normal file
@@ -0,0 +1,331 @@
|
||||
function args_contains( element )
|
||||
for _, value in pairs(_ARGS) do
|
||||
if value == element then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function print_table( table_ref )
|
||||
for _, value in pairs( table_ref ) do
|
||||
print(value)
|
||||
end
|
||||
end
|
||||
|
||||
function multiple_insert( parent_table, insert_table )
|
||||
for _, value in pairs( insert_table ) do
|
||||
table.insert( parent_table, value )
|
||||
end
|
||||
end
|
||||
|
||||
solution "eepp"
|
||||
location("./make/" .. os.get() .. "/")
|
||||
targetdir("./")
|
||||
configurations { "debug", "release" }
|
||||
objdir("obj/" .. os.get() .. "/premake4/")
|
||||
|
||||
link_list = { }
|
||||
os_links = { }
|
||||
|
||||
if os.is("linux") then
|
||||
multiple_insert( os_links, { "rt", "pthread", "X11", "openal", "GL", "Xcursor" } )
|
||||
elseif os.is("windows") then
|
||||
multiple_insert( os_links, { "OpenAL32", "opengl32", "mingw32", "glu32", "gdi32", "-static-libgcc -static-libstdc++ -mwindows" } )
|
||||
elseif os.is("macosx") then
|
||||
multiple_insert( os_links, { "-framework OpenGL -framework OpenAL -framework CoreFoundation -framework AGL" } )
|
||||
elseif os.is("freebsd") then
|
||||
multiple_insert( os_links, { "rt", "pthread", "X11", "openal", "GL", "Xcursor" } )
|
||||
elseif os.is("haiku") then
|
||||
multiple_insert( os_links, { "openal", "GL" } )
|
||||
end
|
||||
|
||||
if args_contains( "GLES2" ) then
|
||||
defines { "EE_GLES2", "SOIL_GLES2" }
|
||||
end
|
||||
|
||||
if args_contains( "GLES1" ) then
|
||||
defines { "EE_GLES1", "SOIL_GLES1" }
|
||||
end
|
||||
|
||||
if not args_contains( "STATIC_FT2" ) then
|
||||
table.insert( link_list, "freetype" )
|
||||
end
|
||||
|
||||
project "SOIL2-static"
|
||||
kind "StaticLib"
|
||||
language "C"
|
||||
targetdir("libs/" .. os.get() .. "/helpers/")
|
||||
files { "src/eepp/helper/SOIL2/src/SOIL2/*.c" }
|
||||
includedirs { "include/eepp/helper/SOIL2" }
|
||||
|
||||
configuration "debug"
|
||||
defines { "DEBUG" }
|
||||
flags { "Symbols" }
|
||||
buildoptions{ "-Wall" }
|
||||
targetname "SOIL2-debug"
|
||||
|
||||
configuration "release"
|
||||
defines { "NDEBUG" }
|
||||
flags { "Optimize" }
|
||||
buildoptions{ "-Wall" }
|
||||
targetname "SOIL2"
|
||||
|
||||
project "glew-static"
|
||||
kind "StaticLib"
|
||||
language "C"
|
||||
targetdir("libs/" .. os.get() .. "/helpers/")
|
||||
files { "src/eepp/helper/glew/*.c" }
|
||||
includedirs { "include/eepp/helper/glew" }
|
||||
|
||||
configuration "debug"
|
||||
defines { "DEBUG" }
|
||||
flags { "Symbols" }
|
||||
buildoptions{ "-Wall" }
|
||||
targetname "glew-debug"
|
||||
|
||||
configuration "release"
|
||||
defines { "NDEBUG" }
|
||||
flags { "Optimize" }
|
||||
buildoptions{ "-Wall" }
|
||||
targetname "glew"
|
||||
|
||||
project "zlib-static"
|
||||
kind "StaticLib"
|
||||
language "C"
|
||||
targetdir("libs/" .. os.get() .. "/helpers/")
|
||||
files { "src/eepp/helper/zlib/*.c" }
|
||||
|
||||
configuration "debug"
|
||||
defines { "DEBUG" }
|
||||
flags { "Symbols" }
|
||||
buildoptions{ "-Wall" }
|
||||
targetname "zlib-debug"
|
||||
|
||||
configuration "release"
|
||||
defines { "NDEBUG" }
|
||||
flags { "Optimize" }
|
||||
buildoptions{ "-Wall" }
|
||||
targetname "zlib"
|
||||
|
||||
project "libzip-static"
|
||||
kind "StaticLib"
|
||||
language "C"
|
||||
targetdir("libs/" .. os.get() .. "/helpers/")
|
||||
files { "src/eepp/helper/libzip/*.c" }
|
||||
includedirs { "src/eepp/helper/zlib" }
|
||||
|
||||
configuration "debug"
|
||||
defines { "DEBUG" }
|
||||
flags { "Symbols" }
|
||||
buildoptions{ "-Wall" }
|
||||
targetname "libzip-debug"
|
||||
|
||||
configuration "release"
|
||||
defines { "NDEBUG" }
|
||||
flags { "Optimize" }
|
||||
buildoptions{ "-Wall" }
|
||||
targetname "libzip"
|
||||
|
||||
project "stb_vorbis-static"
|
||||
kind "StaticLib"
|
||||
language "C"
|
||||
targetdir("libs/" .. os.get() .. "/helpers/")
|
||||
files { "src/eepp/helper/stb_vorbis/*.c" }
|
||||
|
||||
configuration "debug"
|
||||
defines { "DEBUG" }
|
||||
flags { "Symbols" }
|
||||
buildoptions{ "-Wall" }
|
||||
targetname "stb_vorbis-debug"
|
||||
|
||||
configuration "release"
|
||||
defines { "NDEBUG" }
|
||||
flags { "Optimize" }
|
||||
buildoptions{ "-Wall" }
|
||||
targetname "stb_vorbis"
|
||||
|
||||
project "chipmunk-static"
|
||||
kind "StaticLib"
|
||||
language "C"
|
||||
targetdir("libs/" .. os.get() .. "/helpers/")
|
||||
files { "src/eepp/helper/chipmunk/*.c", "src/eepp/helper/chipmunk/constraints/*.c" }
|
||||
includedirs { "include/eepp/helper/chipmunk" }
|
||||
|
||||
configuration "debug"
|
||||
defines { "DEBUG" }
|
||||
flags { "Symbols" }
|
||||
buildoptions{ "-Wall", "-std=gnu99" }
|
||||
targetname "chipmunk-debug"
|
||||
|
||||
configuration "release"
|
||||
defines { "NDEBUG" }
|
||||
flags { "Optimize" }
|
||||
buildoptions{ "-Wall", "-std=gnu99" }
|
||||
targetname "chipmunk"
|
||||
|
||||
project "haikuttf-static"
|
||||
kind "StaticLib"
|
||||
language "C++"
|
||||
targetdir("libs/" .. os.get() .. "/helpers/")
|
||||
files { "src/eepp/helper/haikuttf/*.cpp" }
|
||||
includedirs { "src/eepp/helper/freetype2/include" }
|
||||
|
||||
configuration "debug"
|
||||
defines { "DEBUG" }
|
||||
flags { "Symbols" }
|
||||
buildoptions{ "-Wall" }
|
||||
targetname "haikuttf-debug"
|
||||
|
||||
configuration "release"
|
||||
defines { "NDEBUG" }
|
||||
flags { "Optimize" }
|
||||
buildoptions{ "-Wall" }
|
||||
targetname "haikuttf"
|
||||
|
||||
project "eepp-shared"
|
||||
kind "SharedLib"
|
||||
language "C++"
|
||||
targetdir("libs/" .. os.get() .. "/")
|
||||
includedirs { "include", "src", "src/eepp/helper/freetype2/include" }
|
||||
links { "SOIL2-static",
|
||||
"chipmunk-static",
|
||||
"glew-static",
|
||||
"haikuttf-static",
|
||||
"zlib-static",
|
||||
"libzip-static",
|
||||
"stb_vorbis-static"
|
||||
}
|
||||
|
||||
if os.is("windows") then
|
||||
files { "src/eepp/system/platform/win/*.cpp" }
|
||||
else
|
||||
files { "src/eepp/system/platform/posix/*.cpp" }
|
||||
end
|
||||
|
||||
files { "src/eepp/base/*.cpp",
|
||||
"src/eepp/math/*.cpp",
|
||||
"src/eepp/system/*.cpp",
|
||||
"src/eepp/audio/*.cpp",
|
||||
"src/eepp/graphics/*.cpp",
|
||||
"src/eepp/graphics/renderer/*.cpp",
|
||||
"src/eepp/window/*.cpp",
|
||||
"src/eepp/window/platform/null/*.cpp",
|
||||
"src/eepp/ui/*.cpp",
|
||||
"src/eepp/ui/tools/*.cpp",
|
||||
"src/eepp/physics/*.cpp",
|
||||
"src/eepp/physics/constraints/*.cpp",
|
||||
"src/eepp/gaming/*.cpp",
|
||||
"src/eepp/gaming/mapeditor/*.cpp"
|
||||
}
|
||||
|
||||
if args_contains( "SDL2" ) then
|
||||
table.insert( link_list, "SDL2" )
|
||||
files { "src/eepp/window/backend/SDL2/*.cpp" }
|
||||
defines { "EE_BACKEND_SDL_ACTIVE", "EE_SDL_VERSION_2" }
|
||||
elseif args_contains( "SDL" ) then
|
||||
table.insert( link_list, "SDL" )
|
||||
files { "src/eepp/window/backend/SDL/*.cpp" }
|
||||
defines { "EE_BACKEND_SDL_ACTIVE", "EE_SDL_VERSION_1_2" }
|
||||
end
|
||||
|
||||
if args_contains( "allegro5" ) then
|
||||
table.insert( link_list, "allegro5" )
|
||||
files { "src/eepp/window/backend/allegro5/*.cpp" }
|
||||
defines { "EE_BACKEND_ALLEGRO_ACTIVE" }
|
||||
end
|
||||
|
||||
if args_contains( "SFML" ) then
|
||||
table.insert( link_list, "SFML" )
|
||||
files { "src/eepp/window/backend/SFML/*.cpp" }
|
||||
defines { "EE_BACKEND_SFML_ACTIVE" }
|
||||
end
|
||||
|
||||
if next(link_list) == nil then
|
||||
table.insert( link_list, "SDL" )
|
||||
files { "src/eepp/window/backend/SDL/*.cpp" }
|
||||
defines { "EE_BACKEND_SDL_ACTIVE", "EE_SDL_VERSION_1_2" }
|
||||
end
|
||||
|
||||
multiple_insert( link_list, os_links )
|
||||
|
||||
configuration "windows"
|
||||
files { "src/eepp/window/platform/win/*.cpp" }
|
||||
|
||||
configuration "linux"
|
||||
files { "src/eepp/window/platform/x11/*.cpp" }
|
||||
|
||||
configuration "macosx"
|
||||
files { "src/eepp/window/platform/osx/*.cpp" }
|
||||
|
||||
configuration "debug"
|
||||
defines { "DEBUG", "EE_DEBUG", "EE_MEMORY_MANAGER", "EE_DYNAMIC", "EE_EXPORTS" }
|
||||
flags { "Symbols" }
|
||||
buildoptions{ "-Wall -Wno-long-long" }
|
||||
targetname "eepp-debug"
|
||||
|
||||
configuration "release"
|
||||
defines { "NDEBUG", "EE_DYNAMIC", "EE_EXPORTS" }
|
||||
flags { "Optimize" }
|
||||
buildoptions { "-fno-strict-aliasing -O3 -s -ffast-math" }
|
||||
targetname "eepp"
|
||||
|
||||
project "eepp-test"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
links { link_list, "eepp-shared" }
|
||||
|
||||
files { "src/test/*.cpp" }
|
||||
includedirs { "include", "src" }
|
||||
|
||||
configuration "debug"
|
||||
defines { "DEBUG" }
|
||||
flags { "Symbols" }
|
||||
buildoptions{ "-Wall -Wno-long-long" }
|
||||
targetname "eetest-debug"
|
||||
|
||||
configuration "release"
|
||||
defines { "NDEBUG" }
|
||||
flags { "Optimize" }
|
||||
buildoptions { "-fno-strict-aliasing -O3 -s -ffast-math" }
|
||||
targetname "eetest-release"
|
||||
|
||||
project "eepp-es"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
links { link_list, "eepp-shared" }
|
||||
|
||||
files { "src/examples/external_shader/*.cpp" }
|
||||
includedirs { "include", "src" }
|
||||
|
||||
configuration "debug"
|
||||
defines { "DEBUG" }
|
||||
flags { "Symbols" }
|
||||
buildoptions{ "-Wall -Wno-long-long" }
|
||||
targetname "eees-debug"
|
||||
|
||||
configuration "release"
|
||||
defines { "NDEBUG" }
|
||||
flags { "Optimize" }
|
||||
buildoptions { "-fno-strict-aliasing -O3 -s -ffast-math" }
|
||||
targetname "eees-release"
|
||||
|
||||
project "eepp-ew"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
links { link_list, "eepp-shared" }
|
||||
|
||||
files { "src/examples/empty_window/*.cpp" }
|
||||
includedirs { "include", "src" }
|
||||
|
||||
configuration "debug"
|
||||
defines { "DEBUG" }
|
||||
flags { "Symbols" }
|
||||
buildoptions{ "-Wall -Wno-long-long" }
|
||||
targetname "eeew-debug"
|
||||
|
||||
configuration "release"
|
||||
defines { "NDEBUG" }
|
||||
flags { "Optimize" }
|
||||
buildoptions { "-fno-strict-aliasing -O3 -s -ffast-math" }
|
||||
targetname "eeew-release"
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by Qt Creator 2.6.0, 2012-12-02T00:39:53. -->
|
||||
<!-- Written by Qt Creator 2.6.0, 2012-12-02T03:04:02. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
@@ -48,9 +48,9 @@
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||
<value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">{388e5431-b31b-42b3-b9ad-9002d279d75d}</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">11</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">4</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="GenericProjectManager.GenericBuildConfiguration.BuildDirectory">/home/programming/eepp</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
|
||||
@@ -3,37 +3,12 @@
|
||||
#include <eepp/base/memorymanager.hpp>
|
||||
#include <eepp/base/debug.hpp>
|
||||
#include <eepp/system/clog.hpp>
|
||||
#include <eepp/system/filesystem.hpp>
|
||||
|
||||
using namespace EE::System;
|
||||
|
||||
namespace EE {
|
||||
|
||||
#ifdef EE_MEMORY_MANAGER
|
||||
static std::string SizeToString( const unsigned int& MemSize ) {
|
||||
std::string size = " bytes";
|
||||
double mem = static_cast<double>( MemSize );
|
||||
unsigned int c = 0;
|
||||
|
||||
while ( mem > 1024 ) {
|
||||
c++;
|
||||
mem = mem / 1024;
|
||||
}
|
||||
|
||||
switch (c) {
|
||||
case 0: size = " bytes"; break;
|
||||
case 1: size = " KB"; break;
|
||||
case 2: size = " MB"; break;
|
||||
case 3: size = " GB"; break;
|
||||
case 4: size = " TB"; break;
|
||||
default: size = " WTF";
|
||||
}
|
||||
|
||||
std::ostringstream ss;
|
||||
ss << mem;
|
||||
|
||||
return std::string( ss.str() + size );
|
||||
}
|
||||
#endif
|
||||
|
||||
tAllocatedPointerMap MemoryManager::mMapPointers;
|
||||
size_t MemoryManager::mTotalMemoryUsage = 0;
|
||||
size_t MemoryManager::mPeakMemoryUsage = 0;
|
||||
@@ -142,10 +117,10 @@ void MemoryManager::LogResults() {
|
||||
}
|
||||
|
||||
eePRINT( "|\n" );
|
||||
eePRINT( "| Memory left: %s\n", SizeToString( mTotalMemoryUsage ).c_str() );
|
||||
eePRINT( "| Memory left: %s\n", FileSystem::SizeToString( mTotalMemoryUsage ).c_str() );
|
||||
eePRINT( "| Biggest allocation:\n" );
|
||||
eePRINT( "| %s in file: %s at line: %d\n", SizeToString( mBiggestAllocation.mMemory ).c_str(), mBiggestAllocation.mFile.c_str(), mBiggestAllocation.mLine );
|
||||
eePRINT( "| Peak Memory Usage: %s\n", SizeToString( mPeakMemoryUsage ).c_str() );
|
||||
eePRINT( "| %s in file: %s at line: %d\n", FileSystem::SizeToString( mBiggestAllocation.mMemory ).c_str(), mBiggestAllocation.mFile.c_str(), mBiggestAllocation.mLine );
|
||||
eePRINT( "| Peak Memory Usage: %s\n", FileSystem::SizeToString( mPeakMemoryUsage ).c_str() );
|
||||
eePRINT( "|------------------------------------------------------------|\n\n" );
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,16 @@
|
||||
|
||||
namespace EE { namespace Window {
|
||||
|
||||
cWindow::cFrameData::cFrameData() :
|
||||
FrameElapsed(NULL),
|
||||
ElapsedTime(0)
|
||||
{}
|
||||
|
||||
cWindow::cFrameData::~cFrameData()
|
||||
{
|
||||
eeSAFE_DELETE( FrameElapsed );
|
||||
}
|
||||
|
||||
cWindow::cWindow( WindowSettings Settings, ContextSettings Context, cClipboard * Clipboard, cInput * Input, cCursorManager * CursorManager ) :
|
||||
mClipboard( Clipboard ),
|
||||
mInput( Input ),
|
||||
|
||||
Reference in New Issue
Block a user