This topic is now archived and is closed to further replies.


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

Recommended Posts

cruiz    122
Hi People! I''m trying here to copy a texture(DX3D) in a lot of Textures(For animation..). Ok. I have here first: - CreateTextureFromFile (logical isn''t?) then... CreateTexture and I made a void texture. Ok then a bird( ) said to me I should take the CopyRects-command. ... ok ... I took it... And then... In the copyrects command you can''t(till I can see) use Textures to copy, you should give him surfaces... ????????? I mean... What????? Should I convert all my textures in surfaces and then copy and then convert it again in textures????? Is there an other command? Or what should I do. I mean...I have here the commandlists before me and here it says, that there is a surfacefromfile command. But not a convert texture to surface or surface to texture command... Please help!!! (i can remember on surfaces in DD This should be something different, not?) Thanks to all! Greets: C.Ruiz (I had today an english-test: horrible like you can see... )

Share this post

Link to post
Share on other sites
cruiz    122
Hey! Thanks for this post!
Ok now I have converted it and then "copyreccted" it!
But... Now I should convert it in texture again.
And... that's the same problem like before...
means... I did'nt found any commands to convert...
What's the command to convert it again from surface to texture now?
Tnx to all and to Jack!

Greets: C.Ruiz

[edited by - cruiz on March 19, 2002 4:41:31 AM]

Share this post

Link to post
Share on other sites
cruiz    122
Please help!
Do you know witch command I should take to
convert it now from surface to texture?
This would be the last step!
Tnx to all: C.Ruiz

Share this post

Link to post
Share on other sites
Sorrow    122
you don't convert surfaces to texture. The texture instead contains surfaces.

Call GetSurfaceLevel(whatever) to get access to one of them, and then just release the surface when you're done with it. If you did something to the surface you've already updated the texture.

[edited by - sorrow on March 19, 2002 8:34:50 AM]

Share this post

Link to post
Share on other sites
cruiz    122
It doesn''t work but I don''t understand it either!
CreateTextureFromFile Tex1
CreateTexture Tex2(void) <-(could be probably wrong defintion)

And then??????
Tex1->GetSurface Level( 0, Surface1)

Copyrect( surface1 to surface2

And then????!!!!????

Get surface Level(0, Surface2)
Can anyone explain this? Plz!
Tnx for posts but I''m still frustrated....


P.S.: Coffee is my best friend!
P.P.S.: I try to make my text "living".
The question marks should take the reader to a long journey of you know... What a ***?????? What am I writing here??????

Share this post

Link to post
Share on other sites
Taulin    100
I think what he is saying is, release your Surface1 pointer after you did you copy rect. Then go about your biz as usual.
Your texture buffers should be ready to party now.

Oh....and &%!@~!!!!!

Share this post

Link to post
Share on other sites
Shadows    133
Hmm this is how I do it (note: from memory and no real commands

CreateTexture("somefile", blabla);





Hope this helps, oh and by the way D3D won''t convert between formats so make sure your dest texture is in the correct format...

Regards Shadows

Share this post

Link to post
Share on other sites
cruiz    122
Hi again!
Ok I did it. I believe.
Ok... I know I''m new in DX3D.
But it doesn''t work properly. Yeah....
I would have problems explaining it. I copy it
and then he paints only a part of it. In the rest surface of the brush(sorry for this english) it paints some crazy lines. Like an error. How... tv or I don''t know when it gives problems.
I hope you can Imagine.
Ok I think following:
I loaded the texture well. Because I can see one part ok. (i mean correct bits etc...)
There are 3 numbers.
I mean first there is the size of the vertices.
For example 7.0f and 1.0f. I I change this it changes the size of the entire texture-"field". This should not be the problem.
Then there is the size of CreateTexture.... should be the size of pixels not? (shoudl be! How I think...)
And then there is the size of the copied RECT. I mean his should be ok because I can change it and it works ok... (yes... without the rest...)

What does this crazy lines on the texture-"Field"????????
Sorry people! Raelly!!! Probably It''s a newbie problem.
Probably It''s a big shame this problem.
Hope not but... I know...

Yes I''m tired.... and my coffee-can is void!!!!!!!!!
I need coffee!!!!!!!!

Greets to all out there: C.Ruiz

Share this post

Link to post
Share on other sites
Shadows    133
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, _
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.

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

Regards Shadows

Share this post

Link to post
Share on other sites
Shadows    133
Oh and btw the texturecoordinates are one a 0.0f - 1.0f scale not on a pixel scale... for example

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

Share this post

Link to post
Share on other sites
cruiz    122
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]

Share this post

Link to post
Share on other sites