X-Git-Url: https://git.jsancho.org/?p=guile-irrlicht.git;a=blobdiff_plain;f=src%2Fmaterial.cpp;h=8380924fc210249324a254c33bf420eecabd7a1d;hp=821f8d4602ebe0640a2637af69ea99aa799dd000;hb=357f279e004c6257a160205835c06c283d317ef7;hpb=384a8fb56d8500dc3551085191a39c9da70e221c diff --git a/src/material.cpp b/src/material.cpp index 821f8d4..8380924 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -128,225 +128,255 @@ init_material (void) video::E_ANTI_ALIASING_MODE scm_to_anti_aliasing_mode (SCM anti_aliasing_mode) { - char* mode = scm_to_utf8_string (scm_symbol_to_string (anti_aliasing_mode)); - if (!strcmp (mode, "off")) + char* mode_name = scm_to_utf8_string (scm_symbol_to_string (anti_aliasing_mode)); + video::E_ANTI_ALIASING_MODE mode; + + if (!strcmp (mode_name, "off")) { - return video::EAAM_OFF; + mode = video::EAAM_OFF; } - else if (!strcmp (mode, "simple")) + else if (!strcmp (mode_name, "simple")) { - return video::EAAM_SIMPLE; + mode = video::EAAM_SIMPLE; } - else if (!strcmp (mode, "quality")) + else if (!strcmp (mode_name, "quality")) { - return video::EAAM_QUALITY; + mode = video::EAAM_QUALITY; } - else if (!strcmp (mode, "line-smooth")) + else if (!strcmp (mode_name, "line-smooth")) { - return video::EAAM_LINE_SMOOTH; + mode = video::EAAM_LINE_SMOOTH; } - else if (!strcmp (mode, "point-smooth")) + else if (!strcmp (mode_name, "point-smooth")) { - return video::EAAM_POINT_SMOOTH; + mode = video::EAAM_POINT_SMOOTH; } - else if (!strcmp (mode, "full-basic")) + else if (!strcmp (mode_name, "full-basic")) { - return video::EAAM_FULL_BASIC; + mode = video::EAAM_FULL_BASIC; } - else if (!strcmp (mode, "alpha-to-coverage")) + else if (!strcmp (mode_name, "alpha-to-coverage")) { - return video::EAAM_ALPHA_TO_COVERAGE; + mode = video::EAAM_ALPHA_TO_COVERAGE; } else { scm_error (scm_arg_type_key, NULL, "Wrong anti aliasing mode: ~S", scm_list_1 (anti_aliasing_mode), scm_list_1 (anti_aliasing_mode)); } + + free (mode_name); + return mode; } video::E_BLEND_OPERATION scm_to_blend_operation (SCM blend_operation) { - char* operation = scm_to_utf8_string (scm_symbol_to_string (blend_operation)); - if (!strcmp (operation, "none")) + char* operation_name = scm_to_utf8_string (scm_symbol_to_string (blend_operation)); + video::E_BLEND_OPERATION operation; + + if (!strcmp (operation_name, "none")) { - return video::EBO_NONE; + operation = video::EBO_NONE; } - else if (!strcmp (operation, "add")) + else if (!strcmp (operation_name, "add")) { - return video::EBO_ADD; + operation = video::EBO_ADD; } - else if (!strcmp (operation, "subtract")) + else if (!strcmp (operation_name, "subtract")) { - return video::EBO_SUBTRACT; + operation = video::EBO_SUBTRACT; } - else if (!strcmp (operation, "rev-subtract")) + else if (!strcmp (operation_name, "rev-subtract")) { - return video::EBO_REVSUBTRACT; + operation = video::EBO_REVSUBTRACT; } - else if (!strcmp (operation, "min")) + else if (!strcmp (operation_name, "min")) { - return video::EBO_MIN; + operation = video::EBO_MIN; } - else if (!strcmp (operation, "max")) + else if (!strcmp (operation_name, "max")) { - return video::EBO_MAX; + operation = video::EBO_MAX; } - else if (!strcmp (operation, "min-factor")) + else if (!strcmp (operation_name, "min-factor")) { - return video::EBO_MIN_FACTOR; + operation = video::EBO_MIN_FACTOR; } - else if (!strcmp (operation, "max-factor")) + else if (!strcmp (operation_name, "max-factor")) { - return video::EBO_MAX_FACTOR; + operation = video::EBO_MAX_FACTOR; } - else if (!strcmp (operation, "min-alpha")) + else if (!strcmp (operation_name, "min-alpha")) { - return video::EBO_MIN_ALPHA; + operation = video::EBO_MIN_ALPHA; } - else if (!strcmp (operation, "max-alpha")) + else if (!strcmp (operation_name, "max-alpha")) { - return video::EBO_MAX_ALPHA; + operation = video::EBO_MAX_ALPHA; } else { scm_error (scm_arg_type_key, NULL, "Wrong blend operation: ~S", scm_list_1 (blend_operation), scm_list_1 (blend_operation)); } + + free (operation_name); + return operation; } video::E_COLOR_MATERIAL scm_to_color_material (SCM color_material) { - char* material = scm_to_utf8_string (scm_symbol_to_string (color_material)); - if (!strcmp (material, "none")) + char* material_name = scm_to_utf8_string (scm_symbol_to_string (color_material)); + video::E_COLOR_MATERIAL material; + + if (!strcmp (material_name, "none")) { - return video::ECM_NONE; + material = video::ECM_NONE; } - else if (!strcmp (material, "diffuse")) + else if (!strcmp (material_name, "diffuse")) { - return video::ECM_DIFFUSE; + material = video::ECM_DIFFUSE; } - else if (!strcmp (material, "ambient")) + else if (!strcmp (material_name, "ambient")) { - return video::ECM_AMBIENT; + material = video::ECM_AMBIENT; } - else if (!strcmp (material, "emissive")) + else if (!strcmp (material_name, "emissive")) { - return video::ECM_EMISSIVE; + material = video::ECM_EMISSIVE; } - else if (!strcmp (material, "specular")) + else if (!strcmp (material_name, "specular")) { - return video::ECM_SPECULAR; + material = video::ECM_SPECULAR; } - else if (!strcmp (material, "diffuse-and-ambient")) + else if (!strcmp (material_name, "diffuse-and-ambient")) { - return video::ECM_DIFFUSE_AND_AMBIENT; + material = video::ECM_DIFFUSE_AND_AMBIENT; } else { scm_error (scm_arg_type_key, NULL, "Wrong color material: ~S", scm_list_1 (color_material), scm_list_1 (color_material)); } + + free (material_name); + return material; } video::E_COLOR_PLANE scm_to_color_plane (SCM color_plane) { - char* plane = scm_to_utf8_string (scm_symbol_to_string (color_plane)); - if (!strcmp (plane, "none")) + char* plane_name = scm_to_utf8_string (scm_symbol_to_string (color_plane)); + video::E_COLOR_PLANE plane; + + if (!strcmp (plane_name, "none")) { - return video::ECP_NONE; + plane = video::ECP_NONE; } - else if (!strcmp (plane, "alpha")) + else if (!strcmp (plane_name, "alpha")) { - return video::ECP_ALPHA; + plane = video::ECP_ALPHA; } - else if (!strcmp (plane, "red")) + else if (!strcmp (plane_name, "red")) { - return video::ECP_RED; + plane = video::ECP_RED; } - else if (!strcmp (plane, "green")) + else if (!strcmp (plane_name, "green")) { - return video::ECP_GREEN; + plane = video::ECP_GREEN; } - else if (!strcmp (plane, "blue")) + else if (!strcmp (plane_name, "blue")) { - return video::ECP_BLUE; + plane = video::ECP_BLUE; } - else if (!strcmp (plane, "rgb")) + else if (!strcmp (plane_name, "rgb")) { - return video::ECP_RGB; + plane = video::ECP_RGB; } - else if (!strcmp (plane, "all")) + else if (!strcmp (plane_name, "all")) { - return video::ECP_ALL; + plane = video::ECP_ALL; } else { scm_error (scm_arg_type_key, NULL, "Wrong color plane: ~S", scm_list_1 (color_plane), scm_list_1 (color_plane)); } + + free (plane_name); + return plane; } video::E_COMPARISON_FUNC scm_to_comparison_func (SCM comparison_func) { - char* func = scm_to_utf8_string (scm_symbol_to_string (comparison_func)); - if (!strcmp (func, "never")) + char* func_name = scm_to_utf8_string (scm_symbol_to_string (comparison_func)); + video::E_COMPARISON_FUNC func; + + if (!strcmp (func_name, "never")) { - return video::ECFN_NEVER; + func = video::ECFN_NEVER; } - else if (!strcmp (func, "less-equal")) + else if (!strcmp (func_name, "less-equal")) { - return video::ECFN_LESSEQUAL; + func = video::ECFN_LESSEQUAL; } - else if (!strcmp (func, "equal")) + else if (!strcmp (func_name, "equal")) { - return video::ECFN_EQUAL; + func = video::ECFN_EQUAL; } - else if (!strcmp (func, "less")) + else if (!strcmp (func_name, "less")) { - return video::ECFN_LESS; + func = video::ECFN_LESS; } - else if (!strcmp (func, "not-equal")) + else if (!strcmp (func_name, "not-equal")) { - return video::ECFN_NOTEQUAL; + func = video::ECFN_NOTEQUAL; } - else if (!strcmp (func, "greater-equal")) + else if (!strcmp (func_name, "greater-equal")) { - return video::ECFN_GREATEREQUAL; + func = video::ECFN_GREATEREQUAL; } - else if (!strcmp (func, "greater")) + else if (!strcmp (func_name, "greater")) { - return video::ECFN_GREATER; + func = video::ECFN_GREATER; } - else if (!strcmp (func, "always")) + else if (!strcmp (func_name, "always")) { - return video::ECFN_ALWAYS; + func = video::ECFN_ALWAYS; } else { scm_error (scm_arg_type_key, NULL, "Wrong comparison func: ~S", scm_list_1 (comparison_func), scm_list_1 (comparison_func)); } + + free (func_name); + return func; } video::E_POLYGON_OFFSET scm_to_polygon_offset (SCM polygon_offset) { - char* offset = scm_to_utf8_string (scm_symbol_to_string (polygon_offset)); - if (!strcmp (offset, "back")) + char* offset_name = scm_to_utf8_string (scm_symbol_to_string (polygon_offset)); + video::E_POLYGON_OFFSET offset; + + if (!strcmp (offset_name, "back")) { - return video::EPO_BACK; + offset = video::EPO_BACK; } - else if (!strcmp (offset, "front")) + else if (!strcmp (offset_name, "front")) { - return video::EPO_FRONT; + offset = video::EPO_FRONT; } else { scm_error (scm_arg_type_key, NULL, "Wrong polygon offset: ~S", scm_list_1 (polygon_offset), scm_list_1 (polygon_offset)); } + + free (offset_name); + return offset; }