From: Florent Monnier <monnier.florent@gmail.com>
To: caml-list@yquem.inria.fr
Subject: ocaml+sdl+opengl ?
Date: Sun, 11 Apr 2010 19:53:29 +0200 [thread overview]
Message-ID: <201004111953.29957.monnier.florent@gmail.com> (raw)
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()
================================
next reply other threads:[~2010-04-11 17:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-11 17:53 Florent Monnier [this message]
2010-04-11 18:28 ` [Caml-list] " Daniel Bünzli
2010-04-11 19:14 ` Florent Monnier
2010-04-11 19:10 ` Daniel Bünzli
2010-04-11 19:33 ` Florent Monnier
2010-04-11 19:00 ` Florent Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201004111953.29957.monnier.florent@gmail.com \
--to=monnier.florent@gmail.com \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox