Results 1 to 3 of 3

Thread: TPicture to OpenGL Texture

  1. #1

    TPicture to OpenGL Texture

    Hi all,

    i was woundering if it is possible to extract data from TPicture and use it in OpenGL? any ideas??

    Thanx for any help
    M109uk
    M109uk
    <br />--------------------------------------------------------
    <br />www.pulse-soft.oneuk.com

  2. #2

    TPicture to OpenGL Texture

    My answer is "it's probably possible." I can't say that I know off-hand, but when it comes down to it, TBitmap is just a bunch of pixels, which is what OpenGL likes . One problem would be ordering of colours (bgr versus rgb) -- dunno if that would factor into things, since I've not investigated the matter myself. You might have to manually swap the order (not a big deal, but not exactly handy for speed), though maybe not.

    First of all, the TPicture.Bitmap property will get you a TBitmap. You might try something along the lines of the following: set the bitmap's pixel format to a known value so that it's not pfDevice (e.g. MyPic.Bitmap.PixelFormat := pf32Bit). Then, you can take a look at the scanline property of the picture's bitmap and pass it to the relevant function(s) in OpenGL using the address of scanline[0]^[0] or scanline[bmpheight - 1]^[0] (not sure which is appropriate). Will the padding-to-dword for each scanline affect things? Who knows!

    If you don't care much about speed, the simple solution would be to create a dynamic array of byte, size it appropriately, then do some blockreads for the bitmap's scanlines.

    Can you tell that I don't use the VCL much with OpenGL?

    Try the usual suspects to see if they have any examples. Hopefully someone with more knowledge will chime in here.
    "All paid jobs absorb and degrade the mind."
    <br />-- Aristotle

  3. #3

    TPicture to OpenGL Texture

    Thanks for your idea, i found something on the web with the same idea, and am now adding it in :twisted:
    heres the link http://www.delphifr.com/article.aspx?Val=2218
    Its in french, but most of it is easily worked out.

    Just one last question about this though, i've got a feeling that TPicture wont store the alpha channel for TGA files, im using the GraphicEx library to read them, and im not sure how i can dig out the alpha channel or if it stores it?? do you have any idea about this??

    Thanks for your help..
    M109uk[/url]
    M109uk
    <br />--------------------------------------------------------
    <br />www.pulse-soft.oneuk.com

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •