Sprite white out

Member
Posts: 117
Joined: 2010.09
Post: #1
Hi all,

This seems to have been asked before. But I need a method for Opengl iphone 1.1 i.e. works on a 3g.
I simply wish to draw any sprite with a complete white frame. I haven't got the ram to store every possible animated frame in white aswell.
My only current (and rubbish!) solution is to draw the sprite I require white multiple times with glBlendFunc( GL_SRC_ALPHA, GL_ONE );

Yeah, I know!. But it works!!! :-)
I *assume* there's a much better (more efficient) way to simply draw a white frame rather than multiple draws.

Cheers
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
use texture combiners to combine the constant color (1, 1, 1, 1) with the alpha from your sprite?
Quote this message in a reply
Member
Posts: 117
Joined: 2010.09
Post: #3
Hi OSC,

I kind of read about this method, but never found any code example or can be certain it's opengl 1.1 viable.....

Cheers
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #4
It works fine with OpenGL 1.1. Texture combiners are generally a giant pain to set up. Though if all you want to do is output a constant color that is probably not so bad. Maybe only like 10 lines of code? I don't really remember.

Normally you would use GL_MODULATE as your texture ENV mode which multiplies the vertex color against the texture color. You could use GL_ADD instead, but this would only work with specifically 100% white. You wouldn't be able to flash it any other color.

This is an OK article on texture combiners. You would only need to read like the first 1/4 of it maybe.
http://iphone-3d-programming.labs.oreilly.com/ch08.html

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
assuming (SRC_ALPHA, ONE_MINUS_SRC_ALPHA) blending, something like
Code:
// switch to texture combiner mode
glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_COMBINE);

// calculate color by REPLACE-ing with the CONSTANT TEXTURE_ENV_COLOR
glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_COLOR, (GLfloat[]){ 1, 1, 1, 1 });
glTexEnvi(GL_TEXTURE_2D, GL_COMBINE_RGB, GL_REPLACE);
glTexEnvi(GL_TEXTURE_2D, GL_SRC0_RGB, GL_CONSTANT);
glTexEnvi(GL_TEXTURE_2D, GL_OPERAND0_RGB, GL_SRC_COLOR);

// calculate alpha by REPLACE-ing with the alpha from the TEXTURE
glTexEnvi(GL_TEXTURE_2D, GL_COMBINE_ALPHA, GL_REPLACE);
glTexEnvi(GL_TEXTURE_2D, GL_SRC0_ALPHA, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_2D, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
Quote this message in a reply
Member
Posts: 117
Joined: 2010.09
Post: #6
Thanks guys,

I tried OSC snippet; and notice no difference. Is there anything else I need to set?
Currently 'playing' with it :-)

Cheers
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  App launches, tab bar shows, but content is white and viewWillAppear not called funkboy 3 4,427 Oct 21, 2009 12:13 AM
Last Post: sthaqu
  OpenGL ES Textures Start White demonpants 5 6,844 Sep 3, 2009 06:40 AM
Last Post: Skorche
  xcode NO COLOR (black & white !) imaumac 3 4,057 Jan 14, 2009 10:10 PM
Last Post: longjumper