Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
David Cazier
CGoGN
Commits
a244ca3e
Commit
a244ca3e
authored
Mar 17, 2015
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
less static in GLSLShader & support mac retina
parent
57c9da21
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
205 additions
and
155 deletions
+205
-155
CGoGN/include/Utils/GLSLShader.h
CGoGN/include/Utils/GLSLShader.h
+13
-14
CGoGN/include/Utils/Qt/qtQGLV_glw.h
CGoGN/include/Utils/Qt/qtQGLV_glw.h
+8
-0
CGoGN/include/Utils/Qt/qtgl.h
CGoGN/include/Utils/Qt/qtgl.h
+9
-0
CGoGN/src/Utils/GLSLShader.cpp
CGoGN/src/Utils/GLSLShader.cpp
+85
-61
CGoGN/src/Utils/Qt/qtQGLV_glw.cpp
CGoGN/src/Utils/Qt/qtQGLV_glw.cpp
+4
-5
CGoGN/src/Utils/Qt/qtgl.cpp
CGoGN/src/Utils/Qt/qtgl.cpp
+5
-5
CGoGN/src/Utils/Shaders/shaderColorPerVertex.cpp
CGoGN/src/Utils/Shaders/shaderColorPerVertex.cpp
+4
-4
CGoGN/src/Utils/Shaders/shaderCustom.cpp
CGoGN/src/Utils/Shaders/shaderCustom.cpp
+2
-2
CGoGN/src/Utils/Shaders/shaderCustomTex.cpp
CGoGN/src/Utils/Shaders/shaderCustomTex.cpp
+2
-2
CGoGN/src/Utils/Shaders/shaderEnvMap.cpp
CGoGN/src/Utils/Shaders/shaderEnvMap.cpp
+6
-6
CGoGN/src/Utils/Shaders/shaderExplodeSmoothVolumes.cpp
CGoGN/src/Utils/Shaders/shaderExplodeSmoothVolumes.cpp
+2
-2
CGoGN/src/Utils/Shaders/shaderExplodeVolumes.cpp
CGoGN/src/Utils/Shaders/shaderExplodeVolumes.cpp
+2
-2
CGoGN/src/Utils/Shaders/shaderExplodeVolumesLines.cpp
CGoGN/src/Utils/Shaders/shaderExplodeVolumesLines.cpp
+2
-2
CGoGN/src/Utils/Shaders/shaderFlat.cpp
CGoGN/src/Utils/Shaders/shaderFlat.cpp
+2
-2
CGoGN/src/Utils/Shaders/shaderFlatColor.cpp
CGoGN/src/Utils/Shaders/shaderFlatColor.cpp
+2
-2
CGoGN/src/Utils/Shaders/shaderIsoLines.cpp
CGoGN/src/Utils/Shaders/shaderIsoLines.cpp
+2
-2
CGoGN/src/Utils/Shaders/shaderMatCustom.cpp
CGoGN/src/Utils/Shaders/shaderMatCustom.cpp
+6
-6
CGoGN/src/Utils/Shaders/shaderPhong.cpp
CGoGN/src/Utils/Shaders/shaderPhong.cpp
+6
-6
CGoGN/src/Utils/Shaders/shaderPhongTexture.cpp
CGoGN/src/Utils/Shaders/shaderPhongTexture.cpp
+2
-2
CGoGN/src/Utils/Shaders/shaderRadiancePerVertex.cpp
CGoGN/src/Utils/Shaders/shaderRadiancePerVertex.cpp
+2
-2
CGoGN/src/Utils/Shaders/shaderScalarField.cpp
CGoGN/src/Utils/Shaders/shaderScalarField.cpp
+2
-2
CGoGN/src/Utils/Shaders/shaderSimpleColor.cpp
CGoGN/src/Utils/Shaders/shaderSimpleColor.cpp
+4
-4
CGoGN/src/Utils/Shaders/shaderSimpleFlat.cpp
CGoGN/src/Utils/Shaders/shaderSimpleFlat.cpp
+6
-6
CGoGN/src/Utils/Shaders/shaderSimpleTexture.cpp
CGoGN/src/Utils/Shaders/shaderSimpleTexture.cpp
+2
-2
CGoGN/src/Utils/Shaders/shaderTextureDepth.cpp
CGoGN/src/Utils/Shaders/shaderTextureDepth.cpp
+2
-2
CGoGN/src/Utils/Shaders/shaderTextureMask.cpp
CGoGN/src/Utils/Shaders/shaderTextureMask.cpp
+2
-2
CGoGN/src/Utils/Shaders/shaderVectorPerVertex.cpp
CGoGN/src/Utils/Shaders/shaderVectorPerVertex.cpp
+2
-2
CGoGN/src/Utils/Shaders/shaderWallPaper.cpp
CGoGN/src/Utils/Shaders/shaderWallPaper.cpp
+2
-2
CGoGN/src/Utils/pointSprite.cpp
CGoGN/src/Utils/pointSprite.cpp
+2
-2
CGoGN/src/Utils/text3d.cpp
CGoGN/src/Utils/text3d.cpp
+2
-2
SCHNApps/include/view.h
SCHNApps/include/view.h
+9
-0
SCHNApps/src/view.cpp
SCHNApps/src/view.cpp
+4
-2
No files found.
CGoGN/include/Utils/GLSLShader.h
View file @
a244ca3e
...
...
@@ -65,26 +65,25 @@ public:
*/
enum
shaderType
{
VERTEX_SHADER
=
1
,
FRAGMENT_SHADER
=
2
,
GEOMETRY_SHADER
=
3
};
static
unsigned
int
CURRENT_OGL_VERSION
;
static
unsigned
int
MAJOR_OGL_CORE
;
static
unsigned
int
MINOR_OGL_CORE
;
#ifdef CGOGN_USE_OGL_CORE_PROFILE
static
const
unsigned
int
CURRENT_OGL_VERSION
=
3
;
static
const
unsigned
int
MAJOR_OGL_CORE
=
3
;
static
const
unsigned
int
MINOR_OGL_CORE
=
3
;
#else
static
const
unsigned
int
CURRENT_OGL_VERSION
=
2
;
static
const
unsigned
int
MAJOR_OGL_CORE
=
2
;
static
const
unsigned
int
MINOR_OGL_CORE
=
1
;
#endif
static
std
::
set
<
std
::
pair
<
void
*
,
GLSLShader
*>
>*
m_registeredShaders
;
// static glm::mat4* s_current_matrices;
static
Utils
::
GL_Matrices
*
s_current_matrices
;
protected:
static
std
::
string
DEFINES_GL2
;
static
std
::
string
DEFINES_GL3
;
static
std
::
string
*
DEFINES_GL
;
static
std
::
string
defines_Geom
(
const
std
::
string
&
primitivesIn
,
const
std
::
string
&
primitivesOut
,
int
maxVert
);
static
std
::
string
defines_gl
();
int
m_nbMaxVertices
;
GLuint
m_vao
;
...
...
@@ -210,9 +209,9 @@ public:
*/
virtual
~
GLSLShader
();
static
void
setCurrentOGLVersion
(
unsigned
int
version
);
//
static void setCurrentOGLVersion(unsigned int version);
static
void
setCurrentOGLVersion
(
unsigned
int
major
,
unsigned
int
minor
);
//
static void setCurrentOGLVersion(unsigned int major,unsigned int minor);
/*
* search file in different path
...
...
CGoGN/include/Utils/Qt/qtQGLV_glw.h
View file @
a244ca3e
...
...
@@ -107,6 +107,14 @@ public:
QSize
minimumSizeHint
()
const
;
QSize
sizeHint
()
const
;
inline
int
pixelRatio
()
const
{
#if (QT_VERSION>>16) == 5
return
this
->
devicePixelRatio
();
#else
return
1
;
#endif
}
};
...
...
CGoGN/include/Utils/Qt/qtgl.h
View file @
a244ca3e
...
...
@@ -250,6 +250,15 @@ protected:
* get the focale distance
*/
float
getScale
()
{
return
scalefactor
/
foc
;
}
inline
int
pixelRatio
()
const
{
#if (QT_VERSION>>16) == 5
return
this
->
devicePixelRatio
();
#else
return
1
;
#endif
}
};
}
// namespace QT
...
...
CGoGN/src/Utils/GLSLShader.cpp
View file @
a244ca3e
...
...
@@ -39,44 +39,43 @@ namespace CGoGN
namespace
Utils
{
#ifdef CGOGN_USE_OGL_CORE_PROFILE
unsigned
int
GLSLShader
::
CURRENT_OGL_VERSION
=
3
;
unsigned
int
GLSLShader
::
MAJOR_OGL_CORE
=
3
;
unsigned
int
GLSLShader
::
MINOR_OGL_CORE
=
3
;
#else
unsigned
int
GLSLShader
::
CURRENT_OGL_VERSION
=
2
;
unsigned
int
GLSLShader
::
MAJOR_OGL_CORE
=
2
;
unsigned
int
GLSLShader
::
MINOR_OGL_CORE
=
1
;
#endif
std
::
string
GLSLShader
::
DEFINES_GL2
=
\
"#version 110
\n
"
"#define PRECISION float pipo_PRECISION
\n
"
"#define ATTRIBUTE attribute
\n
"
"#define VARYING_VERT varying
\n
"
"#define VARYING_FRAG varying
\n
"
"#define FRAG_OUT_DEF float pipo_FRAGDEF
\n
"
"#define FRAG_OUT gl_FragColor
\n
"
"#define INVARIANT_POS float pipo_INVARIANT
\n
"
"#define TEXTURE2D texture2D
\n
"
;
std
::
string
GLSLShader
::
DEFINES_GL3
=
\
"#version 150
\n
"
"#define PRECISION precision highp float
\n
"
"#define ATTRIBUTE in
\n
"
"#define VARYING_VERT out
\n
"
"#define VARYING_FRAG in
\n
"
"#define FRAG_OUT_DEF out vec4 outFragColor
\n
"
"#define FRAG_OUT outFragColor
\n
"
"#define INVARIANT_POS invariant gl_Position
\n
"
"#define TEXTURE2D texture
\n
"
;
std
::
string
*
GLSLShader
::
DEFINES_GL
=
NULL
;
//#ifdef CGOGN_USE_OGL_CORE_PROFILE
//unsigned int GLSLShader::CURRENT_OGL_VERSION = 3;
//unsigned int GLSLShader::MAJOR_OGL_CORE = 3;
//unsigned int GLSLShader::MINOR_OGL_CORE = 3;
//#else
//unsigned int GLSLShader::CURRENT_OGL_VERSION = 2;
//unsigned int GLSLShader::MAJOR_OGL_CORE = 2;
//unsigned int GLSLShader::MINOR_OGL_CORE = 1;
//#endif
//std::string GLSLShader::DEFINES_GL2=\
//"#version 110\n"
//"#define PRECISION float pipo_PRECISION\n"
//"#define ATTRIBUTE attribute\n"
//"#define VARYING_VERT varying\n"
//"#define VARYING_FRAG varying\n"
//"#define FRAG_OUT_DEF float pipo_FRAGDEF\n"
//"#define FRAG_OUT gl_FragColor\n"
//"#define INVARIANT_POS float pipo_INVARIANT\n"
//"#define TEXTURE2D texture2D\n";
//std::string GLSLShader::DEFINES_GL3=\
//"#version 150\n"
//"#define PRECISION precision highp float\n"
//"#define ATTRIBUTE in\n"
//"#define VARYING_VERT out\n"
//"#define VARYING_FRAG in\n"
//"#define FRAG_OUT_DEF out vec4 outFragColor\n"
//"#define FRAG_OUT outFragColor\n"
//"#define INVARIANT_POS invariant gl_Position\n"
//"#define TEXTURE2D texture\n";
//std::string* GLSLShader::DEFINES_GL = NULL;
std
::
vector
<
std
::
string
>
GLSLShader
::
m_pathes
;
...
...
@@ -100,8 +99,8 @@ GLSLShader::GLSLShader() :
*
m_uniMat_ModelProj
=
-
1
;
*
m_uniMat_Normal
=
-
1
;
if
(
DEFINES_GL
==
NULL
)
setCurrentOGLVersion
(
MAJOR_OGL_CORE
,
MINOR_OGL_CORE
);
//
if (DEFINES_GL == NULL)
//
setCurrentOGLVersion(MAJOR_OGL_CORE,MINOR_OGL_CORE);
m_nbMaxVertices
=
16
;
...
...
@@ -119,11 +118,36 @@ void GLSLShader::unregisterShader(void* ptr, GLSLShader* shader)
m_registeredShaders
->
erase
(
std
::
pair
<
void
*
,
GLSLShader
*>
(
ptr
,
shader
));
}
std
::
string
GLSLShader
::
defines_gl
()
{
#ifdef CGOGN_USE_OGL_CORE_PROFILE
return
std
::
string
(
"#version 330
\n
\
#define PRECISION precision highp float
\n
\
#define ATTRIBUTE in
\n
\
#define VARYING_VERT out
\n
\
#define VARYING_FRAG in
\n
\
#define FRAG_OUT_DEF out vec4 outFragColor
\n
\
#define FRAG_OUT outFragColor
\n
\
#define INVARIANT_POS invariant gl_Position
\n
\
#define TEXTURE2D texture
\n
"
);
#else
return
std
::
string
(
"#version 110
\n
\
#define PRECISION float pipo_PRECISION
\n
\
#define ATTRIBUTE attribute
\n
\
#define VARYING_VERT varying
\n
\
#define VARYING_FRAG varying
\n
\
#define FRAG_OUT_DEF float pipo_FRAGDEF
\n
\
#define FRAG_OUT gl_FragColor
\n
\
#define INVARIANT_POS float pipo_INVARIANT
\n
\
#define TEXTURE2D texture2D
\n
"
);
#endif
}
std
::
string
GLSLShader
::
defines_Geom
(
const
std
::
string
&
primitivesIn
,
const
std
::
string
&
primitivesOut
,
int
maxVert
)
{
if
(
CURRENT_OGL_VERSION
>=
3
)
{
std
::
string
str
(
"#version
15
0
\n
"
);
std
::
string
str
(
"#version
33
0
\n
"
);
str
.
append
(
"precision highp float;
\n
"
);
str
.
append
(
"layout ("
);
str
.
append
(
primitivesIn
);
...
...
@@ -1042,26 +1066,26 @@ void GLSLShader::unbindVA(const std::string& name)
CGoGNerr
<<
"GLSLShader: Attribute "
<<
name
<<
" not binded"
<<
CGoGNendl
;
}
void
GLSLShader
::
setCurrentOGLVersion
(
unsigned
int
version
)
{
CURRENT_OGL_VERSION
=
version
;
switch
(
version
)
{
case
2
:
DEFINES_GL
=
&
DEFINES_GL2
;
break
;
case
3
:
DEFINES_GL
=
&
DEFINES_GL3
;
break
;
}
}
void
GLSLShader
::
setCurrentOGLVersion
(
unsigned
int
major
,
unsigned
int
minor
)
{
setCurrentOGLVersion
(
major
);
MAJOR_OGL_CORE
=
major
;
MINOR_OGL_CORE
=
minor
;
}
//
void GLSLShader::setCurrentOGLVersion(unsigned int version)
//
{
//
CURRENT_OGL_VERSION = version;
//
switch(version)
//
{
//
case 2:
//
DEFINES_GL = &DEFINES_GL2;
//
break;
//
case 3:
//
DEFINES_GL = &DEFINES_GL3;
//
break;
//
}
//
}
//
void GLSLShader::setCurrentOGLVersion(unsigned int major,unsigned int minor)
//
{
//
setCurrentOGLVersion(major);
//
MAJOR_OGL_CORE = major;
//
MINOR_OGL_CORE = minor;
//
}
/**
* update projection, modelview, ... matrices
...
...
CGoGN/src/Utils/Qt/qtQGLV_glw.cpp
View file @
a244ca3e
...
...
@@ -167,15 +167,14 @@ void QGLView::mousePressEvent(QMouseEvent* event)
// clickPoint = event->pos();
m_current_button
=
event
->
button
();
if
(
m_sqgl
)
m_sqgl
->
cb_mousePress
(
event
->
button
(),
event
->
x
(),
getHeight
()
-
event
->
y
());
m_sqgl
->
cb_mousePress
(
event
->
button
(),
event
->
x
()
*
pixelRatio
(),
getHeight
()
-
event
->
y
()
*
pixelRatio
());
QGLViewer
::
mousePressEvent
(
event
);
}
void
QGLView
::
mouseReleaseEvent
(
QMouseEvent
*
event
)
{
if
(
m_sqgl
)
m_sqgl
->
cb_mouseRelease
(
event
->
button
(),
event
->
x
()
,
getHeight
()
-
event
->
y
());
m_sqgl
->
cb_mouseRelease
(
event
->
button
(),
event
->
x
()
*
pixelRatio
(),
getHeight
()
-
event
->
y
()
*
pixelRatio
());
m_current_button
=
0
;
QGLViewer
::
mouseReleaseEvent
(
event
);
}
...
...
@@ -183,13 +182,13 @@ void QGLView::mouseReleaseEvent(QMouseEvent* event)
void
QGLView
::
mouseClickEvent
(
QMouseEvent
*
event
)
{
if
(
m_sqgl
)
m_sqgl
->
cb_mouseClick
(
event
->
button
(),
event
->
x
()
,
getHeight
()
-
event
->
y
());
m_sqgl
->
cb_mouseClick
(
event
->
button
(),
event
->
x
()
*
pixelRatio
(),
getHeight
()
-
event
->
y
()
*
pixelRatio
());
}
void
QGLView
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
if
(
m_sqgl
)
m_sqgl
->
cb_mouseMove
(
m_current_button
,
event
->
x
()
,
getHeight
()
-
event
->
y
());
m_sqgl
->
cb_mouseMove
(
m_current_button
,
event
->
x
()
*
pixelRatio
(),
getHeight
()
-
event
->
y
()
*
pixelRatio
());
QGLViewer
::
mouseMoveEvent
(
event
);
}
...
...
CGoGN/src/Utils/Qt/qtgl.cpp
View file @
a244ca3e
...
...
@@ -256,14 +256,14 @@ void GLWidget::mousePressEvent(QMouseEvent* event)
m_current_button
=
event
->
button
();
if
(
m_cbs
)
m_cbs
->
cb_mousePress
(
event
->
button
(),
event
->
x
()
,
getHeight
()
-
event
->
y
());
m_cbs
->
cb_mousePress
(
event
->
button
(),
event
->
x
()
*
pixelRatio
(),
getHeight
()
-
event
->
y
()
*
pixelRatio
());
setFocus
(
Qt
::
MouseFocusReason
);
}
void
GLWidget
::
mouseReleaseEvent
(
QMouseEvent
*
event
)
{
if
(
m_cbs
)
m_cbs
->
cb_mouseRelease
(
event
->
button
(),
event
->
x
()
,
getHeight
()
-
event
->
y
());
m_cbs
->
cb_mouseRelease
(
event
->
button
(),
event
->
x
()
*
pixelRatio
(),
getHeight
()
-
event
->
y
()
*
pixelRatio
());
if
(
event
->
pos
()
==
clickPoint
)
mouseClickEvent
(
event
)
;
...
...
@@ -273,15 +273,15 @@ void GLWidget::mouseClickEvent(QMouseEvent* event)
{
if
(
m_cbs
)
m_cbs
->
cb_mouseClick
(
event
->
button
(),
event
->
x
()
,
getHeight
()
-
event
->
y
());
m_cbs
->
cb_mouseClick
(
event
->
button
(),
event
->
x
()
*
pixelRatio
(),
getHeight
()
-
event
->
y
()
*
pixelRatio
());
}
void
GLWidget
::
mouseDoubleClickEvent
(
QMouseEvent
*
event
)
{
if
(
event
->
button
()
==
1
)
{
GLint
x
=
event
->
x
();
GLint
y
=
getHeight
()
-
event
->
y
();
GLint
x
=
event
->
x
()
*
pixelRatio
()
;
GLint
y
=
getHeight
()
-
event
->
y
()
*
pixelRatio
()
;
GLfloat
depth
;
glReadPixels
(
x
,
y
,
1
,
1
,
GL_DEPTH_COMPONENT
,
GL_FLOAT
,
&
depth
);
if
(
depth
<
1.0
f
)
...
...
CGoGN/src/Utils/Shaders/shaderColorPerVertex.cpp
View file @
a244ca3e
...
...
@@ -45,10 +45,10 @@ ShaderColorPerVertex::ShaderColorPerVertex(bool withClipping, bool black_is_tran
m_nameFS
=
"ShaderColorPerVertexClip_fs"
;
m_nameGS
=
""
;
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxvert
(
GLSLShader
::
defines_gl
()
);
glxvert
.
append
(
vertexShaderClipText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxfrag
(
GLSLShader
::
defines_gl
()
);
if
(
black_is_transparent
)
glxfrag
.
append
(
"#define BLACK_TRANSPARENCY 1
\n
"
);
glxfrag
.
append
(
fragmentShaderClipText
);
...
...
@@ -65,10 +65,10 @@ ShaderColorPerVertex::ShaderColorPerVertex(bool withClipping, bool black_is_tran
m_nameFS
=
"ShaderColorPerVertex_fs"
;
m_nameGS
=
"ShaderColorPerVertex_gs"
;
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxvert
(
GLSLShader
::
defines_gl
()
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxfrag
(
GLSLShader
::
defines_gl
()
);
if
(
black_is_transparent
)
glxfrag
.
append
(
"#define BLACK_TRANSPARENCY 1
\n
"
);
glxfrag
.
append
(
fragmentShaderText
);
...
...
CGoGN/src/Utils/Shaders/shaderCustom.cpp
View file @
a244ca3e
...
...
@@ -16,13 +16,13 @@ ShaderCustom::ShaderCustom()
m_nameFS
=
"ShaderCustom_fs"
;
m_nameGS
=
"ShaderCustom_gs"
;
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxvert
(
GLSLShader
::
defines_gl
()
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxgeom
=
GLSLShader
::
defines_Geom
(
"triangles"
,
"triangle_strip"
,
3
);
glxgeom
.
append
(
geometryShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxfrag
(
GLSLShader
::
defines_gl
()
);
glxfrag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
(),
glxgeom
.
c_str
(),
GL_TRIANGLES
,
GL_TRIANGLE_STRIP
,
3
);
...
...
CGoGN/src/Utils/Shaders/shaderCustomTex.cpp
View file @
a244ca3e
...
...
@@ -60,13 +60,13 @@ m_col(1)
m_nameFS
=
"ShaderCustomTex_fs"
;
m_nameGS
=
"ShaderCustomTex_gs"
;
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxvert
(
GLSLShader
::
defines_gl
()
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxgeom
=
GLSLShader
::
defines_Geom
(
"triangles"
,
"triangle_strip"
,
3
);
glxgeom
.
append
(
geometryShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxfrag
(
GLSLShader
::
defines_gl
()
);
glxfrag
.
append
(
fragmentShaderText
);
// loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str());
...
...
CGoGN/src/Utils/Shaders/shaderEnvMap.cpp
View file @
a244ca3e
...
...
@@ -52,11 +52,11 @@ ShaderEnvMap::ShaderEnvMap(bool doubleSided, bool withEyePosition):
// get choose GL defines (2 or 3)
// ans compile shaders
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxvert
(
GLSLShader
::
defines_gl
()
);
if
(
m_with_eyepos
)
glxvert
.
append
(
"#define WITH_EYEPOSITION"
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxfrag
(
GLSLShader
::
defines_gl
()
);
// Use double sided lighting if set
if
(
doubleSided
)
glxfrag
.
append
(
"#define DOUBLE_SIDED
\n
"
);
...
...
@@ -171,10 +171,10 @@ unsigned int ShaderEnvMap::setAttributeColor(VBO* vbo)
{
m_with_color
=
true
;
// set the define and recompile shader
std
::
string
gl3vert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
gl3vert
(
GLSLShader
::
defines_gl
()
);
gl3vert
.
append
(
"#define WITH_COLOR 1
\n
"
);
gl3vert
.
append
(
vertexShaderText
);
std
::
string
gl3frag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
gl3frag
(
GLSLShader
::
defines_gl
()
);
gl3frag
.
append
(
"#define WITH_COLOR 1
\n
"
);
gl3frag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
gl3vert
.
c_str
(),
gl3frag
.
c_str
());
...
...
@@ -201,9 +201,9 @@ void ShaderEnvMap::unsetAttributeColor()
unbindVA
(
"VertexColor"
);
unbind
();
// recompile shader
std
::
string
gl3vert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
gl3vert
(
GLSLShader
::
defines_gl
()
);
gl3vert
.
append
(
vertexShaderText
);
std
::
string
gl3frag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
gl3frag
(
GLSLShader
::
defines_gl
()
);
gl3frag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
gl3vert
.
c_str
(),
gl3frag
.
c_str
());
// and treat uniforms
...
...
CGoGN/src/Utils/Shaders/shaderExplodeSmoothVolumes.cpp
View file @
a244ca3e
...
...
@@ -44,7 +44,7 @@ ShaderExplodeSmoothVolumes::ShaderExplodeSmoothVolumes(bool withColorPerFace, bo
m_nameFS
=
"ShaderExplodeSmoothVolumes_fs"
;
m_nameGS
=
"ShaderExplodeSmoothVolumes_gs"
;
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxvert
(
GLSLShader
::
defines_gl
()
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxgeom
;
...
...
@@ -56,7 +56,7 @@ ShaderExplodeSmoothVolumes::ShaderExplodeSmoothVolumes(bool withColorPerFace, bo
glxgeom
.
append
(
"#define WITH_EXPLODE_FACE 1
\n
"
);
glxgeom
.
append
(
geometryShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxfrag
(
GLSLShader
::
defines_gl
()
);
glxfrag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
(),
glxgeom
.
c_str
(),
GL_LINES_ADJACENCY_EXT
,
GL_TRIANGLE_STRIP
,
4
);
...
...
CGoGN/src/Utils/Shaders/shaderExplodeVolumes.cpp
View file @
a244ca3e
...
...
@@ -44,7 +44,7 @@ ShaderExplodeVolumes::ShaderExplodeVolumes(bool withColorPerFace, bool withExplo
m_nameFS
=
"ShaderExplodeVolumes_fs"
;
m_nameGS
=
"ShaderExplodeVolumes_gs"
;
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxvert
(
GLSLShader
::
defines_gl
()
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxgeom
;
...
...
@@ -56,7 +56,7 @@ ShaderExplodeVolumes::ShaderExplodeVolumes(bool withColorPerFace, bool withExplo
glxgeom
.
append
(
"#define WITH_EXPLODE_FACE 1
\n
"
);
glxgeom
.
append
(
geometryShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxfrag
(
GLSLShader
::
defines_gl
()
);
glxfrag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
(),
glxgeom
.
c_str
(),
GL_LINES_ADJACENCY_EXT
,
GL_TRIANGLE_STRIP
,
4
);
...
...
CGoGN/src/Utils/Shaders/shaderExplodeVolumesLines.cpp
View file @
a244ca3e
...
...
@@ -42,13 +42,13 @@ ShaderExplodeVolumesLines::ShaderExplodeVolumesLines()
m_nameFS
=
"ShaderExplodeVolumesLines_fs"
;
m_nameGS
=
"ShaderExplodeVolumesLines_gs"
;
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxvert
(
GLSLShader
::
defines_gl
()
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxgeom
(
GLSLShader
::
defines_Geom
(
"triangles"
,
"line_strip"
,
4
));
glxgeom
.
append
(
geometryShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxfrag
(
GLSLShader
::
defines_gl
()
);
glxfrag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
(),
glxgeom
.
c_str
(),
GL_TRIANGLES
,
GL_LINE_STRIP
,
4
);
...
...
CGoGN/src/Utils/Shaders/shaderFlat.cpp
View file @
a244ca3e
...
...
@@ -42,13 +42,13 @@ ShaderFlat::ShaderFlat()
m_nameFS
=
"ShaderFlat_fs"
;
m_nameGS
=
"ShaderFlat_gs"
;
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxvert
(
GLSLShader
::
defines_gl
()
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxgeom
=
GLSLShader
::
defines_Geom
(
"triangles"
,
"triangle_strip"
,
3
);
glxgeom
.
append
(
geometryShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxfrag
(
GLSLShader
::
defines_gl
()
);
glxfrag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
(),
glxgeom
.
c_str
(),
GL_TRIANGLES
,
GL_TRIANGLE_STRIP
,
3
);
...
...
CGoGN/src/Utils/Shaders/shaderFlatColor.cpp
View file @
a244ca3e
...
...
@@ -41,7 +41,7 @@ ShaderFlatColor::ShaderFlatColor(bool averageColor)
m_nameFS
=
"shaderFlatColor_fs"
;
m_nameGS
=
"shaderFlatColor_gs"
;
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxvert
(
GLSLShader
::
defines_gl
()
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxgeom
=
GLSLShader
::
defines_Geom
(
"triangles"
,
"triangle_strip"
,
3
);
...
...
@@ -49,7 +49,7 @@ ShaderFlatColor::ShaderFlatColor(bool averageColor)
glxgeom
.
append
(
"#define AVERAGE_COLOR 1
\n
"
);
glxgeom
.
append
(
geometryShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxfrag
(
GLSLShader
::
defines_gl
()
);
glxfrag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
(),
glxgeom
.
c_str
(),
GL_TRIANGLES
,
GL_TRIANGLE_STRIP
,
3
);
...
...
CGoGN/src/Utils/Shaders/shaderIsoLines.cpp
View file @
a244ca3e
...
...
@@ -42,13 +42,13 @@ ShaderIsoLines::ShaderIsoLines(int maxNbIsoPerTriangle)
m_nameFS
=
"shaderIsoLines_fs"
;
m_nameGS
=
"shaderIsoLines_gs"
;
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxvert
(
GLSLShader
::
defines_gl
()
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxgeom
=
GLSLShader
::
defines_Geom
(
"triangles"
,
"line_strip"
,
2
*
maxNbIsoPerTriangle
);
glxgeom
.
append
(
geometryShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxfrag
(
GLSLShader
::
defines_gl
()
);
glxfrag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
(),
glxgeom
.
c_str
(),
GL_TRIANGLES
,
GL_LINE_STRIP
,
2
*
maxNbIsoPerTriangle
);
...
...
CGoGN/src/Utils/Shaders/shaderMatCustom.cpp
View file @
a244ca3e
...
...
@@ -24,7 +24,7 @@ ShaderMatCustom::ShaderMatCustom(bool doubleSided, bool withEyePosition):
m_nameFS
=
"ShaderMatCustom_fs"
;
m_nameGS
=
"ShaderMatCustom_gs"
;
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxvert
(
GLSLShader
::
defines_gl
()
);
// get choose GL defines (2 or 3)
// ans compile shaders
if
(
m_with_eyepos
)
...
...
@@ -34,7 +34,7 @@ ShaderMatCustom::ShaderMatCustom(bool doubleSided, bool withEyePosition):
// std::string glxgeom = GLSLShader::defines_Geom("triangles", "triangle_strip", 3);
// glxgeom.append(geometryShaderText);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxfrag
(
GLSLShader
::
defines_gl
()
);
// Use double sided lighting if set
if
(
doubleSided
)
glxfrag
.
append
(
"#define DOUBLE_SIDED
\n
"
);
...
...
@@ -147,10 +147,10 @@ unsigned int ShaderMatCustom::setAttributeColor(CGoGN::Utils::VBO* vbo)
{
m_with_color
=
true
;
// set the define and recompile shader
std
::
string
gl3vert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
gl3vert
(
GLSLShader
::
defines_gl
()
);
gl3vert
.
append
(
"#define WITH_COLOR 1
\n
"
);
gl3vert
.
append
(
vertexShaderText
);
std
::
string
gl3frag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
gl3frag
(
GLSLShader
::
defines_gl
()
);
gl3frag
.
append
(
"#define WITH_COLOR 1
\n
"
);
gl3frag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
gl3vert
.
c_str
(),
gl3frag
.
c_str
());
...
...
@@ -177,9 +177,9 @@ void ShaderMatCustom::unsetAttributeColor()
unbindVA
(
"VertexColor"
);
unbind
();
// recompile shader
std
::
string
gl3vert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
gl3vert
(
GLSLShader
::
defines_gl
()
);
gl3vert
.
append
(
vertexShaderText
);
std
::
string
gl3frag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
gl3frag
(
GLSLShader
::
defines_gl
()
);
gl3frag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
gl3vert
.
c_str
(),
gl3frag
.
c_str
());
// and treat uniforms
...
...
CGoGN/src/Utils/Shaders/shaderPhong.cpp
View file @
a244ca3e
...
...
@@ -53,11 +53,11 @@ ShaderPhong::ShaderPhong(bool doubleSided, bool withEyePosition):
// get choose GL defines (2 or 3)
// ans compile shaders
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxvert
(
GLSLShader
::
defines_gl
()
);
if
(
m_with_eyepos
)
glxvert
.
append
(
"#define WITH_EYEPOSITION"
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
glxfrag
(
GLSLShader
::
defines_gl
()
);
// Use double sided lighting if set
if
(
doubleSided
)
glxfrag
.
append
(
"#define DOUBLE_SIDED
\n
"
);
...
...
@@ -164,10 +164,10 @@ unsigned int ShaderPhong::setAttributeColor(VBO* vbo)
{
m_with_color
=
true
;
// set the define and recompile shader
std
::
string
gl3vert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
gl3vert
(
GLSLShader
::
defines_gl
()
);
gl3vert
.
append
(
"#define WITH_COLOR 1
\n
"
);
gl3vert
.
append
(
vertexShaderText
);
std
::
string
gl3frag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
gl3frag
(
GLSLShader
::
defines_gl
()
);
gl3frag
.
append
(
"#define WITH_COLOR 1
\n
"
);
gl3frag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
gl3vert
.
c_str
(),
gl3frag
.
c_str
());
...
...
@@ -194,9 +194,9 @@ void ShaderPhong::unsetAttributeColor()
unbindVA
(
"VertexColor"
);
unbind
();
// recompile shader
std
::
string
gl3vert
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
gl3vert
(
GLSLShader
::
defines_gl
()
);
gl3vert
.
append
(
vertexShaderText
);
std
::
string
gl3frag
(
*
GLSLShader
::
DEFINES_GL
);
std
::
string
gl3frag
(
GLSLShader
::
defines_gl
()
);
gl3frag
.
append
(
fragmentShaderText
);