Note that there are some explanatory texts on larger screens.

plurals
  1. POrender transparent textures
    primarykey
    data
    text
    <p>I have one texture that has some portions which are transparent transparent I want to apply over an object whose faces are some opaque material (or colour if it's simpler) but the final object gets transparent. I want the final object to be totally opaque.</p> <p>Here is my code:</p> <p>First I set the material:</p> <pre><code> glDisable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT); glColor4f(0.00, 0.00, 0.00, 1.00); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glColor4f(0.80, 0.80, 0.80, 1.00); glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); glColor4f(0.01, 0.01, 0.01, 1.00); glEnable(GL_COLOR_MATERIAL); </code></pre> <p>Then I setup the VBOs</p> <pre><code> glBindTexture(GL_TEXTURE_2D, object-&gt;texture); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBindBuffer(GL_ARRAY_BUFFER, object-&gt;object); glVertexPointer(3, GL_FLOAT, sizeof(Vertex), ver_offset); glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), tex_offset); glNormalPointer(GL_FLOAT, sizeof(Vertex), nor_offset); </code></pre> <p>And finally I draw the object</p> <pre><code> glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); glDisable(GL_TEXTURE_2D); glBlendFunc(GL_ONE, GL_ZERO); glDrawArrays(GL_TRIANGLES, 0, object-&gt;num_faces); glEnable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDrawArrays(GL_TRIANGLES, 0, object-&gt;num_faces); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); </code></pre> <p>I tried passing different arguments to glBlendFunc() with no prevail. I've uploaded the source here: <a href="http://dpaste.com/83559/" rel="nofollow noreferrer">http://dpaste.com/83559/</a></p> <p><strong>UPDATE</strong> I <em>get</em> <a href="http://img174.yfrog.com/img174/1041/capturecrantitle1.png" rel="nofollow noreferrer">this</a>, but I <em>want</em> <a href="http://img210.imageshack.us/img210/5120/capturecranfereastrfrti.png" rel="nofollow noreferrer">this</a> (or without texture <a href="http://img41.imageshack.us/img41/5120/capturecranfereastrfrti.png" rel="nofollow noreferrer">this</a>).</p> <p>The 2nd and the 3rd picture are produces with <a href="http://devernay.free.fr/hacks/glm/" rel="nofollow noreferrer">glm</a>. I studied the sources, but since my knowledge of OpenGL is limited I didn't understand much.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload