A few small rendering problems

Hello, I am just starting to program with SDL and OpenGL and I have run into a few problems that I cant figure out.
(most have my code has been copied from various tutorials)

-First off, I have a method that draws a basic white square. I set the color to white before I define the verticies, which on its own draws the correct color but when it is with an image, the square becomes the background color(most dominant?) of the last image drawn

-Second, I am having trouble appliying transparency to an Image. I have tried making the background dirrectly transparent with an image editing program, and also by using a color key but neither seem to work with OpenGL…

As you can see from the images above neither ship has transparency, but using the same code with just SDL the black background is removed.

Thanks for the help, sorry if these are really basic problems

Can u post your fillRect function?

Yea no problem, here is the method, it is Contained within the GraphicsFrame class so any variable not declared locally is in the class.

Seems pretty straight forward, unless I am using the basic GL functions wrong.

void GraphicsFrame::fillRect(int x,int y, int width, int height)
        //Move to offset
	glTranslatef( x+xOffSet, y+yOffSet, 0 );

	//Set color to white
	glColor4f( 1.0,1.0, 1.0, 1.0 );

        //Start quad
	glBegin( GL_QUADS );

	//Draw square
	glVertex3f( 0,     0,      0 );
	glVertex3f( width, 0,      0 );
	glVertex3f( width, height, 0 );
	glVertex3f( 0,     height, 0 );

	//End quad


If this doesnt work I can simply recolor and stretch an image of a white square programaticly

Put the glColor4f call inside the glBegin/glEnd pair before the first glVertex call and then tell us if u still see the same behaviour.

That shouldn’t matter because glColor just sets the current colour which subsequent calls to glVertex will pick up and send to the GPU.

If you want transparency on an image in OpenGL then look at alpha blending or alpha testing.

For your first problem, don’t use GL_MODULATE environment color when creating your texture, use GL_REPLACE instead. Or just glColor3f (1,1,1) before drawing a textured object.