indexing description: "[ A scene which uses OpenGL to draw its content. Inherit from this class and put your OpenGL drawing code in the feature `draw'. Have a look at the code of `redraw' and `initialize_scene' to see which options of OpenGL are alredy set. To react on input events, redefine the various `handle_*' features. ]" date: "$Date$" revision: "$Revision$" deferred class EM_GL_SCENE inherit EM_SCENE redefine make_scene end EM_SHARED_SUBSYSTEMS export {NONE} all end EM_CONSTANTS export {NONE} all end GL_FUNCTIONS_EXTERNAL export {NONE} all end GLU_FUNCTIONS_EXTERNAL export {NONE} all end feature {NONE} -- Initialisation make_scene is -- Initialise default values. do Precursor {EM_SCENE} min_view_distance := 0.1 max_view_distance := 100.0 field_of_view := 45.0 end initialize_scene is -- Initialize scene. do Video_subsystem.video_surface.disable_opengl_blitting -- Opengl settings gl_enable_external (Em_gl_depth_test) -- Enable antialiasing gl_enable_external (Em_gl_line_smooth) gl_hint_external (Em_gl_line_smooth, Em_gl_nicest) -- Setup the projection matrix gl_matrix_mode_external (Em_gl_projection) gl_load_identity_external glu_perspective_external (field_of_view, Video_subsystem.video_surface_width/Video_subsystem.video_surface_height, min_view_distance, max_view_distance) -- Setup the model view matrix gl_matrix_mode_external (Em_gl_modelview) gl_load_identity_external end feature -- Access min_view_distance: DOUBLE -- Minimal viewing distance max_view_distance: DOUBLE -- Maximum viewing distance field_of_view: DOUBLE -- Field of view in degrees feature -- Element change set_min_view_distance (a_distance: like min_view_distance) is -- Set `min_view_distance' to `a_distance'. require a_distance_positive: a_distance > 0 a_distance_smaller_max: a_distance < max_view_distance do min_view_distance := a_distance ensure min_view_distance_set: min_view_distance = a_distance end set_max_view_distance (a_distance: like max_view_distance) is -- Set `max_view_distance' to `a_distance'. require a_distance_positive: a_distance > 0 a_distance_bigger_min: a_distance > min_view_distance do max_view_distance := a_distance ensure max_view_distance_set: max_view_distance = a_distance end set_field_of_view (a_fov: like field_of_view) is -- Set `field_of_view' to `a_fov'. do field_of_view := a_fov ensure field_of_view_set: field_of_view = a_fov end feature -- Drawing redraw is -- Redraw scene. do -- Reset depth buffer and clear the screen gl_clear_external (Em_gl_color_buffer_bit | Em_gl_depth_buffer_bit) -- Clear modelview matrix gl_load_identity_external -- Draw scene draw screen.redraw end draw is -- Draw scene. deferred end end