Skip to main content
gamedev.net
🔒 Locked

Texture Problem

Started by StarGamer_Nick 3 replies 350+ views
Original Post
StarGamer_Nick
StarGamer_Nick
Hi, I have a very weird when I try to show a texture on a surface create by a series of vertex. Only one color of my texture is show on the entire surface. I think it might have something to do with my coordinate or with with the type of vertex I''m using. Let me know what you think. (This is my list of vertex, my customVertex are using Position,Normal,Diffuse,Specular & 1 set of Texture Coord) //// CUSTOMVERTEX* pListVertex; pListVertex = new CUSTOMVERTEX[4]; pListVertex[0].position = D3DXVECTOR3(-1.0f,1.0f,0.0f); pListVertex[0].normal = D3DXVECTOR3(0.0f,0.0f,-1.0f); pListVertex[0].diffuse = D3DXCOLOR (0.1f,0.1f,0.1f,0.1f); pListVertex[0].specular = D3DXCOLOR (0.1f,0.1f,0.1f,0.1f); pListVertex[0].u = 0.0f; pListVertex[0].v = 0.0f; pListVertex[1].position = D3DXVECTOR3(1.0f,1.0f,0.0f); pListVertex[1].normal = D3DXVECTOR3(0.0f,0.0f,-1.0f); pListVertex[1].diffuse = D3DXCOLOR (0.1f,0.1f,0.1f,0.1f); pListVertex[1].specular = D3DXCOLOR (0.1f,0.1f,0.1f,0.1f); pListVertex[1].u = 1.0f; pListVertex[1].v = 0.0f; pListVertex[2].position = D3DXVECTOR3(-1.0f,-1.0f,0.0f); pListVertex[2].normal = D3DXVECTOR3(0.0f,0.0f,-1.0f); pListVertex[2].diffuse = D3DXCOLOR (0.1f,0.1f,0.1f,0.1f); pListVertex[2].specular = D3DXCOLOR (0.1f,0.1f,0.1f,0.1f); pListVertex[2].u = 0.0f; pListVertex[2].v = 1.0f; pListVertex[3].position = D3DXVECTOR3(1.0f,-1.0f,0.0f); pListVertex[3].normal = D3DXVECTOR3(0.0f,0.0f,-1.0f); pListVertex[3].diffuse = D3DXCOLOR (0.1f,0.1f,0.1f,0.1f); pListVertex[3].specular = D3DXCOLOR (0.1f,0.1f,0.1f,0.1f); pListVertex[3].u = 1.0f; pListVertex[3].v = 1.0f; //// I''m also using normal material and normal lighting. I''ve read the docs but they barely mention the usage of Light + Material + Texture. Does anyone have any idea of what could be the problem ? Nick
RageMatrix
RageMatrix
Sorry if you''ve got e-mail alert turned on for this thread but I also would like a little more info on this.

Regards,

Rage_Matrix


Tron Software

-=Kicking Butt and Writing Code=-
TooTer
TooTer
You are going to need to show a bit more than that. I am guessing, looking at your code, that you are using an index list? Can you show a bit more detail.

Scott
StarGamer_Nick
StarGamer_Nick
Okay.. I'm putting here the code I use to render the scene
(The code is based on information provided in the Tutorial
and in the document). BTW, I'm not using an index.


The Vertex Format I'm using is:
D3DFVF_CUSTOMVERTEX =
D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_SPECULAR|
D3DFVF_TEX1

(And it's in the correct order in my CustomVertex structure)

The following code is located within a Clean,BeginScene,EndScene Present Code.

g_pd3dDevice is a valid pointer to a Direct3D Device and pVertexBuf is a pointer to a valid Vertex Buffer.

(If pVertexBuf wasn't invalid, I wouldn't be able to see
my object, that's how I can tell for sure)



      
LPDIRECT3DTEXTURE8 pObjTexture1;

D3DXCreateTextureFromFile( g_pd3dDevice, pTextureName,
&(pObjTexture));

g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,
D3DTOP_SELECTARG1);

g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1,
D3DTA_TEXTURE );

g_pd3dDevice->SetTexture( 0, pObjTexture);


g_pd3dDevice->SetStreamSource( 0,pVertexBuf,
sizeof(CUSTOMVERTEX));

g_pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX );

g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2);





I hope this will help someone find an answer because I'm running out of ideas

Thanks.

Nick

[edited by - Stargamer_Nick on June 20, 2002 11:02:13 AM]

[edited by - Stargamer_Nick on June 20, 2002 11:04:07 AM]

[edited by - Stargamer_Nick on June 20, 2002 11:06:50 AM]
StarGamer_Nick
StarGamer_Nick
DOH !



I finally found out what my problem was. It turns out it wasn''t even related to the code I sent, it was located way earlier in my code, when I create my Vertex Buffer, I forgot to transfer the information about Diffuse,Specular & Material Coordinate to the vertex attach to the buffer.

Well, like the old saying goes: "We always learn from our mistake".


Nick

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.