[m-rev.] for review: more bits and pieces for the opengl binding
Julien Fischer
juliensf at students.cs.mu.OZ.AU
Mon Jan 12 19:10:23 AEDT 2004
On Mon, 12 Jan 2004, Fergus Henderson wrote:
> Just one comment:
>
> > Index: mogl.m
> ...
> > +is_enabled(Flag, IsEnabled, !IO) :-
> > + ( Flag = clip_plane(I) ->
> > + is_enabled_3(control_flag_to_int(Flag), I, IsEnabled, !IO)
> > + ; Flag = light(I) ->
> > + is_enabled_3(control_flag_to_int(Flag), I, IsEnabled, !IO)
> > + ;
> > + is_enabled_2(control_flag_to_int(Flag), IsEnabled, !IO)
> > + ).
> > +
> > +:- pred is_enabled_2(int::in, bool::out, io::di, io::uo) is det.
> > +:- pragma foreign_proc("C",
> > + is_enabled_2(I::in, R::out, IO0::di, IO::uo),
> > + [may_call_mercury, promise_pure],
> > +"
> > + if(glIsEnabled(control_flag_flags[I]))
> > + R = ML_bool_return_yes();
> > + else
> > + R = ML_bool_return_no();
> > + IO = IO0;
> > +").
> > +
> > +:- pred is_enabled_3(int::in, int::in, bool::out, io::di, io::uo) is det.
> > +:- pragma foreign_proc("C",
> > + is_enabled_3(I::in, J::in, R::out, IO0::di, IO::uo),
> > + [may_call_mercury, promise_pure],
> > +"
> > + if(glIsEnabled(control_flag_flags[I] + J))
> > + R = ML_bool_return_yes();
> > + else
> > + R = ML_bool_return_no();
> > + IO = IO0;
> > +").
>
> The code duplication there is undesirable. Also, the logic is vulnerable
> to breakage if future revisions of GL introduce new control flags.
> Likewise for a couple of similar places in the existing code in mogl.m
> (enable/3 and disable/3).
>
As future revisions of OpenGL have introduced new control flags this
could be a problem (to say nothing of the fact that we don't currently
support all the control flags from version 1.1 anyway).
I'll fix this (along with enable/3 and disable/3) along the lines
you suggested.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list