Board index » delphi » how use Tbitmap to texture (OpenGL)

how use Tbitmap to texture (OpenGL)

Does anyone knows how to pass the Tbitmap data or timage.picture.bitmap data
to glTexImage2D(GL_TEXTURE_2D,.....)? I have some components that do it, but
it needs to load the bitmap from disk, and my actually images are created by
process or are passed from scaner to tbitmap or tpicture, I really dont
know how to pass the bitmap info to glTexImage2d..

Any clue??

Ill apreciate any help.
Thank you.

 

Re:how use Tbitmap to texture (OpenGL)


With a 24-bit bitmap, you can use the address of the image as the address of
the texture. If your hardware (OpenGL) driver supports the BGR format for
textures (and you set up texturing accordingly) you can use it as is,
otherwise you have to swap the R and B bytes of each pixel. My web site (see
link below) has some code at "Textured Cylinder" that does this. Granted it
loads from disk, but all you need is a pointer to the 24-bit data, whether
it came from disk or a bitmap created dynamically in memory. Indeed, if you
can create a bitmap in memory with the desired image, and if the sole
purpose is to use it as a texture, then you could create the texture
directly. Code for that is also on my site, this time at "Making an
in-memory RGBA texture" (This is code for 32-bit textures).
--
Jon
http://home1.gte.net/jqjacobs/index.htm
This posting was made entirely from recycled electrons. No innocent atoms
were harmed.
"Ral Armando Valadez Estrada" <macgy...@cantera.reduaz.mx> wrote in message
news:9012ts$sva15@bornews.inprise.com...
Quote
> Does anyone knows how to pass the Tbitmap data or timage.picture.bitmap
data
> to glTexImage2D(GL_TEXTURE_2D,.....)? I have some components that do it,
but
> it needs to load the bitmap from disk, and my actually images are created
by
> process or are passed from scaner to tbitmap or tpicture, I really dont
> know how to pass the bitmap info to glTexImage2d..

> Any clue??

> Ill apreciate any help.
> Thank you.

Re:how use Tbitmap to texture (OpenGL)


Thank you Jon, Ill try it.

Thanks a lot.

Jon Q. Jacobs escribi en mensaje <3a242731$1_2@dnews>...

Quote
>With a 24-bit bitmap, you can use the address of the image as the address
of
>the texture. If your hardware (OpenGL) driver supports the BGR format for
>textures (and you set up texturing accordingly) you can use it as is,
>otherwise you have to swap the R and B bytes of each pixel. My web site
(see
>link below) has some code at "Textured Cylinder" that does this. Granted it
>loads from disk, but all you need is a pointer to the 24-bit data, whether
>it came from disk or a bitmap created dynamically in memory. Indeed, if you
>can create a bitmap in memory with the desired image, and if the sole
>purpose is to use it as a texture, then you could create the texture
>directly. Code for that is also on my site, this time at "Making an
>in-memory RGBA texture" (This is code for 32-bit textures).
>--
>Jon
>http://home1.gte.net/jqjacobs/index.htm
>This posting was made entirely from recycled electrons. No innocent atoms
>were harmed.
>"Ral Armando Valadez Estrada" <macgy...@cantera.reduaz.mx> wrote in
message
>news:9012ts$sva15@bornews.inprise.com...
>> Does anyone knows how to pass the Tbitmap data or timage.picture.bitmap
>data
>> to glTexImage2D(GL_TEXTURE_2D,.....)? I have some components that do it,
>but
>> it needs to load the bitmap from disk, and my actually images are created
>by
>> process or are passed from scaner to tbitmap or tpicture, I really dont
>> know how to pass the bitmap info to glTexImage2d..

>> Any clue??

>> Ill apreciate any help.
>> Thank you.

Re:how use Tbitmap to texture (OpenGL)


I would also be interested in how to do this :)

--
Paul Nicholls (Delphi 5)
"The plastic veneer of civilized man is easily melted in the heat of the
moment" - Paul Nicholls

 Home Page: www.southcom.com.au/~phantom
       < IF YOU WANT TO EARN MONEY WHILE YOU SURF ON THE NET GO HERE: >
       < http://www.alladvantage.com/go.asp?refid=BEM-274 >

Re:how use Tbitmap to texture (OpenGL)


thanks Jon for the tip :)

--
Paul Nicholls (Delphi 5)
"The plastic veneer of civilized man is easily melted in the heat of the
moment" - Paul Nicholls

 Home Page: www.southcom.com.au/~phantom
       < IF YOU WANT TO EARN MONEY WHILE YOU SURF ON THE NET GO HERE: >
       < http://www.alladvantage.com/go.asp?refid=BEM-274 >

Other Threads