Loading ...
Sorry, an error occurred while loading the content.

graphics on OSX ocaml - GUI?

Expand Messages
  • herve_5
    Hello, I just installed ocalm 3.09 from its compiled version onto an intel-based mac (OSX 10.4.9). ocaml runs without trouble in the terminal window, and I
    Message 1 of 5 , Apr 8, 2007
    • 0 Attachment
      Hello,

      I just installed ocalm 3.09 from its compiled version onto an intel-based mac (OSX 10.4.9).

      ocaml runs without trouble in the terminal window, and I even found a reasonable GUI for
      mac at <http://www.cs.unm.edu/~wneumann/cococaml> (seems not updated for a couple
      of years though).

      I run into problems with graphics output. Being a terrible beginner I cannot even understand
      whether my compiled version lacks the graphics libraries (how can I check?), and/or if I need
      something better than the basic OSX terminal to see something :-(

      Any advice on how to get a graphics-enabled solution on OSX would be most welcome!

      TIA,
      Hervé Sainct
    • Richard Jones
      ... I guess the question is - which graphics module? The very primitive Graphics module is a basic part of OCaml and probably works on Mac OS X. You should
      Message 2 of 5 , Apr 8, 2007
      • 0 Attachment
        On Sun, Apr 08, 2007 at 09:00:41AM -0000, herve_5 wrote:
        > I run into problems with graphics output. Being a terrible beginner
        > I cannot even understand whether my compiled version lacks the
        > graphics libraries (how can I check?), and/or if I need something
        > better than the basic OSX terminal to see something :-(
        >
        > Any advice on how to get a graphics-enabled solution on OSX would be
        > most welcome!

        I guess the question is - which graphics module?

        The very primitive Graphics module is a basic part of OCaml and
        probably works on Mac OS X. You should see if the example from here
        works or you:
        http://www.ocaml-tutorial.org/the_structure_of_ocaml_programs

        You might need to install X11.app (from Mac OS X install disk 1) for
        the above to work.

        As for widget libraries -- probably more useful for you -- there are a
        variety of options, none of which seem to be very well developed. For
        example, alpha-quality Cocoa bindings:
        http://labo.epimac.org/article.php3?id_article=7 and it may be
        possible to get Gtk and lablgtk2 working, but you'll probably end up
        compiling everything yourself.

        Rich.

        --
        Richard Jones
        Red Hat
      • William Neumann
        ... Yes. To use the Graphics module, you need to install and run X11.app (though I remember a project that somehow used native graphics, though I can t find
        Message 3 of 5 , Apr 8, 2007
        • 0 Attachment
          On Apr 8, 2007, at 9:06 AM, Richard Jones wrote:

          > You might need to install X11.app (from Mac OS X install disk 1) for
          > the above to work.

          Yes. To use the Graphics module, you need to install and run X11.app
          (though I remember a project that somehow used native graphics,
          though I can't find it with a half-assed google search). Then start
          your toplevel from the X11 temminal (if you're using cococaml, you
          can launch it with "open /Applications/CocOCaml.app").

          Then just enter
          #load "graphics.cma";;
          open Graphics;;

          into the toplevel, and you're good to go.

          open_graph " 600x600";;
          set_color yellow;;
          fill_circle 300 300 200;;
          set_color black;;
          fill_ellipse 225 375 35 50;;
          fill_ellipse 375 375 35 50;;
          set_line_width 5;;
          draw_arc 300 300 100 100 225 315;;
          draw_circle 300 300 200;;

          let draw_face x y r =
          set_color yellow;
          fill_circle x y r;
          set_color black;
          let offset = 3 * r / 8 in
          fill_ellipse (x - offset) (y + offset) (r / 5) (r / 4);
          fill_ellipse (x + offset) (y + offset) (r / 5) (r / 4);
          set_line_width (max 1 (r/40));
          draw_arc x y (r / 2) (r/2) 225 315;
          draw_circle x y r;;

          draw_face 500 500 25;;


          William D. Neumann

          "I eat T-bone steaks, I lift barbell plates, I'm sweeter than a
          German chocolate cake. I'm the reflection of perfection, the number
          one selection. I'm the man of the hour, the man with the power, too
          sweet to be sour. The ladies' pet, the men's regret, where what you
          see is what you get, and what you don't see, is better yet."

          --Superstar Billy Graham
        • vincent.aravantinos
          ... How does ocamlbrowser work ? It has a GUI but does not need X11 - ie: works with a simple terminal - Vincent
          Message 4 of 5 , Apr 9, 2007
          • 0 Attachment
            --- In ocaml_beginners@yahoogroups.com, William Neumann <wneumann@...> wrote:
            >
            > On Apr 8, 2007, at 9:06 AM, Richard Jones wrote:
            >
            > > You might need to install X11.app (from Mac OS X install disk 1) for
            > > the above to work.
            >
            > Yes. To use the Graphics module, you need to install and run X11.app
            > (though I remember a project that somehow used native graphics,
            > though I can't find it with a half-assed google search). Then start
            > your toplevel from the X11 temminal (if you're using cococaml, you
            > can launch it with "open /Applications/CocOCaml.app").

            How does ocamlbrowser work ?
            It has a GUI but does not need X11 - ie: works with a simple terminal -

            Vincent
          • William D. Neumann
            ... It uses labltk. Apple has aqua native tcl/tk frameworks. The same can probably work with OpenGL apps, but I m not sure. William D. Neumann ... There s
            Message 5 of 5 , Apr 9, 2007
            • 0 Attachment
              On Mon, 9 Apr 2007, vincent.aravantinos wrote:

              > How does ocamlbrowser work ?
              > It has a GUI but does not need X11 - ie: works with a simple terminal -

              It uses labltk. Apple has aqua native tcl/tk frameworks.
              The same can probably work with OpenGL apps, but I'm not sure.

              William D. Neumann

              ---

              "There's just so many extra children, we could just feed the
              children to these tigers. We don't need them, we're not doing
              anything with them.

              Tigers are noble and sleek; children are loud and messy."

              -- Neko Case

              Life is unfair. Kill yourself or get over it.
              -- Black Box Recorder
            Your message has been successfully submitted and would be delivered to recipients shortly.