I am trying to make this mod for Age of Empires & here you can see a isometric map/terrain & a castle on it. Now the art is stored in rectangular pictures with the white regions being masked to get irregular outlines. To mask the white regions i gave those pixels an alpha of 0 & the remaining colors an alpha=255 & converted them to textures in Orthographic view. The tiles are also stored similarly .
[[img]http://img220.imageshack.us/img220/9185/postitns9.th.jpg[/img]](http://img220.imageshack.us/my.php?image=postitns9.jpg)
I have also added lights by using a white light texture as can be seen at the top left of the castle(LEFT PIC)
here are the steps i follow to draw the scene:-
-
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Nice perspective correction
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Set The Blending Function For Translucency
glEnable(GL_TEXTURE_2D); // Allow 2D textures
glEnable(GL_BLEND);//draw terrain textures inside glBegin()…glEnd() as textured quads
2.Now draw the castle in solid shape
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, textures[2]);//castle
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);glVertex2i(100,100); //tl
glTexCoord2f(1, 0.0f);glVertex2i(400, 100); //tr
glTexCoord2f(1, 1); glVertex2i(400, 400); //br
glTexCoord2f(0.0f, 1); glVertex2i(100, 400); //ULTA AAYEGA!! - bl
glEnd();
3.Now draw the light map blending it with whats already in buffer
*–>> //glColor4ub(255,0,0,255);
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
glBindTexture(GL_TEXTURE_2D, textures[1]);//lights
//light map
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);glVertex2i(100,100); //tl
glTexCoord2f(1, 0.0f);glVertex2i(150, 100); //tr
glTexCoord2f(1, 1); glVertex2i(150, 150); //br
glTexCoord2f(0.0f, 1); glVertex2i(100, 150); //ULTA AAYEGA!! - bl
glEnd();
-
Swap SDL l buffers
SDL_GL_SwapBuffers( );
This gives me a bright white light …no problem(LEFT PICTURE)
the trouble starts when i want a red light
Then i use the line
*–>> glColor4ub(255,0,0,255);
at the position shown.THIS SHOULD DRAW THE LIGHT MAP TEXTURE IN RED & BLEND IT TOO...instead the WhOLE SCREEN gOES RED.I want 2D lighting with different colors....what should i do if this does not work.In the Nehe tutorials the chapter 9 on animated stars does the same and acieves colors on grayscale textures like mine.But in my case it floods the whole screen.
(RIGHT PICTURE)
ARE the BLEND FUNCTIONS WRONG ??
PLEASE SOMEBODY HELP!!