Original Post
hi, I'm just new to openGL (change from sdl to opengl cause of performance). I have a 2D game of units, and for team color (about 8 color). For each unit texture , I have a mask texture (of gray color), only for parts that need colors. So to apply unit color, I just draw unit texture, then draw mask texture with mask Color (for example remove red color, then green and blue make cian color...,red and blue make yellow...)
In DirectX, it's very easy :
long mask[]={0xFFFFFFFF,0xFFFFFF00,0xFFFF00FF,0xFF00FFFF,0xFFFF0000,0xFFCCCCCC,0xFF00FF00,0xFFFF8000};
gSprite->Draw(gTexture,&drawRect,NULL,&d3d,mask[color]);
In SDL, it's about the same :
SDL_Surface *src
long mask[]={0xFFFFFFFF,0xFFFFFF00,0xFFFF00FF,0xFF00FFFF,0xFF0000FF,0xFFCCCCCC,0xFF00FF00,0xFF0080FF};
src->format->Rmask=mask[color] & 0x00FF;
src->format->Gmask=mask[color] & 0x00FF00;
src->format->Bmask=mask[color] & 0x00FF0000;
So now I move to SDL_Opengl, I want to know the same technique to do it.
I found out : glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
But it only work, if I set 1 color to true, if I set 2 color , it doesnt make yellow, or cian...
Thanks. I hope you understand the way I express my problem.
In DirectX, it's very easy :
long mask[]={0xFFFFFFFF,0xFFFFFF00,0xFFFF00FF,0xFF00FFFF,0xFFFF0000,0xFFCCCCCC,0xFF00FF00,0xFFFF8000};
gSprite->Draw(gTexture,&drawRect,NULL,&d3d,mask[color]);
In SDL, it's about the same :
SDL_Surface *src
long mask[]={0xFFFFFFFF,0xFFFFFF00,0xFFFF00FF,0xFF00FFFF,0xFF0000FF,0xFFCCCCCC,0xFF00FF00,0xFF0080FF};
src->format->Rmask=mask[color] & 0x00FF;
src->format->Gmask=mask[color] & 0x00FF00;
src->format->Bmask=mask[color] & 0x00FF0000;
So now I move to SDL_Opengl, I want to know the same technique to do it.
I found out : glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
But it only work, if I set 1 color to true, if I set 2 color , it doesnt make yellow, or cian...
Thanks. I hope you understand the way I express my problem.