Help Pliz....~~~~!!

Started by
5 comments, last by 00702000744 21 years, 7 months ago
My question lies on one possible difference between OpenGL and DirectX which I am not sure if it exists. The following are what I have done in both OpenGL and DirectX: //OpenGL code glTexCoord2f(pObject->pTexVerts[ index2 ].x, pObject->pTexVerts[ index2 ].y); glVertex3f(pObject->pVerts[ index ].x, pObject->pVerts[ index ].y, pObject->pVerts[ index ].z); //DirectX code pVertices.position = D3DXVECTOR3( pAllVertex[(int)(pFirstFrame.pFaces[index].vertIndex[0])].x, pAllVertex[(int)(pFirstFrame.pFaces[index].vertIndex[0])].y, pAllVertex[(int)(pFirstFrame.pFaces[index].vertIndex[0])].z); pVertices.tu = pFirstFrame.pTexVerts[pFirstFrame.pFaces[index].coordIndex[0]].x; pVertices.tv = pFirstFrame.pTexVerts[pFirstFrame.pFaces[index].coordIndex[0]].y; When debugging, I found out that the vertex positions and texture coordinates are the same in both programs, however, it turns out that the DirectX code final rendered object has wrong texture coordinates that make it look messy while the openGL code is perfect. Can anyone tell me why would this happen? Thanks for help in advance! </i>
Advertisement
Sorry forgot to tell you pVertices is the memory entry to the vertex buffer as the following indicates:

m_pVB->Lock( 0, 0, (BYTE**)&pVertices, 0 );
Your code looks inconsistent on the variables names:

//OpenGL code
glTexCoord2f(pObject->pTexVerts[ index2 ].x, pObject->pTexVerts[ index2 ].y);

glVertex3f(pObject->pVerts[ index ].x, pObject->pVerts[ index ].y, pObject->pVerts[ index ].z);

Uses pObject->pTexVerts.x/.y, index2, pObject->pVerts.x/.y/.z, and index, whereas:

pVertices.position = D3DXVECTOR3( pAllVertex[(int)(pFirstFrame.pFaces[index].vertIndex[0])].x,
pAllVertex[(int)(pFirstFrame.pFaces[index].vertIndex[0])].y,
pAllVertex[(int)(pFirstFrame.pFaces[index].vertIndex[0])].z);
pVertices.tu = pFirstFrame.pTexVerts[pFirstFrame.pFaces[index].coordIndex[0]].x;
pVertices.tv = pFirstFrame.pTexVerts[pFirstFrame.pFaces[index].coordIndex[0]].y;<br><br>Uses pAllVertex, pFirstFrame.pFaces.vertIndex.x/.y/.z, index, pFirstFrame.pTexVerts.x/.y. The texture coordinates, are they using the same index as the OpenGL version?<br><br> </i> <br><br>Jim Adams<br><a href="http://home.att.net/~rpgbook">home.att.net/~rpgbook</a><br>Author, <a href="http://www.amazon.com/exec/obidos/ASIN/1931841098/prograrolepla-20">Programming Role-Playing Games with DirectX</a><br>and Focus &#79;n: Advanced Animation with DirectX<br><br>
Oh - just noticed this :

pVertices.position =
pVertices.tu =
pVertices.tv =<br><br>Your texture coordinates are referenced by index ([]), while the position is not. Shouldn''t you match by removing the , or by adding to position?<br> </i>
Ok, to clear things out, I''ll put my question in this way:

Are these two parts of code equivelent?

// First part(From OpenGL)
glTexCoord2f(3.0f, 5.0f);
glVertex3f(4.0f, 4.0f, 4.0f);

// Second Part(From DX)
m_pVB->Lock( 0, 0, (BYTE**)&pVertices, 0 );
pVertices.position = D3DXVECTOR3(4.0f, 4.0f, 4.0f);
pVertices.tu = 3.0f;
pVertices.tv = 5.0f;<br><br>m_pVB->Unlock();<br><br> </i>
ermmm I don''t think so...aren''t the texture mapping coordinates flipped going from OpenGL to Direct3D???

IIRC, the bottom left corner of the OpenGL coordinate matrix is 0.0f, 0.0f and on Direct3D it''s 0.0f,1.0f

The y-axis is reversed...

Or am I loopY?
you''re accesing the v-tex coord with the index [], but you''re not accessing the position or u-tex coord with it.

This topic is closed to new replies.

Advertisement