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
nomad-lab
VR-demos
Commits
efd3eb3b
Commit
efd3eb3b
authored
Apr 20, 2017
by
Ruben Jesus Garcia Hernandez
Browse files
Blending of zlayers functionality copied to NOMADVRLib
parent
f6f85797
Changes
2
Hide whitespace changes
Inline
Side-by-side
NOMADVRLib/IsoShaders.cpp
View file @
efd3eb3b
...
...
@@ -102,7 +102,7 @@ const char *const IsoTransparentShaders [] = {"Iso Transparent Renderer",
nullptr
};
const
char
*
const
IsoBlendShaders
[]
=
{
const
char
*
const
IsoBlendShaders
[]
=
{
"Iso Transparent Blend"
,
// vertex shader
#if defined(WIN32) || defined(CAVE)
"#version 410 core
\n
"
...
...
@@ -110,13 +110,13 @@ const char *const IsoBlendShaders [] = {
"#version 300 es
\n
"
#endif
"uniform mat4 matrix;
\n
"
"layout(location = 0) in vec
4
position;
\n
"
"layout(location = 0) in vec
3
position;
\n
"
"layout(location = 1) in vec2 v2TexCoordsIn;
\n
"
"out vec2 v2TexCoord;
\n
"
"void main()
\n
"
"{
\n
"
" v2TexCoord = v2TexCoordsIn;
\n
"
" gl_Position = matrix * vec4(position
.xyz
, 1);
\n
"
" gl_Position = matrix * vec4(position, 1);
\n
"
"}
\n
"
,
//fragment shader
"#version 410 core
\n
"
...
...
NOMADVRLib/IsosurfacesGL.cpp
View file @
efd3eb3b
...
...
@@ -346,4 +346,63 @@ glDepthMask(GL_TRUE);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
return
glGetError
();
}
GLenum
SetupBlending
(
GLuint
*
vao
,
GLuint
*
vertex
,
GLuint
*
indices
)
{
float
z
=
0.0
f
;
//(m_fNearClip + m_fFarClip) / 2.0f;
const
float
points
[]
=
{
-
1
,
-
1
,
z
,
0
,
0
,
-
1
,
1
,
z
,
0
,
1
,
1
,
1
,
z
,
1
,
1
,
1
,
-
1
,
z
,
1
,
0
};
glGenVertexArrays
(
1
,
myvao
);
glBindVertexArray
(
*
myvao
);
glGenBuffers
(
1
,
vertex
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
*
vertex
);
glBufferData
(
GL_ARRAY_BUFFER
,
4
*
5
*
sizeof
(
GLfloat
),
points
,
GL_STATIC_DRAW
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error after glBufferData: %d, %s, l %d
\n
"
,
e
,
gluErrorString
(
e
),
__LINE__
);
glEnableVertexAttribArray
(
0
);
glEnableVertexAttribArray
(
1
);
glDisableVertexAttribArray
(
2
);
glDisableVertexAttribArray
(
3
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error: %d, %s, l %d
\n
"
,
e
,
gluErrorString
(
e
),
__LINE__
);
glVertexAttribPointer
(
0
,
3
,
GL_FLOAT
,
GL_FALSE
,
5
*
sizeof
(
float
),
(
void
*
)
0
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error: %d, %s, l %d
\n
"
,
e
,
gluErrorString
(
e
),
__LINE__
);
glVertexAttribPointer
(
1
,
2
,
GL_FLOAT
,
GL_FALSE
,
5
*
sizeof
(
float
),
(
void
*
)(
3
*
sizeof
(
float
)));
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error: %d, %s, l %d
\n
"
,
e
,
gluErrorString
(
e
),
__LINE__
);
glGenBuffers
(
1
,
index
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error: %d, %s, l %d
\n
"
,
e
,
gluErrorString
(
e
),
__LINE__
);
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
*
index
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error: %d, %s, l %d
\n
"
,
e
,
gluErrorString
(
e
),
__LINE__
);
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
sizeof
(
iData
),
iData
,
GL_STATIC_DRAW
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error: %d, %s, l %d
\n
"
,
e
,
gluErrorString
(
e
),
__LINE__
);
return
e
;
}
void
DeleteBlendingBuffers
(
GLuint
*
vao
,
GLuint
*
vertex
,
GLuint
*
indices
)
{
glDeleteBuffers
(
1
,
vertex
);
glDeleteBuffers
(
1
,
indices
);
glDeleteVertexArrays
(
1
,
vao
);
}
void
BlendTextures
(
GLuint
textures
)
{
glEnable
(
GL_BLEND
);
glBlendFunc
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
);
for
(
int
zl
=
ZLAYERS
-
1
;
zl
>=
0
;
zl
--
)
{
glBindTexture
(
GL_TEXTURE_2D
,
textures
[
2
+
zl
]);
glDrawElements
(
GL_TRIANGLES
,
6
,
GL_UNSIGNED_INT
,
0
);
}
}
#endif
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