From: "chris.danx" <chris.danx@ntlworld.com>
To: Caml Mailing List <caml-list@inria.fr>
Subject: [Caml-list] Different function on Image format (uses camlImages)
Date: Thu, 27 Nov 2003 23:27:02 +0000 [thread overview]
Message-ID: <3FC68846.7020804@ntlworld.com> (raw)
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 <image_format> with
<rgb> -> OImage.rgb24 img
| <rgba> -> 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
next reply other threads:[~2003-11-27 23:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-27 23:27 chris.danx [this message]
2003-11-27 23:55 ` chris.danx
2003-11-29 0:36 ` chris.danx
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3FC68846.7020804@ntlworld.com \
--to=chris.danx@ntlworld.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox