comp.lang.ada
 help / color / mirror / Atom feed
* Anouncement: OpenGL Binding w/ Ada-2012.
@ 2012-10-18 17:16 Shark8
  2012-10-24  3:38 ` joel.s.williamson
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Shark8 @ 2012-10-18 17:16 UTC (permalink / raw)


I've recently completed the initial binding for OpenGL to Ada 2012.
It's available at http://github.com/OneWingedShark/TAO-GL


Some notes:

1) Currently all the functions from OpenGL 1.1 are included; this is because I didn't realize at the time how dated the C-headers I started out with were -- though it makes little difference in the overall amount of work which is mostly reading documentation and typing/subtyping enumerations for the parameters.

2) The preconditions are at present mostly minimalistic (just the easy/straightforward preconditions), though all of them should have the correct restrictions regarding the "raises error between glBegin/glEnd" restriction.

3) There are a few points where the binding is not nearly thick enough for my taste, mostly because I'm unsure of how to correctly translate the function [parameters esp] into nice Ada; this usually results in an exposed System.Address parameter.

If you do give it a try, feel free to post impressions, ideas, suggestions.
Thank you.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Anouncement: OpenGL Binding w/ Ada-2012.
  2012-10-18 17:16 Anouncement: OpenGL Binding w/ Ada-2012 Shark8
@ 2012-10-24  3:38 ` joel.s.williamson
  2012-10-24 20:33   ` Shark8
  2012-10-24 16:32 ` Quentin Ochem
  2012-10-26 13:50 ` Yannick Duchêne (Hibou57)
  2 siblings, 1 reply; 9+ messages in thread
From: joel.s.williamson @ 2012-10-24  3:38 UTC (permalink / raw)


On Thursday, October 18, 2012 1:16:52 PM UTC-4, Shark8 wrote:
> I've recently completed the initial binding for OpenGL to Ada 2012.
> 
> It's available at http://github.com/OneWingedShark/TAO-GL
> 
> 
> 
> 
> 
> Some notes:
> 
> 
> 
> 1) Currently all the functions from OpenGL 1.1 are included; this is because I didn't realize at the time how dated the C-headers I started out with were -- though it makes little difference in the overall amount of work which is mostly reading documentation and typing/subtyping enumerations for the parameters.
> 
> 
> 
> 2) The preconditions are at present mostly minimalistic (just the easy/straightforward preconditions), though all of them should have the correct restrictions regarding the "raises error between glBegin/glEnd" restriction.
> 
> 
> 
> 3) There are a few points where the binding is not nearly thick enough for my taste, mostly because I'm unsure of how to correctly translate the function [parameters esp] into nice Ada; this usually results in an exposed System.Address parameter.
> 
> 
> 
> If you do give it a try, feel free to post impressions, ideas, suggestions.
> 
> Thank you.

Do you intend to get this working with modern OpenGL (ie 3+), as I was disappointed to see that the existing Ada bindings are only for OpenGL 2.1 and being able to use current OpenGL from current Ada would be great.

Keep up the good work.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Anouncement: OpenGL Binding w/ Ada-2012.
  2012-10-18 17:16 Anouncement: OpenGL Binding w/ Ada-2012 Shark8
  2012-10-24  3:38 ` joel.s.williamson
@ 2012-10-24 16:32 ` Quentin Ochem
  2012-10-24 20:40   ` Shark8
  2012-10-26 13:50 ` Yannick Duchêne (Hibou57)
  2 siblings, 1 reply; 9+ messages in thread
From: Quentin Ochem @ 2012-10-24 16:32 UTC (permalink / raw)



> If you do give it a try, feel free to post impressions, ideas, suggestions.

One suggestion: there's a number of cases where pre conditions can be replaced by proper subtyping, e.g.:

procedure PointSize (size : float)
with pre => not Executing AND size > 0.0;

Can be replaced by:

subtype Positive_Float is Float range 0.0 .. Float'Last;
procedure PointSize (size : Positive_Float)
with pre => not Executing;

It seems good practice to use subtyping whenever possible, in particular if it's a property of a parameter, and let Pre condition for more complex properties related to the subprogram as a whole.

Just my 2 cents...



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Anouncement: OpenGL Binding w/ Ada-2012.
  2012-10-24  3:38 ` joel.s.williamson
@ 2012-10-24 20:33   ` Shark8
  0 siblings, 0 replies; 9+ messages in thread
From: Shark8 @ 2012-10-24 20:33 UTC (permalink / raw)


On Tuesday, October 23, 2012 9:38:26 PM UTC-6, joel.s.w...@gmail.com wrote:
> 
> Do you intend to get this working with modern OpenGL (ie 3+), as I was disappointed to see that the existing Ada bindings are only for OpenGL 2.1 and being able to use current OpenGL from current Ada would be great.

Yes, I am intending to do so; the current OpenGL is 4.3 -- the current problem that I'm considering is how to address open-gl's "objects" enumerations (lights, textures, etc.)

Typing/subtyping is an excellent way to handle these, given I can specify it as a range; i.e. Subtype Light_Number is Enum Range GL_Light0 .. GL_Light0+MAX_LIGHTS.

The current [re-]design problem I'm considering involves this exact problem; the number of lights is determined at runtime [unless I decide to use the specification minimums]... which means passing runtime-queried parameters into generic-packages.

> 
> Keep up the good work.

Thank you.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Anouncement: OpenGL Binding w/ Ada-2012.
  2012-10-24 16:32 ` Quentin Ochem
@ 2012-10-24 20:40   ` Shark8
  2012-10-25 22:22     ` Quentin Ochem
  0 siblings, 1 reply; 9+ messages in thread
From: Shark8 @ 2012-10-24 20:40 UTC (permalink / raw)


On Wednesday, October 24, 2012 10:32:20 AM UTC-6, Quentin Ochem wrote:
> > If you do give it a try, feel free to post impressions, ideas, suggestions.
> 
> One suggestion: there's a number of cases where pre conditions can be replaced by proper subtyping, e.g.:
> 
> procedure PointSize (size : float)
> with pre => not Executing AND size > 0.0;
> 
> 
> Can be replaced by:
> subtype Positive_Float is Float range 0.0 .. Float'Last;
> procedure PointSize (size : Positive_Float)
> with pre => not Executing;

Can it? I'd have to take a look at the way Ada's ranges for floats work again to tell. IIRC it's [Min_val..Max_Val), if that is the case there is one important value which is not precluded from the parameter of the new specification: 0.0.

> 
> It seems good practice to use subtyping whenever possible, in particular if it's a property of a parameter, and let Pre condition for more complex properties related to the subprogram as a whole.

Agreed. Very much agreed.

> 
> Just my 2 cents...

Thank you much.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Anouncement: OpenGL Binding w/ Ada-2012.
  2012-10-24 20:40   ` Shark8
@ 2012-10-25 22:22     ` Quentin Ochem
  2012-10-26  1:46       ` Shark8
  0 siblings, 1 reply; 9+ messages in thread
From: Quentin Ochem @ 2012-10-25 22:22 UTC (permalink / raw)


> 
> Can it? I'd have to take a look at the way Ada's ranges for floats work again to tell. IIRC it's [Min_val..Max_Val), if that is the case there is one important value which is not precluded from the parameter of the new specification: 0.0.

Arf - you're entirely right on this, looked at this aspect to quickly.

The alternative is to either use a definition starting at the first value after 0.0:

subtype Positive_Float is Float range Float'Succ (0.0) .. Float'Last;

which admittedly is less readable. Alternatively, an Ada 2012 static predicate would work just as well:

subtype Positive_Float is Float 
with Static_Predicate => Positive_Float > 0.0;

Given the amount of places where this notion of positive float is used, it's interesting to try out either of these two forms.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Anouncement: OpenGL Binding w/ Ada-2012.
  2012-10-25 22:22     ` Quentin Ochem
@ 2012-10-26  1:46       ` Shark8
  0 siblings, 0 replies; 9+ messages in thread
From: Shark8 @ 2012-10-26  1:46 UTC (permalink / raw)


On Thursday, October 25, 2012 4:22:43 PM UTC-6, Quentin Ochem wrote:
> > 
> > Can it? I'd have to take a look at the way Ada's ranges for floats work again to tell. IIRC it's [Min_val..Max_Val), if that is the case there is one important value which is not precluded from the parameter of the new specification: 0.0.
> 
> Arf - you're entirely right on this, looked at this aspect to quickly.

Yep, I've done that myself.

> The alternative is to either use a definition starting at the first value after 0.0:
> 
> subtype Positive_Float is Float range Float'Succ (0.0) .. Float'Last;

True, that's a good one. Though I'm wondering if the Succ will be the next normal value, or the next [possibly denormalized] value... I'll have to look into that later, perhaps when dealing w/ OpenGL's 10-, 11-, and 16-bit floating point numbers.

> which admittedly is less readable. Alternatively, an Ada 2012 static predicate would work just as well:
> subtype Positive_Float is Float 
> with Static_Predicate => Positive_Float > 0.0;
> 
> Given the amount of places where this notion of positive float is used, it's interesting to try out either of these two forms.

Agreed. It would be interesting to see if the two methods are a: equivalent, and b: if there's any performance difference between the two.

Intuitively you would think they were the same, but there may be subtle differences... such as if the subtype's parent is an IEEE float, +Inf would be a valid value for the predicate but an invalid value for the range {because we use subtype Safe_Float is Float'Range to weed out all the non-numeric representations the Succ(0.0)..Float'Last range is a strict subset of Float'Range it too would exclude +Inf whereas a subtype w/ only the greater-than-zero predicate might not.}



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Anouncement: OpenGL Binding w/ Ada-2012.
  2012-10-18 17:16 Anouncement: OpenGL Binding w/ Ada-2012 Shark8
  2012-10-24  3:38 ` joel.s.williamson
  2012-10-24 16:32 ` Quentin Ochem
@ 2012-10-26 13:50 ` Yannick Duchêne (Hibou57)
  2012-10-27  1:56   ` Shark8
  2 siblings, 1 reply; 9+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2012-10-26 13:50 UTC (permalink / raw)


Le Thu, 18 Oct 2012 19:16:51 +0200, Shark8 <onewingedshark@gmail.com> a  
écrit:
> If you do give it a try, feel free to post impressions, ideas,  
> suggestions.
> Thank you.

Won't have time to play with it, but I like reading at spec files: what  
about further decomposition with child packages organized by concerns? Ex:  
`TAO_GL.Functions` is a bit long, and may be a child package for colours,  
another for matrix operations, and one for lights and materials (or two  
different children for each), would make it even cleaner. But that may be  
just me, I tend to split a lot to get tiny regions.

-- 
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Anouncement: OpenGL Binding w/ Ada-2012.
  2012-10-26 13:50 ` Yannick Duchêne (Hibou57)
@ 2012-10-27  1:56   ` Shark8
  0 siblings, 0 replies; 9+ messages in thread
From: Shark8 @ 2012-10-27  1:56 UTC (permalink / raw)


On Friday, October 26, 2012 7:50:51 AM UTC-6, Hibou57 (Yannick Duchêne) wrote:
> Le Thu, 18 Oct 2012 19:16:51 +0200, Shark8 <onewingedshark@gmail.com> a  
> 
> Won't have time to play with it, but I like reading at spec files: what  
> about further decomposition with child packages organized by concerns? Ex:  
> `TAO_GL.Functions` is a bit long, and may be a child package for colours,  
> another for matrix operations, and one for lights and materials (or two  
> different children for each), would make it even cleaner. But that may be  
> just me, I tend to split a lot to get tiny regions.

Good question; I was thinking about that earlier and still haven't decided.

Given how OpenGL has programs whose validity [error-free] may be dependent on runtime parameters that may best be mirrored via generic instantiation a bit of rewriting/re-organization is likely ... but to be perfectly honest I'm not sure which lines would be good to split these [functions] up on. (Though on operation-type does make sense.)



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-10-29  2:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-18 17:16 Anouncement: OpenGL Binding w/ Ada-2012 Shark8
2012-10-24  3:38 ` joel.s.williamson
2012-10-24 20:33   ` Shark8
2012-10-24 16:32 ` Quentin Ochem
2012-10-24 20:40   ` Shark8
2012-10-25 22:22     ` Quentin Ochem
2012-10-26  1:46       ` Shark8
2012-10-26 13:50 ` Yannick Duchêne (Hibou57)
2012-10-27  1:56   ` Shark8

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox