Jump to content
  • Advertisement
Sign in to follow this  
jerrinx

OpenGL Texture Sharing b/w OpenGL and DirectX

This topic is 2223 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey Guys,

I have an abstraction library for DirectX and OpenGL.
I want to load textures from a single file and read it into memory for either rendering systems directly, without manipulations.

But I can't find an input pixel format shared by both DirectX and OpenGL.

OpenGL Supports the function glTexImage2D
[font="monospace"][size="3"][color="#000000"]on format[/font]
GL_RGBA[color=#000000], GL_BGRA
with type [color=#000000][font=monospace][size=1]GL_UNSIGNED_INT_8_8_8_8[/font]

DirectX supports the function CreateTexture
on format
D3DFMT_A8R8G8B8

I could actually swap around the bytes when reading texture for one of the systems, but that could incur performance loss.
Asynchronous texture loading is one thing I have in mind and want it to be fast when loading.

Any solutions ?

Thanks for your help in advance !!
Jerry

Share this post


Link to post
Share on other sites
Advertisement
These two pairs of texture format describe same thing:
GL_RGBA = D3DFMT_A8B8G8R8
GL_BGRA = D3DFMT_A8R8G8B8

Share this post


Link to post
Share on other sites
Yeah the byte order is backwards in D3D9. They fixed it for D3D10.

Share this post


Link to post
Share on other sites
OpenGL with GL_RGBA8 internalformat, GL_BGRA format and GL_UNSIGNED_INT_8_8_8_8_REV type is identical to D3D9 A8R8G8B8 or X8R8G8B8. Note that D3D9 can't do any 24-bit texture types (nor can OpenGL - well there may be some weird hardware out there that actually can, but the majority will pad to 32) so keep away from GL_RGB/GL_BGR.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!