* ocaml+sdl+opengl ?
@ 2010-04-11 17:53 Florent Monnier
2010-04-11 18:28 ` [Caml-list] " Daniel Bünzli
2010-04-11 19:00 ` Florent Monnier
0 siblings, 2 replies; 6+ messages in thread
From: Florent Monnier @ 2010-04-11 17:53 UTC (permalink / raw)
To: caml-list
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()
================================
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] ocaml+sdl+opengl ?
2010-04-11 17:53 ocaml+sdl+opengl ? Florent Monnier
@ 2010-04-11 18:28 ` Daniel Bünzli
2010-04-11 19:14 ` Florent Monnier
2010-04-11 19:00 ` Florent Monnier
1 sibling, 1 reply; 6+ messages in thread
From: Daniel Bünzli @ 2010-04-11 18:28 UTC (permalink / raw)
To: Florent Monnier; +Cc: caml-list
You did not specify the platform but on osx 10.6.3 sdl+lablgl works.
More precisely
> sdl+LablGL in interpreted mode => Failure
Works but you need to make a custom toplevel (see ocamlsdl's readme about osx).
$ ocamlmktop -I +lablGL -I +sdl -custom -o ocamlsdl lablgl.cma
bigarray.cma sdl.cma
$ ./ocamlsdl -I +lablGL -I +sdl test.ml
> sdl+LablGL in native code => Failure
Works here with
$ ocamlopt -I +lablGL lablgl.cmxa bigarray.cmxa -I +sdl sdl.cmxa test.ml -o test
Best,
Daniel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] ocaml+sdl+opengl ?
2010-04-11 17:53 ocaml+sdl+opengl ? Florent Monnier
2010-04-11 18:28 ` [Caml-list] " Daniel Bünzli
@ 2010-04-11 19:00 ` Florent Monnier
1 sibling, 0 replies; 6+ messages in thread
From: Florent Monnier @ 2010-04-11 19:00 UTC (permalink / raw)
To: caml-list
Le dimanche 11 avril 2010 19:53:29, Florent Monnier a écrit :
> 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.)
So I have made another test. I have copied the following files from the sources
of ocamlsdl from its directory ocamlsdl-0.7.2/src/ into the same directory
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="-I +glMLite GL.cmxa"
GL_BINDINGS="-I +lablGL lablgl.cmxa"
here the results I get:
=> with LablGL it fails again.
=> with glMLite now it works in native code too.
Again the SDL part fails with one OpenGL bindings and not with the other one.
What could explain this ?
Also with glMLite and in native mode, using ocamlsdl as a lib fails, and
compiling locally ocamlsdl's source files succeeds.
What could explain this ?
> ================================
> 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()
> ================================
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] ocaml+sdl+opengl ?
2010-04-11 19:14 ` Florent Monnier
@ 2010-04-11 19:10 ` Daniel Bünzli
2010-04-11 19:33 ` Florent Monnier
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Bünzli @ 2010-04-11 19:10 UTC (permalink / raw)
To: Florent Monnier; +Cc: caml-list
> OK, so I guess the problem is specific for Linux
Well apparently not, I just tried on my netbook and sdl+lablgl works
perfectly (both byte and native).
> uname -a
Linux minidip 2.6.31-20-generic #58-Ubuntu SMP Fri Mar 12 05:23:09 UTC
2010 i686 GNU/Linux
Best,
Daniel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] ocaml+sdl+opengl ?
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
0 siblings, 1 reply; 6+ messages in thread
From: Florent Monnier @ 2010-04-11 19:14 UTC (permalink / raw)
To: caml-list
> You did not specify the platform but on osx 10.6.3 sdl+lablgl works.
I'm using Linux.
(and glMLite does work on MacOSX too)
> > sdl+LablGL in interpreted mode => Failure
>
> Works but you need to make a custom toplevel (see ocamlsdl's readme about
> osx).
>
> $ ocamlmktop -I +lablGL -I +sdl -custom -o ocamlsdl lablgl.cma
> bigarray.cma sdl.cma
> $ ./ocamlsdl -I +lablGL -I +sdl test.ml
>
> > sdl+LablGL in native code => Failure
>
> Works here with
>
> $ ocamlopt -I +lablGL lablgl.cmxa bigarray.cmxa -I +sdl sdl.cmxa test.ml -o
> test
OK, so I guess the problem is specific for Linux
--
Best,
Florent
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] ocaml+sdl+opengl ?
2010-04-11 19:10 ` Daniel Bünzli
@ 2010-04-11 19:33 ` Florent Monnier
0 siblings, 0 replies; 6+ messages in thread
From: Florent Monnier @ 2010-04-11 19:33 UTC (permalink / raw)
To: caml-list
> > OK, so I guess the problem is specific for Linux
>
> Well apparently not, I just tried on my netbook and sdl+lablgl works
> perfectly (both byte and native).
>
> > uname -a
>
> Linux minidip 2.6.31-20-generic #58-Ubuntu SMP Fri Mar 12 05:23:09 UTC
> 2010 i686 GNU/Linux
I use Mandriva-Linux.
I have the same problem with the official mandriva package of ocamlsdl,
and with ocamlsdl compiled from sources.
What could be the problem?
--
Best,
Florent
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-04-11 19:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-11 17:53 ocaml+sdl+opengl ? Florent Monnier
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox