Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Game Library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Onuralp SEZER
Game Library
Commits
d41d220b
Commit
d41d220b
authored
2 years ago
by
Joseph Walton-Rivers
Browse files
Options
Downloads
Patches
Plain Diff
start of asset management interfaces
parent
2cb7b057
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
demo/demo/main.cpp
+2
-0
2 additions, 0 deletions
demo/demo/main.cpp
include/fggl/assets/manager.hpp
+32
-1
32 additions, 1 deletion
include/fggl/assets/manager.hpp
include/fggl/assets/module.hpp
+51
-0
51 additions, 0 deletions
include/fggl/assets/module.hpp
with
85 additions
and
1 deletion
demo/demo/main.cpp
+
2
−
0
View file @
d41d220b
...
...
@@ -37,6 +37,7 @@
#include
"fggl/scenes/menu.hpp"
#include
"fggl/modules/manager.hpp"
#include
"fggl/assets/module.hpp"
#include
"GameScene.h"
#include
"rollball.hpp"
...
...
@@ -74,6 +75,7 @@ int main(int argc, const char* argv[]) {
moduleManager
.
use
<
fggl
::
audio
::
OpenAL
>
();
moduleManager
.
use
<
fggl
::
gfx
::
OpenGL4
>
();
moduleManager
.
use
<
fggl
::
display
::
GLFW
>
();
moduleManager
.
use
<
fggl
::
assets
::
AssetFolders
>
();
moduleManager
.
resolve
();
// create the application
...
...
This diff is collapsed.
Click to expand it.
include/fggl/assets/manager.hpp
+
32
−
1
View file @
d41d220b
...
...
@@ -20,6 +20,11 @@
#define FGGL_ASSETS_MANAGER_HPP
#include
<string_view>
#include
<map>
#include
<functional>
#include
<memory>
#include
"fggl/data/storage.hpp"
#include
"fggl/util/safety.hpp"
namespace
fggl
::
assets
{
...
...
@@ -27,11 +32,37 @@ namespace fggl::assets {
struct
AssetTag
{};
using
AssetType
=
util
::
OpaqueName
<
std
::
string_view
,
AssetTag
>
;
class
Manager
{
struct
AssetData
{
void
*
data
;
std
::
size_t
size
;
};
struct
AssetCallbacks
{
std
::
function
<
void
(
const
AssetType
&
,
AssetData
)
>
init
;
std
::
function
<
void
(
const
AssetType
&
,
AssetData
)
>
destroy
;
};
struct
Asset
{};
class
AssetManager
{
public:
constexpr
const
static
modules
::
ModuleService
service
=
modules
::
make_service
(
"fggl::assets::AssetModule"
);
using
AssetGUID
=
std
::
string
;
AssetManager
(
data
::
Storage
*
storage
)
:
m_storage
(
storage
)
{}
virtual
~
AssetManager
()
=
default
;
void
load
(
const
AssetType
&
,
const
AssetGUID
&
name
);
void
loadToTemp
(
const
AssetType
&
,
const
AssetGUID
&
name
);
void
unload
(
const
AssetGUID
&
name
);
private
:
data
::
Storage
*
m_storage
;
std
::
map
<
AssetGUID
,
std
::
shared_ptr
<
Asset
>>
m_registry
;
std
::
map
<
AssetType
,
AssetCallbacks
>
m_callbacks
;
};
}
// namespace fggl::assets
#endif //FGGL_ASSETS_MANAGER_HPP
This diff is collapsed.
Click to expand it.
include/fggl/assets/module.hpp
0 → 100644
+
51
−
0
View file @
d41d220b
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
//
// Created by webpigeon on 27/06/22.
//
#ifndef FGGL_ASSETS_MODULE_HPP
#define FGGL_ASSETS_MODULE_HPP
#include
"fggl/modules/module.hpp"
#include
"fggl/data/module.hpp"
#include
"fggl/assets/manager.hpp"
namespace
fggl
::
assets
{
struct
AssetFolders
{
constexpr
static
const
char
*
name
=
"fggl::assets::Folders"
;
constexpr
static
const
std
::
array
<
modules
::
ModuleService
,
1
>
provides
=
{
AssetManager
::
service
};
constexpr
static
const
std
::
array
<
modules
::
ModuleService
,
1
>
depends
=
{
data
::
Storage
::
service
};
static
const
modules
::
ServiceFactory
factory
;
};
bool
asset_factory
(
modules
::
ModuleService
service
,
modules
::
Services
&
services
)
{
if
(
service
==
AssetManager
::
service
)
{
auto
storage
=
services
.
get
<
data
::
Storage
>
();
services
.
create
<
AssetManager
>
(
storage
);
return
true
;
}
return
false
;
}
const
modules
::
ServiceFactory
AssetFolders
::
factory
=
asset_factory
;
}
// namespace fggl::assets
#endif //FGGL_ASSETS_MODULE_HPP
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment