void load_exploration_map () { FILE *fp = NULL; char exploration_map_filename[256]; if(!minimap_texture) return; my_strcp (exploration_map_filename, map_file_name); exploration_map_filename[strlen(exploration_map_filename)-4] = 0; strcat (exploration_map_filename, ".xm"); safe_strncpy (current_exploration_map_filename, exploration_map_filename, sizeof (current_exploration_map_filename)); fp = open_file_config (exploration_map_filename, "rb"); if(fp) { if (fread(exploration_map, sizeof(GLubyte), 256 * 256, fp) != 256 * 256) { memset(exploration_map, 0, 256 * 256 * sizeof(GLubyte)); LOG_ERROR("%s() read failed for file [%s]\n", __FUNCTION__, exploration_map_filename); } fclose(fp); } else { memset(exploration_map, 0, 256 * 256 * sizeof(GLubyte)); } if(poor_man) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } else if(use_mipmaps) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); } else { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } if(have_extension(arb_texture_compression)) { if(have_extension(ext_texture_compression_s3tc)) glTexImage2D(GL_TEXTURE_2D,0,GL_COMPRESSED_RGB_S3TC_DXT1_EXT, minimap_size, minimap_size,0,GL_LUMINANCE,GL_UNSIGNED_BYTE,&exploration_map); else glTexImage2D(GL_TEXTURE_2D,0,GL_COMPRESSED_LUMINANCE, minimap_size, minimap_size,0,GL_ALPHA,GL_UNSIGNED_BYTE,&exploration_map); } else glTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE, minimap_size, minimap_size,0,GL_LUMINANCE,GL_UNSIGNED_BYTE,&exploration_map); CHECK_GL_ERRORS(); }
static unsigned int on_window_button_pressed (InputPadGtkWindow *window, gchar *str, guint type, guint keysym, guint keycode, guint state, gpointer data) { if (!have_extension (window)) { return FALSE; } if (type == INPUT_PAD_TABLE_TYPE_CHARS) { if (keysym > 0) { send_key_event (gtk_widget_get_window (GTK_WIDGET (window)), keysym, keycode, state); return TRUE; } else { return FALSE; } } else if (type == INPUT_PAD_TABLE_TYPE_KEYSYMS) { send_key_event (gtk_widget_get_window (GTK_WIDGET (window)), keysym, keycode, state); return TRUE; } return FALSE; }
void init_gl_extensions() { char str[1024]; init_opengl_extensions(); /* GL_ARB_multitexture */ if (have_extension(arb_multitexture)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_ARB_multitexture"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ARB_multitexture"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ARB_multitexture */ /* GL_ARB_texture_env_combine */ if (have_extension(arb_texture_env_combine)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_ARB_texture_env_combine"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ARB_texture_env_combine"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ARB_texture_env_combine */ /* GL_EXT_compiled_vertex_array */ if (have_extension(ext_compiled_vertex_array)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_EXT_compiled_vertex_array"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_EXT_compiled_vertex_array"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_EXT_compiled_vertex_array */ /* GL_ARB_point_sprite */ if (have_extension(ext_compiled_vertex_array)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_ARB_point_sprite"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ARB_point_sprite"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ARB_point_sprite */ /* GL_ARB_texture_compression */ if (have_extension(arb_texture_compression)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_ARB_texture_compression"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ARB_texture_compression"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ARB_texture_compression */ /* GL_EXT_texture_compression_s3tc */ if (have_extension(ext_texture_compression_s3tc)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_EXT_texture_compression_s3tc"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_EXT_texture_compression_s3tc"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_EXT_texture_compression_s3tc */ /* GL_SGIS_generate_mipmap */ if (have_extension(sgis_generate_mipmap)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_SGIS_generate_mipmap"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_SGIS_generate_mipmap"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_SGIS_generate_mipmap */ /* GL_ARB_shadow */ if (have_extension(arb_shadow)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_ARB_shadow"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ARB_shadow"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ARB_shadow */ /* GL_ARB_vertex_buffer_object */ if (have_extension(arb_vertex_buffer_object)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_ARB_vertex_buffer_object"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ARB_vertex_buffer_object"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ARB_vertex_buffer_object */ /* GL_EXT_framebuffer_object */ if (have_extension(ext_framebuffer_object)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_EXT_framebuffer_object"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_EXT_framebuffer_object"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_EXT_framebuffer_object */ /* GL_EXT_draw_range_elements */ if (have_extension(ext_draw_range_elements)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_EXT_draw_range_elements"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_EXT_draw_range_elements"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_EXT_draw_range_elements */ /* GL_ARB_texture_non_power_of_two */ if (have_extension(arb_texture_non_power_of_two)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_ARB_texture_non_power_of_two"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ARB_texture_non_power_of_two"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ARB_texture_non_power_of_two */ /* GL_ARB_fragment_program */ if (have_extension(arb_fragment_program)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_ARB_fragment_program"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ARB_fragment_program"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ARB_fragment_program */ /* GL_ARB_vertex_program */ if (have_extension(arb_vertex_program)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_ARB_vertex_program"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ARB_vertex_program"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ARB_vertex_program */ /* GL_ARB_fragment_shader */ if (have_extension(arb_fragment_shader)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_ARB_fragment_shader"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ARB_fragment_shader"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ARB_fragment_shader */ /* GL_ARB_vertex_shader */ if (have_extension(arb_vertex_shader)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_ARB_vertex_shader"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ARB_vertex_shader"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ARB_vertex_shader */ /* GL_ARB_shader_objects */ if (have_extension(arb_shader_objects)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_ARB_shader_objects"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ARB_shader_objects"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ARB_shader_objects */ /* GL_ARB_shading_language_100 */ if (have_extension(arb_shading_language_100)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_ARB_shading_language_100"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ARB_shading_language_100"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ARB_shading_language_100 */ /* GL_ARB_texture_mirrored_repeat */ if (have_extension(arb_texture_mirrored_repeat)) { safe_snprintf(str, sizeof(str), gl_ext_found_not_used, "GL_ARB_texture_mirrored_repeat"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ARB_texture_mirrored_repeat"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ARB_texture_mirrored_repeat */ /* GL_ARB_texture_rectangle */ if (have_extension(arb_texture_rectangle)) { safe_snprintf(str, sizeof(str), gl_ext_found_not_used, "GL_ARB_texture_rectangle"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ARB_texture_rectangle"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ARB_texture_rectangle */ /* GL_EXT_fog_coord */ if (have_extension(ext_fog_coord)) { safe_snprintf(str, sizeof(str), gl_ext_found_not_used, "GL_EXT_fog_coord"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_EXT_fog_coord"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_EXT_fog_coord */ /* GL_ATI_texture_compression_3dc */ if (have_extension(ati_texture_compression_3dc)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_ATI_texture_compression_3dc"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_ATI_texture_compression_3dc"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_ATI_texture_compression_3dc */ /* GL_EXT_texture_compression_latc */ if (have_extension(ext_texture_compression_latc)) { safe_snprintf(str, sizeof(str), gl_ext_found, "GL_EXT_texture_compression_latc"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_EXT_texture_compression_latc"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_EXT_texture_compression_latc */ /* GL_EXT_texture_filter_anisotropic */ if (have_extension(ext_texture_filter_anisotropic)) { glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &anisotropic_filter); safe_snprintf(str, sizeof(str), gl_ext_found, "GL_EXT_texture_filter_anisotropic"); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { anisotropic_filter = 1.0f; safe_snprintf(str, sizeof(str), gl_ext_not_found, "GL_EXT_texture_filter_anisotropic"); LOG_TO_CONSOLE(c_red1, str); LOG_DEBUG("%s\n",str); } /* GL_EXT_texture_filter_anisotropic */ #if 0 // Disabled because of bad drivers if (have_extension(ext_framebuffer_object)) { check_fbo_formats(); } #endif init_shaders(); #ifdef GL_EXTENSION_CHECK evaluate_extension(); #endif //GL_EXTENSION_CHECK gl_extensions_loaded = 1; CHECK_GL_ERRORS(); }
void evaluate_extension() { char str[1024]; int has_arb_texture_env_add; int has_arb_texture_env_crossbar; int has_arb_texture_rectangle; int has_arb_fragment_shader_shadow; int has_ati_fragment_shader; int has_ati_texture_env_combine3; int has_nv_texture_env_combine4; int has_nv_texture_shader; int has_nv_texture_shader2; int options; char* extensions; extensions = (char*)glGetString(GL_EXTENSIONS); has_arb_texture_env_add = strstr(extensions, "GL_ARB_texture_env_add") > 0; has_arb_texture_env_crossbar = strstr(extensions, "GL_ARB_texture_env_crossbar") > 0; has_arb_texture_rectangle = strstr(extensions, "GL_ARB_texture_rectangle") > 0; has_arb_fragment_shader_shadow = strstr(extensions, "GL_ARB_fragment_program_shadow") > 0; has_ati_fragment_shader = strstr(extensions, "GL_ATI_fragment_shader") > 0; has_ati_texture_env_combine3 = strstr(extensions, "GL_ATI_texture_env_combine3") > 0; has_nv_texture_env_combine4 = strstr(extensions, "GL_NV_texture_env_combine4") > 0; has_nv_texture_shader = strstr(extensions, "GL_NV_texture_shader") > 0; has_nv_texture_shader2 = strstr(extensions, "GL_NV_texture_shader2") > 0; options = (get_texture_units() >= 2) && has_arb_texture_env_add && have_extension(arb_texture_env_combine) && have_extension(arb_vertex_program) && have_extension(arb_texture_compression) && have_extension(arb_vertex_buffer_object) && have_extension(ext_texture_compression_s3tc); if (!options) { safe_snprintf(str,sizeof(str),"%s%s%s","Your graphic card/driver don't support the minimum", " requirements for the next EL release. Please upgrade your driver.", " If this don't help, you need a better graphic card."); LOG_TO_CONSOLE(c_red1, str); LOG_ERROR("%s\n",str); return; } if (!have_extension(arb_vertex_shader) || (have_extension(arb_fragment_program) && !have_extension(arb_fragment_shader)) || (has_ati_fragment_shader && !have_extension(arb_fragment_program) && !have_extension(arb_fragment_shader))) { safe_snprintf(str,sizeof(str),"Please update your graphic card driver!"); LOG_TO_CONSOLE(c_yellow1, str); LOG_WARNING("%s\n",str); } options = ((has_ati_texture_env_combine3 && has_arb_texture_env_crossbar) || has_nv_texture_env_combine4) && (get_texture_units() >= 4) && have_extension(ext_draw_range_elements) && have_extension(arb_shadow) && have_extension(arb_point_parameters) && have_extension(arb_point_sprite); if (!options) { safe_snprintf(str,sizeof(str),"%s%s%s","Your graphic card supports the absolute minimum", " requirements for the next EL release, but don't expect that you can use", " all features."); LOG_TO_CONSOLE(c_yellow1, str); LOG_DEBUG("%s\n",str); } else { options = (has_ati_fragment_shader || (has_nv_texture_shader && has_nv_texture_shader2)) && have_extension(arb_occlusion_query) && has_arb_texture_rectangle && have_extension(ext_framebuffer_object); if (!options) { safe_snprintf(str,sizeof(str),"%s%s","Your graphic card supports the default ", "requirements for the next EL release."); LOG_TO_CONSOLE(c_green2, str); LOG_DEBUG("%s\n",str); } else { if (have_extension(arb_fragment_shader) && have_extension(arb_shader_objects) && have_extension(arb_vertex_shader) && have_extension(arb_shading_language_100)) { safe_snprintf(str,sizeof(str),"%s%s","Your graphic card supports all ", "features EL will use in the future."); LOG_TO_CONSOLE(c_blue2, str); LOG_DEBUG("%s\n",str); } else { safe_snprintf(str,sizeof(str),"%s%s","Your graphic card supports more than the", " default requirements for the next EL release."); LOG_TO_CONSOLE(c_blue2, str); LOG_DEBUG("%s\n",str); } } } }