Class OcsfmlGraphics.render_window

class render_window : ? list -> ?context:OcsfmlWindow.ContextSettings.t -> OcsfmlWindow.VideoMode.t -> string -> object .. end
Window that can serve as a target for 2D drawing.

OcsfmlGraphics.render_window is the main class of the Graphics module.

It defines an OS window that can be painted using the other classes of the graphics module.

OcsfmlGraphics.render_window is derived from OcsfmlWindow.window, thus it inherits all its features: events, window management, OpenGL rendering, etc. See the documentation of OcsfmlWindow.window for a more complete description of all these features, as well as code examples.

On top of that, OcsfmlWindow.render_window adds more features related to 2D drawing with the graphics module (see its base class OcsfmlGraphics.render_target for more details). Here is a typical rendering and event loop with a OcsfmlWindow.render_window:

    (* Declare and create a new render-window *)
    let window = new window (OcsfmlGraphics.VideoMode.create ~w:800 ~h:600 ()) "SFML window" in
    (* Limit the framerate to 60 frames per second (this step is optional) *)
    window#set_framerate_limit 60 

    (* Event processing *)
    let rec process_events () =
      match window#poll_event with
        | Some e -> 
           begin match e with
             | OcsfmlWindow.Event.Closed -> window#close
             | _ -> () 
          end ;
          process_events ()
        | _ -> ()

    (* The main loop - ends as soon as the window is closed *)
    let rec main_loop () =
      process_events () ;
      (* Clear the whole window before rendering a new frame *)
      window#clear () ;

      (* Draw some graphical entities *)
      window#draw sprite ;
      window#draw circle ;
      window#draw text ;

      (* End the current frame and display its contents on screen *)

      if window#is_open
      then main_loop () 
    main_loop ()

method destroy : unit
method capture : image
Copy the current contents of the window to an image.

This is a slow operation, whose main purpose is to make screenshots of the application. If you want to update an image with the contents of the window and then use it for drawing, you should rather use a OcsfmlGraphics.texture and its update_from_window function. You can also draw things directly to a texture with the OcsfmlGraphics.render_texture class.
Returns Image containing the captured contents.

method set_icon : OcsfmlWindow.pixel_array_type -> unit
Change the window's icon.

pixels must be a bigarray of width x height pixels in 32-bits RGBA format.

The OS default icon is used by default.