need help with putting texture on mesh

Started by
12 comments, last by Evil Steve 16 years, 2 months ago
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
		
    }
:)
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)) ...
ok ive corrected that but still the texture isnt displayed on the mesh subsets?
:)
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.
yes my question is , i want to display this texture on the mesh
:)
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?
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   }
:)
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?
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
:)
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.

This topic is closed to new replies.

Advertisement