I'm trying to create a hashtable with keys that are strings, and values that
are OpenGL textures from the lablgl package. I get the above error. A
google search turned up a 'common errors' page on the ocaml tutorial that
indicates I need to use type annotation. However, that example is a simple
string, and the type I have to deal with is listed as (string, (_[<
Gl.format > `rgb ], _[< Gl.kind > `ubyte ]) GlPix.t).
I'm not sure where to begin to figure out how to properly annotate this.
Any tips or pointers to resources would be appreciated.
Code follows. It requires the lablgl package.
Thanks,
Grant
let image_height = 64
and image_width = 64
let make_generic_image () =
let image =
GlPix.create `ubyte ~format:`rgb ~width:image_width ~height:image_height
in
for i = 0 to image_width - 1 do
for j = 0 to image_height - 1 do
Raw.sets (GlPix.to_raw image) ~pos:(3*(i*image_height+j))
(if (i land 2 ) lxor (j land 2) = 0
then [|255;255;255|]
else [|0;0;0|])
done
done;
image;;
let textures = Hashtbl.create 100;;
Hashtbl.add textures "unknown" (make_generic_image ());;
.