<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/11/544ed91316b7f021748820400d5659b0"
  from="chris.danx &lt;chris.danx@n...&gt;"
  author="chris.danx"
  date="2003-11-27T23:26:48"
  subject="[Caml-list] Different function on Image format  (uses camlImages)"
  prev="2003/11/13322a1c9558dc8213aabf326278ba2d"
  next="2003/11/1c9948d9968d705264d69167beb9c229"
  next-in-thread="2003/11/1c9948d9968d705264d69167beb9c229"
  prev-thread="2003/11/81d0d1f0a5637b0bbc5c1e42e41daa94"
  next-thread="2003/11/8b68d8a294eca1101e0d365b9c162338"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Different function on Image format  (uses camlImages)">
<msg 
  url="2003/11/544ed91316b7f021748820400d5659b0"
  from="chris.danx &lt;chris.danx@n...&gt;"
  author="chris.danx"
  date="2003-11-27T23:26:48"
  subject="[Caml-list] Different function on Image format  (uses camlImages)">
<msg 
  url="2003/11/1c9948d9968d705264d69167beb9c229"
  from="chris.danx &lt;chris.danx@n...&gt;"
  author="chris.danx"
  date="2003-11-27T23:54:50"
  subject="Re: [Caml-list] Different function on Image format  (uses camlImages)">
<msg 
  url="2003/11/ad40436aeb363b79eac521460bfe452e"
  from="chris.danx &lt;chris.danx@n...&gt;"
  author="chris.danx"
  date="2003-11-29T17:37:40"
  subject="Re: [Caml-list] Different function on Image format  (uses camlImages)">
</msg>
</msg>
</msg>
</thread>

<contents>
Hi,

I'm writing a simple texture loader class so that I can load up images 
using camlimages, convert them to a format suitable for opengl, then 
store them under some name in a hash table.  So far I've got it working 
for rgb24 format images, but ideally I want to use both 24bit rgb pixels 
and 32bit rgba pixels.  The problem is deciding which function to call 
depending on the image type.

Before I go on, is this an appropriate place to ask about CamlImages? 
Also I am new to OCaml, and this is one of the few things I've attempted 
of any complexity.

This is the class as it stands.


class texture_loader
   = object(self)

     val mutable texts = Hashtbl.create 5;

     method load (filename : string) (tex_id : string) =
	try
	  let x = Hashtbl.find texts tex_id in
	    raise (Id_exists tex_id)
	with
	    Not_found -&gt;         	
	      let img = OImage.load filename [] in
		let img = OImage.rgb24 img in
		  Hashtbl.add texts tex_id (rgb_to_gl img);
		  ()
end;;


Assuming I have functions "rgb_to_gl" and "rgba_to_gl", how can I tell 
which format the image is so the correct function can be called. 
Something like this is what sprang to mind

let img = match &lt;image_format&gt; with
      &lt;rgb&gt;  -&gt; OImage.rgb24  img
    | &lt;rgba&gt; -&gt; OImage.rgba24 img
in ...

The problem is what should the things between the angled brackets be?


Thanks,
Chris

-------------------
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

</contents>

</message>

