indexing description: "[ A Simple Scene Demo ]" date: "$Date$" revision: "$Revision$" class SIMPLE_SCENE inherit EM_KEY_CONSTANTS EM_SHARED_BITMAP_FACTORY export {NONE} all end EM_SHARED_SUBSYSTEMS export {NONE} all end EM_DRAWABLE_SCENE redefine handle_update_event, handle_quit_event, redraw end EM_CONSTANTS export {NONE} all end GL_FUNCTIONS export {NONE} all end GLU_FUNCTIONS export {NONE} all end create make feature {NONE} -- Creation make is -- creation procedure do make_scene initialize_images -- we need this to reset some setting to draw this scene correctly -- if cube was shown before if Video_subsystem.video_surface.is_opengl_blitting_enabled then Video_subsystem.video_surface.disable_opengl_blitting gl_tex_envi (Em_gl_texture_env, Em_gl_texture_env_mode, Em_gl_modulate) end end feature {NONE} -- Initialization initialize_images is -- Initialize all images. do bitmap_factory.create_bitmap_from_image ("./image/matterhorn.jpg") check todo_proper_error_handling: bitmap_factory.last_bitmap /= Void end background_image := bitmap_factory.last_bitmap main_container.extend (background_image) bitmap_factory.create_bitmap_from_image ("./image/cow.gif") check todo_proper_error_handling: bitmap_factory.last_bitmap /= Void end image := bitmap_factory.last_bitmap main_container.extend (image) ensure image_not_void: image /= Void end feature -- Event handling handle_quit_event (a_quit_event: EM_QUIT_EVENT) is -- Handle quit events. do event_loop.stop end handle_update_event is -- Handle the outside event. local keyboard: EM_KEYBOARD do create keyboard.make_snapshot if keyboard.is_pressed (sdlk_up) then image.set_y (image.y - delta) end if keyboard.is_pressed (sdlk_left) then image.set_x (image.x - delta) end if keyboard.is_pressed (sdlk_right) then image.set_x (image.x + delta) end if keyboard.is_pressed (sdlk_down) then image.set_y (image.y + delta) end end feature -- Drawing redraw is -- Redraw `Current' scene. -- Causes to clear `screen' and redraw `main_container' onto it. do if Video_subsystem.opengl_enabled and not Video_subsystem.video_surface.is_opengl_blitting_enabled then Video_subsystem.video_surface.enable_opengl_blitting end -- Because we haven OpenGl enabled we need to clear the buffer this way -- Reset depth buffer and clear the screen gl_clear_external (Em_gl_color_buffer_bit | Em_gl_depth_buffer_bit) -- Without OpenGl -- if background_color /= Void then -- screen.fill (background_color) -- end main_container.draw (screen) screen.redraw end feature {NONE} -- Implementation image: EM_BITMAP -- Foreground image background_image: EM_BITMAP -- Background image Delta: INTEGER is 5 -- Delta indicates how far the surface should -- be moved upon an arrow key press end