Is it possible to use different blending functions for different parts of te scene ?
Say i want to render sprites in a 2D ame & i use
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
glBegin(GL_QUADS);
//Render sprites
glEnd();
then for light mapping to create lights in te 2D scene i do(immediately after above)
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
glBegin(GL_QUADS);
//put light textures on pixels already in te screen
glEnd();
but i have noticed that only the last glBlendFunc(GL_SRC_ALPHA,GL_ONE) applies to whole scene!
Mixing 2 blending functions for 1 scene 2d lighting
I first draw the terrain & castle wit the appropriate regions transparent & blending enabled to get irregular outline.i use
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Then i use a light texture(visible clearly in right pic) & draw it with
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
& i get the effect i want from the light but the castle has flared up too
With just
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPhHA);
i get a solid castle but lose the lighting effect!(right side)
I tried to use GL_LUMINANCE & stored the light values like this(for a uniform square shaped light…not the 1 above)
unsigned int img[32][32];
for (i = 0; i < 32; i++)
for (int j = 0; j < 32; j++){
img[i][j]= 255;
glTexImage2D(GL_TEXTURE_2D, 0, 1, 32,32, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, TextureImage[2]->pixels);
But the program crashes
So what is the best way i can implement lightin here in my 2D game wit ortho views