indexing description: "Two dimensional texture" date: "$Date$" revision: "$Revision$" class EMGLU_TEXTURE_2D[F -> EMGL_FORMAT create default_create end] inherit EMGLU_TEXTURE[F] undefine default_create end EMGL_TEXTURE_2D[F] EMGLU_FUNCTIONS export {NONE} all undefine default_create end EM_CONSTANTS export {NONE} all undefine default_create end EM_SHARED_BITMAP_FACTORY export {NONE} all undefine default_create end EM_SHARED_ERROR_HANDLER export {NONE} all undefine default_create end create make_empty, make_from_surface, make_from_surface_stretched, make_mipmap_from_surface, make_mipmap_from_surface_with_border, make_mipmap_from_surface_stretched, make_mipmap_from_surface_with_border_stretched feature {NONE} -- Initialization make_mipmap_from_surface (a_surface: EM_SURFACE) is -- require valid_bitmap: a_surface /= Void do make_mipmap_from_surface_with_border (a_surface, 0) end make_mipmap_from_surface_stretched (a_surface: EM_SURFACE) is -- require valid_bitmap: a_surface /= Void do make_mipmap_from_surface_with_border_stretched (a_surface, 0) end make_mipmap_from_surface_with_border( a_surface: EM_SURFACE; border: INTEGER) is -- Create a new EMGL_TEXTURE_2D object from a bitmap require valid_bitmap: a_surface/=void local tmp_surface: EM_SURFACE height, width: INTEGER error: INTEGER do default_create width := next_power_of_two( a_surface.width + border*2) height := next_power_of_two( a_surface.height + border*2) bitmap_factory.create_empty_open_gl_bitmap (width, height) tmp_surface := bitmap_factory.last_bitmap -- Transparent texture fix if a_surface.is_alpha_transparency_enabled then a_surface.disable_alpha_transparency tmp_surface.blit_surface (a_surface, border, border) a_surface.enable_alpha_transparency else tmp_surface.blit_surface (a_surface, border, border) end -- clear any opengl error from until gl_get_error_external = 0 loop end bind_and_save_old set_texture_min_filter_internal( em_gl_linear ) set_texture_mag_filter_internal( em_gl_linear ) error := glu_build2dmipmaps_external ( Em_gl_texture_2d, internal_format, width, height, Em_gl_rgba, Em_gl_unsigned_byte, tmp_surface.pixels ) error := gl_get_error_external if error /= 0 then Error_handler.raise_warning (Error_handler.Em_error_generate_texture, [emglu_error_string( error )]) end bind_old_id is_mipmap:=true end make_mipmap_from_surface_with_border_stretched( a_surface: EM_SURFACE; border: INTEGER) is -- Create a new EMGL_TEXTURE_2D object from a bitmap require valid_bitmap: a_surface/=void local tmp_surface: EM_SURFACE height, width: INTEGER error: INTEGER do default_create width := a_surface.width + border*2 height := a_surface.height + border*2 bitmap_factory.create_empty_open_gl_bitmap (width, height) tmp_surface := bitmap_factory.last_bitmap -- Transparent texture fix if a_surface.is_alpha_transparency_enabled then a_surface.disable_alpha_transparency tmp_surface.blit_surface (a_surface, border, border) a_surface.enable_alpha_transparency else tmp_surface.blit_surface (a_surface, border, border) end -- clear any opengl error from until gl_get_error_external = 0 loop end bind_and_save_old set_texture_min_filter_internal( em_gl_linear ) set_texture_mag_filter_internal( em_gl_linear ) error := glu_build2dmipmaps_external ( Em_gl_texture_2d, internal_format, width, height, Em_gl_rgba, Em_gl_unsigned_byte, tmp_surface.pixels ) error := gl_get_error_external if error /= 0 then Error_handler.raise_warning (Error_handler.Em_error_generate_texture, [emglu_error_string( error )]) end bind_old_id is_mipmap:=true end feature -- Status is_mipmap: BOOLEAN end -- class EMGLU_TEXTURE_2D