From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA07084; Fri, 28 Nov 2003 00:26:48 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA14469 for ; Fri, 28 Nov 2003 00:26:47 +0100 (MET) Received: from mta05-svc.ntlworld.com (mta05-svc.ntlworld.com [62.253.162.45]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hARNQk108854 for ; Fri, 28 Nov 2003 00:26:46 +0100 (MET) Received: from ntlworld.com ([80.4.69.150]) by mta05-svc.ntlworld.com (InterMail vM.4.01.03.37 201-229-121-137-20020806) with ESMTP id <20031127232646.ZTAH27066.mta05-svc.ntlworld.com@ntlworld.com> for ; Thu, 27 Nov 2003 23:26:46 +0000 Message-ID: <3FC68846.7020804@ntlworld.com> Date: Thu, 27 Nov 2003 23:27:02 +0000 From: "chris.danx" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031014 Thunderbird/0.3 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Caml Mailing List Subject: [Caml-list] Different function on Image format (uses camlImages) Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; ntlworld:99 camlimages:01 texture:01 camlimages:01 hash:01 ideally:01 texture:01 val:01 hashtbl:01 hashtbl:01 img:99 img:99 chris:01 chris:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 -> 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 with -> OImage.rgb24 img | -> 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