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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hurstel
CGoGN
Commits
549167d9
Commit
549167d9
authored
Feb 14, 2014
by
boustila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update VRJ
parent
da400179
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
975 additions
and
4 deletions
+975
-4
include/Algo/Import/importObjTex.h
include/Algo/Import/importObjTex.h
+2
-0
include/Utils/Shaders/shaderCustom.frag
include/Utils/Shaders/shaderCustom.frag
+8
-0
include/Utils/Shaders/shaderCustom.geom
include/Utils/Shaders/shaderCustom.geom
+35
-0
include/Utils/Shaders/shaderCustom.h
include/Utils/Shaders/shaderCustom.h
+54
-0
include/Utils/Shaders/shaderCustom.vert
include/Utils/Shaders/shaderCustom.vert
+8
-0
include/Utils/Shaders/shaderCustomTex.frag
include/Utils/Shaders/shaderCustomTex.frag
+13
-0
include/Utils/Shaders/shaderCustomTex.geom
include/Utils/Shaders/shaderCustomTex.geom
+24
-0
include/Utils/Shaders/shaderCustomTex.h
include/Utils/Shaders/shaderCustomTex.h
+68
-0
include/Utils/Shaders/shaderCustomTex.vert
include/Utils/Shaders/shaderCustomTex.vert
+16
-0
include/Utils/Shaders/shaderMatCustom.frag
include/Utils/Shaders/shaderMatCustom.frag
+43
-0
include/Utils/Shaders/shaderMatCustom.geom
include/Utils/Shaders/shaderMatCustom.geom
+35
-0
include/Utils/Shaders/shaderMatCustom.h
include/Utils/Shaders/shaderMatCustom.h
+95
-0
include/Utils/Shaders/shaderMatCustom.vert
include/Utils/Shaders/shaderMatCustom.vert
+37
-0
include/Utils/gl_matrices.h
include/Utils/gl_matrices.h
+5
-4
src/Utils/Shaders/shaderCustom.cpp
src/Utils/Shaders/shaderCustom.cpp
+137
-0
src/Utils/Shaders/shaderCustomTex.cpp
src/Utils/Shaders/shaderCustomTex.cpp
+167
-0
src/Utils/Shaders/shaderMatCustom.cpp
src/Utils/Shaders/shaderMatCustom.cpp
+228
-0
No files found.
include/Algo/Import/importObjTex.h
View file @
549167d9
...
...
@@ -294,6 +294,8 @@ public:
const
Geom
::
BoundingBox
<
VEC3
>&
getGroupBB
(
unsigned
int
i
)
const
{
return
m_groupBBs
[
i
];}
Geom
::
BoundingBox
<
VEC3
>&
getGroupBB
(
unsigned
int
i
)
{
return
m_groupBBs
[
i
];}
const
std
::
string
&
objGroupName
(
unsigned
int
i
)
const
{
return
m_groupNames
[
i
];}
/**
...
...
include/Utils/Shaders/shaderCustom.frag
0 → 100644
View file @
549167d9
// ShaderCustom::fragmentShaderText
VARYING_FRAG
vec4
ColorFS
;
VARYING_FRAG
vec3
N
;
void
main
()
{
gl_FragData
[
0
]
=
ColorFS
;
gl_FragData
[
1
]
=
vec4
(
0
.
5
*
normalize
(
N
)
+
vec3
(
0
.
5
),
1
.
0
);
}
include/Utils/Shaders/shaderCustom.geom
0 → 100644
View file @
549167d9
// ShaderCustom::geometryShaderText
uniform
float
explode
;
uniform
mat4
ModelViewProjectionMatrix
;
uniform
mat4
NormalMatrix
;
uniform
mat4
ModelViewMatrix
;
uniform
vec3
lightPosition
;
uniform
vec4
diffuse
;
uniform
vec4
ambient
;
VARYING_OUT
vec4
ColorFS
;
VARYING_OUT
vec3
N
;
VARYING_OUT
vec2
texCoord
;
void
main
(
void
)
{
vec3
v1
=
POSITION_IN
(
1
).
xyz
-
POSITION_IN
(
0
).
xyz
;
vec3
v2
=
POSITION_IN
(
2
).
xyz
-
POSITION_IN
(
0
).
xyz
;
N
=
cross
(
v1
,
v2
);
N
=
normalize
(
vec3
(
NormalMatrix
*
vec4
(
N
,
0
.
0
)));
vec3
center
=
POSITION_IN
(
0
).
xyz
+
POSITION_IN
(
1
).
xyz
+
POSITION_IN
(
2
).
xyz
;
center
/=
3
.
0
;
vec4
newPos
=
ModelViewMatrix
*
vec4
(
center
,
0
.
0
);
vec3
L
=
normalize
(
lightPosition
-
newPos
.
xyz
);
float
lambertTerm
=
dot
(
N
,
L
);
ColorFS
=
ambient
;
if
(
lambertTerm
>
0
.
0
)
ColorFS
+=
diffuse
*
lambertTerm
;
int
i
;
for
(
i
=
0
;
i
<
NBVERTS_IN
;
i
++
)
{
vec4
pos
=
explode
*
POSITION_IN
(
i
)
+
(
1
.
0
-
explode
)
*
vec4
(
center
,
1
.
0
);
gl_Position
=
ModelViewProjectionMatrix
*
pos
;
EmitVertex
();
}
EndPrimitive
();
}
include/Utils/Shaders/shaderCustom.h
0 → 100644
View file @
549167d9
#ifndef __SHADER_CUSTOM__
#define __SHADER_CUSTOM__
#include "Utils/GLSLShader.h"
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
using
namespace
CGoGN
;
class
ShaderCustom
:
public
Utils
::
GLSLShader
{
protected:
// shader sources
static
std
::
string
vertexShaderText
;
static
std
::
string
fragmentShaderText
;
static
std
::
string
geometryShaderText
;
// uniform locations
CGoGNGLuint
m_unif_ambiant
;
CGoGNGLuint
m_unif_diffuse
;
CGoGNGLuint
m_unif_lightPos
;
CGoGNGLuint
m_unif_explode
;
float
m_explode
;
Geom
::
Vec4f
m_ambiant
;
Geom
::
Vec4f
m_diffuse
;
Geom
::
Vec3f
m_light_pos
;
Utils
::
VBO
*
m_vboPos
;
void
getLocations
();
void
restoreUniformsAttribs
();
public:
ShaderCustom
();
void
setExplode
(
float
explode
);
void
setAmbiant
(
const
Geom
::
Vec4f
&
ambiant
);
void
setDiffuse
(
const
Geom
::
Vec4f
&
diffuse
);
void
setLightPosition
(
const
Geom
::
Vec3f
&
lp
);
void
setParams
(
float
explode
,
const
Geom
::
Vec4f
&
ambiant
,
const
Geom
::
Vec4f
&
diffuse
,
const
Geom
::
Vec3f
&
lightPos
);
unsigned
int
setAttributePosition
(
Utils
::
VBO
*
vbo
);
void
setTransformation
(
Geom
::
Matrix44f
t
);
};
#endif
include/Utils/Shaders/shaderCustom.vert
0 → 100644
View file @
549167d9
// ShaderCustom::vertexShaderText
uniform
mat4
TransformationMatrix
;
uniform
mat4
ModelViewProjectionMatrix
;
ATTRIBUTE
vec3
VertexPosition
;
void
main
()
{
gl_Position
=
TransformationMatrix
*
vec4
(
VertexPosition
,
1
.
0
);
}
include/Utils/Shaders/shaderCustomTex.frag
0 → 100644
View file @
549167d9
// ShaderCustomTex::fragmentShaderText
PRECISON
;
uniform
sampler2D
textureUnit
;
in
vec3
N
;
in
vec2
fragTexCoord
;
uniform
vec4
ambient
;
FRAG_OUT_DEF
;
void
main
()
{
gl_FragData
[
0
]
=
ambient
*
texture2D
(
textureUnit
,
fragTexCoord
);
gl_FragData
[
1
]
=
vec4
(
0
.
5
*
normalize
(
N
)
+
vec3
(
0
.
5
),
1
.
0
);
}
\ No newline at end of file
include/Utils/Shaders/shaderCustomTex.geom
0 → 100644
View file @
549167d9
// ShaderCustomTex::geometryShaderText
VARYING_IN
vec2
texCoord
[];
VARYING_IN
vec3
Normal
[];
VARYING_OUT
vec2
fragTexCoord
;
VARYING_OUT
vec3
N
;
void
main
(
void
)
{
//vec3 v1 = POSITION_IN(1).xyz - POSITION_IN(0).xyz;
//vec3 v2 = POSITION_IN(2).xyz - POSITION_IN(0).xyz;
//N = cross(v1,v2);
//N = normalize(N);
int
i
;
for
(
i
=
0
;
i
<
NBVERTS_IN
;
i
++
)
{
gl_Position
=
POSITION_IN
(
i
);
fragTexCoord
=
texCoord
[
i
];
N
=
Normal
[
i
];
EmitVertex
();
}
EndPrimitive
();
}
include/Utils/Shaders/shaderCustomTex.h
0 → 100644
View file @
549167d9
#ifndef __SHADER_CUSTOMTEX__
#define __SHADER_CUSTOMTEX__
#include "Utils/GLSLShader.h"
#include "Geometry/vector_gen.h"
#include "Utils/clippingShader.h"
#include "Utils/textures.h"
#include "Utils/gl_def.h"
#include "Geometry/matrix.h"
using
namespace
CGoGN
;
class
ShaderCustomTex
:
public
Utils
::
ClippingShader
{
protected:
// shader sources
static
std
::
string
vertexShaderText
;
static
std
::
string
fragmentShaderText
;
static
std
::
string
geometryShaderText
;
CGoGNGLuint
m_unif_unit
;
int
m_unit
;
Geom
::
Vec4f
m_col
;
Utils
::
GTexture
*
m_tex_ptr
;
Utils
::
VBO
*
m_vboPos
;
Utils
::
VBO
*
m_vboNormal
;
Utils
::
VBO
*
m_vboTexCoord
;
void
restoreUniformsAttribs
();
public:
ShaderCustomTex
();
/**
* choose the texture unit engine to use for this texture
*/
void
setTextureUnit
(
GLenum
texture_unit
);
/**
* set the texture to use
*/
void
setTexture
(
Utils
::
GTexture
*
tex
);
/**
* activation of texture unit with set texture
*/
void
activeTexture
();
/**
* activation of texture unit with texture id
*/
void
activeTexture
(
CGoGNGLuint
texId
);
unsigned
int
setAttributePosition
(
Utils
::
VBO
*
vbo
);
unsigned
int
setAttributeNormal
(
Utils
::
VBO
*
vbo
);
unsigned
int
setAttributeTexCoord
(
Utils
::
VBO
*
vbo
);
void
setBaseColor
(
Geom
::
Vec4f
col
);
void
setTransformation
(
Geom
::
Matrix44f
t
);
};
#endif
include/Utils/Shaders/shaderCustomTex.vert
0 → 100644
View file @
549167d9
// ShaderCustomTex::vertexShaderText
ATTRIBUTE
vec3
VertexPosition
,
VertexNormal
;
ATTRIBUTE
vec2
VertexTexCoord
;
uniform
mat4
TransformationMatrix
;
uniform
mat4
ModelViewProjectionMatrix
;
VARYING_VERT
vec2
texCoord
;
VARYING_VERT
vec3
Normal
;
INVARIANT_POS
;
void
main
()
{
Normal
=
vec3
(
ModelViewProjectionMatrix
*
TransformationMatrix
*
vec4
(
VertexNormal
,
1
.
0
));
gl_Position
=
ModelViewProjectionMatrix
*
TransformationMatrix
*
vec4
(
VertexPosition
,
1
.
0
);
texCoord
=
VertexTexCoord
;
}
include/Utils/Shaders/shaderMatCustom.frag
0 → 100644
View file @
549167d9
//ShaderMatCustom::fragmentShaderText
PRECISON
;
VARYING_FRAG
vec3
EyeVector
,
Normal
,
LightDir
;
#ifdef WITH_COLOR
VARYING_FRAG
vec3
Color
;
#endif
uniform
vec4
materialDiffuse
;
uniform
vec4
materialSpecular
;
uniform
vec4
materialAmbient
;
uniform
float
shininess
;
FRAG_OUT_DEF
;
void
main
()
{
vec3
N
=
normalize
(
Normal
);
vec3
L
=
normalize
(
LightDir
);
//float lambertTerm = dot(N,L);
float
lambertTerm
=
0
.
15
*
dot
(
N
,
L
)
+
0
.
80
;
vec4
finalColor
=
materialAmbient
;
#ifdef DOUBLE_SIDED
if
(
lambertTerm
<
0
.
0
)
{
N
=
-
1
.
0
*
N
;
lambertTerm
=
-
1
.
0
*
lambertTerm
;
#else
if
(
lambertTerm
>
0
.
0
)
{
#endif
#ifndef WITH_COLOR
finalColor
+=
materialDiffuse
*
lambertTerm
;
#else
finalColor
+=
vec4
((
Color
*
lambertTerm
),
0
.
0
)
;
#endif
vec3
E
=
normalize
(
EyeVector
);
vec3
R
=
reflect
(
-
L
,
N
);
float
specular
=
pow
(
max
(
dot
(
R
,
E
),
0
.
0
),
shininess
);
finalColor
+=
materialSpecular
*
specular
;
}
gl_FragColor
=
finalColor
;
//gl_FragColor = vec4(lambertTerm,lambertTerm,lambertTerm,0);
}
include/Utils/Shaders/shaderMatCustom.geom
0 → 100644
View file @
549167d9
// ShaderMatCustom::geometryShaderText
uniform
float
explode
;
uniform
mat4
ModelViewProjectionMatrix
;
uniform
mat4
NormalMatrix
;
uniform
mat4
ModelViewMatrix
;
uniform
vec3
lightPosition
;
uniform
vec4
diffuse
;
uniform
vec4
ambient
;
//VARYING_OUT vec4 ColorFS;
VARYING_OUT
vec3
N
;
VARYING_OUT
vec2
texCoord
;
void
main
(
void
)
{
vec3
v1
=
POSITION_IN
(
1
).
xyz
-
POSITION_IN
(
0
).
xyz
;
vec3
v2
=
POSITION_IN
(
2
).
xyz
-
POSITION_IN
(
0
).
xyz
;
N
=
cross
(
v1
,
v2
);
N
=
normalize
(
vec3
(
NormalMatrix
*
vec4
(
N
,
0
.
0
)));
vec3
center
=
POSITION_IN
(
0
).
xyz
+
POSITION_IN
(
1
).
xyz
+
POSITION_IN
(
2
).
xyz
;
center
/=
3
.
0
;
vec4
newPos
=
ModelViewMatrix
*
vec4
(
center
,
0
.
0
);
vec3
L
=
normalize
(
lightPosition
-
newPos
.
xyz
);
float
lambertTerm
=
dot
(
N
,
L
);
ColorFS
=
ambient
;
if
(
lambertTerm
>
0
.
0
)
ColorFS
+=
diffuse
*
lambertTerm
;
int
i
;
for
(
i
=
0
;
i
<
NBVERTS_IN
;
i
++
)
{
vec4
pos
=
explode
*
POSITION_IN
(
i
)
+
(
1
.
0
-
explode
)
*
vec4
(
center
,
1
.
0
);
gl_Position
=
ModelViewProjectionMatrix
*
pos
;
EmitVertex
();
}
EndPrimitive
();
}
include/Utils/Shaders/shaderMatCustom.h
0 → 100644
View file @
549167d9
#ifndef SHADER_MATCUST
#define SHADER_MATCUST
#include "Utils/GLSLShader.h"
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
#include <string>
using
namespace
CGoGN
;
class
ShaderMatCustom
:
public
Utils
::
GLSLShader
{
protected:
// flag color per vertex or not
bool
m_with_color
;
// flag color per vertex or not
bool
m_with_eyepos
;
// shader sources OGL3
static
std
::
string
vertexShaderText
;
static
std
::
string
fragmentShaderText
;
static
std
::
string
geometryShaderText
;
// uniform locations
CGoGNGLuint
m_unif_ambiant
;
CGoGNGLuint
m_unif_diffuse
;
CGoGNGLuint
m_unif_specular
;
CGoGNGLuint
m_unif_shininess
;
CGoGNGLuint
m_unif_lightPos
;
CGoGNGLuint
m_unif_eyePos
;
//values
Geom
::
Vec4f
m_ambiant
;
Geom
::
Vec4f
m_diffuse
;
Geom
::
Vec4f
m_specular
;
float
m_shininess
;
Geom
::
Vec3f
m_lightPos
;
Geom
::
Vec3f
m_eyePos
;
Utils
::
VBO
*
m_vboPos
;
Utils
::
VBO
*
m_vboNormal
;
Utils
::
VBO
*
m_vboColor
;
void
getLocations
();
void
sendParams
();
void
restoreUniformsAttribs
();
public:
ShaderMatCustom
(
bool
doubleSided
=
false
,
bool
withEyePosition
=
false
);
// inviduals parameter setting functions
void
setAmbiant
(
const
Geom
::
Vec4f
&
ambiant
);
void
setDiffuse
(
const
Geom
::
Vec4f
&
diffuse
);
void
setSpecular
(
const
Geom
::
Vec4f
&
specular
);
void
setShininess
(
float
shininess
);
void
setLightPosition
(
const
Geom
::
Vec3f
&
lp
);
/// set eye position for VR environement
void
setEyePosition
(
const
Geom
::
Vec3f
&
ep
);
const
Geom
::
Vec4f
&
getAmbiant
()
const
{
return
m_ambiant
;
}
const
Geom
::
Vec4f
&
getDiffuse
()
const
{
return
m_diffuse
;
}
const
Geom
::
Vec4f
&
getSpecular
()
const
{
return
m_specular
;
}
float
getShininess
()
const
{
return
m_shininess
;
}
const
Geom
::
Vec3f
&
getLightPosition
()
const
{
return
m_lightPos
;
}
/**
* set all parameter in on call (one bind also)
*/
void
setParams
(
const
Geom
::
Vec4f
&
ambiant
,
const
Geom
::
Vec4f
&
diffuse
,
const
Geom
::
Vec4f
&
specular
,
float
shininess
,
const
Geom
::
Vec3f
&
lightPos
);
// attributes
unsigned
int
setAttributePosition
(
Utils
::
VBO
*
vbo
);
unsigned
int
setAttributeNormal
(
Utils
::
VBO
*
vbo
);
// optional attributes
unsigned
int
setAttributeColor
(
::
Utils
::
VBO
*
vbo
);
void
unsetAttributeColor
();
void
setTransformation
(
Geom
::
Matrix44f
t
);
};
#endif
include/Utils/Shaders/shaderMatCustom.vert
0 → 100644
View file @
549167d9
//ShaderMatCustom::vertexShaderText
ATTRIBUTE
vec3
VertexPosition
,
VertexNormal
;
#ifdef WITH_COLOR
ATTRIBUTE
vec3
VertexColor
;
#endif
uniform
mat4
TransformationMatrix
;
uniform
mat4
ModelViewProjectionMatrix
;
uniform
mat4
ModelViewMatrix
;
uniform
mat4
NormalMatrix
;
uniform
vec3
lightPosition
;
VARYING_VERT
vec3
EyeVector
,
Normal
,
LightDir
;
#ifdef WITH_COLOR
VARYING_VERT
vec3
Color
;
#endif
#ifdef WITH_EYEPOSITION
uniform
vec3
eyePosition
;
#endif
INVARIANT_POS
;
void
main
()
{
Normal
=
vec3
(
NormalMatrix
*
TransformationMatrix
*
vec4
(
VertexNormal
,
0
.
0
));
vec3
Position
=
vec3
(
ModelViewMatrix
*
TransformationMatrix
*
vec4
(
VertexPosition
,
1
.
0
));
LightDir
=
lightPosition
-
Position
;
#ifdef WITH_EYEPOSITION
EyeVector
=
eyePosition
-
Position
;
#else
EyeVector
=
-
Position
;
#endif
#ifdef WITH_COLOR
Color
=
VertexColor
;
#endif
gl_Position
=
ModelViewProjectionMatrix
*
(
TransformationMatrix
*
vec4
(
VertexPosition
,
1
.
0
));
}
include/Utils/gl_matrices.h
View file @
549167d9
...
...
@@ -70,25 +70,26 @@ public:
void
rotate
(
float
angle
,
const
Geom
::
Vec3f
&
Axis
)
{
glm
::
mat4
X
=
glm
::
rotate
(
m_matrices
[
2
]
,
angle
,
glm
::
vec3
(
Axis
[
0
],
Axis
[
1
],
Axis
[
2
]))
*
m_matrices
[
2
];
glm
::
mat4
X
=
glm
::
rotate
(
glm
::
mat4
(
1.
f
)
,
angle
,
glm
::
vec3
(
Axis
[
0
],
Axis
[
1
],
Axis
[
2
]))
*
m_matrices
[
2
];
m_matrices
[
2
]
=
X
;
}
void
translate
(
const
Geom
::
Vec3f
&
P
)
{
glm
::
mat4
X
=
glm
::
translate
(
m_matrices
[
2
],
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]))
*
m_matrices
[
2
];
glm
::
mat4
X
=
glm
::
translate
(
glm
::
mat4
(
1.
f
),
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]))
*
m_matrices
[
2
];
m_matrices
[
2
]
=
X
;
}
void
scale
(
const
Geom
::
Vec3f
&
S
)
{
glm
::
mat4
X
=
glm
::
scale
(
m_matrices
[
2
]
,
glm
::
vec3
(
S
[
0
],
S
[
1
],
S
[
2
]))
*
m_matrices
[
2
];
glm
::
mat4
X
=
glm
::
scale
(
glm
::
mat4
(
1.
f
)
,
glm
::
vec3
(
S
[
0
],
S
[
1
],
S
[
2
]))
*
m_matrices
[
2
];
m_matrices
[
2
]
=
X
;
}
void
scale
(
float
s
)
{
glm
::
mat4
X
=
glm
::
scale
(
m_matrices
[
2
]
,
glm
::
vec3
(
s
,
s
,
s
))
*
m_matrices
[
2
];
glm
::
mat4
X
=
glm
::
scale
(
glm
::
mat4
(
1.
f
)
,
glm
::
vec3
(
s
,
s
,
s
))
*
m_matrices
[
2
];
m_matrices
[
2
]
=
X
;
}
...
...
src/Utils/Shaders/shaderCustom.cpp
0 → 100644
View file @
549167d9
#include <string.h>
#include "Utils/Shaders/shaderCustom.h"
#include "shaderCustom.vert"
#include "shaderCustom.frag"
#include "shaderCustom.geom"
ShaderCustom
::
ShaderCustom
()
{
m_nameVS
=
"ShaderCustom_vs"
;
m_nameFS
=
"ShaderCustom_fs"
;
m_nameGS
=
"ShaderCustom_gs"
;
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
);
glxfrag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
(),
glxgeom
.
c_str
(),
GL_TRIANGLES
,
GL_TRIANGLE_STRIP
,
3
);
bind
();
getLocations
();
unbind
();
//Default values
m_explode
=
1.0
f
;
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
);
m_light_pos
=
Geom
::
Vec3f
(
10.0
f
,
10.0
f
,
1000.0
f
);
Geom
::
Matrix44f
id
;
id
.
identity
();
setTransformation
(
id
);
setParams
(
m_explode
,
m_ambiant
,
m_diffuse
,
m_light_pos
);
}
void
ShaderCustom
::
getLocations
()
{
*
m_unif_explode
=
glGetUniformLocation
(
program_handler
(),
"explode"
);
*
m_unif_ambiant
=
glGetUniformLocation
(
program_handler
(),
"ambient"
);
*
m_unif_diffuse
=
glGetUniformLocation
(
program_handler
(),
"diffuse"
);
*
m_unif_lightPos
=
glGetUniformLocation
(
program_handler
(),
"lightPosition"
);
}
unsigned
int
ShaderCustom
::
setAttributePosition
(
Utils
::
VBO
*
vbo
)
{
m_vboPos
=
vbo
;
bind
();
unsigned
int
id
=
bindVA_VBO
(
"VertexPosition"
,
vbo
);
unbind
();
return
id
;
}
void
ShaderCustom
::
setParams
(
float
expl
,
const
Geom
::
Vec4f
&
ambiant
,
const
Geom
::
Vec4f
&
diffuse
,
const
Geom
::
Vec3f
&
lightPos
)
{
m_explode
=
expl
;
m_ambiant
=
ambiant
;
m_diffuse
=
diffuse
;
m_light_pos
=
lightPos
;
bind
();
glUniform1f
(
*
m_unif_explode
,
expl
);
glUniform4fv
(
*
m_unif_ambiant
,
1
,
ambiant
.
data
());
glUniform4fv
(
*
m_unif_diffuse
,
1
,
diffuse
.
data
());
glUniform3fv
(
*
m_unif_lightPos
,
1
,
lightPos
.
data
());
unbind
();
}
void
ShaderCustom
::
setExplode
(
float
explode
)
{
m_explode
=
explode
;
bind
();
glUniform1f
(
*
m_unif_explode
,
explode
);
unbind
();
}
void
ShaderCustom
::
setAmbiant
(
const
Geom
::
Vec4f
&
ambiant
)
{
m_ambiant
=
ambiant
;
bind
();
glUniform4fv
(
*
m_unif_ambiant
,
1
,
ambiant
.
data
());
unbind
();
}
void
ShaderCustom
::
setDiffuse
(
const
Geom
::
Vec4f
&
diffuse
)
{
m_diffuse
=
diffuse
;
bind
();
glUniform4fv
(
*
m_unif_diffuse
,
1
,
diffuse
.
data
());
unbind
();
}
void
ShaderCustom
::
setLightPosition
(
const
Geom
::
Vec3f
&
lp
)
{
m_light_pos
=
lp
;
bind
();
glUniform3fv
(
*
m_unif_lightPos
,
1
,
lp
.
data
());
unbind
();
}