Skip to content
Browse files

dx9 hardware vertexbuf patch

  • Loading branch information...
1 parent 4c1809a commit 81a05735ac26219f080791c6c121c180a7bb38ee Dmytro Lytovchenko committed Oct 3, 2011
View
2 include/hge_gapi.h
@@ -27,6 +27,7 @@
typedef IDirect3DSurface8 hgeGAPISurface;
typedef D3DVIEWPORT8 hgeGAPIViewport;
typedef D3DADAPTER_IDENTIFIER8 hgeGAPIAdapterIdentifier;
+ typedef D3DCAPS8 hgeGAPICaps;
#endif
#if HGE_DIRECTX_VER == 9
@@ -38,5 +39,6 @@
typedef IDirect3DSurface9 hgeGAPISurface;
typedef D3DVIEWPORT9 hgeGAPIViewport;
typedef D3DADAPTER_IDENTIFIER9 hgeGAPIAdapterIdentifier;
+ typedef D3DCAPS9 hgeGAPICaps;
#endif
View
49 src/core/graphics.cpp
@@ -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;
}
@@ -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
}
}
@@ -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();
@@ -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,
View
BIN tools/particleed/hge.dll
Binary file not shown.
View
BIN tools/particleed/particleed.exe
Binary file not shown.
View
BIN tutorials/precompiled/hge.dll
Binary file not shown.
View
BIN tutorials/precompiled/hge_tut01.exe
Binary file not shown.
View
BIN tutorials/precompiled/hge_tut02.exe
Binary file not shown.
View
BIN tutorials/precompiled/hge_tut03.exe
Binary file not shown.
View
BIN tutorials/precompiled/hge_tut04.exe
Binary file not shown.
View
BIN tutorials/precompiled/hge_tut05.exe
Binary file not shown.
View
BIN tutorials/precompiled/hge_tut05_shaders.exe
Binary file not shown.
View
BIN tutorials/precompiled/hge_tut06.exe
Binary file not shown.
View
BIN tutorials/precompiled/hge_tut07.exe
Binary file not shown.
View
BIN tutorials/precompiled/hge_tut08.exe
Binary file not shown.

0 comments on commit 81a0573

Please sign in to comment.
Something went wrong with that request. Please try again.