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
Game Development
Game Library
Commits
ebf1b235
Commit
ebf1b235
authored
2 years ago
by
Joseph Walton-Rivers
Browse files
Options
Downloads
Patches
Plain Diff
don't cache between scenes
parent
d8400bd7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fggl/gfx/ogl4/models.cpp
+10
-6
10 additions, 6 deletions
fggl/gfx/ogl4/models.cpp
include/fggl/gfx/ogl4/models.hpp
+1
-1
1 addition, 1 deletion
include/fggl/gfx/ogl4/models.hpp
with
11 additions
and
7 deletions
fggl/gfx/ogl4/models.cpp
+
10
−
6
View file @
ebf1b235
...
@@ -64,11 +64,11 @@ namespace fggl::gfx::ogl4 {
...
@@ -64,11 +64,11 @@ namespace fggl::gfx::ogl4 {
modelComp
.
drawType
=
ogl
::
Primative
::
TRIANGLE
;
modelComp
.
drawType
=
ogl
::
Primative
::
TRIANGLE
;
}
}
StaticModel
*
StaticModelRenderer
::
uploadMesh
(
assets
::
AssetGUID
guid
,
const
data
::
Mesh
&
mesh
)
{
StaticModel
*
StaticModelRenderer
::
uploadMesh
(
assets
::
AssetGUID
guid
,
const
data
::
Mesh
&
mesh
,
bool
allowCache
)
{
assert
(
m_assets
!=
nullptr
);
assert
(
m_assets
!=
nullptr
);
// if the asset has already been uploaded, we don't need to do anything
// if the asset has already been uploaded, we don't need to do anything
if
(
m_assets
->
has
(
guid
)
)
{
if
(
allowCache
&&
m_assets
->
has
(
guid
)
)
{
m_assets
->
require
(
guid
);
m_assets
->
require
(
guid
);
return
m_assets
->
get
<
StaticModel
>
(
guid
);
return
m_assets
->
get
<
StaticModel
>
(
guid
);
}
}
...
@@ -80,7 +80,11 @@ namespace fggl::gfx::ogl4 {
...
@@ -80,7 +80,11 @@ namespace fggl::gfx::ogl4 {
modelAsset
->
elements
=
setupIndexBuffer
(
modelAsset
->
vao
,
mesh
.
indexList
());
modelAsset
->
elements
=
setupIndexBuffer
(
modelAsset
->
vao
,
mesh
.
indexList
());
modelAsset
->
elementCount
=
mesh
.
indexCount
();
modelAsset
->
elementCount
=
mesh
.
indexCount
();
modelAsset
->
drawType
=
ogl
::
Primative
::
TRIANGLE
;
modelAsset
->
drawType
=
ogl
::
Primative
::
TRIANGLE
;
m_assets
->
set
(
guid
,
modelAsset
);
// if caching is enabled, then use the cache
if
(
allowCache
)
{
m_assets
->
set
(
guid
,
modelAsset
);
}
return
modelAsset
;
return
modelAsset
;
}
}
...
@@ -106,8 +110,8 @@ namespace fggl::gfx::ogl4 {
...
@@ -106,8 +110,8 @@ namespace fggl::gfx::ogl4 {
#ifdef FGGL_ALLOW_DEFERRED_UPLOAD
#ifdef FGGL_ALLOW_DEFERRED_UPLOAD
void
StaticModelRenderer
::
resolveModels
(
entity
::
EntityManager
&
world
)
{
void
StaticModelRenderer
::
resolveModels
(
entity
::
EntityManager
&
world
)
{
// FIXME: this needs something reactive or performance will suck.
// FIXME: this needs something reactive or performance will suck.
auto
renderables
=
world
.
find
<
data
::
StaticMesh
>
();
auto
renderable
Ent
s
=
world
.
find
<
data
::
StaticMesh
>
();
for
(
const
auto
&
renderable
:
renderables
)
{
for
(
const
auto
&
renderable
:
renderable
Ent
s
)
{
auto
*
currModel
=
world
.
tryGet
<
StaticModel
>
(
renderable
);
auto
*
currModel
=
world
.
tryGet
<
StaticModel
>
(
renderable
);
if
(
currModel
!=
nullptr
)
{
if
(
currModel
!=
nullptr
)
{
continue
;
continue
;
...
@@ -116,7 +120,7 @@ namespace fggl::gfx::ogl4 {
...
@@ -116,7 +120,7 @@ namespace fggl::gfx::ogl4 {
auto
&
meshComp
=
world
.
get
<
data
::
StaticMesh
>
(
renderable
);
auto
&
meshComp
=
world
.
get
<
data
::
StaticMesh
>
(
renderable
);
// model loading (should be via asset system)
// model loading (should be via asset system)
auto
loadedModel
=
uploadMesh
(
"DEFER_ENT_"
+
std
::
to_string
((
uint64_t
)
renderable
),
meshComp
.
mesh
);
auto
loadedModel
=
uploadMesh
(
"DEFER_ENT_"
+
std
::
to_string
((
uint64_t
)
renderable
),
meshComp
.
mesh
,
false
);
auto
loadedShader
=
m_shaders
->
get
(
meshComp
.
pipeline
);
auto
loadedShader
=
m_shaders
->
get
(
meshComp
.
pipeline
);
// splice the loaded asset into the ecs
// splice the loaded asset into the ecs
...
...
This diff is collapsed.
Click to expand it.
include/fggl/gfx/ogl4/models.hpp
+
1
−
1
View file @
ebf1b235
...
@@ -81,7 +81,7 @@ namespace fggl::gfx::ogl4 {
...
@@ -81,7 +81,7 @@ namespace fggl::gfx::ogl4 {
StaticModelRenderer
&
operator
=
(
const
StaticModelRenderer
&
other
)
=
delete
;
StaticModelRenderer
&
operator
=
(
const
StaticModelRenderer
&
other
)
=
delete
;
StaticModelRenderer
&
operator
=
(
StaticModelRenderer
&&
other
)
=
delete
;
StaticModelRenderer
&
operator
=
(
StaticModelRenderer
&&
other
)
=
delete
;
StaticModel
*
uploadMesh
(
assets
::
AssetGUID
guid
,
const
data
::
Mesh
&
mesh
);
StaticModel
*
uploadMesh
(
assets
::
AssetGUID
guid
,
const
data
::
Mesh
&
mesh
,
bool
allowCache
=
true
);
StaticModelGPU
*
uploadMesh2
(
const
assets
::
AssetGUID
&
meshName
,
const
data
::
Mesh
&
mesh
);
StaticModelGPU
*
uploadMesh2
(
const
assets
::
AssetGUID
&
meshName
,
const
data
::
Mesh
&
mesh
);
void
render
(
entity
::
EntityManager
&
world
)
{
void
render
(
entity
::
EntityManager
&
world
)
{
...
...
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