note description: "An object which does all the image rendering on a GAME_WINDOW" author: "Louis Marchand" date: "Thu, 02 Apr 2015 02:40:10 +0000" revision: "2.0" class interface GAME_RENDERER create {GAME_WINDOW_RENDERED} make, make_with_flags, make_with_renderer_driver feature -- Access present -- Show the last drawed modification require renderer_exists: exists target: GAME_RENDER_TARGET assign set_target -- What GAME_RENDER_TARGET to use when using the present original_target: GAME_WINDOW_RENDERED -- The window that will be targetted -- (if no set_target has been called) -- command set_target (a_target: GAME_RENDER_TARGET) -- Assign what GAME_RENDER_TARGET to use when using the present -- command require renderer_exists: exists ensure is_set: not has_error implies target = a_target set_original_target -- Put back the original_target as -- the target require renderer_exists: exists clear -- Fill the target with -- the drawing_color require renderer_exists: exists draw_texture (a_texture: GAME_TEXTURE; a_x, a_y: INTEGER_32) -- Draw the whole a_texture on Current at (a_x,a_y) require renderer_exists: exists draw_sub_texture (a_texture: GAME_TEXTURE; a_x_source, a_y_source, a_width, a_height, a_x_destination, a_y_destination: INTEGER_32) -- Draw the part of a_texture from (a_x_source,a_y_source) -- of size a_widthxa_height on Current at (a_x_destination,a_y_destination) require renderer_exists: exists draw_sub_texture_with_scale (a_texture: GAME_TEXTURE; a_x_source, a_y_source, a_width_source, a_height_source, a_x_destination, a_y_destination, a_width_destination, a_height_destination: INTEGER_32) -- Draw the part of a_texture from (a_x_source,a_y_source) -- of size a_width_sourcexa_height_source on the part of Current -- at (a_x_destination,a_y_destination) of size -- a_width_destinationxa_height_destination require renderer_exists: exists draw_texture_with_rotation (a_texture: GAME_TEXTURE; a_x, a_y: INTEGER_32; a_x_rotation_center, a_y_rotation_center: INTEGER_32; a_rotation_angle: REAL_64) -- Draw the whole a_texture on Current at (a_x,a_y) rotate -- of a_rotation_angle degree with the rotation center at -- (a_x_rotation_center,a_y_rotation_center) require renderer_exists: exists draw_sub_texture_with_rotation (a_texture: GAME_TEXTURE; a_x_source, a_y_source, a_width_source, a_height_source, a_x_destination, a_y_destination, a_x_rotation_center, a_y_rotation_center: INTEGER_32; a_rotation_angle: REAL_64) -- Draw the part of a_texture from (a_x_source,a_y_source) -- of size a_width_sourcexa_height_source on the part of Current -- at (a_x_destination,a_y_destination) of size -- a_width_destinationxa_height_destination. -- Also, rotate the draw of a_rotation_angle degree using the rotation center -- (a_x_rotation_center,a_y_rotation_center) require renderer_exists: exists draw_texture_with_mirror (a_texture: GAME_TEXTURE; a_x, a_y: INTEGER_32; a_vertical_mirror, a_horizontal_mirror: BOOLEAN) -- Draw the whole a_texture on Current at (a_x,a_y) -- Also, use a vertical mirror on the drawed image if a_vertical_mirror -- is True and an horizontal one if a_horizontal_mirror is True. require renderer_exists: exists draw_sub_texture_with_mirror (a_texture: GAME_TEXTURE; a_x_source, a_y_source, a_width_source, a_height_source, a_x_destination, a_y_destination: INTEGER_32; a_vertical_mirror, a_horizontal_mirror: BOOLEAN) -- Draw the part of a_texture from (a_x_source,a_y_source) -- of size a_width_sourcexa_height_source on the part of Current -- at (a_x_destination,a_y_destination) of size -- a_width_destinationxa_height_destination. -- Also, use a vertical mirror on the drawed image if a_vertical_mirror -- is True and an horizontal one if a_horizontal_mirror is True. require renderer_exists: exists draw_sub_texture_with_scale_rotation_and_mirror (a_texture: GAME_TEXTURE; a_x_source, a_y_source, a_width_source, a_height_source, a_x_destination, a_y_destination, a_width_destination, a_height_destination, a_x_rotation_center, a_y_rotation_center: INTEGER_32; a_rotation_angle: REAL_64; a_vertical_mirror, a_horizontal_mirror: BOOLEAN) -- Draw the part of a_texture from (a_x_source,a_y_source) -- of size a_width_sourcexa_height_source on the part of Current -- at (a_x_destination,a_y_destination) of size -- a_width_destinationxa_height_destination. -- Also, rotate the draw of a_rotation_angle degree using the rotation center -- (a_x_rotation_center,a_y_rotation_center). Finally, use a vertical mirror on -- the drawed image if a_vertical_mirror is True and an horizontal one if -- a_horizontal_mirror is True. require renderer_exists: exists drawing_color: GAME_COLOR_READABLE assign set_drawing_color -- All performed drawing on Current is done -- using this color (including clear) require renderer_exists: exists set_drawing_color (a_drawing_color: GAME_COLOR_READABLE) -- Assign the value of the drawing_color require renderer_exists: exists draw_point (a_x, a_y: INTEGER_32) -- Draw a point at (a_x, a_y) require renderer_exists: exists draw_points (a_points: CHAIN [TUPLE [x: INTEGER_32; y: INTEGER_32]]) -- Draw points using all (x, y) in a_points require renderer_exists: exists draw_line (a_x1, a_y1, a_x2, a_y2: INTEGER_32) -- Draw a line from (a_x1, a_y1) to (a_x2, a_y2) require renderer_exists: exists draw_connected_lines (a_points: CHAIN [TUPLE [x: INTEGER_32; y: INTEGER_32]]) -- Draw connected lines using all (x, y) in a_points require renderer_exists: exists draw_rectangle (a_x, a_y, a_width, a_height: INTEGER_32) -- Drawing a wire rectangle of dimension -- a_widthxa_height that has it's left frontier at -- a_x, it's top frontier at a_y. require renderer_exists: exists draw_rectangles (a_rectangles: CHAIN [TUPLE [x: INTEGER_32; y: INTEGER_32; width: INTEGER_32; height: INTEGER_32]]) -- Drawing every wire rectangle in a_rectangles -- that has it's left frontier at -- x, it's top frontier at y, with -- dimension widthxheight require renderer_exists: exists draw_filled_rectangle (a_x, a_y, a_width, a_height: INTEGER_32) -- Drawing a filled rectangle of dimension -- a_widthxa_height that has it's left frontier at -- a_x, it's top frontier at a_y. require renderer_exists: exists draw_filled_rectangles (a_rectangles: CHAIN [TUPLE [x: INTEGER_32; y: INTEGER_32; width: INTEGER_32; height: INTEGER_32]]) -- Drawing every wire rectangle in a_rectangles -- that has it's left frontier at -- x, it's top frontier at y, with -- dimension widthxheight require renderer_exists: exists output_size: TUPLE [width: INTEGER_32; height: INTEGER_32] -- Get the size of the output of Current require renderer_exists: exists clip_rectangle: TUPLE [x: INTEGER_32; y: INTEGER_32; width: INTEGER_32; height: INTEGER_32] -- Indicate what rectangle must be drawed when a draw is -- use. Every drawing outside of the rectangle will be -- ignored require renderer_exists: exists set_clip_rectangle (a_x, a_y, a_width, a_height: INTEGER_32) -- Assign clip_rectangle with the values of a_x, a_y, -- a_width and a_height require renderer_exists: exists ensure is_set: (attached clip_rectangle as la_clip_rectangle and attached normalize_rectangle (a_x, a_y, a_width, a_height) as la_normalized_rectangle) implies (la_clip_rectangle.x = la_normalized_rectangle.x and la_clip_rectangle.y = la_normalized_rectangle.y and la_clip_rectangle.width = la_normalized_rectangle.width and la_clip_rectangle.height = la_normalized_rectangle.height) disable_clip_rectangle -- Remove every clip rectangle from Current require renderer_exists: exists logical_size: TUPLE [width: INTEGER_32; height: INTEGER_32] -- Get the device independant logical size of the output of Current -- [0,0] if never set.. -- Modifying this value may change the scale and viewport values. require renderer_exists: exists set_logical_size (a_width, a_height: INTEGER_32) -- Assign logical_size using values in a_width and a_height. -- Using this feature may change the scale and viewport values. require renderer_exists: exists width_valid: a_width > 0 height_valid: a_height > 0 ensure is_set: attached logical_size as la_logical_size implies (la_logical_size.width = a_width and la_logical_size.height = a_height) scale: TUPLE [x: REAL_32; y: REAL_32] -- Get the scale x and y that Current have to do when drawing. -- Note: For better performance, use integer scaling factor require renderer_exists: exists set_scale (a_x, a_y: REAL_32) -- Assign scale using values in a_x and a_y require renderer_exists: exists ensure is_set: attached scale as la_scale implies (la_scale.x = a_x and la_scale.y = a_y) viewport: TUPLE [x: INTEGER_32; y: INTEGER_32; width: INTEGER_32; height: INTEGER_32] -- The position and size of the drawing area in Current require renderer_exists: exists set_viewport (a_x, a_y, a_width, a_height: INTEGER_32) -- Assign viewport using values in a_x, a_y, a_width -- and a_height. Note that depending on the scale values, -- the viewport may be round to another close value. require renderer_exists: exists ensure is_set: (attached viewport as la_viewport and attached scale as la_scale and attached normalize_rectangle (a_x, a_y, a_width, a_height) as la_normalized_rectangle) implies (la_viewport.x.to_double >= la_normalized_rectangle.x.to_double - (1.0 / la_scale.x.to_double) and la_viewport.x.to_double <= la_normalized_rectangle.x.to_double + (1.0 / la_scale.x.to_double) and la_viewport.y.to_double >= la_normalized_rectangle.y.to_double - (1.0 / la_scale.y.to_double) and la_viewport.y.to_double <= la_normalized_rectangle.y.to_double + (1.0 / la_scale.y.to_double) and la_viewport.width.to_double >= la_normalized_rectangle.width.to_double - (1.0 / la_scale.x.to_double) and la_viewport.width.to_double <= la_normalized_rectangle.width.to_double + (1.0 / la_scale.x.to_double) and la_viewport.height.to_double >= la_normalized_rectangle.height.to_double - (1.0 / la_scale.y.to_double) and la_viewport.height.to_double <= la_normalized_rectangle.height.to_double + (1.0 / la_scale.y.to_double)) exists: BOOLEAN -- Is item a valid pointer to be used as blenderable driver: GAME_RENDERER_DRIVER -- The driver used to render Current end -- class GAME_RENDERER
Generated by ISE EiffelStudio