Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

00702000744

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

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

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[i].tu = pFirstFrame.pTexVerts[pFirstFrame.pFaces[index].coordIndex[0]].x; pVertices[i].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!

Share this post


Link to post
Share on other sites
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 );

Share this post


Link to post
Share on other sites
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[i].tv = pFirstFrame.pTexVerts[pFirstFrame.pFaces[index].coordIndex[0]].y;

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?



Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX
and Focus On: Advanced Animation with DirectX

Share this post


Link to post
Share on other sites
Oh - just noticed this :

pVertices.position =
pVertices.tu =
pVertices[i].tv =

Your texture coordinates are referenced by index ([]), while the position is not. Shouldn''t you match by removing the [i], or by adding [i] to position?

Share this post


Link to post
Share on other sites
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[i].tv = 5.0f;

m_pVB->Unlock();

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

  • 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!