From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ecb2e25e59be0de6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-30 01:53:34 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!dialin-212-144-129-212.arcor-ip.NET!not-for-mail From: Stefan Soos Newsgroups: comp.lang.ada Subject: Re: AdaSDL and glTexImage2D Date: Thu, 30 Jan 2003 10:52:39 +0100 Message-ID: <7lsa1b.jqj.ln@ID-soos.user.dfncis.de> References: <49981b.cu.ln@ID-soos.user.dfncis.de> Reply-To: stefan.soos@gmx.de NNTP-Posting-Host: dialin-212-144-129-212.arcor-ip.net (212.144.129.212) X-Trace: fu-berlin.de 1043920413 32701598 212.144.129.212 (16 [16707]) X-Orig-Path: ID-soos.user.dfncis.de!nobody User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:33597 Date: 2003-01-30T10:52:39+01:00 List-Id: 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 --