Alpha blend problem in Age of empires mod

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 .


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:-

  1. glMatrixMode(GL_MODELVIEW);

    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

    //draw terrain textures inside glBegin()…glEnd() as textured quads

2.Now draw the castle in solid shape
glBindTexture(GL_TEXTURE_2D, textures[2]);//castle

  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

3.Now draw the light map blending it with whats already in buffer

*–>> //glColor4ub(255,0,0,255);
glBindTexture(GL_TEXTURE_2D, textures[1]);//lights

//light map	

  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
  1. 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.


When you use the vertex command, a bunch of data is submitted to the pipeline: vertex position, color etc. Commands like color, normal and others just write to a state register - meaning that a single color command will affect all vertices that follow it. I guess your problem is setting the color to red, but never resetting it back to white :slight_smile: The first pass is drawn white, while all subsequent passes will be red.

Thanks a lot .That solved the problem!!