void CRefractWater::Draw()
{
	if(readmap->minheight>10)
		return;

	glActiveTextureARB(GL_TEXTURE2_ARB);
	glBindTexture(target, subSurfaceTex);
	glEnable(target);
	glCopyTexSubImage2D(target, 0, 0, 0, 0, 0, gu->screenx, gu->screeny);

	SetupWaterDepthTex();

	glActiveTextureARB(GL_TEXTURE0_ARB);
	// GL_TEXTURE_RECTANGLE uses texcoord range 0 to width, whereas GL_TEXTURE_2D uses 0 to 1
	if (target == GL_TEXTURE_RECTANGLE_ARB) {
		float v[] = { 0.04f * gu->screenx, 0.04f * gu->screeny, 0.0f, 0.0f };
		glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 2, v);
	} else {
		float v[] = { 0.04f, 0.04f, 0.0f, 0.0f };
		glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 2, v);
		v[0] = 1.0f / next_power_of_2(gu->screenx);
		v[1] = 1.0f / next_power_of_2(gu->screeny);
		glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 3, v);
	}
	CAdvWater::Draw(false);

	glActiveTextureARB(GL_TEXTURE3_ARB);
	glDisable(GL_TEXTURE_2D);

	glActiveTextureARB(GL_TEXTURE2_ARB);
	glDisable(target);
	glActiveTextureARB(GL_TEXTURE0_ARB);
}
void Renderer::SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f)
{
   if(GLEW_EXT_gpu_program_parameters)
	{
        float buf[4 * C_VENVCONST_END];
        for (unsigned int i = 0; i < count; i++)
	    {
		    buf[4*i  ] = *f++;
    		buf[4*i+1] = *f++;
	    	buf[4*i+2] = *f++;
	    	buf[4*i+3] = 0.f;
	    }
        glProgramEnvParameters4fvEXT(GL_VERTEX_PROGRAM_ARB, const_number, count, buf);
    }
    else
    {
        for (unsigned int i = 0; i < count; i++)
	    {
		    float buf[4];
		    buf[0] = *f++;
		    buf[1] = *f++;
		    buf[2] = *f++;
		    buf[3] = 0.f;
		    glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number + i, buf);
	    }
    }
}
Beispiel #3
0
void Viewer::init()
{
    glewInit();
    //shader_vert="toon.vert";    shader_frag = "toon.frag";
    //shader_vert="vertexshader.txt";    shader_frag = "fragmentshader.txt";
    //InitializeProgram();
    //initShader_ter();
    restoreStateFromFile();

    glEnable (GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glEnable(GL_LIGHTING);
    glEnable(GL_NORMALIZE);

    glCullFace(GL_BACK);
    glEnable(GL_CULL_FACE);

    glEnable(GL_TEXTURE_2D);

    glShadeModel(GL_SMOOTH);
    glEnable(GL_COLOR_MATERIAL);

    glPixelStorei(GL_UNPACK_ALIGNMENT, 4);      // 4-byte pixel alignment

    // pretty rendering
    // fast rendering
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
    glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);

    light.setLight();
    mat.setMaterial();

    mySky.Set( 0,0,0, 300000.0f );
    mySky.LoadTextures(":sky");

    emit updateTasklabel(QString::number(curTerr+1)+"/"+QString::number(terrains.size()));

    initShader_phong();
    QVector4D ltmp(light.position[0],light.position[1],light.position[2],light.position[3]);
    ltmp.normalize();
    GLfloat lpos[4] = {ltmp.x(),ltmp.y(),ltmp.z(),ltmp.w()};
    glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 1, lpos);

    //QVector<QString> tlist;
    //tlist.push_back("CD.ter");
    //tlist.push_back("terr_gcut.ter");
//    /addTerrain("CD.ter");
    //addTerrain("terr_gcut.ter");
    help();
    //DrawInit();
    //qWarning("start drawing");

}
Beispiel #4
0
enum piglit_result
piglit_display(void)
{
    unsigned i;
    unsigned j;
    enum piglit_result result = PIGLIT_PASS;


    glClear(GL_COLOR_BUFFER_BIT);
    glEnable(GL_FRAGMENT_PROGRAM_ARB);

    for (i = 0; i < TEST_COLS; i++) {
        const int x = (i * (BOX_SIZE + 1)) + 1;

        glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, reference_prog);
        glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB,
        0, colors[i]);
        piglit_draw_rect(x, 1, BOX_SIZE, BOX_SIZE);

        for (j = 0; j < ARRAY_SIZE(types); j++) {
            const int y = ((j + 1) * (BOX_SIZE + 1)) + 1;
            GLfloat v[4];

            pack(v, colors[i], types[j]);
            glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB,
            0, v);

            glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, progs[j]);
            piglit_draw_rect(x, y, BOX_SIZE, BOX_SIZE);

            if (!piglit_probe_pixel_rgb(x + (BOX_SIZE / 2),
            y + (BOX_SIZE / 2),
            colors[i])) {
                if (!piglit_automatic)
                    printf("%s failed on color { %f %f %f %f }\n",
                    opcodes[j],
                    colors[i][0], colors[i][1],
                    colors[i][2], colors[i][3]);

                result = PIGLIT_FAIL;
            }
        }
    }

    piglit_present_results();
    return result;
}
Beispiel #5
0
void Viewer::draw()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glClearColor(backgroundCol.x(), backgroundCol.y(), backgroundCol.z(), 1.0f);

    if (mySky.wantSky())
         mySky.Render( );

    glEnable(GL_LIGHTING);

    if (applyGLSL)
        {
            glEnable(GL_VERTEX_PROGRAM_ARB);
            glEnable(GL_FRAGMENT_PROGRAM_ARB);
            light.position[3] = 1;
            light.setLight();
        }
    else{
        light.position[3] = 0;
        light.setLight();
    }

    QVector4D ltmp(light.position[0],light.position[1],light.position[2],light.position[3]);
    ltmp.normalize();
    GLfloat lpos[4] = {ltmp.x(),ltmp.y(),ltmp.z(),ltmp.w()};
    glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 1, lpos);

    // Draws a terrain
    if (curTerr>=0 && curTerr<terrains.size()){

        Terrain * terrain =  terrains[curTerr];
        if (applyTexture)   glBindTexture( GL_TEXTURE_2D, terrain->texid );
        else glBindTexture( GL_TEXTURE_2D, 0);
        terrain->Draw();

        //glLineWidth(10.0);
        //glPointSize(10.0);

        //glColor3f(1.0f,0.0f,0.0f);
        for (int i=0; i<terrain->artifacts.size(); i++){
            glColor3f(terrain->severity[i]/2.2f, 0.0f, 0.0f);
                drawFlag(terrain->artifacts[i]);
        }
    }

    glDisable(GL_VERTEX_PROGRAM_ARB);
    glDisable(GL_FRAGMENT_PROGRAM_ARB);

    glDisable(GL_LIGHTING);

    //glLineWidth(1.0);
    //glPointSize(1.0);



}
Beispiel #6
0
enum piglit_result
piglit_display(void)
{
	static const GLfloat color[4] = { 0.0, 0.5, 0.0, 0.5 };
	static const GLfloat good_color[4] = { 0.0, 1.0, 0.0, 1.0 };
	static const GLfloat bad_color[4] = { 1.0, 0.0, 0.0, 1.0 };
	enum piglit_result result = PIGLIT_PASS;
	unsigned i;

	glClear(GL_COLOR_BUFFER_BIT);

	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 0, bad_color);
	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 1, color);
	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 2, bad_color);
	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 3, bad_color);

	for (i = 0; i < ARRAY_SIZE(progs); i++) {
		const int x = 1 + (i * (BOX_SIZE + 1));

		glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]);

		glVertexAttrib2fvARB(1, & attrib[i * 2]);

		piglit_draw_rect(x, 1, BOX_SIZE, BOX_SIZE);

		if (!piglit_probe_pixel_rgb(x + (BOX_SIZE / 2),
					    1 + (BOX_SIZE / 2),
					    good_color)) {
			if (! piglit_automatic)
				printf("shader %u failed with attributes "
				       "%.1f, %.1f\n",
				       i,
				       attrib[(i * 2) + 0],
				       attrib[(i * 2) + 1]);

			result = PIGLIT_FAIL;
		}
	}

	piglit_present_results();
	return result;
}
void Renderer::SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
    if(GLEW_EXT_gpu_program_parameters)
    {
       glProgramEnvParameters4fvEXT(GL_VERTEX_PROGRAM_ARB, const_number, count, f);
    }
    else
    {
        for (unsigned int i = 0; i < count; i++,f+=4)
            glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number + i, f);
    }
}
Beispiel #8
0
enum piglit_result
piglit_display(void)
{
	static const GLfloat color[4] = { 0.0, 1.0, 0.0, 1.0 };
	static const GLfloat bad_color[4] = { 1.0, 0.0, 0.0, 1.0 };
	enum piglit_result result = PIGLIT_PASS;
	unsigned i;

	glClear(GL_COLOR_BUFFER_BIT);

	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 0, bad_color);
	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 1, color);
	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 2, color);
	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 3, color);

	for (i = 0; i < ARRAY_SIZE(progs); i++) {
		const int x = 1 + (i * (BOX_SIZE + 1));

		glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]);
		glEnable(GL_CLIP_PLANE0 + i);
		piglit_draw_rect_tex(x, 1, BOX_SIZE, BOX_SIZE,
				     1.0, 1.0, -2.0, 0.0);
		glDisable(GL_CLIP_PLANE0 + i);

		if (!piglit_probe_pixel_rgb(x + (BOX_SIZE / 2) - 2,
					    1 + (BOX_SIZE / 2),
					    color)) {
			result = PIGLIT_FAIL;
		}

		if (!piglit_probe_pixel_rgb(x + (BOX_SIZE / 2) + 2,
					    1 + (BOX_SIZE / 2),
					    clear_color)) {
			result = PIGLIT_FAIL;
		}
	}

	piglit_present_results();
	return result;
}
Beispiel #9
0
enum piglit_result
piglit_display(void)
{
	static const GLfloat color[4] = { 0.0, 0.5, 0.0, 0.5 };
	static const GLfloat bad_color[4] = { 1.0, 0.0, 0.0, 1.0 };
	static const GLfloat good_color[4] = { 0.0, 1.0, 0.0, 1.0 };
	static const GLfloat attrib[4][4] = {
		{ 1.0, -37.0, 1.0, 68.2 },
		{ -37.0, 1.0, 68.2, 1.0 },
	};
	enum piglit_result result = PIGLIT_PASS;
	unsigned i;

	glClear(GL_COLOR_BUFFER_BIT);

	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 0, bad_color);
	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 1, bad_color);
	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 2, color);
	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 3, bad_color);

	for (i = 0; i < ARRAY_SIZE(progs); i++) {
		const int x = 1 + (i * (BOX_SIZE + 1));

		glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]);

		glVertexAttrib4fvARB(1, attrib[i]);

		piglit_draw_rect(x, 1, BOX_SIZE, BOX_SIZE);

		if (!piglit_probe_pixel_rgb(x + (BOX_SIZE / 2),
					    1 + (BOX_SIZE / 2),
					    good_color)) {
			result = PIGLIT_FAIL;
		}
	}

	glutSwapBuffers();
	return result;
}
Beispiel #10
0
void vertex_program :: render(GemState *state)
{
    LoadProgram();

    /* actually glProgramEnvParameter4fvARB really depends on GL_ARB_vertex_program
     * and cannot be used with _only_ GL_NV_vertex_program
     */
    if(GLEW_ARB_vertex_program) {
        if(m_programID&&(m_envNum>=0)) {
            glProgramEnvParameter4fvARB(m_programTarget, m_envNum, m_param);
        }
    }
}
Beispiel #11
0
enum piglit_result
piglit_display(void)
{
	static const GLfloat color[4] = { 0.0, 1.0, 0.0, 1.0 };
	static const GLfloat bad_color[4] = { 1.0, 0.0, 0.0, 1.0 };
	enum piglit_result result = PIGLIT_PASS;
	unsigned i;

	glClear(GL_COLOR_BUFFER_BIT);

	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 0, bad_color);
	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 1, color);
	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 2, color);
	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 3, color);

	for (i = 0; i < ARRAY_SIZE(progs); i++) {
		const int x = 1 + (i * (BOX_SIZE + 1));

		glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]);

		if (i == 0) {
			glVertexAttrib4fARB(1, 1.0, 0.0, 0.0, 0.0);
		} else {
			glVertexAttrib4fARB(1, 0.0, 1.0, 2.0, 3.0);
		}

		piglit_draw_rect(x, 1, BOX_SIZE, BOX_SIZE);

		if (!piglit_probe_pixel_rgb(x + (BOX_SIZE / 2),
					    1 + (BOX_SIZE / 2),
					    color)) {
			result = PIGLIT_FAIL;
		}
	}

	piglit_present_results();
	return result;
}
Beispiel #12
0
void CRefractWater::Draw()
{
	if (!mapInfo->water.forceRendering && (readmap->currMinHeight > 1.0f)) {
		return;
	}

	glActiveTextureARB(GL_TEXTURE2_ARB);
	glBindTexture(target, subSurfaceTex);
	glEnable(target);
	glCopyTexSubImage2D(target, 0, 0, 0, 0, 0, globalRendering->viewSizeX, globalRendering->viewSizeY);

	SetupWaterDepthTex();

	glActiveTextureARB(GL_TEXTURE0_ARB);

	// GL_TEXTURE_RECTANGLE uses texcoord range 0 to width, whereas GL_TEXTURE_2D uses 0 to 1
	if (target == GL_TEXTURE_RECTANGLE_ARB) {
		float v[] = { 10.0f * globalRendering->viewSizeX, 10.0f * globalRendering->viewSizeY, 0.0f, 0.0f };
		glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 2, v);
	} else {
		float v[] = { 10.0f, 10.0f, 0.0f, 0.0f };
		glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 2, v);
		v[0] = 1.0f / next_power_of_2(globalRendering->viewSizeX);
		v[1] = 1.0f / next_power_of_2(globalRendering->viewSizeY);
		glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 3, v);
	}
	CAdvWater::Draw(false);

	glActiveTextureARB(GL_TEXTURE3_ARB);
	glDisable(GL_TEXTURE_2D);
	glDisable(GL_TEXTURE_GEN_S);
	glDisable(GL_TEXTURE_GEN_T);

	glActiveTextureARB(GL_TEXTURE2_ARB);
	glDisable(target);
	glActiveTextureARB(GL_TEXTURE0_ARB);
}
/*
==================
RB_ARB2_DrawInteraction
==================
*/
void	RB_ARB2_DrawInteraction( const drawInteraction_t *din ) {
#if !defined(GL_ES_VERSION_2_0)
	// load all the vertex program parameters
	glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_LIGHT_ORIGIN, din->localLightOrigin.ToFloatPtr() );
	glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_VIEW_ORIGIN, din->localViewOrigin.ToFloatPtr() );
	glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_LIGHT_PROJECT_S, din->lightProjection[0].ToFloatPtr() );
	glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_LIGHT_PROJECT_T, din->lightProjection[1].ToFloatPtr() );
	glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_LIGHT_PROJECT_Q, din->lightProjection[2].ToFloatPtr() );
	glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_LIGHT_FALLOFF_S, din->lightProjection[3].ToFloatPtr() );
	glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_BUMP_MATRIX_S, din->bumpMatrix[0].ToFloatPtr() );
	glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_BUMP_MATRIX_T, din->bumpMatrix[1].ToFloatPtr() );
	glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_DIFFUSE_MATRIX_S, din->diffuseMatrix[0].ToFloatPtr() );
	glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_DIFFUSE_MATRIX_T, din->diffuseMatrix[1].ToFloatPtr() );
	glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_SPECULAR_MATRIX_S, din->specularMatrix[0].ToFloatPtr() );
	glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_SPECULAR_MATRIX_T, din->specularMatrix[1].ToFloatPtr() );

	// testing fragment based normal mapping
	if ( r_testARBProgram.GetBool() ) {
		glProgramEnvParameter4fvARB( GL_FRAGMENT_PROGRAM_ARB, 2, din->localLightOrigin.ToFloatPtr() );
		glProgramEnvParameter4fvARB( GL_FRAGMENT_PROGRAM_ARB, 3, din->localViewOrigin.ToFloatPtr() );
	}

	static const float zero[4] = { 0, 0, 0, 0 };
	static const float one[4] = { 1, 1, 1, 1 };
	static const float negOne[4] = { -1, -1, -1, -1 };

	switch ( din->vertexColor ) {
	case SVC_IGNORE:
		glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_COLOR_MODULATE, zero );
		glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_COLOR_ADD, one );
		break;
	case SVC_MODULATE:
		glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_COLOR_MODULATE, one );
		glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_COLOR_ADD, zero );
		break;
	case SVC_INVERSE_MODULATE:
		glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_COLOR_MODULATE, negOne );
		glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_COLOR_ADD, one );
		break;
	}

	// set the constant colors
	glProgramEnvParameter4fvARB( GL_FRAGMENT_PROGRAM_ARB, 0, din->diffuseColor.ToFloatPtr() );
	glProgramEnvParameter4fvARB( GL_FRAGMENT_PROGRAM_ARB, 1, din->specularColor.ToFloatPtr() );

	// set the textures

	// texture 1 will be the per-surface bump map
	GL_SelectTextureNoClient( 1 );
	din->bumpImage->Bind();

	// texture 2 will be the light falloff texture
	GL_SelectTextureNoClient( 2 );
	din->lightFalloffImage->Bind();

	// texture 3 will be the light projection texture
	GL_SelectTextureNoClient( 3 );
	din->lightImage->Bind();

	// texture 4 is the per-surface diffuse map
	GL_SelectTextureNoClient( 4 );
	din->diffuseImage->Bind();

	// texture 5 is the per-surface specular map
	GL_SelectTextureNoClient( 5 );
	din->specularImage->Bind();

	// draw it
	RB_DrawElementsWithCounters( din->surf->geo );
#endif
}
/////////////////////////////////////////////////////////
// Render
//
void GEMglProgramEnvParameter4fvARB :: render(GemState *state) {
	glProgramEnvParameter4fvARB (target, index, params);
}
Beispiel #15
0
	void ARBProgramObject::SetUniform3iv(int idx, const int*   v) { int   vv[4]; vv[0] = v[0]; vv[1] = v[1]; vv[2] = v[2]; vv[3] =    0; glProgramEnvParameter4fvARB(uniformTarget, idx, (float*) vv); }
Beispiel #16
0
	void ARBProgramObject::SetUniform4fv(int idx, const float* v) { float vv[4]; vv[0] = v[0]; vv[1] = v[1]; vv[2] = v[2]; vv[3] = v[3]; glProgramEnvParameter4fvARB(uniformTarget, idx,          vv); }
Beispiel #17
0
enum piglit_result
piglit_display(void)
{
	const GLfloat comparitor[4] = { 0.5, 0.5, 0.5, 0.5 };
	static const float values[3] = { 0.0, 0.5, 1.0 };
	unsigned i;
	unsigned j;
	enum piglit_result result = PIGLIT_PASS;
	GLfloat color[4];
	GLfloat ref[4];

	glClear(GL_COLOR_BUFFER_BIT);
	glEnable(GL_FRAGMENT_PROGRAM_ARB);

	glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 1, comparitor);

	for (i = 0; i < (2 * ARRAY_SIZE(progs)); i++) {
		const int y = (i * (BOX_SIZE + 1)) + 1;
		const unsigned idx = i >> 1;

		if ((i & 1) == 0) {
			glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB,
					 reference_prog);
		} else {
			glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB,
					 progs[idx]);
		}

		for (j = 0; j < (3 * 3 * 3 * 3); j++) {
			const int x = (j * (BOX_SIZE + 1)) + 1;

			/* Determine the color of the reference square.
			 * This depends on both the set-on function and
			 * the mask.
			 */
			ref[0] = values[j        % 3];
			ref[1] = values[(j /  3) % 3];
			ref[2] = values[(j /  9) % 3];
			ref[3] = values[(j / 27) % 3];

			color[0] = tests[idx].func(comparitor[0], ref[0])
				? 1.0 : 0.0;
			color[1] = tests[idx].func(comparitor[1], ref[1])
				? 1.0 : 0.0;
			color[2] = tests[idx].func(comparitor[2], ref[2])
				? 1.0 : 0.0;
			color[3] = tests[idx].func(comparitor[3], ref[3])
				? 1.0 : 0.0;

			glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB,
						    0, color);
			glColor4fv(ref);

			piglit_draw_rect(x, y, BOX_SIZE, BOX_SIZE);
			if ((i & 1) == 0)
				continue;

			if (!piglit_probe_pixel_rgb(x + (BOX_SIZE / 2),
						    y + (BOX_SIZE / 2),
						    color)) {
				if (!piglit_automatic)
					printf("%s failed on ref = "
					       "{ %.01f %.01f %.01f %.01f }\n",
					       tests[idx].opcode,
					       ref[0], ref[1], ref[2], ref[2]);

				result = PIGLIT_FAIL;
			}
		}
	}


	piglit_present_results();
	return result;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBProgram_nglProgramEnvParameter4fvARB(JNIEnv *env, jclass clazz, jint target, jint index, jlong params, jlong function_pointer) {
	const GLfloat *params_address = (const GLfloat *)(intptr_t)params;
	glProgramEnvParameter4fvARBPROC glProgramEnvParameter4fvARB = (glProgramEnvParameter4fvARBPROC)((intptr_t)function_pointer);
	glProgramEnvParameter4fvARB(target, index, params_address);
}
void Renderer::SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
	for (unsigned int i = 0; i < count; i++,f+=4)
		glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number + i, f);
}
void Renderer::SetPSConstant4fv(unsigned int const_number, const float *f)
{
	glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f);
}
void Renderer::SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{
	float f[4] = { f1, f2, f3, f4 };
	glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBProgram_nglProgramEnvParameter4fvARB(JNIEnv *env, jclass clazz, jint target, jint index, jobject params, jint params_position, jlong function_pointer) {
	const GLfloat *params_address = ((const GLfloat *)(*env)->GetDirectBufferAddress(env, params)) + params_position;
	glProgramEnvParameter4fvARBPROC glProgramEnvParameter4fvARB = (glProgramEnvParameter4fvARBPROC)((intptr_t)function_pointer);
	glProgramEnvParameter4fvARB(target, index, params_address);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBVertexProgram_nglProgramEnvParameter4fvARB__IIJ(JNIEnv *__env, jclass clazz, jint target, jint index, jlong paramsAddress) {
    glProgramEnvParameter4fvARBPROC glProgramEnvParameter4fvARB = (glProgramEnvParameter4fvARBPROC)tlsGetFunction(1383);
    intptr_t params = (intptr_t)paramsAddress;
    UNUSED_PARAM(clazz)
    glProgramEnvParameter4fvARB(target, index, params);
}