comp.lang.ada
 help / color / mirror / Atom feed
From: chris <spamoff.danx@ntlworld.com>
Subject: Re: Access type conversions, how?
Date: Tue, 13 Apr 2004 18:54:20 +0100
Date: 2004-04-13T18:54:20+01:00	[thread overview]
Message-ID: <yLVec.158$xN.24@newsfe1-gui.server.ntli.net> (raw)
In-Reply-To: <407c0f2c.0@entanet>

Luke Guest wrote:
> "chris" <spamoff.danx@ntlworld.com> wrote in message
> news:LnTec.5$094.0@newsfe1-win...
> 
>>type GLMatrix is array (1 .. 15) of GLFloat;
>>pragma Convention(C, GLMatrix);
> 
> No.
> 
>>What do you want to do?  Pass an array to a C function or an array of
>>arrays?
> 
> Like I said, we have a GL package which is the OpenGL bindings (yeah, all
> the functions).
> 
> I want to have an abstraction layer so I can *hide* the details of the 3D
> API (or whatever I'm using on a particular platform), above my layer, 
> I don't want any other code to know about the lower levels, i.e. it should 
> not reply on GL.GLfloat, simple as that.

 From the code you posted it looks like a convoluted solution.  Maybe 
it's the lack of context.

I would do one of two things.  Either just stick with the native GL 
types or make Ada ones corresponding to them and convert like this...


type GLMatrix is array (1..15) of GLFloat;
pragma Convention (C, GLMatrix);

type OpenGLMatrix is array (1..15) of GLFloat;


A : OpenGLMatrix;

A (1..15) := OpenGLMatrix (SomeMatrix (1..15));

or A := OpenGLMatrix(SomeMatrix);

I think i'd stick with the GL types (possibly subtyping or creating new 
types from them), there seems to be no gain in hiding those since 
they're simple and easy enough to use.

subtype OpenGLMatrix is GL.GLMatrix;

> But as GL bindings use the GL types, I cannot get a pointer to convert to
> another pointer with the same base types.

Why do that?



  reply	other threads:[~2004-04-13 17:54 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-13  0:32 Access type conversions, how? Luke A. Guest
2004-04-13  1:25 ` Randy Brukardt
2004-04-13  8:08   ` Luke A. Guest
2004-04-13 15:11     ` chris
2004-04-13 16:01       ` Luke Guest
2004-04-13 17:54         ` chris [this message]
2004-04-13 19:31           ` Luke A. Guest
2004-04-13 22:51             ` Luke A. Guest
2004-04-13 21:59               ` Lutz Donnerhacke
2004-04-14 11:53                 ` Luke Guest
2004-04-14 12:07                   ` Lutz Donnerhacke
2004-04-14 13:36             ` Robert I. Eachus
2004-04-14 17:37               ` Jeffrey Carter
2004-04-13 14:57 ` zhenglonggen
2004-04-14  7:45   ` Martin Dowie
2004-04-14 11:49     ` Luke Guest
replies disabled

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