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
KennethVanhoey
CGoGN
Commits
e4bd2906
Commit
e4bd2906
authored
Jul 26, 2011
by
Maire Nicolas
Browse files
Gestion du retour d'erreur de shaderMutator dans clippingShader.
parent
ded869be
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/Utils/clippingShader.h
View file @
e4bd2906
...
...
@@ -317,10 +317,18 @@ private:
private:
/**
* Outputs a "shader mutator failure" error if the condition is satisfied
* @param condition condition to satisfy
* @param location name of the function where the error raising was done
* @return true if the error has been raised
*/
bool
errorRaiseShaderMutatorFailure
(
bool
condition
,
const
std
::
string
&
location
);
/**
* Outputs a "parameter not positive" error if the condition is satisfied
* @param condition condition to satisfy
* @param location name of the function where the error raising
i
s done
* @param location name of the function where the error raising
wa
s done
* @param paramName name of the parameter
* @return true if the error has been raised
*/
...
...
@@ -329,7 +337,7 @@ private:
/**
* Outputs a "shader source is empty" error if the condition is satisfied
* @param condition condition to satisfy
* @param location name of the function where the error raising
i
s done
* @param location name of the function where the error raising
wa
s done
* @param shaderType type of the shader
* @return true if the error has been raised
*/
...
...
@@ -338,7 +346,7 @@ private:
/**
* Outputs a "shader uses a geometry shader" error if the condition is satisfied
* @param condition condition to satisfy
* @param location name of the function where the error raising
i
s done
* @param location name of the function where the error raising
wa
s done
* @return true if the error has been raised
*/
bool
errorRaiseShaderUsesGeometryShader
(
bool
condition
,
const
std
::
string
&
location
);
...
...
@@ -346,7 +354,7 @@ private:
/**
* Outputs a ".. not found in shader" error if the condition is satisfied
* @param condition condition to satisfy
* @param location name of the function where the error raising
i
s done
* @param location name of the function where the error raising
wa
s done
* @param shaderType type of the shader
* @param varName name of the variable that may not be found
* @return true if the error has been raised
...
...
@@ -356,7 +364,7 @@ private:
/**
* Outputs a "parameter is out of range" error if the condition is satisfied
* @param condition condition to satisfy
* @param location name of the function where the error raising
i
s done
* @param location name of the function where the error raising
wa
s done
* @param paramName name of the parameter
* @return true if the error has been raised
*/
...
...
@@ -365,7 +373,7 @@ private:
/**
* Outputs a "uniform .. not found in shader" error if the condition is satisfied
* @param condition condition to satisfy
* @param location name of the function where the error raising
i
s done
* @param location name of the function where the error raising
wa
s done
* @param uniformName name of the uniform that may not be found
* @return true if the error has been raised
*/
...
...
@@ -374,7 +382,7 @@ private:
/**
* Outputs a "clipping code was already inserted" error if the condition is satisfied
* @param condition condition to satisfy
* @param location name of the function where the error raising
i
s done
* @param location name of the function where the error raising
wa
s done
* @return true if the error has been raised
*/
bool
errorRaiseClippingCodeAlreadyInserted
(
bool
condition
,
const
std
::
string
&
location
);
...
...
@@ -382,7 +390,7 @@ private:
/**
* Outputs a "clipping code has not been inserted yet" error if the condition is satisfied
* @param condition condition to satisfy
* @param location name of the function where the error raising
i
s done
* @param location name of the function where the error raising
wa
s done
* @return true if the error has been raised
*/
bool
errorRaiseClippingCodeNotInserted
(
bool
condition
,
const
std
::
string
&
location
);
...
...
src/Utils/clippingShader.cpp
View file @
e4bd2906
...
...
@@ -79,8 +79,11 @@ void ClippingShader::setClipPlanesCount(int planesCount)
ShaderMutator
SM
(
shaderName
,
getVertexShaderSrc
(),
getFragmentShaderSrc
());
// Modify the clip planes count constant in both shader
SM
.
changeIntConstantValue
(
ShaderMutator
::
VERTEX_SHADER
,
"CLIP_PLANES_COUNT"
,
planesCount
);
SM
.
changeIntConstantValue
(
ShaderMutator
::
FRAGMENT_SHADER
,
"CLIP_PLANES_COUNT"
,
planesCount
);
if
(
errorRaiseShaderMutatorFailure
(
(
!
SM
.
changeIntConstantValue
(
ShaderMutator
::
VERTEX_SHADER
,
"CLIP_PLANES_COUNT"
,
planesCount
))
||
(
!
SM
.
changeIntConstantValue
(
ShaderMutator
::
FRAGMENT_SHADER
,
"CLIP_PLANES_COUNT"
,
planesCount
)),
"ClippingShader::setClipPlanesCount"
))
return
;
// Reload both shaders
reloadVertexShaderFromMemory
(
SM
.
getModifiedVertexShaderSrc
().
c_str
());
...
...
@@ -282,8 +285,11 @@ void ClippingShader::setClipSpheresCount(int spheresCount)
ShaderMutator
SM
(
shaderName
,
getVertexShaderSrc
(),
getFragmentShaderSrc
());
// Modify the clip spheres count constant in both shader
SM
.
changeIntConstantValue
(
ShaderMutator
::
VERTEX_SHADER
,
"CLIP_SPHERES_COUNT"
,
spheresCount
);
SM
.
changeIntConstantValue
(
ShaderMutator
::
FRAGMENT_SHADER
,
"CLIP_SPHERES_COUNT"
,
spheresCount
);
if
(
errorRaiseShaderMutatorFailure
(
(
!
SM
.
changeIntConstantValue
(
ShaderMutator
::
VERTEX_SHADER
,
"CLIP_SPHERES_COUNT"
,
spheresCount
))
||
(
!
SM
.
changeIntConstantValue
(
ShaderMutator
::
FRAGMENT_SHADER
,
"CLIP_SPHERES_COUNT"
,
spheresCount
)),
"ClippingShader::setClipSpheresCount"
))
return
;
// Reload both shaders
reloadVertexShaderFromMemory
(
SM
.
getModifiedVertexShaderSrc
().
c_str
());
...
...
@@ -420,7 +426,7 @@ void ClippingShader::updateClipSphereUniformsArray(int sphereIndex)
bool
ClippingShader
::
insertClippingCode
()
{
// Check if the code has not
been
already inserted
// Check if the code has not already
been
inserted
if
(
errorRaiseClippingCodeAlreadyInserted
(
m_hasClippingCodeBeenInserted
,
"ClippingShader::insertClippingCode"
))
return
false
;
...
...
@@ -428,7 +434,7 @@ bool ClippingShader::insertClippingCode()
if
(
errorRaiseShaderSourceIsEmpty
((
getVertexShaderSrc
()
==
NULL
),
"ClippingShader::insertClippingCode"
,
ShaderMutator
::
VERTEX_SHADER
))
return
false
;
if
(
errorRaiseShaderSourceIsEmpty
((
getFragmentShaderSrc
()
==
NULL
),
"ClippingShader::insertClippingCode"
,
ShaderMutator
::
FRAGMENT_SHADER
))
return
false
;
return
false
;
// Check if the shader does not use a geometry shader
if
(
errorRaiseShaderUsesGeometryShader
((
getGeometryShaderSrc
()
!=
NULL
),
"ClippingShader::insertClippingCode"
))
...
...
@@ -629,14 +635,20 @@ bool ClippingShader::insertClippingCode()
return
false
;
// Modify vertex shader source code
SM
.
insertCodeBeforeMainFunction
(
ShaderMutator
::
VERTEX_SHADER
,
VS_headInsertion
);
SM
.
insertCodeAtMainFunctionBeginning
(
ShaderMutator
::
VERTEX_SHADER
,
VS_mainEndInsertion
);
if
(
errorRaiseShaderMutatorFailure
(
(
!
SM
.
insertCodeBeforeMainFunction
(
ShaderMutator
::
VERTEX_SHADER
,
VS_headInsertion
))
||
(
!
SM
.
insertCodeAtMainFunctionBeginning
(
ShaderMutator
::
VERTEX_SHADER
,
VS_mainEndInsertion
)),
"ClippingShader::insertClippingCode"
))
return
false
;
// Modify fragment shader source code
SM
.
setMinShadingLanguageVersion
(
ShaderMutator
::
FRAGMENT_SHADER
,
120
);
// Following code insertions need at least shading language 120 (GLSL arrays)
SM
.
insertCodeBeforeMainFunction
(
ShaderMutator
::
FRAGMENT_SHADER
,
FS_headInsertion
);
SM
.
insertCodeAtMainFunctionBeginning
(
ShaderMutator
::
FRAGMENT_SHADER
,
FS_mainBeginInsertion
);
SM
.
insertCodeAtMainFunctionEnd
(
ShaderMutator
::
FRAGMENT_SHADER
,
FS_mainEndInsertion
);
if
(
errorRaiseShaderMutatorFailure
(
(
!
SM
.
setMinShadingLanguageVersion
(
ShaderMutator
::
FRAGMENT_SHADER
,
120
))
// Following code insertions need at least shading language 120 (GLSL arrays)
||
(
!
SM
.
insertCodeBeforeMainFunction
(
ShaderMutator
::
FRAGMENT_SHADER
,
FS_headInsertion
))
||
(
!
SM
.
insertCodeAtMainFunctionBeginning
(
ShaderMutator
::
FRAGMENT_SHADER
,
FS_mainBeginInsertion
))
||
(
!
SM
.
insertCodeAtMainFunctionEnd
(
ShaderMutator
::
FRAGMENT_SHADER
,
FS_mainEndInsertion
)),
"ClippingShader::insertClippingCode"
))
return
false
;
// Reload both shaders
reloadVertexShaderFromMemory
(
SM
.
getModifiedVertexShaderSrc
().
c_str
());
...
...
@@ -700,7 +712,10 @@ void ClippingShader::setClipMode(clippingMode clipMode)
newConstantValue
=
0
;
break
;
}
SM
.
changeIntConstantValue
(
ShaderMutator
::
FRAGMENT_SHADER
,
"CLIPPING_MODE"
,
newConstantValue
);
if
(
errorRaiseShaderMutatorFailure
(
(
!
SM
.
changeIntConstantValue
(
ShaderMutator
::
FRAGMENT_SHADER
,
"CLIPPING_MODE"
,
newConstantValue
)),
"ClippingShader::setClipMode"
))
return
;
// Reload modified shader
reloadFragmentShaderFromMemory
(
SM
.
getModifiedFragmentShaderSrc
().
c_str
());
...
...
@@ -785,6 +800,20 @@ void ClippingShader::sendClipColorAttenuationFactorUniform()
***********************************************/
bool
ClippingShader
::
errorRaiseShaderMutatorFailure
(
bool
condition
,
const
std
::
string
&
location
)
{
if
(
condition
)
{
CGoGNerr
<<
"ERROR - "
<<
location
<<
" - Shader Mutator failure"
<<
CGoGNendl
;
}
return
condition
;
}
bool
ClippingShader
::
errorRaiseParameterIsNotPositive
(
bool
condition
,
const
std
::
string
&
location
,
const
std
::
string
&
paramName
)
{
if
(
condition
)
...
...
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