DX3D Sur-Faces VS Tex-Tures, oh my! ;)

Started by
11 comments, last by cruiz 22 years ago
CreateTextureFromFileEx:
This is VB code (took it from a site but the parameters are mostly the same)

object.CreateTextureFromFileEx( _
Device As Direct3DDevice8, _
SrcFile As String, _
Width As Long, _
Height As Long, _
MipLevels As Long, _
Usage As Long, _
Format As CONST_D3DFORMAT, _
Pool As CONST_D3DPOOL, _
Filter As Long, _
MipFilter As Long, _
ColorKey As Long, _
SrcInfo As Any _
Palette As Any) As Direct3DTexture8

Object : An initialised D3DX8 object.
Device : Your 3D rendering Device
SrcFile : A string indicating where the texture is to be loaded from
Width : width in pixels, if specified it must be a valid power of 2 value (64, 128, 256 and so on...). You can use "D3DX_DEFAULT" to let Direct3D decide what size to load it as (whatever size it was saved at)
Height : Same as width, but for the height (funny that)
MipLevels : How many mip-map levels are generated; these will be discussed later on in this series. For now just leave it as D3DX_DEFAULT (A complete chain is created) or 1 (Only 1 level is generated) where 1 will require the least amount of memory.
Usage : You can make this texture a render target (useful for some special effects) but for normal use make this value 0.
Format : What format the surface is in; same as when you specify what backbuffer format you want during initialisation. If you''re doing anything clever you may well need to know what this format is; but most of the time just leave it as "D3DFMT_UNKNOWN"
Pool : Whereabouts this memory should be allocated; certain areas have less space and different areas are faster for different uses. D3DPOOL_MANAGED should be suitable for most uses, other uses will be explained later on in this series.
Filter : What texture filter we want to use. This only really affects things that are stretched or squashed - which when you move into proper 3D will happen to almost every texture used. Normally you''ll want to use D3DX_FILTER_LINEAR , but for simple things you can use D3DX_FILTER_POINT and for best quality you can use D3DX_FILTER_TRIANGLE. Experiment with them as you choose - some look better than others in certain situations
MipFilter : Same as the above argument, but for mip maps. These will be explained later on in the series.
ColorKey : What colour is going to be transparent black. This is a 32 bit ARGB code - best represented by a hexidecimal number. You should be familiar with RGB notation (3 sets of 2 figures (0 to 9) or letters (A to F)); this value is basically &HFF. All it does is make all pixels of the specified colour fully transparent.
SrcInfo : Allows you to specify a D3DXIMAGE_INFO structure giving any information about the source file - height, width, depth and format. Not really needed - leave as "ByVal 0"
Palette : Leave as ByVal 0. Palettes are on the way out, with the ever increasing hardware (even the now "old" cards support better) capabilites there is very little speed advantage to be gained by using them - and they look pretty rubbish anyway.

However...
If you haven''t downloaded the SDK yet do so it really explains it all!

Regards Shadows

Advertisement
Oh and btw the texturecoordinates are one a 0.0f - 1.0f scale not on a pixel scale... for example

256x256
0.0f = Pixel 0
0.5f = Pixel 128
1.0f = Pixel 256

The formula would be:
TexCoord = (1 / MaxTexSize) * PixelCoord;
Which works perfect for example
TexCoord = (1 / 256) * 128
TexCoord = 0.5;

Hope this helps
Regards Shadows

Hi people!
Tnx shadows!
Yes I have the SDK.
But I don't find the SDK very useful...
Yes now I can cut it. Thaaaaannnnkkkkkssss!
I can move it, too.
----My coffee is void again!
---My head explodes soon...
I gonna get more coffee and then I will see...

ok... euh yes
Now I said this to the graphics-friend.
Soon I will can copy the entire game from DDraw to D3D.
Thanks to all!

C.Ruiz( My bed is jalous of my pc and the coffee)


[edited by - cruiz on March 25, 2002 10:29:09 AM]

This topic is closed to new replies.

Advertisement