From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 91CD5BC57 for ; Sun, 11 Apr 2010 20:52:46 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuACAC+3wUvUGyoCkWdsb2JhbACRQooEFQEBAQEJCwoHEQMfpmyFeC6IUoUMBA X-IronPort-AV: E=Sophos;i="4.52,185,1270418400"; d="scan'208";a="60536995" Received: from smtp2-g21.free.fr ([212.27.42.2]) by mail4-smtp-sop.national.inria.fr with ESMTP; 11 Apr 2010 20:52:45 +0200 Received: from smtp2-g21.free.fr (localhost [127.0.0.1]) by smtp2-g21.free.fr (Postfix) with ESMTP id 1287E4B01DA for ; Sun, 11 Apr 2010 20:52:40 +0200 (CEST) Received: from localhost.localnet (91-168-182-168.rev.libertysurf.net [91.168.182.168]) by smtp2-g21.free.fr (Postfix) with ESMTP id D66C04B01FC for ; Sun, 11 Apr 2010 20:52:37 +0200 (CEST) From: Florent Monnier To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] ocaml+sdl+opengl ? Date: Sun, 11 Apr 2010 21:00:27 +0200 User-Agent: KMail/1.12.4 (Linux/2.6.31.12-desktop586-3mnb; KDE/4.3.5; i686; ; ) References: <201004111953.29957.monnier.florent@gmail.com> In-Reply-To: <201004111953.29957.monnier.florent@gmail.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <201004112100.27483.monnier.florent@gmail.com> X-Spam: no; 0.00; ocaml:01 ocamlsdl:01 windowing:01 lablgl:01 lablgl:01 sdlvideo:01 ocamlsdl:01 bindings:01 ocaml:01 bigarray:01 bigarray:01 ocamlopt:01 cmxa:01 cmxa:01 ocamlopt:01 Le dimanche 11 avril 2010 19:53:29, Florent Monnier a =E9crit : > Hi, > I'm trying to use ocamlsdl for the windowing of an OpenGL application. >=20 > You will find below 2 test files, one using LablGL and one using glMLite. >=20 > I have made these test: >=20 > sdl+glMLite in interpreted mode =3D> OK, everything works all right > sdl+LablGL in interpreted mode =3D> Failure > sdl+glMLite in native code =3D> Failure > sdl+LablGL in native code =3D> Failure >=20 > The exception is raised by the function Sdlvideo.set_video_mode which is a > function from ocamlsdl, so it is very strange that changing the OpenGL > bindings changes the behaviour! >=20 > Here are respectively the commands I use: >=20 > ocaml -I +glMLite GL.cma bigarray.cma -I +sdl sdl.cma test.ml > ocaml -I +lablGL lablgl.cma bigarray.cma -I +sdl sdl.cma test.ml > ocamlopt -I +glMLite GL.cmxa bigarray.cmxa -I +sdl sdl.cmxa test.ml -o te= st > ocamlopt -I +lablGL lablgl.cmxa bigarray.cmxa -I +sdl sdl.cmxa test.ml -o > test >=20 >=20 > Does someone have an idea or a clue about how to fix the problem? > (The code is right, otherwise the first test wouldn't work. > Also the exact equivalent in pure C does work right.) So I have made another test. I have copied the following files from the sou= rces=20 of ocamlsdl from its directory ocamlsdl-0.7.2/src/ into the same directory= =20 where are located the test files (which are at the end of this email): common.c sdlgl_stub.c sdl.ml sdlvideo_flag.c common.h sdlinit_flag.c sdlmouse.ml sdlvideo_flag.h config.h sdlinit_flag.h sdlmouse_stub.c sdlvideo.ml files sdljoystick.ml sdlmouse_stub.h sdlvideo_stub.c sdlevent.ml sdljoystick_stub.c sdlrwops_stub.c sdlvideo_stub.h sdlevent_stub.c sdlkey.ml sdlrwops_stub.h sdlgl.ml sdlkey_stub.c sdl_stub.c Then I have compiled everything with : ocamlopt -o test bigarray.cmxa \ sdl.ml sdlmouse.ml sdljoystick.ml sdlkey.ml \ sdlevent.ml sdlvideo.ml sdlgl.ml \ $GL_BINDINGS test.ml \ -ccopt "`sdl-config --cflags`" \ sdl_stub.c sdlgl_stub.c sdlvideo_stub.c sdlkey_stub.c sdlevent_stub.c \ sdlmouse_stub.c sdljoystick_stub.c common.c sdlrwops_stub.c \ -cclib "-lGL `sdl-config --libs`" where I switch the OpenGL bindings with: GL_BINDINGS=3D"-I +glMLite GL.cmxa" GL_BINDINGS=3D"-I +lablGL lablgl.cmxa" here the results I get: =3D> with LablGL it fails again. =3D> with glMLite now it works in native code too. Again the SDL part fails with one OpenGL bindings and not with the other on= e. What could explain this ? Also with glMLite and in native mode, using ocamlsdl as a lib fails, and=20 compiling locally ocamlsdl's source files succeeds. What could explain this ? > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D > let display() =3D > GlClear.clear [`color]; > GlDraw.begins `triangles; > GlDraw.color (0.0, 1.0, 0.0); > GlDraw.vertex2 (-0.5, -0.5); > GlDraw.vertex2 ( 0.0, 0.5); > GlDraw.vertex2 (0.5, -0.5); > GlDraw.ends(); > Sdlgl.swap_buffers() >=20 > let () =3D > Sdl.init [`EVERYTHING]; > let _ =3D Sdlvideo.set_video_mode ~w:640 ~h:480 ~bpp:0 [`OPENGL; > `DOUBLEBUF] in > let rec loop() =3D > match Sdlevent.poll() with >=20 > | Some Sdlevent.KEYDOWN { Sdlevent.keysym =3D Sdlkey.KEY_ESCAPE } > | Some Sdlevent.QUIT -> () > | _ -> display(); loop() >=20 > in > loop(); > Sdl.quit() > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D > open GL > let display() =3D > glClear [GL_COLOR_BUFFER_BIT]; > glBegin GL_TRIANGLES; > glColor3 0.0 1.0 0.0; > glVertex2 (-0.5) (-0.5); > glVertex2 ( 0.0) ( 0.5); > glVertex2 ( 0.5) (-0.5); > glEnd(); > Sdlgl.swap_buffers() >=20 > let () =3D > Sdl.init [`EVERYTHING]; > let _ =3D Sdlvideo.set_video_mode ~w:640 ~h:480 ~bpp:0 [`OPENGL; > `DOUBLEBUF] in > let rec loop() =3D > match Sdlevent.poll() with >=20 > | Some Sdlevent.KEYDOWN { Sdlevent.keysym =3D Sdlkey.KEY_ESCAPE } > | Some Sdlevent.QUIT -> () > | _ -> display(); loop() >=20 > in > loop(); > Sdl.quit() > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D