Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
978b548c
Commit
978b548c
authored
Jun 24, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small improvements to SHADER class.
parent
ef865aab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
28 deletions
+37
-28
shader.cpp
common/gal/opengl/shader.cpp
+10
-21
shader.h
include/gal/opengl/shader.h
+27
-7
No files found.
common/gal/opengl/shader.cpp
View file @
978b548c
...
...
@@ -35,13 +35,14 @@
using
namespace
KiGfx
;
SHADER
::
SHADER
()
SHADER
::
SHADER
()
:
isProgramCreated
(
false
),
isShaderLinked
(
false
),
maximumVertices
(
4
),
active
(
false
),
geomInputType
(
GL_LINES
),
geomOutputType
(
GL_LINES
)
{
isProgramCreated
=
false
;
isShaderLinked
=
false
;
maximumVertices
=
4
;
geomInputType
=
GL_LINES
;
geomOutputType
=
GL_LINES
;
}
...
...
@@ -108,7 +109,7 @@ std::string SHADER::ReadSource( std::string aShaderSourceName )
}
void
SHADER
::
AddSource
(
std
::
string
aShaderSourceName
,
ShaderType
aShaderType
)
void
SHADER
::
AddSource
(
const
std
::
string
&
aShaderSourceName
,
ShaderType
aShaderType
)
{
if
(
isShaderLinked
)
{
...
...
@@ -195,19 +196,7 @@ bool SHADER::Link()
}
void
SHADER
::
Use
()
{
glUseProgram
(
programNumber
);
}
void
SHADER
::
Deactivate
()
{
glUseProgram
(
0
);
}
void
SHADER
::
AddParameter
(
std
::
string
aParameterName
)
void
SHADER
::
AddParameter
(
const
std
::
string
&
aParameterName
)
{
GLint
location
=
glGetUniformLocation
(
programNumber
,
aParameterName
.
c_str
()
);
...
...
@@ -224,7 +213,7 @@ void SHADER::SetParameter( int parameterNumber, float value )
}
int
SHADER
::
GetAttribute
(
std
::
string
aAttributeName
)
int
SHADER
::
GetAttribute
(
std
::
string
aAttributeName
)
const
{
return
glGetAttribLocation
(
programNumber
,
aAttributeName
.
c_str
()
);
}
include/gal/opengl/shader.h
View file @
978b548c
...
...
@@ -76,23 +76,42 @@ public:
* @param aShaderSourceName is the shader source file name.
* @param aShaderType is the type of the shader.
*/
void
AddSource
(
std
::
string
aShaderSourceName
,
ShaderType
aShaderType
);
void
AddSource
(
const
std
::
string
&
aShaderSourceName
,
ShaderType
aShaderType
);
/**
* Link the shaders.
* @brief Link the shaders.
*
* @return true in case of success, false otherwise.
*/
bool
Link
();
/**
* Use the shader.
*
@brief
Use the shader.
*/
void
Use
();
inline
void
Use
()
{
glUseProgram
(
programNumber
);
active
=
true
;
}
/**
* @brief Deactivate the shader and use the default OpenGL program.
*/
void
Deactivate
();
inline
void
Deactivate
()
{
glUseProgram
(
0
);
active
=
false
;
}
/**
* @brief Returns the current state of the shader.
*
* @return True if any of shaders is enabled.
*/
inline
bool
IsActive
()
const
{
return
active
;
}
/**
* @brief Configure the geometry shader - has to be done before linking!
...
...
@@ -113,7 +132,7 @@ public:
*
* @param aParameterName is the name of the parameter.
*/
void
AddParameter
(
std
::
string
aParameterName
);
void
AddParameter
(
const
std
::
string
&
aParameterName
);
/**
* @brief Set a parameter of the shader.
...
...
@@ -129,7 +148,7 @@ public:
* @param aAttributeName is the name of the attribute.
* @return the location.
*/
int
GetAttribute
(
std
::
string
aAttributeName
);
int
GetAttribute
(
std
::
string
aAttributeName
)
const
;
private
:
...
...
@@ -152,6 +171,7 @@ private:
GLuint
programNumber
;
///< Shader program number
bool
isProgramCreated
;
///< Flag for program creation
bool
isShaderLinked
;
///< Is the shader linked?
bool
active
;
///< Is any of shaders used?
GLuint
maximumVertices
;
///< The maximum of vertices to be generated
GLuint
geomInputType
;
///< Input type [e.g. GL_LINES, GL_TRIANGLES, GL_QUADS etc.]
GLuint
geomOutputType
;
///< Output type [e.g. GL_LINES, GL_TRIANGLES, GL_QUADS etc.]
...
...
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