Commit a244ca3e authored by Sylvain Thery's avatar Sylvain Thery

less static in GLSLShader & support mac retina

parent 57c9da21
......@@ -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
......
......@@ -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
}
};
......
......@@ -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
......
......@@ -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 150\n");
std::string str("#version 330\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
......
......@@ -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);
}
......
......@@ -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.0f)
......
......@@ -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);
......
......@@ -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);
......
......@@ -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());
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
loadShadersFromMemory(gl3vert.c_str(), gl3frag.c_str());
// and treat uniforms
......
......@@ -50,11 +50,11 @@ ShaderPhongTexture::ShaderPhongTexture(bool doubleSided, bool withEyePosition):
// get choose GL defines (2 or 3)