comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <martin@krischik.com>
Subject: Re: OpenGL Texture mapping
Date: Fri, 17 Dec 2004 09:32:50 +0100
Date: 2004-12-17T09:32:50+01:00	[thread overview]
Message-ID: <61297206.dXk3falXKh@linux1.krischik.com> (raw)
In-Reply-To: cptbjo$s7b3@cui1.lmms.lmco.com

Alfredo Macias wrote:

> Sorry for the confusion, I only included what I thought was the most
> relevant code, but that is just a part of it.
> 
> Data :  Data_Buffer_Type; is actually an incoming parameter to this
> procedure where I'm trying to do the texture mapping.
> Which means that Data was originally instantiated by the caller and
> initialized to values read from a bitmap file, so by the time Data is
> received by my texture mapping procedure, Data actually contains 256*256
> bytes with the bitmap data.  (I have output its contents as text and
> manually verified it for correctness right before my call to
> Gl.GlTexImage2D).
> 
> So other than that, does anything else look incorrect?

No! But tell you the truth: before I would post a statement like this to
c.l.a I would break it up - one function call at a time - and store all
intermediate result in temporary variables.

declare:

X0 : .... renames Data(1)(1);
X1 : System.Address := X0'Address; 
X2 : .... := Gl_Pointer_Conversions.To_Pointer (X1)
X3 : .... := Gl.Glpointerᅵᅵ(X2)

begin
ᅵᅵᅵᅵᅵᅵGl.GlTexImage2D(
ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵGl.Gl_TEXTURE_2D,
ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵGl.Glsizei(0),
ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵGl.Pixelformatenm'(Gl.Gl_Rgb),
ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵGl.Glsizei(Width),
ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵGl.Glsizei(Height),
ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵGl.Glsizei(0),
ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵGl.Pixelformatenm'(Gl.Gl_Rgb),
ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵGl.Pixeldatatypeenm'(Gl.Gl_Unsigned_Byte),
ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵ.... => X3);
end

That way you get a more meaningfull errror message. Also better if you ever
need to use the debugger. And no difference in perfomace once the optimizer
found out that each variable is only used once. The GNAT optimizer will
actually tell you that all variables are "constant".

BTW: you should name the parameters when there are more then three - I you
need to read your code in half a year you'll be gratefull for it ;-) .

With Regards

Martin
-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com



      reply	other threads:[~2004-12-17  8:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-16 18:45 OpenGL Texture mapping Alfredo Macias
2004-12-16 20:15 ` tmoran
2004-12-16 21:33 ` Martin Krischik
2004-12-17  1:09   ` Alfredo Macias
2004-12-17  8:32     ` Martin Krischik [this message]
replies disabled

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