glColor4f don't work.

Problems with Canvas, OpenGL, etc...

glColor4f don't work.

Postby impi » Mon May 17, 2010 8:37 pm

Code: Select all
gl.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertexBuffer);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texCoordBuffer);
gl.glDrawArrays(GL10.GL_TRIANGLES, pos, count * FLOATS_PER_TRIANGLE);


Altrough i would think this draws my map colored with red, it appears complete uncolored. Just normal texture Colors.

Without Textures this dont work too... i doens't even can draw an colored rect!
Using glColorPointer dont work either.
Is there any initialization setting that prevents coloring?

So many examples are using glColor4f like this, and it seems to work, but it don't work on my code here... so whats going on here ? :|

I'm using the Emulator btw. Don't got an phone at the moment.
impi
Developer
Developer
 
Posts: 29
Joined: Wed Apr 28, 2010 11:17 pm

Top

Re: glColor4f don't work.

Postby impi » Tue May 18, 2010 6:52 pm

Wow, finally i got the error, or finally a semisolution.

I must call gl.glDisable(GL10.GL_TEXTURE_2D); before and it works magically.

Seems that i'm unable to colorize in texture mode, what is going on there ?
impi
Developer
Developer
 
Posts: 29
Joined: Wed Apr 28, 2010 11:17 pm

Re: glColor4f don't work.

Postby seed » Wed May 19, 2010 8:45 pm

Visit Exit 4 Gaming - http://www.exit4games.com/
Home of LavaBall - http://exit4games.com/?page_id=3
Home of Rebound - http://exit4games.com/?page_id=138
Home of Tap Crazy - http://exit4games.com/?page_id=219
Download "Caveman Pool" From the Market Today!
seed
Senior Developer
Senior Developer
 
Posts: 103
Joined: Mon Mar 15, 2010 3:22 pm

Re: glColor4f don't work.

Postby impi » Thu May 20, 2010 1:33 pm

Nope, Lightning with is disabled gl.glDisable(GL10.GL_LIGHTNING); in onSurfaceCreated() from my GLSurfaceView
impi
Developer
Developer
 
Posts: 29
Joined: Wed Apr 28, 2010 11:17 pm

Re: glColor4f don't work.

Postby ShadowKntSDS » Thu May 20, 2010 6:16 pm

Looking back through these tutorials: http://www.droidnova.com/android-3d-game-tutorial-part-ii,328.html

It looks like when you want colors, you either need to set glColor4f and NOT set glTexCoordPointer, or you want to use glColorPointer to setup colors for each vertex. I've never colored more than a single triangle with glColor4f myself, so I'd lean towards glColorPointer.
ShadowKntSDS
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Apr 28, 2010 10:29 pm

Re: glColor4f don't work.

Postby impi » Thu May 20, 2010 6:26 pm

glColorPointer didn't work either, as is said above, and glTexCoordPointer doenst affect the process. I cannot draw an colored triangle within GL_TEXTURE_2D mode.

I pasted my code straight into Replica Island onDrawFrame, (without gl.glDisable(GL10.GL_TEXTURE_2D)) and it worked, but i dont find any special settings in Replica Island. :|
impi
Developer
Developer
 
Posts: 29
Joined: Wed Apr 28, 2010 11:17 pm

Top

Re: glColor4f don't work.

Postby seed » Thu May 20, 2010 7:03 pm

impi wrote:glColorPointer didn't work either, as is said above, and glTexCoordPointer doenst affect the process. I cannot draw an colored triangle within GL_TEXTURE_2D mode.

I pasted my code straight into Replica Island onDrawFrame, (without gl.glDisable(GL10.GL_TEXTURE_2D)) and it worked, but i dont find any special settings in Replica Island. :|


I have some code I wrote that was the start of an editor for lavaball before I decided to go another route. I was putting buttons on the screen with textures for the icons and using glColorf to change the color of them on selection. I will dig the code up tonight and post something if the following doesn't fix your problem.

I know you don't have lighting on but just to double check, you aren't setting up normal pointers are you? Do you have GL_NORMAL_ARRAY disabled?

gl.glDisableClientState(GL10.GL_NORMAL_ARRAY);

Regards
Visit Exit 4 Gaming - http://www.exit4games.com/
Home of LavaBall - http://exit4games.com/?page_id=3
Home of Rebound - http://exit4games.com/?page_id=138
Home of Tap Crazy - http://exit4games.com/?page_id=219
Download "Caveman Pool" From the Market Today!
seed
Senior Developer
Senior Developer
 
Posts: 103
Joined: Mon Mar 15, 2010 3:22 pm

Re: glColor4f don't work.

Postby impi » Sat May 29, 2010 3:57 pm

Hell, thank you this works!

But i never used any NormalPointer before, but disabling this in onSurfaceCreated is the solution for this.

Replica Island doenst do this thing, but it uses his own GLSurfaceView anyways.
impi
Developer
Developer
 
Posts: 29
Joined: Wed Apr 28, 2010 11:17 pm

Top

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

Who is online

Users browsing this forum: No registered users and 1 guest