Jump to content

  • Log In with Google      Sign In   
  • Create Account


IDirect3DTexture9 vs LPDIRECT3DTEXTURE9


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 AussieSpoon   Members   -  Reputation: 184

Like
0Likes
Like

Posted 06 January 2013 - 08:07 AM

Hello,

 

I have been using LPDIRECT3DTEXTURE9 exclusivly in my projects and creating textures using "D3DXCreateTextureFromFile(..." 

 

But I want to learn how to use a IDirect3DTexture9 instead. (I understand that LPDIRECT3DTEXTURE9 is just a IDirect3DTexture9*) 

 

My main problem is creating a IDirect3DTexture9 from a file. It is a lot easier using D3DXCreateTextureFromFile(....) constructor, from what I can tell

 

. I believe for a IDirect3DTexture9 i use device->CreateTexture(.....) but I don't know what pass in for DWORD usage, D3DFORMAT format, D3DPOOL Pool? Are there defaults for these? (does LPDIRECT3DTEXTURE9 have these?)

 

Also there doesn't seem do be a file name parameter for IDirect3DTexture9 so how would I create a IDirect3DTexture9 from a file? 

 

I have looked at the msdn pages and they are no help to me. 

 

Thanks. 



Sponsor:

#2 Hodgman   Moderators   -  Reputation: 29489

Like
3Likes
Like

Posted 06 January 2013 - 08:37 AM

I understand that LPDIRECT3DTEXTURE9 is just a IDirect3DTexture9*

Then to stop using LPDIRECT3DTEXTURE9, you just have to find-replace-in-files with IDirect3DTexture9* and you're done cool.png

does LPDIRECT3DTEXTURE9 have these?

There's no difference between LPDIRECT3DTEXTURE9 and IDirect3DTexture9*, so yes, they both have al the same stuff as each other.

I don't know what pass in for DWORD usage, D3DFORMAT format, D3DPOOL Pool?
Also there doesn't seem do be a file name parameter for IDirect3DTexture9 so how would I create a IDirect3DTexture9 from a file?

D3D is just a graphics API, it doesn't (and shouldn't!) know anything about file systems (D3DX is the helper layer to make writing simple programs easier, so it has file-system and image-format helpers). If you're not using D3DX to load your files, then you've got to load the file yourself, decode the file-format (PNG, BMP, etc) and generate an array of bytes that contain the pixel values, which you'll pass to CreateTexture. There's plenty of image loading libraries out there to help with the decoding steps (no need to write your own PNG/etc decoder).
 
For format, the most common will be D3DFMT_A8B8G8R8 -- the regular 32bpp format with red, green, blue and alpha channels. If you're loading a 24bpp image file, you'll have to convert it to 32bpp by adding an alpha channel to it.
 
For usage, most textures will use 0 (no flags).

If you want to write to it constantly from the CPU (for streaming video, etc), you'd use D3DUSAGE_DYNAMIC. If you want to draw to it using the GPU, you'd use D3DUSAGE_RENDERTARGET. If you're creating a depth-buffer texture (e.g. with format=D3DFMT_D24S8), you'd use D3DUSAGE_DEPTHSTENCIL.
 
For the pool, regular textures usually use D3DPOOL_MANAGED. Dynamic, render-target, and depth-buffer textures can't go in that pool though, so for them you'd use D3DPOOL_DEFAULT.



#3 AussieSpoon   Members   -  Reputation: 184

Like
0Likes
Like

Posted 06 January 2013 - 08:52 AM

 

Then to stop using LPDIRECT3DTEXTURE9, you just have to find-replace-in-files with IDirect3DTexture9* and you're done cool.png

Thanks for the response.

 

Could you further elaborate on what this means? Do I go into the directX file (in this case d3dx9tex.h?) and replace  LPDIRECT3DTEXTURE9 with IDirect3DTexture9*? 

 

Sorry but I've never alterd any of the DirectX code out of fear of ruining it. 



#4 Paxi   Members   -  Reputation: 183

Like
3Likes
Like

Posted 06 January 2013 - 09:08 AM

I think he ment that you can just replace every LPDIRECT3DTEXTURE9 in your code with IDirect3DTexture9*.
 

LPDIRECT3DTEXTURE9 is nothing more than a typefef for IDirect3DTexture9*



#5 AussieSpoon   Members   -  Reputation: 184

Like
0Likes
Like

Posted 06 January 2013 - 09:20 AM

I think he ment that you can just replace every LPDIRECT3DTEXTURE9 in your code with IDirect3DTexture9*.
 

LPDIRECT3DTEXTURE9 is nothing more than a typefef for IDirect3DTexture9*

 

 

I think he ment that you can just replace every LPDIRECT3DTEXTURE9 in your code with IDirect3DTexture9*.
 

LPDIRECT3DTEXTURE9 is nothing more than a typefef for IDirect3DTexture9*

Oh damn, I thought I did that correctly but I had IDirect3DTexture instead of IDirect3DTexture*

 

Thanks heaps everyone 



#6 cozzie   Members   -  Reputation: 1583

Like
0Likes
Like

Posted 06 January 2013 - 10:15 AM

Hi,

One addition, it might me worthwhile to think about the structure of your possible engine. If your planning to create lots of classes, it might me usefull to use the 'LP' variants for d3d objects (i.e. textures), this makes life easier when passing through these objects without '*'/ pointers, since LP.... already is a pointer.

Maybe this can help you. Myself I use always LP.... objects.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS