Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Clark Lin
hw3d
Commits
054d8661
Commit
054d8661
authored
Jul 27, 2019
by
chili
Browse files
loading specular maps
parent
fc18dc8b
Changes
3
Show whitespace changes
Inline
Side-by-side
hw3d/Mesh.cpp
View file @
054d8661
...
@@ -272,11 +272,18 @@ std::unique_ptr<Mesh> Model::ParseMesh( Graphics& gfx,const aiMesh& mesh,const a
...
@@ -272,11 +272,18 @@ std::unique_ptr<Mesh> Model::ParseMesh( Graphics& gfx,const aiMesh& mesh,const a
if
(
mesh
.
mMaterialIndex
>=
0
)
if
(
mesh
.
mMaterialIndex
>=
0
)
{
{
using
namespace
std
::
string_literals
;
auto
&
material
=
*
pMaterials
[
mesh
.
mMaterialIndex
];
auto
&
material
=
*
pMaterials
[
mesh
.
mMaterialIndex
];
using
namespace
std
::
string_literals
;
const
auto
base
=
"Models
\\
nano_textured
\\
"
s
;
aiString
texFileName
;
aiString
texFileName
;
material
.
GetTexture
(
aiTextureType_DIFFUSE
,
0
,
&
texFileName
);
material
.
GetTexture
(
aiTextureType_DIFFUSE
,
0
,
&
texFileName
);
bindablePtrs
.
push_back
(
std
::
make_unique
<
Bind
::
Texture
>
(
gfx
,
Surface
::
FromFile
(
"Models
\\
nano_textured
\\
"
s
+
texFileName
.
C_Str
()
)
)
);
bindablePtrs
.
push_back
(
std
::
make_unique
<
Bind
::
Texture
>
(
gfx
,
Surface
::
FromFile
(
base
+
texFileName
.
C_Str
()
)
)
);
material
.
GetTexture
(
aiTextureType_SPECULAR
,
0
,
&
texFileName
);
bindablePtrs
.
push_back
(
std
::
make_unique
<
Bind
::
Texture
>
(
gfx
,
Surface
::
FromFile
(
base
+
texFileName
.
C_Str
()
),
1
)
);
bindablePtrs
.
push_back
(
std
::
make_unique
<
Bind
::
Sampler
>
(
gfx
)
);
bindablePtrs
.
push_back
(
std
::
make_unique
<
Bind
::
Sampler
>
(
gfx
)
);
}
}
...
...
hw3d/Texture.cpp
View file @
054d8661
...
@@ -6,7 +6,9 @@ namespace Bind
...
@@ -6,7 +6,9 @@ namespace Bind
{
{
namespace
wrl
=
Microsoft
::
WRL
;
namespace
wrl
=
Microsoft
::
WRL
;
Texture
::
Texture
(
Graphics
&
gfx
,
const
Surface
&
s
)
Texture
::
Texture
(
Graphics
&
gfx
,
const
Surface
&
s
,
unsigned
int
slot
)
:
slot
(
slot
)
{
{
INFOMAN
(
gfx
);
INFOMAN
(
gfx
);
...
@@ -44,6 +46,6 @@ namespace Bind
...
@@ -44,6 +46,6 @@ namespace Bind
void
Texture
::
Bind
(
Graphics
&
gfx
)
noexcept
void
Texture
::
Bind
(
Graphics
&
gfx
)
noexcept
{
{
GetContext
(
gfx
)
->
PSSetShaderResources
(
0u
,
1u
,
pTextureView
.
GetAddressOf
()
);
GetContext
(
gfx
)
->
PSSetShaderResources
(
slot
,
1u
,
pTextureView
.
GetAddressOf
()
);
}
}
}
}
hw3d/Texture.h
View file @
054d8661
...
@@ -8,8 +8,10 @@ namespace Bind
...
@@ -8,8 +8,10 @@ namespace Bind
class
Texture
:
public
Bindable
class
Texture
:
public
Bindable
{
{
public:
public:
Texture
(
Graphics
&
gfx
,
const
Surface
&
s
);
Texture
(
Graphics
&
gfx
,
const
Surface
&
s
,
unsigned
int
slot
=
0
);
void
Bind
(
Graphics
&
gfx
)
noexcept
override
;
void
Bind
(
Graphics
&
gfx
)
noexcept
override
;
private:
unsigned
int
slot
;
protected:
protected:
Microsoft
::
WRL
::
ComPtr
<
ID3D11ShaderResourceView
>
pTextureView
;
Microsoft
::
WRL
::
ComPtr
<
ID3D11ShaderResourceView
>
pTextureView
;
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment