Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VkCV Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vulkan2021
VkCV Framework
Commits
3c75a574
Commit
3c75a574
authored
3 years ago
by
Trevor Hollmann
Browse files
Options
Downloads
Patches
Plain Diff
[
#79
] Create new function specifically for texture loading.
parent
467e171e
No related branches found
No related tags found
1 merge request
!69
Resolve "Rework Asset Loader API"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/asset_loader/src/vkcv/asset/asset_loader.cpp
+27
-0
27 additions, 0 deletions
modules/asset_loader/src/vkcv/asset/asset_loader.cpp
with
27 additions
and
0 deletions
modules/asset_loader/src/vkcv/asset/asset_loader.cpp
+
27
−
0
View file @
3c75a574
...
...
@@ -76,6 +76,33 @@ enum IndexType getIndexType(const enum fx::gltf::Accessor::ComponentType &type)
}
}
int
loadTexture
(
const
Scene
&
scene
,
Texture
&
tex
)
{
if
(
tex
.
uri
<
0
||
tex
.
uri
>=
scene
.
uris
.
size
())
{
vkcv_log
(
LogLevel
::
ERROR
,
"URI index out of range: %d"
,
tex
.
uri
);
}
const
std
::
string
&
uri
=
scene
.
uris
[
tex
.
uri
];
int
w
,
h
,
ch
;
uint8_t
*
data
=
NULL
;
if
(
!
(
data
=
stbi_load
(
uri
.
c_str
(),
&
w
,
&
h
,
&
ch
,
4
)))
{
vkcv_log
(
LogLevel
::
ERROR
,
"Failed to load image data from %s"
,
uri
.
c_str
());
tex
.
w
=
tex
.
h
=
tex
.
channels
=
0
;
return
ASSET_ERROR
;
}
tex
.
channels
=
4
;
tex
.
w
=
static_cast
<
uint16_t
>
(
w
);
tex
.
h
=
static_cast
<
uint16_t
>
(
h
);
tex
.
data
.
resize
(
tex
.
w
*
tex
.
h
*
tex
.
channels
);
memcpy
(
tex
.
data
.
data
(),
data
,
tex
.
data
.
size
());
free
(
data
);
return
ASSET_SUCCESS
;
}
/**
* This function loads all the textures of a Scene described by the texture-
* and image- array of an fx::gltf::Document.
...
...
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