Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CommonGUI
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Frédéric Larue
CommonGUI
Commits
7aad66e6
Commit
7aad66e6
authored
Jun 26, 2018
by
Frédéric Larue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Shader class now gives the possibility to set up arrays of samplers.
parent
3f884fad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
16 deletions
+62
-16
GPU/Shader.cpp
GPU/Shader.cpp
+56
-11
GPU/Shader.h
GPU/Shader.h
+6
-5
No files found.
GPU/Shader.cpp
View file @
7aad66e6
...
...
@@ -132,15 +132,60 @@ void GPU::Shader::RecoverActiveUniforms()
std
::
string
name
(
nameBuffer
);
if
(
type
<
GL_SAMPLER_1D_ARB
||
type
>
GL_SAMPLER_2D_RECT_SHADOW_ARB
)
switch
(
type
)
{
Uniform
&
unif
=
m_Uniforms
[
name
];
unif
.
location
=
glGetUniformLocationARB
(
m_Id
,
nameBuffer
);
unif
.
size
=
size
;
unif
.
type
=
type
;
case
GL_SAMPLER_1D
:
case
GL_SAMPLER_2D
:
case
GL_SAMPLER_3D
:
case
GL_SAMPLER_CUBE
:
case
GL_SAMPLER_1D_SHADOW
:
case
GL_SAMPLER_2D_SHADOW
:
case
GL_SAMPLER_1D_ARRAY
:
case
GL_SAMPLER_2D_ARRAY
:
case
GL_SAMPLER_1D_ARRAY_SHADOW
:
case
GL_SAMPLER_2D_ARRAY_SHADOW
:
case
GL_SAMPLER_2D_MULTISAMPLE
:
case
GL_SAMPLER_2D_MULTISAMPLE_ARRAY
:
case
GL_SAMPLER_CUBE_SHADOW
:
case
GL_SAMPLER_BUFFER
:
case
GL_SAMPLER_2D_RECT
:
case
GL_SAMPLER_2D_RECT_SHADOW
:
case
GL_INT_SAMPLER_1D
:
case
GL_INT_SAMPLER_2D
:
case
GL_INT_SAMPLER_3D
:
case
GL_INT_SAMPLER_CUBE
:
case
GL_INT_SAMPLER_1D_ARRAY
:
case
GL_INT_SAMPLER_2D_ARRAY
:
case
GL_INT_SAMPLER_2D_MULTISAMPLE
:
case
GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
:
case
GL_INT_SAMPLER_BUFFER
:
case
GL_INT_SAMPLER_2D_RECT
:
case
GL_UNSIGNED_INT_SAMPLER_1D
:
case
GL_UNSIGNED_INT_SAMPLER_2D
:
case
GL_UNSIGNED_INT_SAMPLER_3D
:
case
GL_UNSIGNED_INT_SAMPLER_CUBE
:
case
GL_UNSIGNED_INT_SAMPLER_1D_ARRAY
:
case
GL_UNSIGNED_INT_SAMPLER_2D_ARRAY
:
case
GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE
:
case
GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
:
case
GL_UNSIGNED_INT_SAMPLER_BUFFER
:
case
GL_UNSIGNED_INT_SAMPLER_2D_RECT
:
{
Uniform
&
smpl
=
m_Samplers
[
name
];
smpl
.
location
=
glGetUniformLocationARB
(
m_Id
,
nameBuffer
);
smpl
.
size
=
size
;
smpl
.
type
=
type
;
break
;
}
default:
{
Uniform
&
unif
=
m_Uniforms
[
name
];
unif
.
location
=
glGetUniformLocationARB
(
m_Id
,
nameBuffer
);
unif
.
size
=
size
;
unif
.
type
=
type
;
break
;
}
}
else
m_Samplers
[
name
]
=
glGetUniformLocationARB
(
m_Id
,
nameBuffer
);
}
}
...
...
@@ -148,7 +193,7 @@ void GPU::Shader::RecoverActiveUniforms()
void
GPU
::
Shader
::
RecoverActiveAttributes
()
{
m_Attributes
.
clear
();
GLint
count
;
GLcharARB
nameBuffer
[
512
];
...
...
@@ -366,15 +411,15 @@ void GPU::Shader::SetUniform( const std::string& name,
void
GPU
::
Shader
::
SetSampler
(
const
std
::
string
&
name
,
const
GLint
texUnit
)
const
GLint
*
texUnit
)
{
Sampler
Map
::
iterator
s
=
m_Samplers
.
find
(
name
);
Uniform
Map
::
iterator
s
=
m_Samplers
.
find
(
name
);
if
(
s
!=
m_Samplers
.
end
()
)
{
GLuint
activeProgBackup
=
glGetHandleARB
(
GL_PROGRAM_OBJECT_ARB
);
glUseProgramObjectARB
(
m_Id
);
glUniform1i
ARB
(
s
->
second
,
texUnit
);
glUniform1i
vARB
(
s
->
second
.
location
,
s
->
second
.
size
,
(
GLint
*
)
texUnit
);
glUseProgramObjectARB
(
activeProgBackup
);
}
...
...
GPU/Shader.h
View file @
7aad66e6
...
...
@@ -122,7 +122,6 @@ namespace GPU
private:
typedef
std
::
map
<
std
::
string
,
Uniform
>
UniformMap
;
typedef
std
::
map
<
std
::
string
,
GLint
>
SamplerMap
;
typedef
std
::
map
<
std
::
string
,
GLint
>
AttribMap
;
typedef
std
::
map
<
GLint
,
Texture
*>
SamplerBindingMap
;
typedef
std
::
map
<
GLint
,
VBOAttribBuffer
*>
AttribBindingMap
;
...
...
@@ -138,8 +137,8 @@ namespace GPU
GeomPg
m_GeomPg
;
UniformMap
m_Uniforms
;
UniformMap
m_Samplers
;
AttribMap
m_Attributes
;
SamplerMap
m_Samplers
;
SamplerBindingMap
m_SamplerBinding
;
/*****************************\
...
...
@@ -186,8 +185,10 @@ namespace GPU
void
SetUniform
(
const
std
::
string
&
name
,
const
void
*
value
);
inline
void
SetSampler
(
const
std
::
string
&
name
,
const
GLint
texUnit
)
{
SetSampler
(
name
,
&
texUnit
);
}
void
SetSampler
(
const
std
::
string
&
name
,
const
GLint
texUnit
);
const
GLint
*
texUnit
);
void
SetAttrib
(
const
std
::
string
&
name
,
VBOAttribBuffer
*
attrib
);
...
...
@@ -202,8 +203,8 @@ namespace GPU
}
inline
GLint
SamplerLoc
(
const
std
::
string
&
name
)
const
{
Sampler
Map
::
const_iterator
s
=
m_Samplers
.
find
(
name
);
return
(
s
!=
m_Samplers
.
end
())
?
s
->
second
:
-
1
;
Uniform
Map
::
const_iterator
s
=
m_Samplers
.
find
(
name
);
return
(
s
!=
m_Samplers
.
end
())
?
s
->
second
.
location
:
-
1
;
}
inline
GLint
AttribLoc
(
const
std
::
string
&
name
)
const
{
...
...
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