[Partially-Solved] Helping with fading texture

Problems with Canvas, OpenGL, etc...

[Partially-Solved] Helping with fading texture

Postby mark@project8games.com » Tue Aug 17, 2010 9:11 pm

Hey guys, I'm trying to do some very simple programmatic texture fading. But, regardless of what alpha I give my color coordinates, I cannot get the texture to fade at all. Here's some snippets of code

I do set :
gl.glTexEnvx(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_MODULATE);

I also use GLUtils to load the texture:
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);

My drawing is as straightforward as it gets. I'm not even using VBO's. I create a quad, map a color buffer using the given array (obviously along with a texture and vert buffer)
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                        
  2. float colors[] = new float[] {
  3. 1.0f,1.0f,1.0f, alpha,
  4. 1.0f,1.0f,1.0f, alpha,
  5. 1.0f,1.0f,1.0f, alpha,
  6. 1.0f,1.0f,1.0f, alpha,
  7. };
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


and do a basic draw:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                        
  2. //Enable the vertex and texture state
  3. gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
  4. gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);
  5. gl.glColorPointer(4, GL10.GL_FLOAT, 0, colorBuffer);
  6.  
  7. //Draw the vertices as triangles, based on the Index Buffer information
  8. gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_BYTE, indexBuffer);
  9.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


The texture appears on the screen, but without any of the alpha as I wanted it. It looks just I drew it using using drawTexture or something.

Is there something I'm missing here? Could this possibly be my issue http://groups.google.com/group/android- ... 3e63f82fca

Any help would be much appreciated. Thanks.
Last edited by mark@project8games.com on Fri Aug 20, 2010 5:36 pm, edited 1 time in total.
User avatar
mark@project8games.com
Developer
Developer
 
Posts: 41
Joined: Tue Mar 02, 2010 8:33 pm

Top

Re: Helping with fading texture

Postby mark@project8games.com » Fri Aug 20, 2010 5:33 pm

Ok, I partially solved this. I needed to make my color array consist entirely of the alpha, a la, glColor4f().

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. float colors[] = new float[] {
  2. alpha,alpha,alpha, alpha,
  3. alpha,alpha,alpha, alpha,
  4. alpha,alpha,alpha, alpha,
  5. alpha,alpha,alpha, alpha,
  6. };
Parsed in 0.034 seconds, using GeSHi 1.0.8.4



Unfortunately, I can't seem to get a "gradient" fade to work. The alpha always seems to be an average of the alphas of the verts
User avatar
mark@project8games.com
Developer
Developer
 
Posts: 41
Joined: Tue Mar 02, 2010 8:33 pm

Re: [Partially-Solved] Helping with fading texture

Postby Snedd » Sun Aug 22, 2010 8:22 am

It wasn't clear from your code snippet, are you setting the blend mode?
E.g.:

glEnable(GL_BLEND)
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)
Snedd
Freshman
Freshman
 
Posts: 7
Joined: Sat Aug 21, 2010 11:51 am

Re: [Partially-Solved] Helping with fading texture

Postby mark@project8games.com » Tue Aug 24, 2010 3:04 am

Yes, I am setting blend mode and blend function as above.
User avatar
mark@project8games.com
Developer
Developer
 
Posts: 41
Joined: Tue Mar 02, 2010 8:33 pm

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 4 guests