[m-rev.] for review: mercury_opengl changes
Peter Wang
wangp at students.csse.unimelb.edu.au
Tue Dec 5 18:14:47 AEDT 2006
On 2006-12-05, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
>
> On Tue, 5 Dec 2006, Peter Wang wrote:
> >extras/graphics/mercury_opengl/mogl.m:
> > Add bindings for glTexImage1D, glTexImage2D, glTexImage3D,
> > glCopyTexImage1D, glCopyTexImage2D.
> >
> > Move the pixel_data type into the interface.
> >
> > Import mogl.type_tables.
> >
> >extras/graphics/mercury_opengl/mogl.type_tables.m:
> > New module. This is intended to expose some of the <type>_to_int and
> > <type>_flags[] tables. Modules other than mogl can import this
> > module
> > to convert mogl types to their equivalent OpenGL constants.
>
> Is this a particularly useful thing to be able to do?
In my case I'm using a separate library to load textures, and it accepts
OpenGL texture format flags.
> (Actually, I was hoping to use the foreign_export_enum stuff I've been
> working on to eliminate the need for most of the <type>_to_int predicates).
I don't mind if the module's interfaces change later.
> > Add pixel_format and pixel_type conversion tables.
> >
> > Move texture_format conversion tables from mogl to here.
> >
>
> Which version of the OpenGL spec are these changes targeted at?
1.1.
> >Index: mogl.m
> >===================================================================
> >RCS file:
> >/home/mercury1/repository/mercury/extras/graphics/mercury_opengl/mogl.m,v
> >retrieving revision 1.22
> >diff -u -r1.22 mogl.m
> >--- mogl.m 31 Aug 2006 11:09:50 -0000 1.22
> >+++ mogl.m 5 Dec 2006 04:22:03 -0000
> >@@ -521,6 +534,34 @@
> >:- pred tex_gen(texture_coord::in, texture_gen_parameter::in,
> > io::di, io::uo) is det.
> >
> >+:- inst border ---> 0 ; 1.
> >+
> >+:- type pixel_data.
> >+:- pragma foreign_type("C", pixel_data, "const GLvoid *").
>
> I suggest hiding the foreign_type decl in it's own little interface
> section, rather than including it in the "public" interface.
Ok.
> What's responsible for managing the memory required by the texture
> data? (It was never entirely clear to me whether textures are
> copied to the server or if the reside on the client side. There's
> no problem for the former; there may be for the latter, e.g.
> if the memory was allocated by the garbage collector and we no longer
> maintain a reference to it.)
The former (i.e. it's copied).
> >+%------------------------------------------------------------------------------%
> >+
> >+:- module mogl.type_tables.
> >+:- interface.
> >+
> >+:- func pixel_format_to_int(pixel_format) = int.
> >+
> >+:- func pixel_type_to_int(pixel_type) = int.
> >+
> >+:- pred texture_format_to_int(texture_format, int).
> >+:- mode texture_format_to_int(in, out) is det.
> >+%:- mode texture_format_to_int(out, in) is semidet.
>
> Why is that mode commented out?
I just copied it verbatim from mogl.m.
Peter
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list