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
2451dd7d
Commit
2451dd7d
authored
3 years ago
by
Trevor Hollmann
Browse files
Options
Downloads
Patches
Plain Diff
[
#26
] Implement hack to load texture.
parent
81b1136f
No related branches found
No related tags found
1 merge request
!19
Resolve "Asset Loading"
Pipeline
#25184
failed
3 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/asset_loader/include/vkcv/asset/asset_loader.hpp
+2
-1
2 additions, 1 deletion
modules/asset_loader/include/vkcv/asset/asset_loader.hpp
modules/asset_loader/src/vkcv/asset/asset_loader.cpp
+17
-8
17 additions, 8 deletions
modules/asset_loader/src/vkcv/asset/asset_loader.cpp
with
19 additions
and
9 deletions
modules/asset_loader/include/vkcv/asset/asset_loader.hpp
+
2
−
1
View file @
2451dd7d
...
@@ -96,9 +96,10 @@ typedef struct {
...
@@ -96,9 +96,10 @@ typedef struct {
std
::
vector
<
VertexGroup
>
vertexGroups
;
std
::
vector
<
VertexGroup
>
vertexGroups
;
std
::
vector
<
Material
>
materials
;
std
::
vector
<
Material
>
materials
;
// FIXME Dirty hack to get one(!) texture for our cube demo
// FIXME Dirty hack to get one(!) texture for our cube demo
// hardcoded to always have RGBA channel layout
struct
{
struct
{
int
w
,
h
,
ch
;
// width, height and channels of image
int
w
,
h
,
ch
;
// width, height and channels of image
void
*
img
;
// raw
data
, free after use (deal with it)
uint8_t
*
img
;
// raw
bytes
, free after use (deal with it)
}
texture_hack
;
}
texture_hack
;
}
Mesh
;
}
Mesh
;
...
...
This diff is collapsed.
Click to expand it.
modules/asset_loader/src/vkcv/asset/asset_loader.cpp
+
17
−
8
View file @
2451dd7d
...
@@ -3,6 +3,9 @@
...
@@ -3,6 +3,9 @@
#include
<string.h>
// memcpy(3)
#include
<string.h>
// memcpy(3)
#include
<stdlib.h>
// calloc(3)
#include
<stdlib.h>
// calloc(3)
#include
<fx/gltf.h>
#include
<fx/gltf.h>
#define STB_IMAGE_IMPLEMENTATION
#define STBI_ONLY_JPEG
#include
<stb_image.h>
namespace
vkcv
::
asset
{
namespace
vkcv
::
asset
{
...
@@ -170,24 +173,30 @@ int loadMesh(const std::string &path, Mesh &mesh) {
...
@@ -170,24 +173,30 @@ int loadMesh(const std::string &path, Mesh &mesh) {
std
::
vector
<
Material
>
materials
;
std
::
vector
<
Material
>
materials
;
mesh
=
{
object
.
meshes
[
0
].
name
,
vertexGroups
,
materials
,
0
,
0
,
0
,
NULL
};
// FIXME HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
// FIXME HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
// fail quietly if there is no texture
// fail quietly if there is no texture
if
(
object
.
textures
.
size
())
{
if
(
object
.
textures
.
size
())
{
const
std
::
string
mime_type
(
"image/jpeg"
);
const
std
::
string
mime_type
(
"image/jpeg"
);
const
fx
::
gltf
::
Texture
&
tex
=
object
.
textures
[
0
];
const
fx
::
gltf
::
Texture
&
tex
=
object
.
textures
[
0
];
const
fx
::
gltf
::
Image
&
img
=
object
.
images
[
tex
.
source
];
const
fx
::
gltf
::
Image
&
img
=
object
.
images
[
tex
.
source
];
#ifdef DEBUG
printf
(
"texture name=%s sampler=%u source=%u
\n
"
,
printf
(
"texture name=%s sampler=%u source=%u
\n
"
,
tex
.
name
.
c_str
(),
tex
.
sampler
,
tex
.
source
);
tex
.
name
.
c_str
(),
tex
.
sampler
,
tex
.
source
);
printf
(
"image name=%s uri=%s mime=%s
\n
"
,
printf
(
"image name=%s uri=%s mime=%s
\n
"
,
img
.
name
.
c_str
(),
img
.
name
.
c_str
(),
img
.
uri
.
c_str
()
,
img
.
uri
.
c_str
(),
img
.
mimeType
.
c_str
()
);
img
.
mimeType
.
c_str
());
#endif
// URI is in img.uri
mesh
.
texture_hack
.
img
=
stbi_load
(
img
.
uri
.
c_str
(),
&
mesh
.
texture_hack
.
w
,
&
mesh
.
texture_hack
.
h
,
// TODO decode using stbimage lib and store in mesh.texture
&
mesh
.
texture_hack
.
ch
,
4
);
}
}
// FIXME HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
// FIXME HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
mesh
=
{
object
.
meshes
[
0
].
name
,
vertexGroups
,
materials
};
return
1
;
return
1
;
}
}
...
...
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