Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Johannes Braun
glare
Commits
e3ee56f2
Commit
e3ee56f2
authored
Aug 23, 2017
by
Johannes Braun
Browse files
Enabled only one instance of each shader type per shader program. Closes #37
parent
72ac9a19
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/libraries/core/base/program.cpp
View file @
e3ee56f2
...
...
@@ -5,7 +5,12 @@ namespace glare::core
Program
::
Program
(
const
std
::
vector
<
std
::
shared_ptr
<
Shader
>>
&
shaders
)
{
for
(
const
auto
&
shader
:
shaders
)
{
if
(
m_shader_stages
.
find
(
shader
->
type
())
!=
m_shader_stages
.
end
())
throw
std
::
invalid_argument
(
"Can't attach more than one of shader type id "
+
std
::
to_string
(
static_cast
<
unsigned
>
(
shader
->
type
()))
+
" to a program."
);
gl
::
attachShader
(
m_handle
,
shader
->
id
());
m_shader_stages
.
insert
(
shader
->
type
());
}
gl
::
linkProgram
(
m_handle
);
int
success
=
0
;
...
...
@@ -80,7 +85,6 @@ namespace glare::core
{
for
(
auto
&&
shader
:
shaders
)
{
m_shader_stages
.
push_back
(
shader
->
type
());
int
num_subroutines
;
gl
::
getProgramStageiv
(
m_handle
,
shader
->
type
(),
gl
::
ProgramParameter
::
eActiveSubroutines
,
&
num_subroutines
);
int
max_length
;
...
...
src/libraries/core/base/program.h
View file @
e3ee56f2
...
...
@@ -3,6 +3,7 @@
#include
<map>
#include
<string>
#include
<set>
#include
<glm/ext.hpp>
#include
<util/opengl.h>
...
...
@@ -93,7 +94,7 @@ namespace glare::core
gl
::
handle
::
shader_program
m_handle
;
std
::
map
<
std
::
string
,
UniformInfo
>
m_uniforms
;
std
::
map
<
std
::
string
,
std
::
map
<
gl
::
ShaderType
,
SubroutineInfo
>>
m_subroutines
;
std
::
vector
<
gl
::
ShaderType
>
m_shader_stages
;
std
::
set
<
gl
::
ShaderType
>
m_shader_stages
;
std
::
map
<
gl
::
ShaderType
,
std
::
vector
<
unsigned
>>
m_subroutine_bindings
;
};
...
...
Write
Preview
Supports
Markdown
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