Beispiel #1
0
void InitChromaticSingleStates()
{
	//Set up the register combiners
	glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 2);

	//Enable per stage constants
	glEnable(GL_PER_STAGE_CONSTANTS_NV);

	//Send (1, 0, 0, 0) and (0, 1, 0, 0) as combiner 0 constant colors
	GLfloat combiner0Constant0[]={1.0f, 0.0f, 0.0f, 0.0f};
	glCombinerStageParameterfvNV(GL_COMBINER0_NV, GL_CONSTANT_COLOR0_NV, combiner0Constant0);
	GLfloat combiner0Constant1[]={0.0f, 1.0f, 0.0f, 0.0f};
	glCombinerStageParameterfvNV(GL_COMBINER0_NV, GL_CONSTANT_COLOR1_NV, combiner0Constant1);

	//Send (0, 0, 1, 0) as combiner 1 constant color 0
	GLfloat combiner1Constant0[]={0.0f, 0.0f, 1.0f, 0.0f};
	glCombinerStageParameterfvNV(GL_COMBINER1_NV, GL_CONSTANT_COLOR0_NV, combiner1Constant0);

	//Combiner 0 does:	red(tex2)+green(tex1)->spare0.rgb
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE2_ARB,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_CONSTANT_COLOR0_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE1_ARB,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_CONSTANT_COLOR1_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerOutputNV(	GL_COMBINER0_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE0_NV,
						GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);

	//Combiner 1 does:	blue(tex0)+spare0.rgb->spare0.rgb
	glCombinerInputNV(	GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_B_NV, GL_CONSTANT_COLOR0_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_C_NV, GL_SPARE0_NV,
						GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glCombinerInputNV(	GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO,
						GL_UNSIGNED_INVERT_NV, GL_RGB);
	glCombinerOutputNV(	GL_COMBINER1_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE0_NV,
						GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);

	glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_PRIMARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_TEXTURE3_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
	glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

	//Bind vertex program
	glBindProgramNV(GL_VERTEX_PROGRAM_NV, chromaticSingleVP);
}
Beispiel #2
0
void GeneralCombinerStruct::Invoke(int stage)
{
    int i;

    if (NULL != glCombinerStageParameterfvNV)
        for (i = 0; i < numConsts; i++)
            glCombinerStageParameterfvNV(GL_COMBINER0_NV + stage, cc[i].reg.bits.name, &(cc[i].v[0]));

    for (i = 0; i < 2; i++)
        portion[i].Invoke(stage);
}
void GLGpuNvparseProgram::bindProgramParameters(GpuProgramParametersSharedPtr params, uint16 mask)
{
    // NB, register combiners uses 2 constants per texture stage (0 and 1)
    // We have stored these as (stage * 2) + const_index in the physical buffer
    // There are no other parameters in a register combiners shader
    const FloatConstantList& floatList = 
        params->getFloatConstantList();
    size_t index = 0;
    for (FloatConstantList::const_iterator i = floatList.begin();
        i != floatList.end(); ++i, ++index)
    {
        GLenum combinerStage = GL_COMBINER0_NV + (unsigned int)(index / 2);
        GLenum pname = GL_CONSTANT_COLOR0_NV + (index % 2);
        glCombinerStageParameterfvNV(combinerStage, pname, &(*i));
        
    }

}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_NVRegisterCombiners2_nglCombinerStageParameterfvNV(JNIEnv *env, jclass clazz, jint stage, jint pname, jobject params, jint params_position, jlong function_pointer) {
	const GLfloat *params_address = ((const GLfloat *)(*env)->GetDirectBufferAddress(env, params)) + params_position;
	glCombinerStageParameterfvNVPROC glCombinerStageParameterfvNV = (glCombinerStageParameterfvNVPROC)((intptr_t)function_pointer);
	glCombinerStageParameterfvNV(stage, pname, params_address);
}