Jump to content

  • Log In with Google      Sign In   
  • Create Account

How hard will it be to convert an MD5 Loader in DirectX 11 to DirectX 9


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Anddos   Members   -  Reputation: 516

Like
0Likes
Like

Posted 27 May 2014 - 12:44 AM

Ive found this tutorial online

 

http://www.braynzarsoft.net/index.php?p=D3D11MD51

 

I am not ready for DirectX 11 yet, i want to load this in DirectX 9 instead

What steps do i need to take to adjust to DirectX 9,i am not bothing about shaders at this moment in time,i am just interested to get an animated model thats not .x loaded in my DirectX 9 window

 

(dx11)            (dx9)

XMFLOAT3 = D3DXVECTOR3

XMVECTOR = D3DXMATRIX

 

is that correct?


Edited by Anddos, 27 May 2014 - 01:18 AM.

:)

Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 8279

Like
3Likes
Like

Posted 27 May 2014 - 01:44 AM

The bulk of the loader code is all CPU-side, and the D3DX/XM data types are actually not API-specific; they're all from CPU-side math libraries.

  • You can use D3DX data types in D3D11 if you have the headers and libs available for them.
  • You can use XM data types in D3D9 if you have the headers and libs available for them.
  • You can even just use raw float arrays instead, if you're so inclined (and in some cases that may be preferable as you won't have a dependency that may affect code portability).

The only conversion that should be needed is that relating to actual D3D objects, which will be those who's data type begins with "ID3D11" or "IDirect3D9" (or "LPDIRECT3D9" if using those).  So for a model format that's just going to be vertex and index buffers.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 Anddos   Members   -  Reputation: 516

Like
0Likes
Like

Posted 27 May 2014 - 03:52 AM

The bulk of the loader code is all CPU-side, and the D3DX/XM data types are actually not API-specific; they're all from CPU-side math libraries.

  • You can use D3DX data types in D3D11 if you have the headers and libs available for them.
  • You can use XM data types in D3D9 if you have the headers and libs available for them.
  • You can even just use raw float arrays instead, if you're so inclined (and in some cases that may be preferable as you won't have a dependency that may affect code portability).

The only conversion that should be needed is that relating to actual D3D objects, which will be those who's data type begins with "ID3D11" or "IDirect3D9" (or "LPDIRECT3D9" if using those).  So for a model format that's just going to be vertex and index buffers.

 

Thanks for the input

 

I am unsure how to convert this correctly to d3d9

 

 
// create an index buffer interface called i_buffer
    g_pD3DDevice->CreateIndexBuffer(sizeof(WORD) * subset.numTriangles * 3,
                              D3DUSAGE_DYNAMIC,
                              D3DFMT_INDEX16,
                              D3DPOOL_MANAGED,
                              &i_buffer,
                              NULL);
VOID* pVoid;    // a void pointer
// lock i_buffer and load the indices into it
    i_buffer->Lock(0, 0, (void**)&pVoid, 0);
    memcpy(pVoid, subset.indices[0], sizeof(indices));
    i_buffer->Unlock();
 
 
The parameters are different it seems
// create a vertex buffer interface called v_buffer
// create a vertex buffer interface called v_buffer
    g_pD3DDevice->CreateVertexBuffer(sizeof( Vertex ) * subset.vertices.size(),
                               D3DUSAGE_DYNAMIC,
                               CUSTOMFVF, //what do i put for this flag?
                               D3DPOOL_MANAGED,
                               &v_buffer,
                               NULL);
 
    VOID* pVoid;    // a void pointer
 
    // lock v_buffer and load the vertices into it
    v_buffer->Lock(0, 0, (void**)&pVoid, 0);
    memcpy(pVoid, subset.vertBuff, sizeof(Vertex));
    v_buffer->Unlock();

Edited by Anddos, 27 May 2014 - 04:12 AM.

:)

#4 mhagain   Crossbones+   -  Reputation: 8279

Like
1Likes
Like

Posted 27 May 2014 - 05:50 AM

For a CreateVertexBuffer call in D3D9 the FVF should normally be 0.

 

There is only one case where specifying an FVF is needed and that's:

  • You're creating a device with software vertex processing, and
  • This vertex buffer is the destination buffer for a ProcessVertices call.

If this doesn't apply (and if you don't know what ProcessVertices does or don't even know the call exists then it doesn't apply) you set FVF to 0 and the buffer will create OK and can be used for any vertex format.  There are no disadvantages to setting FVF to 0 in normal usage.

 

For reference, ProcessVertices was an optimization with software T&L that allowed you to kick off vertex processing on another thread, or to have vertex processing occur once only for multi-pass algorithms.  You run ProcessVertices and vertex processing copies from the source streams to a single destination stream, running transform and lighting on them (or the vertex shader if one is active) as it goes, and which you then use as input to a normal draw call.  There's no reason to use it otherwise and ProcessVertices is not available with a hardware T&L device.

 

So this is a special kind of vertex buffer known as an "FVF vertex buffer" which is only used in very limited and very specific scenarios.  Otherwise you just set FVF to 0 and don't worry about it.

 

Unfortunately a lot of D3D9 tutorial material doesn't take this distinction into account (which gives the impression that the authors of the tutorials don't really know what they're doing - also unfortunate) so you sometimes see it used.  Just be aware that outside of the ProcessVertices call, 0 is a valid value for the FVF parameter and you can use it, no matter what you see in tutorials.


Edited by mhagain, 27 May 2014 - 12:33 PM.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS