static int fog_cb(ppogl::Script *vm) { if(vm->isKeyInTable("enabled")){ fogPlane.setEnabled(vm->getBoolFromTable("enabled")); } //mode if(vm->isKeyInTable("mode")){ std::string mode = vm->getStringFromTable("mode"); if(mode=="exp"){ fogPlane.setMode(GL_EXP); }else if(mode=="exp2"){ fogPlane.setMode(GL_EXP2); }else if(mode=="linear"){ fogPlane.setMode(GL_LINEAR); }else { PP_WARNING("pptheme.fog: mode must be one of " "`exp', `exp2', or `linear'"); return 0; } } if(vm->isKeyInTable("density")){ fogPlane.setDensity(vm->getFloatFromTable("density")); } if(vm->isKeyInTable("color")){ fogPlane.setColor(vm->getColorFromTable("color")); } if(vm->isKeyInTable("start")){ fogPlane.setStart(vm->getFloatFromTable("start")); } if(vm->isKeyInTable("end")){ fogPlane.setEnd(vm->getFloatFromTable("end")); } return 0; }
static int fog_cb (ClientData cd, Tcl_Interp *ip, int argc, CONST84 char *argv[]) { double tmp_arr[4]; double tmp_dbl; bool error = false; if (argc < 2) { error = true; } NEXT_ARG; while ( !error && argc > 0 ) { if ( strcmp( "-on", *argv ) == 0 ) { fogPlane.setEnabled(); } else if ( strcmp( "-off", *argv ) == 0 ) { fogPlane.setEnabled(false); } else if ( strcmp( "-mode", *argv ) == 0 ) { NEXT_ARG; if ( argc == 0 ) { error = true; break; } if ( strcmp( "exp", *argv ) == 0 ) { fogPlane.setMode(GL_EXP); } else if ( strcmp( "exp2", *argv ) == 0 ) { fogPlane.setMode(GL_EXP2); } else if ( strcmp( "linear", *argv ) == 0 ) { fogPlane.setMode(GL_LINEAR); } else { print_warning( TCL_WARNING, "tux_fog: mode must be one of " "`exp', `exp2', or `linear'" ); error = true; } } else if ( strcmp( "-density", *argv ) == 0 ) { NEXT_ARG; if ( argc == 0 ) { error = true; break; } if ( Tcl_GetDouble ( ip, *argv, &tmp_dbl ) == TCL_ERROR ) { error = true; break; } fogPlane.setDensity(tmp_dbl); } else if ( strcmp( "-start", *argv ) == 0 ) { NEXT_ARG; if ( argc == 0 ) { error = true; break; } if ( Tcl_GetDouble ( ip, *argv, &tmp_dbl ) == TCL_ERROR ) { error = true; break; } fogPlane.setStart(tmp_dbl); } else if ( strcmp( "-end", *argv ) == 0 ) { NEXT_ARG; if ( argc == 0 ) { error = true; break; } if ( Tcl_GetDouble ( ip, *argv, &tmp_dbl ) == TCL_ERROR ) { error = true; break; } fogPlane.setEnd(tmp_dbl); } else if ( strcmp( "-color", *argv ) == 0 ) { NEXT_ARG; if ( argc == 0 ) { error = true; break; } if ( get_tcl_tuple ( ip, *argv, tmp_arr, 4 ) == TCL_ERROR ) { error = true; break; } copy_to_glfloat_array( fogPlane.getColor(), tmp_arr, 4 ); } else { print_warning( TCL_WARNING, "tux_fog: unrecognized " "parameter `%s'", *argv ); } NEXT_ARG; } if ( error ) { print_warning( TCL_WARNING, "error in call to tux_fog" ); Tcl_AppendResult( ip, "\nUsage: tux_fog [-on|-off] " "[-mode [exp|exp2|linear]] " "[-density <value>] " "[-start <value>] " "[-end <value>] " "[-color { r g b a }] ", (char *) 0 ); return TCL_ERROR; } return TCL_OK; }