indexing description: "[ Example component to show implementation of a 3D scene component. Drawing: Implement 'draw' and put your OpenGL code there. Events: See EM_COMPONENT ]" date: "$Date$" revision: "$Revision$" class SIERPINSKI_SCENE inherit EM_COMPONENT_SCENE create make feature {NONE} -- Initialisation make is -- Initialise default values. do make_component_scene show_opengl_demo -- 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 show_opengl_demo is -- Show OpenGL demo. local text: STRING label: EM_LABEL button: EM_BUTTON checkbox: EM_CHECKBOX do if sierpinski_display = Void then -- Help text create sierpinski_help_panel.make_from_dimension (width, 100) sierpinski_help_panel.set_position (0, 0) create text.make_empty text.append_string ("To display 3D content together with widgets, use an EM_3D_COMPONENT.%N") text.append_string ("Basic approach:%N") text.append_string (" - inherit from EM_3D_COMPONENT%N") text.append_string (" - place OpenGL code in 'draw'%N") text.append_string (" - subscribe on desired event types to react on input events") create label.make_from_text (text) label.set_position (0, 10) label.set_dimension (570, 90) label.enable_multilined label.align_top sierpinski_help_panel.add_widget (label) -- Sierpinski pyramid create sierpinski_display.make sierpinski_display.set_position (0, 100) sierpinski_display.set_dimension (width, height-140) -- Usage text create sierpinski_control_panel.make_from_dimension (width, 40) sierpinski_control_panel.set_position (0, height-40) create label.make_from_text ("Level: ") label.set_dimension (50, 20) label.align_right sierpinski_control_panel.add_widget (label) create button.make_from_text ("+") button.set_dimension (20, 20) button.set_position (50, 0) button.clicked_event.subscribe (agent sierpinski_display.increase_subdivisions) sierpinski_control_panel.add_widget (button) create button.make_from_text ("-") button.set_dimension (20, 20) button.set_position (70, 0) button.clicked_event.subscribe (agent sierpinski_display.decrease_subdivisions) sierpinski_control_panel.add_widget (button) create label.make_from_text ("Zoom: ") label.set_position (100, 0) label.set_dimension (50, 20) label.align_right sierpinski_control_panel.add_widget (label) create button.make_from_text ("+") button.set_dimension (20, 20) button.set_position (150, 0) button.clicked_event.subscribe (agent sierpinski_display.decrease_distance) sierpinski_control_panel.add_widget (button) create button.make_from_text ("-") button.set_dimension (20, 20) button.set_position (170, 0) button.clicked_event.subscribe (agent sierpinski_display.increase_distance) sierpinski_control_panel.add_widget (button) create checkbox.make_from_text ("Lighting") checkbox.set_position (200, 0) checkbox.set_dimension (100, 20) checkbox.checked_event.subscribe (agent sierpinski_display.enable_lighting) checkbox.unchecked_event.subscribe (agent sierpinski_display.disable_lighting) sierpinski_control_panel.add_widget (checkbox) create checkbox.make_from_text ("Fog") checkbox.set_position (300, 0) checkbox.set_dimension (100, 20) checkbox.checked_event.subscribe (agent sierpinski_display.enable_fog) checkbox.unchecked_event.subscribe (agent sierpinski_display.disable_fog) sierpinski_control_panel.add_widget (checkbox) create label.make_from_text ("drag to rotate - mouse wheel to zoom - left click increase level - right click decrease level") label.set_dimension (width, 20) label.set_position (0, 20) label.align_center sierpinski_control_panel.add_widget (label) end add_component (sierpinski_display) add_component (sierpinski_control_panel) add_component (sierpinski_help_panel) end sierpinski_display: SIERPINSKI_DISPLAY -- Sierpinski piramyd display sierpinski_control_panel: EM_PANEL -- Panel with controls for sierpinski display sierpinski_help_panel: EM_PANEL -- Panel to display help text end