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
ACGL
acgl
Commits
f5f024a0
Commit
f5f024a0
authored
Sep 05, 2011
by
Robert Menzel
Browse files
Merge branch 'master' of
file:///data/git-repository/acgl/libraries/acgl
parents
c477eacc
09129e4e
Changes
6
Hide whitespace changes
Inline
Side-by-side
include/ACGL/Base/FileHelpers.hh
View file @
f5f024a0
...
...
@@ -61,6 +61,11 @@ namespace FileHelpers
* Will return the modification time of the file.
*/
FileModificationTime
getFileModificationTime
(
const
std
::
string
&
fileName
)
;
/*
* Checks whether a file with the given filename exists and is readable.
*/
bool
fileExists
(
const
std
::
string
&
fileName
);
}
}
// Base
...
...
include/ACGL/OpenGL/Tools.hh
View file @
f5f024a0
...
...
@@ -39,6 +39,9 @@ uint32_t getOpenGLMajorVersionNumber();
// returns the combined version number as 10*major + minor for easy comparing
uint32_t
getOpenGLVersionNumber
();
bool
doesSupportGeometryShader
();
bool
doesSupportTessellationShader
();
// for every OpenGL error enum this will return a human readable version of it
// similar to gluErrorString, but that function is not available on all plattforms
// (read: iOS)
...
...
src/ACGL/Base/FileHelpers.cc
View file @
f5f024a0
...
...
@@ -103,6 +103,12 @@ namespace FileHelpers
stat
(
fileName
.
c_str
(),
&
fileStats
);
return
fileStats
.
st_mtime
;
}
bool
fileExists
(
const
std
::
string
&
fileName
)
{
std
::
ifstream
file
(
fileName
.
c_str
()
);
return
file
.
good
();
}
}
}
// Base
...
...
src/ACGL/OpenGL/Controller/ShaderControlFile.cc
View file @
f5f024a0
...
...
@@ -22,6 +22,10 @@ SharedShader ShaderControlFile::create(void)
if
(
extension
==
"vsh"
)
mType
=
GL_VERTEX_SHADER
;
else
if
(
extension
==
"tcsh"
)
mType
=
GL_TESS_CONTROL_SHADER
;
else
if
(
extension
==
"tesh"
)
mType
=
GL_TESS_EVALUATION_SHADER
;
else
if
(
extension
==
"gsh"
)
mType
=
GL_GEOMETRY_SHADER
;
else
if
(
extension
==
"fsh"
)
...
...
src/ACGL/OpenGL/Controller/ShaderProgramControlAutoFiles.cc
View file @
f5f024a0
...
...
@@ -8,18 +8,51 @@
#include
<ACGL/Resource/FileManager.hh>
#include
<ACGL/OpenGL/Managers.hh>
#include
<ACGL/Base/Settings.hh>
#include
<ACGL/Base/FileHelpers.hh>
using
namespace
ACGL
::
Base
;
using
namespace
ACGL
::
OpenGL
;
//using namespace ACGL::Resource;
SharedShaderProgram
ShaderProgramControlAutoFiles
::
create
(
void
)
{
SharedShaderProgram
shaderProgram
(
new
ShaderProgram
());
if
(
ConstSharedShader
shader
=
ShaderFileManager
::
the
()
->
get
(
ShaderControlFile
(
mFilename
+
".vsh"
).
type
(
GL_VERTEX_SHADER
)))
shaderProgram
->
attachShader
(
shader
);
if
(
ConstSharedShader
shader
=
ShaderFileManager
::
the
()
->
get
(
ShaderControlFile
(
mFilename
+
".gsh"
).
type
(
GL_GEOMETRY_SHADER
)))
shaderProgram
->
attachShader
(
shader
);
#ifndef ACGL_OPENGL_ES
// this shader types are not defined for ES
bool
tessellationControlShaderPresent
=
FileHelpers
::
fileExists
(
Base
::
Settings
::
the
()
->
getFullShaderPath
()
+
mFilename
+
".tcsh"
);
bool
tessellationEvaluationShaderPresent
=
FileHelpers
::
fileExists
(
Base
::
Settings
::
the
()
->
getFullShaderPath
()
+
mFilename
+
".tesh"
);
if
(
OpenGL
::
doesSupportTessellationShader
())
{
if
(
tessellationControlShaderPresent
&&
tessellationEvaluationShaderPresent
)
{
// both tessellation stages are present -> load them
if
(
ConstSharedShader
shader
=
ShaderFileManager
::
the
()
->
get
(
ShaderControlFile
(
mFilename
+
".tcsh"
).
type
(
GL_TESS_CONTROL_SHADER
)))
shaderProgram
->
attachShader
(
shader
);
if
(
ConstSharedShader
shader
=
ShaderFileManager
::
the
()
->
get
(
ShaderControlFile
(
mFilename
+
".tesh"
).
type
(
GL_TESS_EVALUATION_SHADER
)))
shaderProgram
->
attachShader
(
shader
);
}
else
{
if
(
tessellationControlShaderPresent
||
tessellationEvaluationShaderPresent
)
{
// only ONE tessellation stage is present -> somethings wrong
ACGL
::
Utils
::
warning
()
<<
"only one of two tessellation shaders are present - ignored"
<<
std
::
endl
;
}
}
}
else
if
(
tessellationControlShaderPresent
||
tessellationEvaluationShaderPresent
)
{
ACGL
::
Utils
::
warning
()
<<
"tessellation shader present but hardware doesn't support those - ignored"
<<
std
::
endl
;
}
bool
geometryShaderPresent
=
FileHelpers
::
fileExists
(
Base
::
Settings
::
the
()
->
getFullShaderPath
()
+
mFilename
+
".gsh"
);
if
(
OpenGL
::
doesSupportGeometryShader
())
{
if
(
geometryShaderPresent
)
if
(
ConstSharedShader
shader
=
ShaderFileManager
::
the
()
->
get
(
ShaderControlFile
(
mFilename
+
".gsh"
).
type
(
GL_GEOMETRY_SHADER
)))
shaderProgram
->
attachShader
(
shader
);
}
else
if
(
geometryShaderPresent
)
{
ACGL
::
Utils
::
warning
()
<<
"geometry shader present but hardware doesn't support it - ignored"
<<
std
::
endl
;
}
#endif
if
(
ConstSharedShader
shader
=
ShaderFileManager
::
the
()
->
get
(
ShaderControlFile
(
mFilename
+
".fsh"
).
type
(
GL_FRAGMENT_SHADER
)))
shaderProgram
->
attachShader
(
shader
);
...
...
@@ -30,6 +63,7 @@ SharedShaderProgram ShaderProgramControlAutoFiles::create(void)
if
(
shaderProgram
->
link
())
return
shaderProgram
;
return
SharedShaderProgram
();
}
...
...
@@ -37,8 +71,17 @@ bool ShaderProgramControlAutoFiles::update(SharedShaderProgram& shaderProgram)
{
bool
update
=
false
;
update
|=
ShaderFileManager
::
the
()
->
update
(
mFilename
+
".vsh"
);
update
|=
ShaderFileManager
::
the
()
->
update
(
mFilename
+
".gsh"
);
update
|=
ShaderFileManager
::
the
()
->
update
(
mFilename
+
".fsh"
);
#ifndef ACGL_OPENGL_ES
if
(
OpenGL
::
doesSupportGeometryShader
())
{
update
|=
ShaderFileManager
::
the
()
->
update
(
mFilename
+
".gsh"
);
}
if
(
OpenGL
::
doesSupportTessellationShader
())
{
update
|=
ShaderFileManager
::
the
()
->
update
(
mFilename
+
".tcsh"
);
update
|=
ShaderFileManager
::
the
()
->
update
(
mFilename
+
".tesh"
);
}
#endif
if
(
update
)
return
shaderProgram
->
link
();
return
false
;
...
...
src/ACGL/OpenGL/Tools.cc
View file @
f5f024a0
...
...
@@ -77,6 +77,32 @@ uint32_t getOpenGLVersionNumber()
return
privateGetOpenGLVersion
(
2
);
}
bool
doesSupportGeometryShader
()
{
#ifdef ACGL_OPENGL_ES
return
false
;
#else
# if defined(ACGL_USE_GLEW)
return
(
GLEW_EXT_geometry_shader4
||
GLEW_ARB_geometry_shader4
||
(
getOpenGLVersionNumber
()
>=
32
));
# else
return
(
getOpenGLVersionNumber
()
>=
32
);
# endif
#endif
}
bool
doesSupportTessellationShader
()
{
#ifdef ACGL_OPENGL_ES
return
false
;
#else
# if defined(ACGL_USE_GLEW)
return
(
GLEW_ARB_tessellation_shader
||
(
getOpenGLVersionNumber
()
>=
40
));
# else
return
(
getOpenGLVersionNumber
()
>=
40
);
# endif
#endif
}
const
GLubyte
*
acglErrorString
(
GLenum
_errorCode
)
{
#ifndef ACGL_USE_GLEW
...
...
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