indexing description: "[ A mipmap texture which takes the content from an EM_SURFACE. The texture is updated automatically when `surface' is modified. ]" date: "$Date$" revision: "$Revision$" class GL_SURFACE_MIPMAP_TEXTURE inherit GL_SURFACE_TEXTURE redefine compute_texture_size, generate_texture end create make_from_surface feature {NONE} -- Implementation compute_texture_size is -- Compute texture size as next higher power of 2 of surface dimension. do width := surface.width height := surface.height end generate_texture is -- Generate texture. local alpha_was_enabled: BOOLEAN saved_flags: INTEGER saved_alpha: INTEGER error: INTEGER c_string: EWG_ZERO_TERMINATED_STRING do saved_flags := surface.flags & (Em_srcalpha | Em_rleaccelok) alpha_was_enabled := surface.is_alpha_transparency_enabled if alpha_was_enabled then saved_alpha := surface.alpha_value surface.disable_alpha_transparency end -- blit to surface with correct opengl format internal_surface.blit_surface (surface, 0, 0) -- restore the alpha blending attributes if alpha_was_enabled then error := sdl_set_alpha_external (surface.item, saved_flags, saved_alpha) end gl_bind_texture_external (Em_gl_texture_2d, internal_id) gl_color3f_external (1, 0, 0) error := glu_build2dmipmaps_external ( Em_gl_texture_2d, Em_gl_rgba, width, height, Em_gl_rgba, Em_gl_unsigned_byte, internal_surface.pixels ) if error /= 0 then create c_string.make_shared (glu_error_string_external (error)) Error_handler.raise_warning (Error_handler.Em_error_generate_mipmap, [c_string.string]) end end end