Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Frédéric Larue
CommonGUI
Commits
4951e563
Commit
4951e563
authored
Mar 01, 2019
by
Frédéric Larue
Browse files
New functions to set uniforms in GPU::Shader added.
parent
f22893b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
GPU/Shader.cpp
View file @
4951e563
...
...
@@ -435,6 +435,60 @@ void GPU::Shader::SetUniform( const std::string& name,
}
void
GPU
::
Shader
::
SetUniform
(
const
std
::
string
&
name
,
GLint
value
)
{
UniformMap
::
iterator
uu
=
m_Uniforms
.
find
(
name
);
if
(
uu
!=
m_Uniforms
.
end
()
)
{
GLuint
activeProgBackup
;
gpuAssert
(
activeProgBackup
=
glGetHandleARB
(
GL_PROGRAM_OBJECT_ARB
)
);
gpuAssert
(
glUseProgramObjectARB
(
Id
()
)
);
Uniform
&
u
=
uu
->
second
;
assert
(
(
u
.
type
==
GL_INT
||
u
.
type
==
GL_BOOL_ARB
)
&&
u
.
size
==
1
);
gpuAssert
(
glUniform1ivARB
(
u
.
location
,
u
.
size
,
&
value
)
);
gpuAssert
(
glUseProgramObjectARB
(
activeProgBackup
)
);
}
}
void
GPU
::
Shader
::
SetUniform
(
const
std
::
string
&
name
,
GLfloat
value
)
{
UniformMap
::
iterator
uu
=
m_Uniforms
.
find
(
name
);
if
(
uu
!=
m_Uniforms
.
end
()
)
{
GLuint
activeProgBackup
;
gpuAssert
(
activeProgBackup
=
glGetHandleARB
(
GL_PROGRAM_OBJECT_ARB
)
);
gpuAssert
(
glUseProgramObjectARB
(
Id
()
)
);
Uniform
&
u
=
uu
->
second
;
assert
(
u
.
type
==
GL_FLOAT
&&
u
.
size
==
1
);
gpuAssert
(
glUniform1fvARB
(
u
.
location
,
u
.
size
,
&
value
)
);
gpuAssert
(
glUseProgramObjectARB
(
activeProgBackup
)
);
}
}
void
GPU
::
Shader
::
SetUniform
(
const
std
::
string
&
name
,
GLdouble
value
)
{
UniformMap
::
iterator
uu
=
m_Uniforms
.
find
(
name
);
if
(
uu
!=
m_Uniforms
.
end
()
)
{
GLuint
activeProgBackup
;
gpuAssert
(
activeProgBackup
=
glGetHandleARB
(
GL_PROGRAM_OBJECT_ARB
)
);
gpuAssert
(
glUseProgramObjectARB
(
Id
()
)
);
Uniform
&
u
=
uu
->
second
;
assert
(
u
.
type
==
GL_DOUBLE
&&
u
.
size
==
1
);
gpuAssert
(
glUniform1dv
(
u
.
location
,
u
.
size
,
&
value
)
);
gpuAssert
(
glUseProgramObjectARB
(
activeProgBackup
)
);
}
}
void
GPU
::
Shader
::
SetSamplers
(
const
std
::
string
&
name
,
const
GLint
*
texUnit
)
{
...
...
GPU/Shader.h
View file @
4951e563
...
...
@@ -212,6 +212,10 @@ namespace GPU
void
SetUniform
(
const
std
::
string
&
name
,
const
void
*
value
);
void
SetUniform
(
const
std
::
string
&
name
,
GLint
value
);
void
SetUniform
(
const
std
::
string
&
name
,
GLfloat
value
);
void
SetUniform
(
const
std
::
string
&
name
,
GLdouble
value
);
inline
void
SetSampler
(
const
std
::
string
&
name
,
const
GLint
texUnit
)
{
SetSamplers
(
name
,
&
texUnit
);
}
void
SetSamplers
(
const
std
::
string
&
name
,
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment