Esempio n. 1
0
void SglColor4usv(const GLushort* iv) {
  glColor4f ( sRGB_frob(iv[0]*(1.f/65535.f)), sRGB_frob(iv[1]*(1.f/65535.f)), sRGB_frob(iv[2]*(1.f/65535.f)), iv[3]*(1.f/65535.f) );
}
Esempio n. 2
0
void SglColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
  glColor4f ( sRGB_frob(r), sRGB_frob(g), sRGB_frob(b), a );
}
Esempio n. 3
0
void SglColor4fva(const GLfloat* iv) {
  glColor4f ( sRGB_frob(iv[0]), sRGB_frob(iv[1]), sRGB_frob(iv[2]), iv[3]*iv[3] );
}
Esempio n. 4
0
void SglColor3us(GLushort r, GLushort g, GLushort b) {
  glColor4f ( sRGB_frob(r*(1.f/65535.f)), sRGB_frob(g*(1.f/65535.f)), sRGB_frob(b*(1.f/65535.f)), 1.0 );
}
Esempio n. 5
0
void SglColor3ub(GLubyte r, GLubyte g, GLubyte b) {
  glColor4f (sRGB_frob(r*(1.f/255.f)), sRGB_frob(g*(1.f/255.f)), sRGB_frob(b*(1.f/255.f)), 1.0);
}
Esempio n. 6
0
void SglColor3fv(const GLfloat* iv) {
  glColor4f ( sRGB_frob(iv[0]), sRGB_frob(iv[1]), sRGB_frob(iv[2]), 1.0 );
}
Esempio n. 7
0
// DJB OpenGL changing to adapt to OpenGL ES
void SglColor3f(GLfloat r, GLfloat g, GLfloat b) {
  glColor4f ( sRGB_frob(r), sRGB_frob(g), sRGB_frob(b), 1.0 );
}
bool OGL_DoFades(float Left, float Top, float Right, float Bottom)
{
	if (!OGL_FaderActive()) return false;
	
	// Set up the vertices
	GLfloat Vertices[4][2];
	Vertices[0][0] = Left;
	Vertices[0][1] = Top;
	Vertices[1][0] = Right;
	Vertices[1][1] = Top;
	Vertices[2][0] = Right;
	Vertices[2][1] = Bottom;
	Vertices[3][0] = Left;
	Vertices[3][1] = Bottom;
	glVertexPointer(2,GL_FLOAT,0,Vertices[0]);
	
	// Do real blending
	glDisable(GL_ALPHA_TEST);
	glEnable(GL_BLEND);
	glDisable(GL_TEXTURE_2D);
	
	// Modified color:
	GLfloat BlendColor[4];	
	
	for (int f=0; f<NUMBER_OF_FADER_QUEUE_ENTRIES; f++)
	{
		OGL_Fader& Fader = FaderQueue[f];
		
		switch(Fader.Type)
		{
		case NONE:
			break;
		
		case _tint_fader_type:
			// The simplest kind: fade to the fader color.
			SglColor4fva(Fader.Color);
			glDrawArrays(GL_POLYGON,0,4);
			break;
		
		case _randomize_fader_type:
			UseFlatStatic = TEST_FLAG(Get_OGL_ConfigureData().Flags,OGL_Flag_FlatStatic);
			if (UseFlatStatic)
			{
				for (int c=0; c<3; c++)
					FlatStaticColor[c] = FlatStaticRandom.KISS() + FlatStaticRandom.LFIB4();
				FlatStaticColor[3] = PIN(int(65535*Fader.Color[3]+0.5),0,65535);
				glDisable(GL_ALPHA_TEST);
				glEnable(GL_BLEND);
				SglColor4usv(FlatStaticColor);
				glDrawArrays(GL_POLYGON,0,4);
			}
			else
			{
				// Do random flipping of the lower bits of color values;
				// the stronger the opacity (alpha), the more bits to flip.
				if (Using_sRGB) glDisable(GL_FRAMEBUFFER_SRGB_EXT);
				glDisable(GL_BLEND);
				MultAlpha(Fader.Color,BlendColor);
				glColor3fv(BlendColor);
				glEnable(GL_COLOR_LOGIC_OP);
				glLogicOp(GL_XOR);
				glDrawArrays(GL_POLYGON,0,4);
				// Revert to defaults
				glDisable(GL_COLOR_LOGIC_OP);
				glEnable(GL_BLEND);
				if (Using_sRGB) glEnable(GL_FRAMEBUFFER_SRGB_EXT);
			}
			break;
		
		case _negate_fader_type:
			// This is only a partial approximation of the negation effect
			// Neither glBlendColorEXT nor glBlendEquationEXT is currently supported
			// in ATI Rage 128 AppleGL, which makes my life more difficult :-P
			MultAlpha(Fader.Color,BlendColor);
			SglColor4fva(BlendColor);
			glBlendFunc(GL_ONE_MINUS_DST_COLOR,GL_ONE_MINUS_SRC_ALPHA);
			glDrawArrays(GL_POLYGON,0,4);
			// Revert to defaults
			glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
			break;
		
		case _dodge_fader_type:
			ComplementColor(Fader.Color,BlendColor);
			MultAlpha(BlendColor,BlendColor);
			SglColor4fva(BlendColor);
			glBlendFunc(GL_DST_COLOR,GL_ONE_MINUS_SRC_ALPHA);
			glDrawArrays(GL_POLYGON,0,4);
			glBlendFunc(GL_DST_COLOR,GL_ONE);
			glDrawArrays(GL_POLYGON,0,4);
			// Revert to defaults
			glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
			break;
		
		case _burn_fader_type:
			// Attempted to get that reversed-color effect at maximum intensity,
			// with it being only near maximum intensity
			// (MultAlpha + GL_SRC_ALPHA means opacity^2).
			MultAlpha(Fader.Color,BlendColor);
			SglColor4fva(BlendColor);
			glBlendFunc(GL_DST_COLOR,GL_ONE);
			glDrawArrays(GL_POLYGON,0,4);
			ComplementColor(Fader.Color,BlendColor);
			MultAlpha(BlendColor,BlendColor);
			SglColor4fva(BlendColor);
			glBlendFunc(GL_SRC_ALPHA,GL_ONE);
			glDrawArrays(GL_POLYGON,0,4);
			// Revert to defaults
			glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
			break;
		
		case _soft_tint_fader_type:
			// Fade to the color multiplied by the fader color,
			// as if the scene was illuminated by light with that fader color.
			if(Using_sRGB) {
				float alpha = std::sqrt(Fader.Color[3]);
				float corrected[4] = {
					sRGB_frob(Fader.Color[0])*alpha,
					sRGB_frob(Fader.Color[1])*alpha,
					sRGB_frob(Fader.Color[2])*alpha,
					alpha
				};
				MultAlpha(corrected,BlendColor);
			}
			else
				MultAlpha(Fader.Color,BlendColor);
			glColor4fv(BlendColor);
			glBlendFunc(GL_DST_COLOR,GL_ONE_MINUS_SRC_ALPHA);
			glDrawArrays(GL_POLYGON,0,4);
			// Revert to defaults
			glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
			break;
		}		
	}
	
	return true;
}