Sign in to follow this  

OpenGL Texture Sharing b/w OpenGL and DirectX

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 [b]glTexImage2D[/b]
[font="monospace"][size="3"][color="#000000"]on format[/color][/size][/font]
[b]GL_RGBA[color=#000000], [/color]GL_BGRA[/b]
with type [b][color=#000000][font=monospace][size=1]GL_UNSIGNED_INT_8_8_8_8[/size][/font][/color][/b]

DirectX supports the function [b]CreateTexture [/b]
on format

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 !!

Share this post

Link to post
Share on other sites
These two pairs of texture format describe same thing:

Share this post

Link to post
Share on other sites
OpenGL with GL_RGBA8 [i]internalformat[/i], GL_BGRA [i]format[/i] and GL_UNSIGNED_INT_8_8_8_8_REV [i]type[/i] 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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this