Example #1
0
void drawrect(int left, int top, int right, int bottom, GLrgba color)
{
	float average;
	float hue;
	int potential;
	int repeats;
	int height;
	int i, j;
	bool bright;
	GLrgba color_noise;

	glDisable(GL_CULL_FACE);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_BLEND);
	glLineWidth(1.0f);
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	glColor3fv(&color.red);

	if (left == right)
	{ //in low resolution, a "rect" might be 1 pixel wide
		glBegin(GL_LINES);
		glVertex2i(left, top);
		glVertex2i(left, bottom);
		glEnd();
	}
	if (top == bottom)
	{ //in low resolution, a "rect" might be 1 pixel wide
		glBegin(GL_LINES);
		glVertex2i(left, top);
		glVertex2i(right, top);
		glEnd();
	}
	else
	{ // draw one of those fancy 2-dimensional rectangles
		glBegin(GL_QUADS);
		glVertex2i(left, top);
		glVertex2i(right, top);
		glVertex2i(right, bottom);
		glVertex2i(left, bottom);
		glEnd();


		average = (color.red + color.blue + color.green) / 3.0f;
		bright = average > 0.5f;
		potential = (int)(average * 255.0f);

		if (bright)
		{
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
			glBegin(GL_POINTS);
			for (i = left + 1; i < right - 1; i++)
			{
				for (j = top + 1; j < bottom - 1; j++)
				{
					glColor4i(255, 0, RandomVal(potential), 255);
					hue = 0.2f + (float)RandomVal(100) / 300.0f + (float)RandomVal(100) / 300.0f + (float)RandomVal(100) / 300.0f;
					color_noise = glRgbaFromHsl(hue, 0.3f, 0.5f);
					color_noise.alpha = (float)RandomVal(potential) / 144.0f;
					glColor4f(RANDOM_COLOR_VAL, RANDOM_COLOR_VAL, RANDOM_COLOR_VAL, (float)RandomVal(potential) / 144.0f);
					glColor4fv(&color_noise.red);
					glVertex2i(i, j);
				}
			}
			glEnd();
		}
		repeats = RandomVal(6) + 1;
		height = (bottom - top) + (RandomVal(3) - 1) + (RandomVal(3) - 1);
		for (i = left; i < right; i++)
		{
			if (RandomVal(3) == 0)
				repeats = RandomVal(4) + 1;
			if (RandomVal(6) == 0)
			{
				height = bottom - top;
				height = RandomVal(height);
				height = RandomVal(height);
				height = RandomVal(height);
				height = ((bottom - top) + height) / 2;
			}
			for (j = 0; j < 1; j++)
			{
				glBegin(GL_LINES);
				glColor4f(0, 0, 0, (float)RandomVal(256) / 256.0f);
				glVertex2i(i, bottom - height);
				glColor4f(0, 0, 0, (float)RandomVal(256) / 256.0f);
				glVertex2i(i, bottom);
				glEnd();
			}
		}
	}
}
Example #2
0
template< > inline void glColor4< int >			(int red,int green,int blue, int alpha )						{	glColor4i(red,green,blue,alpha);	};
inline void glColor( const GLint & red, const GLint & green, const GLint & blue, const GLint & alpha )		{ glColor4i( red, green, blue, alpha ); }
Example #4
0
/////////////////////////////////////////////////////////
// Render
//
void GEMglColor4i :: render(GemState *state)
{
  glColor4i (red, green, blue, alpha);
}
Example #5
0
M(void, glColor4i, jint red, jint green, jint blue, jint alpha) {
	glColor4i(red, green, blue, alpha);
}