Jump to content
  • Advertisement
Sign in to follow this  
pankaj.sachdeva

Why SlimDX displays texture in Black & White only

This topic is 2648 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All,

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


SlimDX.Direct3D9.Texture texture = SlimDX.Direct3D9.Texture.FromFile(device, fileName);
device.SetTexture(0,texture);



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
Advertisement
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.

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
Got the solution I screwed the light setup function in my program. Actually I'd use

device.SetTextureStageState(0, TextureStage.ColorArg1, TextureArgument.Diffuse);

instead of

device.SetTextureStageState(0, TextureStage.ColorArg1, TextureArgument.Texture);

Share this post


Link to post
Share on other sites
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!