Jump to content

  • Log In with Google      Sign In   
  • Create Account


mathew_653

Member Since 24 Jan 2013
Offline Last Active Aug 17 2014 10:53 AM

Topics I've Started

Screen fade, blanking instead of fading.

24 January 2013 - 05:47 PM

Hello, i have looked at the other subforms of this forum and feel this is the best place.

I shall first off explain my issue and my own observations, before showing the relivent code.

 

The goal is to create a fade out effect.

At first i suspected multithreading, i have seen weird stuff happen in the past with it.

 

But this has prooved not to be the case, the float being past appears to be incrementing at the correct rate, but where the fault occurs is that instead of a fade, i get a flick of the screen then blankness as if the fade is at 100% when it is not(the printf in fade drawing showed that).

 

Additional infomation, the platform i am using is windows but i use SDL to handle all the initalising and stuff, as i do plan to port the code later to other platforms.

 

I shall now quote my code, starting with relivent render code(Cut down for cleaness):

 

Renderer

				_GL_Color ClearColor = RGBtoFloat({0,0,0,255});
				glClearColor(ClearColor.r,ClearColor.g,ClearColor.b,ClearColor.a);
				glClear( GL_COLOR_BUFFER_BIT );
			
				glEnable(GL_COLOR_MATERIAL);
				glEnable( GL_CULL_FACE );

				//Enable alpha masking here for non background element drawing.
				glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

				glEnable( GL_BLEND );
				glEnable( GL_ALPHA_TEST );

				//Set to no texture
				glBindTexture(GL_TEXTURE_2D, 0);
				glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
				if (pFade != NULL) { pFade->Draw(); }
				
				glDisable( GL_ALPHA_TEST );
				glDisable( GL_BLEND );
				glDisable( GL_CULL_FACE );
				glDisable(GL_COLOR_MATERIAL);
			
				SDL_GL_SwapBuffers();

 

Fade draw function(inside fade class)

	if (Colors[4] <= 0.0f) { return; }

	printf("Colors[4] = %f\n", Colors[4]);
	
	glBegin( GL_QUADS );
	//Bottom left
	glColor4f( Colors[1], Colors[2], Colors[3], Colors[4] );
	glVertex3f( 0, ScreenY, 0.0f );

	//Bottom right
	glColor4f( Colors[1], Colors[2], Colors[3], Colors[4] );
	glVertex3f( ScreenX, ScreenY, 0.0f );
 
	//Top right
	glColor4f( Colors[1], Colors[2], Colors[3], Colors[4] );
	glVertex3f( ScreenX, 0, 0.0f );

	//Top left
	glColor4f( Colors[1], Colors[2], Colors[3], Colors[4] );
	glVertex3f( 0, 0, 0.0f );
	glEnd();

 

In advance, thank you for any help you can provide.


PARTNERS