Why can't I change the vertex colour when the texture is alpha only?

Started by
7 comments, last by tom_mai78101 11 years ago

For OpenGL ES, I'm working on an iOS game which uses a pre-written font class. It works great, but I can't change the vertex colour of the primitives used to draw the text.

I'm using this code here: http://www.themusingsofalostprogrammer.com/2010/01/how-to-do-font-rendering-in-opengl-on.html

I tried to modify the code so I could change the vertex colour, but it doesn't seem to effect it. Before you say it, I can't use a vertex/fragment program because I'm using a 1st gen iPod which doesn't support it. Any other ideas? Would love to share more, but I'm on a bus w/ wifi and I'm about to get off; my stop is coming up.

Shogun

Advertisement
have you tried simply calling glColor3f before you use the libraries print function ?
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

For starters, glColor and friends aren't supported on OpenGL ES.

Second, I did modify the vertex array code to include a diffuse colour for each vertex, but that didn't change anything either.

Is there a way to do this using glTexEnv? This is a bit tougher than I thought. blink.png

Shogun.

glColor4f is available in ES1.0/1.1 (you're right that 3f is missing though), just set alpha to 1.0

do a glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); as well before you render and it should multiply the vertex color with the texture color

You do not need a color array unless you want different colors for each vertex.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

Are you sure glColor4f is supported in OpenGL ES 1.1? Once again, XCode is telling me that it's undefined. I had to remove it before, and I can't find a definition for it anywhere.

I tried using glTexEnvi(...) and it still didn't work.

Shogun.

Are you sure glColor4f is supported in OpenGL ES 1.1? Once again, XCode is telling me that it's undefined. I had to remove it before, and I can't find a definition for it anywhere.

I tried using glTexEnvi(...) and it still didn't work.

Shogun.

Yes, glColor4f is available in OpenGL:ES 1.1 (its not in 2.0 though)

GL_API void GL_APIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);


should be in OpenGLES/ES1/gl.h (or whatever path you use on iOS)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

GL ES 1.1 does support glColor4f: http://www.khronos.org/opengles/sdk/1.1/docs/man/ - if XCode is telling you that it's undefined then you've a problem with XCode.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Okay, it's working now. I don't know why, but it's working now.

I reopened the project and it just started compiling without error. Meh, unless I subconsciously spelled it as glColour4f, I have no idea why it wasn't working before. Well, that did the trick. Now I feel stupid again...

I'll give you both ratings for your troubles >.<

Shogun

I'll tell you why it didn't work before, but it worked afterwards.

Reason: You didn't refresh/clean your project. XCode may happened to have some old data that's hiddenly conflicting. Sometimes, it happens on my Eclipse for Java/Android.

This topic is closed to new replies.

Advertisement