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
335bf720
Commit
335bf720
authored
Jun 30, 2013
by
Maciej Sumiński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More debug information in case of failure compilation of shaders.
parent
5eb38ec2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
4 deletions
+53
-4
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+10
-2
shader.cpp
common/gal/opengl/shader.cpp
+35
-1
shader.h
include/gal/opengl/shader.h
+8
-1
No files found.
common/gal/opengl/opengl_gal.cpp
View file @
335bf720
...
...
@@ -359,8 +359,16 @@ void OPENGL_GAL::BeginDrawing()
// Compile the shaders
if
(
!
isShaderInitialized
&&
isUseShader
)
{
shader
.
AddSource
(
shaderPath
+
std
::
string
(
"/shader.vert"
),
SHADER_TYPE_VERTEX
);
shader
.
AddSource
(
shaderPath
+
std
::
string
(
"/shader.frag"
),
SHADER_TYPE_FRAGMENT
);
if
(
!
shader
.
AddSource
(
shaderPath
+
std
::
string
(
"/shader.vert"
),
SHADER_TYPE_VERTEX
)
)
{
wxLogFatalError
(
wxT
(
"Cannot compile vertex shader!"
)
);
}
if
(
!
shader
.
AddSource
(
shaderPath
+
std
::
string
(
"/shader.frag"
),
SHADER_TYPE_FRAGMENT
)
)
{
wxLogFatalError
(
wxT
(
"Cannot compile fragment shader!"
)
);
}
if
(
!
shader
.
Link
()
)
{
wxLogFatalError
(
wxT
(
"Cannot link the shaders!"
)
);
...
...
common/gal/opengl/shader.cpp
View file @
335bf720
...
...
@@ -83,6 +83,27 @@ void SHADER::ProgramInfo( GLuint aProgram )
}
void
SHADER
::
ShaderInfo
(
GLuint
aShader
)
{
GLint
glInfoLogLength
=
0
;
GLint
writtenChars
=
0
;
// Get the length of the info string
glGetShaderiv
(
aShader
,
GL_INFO_LOG_LENGTH
,
&
glInfoLogLength
);
// Print the information
if
(
glInfoLogLength
>
2
)
{
GLchar
*
glInfoLog
=
new
GLchar
[
glInfoLogLength
];
glGetShaderInfoLog
(
aShader
,
glInfoLogLength
,
&
writtenChars
,
glInfoLog
);
wxLogInfo
(
wxString
::
FromUTF8
(
(
char
*
)
glInfoLog
)
);
delete
glInfoLog
;
}
}
std
::
string
SHADER
::
ReadSource
(
std
::
string
aShaderSourceName
)
{
// Open the shader source for reading
...
...
@@ -109,7 +130,7 @@ std::string SHADER::ReadSource( std::string aShaderSourceName )
}
void
SHADER
::
AddSource
(
const
std
::
string
&
aShaderSourceName
,
ShaderType
aShaderType
)
bool
SHADER
::
AddSource
(
const
std
::
string
&
aShaderSourceName
,
ShaderType
aShaderType
)
{
if
(
isShaderLinked
)
{
...
...
@@ -144,6 +165,17 @@ void SHADER::AddSource( const std::string& aShaderSourceName, ShaderType aShader
// Compile and attach shader to the program
glCompileShader
(
shaderNumber
);
GLint
status
;
glGetShaderiv
(
shaderNumber
,
GL_COMPILE_STATUS
,
&
status
);
if
(
status
!=
GL_TRUE
)
{
wxLogError
(
wxT
(
"Shader compilation error"
)
);
ShaderInfo
(
shaderNumber
);
return
false
;
}
glAttachShader
(
programNumber
,
shaderNumber
);
ProgramInfo
(
programNumber
);
...
...
@@ -157,6 +189,8 @@ void SHADER::AddSource( const std::string& aShaderSourceName, ShaderType aShader
// Delete the allocated char array
delete
[]
source
;
return
true
;
}
...
...
include/gal/opengl/shader.h
View file @
335bf720
...
...
@@ -76,7 +76,7 @@ public:
* @param aShaderSourceName is the shader source file name.
* @param aShaderType is the type of the shader.
*/
void
AddSource
(
const
std
::
string
&
aShaderSourceName
,
ShaderType
aShaderType
);
bool
AddSource
(
const
std
::
string
&
aShaderSourceName
,
ShaderType
aShaderType
);
/**
* @brief Link the shaders.
...
...
@@ -159,6 +159,13 @@ private:
*/
void
ProgramInfo
(
GLuint
aProgram
);
/**
* @brief Get the shader information.
*
* @param aShader is the shader number.
*/
void
ShaderInfo
(
GLuint
aShader
);
/**
* @brief Read the shader source file
*
...
...
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