Jump to content
  • Advertisement
Sign in to follow this  
blueshogun96

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

This topic is 1925 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!