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
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
CGoGN
CGoGN
Commits
ba7951a0
Commit
ba7951a0
authored
Oct 25, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forgotten file update
parent
86c98a1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
24 deletions
+51
-24
src/Utils/Shaders/shaderEnvMap.cpp
src/Utils/Shaders/shaderEnvMap.cpp
+51
-24
No files found.
src/Utils/Shaders/shaderEnvMap.cpp
View file @
ba7951a0
...
...
@@ -41,7 +41,7 @@ ShaderEnvMap::ShaderEnvMap(bool doubleSided, bool withEyePosition):
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_blend
(
0.5
f
),
m_lightPos
(
Geom
::
Vec3f
(
10.0
f
,
10.0
f
,
1000.0
f
)),
m_lightPos
(
Geom
::
Vec3f
(
10.0
f
,
10.0
f
,
1000
0
.0
f
)),
m_vboPos
(
NULL
),
m_vboNormal
(
NULL
),
m_vboColor
(
NULL
)
...
...
@@ -105,7 +105,7 @@ void ShaderEnvMap::sendParams()
if
(
m_with_eyepos
)
glUniform3fv
(
*
m_unif_eyePos
,
1
,
m_eyePos
.
data
());
// we use texture engine 0
glUniform1iARB
(
*
m_unif_envMap
,
0
);
glUniform1iARB
(
*
m_unif_envMap
,
GL_TEXTURE
0
);
}
void
ShaderEnvMap
::
setAmbiant
(
const
Geom
::
Vec4f
&
ambiant
)
...
...
@@ -246,8 +246,6 @@ void ShaderEnvMap::setCubeMap(unsigned int sz,
bool
ShaderEnvMap
::
setCubeMapImg
(
unsigned
int
sz
,
unsigned
char
*
img
)
{
std
::
cout
<<
"setCubeMapImg: "
<<
sz
<<
std
::
endl
;
glEnable
(
GL_TEXTURE_CUBE_MAP
);
glBindTexture
(
GL_TEXTURE_CUBE_MAP
,
*
m_texId
);
...
...
@@ -331,10 +329,8 @@ bool ShaderEnvMap::setCubeMapImg(unsigned int sz, unsigned char *img)
}
bool
ShaderEnvMap
::
setCubeMapPipo
()
bool
ShaderEnvMap
::
setCubeMapColored
()
{
std
::
cout
<<
"setCubeMapPipo"
<<
std
::
endl
;
glEnable
(
GL_TEXTURE_CUBE_MAP
);
glBindTexture
(
GL_TEXTURE_CUBE_MAP
,
*
m_texId
);
...
...
@@ -396,6 +392,54 @@ bool ShaderEnvMap::setCubeMapPipo()
}
bool
ShaderEnvMap
::
setCubeMapCheckered
()
{
glEnable
(
GL_TEXTURE_CUBE_MAP
);
glBindTexture
(
GL_TEXTURE_CUBE_MAP
,
*
m_texId
);
unsigned
int
sz
=
256
;
unsigned
char
*
texture
=
new
unsigned
char
[
3
*
sz
*
sz
];
unsigned
int
width
=
16
;
for
(
unsigned
int
i
=
0
;
i
<
sz
;
++
i
)
{
for
(
unsigned
int
j
=
0
;
j
<
sz
;
++
j
)
{
unsigned
int
k
=
i
*
sz
+
j
;
if
((
i
/
width
)
%
2
==
(
j
/
width
)
%
2
)
{
texture
[
k
*
3
]
=
255
;
texture
[
k
*
3
+
1
]
=
255
;
texture
[
k
*
3
+
2
]
=
255
;
}
else
{
texture
[
k
*
3
]
=
0
;
texture
[
k
*
3
+
1
]
=
0
;
texture
[
k
*
3
+
2
]
=
0
;
}
}
}
glTexImage2D
(
GL_TEXTURE_CUBE_MAP_POSITIVE_X
,
0
,
GL_RGBA
,
sz
,
sz
,
0
,
GL_RGB
,
GL_UNSIGNED_BYTE
,
texture
);
glTexImage2D
(
GL_TEXTURE_CUBE_MAP_NEGATIVE_X
,
0
,
GL_RGBA
,
sz
,
sz
,
0
,
GL_RGB
,
GL_UNSIGNED_BYTE
,
texture
);
glTexImage2D
(
GL_TEXTURE_CUBE_MAP_POSITIVE_Y
,
0
,
GL_RGBA
,
sz
,
sz
,
0
,
GL_RGB
,
GL_UNSIGNED_BYTE
,
texture
);
glTexImage2D
(
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
,
0
,
GL_RGBA
,
sz
,
sz
,
0
,
GL_RGB
,
GL_UNSIGNED_BYTE
,
texture
);
glTexImage2D
(
GL_TEXTURE_CUBE_MAP_POSITIVE_Z
,
0
,
GL_RGBA
,
sz
,
sz
,
0
,
GL_RGB
,
GL_UNSIGNED_BYTE
,
texture
);
glTexImage2D
(
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
,
0
,
GL_RGBA
,
sz
,
sz
,
0
,
GL_RGB
,
GL_UNSIGNED_BYTE
,
texture
);
delete
[]
texture
;
return
true
;
}
#ifdef WITH_QT
bool
ShaderEnvMap
::
setCubeMap
(
const
std
::
string
&
filename
)
{
...
...
@@ -408,16 +452,6 @@ bool ShaderEnvMap::setCubeMap(const std::string& filename)
return
false
;
}
// get the info of images
// unsigned int bpp = ptr->depth() / 8;
//
// // compatible TYPE
// if (bpp != 1)
// {
// CGoGNout << "Image::load incompatible type: bpp=" << ptr->depth() << CGoGNendl;
// delete ptr;
// return false;
// }
if
(
ptr
->
width
()
/
4
!=
ptr
->
height
()
/
3
)
{
...
...
@@ -442,21 +476,14 @@ bool ShaderEnvMap::setCubeMap(const std::string& filename)
void
ShaderEnvMap
::
predraw
()
{
// glPushAttrib(GL_ENABLE_BIT); // ??
glActiveTexture
(
GL_TEXTURE0
);
glEnable
(
GL_TEXTURE_CUBE_MAP
);
glBindTexture
(
GL_TEXTURE_2D
,
*
m_texId
);
bind
();
glUniform1iARB
(
*
m_unif_envMap
,
GL_TEXTURE0
);
}
void
ShaderEnvMap
::
postdraw
()
{
glDisable
(
GL_TEXTURE_CUBE_MAP
);
// glPopAttrib();
unbind
();
}
}
// namespace Utils
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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