Skip to main content
gamedev.net
🔒 Locked

[C++] Loading Textures...

Started by SouthernMunk Dec 7, 2005 at 2:54 AM 3 replies 950+ views
Original Post
SouthernMunk
SouthernMunk
I'm writing (or wanting to write) a *simple* class that will manage textures within my application. I was just wondering how I can set the contents of a texture. After using IDirect3DDevice9::CreateTexture() to create the IDirect3DTexture9 interface, can I call the IDirect3DTexture9::SetPrivateData() method to set the colour values? Also, what is the REFGUID parameter for? Another question - I'm not exactly sure what the Levels parameter of the IDirect3DDevice9::CreateDevice() method does? Could someone enlighten me?
Woooooooot!
xyzzy00
xyzzy00
The D3DXCreateTexture functions are your friend.

If you need to fill in the data by hand, Lock the surface, copy the data in a scanline at a time (honoring pitch), and Unlock the surface.

xyzzy

curtmax_0
curtmax_0
If you are creating the texture without D3DX, you need to use LockRect() then memcpy() the data and then UnlockRect(). Check the dx docs for IDirect3DTexture9.

I've never really used the D3DX texture loading functions, but I would assume they are fairly straightforward (or completely retarded.. you never know with microsoft)

EDIT:

Added clicky to interface docs: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/IDirect3DTexture9.asp
jollyjeffers
jollyjeffers
Just as a quick follow-up... the functions you want to be looking at are (I personally think they're more straightfoward than retarded though [smile]):

D3DXCreateTextureFromFile()
D3DXCreateTextureFromFileEx()

You mentioned the IDirect3DTexture9::SetPrivateData() function. In this instance, "private" is for you - not Direct3D. It allows you to attach some data to a texture instance - some advanced texture managers/material systems might find this convenient.

Quote:
Another question - I'm not exactly sure what the Levels parameter of the IDirect3DDevice9::CreateDevice() method does? Could someone enlighten me?

Do you mean IDirect3DDevice9::CreateTexture()? The method you've mentioned doesn't exist, and IDirect3D9::CreateDevice() doesn't have a Levels param [smile]

The levels are for mip-mapping. To improve visual quality when sampling textures in a 3D scene, lower resolution textures can be generated and used (for 2N sizes). Setting this parameter to "0" will generate a default mip-chain, and setting it to "1" will disable it. Theres a bit of information here, alternatively googling the term should yield some information.

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
SouthernMunk
SouthernMunk
Quote:
Original post by jollyjeffers
Do you mean IDirect3DDevice9::CreateTexture()? The method you've mentioned doesn't exist, and IDirect3D9::CreateDevice() doesn't have a Levels param [smile]


Yeah, I meant CreateTexture() not CreateDevice(). Sorry, not enough sleep. :D

Thanks for the info people, much appreciated. Will do some more reading tonight.
Woooooooot!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.