Пример #1
0
int main(int argc, char* argv[])
{
  IupOpen(&argc, &argv);
  IupControlsOpen();

  MatrixTest();

  IupMainLoop();

  IupClose();

  return EXIT_SUCCESS;
}
Пример #2
0
void
TexEnvTest::runOne(BasicResult& r, Window& w) {

	(void) w;

#define COLORS (3*3*3*3)

	GLfloat colors[COLORS][4];

	// colors[] is an array of all possible RGBA colors with component
	// values of 0, 0.5, and 1.0
	for (int i = 0; i < COLORS; i++) {
		GLint r = i % 3;
		GLint g = (i / 3) % 3;
		GLint b = (i / 9) % 3;
		GLint a = (i / 27) % 3;
		colors[i][0] = (float) r / 2.0;
		colors[i][1] = (float) g / 2.0;
		colors[i][2] = (float) b / 2.0;
		colors[i][3] = (float) a / 2.0;
	}

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glEnable(GL_TEXTURE_2D);

#if BLEND_WITH_BACKGROUND
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_BLEND);
#endif

	glClearColor(BgColor[0], BgColor[1], BgColor[2], BgColor[3]);
	glShadeModel(GL_FLAT);

	glViewport(0, 0, 256, 256);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0, 256, 0, 256, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glTranslatef(0.375, 0.375, 0.0);

	int numModes;
	if (GLUtils::haveExtensions("GL_EXT_texture_env_add") ||
		GLUtils::haveExtensions("GL_ARB_texture_env_add"))
		numModes = 5;
	else
		numModes = 4;

	r.pass = true;

	for (int fmt = 0; fmt < 6; fmt++) {
		const GLenum format = FormatEnums[fmt];
		const char *formatName = FormatNames[fmt];
		for (int mode = 0; mode < numModes; mode++) {
			const GLenum envMode = EnvModeEnums[mode];
			const char *envName = EnvModeNames[mode];
			//printf("format %s mode %s\n", FormatNames[fmt],
			//	EnvModeNames[mode]);
			if (envMode == GL_BLEND && format != GL_ALPHA) {
				// also vary texenv color, every 5th is OK.
				for (int eCol = 0; eCol < COLORS; eCol += 5) {
					const GLfloat *envColor = colors[eCol];
					if (!MatrixTest(envMode, format,
						envName, formatName,
						COLORS, colors, envColor, w)) {
						r.pass = false;
						break;
					}
				}
			}
			else {
				// texenv color not significant
				if (!MatrixTest(envMode, format,
					envName, formatName,
					COLORS, colors, colors[0], w)) {
					r.pass = false;
				}
			}
		}
	}
} // TexEnvTest::runOne