Sign in to follow this  
Juksosah

Weird texture problem !

Recommended Posts

A weird thing is happening here... I loaded a texture using D3DXCreateTexFromFile.. or something like that and rendered some lines (using linestrips) on the screen. It worked fine. Then I wanted to change the texture (so basically all i've done in my code is changing the texture's filename) and the new texture showd up properly but my lines were gone ?!? I switched back to the old texture and the lines were back again... Any explanations ? the lines are rendered after the texture

Share this post


Link to post
Share on other sites
A little bit more information might be useful. Your description doesn't have much in the way of details [smile]

If you're rendering 2D geometry/images then its likely to be draw-order dependent (not sure if ID3DXLine supports Z/depth values, even if thats what you're using...)

You say you're changing your textures... does that mean you're creating/loading a new IDirect3DTexture9 or are you Release()'ing and re-using the same one?

A bit more of an explanation - some pseudo code for example - might help us give you a better answer...

Cheers,
Jack

Share this post


Link to post
Share on other sites

Your lines are actually having UV coordinates ?

If not, is your texture having alpha channel and you have alpha blending/testing enabled. This might lead to a situation where the texture alpha keeps the lines from being rendered.

Share this post


Link to post
Share on other sites
Ok I was in a hurry...


//I wanted to change wMan4.jpg for another jpg.
//When I changed the filename, the line then dissapeared.

if (c1->initialise(d3dDevice, "wMan4.jpg") != D3D_OK){
return debug::erreur(rslt, __LINE__, __FILE__, "CreateVeffailed.");
}


A little bit of initialise function...


rslt = pDevice->CreateVertexBuffer ( NB_VERTICES * sizeof(BASEVERTEX),
D3DUSAGE_WRITEONLY, D3DFVF_BASEVERTEX, D3DPOOL_DEFAULT, &vertexBuffer, NULL);


if (imageFile){

rslt=D3DXCreateTextureFromFileEx(pDevice, imageFile, D3DX_DEFAULT, D3DX_DEFAULT,
D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
D3DX_DEFAULT, D3DX_DEFAULT, /*0*/0xFFFFFFFF, &in, NULL, &texture);

if (FAILED(rslt)){

return D3DObject::erreur(rslt, __LINE__, __FILE__, "CreateTexture() failed.");
}
}



pDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER );
pDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);



My FVF for the lines is D3DFVF_BASEVERTEXLINE (D3DFVF_XYZ | D3DFVF_DIFFUSE)

FOr the textures it's D3DFVF_BASEVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1)

Share this post


Link to post
Share on other sites
No my lines don't have UV coordinates.

Of course the lines are for debugging/visual helping purpose only, but right now I need to see them !

And no I don't create another IDirect3DTexture9 nor realising it.

All I do is changing the filename used to create the texture
So basically in my scene there is one textured quad and a bunch of lines.

I ran the program once with let's say a boat image on the quad.
Lines were showing up properly.

I changed the filename (ex : from boat.jpg to cat.jpg) in my code, compiled and ran it again.
But all I saw was a cat, and no lines :(


That's it.

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