From: Stefan Soos <stefan.soos@gmx.de>
Subject: Re: AdaSDL and glTexImage2D
Date: Thu, 30 Jan 2003 10:52:39 +0100
Date: 2003-01-30T10:52:39+01:00 [thread overview]
Message-ID: <7lsa1b.jqj.ln@ID-soos.user.dfncis.de> (raw)
In-Reply-To: b19cth$c2k$1@msunews.cl.msu.edu
Hello,
On Wed, 29 Jan 2003 15:15:44 -0500, Chad R. Meiners wrote:
> In AdaSDL-Video-Drawing.adb around line 273 you will find:
> declare
> subtype Current_Screen is Screen_Eight(1..Array_Size);
> package Convert is new System.Address_To_Access_Conversions
> (Current_Screen);
> begin
> Eight_Bit_Draw
> ( On => Convert.To_Pointer (Item.Item.Pixels).all, -- The
> important conversion
> Colors => To_Palette_Provider (Item),
> Coordinates => Coords);
> end;
>
> Here is a example of converting the Image.Pixels (in this case
> Item.Item.Pixels ;) into an access to an array of size Array_Size. Notice
> that we had to declare a subtype of the Screen_Eight array with a specified
> range so that the compiler can reconstruct the range information.
I've only looked at the thin binding in adsdl.ad[bs] and
adsdl_framebuf and there he's doing some tricky stuff with
SDL.Types.Uint[8|16|32]_Ptrs. I've seen the package
Address_To_Access_Conversions in varios sources before but I didn't
know what it was good for ;)
> Now I am guessing that GLubyte_Array is an array of bytes. So for your code
> your solution might look like this
>
> declare
> Bytes_Per_Pixel : constant := 4; -- I believe RGBA is 32 bit color, but
> if I am wrong in your case change this value
> subtype Current_Buffer is
> GLubyte_Array(0..(Width*Height*Bytes_Per_Pixel)-1);
> package Convert is new
> System.Address_To_Access_Conversions(Current_Buffer);
> begin
> glTexImage2D (GL_TEXTURE_2D,
> 0,
> GLint (GL_RGBA),
> GLsizei (Width), GLsizei (Height),
> 0,
> GL_RGBA,
> GL_UNSIGNED_BYTE,
> Convert.To_Pointer (Image.Pixels).all);
> end;
That's exactly how it works. Thank you very much.
The Bytes_Per_Pixel information is stored in Image.format.BytesPerPixel.
> Now remember this might need some tinkering to get it right since I don't
> have the packages to test this out.
There was a little bit of tinkering because I have to do some color
conversion and flipping of the textures but your code worked just
right out of the box ;) Again, thank you so much.
> I hope this solves your problem,
>
> Chad R. Meiners
Indeed, it did. Thanks and bye,
Stefan
--
prev parent reply other threads:[~2003-01-30 9:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-29 10:09 AdaSDL and glTexImage2D Stefan Soos
2003-01-29 20:15 ` Chad R. Meiners
2003-01-30 9:52 ` Stefan Soos [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