2D. Rendering to a Masked Texture

Moderator
Posts: 335
Joined: 2002.04
Post: #1
This is more for a cool feature rather than a gameplay critical effect, but I was wondering if there's a fast way in basic OpenGL to draw to a texture but keep that texture's original alpha channel (I'm using 32 bit RGBA textures). I can see ways of doing it off-card by doing the effect with the CPU (ie re-copying the alpha bytes over the result), but I was wondering if OpenGL has any built in methods.
Preferably, any effect would have to be 'clear' OpenGL rather than via the extensions, as I've found that otherwise cool extensions (like the multipass textures) only work on NVidia cards (it passes if it works on my iBook 500 Wink )
Quote this message in a reply
Member
Posts: 145
Joined: 2002.06
Post: #2
Um, I've never done render-to-texture, but would glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE) work?

"He who breaks a thing to find out what it is, has left the path of wisdom."
- Gandalf the Gray-Hat

Bring Alistair Cooke's America to DVD!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
So, get a context with 8-bit destination alpha, render your texture to it, ColorMask like inio says, render the color channels, ColorMask back to normal, then CopyTexSubImage2D. Seems like it should work Smile

AFAICT, ColorMask doesn't affect the behavior of CopyTexSubImage2D, so just ColorMasking before you do that probably won't work.
Quote this message in a reply
Moderator
Posts: 335
Joined: 2002.04
Post: #4
neat, that sounds like a good solution (was playing about with CopyTexSubImage2D, but hadn't spotted the glColorMask). I'll give it a try.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Rendering Heightmap using texture data ardowz 3 945 Feb 25, 2014 10:25 AM
Last Post: SethWillits
  FBO rendering to GL_ALPHA texture Fenris 11 5,884 Jun 4, 2009 03:18 PM
Last Post: Fenris
  glOrtho setup for rendering "impostors" into a texture. TomorrowPlusX 22 8,908 May 22, 2006 07:21 AM
Last Post: TomorrowPlusX
  Masked Textures Dan Potter 1 2,212 Feb 26, 2005 10:07 AM
Last Post: Dan Potter
  Halo around masked sprites Bachus 3 4,758 Feb 4, 2003 06:26 PM
Last Post: NYGhost