Jump to content
  • Advertisement
Sign in to follow this  
Anddos

need help with putting texture on mesh

This topic is 3777 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

ok i have
        HRESULT hr;
	hr =D3DXCreateTextureFromFile(d3ddev , "taps.bitmap",&D3DTexture);
        if(hr)
	{
		MessageBox(NULL,"valid texture","",0);
	}
hr returns ok now in render loop i have
for(DWORD i = 0; i < numMaterials; i++)    // loop through each subset
    {
         d3ddev->SetMaterial(&material);    // set the material for the subset
		 d3ddev->SetTexture(0 , &D3DTexture);
		
         meshSpaceship->DrawSubset(i);    // draw the subset
		
    }

Share this post


Link to post
Share on other sites
Advertisement
So what's the problem?

Also, this:
if (hr) ...

is incorrect because not all non-zero HRESULT values indicate success. Instead you should write:
if (SUCCEEDED(hr)) ...

Share this post


Link to post
Share on other sites
Ok. Do you have a question? What do the Debug Runtimes say? And that's not the correct way to test for errors. In fact, you'll get your "valid texture" only if the function fails with one of the 2 billion possible codes, or if it succeeds with any of the other 2 billion ones.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anddos
yes my question is , i want to display this texture on the mesh
That's still not a question [smile]

However, as I said in my post, what do the debug runtimes tell you? Does the function fail? Are you useing SUCCEEDED() or FAILED() now, and you've just not updated your post?
Does SetTexture succeed or fail? Any debug output? Is the texture pointer null? Does the mesh render, just without textures?

Share this post


Link to post
Share on other sites
the mesh does render without textures
loading the texture , hr returns success
both meshs ive turned a grey color , which cant be right

this code in in Render();


d3ddev->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1);
d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
d3ddev->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE);
d3ddev->SetTexture(0 , D3DTexture);
//Ignored

for(DWORD i = 0; i < numMaterials; i++) // loop through each subset
{
d3ddev->SetMaterial(&material); // set the material for the subset
meshSpaceship->DrawSubset(i); // draw the subset
}

Share this post


Link to post
Share on other sites
When you say it "returns success", you mean you've changed the code to:
if(SUCCEEDED(hr))
Right?
Any debug output from the debug runtimes? Does SetTexture() fail? Is the texture pointer null?

Share this post


Link to post
Share on other sites
When you say it "returns success", you mean you've changed the code to:
if(SUCCEEDED(hr))
Right?
Any debug output from the debug runtimes? Does SetTexture() fail? Is the texture pointer null?

yes i have changed the code to if(SUCCEEDED(hr))
theres no debug runtimes ,
the texture pointer is NULL as global
SetTexture SUCCEEDED

Share this post


Link to post
Share on other sites
Quote:
Original post by Anddos
When you say it "returns success", you mean you've changed the code to:
if(SUCCEEDED(hr))
Right?
Any debug output from the debug runtimes? Does SetTexture() fail? Is the texture pointer null?

yes i have changed the code to if(SUCCEEDED(hr))
theres no debug runtimes ,
the texture pointer is NULL as global
SetTexture SUCCEEDED
There are debug runtimes. If the texture pointer is NULL, then the texture load failed, or you're releasing it, or you've discarded it in some way. If the pointer is NULL, it means "No texture", so SetTexture will succeed.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!