Commit cd9abeae authored by CGoGN GIT Supervisor's avatar CGoGN GIT Supervisor

Merge branch 'master' of /home/untereiner/CGoGN

Conflicts:
	src/Utils/Shaders/shaderPhong.cpp
parents 5fdea41b fe862a0e
......@@ -67,5 +67,5 @@ QT4_WRAP_UI( clipping_ui ../clipping.ui )
QT4_WRAP_CPP( clipping_moc ../clipping.h )
add_executable( clipping ../clipping.cpp ${clipping_ui} ${clipping_moc})
target_link_libraries( clipping
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
${CGoGN_LIBS_R} ${COMMON_LIBS} ${QT_LIBRARIES} )
......@@ -32,9 +32,67 @@ namespace Utils
{
#include "shaderPhong.vert"
#include "shaderPhong.frag"
//std::string ShaderPhong::vertexShaderText =
//"ATTRIBUTE vec3 VertexPosition, VertexNormal;\n"
//"#ifdef WITH_COLOR\n"
//"ATTRIBUTE vec3 VertexColor;\n"
//"#endif\n"
//"uniform mat4 ModelViewProjectionMatrix;\n"
//"uniform mat4 ModelViewMatrix;\n"
//"uniform mat4 NormalMatrix;\n"
//"uniform vec3 lightPosition;\n"
//"VARYING_VERT vec3 EyeVector, Normal, LightDir;\n"
//"#ifdef WITH_COLOR\n"
//"VARYING_VERT vec3 Color;\n"
//"#endif\n"
//"INVARIANT_POS;\n"
//"void main ()\n"
//"{\n"
//" Normal = vec3 (NormalMatrix * vec4 (VertexNormal, 0.0));\n"
//" vec3 Position = vec3 (ModelViewMatrix * vec4 (VertexPosition, 1.0));\n"
//" LightDir = lightPosition - Position;\n"
//" EyeVector = -Position;\n"
//" #ifdef WITH_COLOR\n"
//" Color = VertexColor;\n"
//" #endif\n"
//" gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);\n"
//"}";
ShaderPhong::ShaderPhong(bool doubleSided):
//std::string ShaderPhong::fragmentShaderText =
//"PRECISON;\n"
//"VARYING_FRAG vec3 EyeVector, Normal, LightDir;\n"
//"#ifdef WITH_COLOR\n"
//"VARYING_FRAG vec3 Color;\n"
//"#endif\n"
//"uniform vec4 materialDiffuse;\n"
//"uniform vec4 materialSpecular;\n"
//"uniform vec4 materialAmbient;\n"
//"uniform float shininess;\n"
//"FRAG_OUT_DEF;\n"
//"void main()\n"
//"{\n"
//" vec3 N = normalize (Normal);\n"
//" vec3 L = normalize (LightDir);\n"
//" float lambertTerm = dot(N,L);\n"
//
//" vec4 finalColor = materialAmbient;\n"
//" if(lambertTerm > 0.0)\n"
//" {\n"
//" #ifndef WITH_COLOR\n"
//" finalColor += materialDiffuse * lambertTerm;\n"
//" #else\n"
//" finalColor += vec4((Color*lambertTerm),0.0) ;\n"
//" #endif\n"
//" vec3 E = normalize(EyeVector);\n"
//" vec3 R = reflect(-L, N);\n"
//" float specular = pow( max(dot(R, E), 0.0), shininess );\n"
//" finalColor += materialSpecular * specular;\n"
//" }\n"
//" gl_FragColor=finalColor;\n"
//"}";
ShaderPhong::ShaderPhong():
m_with_color(false),
m_ambiant(Geom::Vec4f(0.05f,0.05f,0.1f,0.0f)),
m_diffuse(Geom::Vec4f(0.1f,1.0f,0.1f,0.0f)),
......@@ -45,19 +103,11 @@ ShaderPhong::ShaderPhong(bool doubleSided):
m_vboNormal(NULL),
m_vboColor(NULL)
{
m_nameVS = "ShaderPhong_vs";
m_nameFS = "ShaderPhong_fs";
m_nameGS = "ShaderPhong_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);
// Use double sided lighting if set
if (doubleSided)
glxfrag.append("#define DOUBLE_SIDED\n");
glxfrag.append(fragmentShaderText);
loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str());
......@@ -182,12 +232,14 @@ void ShaderPhong::restoreUniformsAttribs()
getLocations();
bind();
sendParams();
bindVA_VBO("VertexPosition", m_vboPos);
bindVA_VBO("VertexNormal", m_vboNormal);
if (m_vboColor)
bindVA_VBO("VertexColor", m_vboColor);
unbind();
}
......
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