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
CGoGN
CGoGN
Commits
cd9abeae
Commit
cd9abeae
authored
Aug 19, 2011
by
CGoGN GIT Supervisor
Browse files
Merge branch 'master' of /home/untereiner/CGoGN
Conflicts: src/Utils/Shaders/shaderPhong.cpp
parents
5fdea41b
fe862a0e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Apps/Examples/Release/CMakeLists.txt
View file @
cd9abeae
...
...
@@ -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
}
)
src/Utils/Shaders/shaderPhong.cpp
View file @
cd9abeae
...
...
@@ -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.05
f
,
0.05
f
,
0.1
f
,
0.0
f
)),
m_diffuse
(
Geom
::
Vec4f
(
0.1
f
,
1.0
f
,
0.1
f
,
0.0
f
)),
...
...
@@ -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
();
}
...
...
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