Browse thread
[Caml-list] Different function on Image format (uses camlImages)
- chris.danx
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | chris.danx <chris.danx@n...> |
| Subject: | [Caml-list] Different function on Image format (uses camlImages) |
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