//------------------------------------------------------------------;
//
//------------------------------------------------------------------;

c_fx::c_fx ( void ) {

   return;
}

//------------------------------------------------------------------;
// TODO : dealloc for members globally - ?
//------------------------------------------------------------------;

c_fx::~c_fx ( void ) {

   delete [] e_fx;

   return;
}

//------------------------------------------------------------------;
//
//------------------------------------------------------------------;

int c_fx::m_set_fx ( void ) {

   return 1;
}

//------------------------------------------------------------------;
//
//------------------------------------------------------------------;

int c_fx::m_init_fx ( void ) {

   return 1;
}

//------------------------------------------------------------------;
//
//------------------------------------------------------------------;

int c_fx::m_texture_states ( void ) {

   return 1;
}

//------------------------------------------------------------------;
//
//------------------------------------------------------------------;

void c_fx::m_set_mesh_mat ( const nv_mesh    *pmesh,
                            const ase::model *model) {

   ase::matobj *matobj = model->mat[pmesh->matidx];
   ase::map_it  map_it = matobj->map_bump.begin();

   if (map_it != matobj->map_bump.end()) {

        ase::tex_cit tex_it = model->tex.find((*map_it)->bitmap);

        if (tex_it != model->tex.end()) {

            ase::texdata * txdata = (*tex_it).second;
            glBindTexture (GL_TEXTURE_2D, txdata->textid);
        }
    }
}

//------------------------------------------------------------------;
//
//------------------------------------------------------------------;

void c_fx::m_set_reg_comb() {

    glEnable(GL_REGISTER_COMBINERS_NV);

    glCombinerParameteriNV ( GL_NUM_GENERAL_COMBINERS_NV, 2 );
    glCombinerInputNV      ( GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB, GL_EXPAND_NORMAL_NV, GL_RGB );
    glCombinerInputNV      ( GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_PRIMARY_COLOR_NV, GL_EXPAND_NORMAL_NV, GL_RGB );
    glCombinerInputNV      ( GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE0_ARB, GL_EXPAND_NORMAL_NV, GL_RGB );
    glCombinerInputNV      ( GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_SECONDARY_COLOR_NV, GL_EXPAND_NORMAL_NV, GL_RGB );
    glCombinerOutputNV     ( GL_COMBINER0_NV, GL_RGB, GL_SPARE0_NV, GL_SPARE1_NV, GL_DISCARD_NV, GL_NONE, GL_NONE, GL_TRUE, GL_TRUE, GL_FALSE );

    glCombinerInputNV      ( GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_A_NV, GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB );
    glCombinerInputNV      ( GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_B_NV, GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB );
    glCombinerOutputNV     ( GL_COMBINER1_NV, GL_RGB, GL_SPARE1_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE );

    glFinalCombinerInputNV ( GL_VARIABLE_A_NV, GL_E_TIMES_F_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB );
    glFinalCombinerInputNV ( GL_VARIABLE_B_NV, GL_E_TIMES_F_NV, GL_UNSIGNED_INVERT_NV, GL_RGB );
    glFinalCombinerInputNV ( GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB );
    glFinalCombinerInputNV ( GL_VARIABLE_D_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB );
    glFinalCombinerInputNV ( GL_VARIABLE_E_NV, GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB );
    glFinalCombinerInputNV ( GL_VARIABLE_F_NV, GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB );
    glFinalCombinerInputNV ( GL_VARIABLE_G_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA );

/**
    nvparse(   
    "!!RC1.0\n"
    "{\n"
    "	rgb {\n"
    "		spare0 = expand(col0) . expand(tex0);\n"
    "		spare1 = expand(col1) . expand(tex0);\n"
    "	}\n"
    "}\n"
    "{\n"
    "	rgb {\n"
    "		spare1 = spare1 * spare1;\n"
    "	}\n"
    "}\n"
    "final_product = spare1 * spare1;\n"
    "out.rgb = spare0 + final_product;\n"
    "out.a = unsigned_invert(zero);\n"
    );
**/
}
