Skip to content

Commit

Permalink
dx9 hardware vertexbuf patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro Lytovchenko committed Oct 3, 2011
1 parent 4c1809a commit 81a0573
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 14 deletions.
2 changes: 2 additions & 0 deletions include/hge_gapi.h
Expand Up @@ -27,6 +27,7 @@
typedef IDirect3DSurface8 hgeGAPISurface;
typedef D3DVIEWPORT8 hgeGAPIViewport;
typedef D3DADAPTER_IDENTIFIER8 hgeGAPIAdapterIdentifier;
typedef D3DCAPS8 hgeGAPICaps;
#endif

#if HGE_DIRECTX_VER == 9
Expand All @@ -38,5 +39,6 @@
typedef IDirect3DSurface9 hgeGAPISurface;
typedef D3DVIEWPORT9 hgeGAPIViewport;
typedef D3DADAPTER_IDENTIFIER9 hgeGAPIAdapterIdentifier;
typedef D3DCAPS9 hgeGAPICaps;
#endif

49 changes: 35 additions & 14 deletions src/core/graphics.cpp
Expand Up @@ -179,10 +179,10 @@ bool HGE_CALL HGE_Impl::Gfx_BeginScene(HTARGET targ)

pD3DDevice->BeginScene();
#if HGE_DIRECTX_VER == 8
pVB->Lock( 0, 0, (uint8_t**)&VertArray, 0 );
pVB->Lock( 0, 0, (uint8_t**)&VertArray, D3DLOCK_DISCARD );
#endif
#if HGE_DIRECTX_VER == 9
pVB->Lock( 0, 0, (VOID**)&VertArray, 0 );
pVB->Lock( 0, 0, (VOID**)&VertArray, D3DLOCK_DISCARD );
#endif
return true;
}
Expand Down Expand Up @@ -593,10 +593,10 @@ void HGE_Impl::_render_batch(bool bEndScene)

if(bEndScene) VertArray = 0;
#if HGE_DIRECTX_VER == 8
else pVB->Lock( 0, 0, (uint8_t**)&VertArray, 0 );
else pVB->Lock( 0, 0, (uint8_t**)&VertArray, D3DLOCK_DISCARD );
#endif
#if HGE_DIRECTX_VER == 9
else pVB->Lock( 0, 0, (VOID**)&VertArray, 0 );
else pVB->Lock( 0, 0, (VOID**)&VertArray, D3DLOCK_DISCARD );
#endif
}
}
Expand Down Expand Up @@ -771,14 +771,35 @@ bool HGE_Impl::_GfxInit()
else nScreenBPP=32;

// Create D3D Device

if( FAILED( pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
d3dpp, &pD3DDevice ) ) )
{
_PostError("Can't create D3D device");
return false;
}
// #if HGE_DIRECTX_VER == 8
// if( FAILED( pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
// D3DCREATE_SOFTWARE_VERTEXPROCESSING,
// d3dpp, &pD3DDevice ) ) )
// {
// _PostError("Can't create D3D8 device");
// return false;
// }
// #endif
// #if HGE_DIRECTX_VER == 9
hgeGAPICaps caps;
pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps);
uint32_t vp;
if((caps.VertexShaderVersion < D3DVS_VERSION(1,1)) || !(caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT))
{
System_Log("Software Vertex-processing device selected");
vp = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
}
else
{
System_Log("Hardware Vertex-processing device selected");
vp = D3DCREATE_HARDWARE_VERTEXPROCESSING;
}
if( FAILED( pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, vp, d3dpp, &pD3DDevice ) ) )
{
_PostError("Can't create D3D device");
return false;
}
// #endif

_AdjustWindow();

Expand Down Expand Up @@ -985,13 +1006,13 @@ bool HGE_Impl::_init_lost()
// Create Vertex buffer
#if HGE_DIRECTX_VER == 8
if( FAILED (pD3DDevice->CreateVertexBuffer(VERTEX_BUFFER_SIZE*sizeof(hgeVertex),
D3DUSAGE_WRITEONLY,
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
D3DFVF_HGEVERTEX,
D3DPOOL_DEFAULT, &pVB )))
#endif
#if HGE_DIRECTX_VER == 9
if( FAILED (pD3DDevice->CreateVertexBuffer(VERTEX_BUFFER_SIZE*sizeof(hgeVertex),
D3DUSAGE_WRITEONLY,
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
D3DFVF_HGEVERTEX,
D3DPOOL_DEFAULT,
&pVB,
Expand Down
Binary file modified tools/particleed/hge.dll
Binary file not shown.
Binary file modified tools/particleed/particleed.exe
Binary file not shown.
Binary file modified tutorials/precompiled/hge.dll
Binary file not shown.
Binary file modified tutorials/precompiled/hge_tut01.exe
Binary file not shown.
Binary file modified tutorials/precompiled/hge_tut02.exe
Binary file not shown.
Binary file modified tutorials/precompiled/hge_tut03.exe
Binary file not shown.
Binary file modified tutorials/precompiled/hge_tut04.exe
Binary file not shown.
Binary file modified tutorials/precompiled/hge_tut05.exe
Binary file not shown.
Binary file modified tutorials/precompiled/hge_tut05_shaders.exe
Binary file not shown.
Binary file modified tutorials/precompiled/hge_tut06.exe
Binary file not shown.
Binary file modified tutorials/precompiled/hge_tut07.exe
Binary file not shown.
Binary file modified tutorials/precompiled/hge_tut08.exe
Binary file not shown.

0 comments on commit 81a0573

Please sign in to comment.