Commit db2b293a authored by Sylvain Thery's avatar Sylvain Thery Committed by Pierre Kraemer

less static in GLSLShader & support mac retina

parent d5d75bd3
......@@ -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 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";
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;
......
......@@ -44,10 +44,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);
......@@ -64,10 +64,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);
......
......@@ -21,6 +21,7 @@
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#define CGoGN_UTILS_DLL_EXPORT 1
#include <GL/glew.h>
#include "Utils/Shaders/shaderPhong.h"
......@@ -36,7 +37,6 @@ namespace Utils
#include "shaderPhongClip.vert"
#include "shaderPhongClip.frag"
ShaderPhong::ShaderPhong(bool withClipping, bool doubleSided, bool withEyePosition):
m_with_color(false),
m_with_eyepos(withEyePosition),
......@@ -54,30 +54,17 @@ ShaderPhong::ShaderPhong(bool withClipping, bool doubleSided, bool withEyePositi
std::string glxvert(GLSLShader::defines_gl());
std::string glxfrag(GLSLShader::defines_gl());
if (withClipping)
{
m_nameVS = "ShaderPhongClip_vs";
m_nameFS = "ShaderPhongClip_fs";
if (m_with_eyepos)
glxvert.append("#define WITH_EYEPOSITION");
glxvert.append(vertexShaderClipText);
// Use double sided lighting if set
if (doubleSided)
glxfrag.append("#define DOUBLE_SIDED\n");
glxfrag.append(fragmentShaderClipText);
}
else
{
m_nameVS = "ShaderPhong_vs";
m_nameFS = "ShaderPhong_fs";
if (m_with_eyepos)
glxvert.append("#define WITH_EYEPOSITION");
glxvert.append(vertexShaderText);
// Use double sided lighting if set
if (doubleSided)
glxfrag.append("#define DOUBLE_SIDED\n");
glxfrag.append(fragmentShaderText);
}
// get choose GL defines (2 or 3)
// ans compile shaders
std::string glxvert(GLSLShader::defines_gl());
if (m_with_eyepos)
glxvert.append("#define WITH_EYEPOSITION");
glxvert.append(vertexShaderText);
std::string glxfrag(GLSLShader::defines_gl());
// Use double sided lighting if set
if (doubleSided)
glxfrag.append("#define DOUBLE_SIDED\n");
glxfrag.append(fragmentShaderText);
loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str());
......
......@@ -46,10 +46,10 @@ ShaderSimpleColor::ShaderSimpleColor(bool withClipping, bool black_is_transparen
// chose GL defines (2 or 3)
// and compile shaders
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);
......@@ -67,10 +67,10 @@ ShaderSimpleColor::ShaderSimpleColor(bool withClipping, bool black_is_transparen
// chose GL defines (2 or 3)
// and compile shaders
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);
......
......@@ -21,6 +21,7 @@
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#define CGoGN_UTILS_DLL_EXPORT 1
#include <GL/glew.h>
#include "Utils/Shaders/shaderSimpleFlat.h"
......@@ -36,8 +37,6 @@ namespace Utils
#include "shaderSimpleFlatClip.vert"
#include "shaderSimpleFlatClip.frag"
ShaderSimpleFlat::ShaderSimpleFlat(bool withClipping, bool doubleSided):
m_with_color(false),
m_ambiant(Geom::Vec4f(0.05f,0.05f,0.1f,0.0f)),
......@@ -48,8 +47,18 @@ ShaderSimpleFlat::ShaderSimpleFlat(bool withClipping, bool doubleSided):
m_vboColor(NULL),
m_planeClip(Geom::Vec4f(0.0f,0.0f,0.0f,0.0f))
{
m_nameVS = "ShaderSimpleFlat_vs";
m_nameFS = "ShaderSimpleFlat_fs";
// m_nameGS = "ShaderSimpleFlat_gs";
// get choose GL defines (2 or 3)
// ans compile shaders
std::string glxvert(GLSLShader::defines_gl());
glxvert.append(vertexShaderText);
std::string glxfrag(GLSLShader::defines_gl());
if (doubleSided)
glxfrag.append("#define DOUBLE_SIDED\n");
glxfrag.append(fragmentShaderText);
if (withClipping)
{
......@@ -117,7 +126,6 @@ void ShaderSimpleFlat::setDiffuse(const Geom::Vec4f& diffuse)
unbind();
}
void ShaderSimpleFlat::setLightPosition(const Geom::Vec3f& lightPos)
{
bind();
......@@ -126,7 +134,6 @@ void ShaderSimpleFlat::setLightPosition(const Geom::Vec3f& lightPos)
unbind();
}
void ShaderSimpleFlat::setBackColor(const Geom::Vec4f& back)
{
bind();
......@@ -135,7 +142,6 @@ void ShaderSimpleFlat::setBackColor(const Geom::Vec4f& back)
unbind();
}
void ShaderSimpleFlat::setParams(const Geom::Vec4f& ambiant, const Geom::Vec4f& diffuse, const Geom::Vec3f& lightPos)
{
m_ambiant = ambiant;
......@@ -225,8 +231,6 @@ void ShaderSimpleFlat::setClippingPlane(const Geom::Vec4f& plane)
}
}
} // namespace Utils
} // namespace CGoGN
......@@ -13,7 +13,7 @@
#include <QKeyEvent>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QMessageBox>
#include <QWindow>
namespace CGoGN
{
......@@ -337,6 +337,7 @@ void View::init()
m_buttonArea = new ViewButtonArea(this);
m_buttonArea->setTopRightPosition(this->width(), 0);
std::cout << this->width() << std::endl;
m_VsplitButton = new ViewButton(":icons/icons/Vsplit.png", this);
m_buttonArea->addButton(m_VsplitButton);
connect(m_VsplitButton, SIGNAL(clicked(int, int, int, int)), this, SLOT(ui_verticalSplitView(int, int, int, int)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment