Sandeep Tiwari
Sandeep Tiwari

Reputation: 2072

How mantain OpenGL cube shape when make it see through?

I am facing a problem when I make see through of my cube the cube shape disturb(looking as in image) I use code for drawing cube is--

//Drawing gl.glTranslatef(0.0f, 0.0f, -5.0f); //Move 5 units into the screen

        float scaling  = (PhotoCube3DLWPActivity.scaleValue)/100.0f;
        gl.glScalef(scaling,scaling,scaling);           //Scale the Cube to 80 percent, otherwise it would be too large for the screen
        //Check if the blend flag has been set to enable/disable blending
            if(PhotoCube3DLWPActivity.blend)
            {
                gl.glEnable(GL10.GL_BLEND);         //Turn Blending On 
                gl.glDisable(GL10.GL_DEPTH_TEST);   //Turn Depth Testing Off

            } else {
                gl.glDisable(GL10.GL_BLEND);        //Turn Blending On 
                gl.glEnable(GL10.GL_DEPTH_TEST);    //Turn Depth Testing Off 
            }

but in else case no such type of probem,please elp me ASAP.enter image description here

Upvotes: 1

Views: 264

Answers (1)

Jave
Jave

Reputation: 31846

It looks perfectly normal to me. Currently the back-sides of the cube shows very clearly, which due to the perspective are smaller than the front (If you look carefully you can see the front very faintly).
You might want to change your blending function to get a 'better' look of transparent material, usually like so: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Upvotes: 1

Related Questions