Commit c505ddc5 authored by Ruben Jesus Garcia Hernandez's avatar Ruben Jesus Garcia Hernandez
Browse files

Complete move of functionality.

parent efd3eb3b
...@@ -349,14 +349,17 @@ return glGetError(); ...@@ -349,14 +349,17 @@ return glGetError();
GLenum SetupBlending (GLuint *vao, GLuint *vertex, GLuint *indices) GLenum SetupBlending (GLuint *vao, GLuint *vertex, GLuint *indices)
{ {
GLenum e;
float z = 0.0f; //(m_fNearClip + m_fFarClip) / 2.0f; float z = 0.0f; //(m_fNearClip + m_fFarClip) / 2.0f;
const float points[] = { const float points[] = {
-1, -1, z, 0, 0, -1, -1, z, 0, 0,
-1, 1, z, 0, 1, -1, 1, z, 0, 1,
1, 1, z, 1, 1, 1, 1, z, 1, 1,
1, -1, z, 1, 0 }; 1, -1, z, 1, 0 };
glGenVertexArrays(1, myvao); const GLuint iData[] = { 0, 1, 2,
glBindVertexArray(*myvao); 2, 3, 0 };
glGenVertexArrays(1, vao);
glBindVertexArray(*vao);
glGenBuffers(1, vertex); glGenBuffers(1, vertex);
glBindBuffer(GL_ARRAY_BUFFER, *vertex); glBindBuffer(GL_ARRAY_BUFFER, *vertex);
glBufferData(GL_ARRAY_BUFFER, 4 * 5 * sizeof(GLfloat), points, GL_STATIC_DRAW); glBufferData(GL_ARRAY_BUFFER, 4 * 5 * sizeof(GLfloat), points, GL_STATIC_DRAW);
...@@ -375,10 +378,10 @@ GLenum SetupBlending (GLuint *vao, GLuint *vertex, GLuint *indices) ...@@ -375,10 +378,10 @@ GLenum SetupBlending (GLuint *vao, GLuint *vertex, GLuint *indices)
if ((e = glGetError()) != GL_NO_ERROR) if ((e = glGetError()) != GL_NO_ERROR)
eprintf("Gl error: %d, %s, l %d\n", e, gluErrorString(e), __LINE__); eprintf("Gl error: %d, %s, l %d\n", e, gluErrorString(e), __LINE__);
glGenBuffers(1, index); glGenBuffers(1, indices);
if ((e = glGetError()) != GL_NO_ERROR) if ((e = glGetError()) != GL_NO_ERROR)
eprintf("Gl error: %d, %s, l %d\n", e, gluErrorString(e), __LINE__); eprintf("Gl error: %d, %s, l %d\n", e, gluErrorString(e), __LINE__);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, *index); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, *indices);
if ((e = glGetError()) != GL_NO_ERROR) if ((e = glGetError()) != GL_NO_ERROR)
eprintf("Gl error: %d, %s, l %d\n", e, gluErrorString(e), __LINE__); eprintf("Gl error: %d, %s, l %d\n", e, gluErrorString(e), __LINE__);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(iData), iData, GL_STATIC_DRAW); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(iData), iData, GL_STATIC_DRAW);
...@@ -395,12 +398,12 @@ void DeleteBlendingBuffers(GLuint *vao, GLuint *vertex, GLuint *indices) ...@@ -395,12 +398,12 @@ void DeleteBlendingBuffers(GLuint *vao, GLuint *vertex, GLuint *indices)
glDeleteVertexArrays(1, vao); glDeleteVertexArrays(1, vao);
} }
void BlendTextures(GLuint textures) void BlendTextures(GLuint *textures, int zlayers)
{ {
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for (int zl = ZLAYERS - 1; zl >= 0; zl--) { for (int zl = zlayers - 1; zl >= 0; zl--) {
glBindTexture(GL_TEXTURE_2D, textures[2 + zl]); glBindTexture(GL_TEXTURE_2D, textures[2 + zl]);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
} }
......
...@@ -30,5 +30,7 @@ bool SetupDepthPeeling(int renderWidth, int renderHeight, int zlayers, GLuint *t ...@@ -30,5 +30,7 @@ bool SetupDepthPeeling(int renderWidth, int renderHeight, int zlayers, GLuint *t
void CleanDepthTexture (GLuint t); void CleanDepthTexture (GLuint t);
GLenum EnableDepthFB(unsigned int zl, const GLuint transP, GLenum EnableDepthFB(unsigned int zl, const GLuint transP,
const GLuint peelingFramebuffer, const GLuint *texture /*[2+ZLAYERS]*/); const GLuint peelingFramebuffer, const GLuint *texture /*[2+ZLAYERS]*/);
void DeleteBlendingBuffers(GLuint *vao, GLuint *vertex, GLuint *indices);
void BlendTextures(GLuint *textures, int zlayers);
#endif #endif
#endif // __ISOSURFACESGL_H #endif // __ISOSURFACESGL_H
...@@ -2194,19 +2194,13 @@ void CMainApplication::RenderScene(vr::Hmd_Eye nEye) ...@@ -2194,19 +2194,13 @@ void CMainApplication::RenderScene(vr::Hmd_Eye nEye)
if ((e = glGetError()) != GL_NO_ERROR) if ((e = glGetError()) != GL_NO_ERROR)
dprintf("Gl error after zlayer: %d, %s, l %d\n", e, gluErrorString(e), __LINE__); dprintf("Gl error after zlayer: %d, %s, l %d\n", e, gluErrorString(e), __LINE__);
glEnable(GL_BLEND); BlendTextures(m_iTexture + 1, ZLAYERS);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for (int zl = ZLAYERS - 1; zl >= 0; zl--) {
glBindTexture(GL_TEXTURE_2D, m_iTexture[3+zl]);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
}
if ((e = glGetError()) != GL_NO_ERROR) if ((e = glGetError()) != GL_NO_ERROR)
dprintf("Gl error after zlayer: %d, %s, l %d\n", e, gluErrorString(e), __LINE__); dprintf("Gl error after zlayer: %d, %s, l %d\n", e, gluErrorString(e), __LINE__);
glDeleteBuffers(1, &testBuf);
glDeleteBuffers(1, &indexBufferID); DeleteBlendingBuffers(&myvao, &testBuf, &indexBufferID);
glDeleteVertexArrays(1, &myvao);
if ((e = glGetError()) != GL_NO_ERROR) if ((e = glGetError()) != GL_NO_ERROR)
dprintf("Gl error after zlayer: %d, %s, l %d\n", e, gluErrorString(e), __LINE__); dprintf("Gl error after zlayer: %d, %s, l %d\n", e, gluErrorString(e), __LINE__);
glUseProgram(0); glUseProgram(0);
......
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