Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Possible OpenGL Blending Bug?

It seems like I may have found an opengl bug with blending. When blending is enabled some triangles that are occluded still get blended with ones covering them. The depth buffer is working and does contain correct data. I am trying to blend multiple light sources contributions together additively but even with 1 light source the triangles blend with some of the triangles behind them. I have used OpenGL Profiler to check for errors and inspect the depth buffer and everything seemed normal. This is the code that I am using:


glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)

glEnable(GL_DEPTH_TEST);

glDepthFunc(GL_LEQUAL);


glEnable(GL_BLEND);

glBlendFunc(GL_ONE, GL_ONE);


glBindBuffer(GL_ARRAY_BUFFER, island.vbo);


glVertexAttribPointer(0, 3, GL_FLOAT, false, sizeof(Vertex), 0);

glVertexAttribPointer(1, 3, GL_FLOAT, false, sizeof(Vertex), (void *)(3 * sizeof(GLfloat)));

glEnableVertexAttribArray(0);

glEnableVertexAttribArray(1);


glUseProgram(directional_shader.handle);


directional_shader.setUniform(directional_mvp_location, mvp_matrix);

directional_shader.setUniform(directional_dir_location, dir_lights[0].direction);

directional_shader.setUniform(directional_col_location, dir_lights[0].color);


glDrawArrays(GL_TRIANGLES_ADJACENCY, 0, island.vertex_count);


glDisable(GL_BLEND);


[(NSOpenGLContext*)handle flushBuffer];


MacBook Air, OS X Mavericks (10.9)

Posted on Nov 15, 2013 3:47 PM

Reply

There are no replies.

Possible OpenGL Blending Bug?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.