diff options
| author | raysan5 <raysan5@gmail.com> | 2016-01-11 11:59:15 +0100 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2016-01-11 11:59:15 +0100 |
| commit | e5a56fa98515337c805e5a641cd3787cb6898596 (patch) | |
| tree | 64cd9c053acd7770b797ebd1d4baef8320366df6 /src | |
| parent | f10835cf09d224bc0fe10b0440fba8770f5678c1 (diff) | |
| download | raylib-e5a56fa98515337c805e5a641cd3787cb6898596.tar.gz raylib-e5a56fa98515337c805e5a641cd3787cb6898596.zip | |
Change drawing order to avoid artifacts with...
... transparent elements
Diffstat (limited to 'src')
| -rw-r--r-- | src/rlgl.c | 58 |
1 files changed, 29 insertions, 29 deletions
@@ -1301,7 +1301,35 @@ void rlglDraw(void) glUniform1i(currentShader.mapDiffuseLoc, 0); } - // NOTE: We draw in this order: triangle shapes, textured quads and lines + // NOTE: We draw in this order: lines, triangles, quads + + if (lines.vCounter > 0) + { + glBindTexture(GL_TEXTURE_2D, whiteTexture); + + if (vaoSupported) + { + glBindVertexArray(vaoLines); + } + else + { + glBindBuffer(GL_ARRAY_BUFFER, linesBuffer[0]); + glVertexAttribPointer(currentShader.vertexLoc, 3, GL_FLOAT, 0, 0, 0); + glEnableVertexAttribArray(currentShader.vertexLoc); + + if (currentShader.colorLoc != -1) + { + glBindBuffer(GL_ARRAY_BUFFER, linesBuffer[1]); + glVertexAttribPointer(currentShader.colorLoc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0); + glEnableVertexAttribArray(currentShader.colorLoc); + } + } + + glDrawArrays(GL_LINES, 0, lines.vCounter); + + if (!vaoSupported) glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindTexture(GL_TEXTURE_2D, 0); + } if (triangles.vCounter > 0) { @@ -1394,34 +1422,6 @@ void rlglDraw(void) glBindTexture(GL_TEXTURE_2D, 0); // Unbind textures } - if (lines.vCounter > 0) - { - glBindTexture(GL_TEXTURE_2D, whiteTexture); - - if (vaoSupported) - { - glBindVertexArray(vaoLines); - } - else - { - glBindBuffer(GL_ARRAY_BUFFER, linesBuffer[0]); - glVertexAttribPointer(currentShader.vertexLoc, 3, GL_FLOAT, 0, 0, 0); - glEnableVertexAttribArray(currentShader.vertexLoc); - - if (currentShader.colorLoc != -1) - { - glBindBuffer(GL_ARRAY_BUFFER, linesBuffer[1]); - glVertexAttribPointer(currentShader.colorLoc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0); - glEnableVertexAttribArray(currentShader.colorLoc); - } - } - - glDrawArrays(GL_LINES, 0, lines.vCounter); - - if (!vaoSupported) glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindTexture(GL_TEXTURE_2D, 0); - } - if (vaoSupported) glBindVertexArray(0); // Unbind VAO glUseProgram(0); // Unbind shader program |
