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 AAA15453; Fri, 28 Nov 2003 00:54:50 +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 AAA15834 for ; Fri, 28 Nov 2003 00:54:49 +0100 (MET) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from mta07-svc.ntlworld.com (mta07-svc.ntlworld.com [62.253.162.47]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hARNsl111753 for ; Fri, 28 Nov 2003 00:54:47 +0100 (MET) Received: from ntlworld.com ([80.4.69.150]) by mta07-svc.ntlworld.com (InterMail vM.4.01.03.37 201-229-121-137-20020806) with ESMTP id <20031127235447.IHLI15835.mta07-svc.ntlworld.com@ntlworld.com> for ; Thu, 27 Nov 2003 23:54:47 +0000 Message-ID: <3FC68ED8.1000708@ntlworld.com> Date: Thu, 27 Nov 2003 23:55:04 +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: Re: [Caml-list] Different function on Image format (uses camlImages) References: <3FC68846.7020804@ntlworld.com> In-Reply-To: <3FC68846.7020804@ntlworld.com> 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 caml-list:01 camlimages:01 img:99 img:99 glpix:01 glpix:01 texture:01 val:01 hashtbl:01 hashtbl:01 texture:01 nehe:01 chris:01 chris:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk chris.danx wrote: > let img = match with > -> OImage.rgb24 img > | -> OImage.rgba24 img > in ... > > The problem is what should the things between the angled brackets be? Zaps himself!!! I went off on a tangent there. I can tell which format the image is but can't apply rgba_to_gl. The error is File "texload.ml", line 35, characters 45-48: This expression has type Image.rgb = Color.Rgb.t but is here used with type Image.rgba = Color.Rgba.t Line 35 is the [| 4 component array |] in rgba_to_gl. I think I understand why i get this error, I'm just not sure I know how to resolve it (i got it previously, but ripped out the pattern matching code for the image format). It seems the image needs to be treated as OImage.rgba32 but I'm a bit lost... This is the complete script so far... let rgb_to_gl img = let w = img#width and h = img#height in let targ_img = GlPix.create `ubyte ~format:`rgb ~width:w ~height:h in for i = 0 to w - 1 do for j = 0 to h - 1 do let pix = img#get i j in Raw.sets (GlPix.to_raw targ_img) ~pos:(3*i*h+j) [| pix.r; pix.g; pix.b |]; done done; targ_img;; let rgba_to_gl img = let w = img#width and h = img#height in let targ_img = GlPix.create `ubyte ~format:`rgba ~width:w ~height:h in for i = 0 to w - 1 do for j = 0 to h - 1 do let pix = img#get i j in Raw.sets (GlPix.to_raw targ_img) ~pos:(4*i*h+j) [| pix.r; pix.g; pix.b; pix.alpha|]; done done; targ_img;; 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 conv = match img#tag with ClassRgb24 -> rgb_to_gl | ClassRgba32 -> rgba_to_gl in Hashtbl.add texts tex_id (conv img); () end;; let _ = let tex = new texture_loader in tex#load "NeHe.bmp" "bob";; 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