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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 74436BC57 for ; Sun, 11 Apr 2010 19:45:49 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnoDAD6nwUvUGyoCkWdsb2JhbACPdYFQigQVAQEBAQkLCgcRAx+nGYV7LohShQwE X-IronPort-AV: E=Sophos;i="4.52,185,1270418400"; d="scan'208";a="48711067" Received: from smtp2-g21.free.fr ([212.27.42.2]) by mail2-smtp-roc.national.inria.fr with ESMTP; 11 Apr 2010 19:45:48 +0200 Received: from smtp2-g21.free.fr (localhost [127.0.0.1]) by smtp2-g21.free.fr (Postfix) with ESMTP id 1B3B74B0193 for ; Sun, 11 Apr 2010 19:45:43 +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 346CD4B012C for ; Sun, 11 Apr 2010 19:45:41 +0200 (CEST) From: Florent Monnier To: caml-list@yquem.inria.fr Subject: ocaml+sdl+opengl ? Date: Sun, 11 Apr 2010 19:53:29 +0200 User-Agent: KMail/1.12.4 (Linux/2.6.31.12-desktop586-3mnb; KDE/4.3.5; i686; ; ) MIME-Version: 1.0 Message-Id: <201004111953.29957.monnier.florent@gmail.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 Hi, I'm trying to use ocamlsdl for the windowing of an OpenGL application. You will find below 2 test files, one using LablGL and one using glMLite. I have made these test: sdl+glMLite in interpreted mode => OK, everything works all right sdl+LablGL in interpreted mode => Failure sdl+glMLite in native code => Failure sdl+LablGL in native code => Failure 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! Here are respectively the commands I use: 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 test ocamlopt -I +lablGL lablgl.cmxa bigarray.cmxa -I +sdl sdl.cmxa test.ml -o test 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.) ================================ let display() = 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() let () = Sdl.init [`EVERYTHING]; let _ = Sdlvideo.set_video_mode ~w:640 ~h:480 ~bpp:0 [`OPENGL; `DOUBLEBUF] in let rec loop() = match Sdlevent.poll() with | Some Sdlevent.KEYDOWN { Sdlevent.keysym = Sdlkey.KEY_ESCAPE } | Some Sdlevent.QUIT -> () | _ -> display(); loop() in loop(); Sdl.quit() ================================ open GL let display() = 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() let () = Sdl.init [`EVERYTHING]; let _ = Sdlvideo.set_video_mode ~w:640 ~h:480 ~bpp:0 [`OPENGL; `DOUBLEBUF] in let rec loop() = match Sdlevent.poll() with | Some Sdlevent.KEYDOWN { Sdlevent.keysym = Sdlkey.KEY_ESCAPE } | Some Sdlevent.QUIT -> () | _ -> display(); loop() in loop(); Sdl.quit() ================================