Sign in to follow this  
pankaj.sachdeva

Why SlimDX displays texture in Black & White only

Recommended Posts

Hi All,

I got a problem where I am creating a texture from file using the following code:

[code]
SlimDX.Direct3D9.Texture texture = SlimDX.Direct3D9.Texture.FromFile(device, fileName);
device.SetTexture(0,texture);[/code]


but I got trapped into an issue where this texture is displayed only in Black & White color whereas the texture file has colors. Could anybody please help in fixing this issue?

I have also attached the texture file with this thread.

Share this post


Link to post
Share on other sites
Buckeye    10747
First, I'm not a slimdx person. But for anyone to help you, you'll need to post the code where you render the texture, I would think.

In the meantime, does the texture load successfully? It doesn't appear that you check for the possibility it's not loading correctly.

You should be checking if texture is NULL to determine if the load was successful.

If it's not loading, try setting the filename to a full path for the file - something like "c:\\myprojects\\someTexture.jpg", rather than just "someTexture.jpg"

It may be that the texture isn't where your program is looking for it.

Share this post


Link to post
Share on other sites
Texture is loading correctly and there is no issue with the path of the texture file. The code written below is the actual code from my code.
[quote name='Buckeye' timestamp='1302340038' post='4796251']
First, I'm not a slimdx person. But for anyone to help you, you'll need to post the code where you render the texture, I would think.

In the meantime, does the texture load successfully? It doesn't appear that you check for the possibility it's not loading correctly.

You should be checking if texture is NULL to determine if the load was successful.

If it's not loading, try setting the filename to a full path for the file - something like "c:\\myprojects\\someTexture.jpg", rather than just "someTexture.jpg"

It may be that the texture isn't where your program is looking for it.
[/quote]

Share this post


Link to post
Share on other sites
Got the solution I screwed the light setup function in my program. Actually I'd use

[code]device.SetTextureStageState(0, TextureStage.ColorArg1, TextureArgument.Diffuse);[/code]

instead of

[code]device.SetTextureStageState(0, TextureStage.ColorArg1, TextureArgument.Texture);[/code]

Share this post


Link to post
Share on other sites
Yashwinder    100
Try using the full extension of fromFile Functoin and give the format parameter as Format.unknown as

Texture1 = Texture.FromFile(Device, "StringFileName.jpg", 800, 600, 0, Usage.None , Format.Unknown , Pool.Default , Filter.Linear, Filter.Linear, 0);

May be this will help you

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this