Git Product home page Git Product logo

graphics's Introduction

Graphics

The graphics library provides a set of portable drawing primitives. Drawing takes place in a separate window that is created when Graphics.open_graph is called. It used to be distributed with OCaml up to OCaml 4.08.

Screenshot

Documentation

The API is documented here and as comments in the source file src/graphics.mli.

On Unix

On Unix graphics uses the X11 windows system.

Here are the graphics mode specifications supported by Graphics.open_graph on the X11 implementation of this library: the argument to Graphics.open_graph has the format "display-name geometry", where display-name is the name of the X-windows display to connect to, and geometry is a standard X-windows geometry specification. The two components are separated by a space. Either can be omitted, or both. Examples:

  • Graphics.open_graph "foo:0": connects to the display foo:0 and creates a window with the default geometry
  • Graphics.open_graph "foo:0 300x100+50-0" connects to the display foo:0 and creates a window 300 pixels wide by 100 pixels tall, at location (50,0)
  • Graphics.open_graph " 300x100+50-0" connects to the default display and creates a window 300 pixels wide by 100 pixels tall, at location (50,0)
  • Graphics.open_graph "" connects to the default display and creates a window with the default geometry.

On Windows

On Windows graphics uses the native Win32 API.

Examples

The examples/ directory contains a few examples. You can run them with:

  • dune exec examples/graph_example.exe
  • dune exec examples/graph_test.exe
  • dune exec examples/sorts.exe

graphics's People

Contributors

alainfrisch avatar bobot avatar camlspotter avatar damiendoligez avatar danmey avatar diremy avatar dra27 avatar fdopen avatar fourchaux avatar gasche avatar hhugo avatar jeremiedimino avatar lefessan avatar maranget avatar mshinwell avatar murmour avatar nojb avatar np avatar octachron avatar pierreweis avatar roglo avatar sanette avatar shindere avatar smorimoto avatar stedolan avatar whitequark avatar xavierleroy avatar yallop avatar zoggy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphics's Issues

Unable to install graphics on a fresh opam installation on Mac OS 10.14.6

Here is the output of opam install graphics

$ opam install graphics
The following actions will be performed:
  ∗ install   conf-pkg-config 1.1   [required by conf-libX11]
  ∗ install   conf-libX11     1     [required by graphics]
  ∗ install   graphics        5.0.0
  ↻ recompile ocamlfind       1.8.1 [uses graphics]
===== ∗ 3   ↻ 1 =====
Do you want to continue? [Y/n] y

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
[ocamlfind.1.8.1] found in cache
[graphics.5.0.0] downloaded from https://github.com/ocaml/graphics/releases/download/5.0.0/graphics-5.0.0.tbz

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
⊘ removed   ocamlfind.1.8.1
∗ installed conf-pkg-config.1.1
∗ installed conf-libX11.1
[ERROR] The compilation of graphics failed at
        "/Users/vpoirrie/.opam/opam-init/hooks/sandbox.sh build dune build -p
        graphics -j 3 @install".

#=== ERROR while compiling graphics.5.0.0 =====================================#
# context     2.0.4 | macos/x86_64 | ocaml-system.4.09.0 | https://opam.ocaml.org#bd644e85
# path        ~/_opam/.opam-switch/build/graphics.5.0.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p graphics -j 3 @install
# exit-code   1
# env-file    ~/.opam/log/graphics-12083-48c407.env
# output-file ~/.opam/log/graphics-12083-48c407.out
### output ###
# [...]
# In file included from src/unix/text.c:16:
# src/unix/libgraph.h:17:10: fatal error: 'X11/Xlib.h' file not found
# #include <X11/Xlib.h>
#          ^~~~~~~~~~~~
# 1 error generated.
#       ocamlc src/subwindow.o (exit 2)
# (cd _build/default/src && /usr/local/bin/ocamlc.opt -g -ccopt -O2 -ccopt -fno-strict-aliasing -ccopt -fwrapv -ccopt -g -o subwindow.o subwindow.c)
# In file included from src/unix/subwindow.c:16:
# src/unix/libgraph.h:17:10: fatal error: 'X11/Xlib.h' file not found
# #include <X11/Xlib.h>
#          ^~~~~~~~~~~~
# 1 error generated.



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
┌─ The following actions failed
│ λ build graphics 5.0.0
└─ 
┌─ The following changes have been performed (the rest was aborted)
│ ⊘ remove  ocamlfind       1.8.1
│ ∗ install conf-libX11     1
│ ∗ install conf-pkg-config 1.1
└─ 

set_text_size doesn't work

Original bug ID: 4677
Reporter: Outsider
Status: confirmed (set by @damiendoligez on 2012-09-17T11:37:50Z)
Resolution: open
Priority: normal
Severity: text
Version: 3.11.0+beta
Target version: later
Category: standard library
Monitored by: Outsider

Bug description

It is like I said : it doesn't work and it bothers me.
I have to create a little game and I hoped to changed things the way I liked.
It is not a major problem but it could be better to fix this problem.

Make Graphics module use modern X fonts instead of X core fonts

(The following issue was imported from the OCaml bugtracker)

Original bug ID: 4917
Reporter: Richard Jones
Status: acknowledged (set by @damiendoligez on 2009-12-08T16:33:11Z)
Resolution: open
Priority: normal
Severity: feature
Version: 3.11.1
Category: otherlibs
Tags: patch
Monitored by: mehdi @glondu @hcarty @Chris00

Bug description

X core fonts have been deprecated for many years. Fedora are trying to identify pieces of software which still use X core fonts and could be changed to use modern X fonts (based on Xft and FontConfig). The OCaml Graphics module is one such place.

The attached patch changes the Graphics module to use modern X fonts. The changes are relatively simple - changing calls such as XDrawString to use the Xft equivalent (XftDrawString8).

One immediate advantage is that Graphics users will see anti-aliased fonts.

Another advantage is that Graphics users can specify font names like "Times-12" instead of the massive and incomprehensible XLFD strings ("--times--r-....")

File attachments

License exception may need an update

The linkage exception in the LICENSE file refers to "OCaml Core System", which I presume originates from a time when the graphics library was distributed with the OCaml compiler.

Multiple mouse buttons for Graphics

Original bug ID: 3693
Reporter: administrator
Status: acknowledged
Resolution: open
Priority: normal
Severity: feature
Category: otherlibs
Monitored by: @Chris00

Bug description

Full_Name: Ken Rose
Version: 3/08.1
OS: Linux
Submission from: o1-dialup-66-81-19-51.rev.o1.com (66.81.19.51)

It would be very useful if the graphics library distinguished among the various
mouse buttons, rather than forcing them all together, as in the current
implementation.

I'd be willing to implement the change and submit a patch, if that's desireable.
A quick look suggests it might be pretty easy to do, though I'm not certain
there is no trap lurking.

Thanks

  • ken

4.10 dune runtest fails undefined reference to caml_process_pending_signals

With commit ocaml/ocaml@fc788ef I get this error with dune runtest:

[   54s] Command [6] exited with code 2:
[   54s] $ (cd _build/default && /usr/bin/ocamlopt.opt -w -40 -g -o test/test.exe -I src src/graphics.cmxa test/.test.eobjs/native/test.cmx)
[   54s] /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: src/libgraphics_stubs.a(events.o): in function `caml_gr_wait_event_poll':
[   54s] /home/abuild/rpmbuild/BUILD/ocaml-graphics-5.0.0/_build/default/src/src/unix/events.c:166: undefined reference to `caml_process_pending_signals'
[   54s] collect2: error: ld returned 1 exit status
[   54s] File "caml_startup", line 1:
[   54s] Error: Error during linking

Not sure if this is an issue in ocaml to be resolved, or if external packages need to be tweaked to support 4.10.

Graphics background color under Windows

Original bug ID: 7745
Reporter: sampo
Status: confirmed (set by @dra27 on 2018-02-23T21:39:34Z)
Resolution: open
Priority: normal
Severity: minor
Version: 4.06.0
Category: otherlibs
Monitored by: @nojb

Bug description

Hello everybody.
I tested this program found at this address https://www.typerex.org/images/ocpwin-graphics.png

#load "graphics.cma";;

open Graphics;;

open_graph "600x600";;

  • : unit = ()

draw_poly [| 30,300; 200,40; 400,190; 250,500 |];;

  • : unit = ()

set_color red;;

  • : unit = ()

fill_poly [| 35,300; 200,45; 395,190; 250,495 |];;

  • : unit = ()
    With Windows(OCaml 4.06.0), two things are different:
  1. instead of writing on the graphic window "OCaml graphics" it is
    written Chinese characters.
  2. instead of the red color, the black color is displayed.
    With Linux(OCaml 4.02.3), one error:

open_graph "600x600";;

Exception: Graphics.Graphic_failure "Cannot open display 600x600".
Thank you.
(I am not sure which category I have registered, sorry if it's not the right one)

Unable to install on Mac OS 10.14.6

Hi,

I'm unable to install the package on MacOS 10.14 (Mojave), while it did work when graphics was bundled with ocaml.

Here is the error:

src/unix/libgraph.h:17:10: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>

I have xquartz installed.

Doing a

sudo ln -s /opt/X11/include/X11 /usr/local/include/X11

(as mentioned here) just changes the error to:

ld: library not found for -lX11
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any idea?

Thanks

Cannot load graphics library on ARM macOS

Hey!

I've been trying to play with OCaml on ARM-based macOS, but I've been facing an issue which can be problematic for my usage.
Everything works fine, except for the graphics library which completely refuse to load up.
OCaml runs on version 4.12.0 freshly installed from opam, packages �core and graphics were added too to bring up graphics functionnality.

I use OCaml's top find in order to get my libraries loaded, here is a sample code:

#use "topfind";;
#require "graphics";;

While this code works on my native Linux (Debian) system, and my Debian on Windows 10 through WSL2... it does not work here.

# #require "Graphics";;
/Users/kevin/.opam/default/lib/Graphics: added to search path
/Users/kevin/.opam/default/lib/Graphics/graphics.cma: loaded
Cannot load required shared library dllgraphics_stubs.
Reason: /Users/kevin/.opam/default/lib/stublibs/dllgraphics_stubs.so: dlopen(/Users/kevin/.opam/default/lib/stublibs/dllgraphics_stubs.so, 10): Symbol not found: _XAllocColor
  Referenced from: /Users/kevin/.opam/default/lib/stublibs/dllgraphics_stubs.so
  Expected in: flat namespace
 in /Users/kevin/.opam/default/lib/stublibs/dllgraphics_stubs.so.

I do get this weird error, apparently a library isn't providing what it should which leads OCaml to fail up loading it... but I can't find anything related when searching on Google.
Side note, I haven't got any error or warning then opam was installing OCaml, core and graphics packages - aside from the classic pkg-config I had to install on all my systems anyway.

I'm using a late-2020 MacBook Air with an M1 chip, on macOS Big Sur 11.2.2.
I'm up to you if you need any more information or debug files.

Thanks!

Cannot build graphics 5.0.1 on Linux

I was trying to build ocaml-graphics for my system using the AUR package. What it does is downloading the source package, extract it, and run dune build -p graphics in it. It fails with the following error message:

    ocamlopt src/discover/discover.exe (exit 2)
(cd _build/default && /usr/bin/ocamlopt.opt -w -40 -g -o src/discover/discover.exe /usr/lib/ocaml/unix.cmxa -I /usr/lib/ocaml /usr/lib/ocaml/dune-configurator/configurator.cmxa src/discover/.discover.eobjs/native/discover.cmx)
File "_none_", line 1:
Error: Files /usr/lib/ocaml/dune-configurator/configurator.cmxa
       and /usr/lib/ocaml/stdlib.cmxa
       make inconsistent assumptions over implementation Stdlib__sys
Done: 81/107 (jobs: 1)

Compiling the 5.0.0 sources yields no error.

Rectangle madness

Original bug ID: 7498
Reporter: iesvs
Assigned to: @diml
Status: assigned (set by @diml on 2017-04-21T12:43:38Z)
Resolution: open
Priority: normal
Severity: minor
Version: 4.04.0
Category: standard library

Bug description

Graphics.draw_rect and Graphics.fill_rect have strange behaviors.

I will suppose that they use the same meaning for their arguments.
I see two behaviors

  1. how I understand the documentation
    fill_rect x y z h
    means { px, py : x <= px < x + w and y <= py < y + h }

  2. what is currently implemented on Linux
    fill_rect x y z h
    means { px, py : x <= px <= x + w and y <= py <= y + h }

In any cases the behavior of windows must be the same. I use the C compiler of VS 2010 to compile ocaml.

For the case 1, Linux must be changed and Windows too
I have the fix fix1.patch

For the case 2, Windows does not do the same thing as Linux
I have the fix fix2.patch

I also add a test file (test.ml).

ocamlopt -o test graphics.cmxa test.ml && ./test 1
will test the case 1
and
ocamlopt -o test graphics.cmxa test.ml && ./test 2
will test the case 2

The documentation of get_image states that the arguments have the same meaning than fill_rect. That's why case 1 is probably the expected behavior.

By the way, there is the commit
9f20c9c8a10307f40406890352ba3fbb2e4bd735
which looks like the opposite of fix1 (for the Linux part). That's strange.

I don't have Mac OS X to test, sorry.

File attachments

Graphics: foreground and background colors should be changeable

Original bug ID: 1710
Reporter: administrator
Status: acknowledged
Resolution: open
Priority: normal
Severity: feature
Category: otherlibs

Bug description

tags 179254 upstream
severity wishlist
thanks

Bonjour,

Je suis en train de faire le menage dans le bts du package debian ocaml,
et je suis tomber sur ces deux bugreports, que je pensais avoir fait
suivre upstram precedement, mais que je ne retrouve pas dans le BTS
ocaml. Voila qui est fait donc.

Amicalement,

Sven Luther

On Fri, Jan 31, 2003 at 09:34:11PM +0100, Goswin Brederlow wrote:

Package: ocaml
Version: 3.06-15
Severity: wishlist

There seems to be no way to change the foreground and background
colors in module Graphics. The problem is that X uses the background
color to fill in missing peaces when resizeing or when uncovering
regions before seding an expose event. If the background is white and
the actual graphic displayed is black that is very anoying to the eye.

Setting the background color to something roughly reflecting the
average color displayed greatly reduces flickering.

MfG
Goswin

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux dual 2.4.19 #11 SMP Thu Jan 9 00:18:31 CET 2003 i686
Locale: LANG=C, LC_CTYPE=de_DE

Versions of packages ocaml depends on:
ii libc6 2.3.1-10 GNU C Library: Shared libraries an
ii libncurses5-dev 5.3.20021109-2 Developer's libraries and docs for
ii ocaml-base [ocaml-base-3. 3.06-15 Runtime system for ocaml bytecode

-- debconf information excluded

Re: ocaml: module Graphics: type event should include a resize event

(The following issue was imported from the OCaml bugtracker)

Original bug ID: 1711
Reporter: administrator
Status: acknowledged
Resolution: open
Priority: normal
Severity: feature
Category: otherlibs

Bug description

tags 179255 upstream
severity 179255 whishlist
thanks

Bonjour,

Je suis en train de faire le menage dans le bts du package debian ocaml,
et je suis tomber sur ces deux bugreports, que je pensais avoir fait
suivre upstram precedement, mais que je ne retrouve pas dans le BTS
ocaml. Voila qui est fait donc.

Amicalement,

Sven Luther

On Fri, Jan 31, 2003 at 09:38:12PM +0100, Goswin Brederlow wrote:

Package: ocaml
Version: 3.06-15
Severity: wishlist

It would be nice if one could also wait for a resize event (and maybe
even expose events to trigger redraws when not using double buffering).

MfG
Goswin

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux dual 2.4.19 #11 SMP Thu Jan 9 00:18:31 CET 2003 i686
Locale: LANG=C, LC_CTYPE=de_DE

Versions of packages ocaml depends on:
ii libc6 2.3.1-10 GNU C Library: Shared libraries an
ii libncurses5-dev 5.3.20021109-2 Developer's libraries and docs for
ii ocaml-base [ocaml-base-3. 3.06-15 Runtime system for ocaml bytecode

-- debconf information excluded

Cannot install graphics in ubuntu 20.04 on Windows laptop

I have been trying to install graphics using "opam install graphics" in ubuntu. But I kept running into this error:

[NOTE] It seems you have not updated your repositories for a while. Consider updating them with:
       opam update

The following actions will be performed:
  ∗ install   conf-libX11       1      [required by graphics]
  ∗ install   graphics          5.1.2
  ↻ recompile ocamlfind         1.9.1  [uses graphics]
  ↻ recompile dot-merlin-reader 4.1    [uses ocamlfind]
  ↻ recompile base-bytes        base   [uses ocamlfind]
  ↻ recompile ocaml-lsp-server  1.8.2  [uses dot-merlin-reader]
  ↻ recompile zed               3.1.0  [uses base-bytes]
  ↻ recompile qcheck-core       0.18   [uses base-bytes]
  ↻ recompile ounit2            2.2.4  [uses base-bytes]
  ↻ recompile ocplib-endian     1.1    [uses base-bytes]
  ↻ recompile ocp-indent        1.8.1  [uses ocamlfind]
  ↻ recompile ANSITerminal      0.8.2  [uses base-bytes]
  ↻ recompile qcheck-ounit      0.18   [uses base-bytes]
  ↻ recompile lwt               5.4.2  [uses ocplib-endian]
  ↻ recompile ocamlformat-rpc   0.19.0 [uses ocp-indent]
  ↻ recompile ocamlformat       0.19.0 [uses ocp-indent]
  ↻ recompile qcheck            0.18   [uses base-bytes]
  ↻ recompile lwt_react         1.1.4  [uses lwt]
  ↻ recompile lwt_log           1.1.1  [uses lwt]
  ↻ recompile lambda-term       3.1.0  [uses zed]
  ↻ recompile utop              2.8.0  [uses ocamlfind]
===== ∗ 2   ↻ 19 =====
Do you want to continue? [Y/n] y

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ANSITerminal.0.8.2] found in cache
[dot-merlin-reader.4.1] found in cache
[graphics.5.1.2] found in cache
[lambda-term.3.1.0] found in cache
[lwt.5.4.2] found in cache
[lwt_log.1.1.1] found in cache
[lwt_react.1.1.4] found in cache
[ocaml-lsp-server.1.8.2] found in cache
[ocamlfind.1.9.1] found in cache
[ocamlformat.0.19.0] found in cache
[ocamlformat-rpc.0.19.0] found in cache
[ocp-indent.1.8.1] found in cache
[ocplib-endian.1.1] found in cache
[ounit2.2.2.4] found in cache
[qcheck.0.18] found in cache
[qcheck-core.0.18] found in cache
[qcheck-ounit.0.18] found in cache
[utop.2.8.0] found in cache
[zed.3.1.0] found in cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of conf-libX11 failed at "/home/danju666/.opam/opam-init/hooks/sandbox.sh build pkg-config
        x11".

#=== ERROR while compiling conf-libX11.1 ======================================#
# context     2.0.5 | linux/x86_64 | ocaml-base-compiler.4.12.0 | https://opam.ocaml.org#ef82e5bc
# path        ~/.opam/cs3110-2021fa/.opam-switch/build/conf-libX11.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build pkg-config x11
# exit-code   1
# env-file    ~/.opam/log/conf-libX11-42-626d32.env
# output-file ~/.opam/log/conf-libX11-42-626d32.out
### output ###
# bwrap: execvp pkg-config: No such file or directory
# bwrap: execvp pkg-config: No such file or directory



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build conf-libX11 1
└─
╶─ No changes have been performed

The packages you requested declare the following system dependencies. Please make sure they are installed before
retrying:
    libx11-dev

Graphics broken pipe

Original bug ID: 3668
Reporter: administrator
Status: acknowledged
Resolution: open
Priority: normal
Severity: feature
Category: otherlibs

Bug description

Full_Name: e. amian
Version: Objective Caml version 3.08.3
OS: Linux 2.6.11-gentoo-r8
Submission from: hoproxy.proxy.lucent.com (192.11.226.116)

Closing a Graphics window by clicking on top right 'close button'
(delete_event)
crashes the top level. Sample session
Objective Caml version 3.08.3

Graphics.open_graph " 200x200";;

  • : unit = ()

Broken pipe

Graphics crash under Windows

Original bug ID: 7419
Reporter: Anax
Assigned to: @dra27
Status: assigned (set by @dra27 on 2016-11-22T15:49:09Z)
Resolution: open
Priority: normal
Severity: minor
Platform: Winodws
OS: Windows 10
Version: 4.02.3
Category: platform support (windows, cross-compilation, etc)
Monitored by: @gasche

Bug description

In class, we did some exercices on trees, and in the fil the teacher gave us, there were a function to trace trees (the fact that it is tree is not important).
I don't really know the module graphics.cma, but when I use it to trace a forest here, the forest is tarced, but when I when to close the windows with the space bar (there is the code let _ = read_key() in close_graph() at the end of the function) it crashes I have to launch again ocaml.
I use Windows 10 on my computer, and a friend of mine as the same problem on his Windows. At school, we use ubuntu and it works.

Steps to reproduce

As I don't really know how really works the graphics module, I give you the caml function :

let rec trace_arbre_binaire t (xmin, xmax, ymin, ymax) h =
	match t with
	| Vide -> ()
	| Noeud_Binaire (x, t1, t2) ->
			let dy = (ymax - ymin) / h in
			let xm = (xmin + xmax) / 2 in
			let s = string_of_int x in
			moveto (xm - (10 * String.length s) / 2)  ymax;
			set_color green;
			draw_string s;
			let dx = (xmax - xmin) / 2 in
			set_color yellow;
			if t1 <> Vide then (
				moveto xm (ymax - 5);
				lineto (xmin + dx / 2) (ymax - dy + 15);
			);
			if t2 <> Vide then (
				moveto xm (ymax - 5);
				lineto (xmin + dx / 2 + dx) (ymax - dy + 15);
			);
			trace_arbre_binaire t1 (xmin, xm, ymin, ymax - dy) (h - 1);
			trace_arbre_binaire t2 (xm, xmax, ymin, ymax - dy) (h - 1)

let voir_arbre_binaire t =
	let nx = 800
	and ny = 600 in
	open_graph (" " ^ (string_of_int nx) ^ "x" ^ (string_of_int ny));
	set_color black;
	fill_rect 0 0 nx ny;
	let k = 50 in
	trace_arbre_binaire t (k,nx - k,k,ny - k) (hauteur_arbre_binaire t);
	let _ = read_key() in close_graph();;

where the type 'a arbre is

type 'a arbre_binaire =
|  Vide
|  Noeud_Binaire of 'a * 'a arbre_binaire * 'a arbre_binaire

Additional information

(I'm a French student, so I apologize for my apporxiamtive English)

File attachments

Compilation on native Windows fails

Logs

Steps to reproduce and logs :
https://github.com/GauBen/bcotp/runs/1599361734?check_suite_focus=true#step:5:68

# C:/cygwin/home/runneradmin/.opam/ocaml-variants.4.11.1+mingw64c/lib/ocaml/caml/mlvalues.h:265:24: warning: passing argument 1 of 'gr_font' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
#   265 | #define String_val(x) ((const char *) Bp_val(x))
#       |                       ~^~~~~~~~~~~~~~~~~~~~~~~~~
# src/win32/draw.c:340:17: note: in expansion of macro 'String_val'
# src/win32/draw.c:325:27: note: expected 'char *' but argument is of type 'const char *'
#   ocamlmklib src/dllgraphics_stubs.dll,src/libgraphics_stubs.a (exit 2)
# (cd _build/default && C:\cygwin\home\runneradmin\.opam\ocaml-variants.4.11.1+mingw64c\bin\ocamlmklib.opt.exe -g -o src/graphics_stubs src/draw.o src/events.o src/open.o -lkernel32 -lgdi32 -luser32)
# /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: C:\cygwin\tmp\dyndllf0869b.o:open.c:(.bss+0x5c): multiple definition of `grremember_mode'; C:\cygwin\tmp\dyndll23a1f4.o:draw.c:(.bss+0x60): first defined here
# /usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: C:\cygwin\tmp\dyndllf0869b.o:open.c:(.bss+0x60): multiple definition of `grdisplay_mode'; C:\cygwin\tmp\dyndll23a1f4.o:draw.c:(.bss+0x64): first defined here
# collect2: error: ld returned 1 exit status
# ** Fatal error: Error during linking

Or:

  • Install Cygwin
  • Install Opam and OCaml 4.11.1
  • opam install graphics

Solution

I found a way to compile graphics on Cygwin:

  • Remove or comment lines 26 and 27 in src/win32/draw.c
  • Remove "conf-libX11" in dune-project and graphics.opam

Regards,
Gautier

bug in fill_rect

windows 10, graphics.cma = 2015-12-09.
fill_rect 0 0 10 10 fills a square at 0 1 instead of 0 0
David Allsopp said "there is indeed a bug in the Windows implementation of Graphics.fill_rectis implemented using FillRect which states that it doesn’t include the right and bottom edge, so we should be increasing the width and height passed to it to compensate for that."

Question: how to handle close of window?

I'm on macos

I opened a window from ocaml shell, the XQuartz window opens. If I then close the window from the 'x' button on the window controls I get this error and the ocaml shell crashes:

# Fatal error: exception Graphics.Graphic_failure("fatal I/O error")

(closing from code Graphics.close_graph ();; works fine)

Is there a way to handle the close button so it doesn't cause an error?

sound command is not working

It seems that the sound command is not working.
It produces no sound even if executes from multiples OS with diverse Ocaml installations.
Is there a specif reason or is this just a bug?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.