moving to a structure in visual representing the underlying APIs first and then layering on top the scene graph. Various other additions and fixes.

This commit is contained in:
Hartmut Seichter 2019-02-02 00:11:33 +01:00
parent 7037abbcb6
commit 40e8c43e01
15 changed files with 217 additions and 37 deletions

View file

@ -1,14 +1,16 @@
set(hdrs
include/pw/system/window.hpp
include/pw/system/input.hpp
include/pw/system/display.hpp
include/pw/system/input.hpp
include/pw/system/path.hpp
include/pw/system/window.hpp
)
set(srcs
src/display.cpp
src/window.cpp
src/path.cpp
src/input.cpp
src/window.cpp
)
add_library(pwsystem

View file

@ -0,0 +1,38 @@
#ifndef PW_SYSTEM_PATH_HPP
#define PW_SYSTEM_PATH_HPP
#include <pw/core/globals.hpp>
namespace pw {
class path {
public:
static path& get();
~path();
std::string separator();
std::string executable_path();
typedef std::vector<std::string> path_list;
protected:
path_list _plugin_paths;
path_list _resource_paths;
path();
struct impl;
std::unique_ptr<impl> _impl;
};
}
#endif

94
src/system/src/path.cpp Normal file
View file

@ -0,0 +1,94 @@
#include "pw/system/path.hpp"
#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
#include <direct.h>
#elif defined(__APPLE__)
#include <CoreFoundation/CoreFoundation.h>
#include <unistd.h>
#if defined(__MACH__)
#include <mach/mach.h>
#endif
// #include "_host/helpers_osx.h"
#elif defined(TP_HAVE_UNISTD_H)
#include <unistd.h>
#else
// Unknown platform
#endif
namespace pw {
struct path::impl {
path &host;
impl(path &host_) : host(host_) {}
};
//
//
//
path &path::get()
{
static path instance;
return instance;
}
path::~path()
{
}
std::string path::separator()
{
#if defined(WIN32)
return std::string("\");
#else
return std::string("/");
#endif
}
std::string path::executable_path()
{
std::string result;
const unsigned int MAXPATHLEN = 2048;
static char path[MAXPATHLEN];
memset(&path[0],0,MAXPATHLEN);
#if defined(__APPLE__)
CFURLRef bundleURL;
CFStringRef pathStr;
CFBundleRef mainBundle = CFBundleGetMainBundle();
bundleURL = CFBundleCopyExecutableURL(mainBundle);
pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
CFStringGetCString(pathStr, path, MAXPATHLEN, kCFStringEncodingASCII);
result.assign(&path[0]);
CFRelease(pathStr);
CFRelease(bundleURL);
#elif defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
static TCHAR lpFname[MAXPATHLEN];
DWORD ret = GetModuleFileName( NULL, &lpFname[0], MAXPATHLEN );
result.assign(&lpFname[0]);
#else
readlink("/proc/self/exe", path, sizeof(path));
result.assign(path);
#endif
return result;
}
path::path()
{
_impl = std::make_unique<impl>(*this);
}
}