XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

Porting OpenGL texture code to D3D

Last post 05-13-2008 1:32 PM by jwatte. 1 replies.
  • 05-12-2008 11:42 AM

    Porting OpenGL texture code to D3D

    Hi all,

    I am trying to build a plugin for a proprietary software which can provide texture ID in OpenGL format (namely provides int value ID) associated with a particular object. That being said, it does support both D3D and OpenGL within the aforesaid plugin. The problem is I am not sure how I can pass texture ID/instance into the plugin as I am unaware of a way of exposing software to D3D API's classes and structures used for instantiating of textures, and at the same time am unsure if there is a call within D3D that would reference a particular texture via its ID which is expressed as an int value.

    So, I was wondering if anyone had any ideas as to how one could approach this predicament. Namely, is there a D3D call equivalent to OpenGL's referencing of a texture ID (int) that is compatible with OpenGL's format?
  • 05-13-2008 1:32 PM In reply to

    Re: Porting OpenGL texture code to D3D

    In a 32-bit OS, you can just cast the pointer:


    int id = (int)pIDirect3DTexture9;


    In a 64-bit OS, you're not so lucky; you have to build a translation table, such as a hash table, that can go from id to pointer and back. And every user of the ID needs to be "in" on it, or use some interface that knows how to do the translation when the texture is needed.



    Jon Watte, Direct3D MVP kW X-port 3ds Max .X exporter kW Animation source code
Page 1 of 1 (2 items) Previous Next