Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* [Caml-list] lablgl bind texture patch
@ 2002-11-11 21:02 Chris Hecker
  0 siblings, 0 replies; only message in thread
From: Chris Hecker @ 2002-11-11 21:02 UTC (permalink / raw)
  To: caml-list


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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-11-12  9:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-11 21:02 [Caml-list] lablgl bind texture patch Chris Hecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox