+ Use qt6_add_big_resources to improve build time + RM::getPath(sting) to build absolute path to assets + Allows easy access to models or other large assets not loaded into QRCpull/12/head
parent
82b06c247d
commit
c15d064dce
@ -0,0 +1,13 @@
|
||||
/*##############################################################################
|
||||
## Author: Shaun Reed ##
|
||||
## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
|
||||
## About: Manage files and resources used by qtk ##
|
||||
## ##
|
||||
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||
##############################################################################*/
|
||||
|
||||
#include "resourcemanager.h"
|
||||
|
||||
std::string RM::resourcesDir =
|
||||
std::string(__FILE__).substr(0, std::string(__FILE__).find("src/"))
|
||||
+ "resources/";
|
@ -0,0 +1,35 @@
|
||||
/*##############################################################################
|
||||
## Author: Shaun Reed ##
|
||||
## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
|
||||
## About: Manage files and resources used by qtk ##
|
||||
## ##
|
||||
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||
##############################################################################*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifndef QTK_RESOURCEMANAGER_H
|
||||
#define QTK_RESOURCEMANAGER_H
|
||||
|
||||
typedef class ResourceManager {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Takes a path using qrc format and constructs full system path to qtk assets
|
||||
* Qrc format prefix ':/' is trimmed from the path for the caller
|
||||
* Assets used with RM may (or may not) appear in qtk/resources.qrc
|
||||
*
|
||||
* @param path Path relative to qtk/resources/; ie) ':/models/backpack/backpack.obj'
|
||||
* An asset at location qtk/resources/path/to/asset.obj
|
||||
* Should be given in qrc format: ':/path/to/asset.obj'
|
||||
* @return Absoulte system path to a qtk asset
|
||||
*/
|
||||
static std::string getPath(const std::string & path) {
|
||||
// Only construct qtk resource path if in qrc format; else return it as-is
|
||||
return path[0] == ':' ? resourcesDir + path.substr(2) : path;
|
||||
}
|
||||
|
||||
static std::string resourcesDir;
|
||||
} RM;
|
||||
|
||||
#endif //QTK_RESOURCEMANAGER_H
|
Loading…
Reference in new issue