Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] lablgl bind texture patch
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chris Hecker <checker@d...>
Subject: [Caml-list] lablgl bind texture patch

Here's a small patch to add glBindTexture et al. to lablgl 0.98.  It was 
easiest to add the scalar versions of gen_ and delete_ and then build the 
array versions off those even though OpenGL only has the array versions, so 
I exposed them.

I haven't actually tested it beyond my use, but it's pretty trivial.

Enjoy,
Chris


diff -ur old/lablGl-0.98/glTex.ml lablGl-0.98/glTex.ml
--- old/lablGl-0.98/glTex.ml	Sun Sep 30 19:59:13 2001
+++ lablGl-0.98/glTex.ml	Sun Nov 10 17:52:07 2002
@@ -66,3 +66,11 @@
  ]
  external parameter : target:[`texture_1d|`texture_2d] -> parameter -> unit
      = "ml_glTexParameter"
+
+type texture_id = int32
+external gen_texture : unit -> texture_id = "ml_gen_texture"
+let gen_textures n = Array.init n (fun _ -> gen_texture ())
+external bind_texture : target:[`texture_1d|`texture_2d] -> texture_id -> unit
+    = "ml_glBindTexture"
+external delete_texture : texture_id -> unit = "ml_delete_texture"
+let delete_textures a = Array.iter (fun id -> delete_texture id) a
diff -ur old/lablGl-0.98/glTex.mli lablGl-0.98/glTex.mli
--- old/lablGl-0.98/glTex.mli	Sun Sep 30 19:59:13 2001
+++ lablGl-0.98/glTex.mli	Sun Nov 10 17:49:55 2002
@@ -41,3 +41,10 @@
    | `priority of clampf
  ]
  val parameter : target:[`texture_1d|`texture_2d] -> parameter -> unit
+
+type texture_id
+val gen_texture : unit -> texture_id
+val gen_textures : int -> texture_id array
+val bind_texture : target:[`texture_1d|`texture_2d] -> texture_id -> unit
+val delete_texture : texture_id -> unit
+val delete_textures : texture_id array -> unit
diff -ur old/lablGl-0.98/ml_gl.c lablGl-0.98/ml_gl.c
--- old/lablGl-0.98/ml_gl.c	Sun Jul 14 19:15:48 2002
+++ lablGl-0.98/ml_gl.c	Sun Nov 10 17:51:41 2002
@@ -576,6 +576,26 @@
      return Val_unit;
  }

+CAMLprim value ml_gen_texture (value unit)
+{
+    GLuint id;
+    glGenTextures(1,&id);
+    return copy_int32(id);
+}
+CAMLprim value ml_glBindTexture (value target, value texture_id)
+{
+    GLenum targ = GLenum_val(target);
+    GLuint id = Int32_val(texture_id);
+    glBindTexture(targ,id);
+    return Val_unit;
+}
+CAMLprim value ml_delete_texture (value texture_id)
+{
+    GLuint id = Int32_val(texture_id);
+    glDeleteTextures(1,&id);
+    return Val_unit;
+}
+
  ML_3 (glTranslated, Double_val, Double_val, Double_val)

  CAMLprim value ml_glVertex(value x, value y, value z, value w)  /* ML */

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners