From 850bd7b4140e448dabce0385d5b695ff6ec3b531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Sat, 10 Mar 2007 00:44:46 +0100 Subject: [PATCH] wined3d: Restore the index buffer when switching from UP to buffer drawing. The state handler binds index buffer 0 when a user pointer is used. Likewise the real index buffer has to be restored when switching back to drawing from index buffers. --- dlls/wined3d/device.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 0998eec69d3..c7eda3bcb85 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4250,12 +4250,17 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, WI UINT PrimitiveCount) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - This->stateBlock->streamIsUP = FALSE; TRACE("(%p) : Type=(%d,%s), Start=%d, Count=%d\n", This, PrimitiveType, debug_d3dprimitivetype(PrimitiveType), StartVertex, PrimitiveCount); + /* The index buffer is not needed here, but restore it, otherwise it is hell to keep track of */ + if(This->stateBlock->streamIsUP) { + IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER); + This->stateBlock->streamIsUP = FALSE; + } + if(This->stateBlock->loadBaseVertexIndex != 0) { This->stateBlock->loadBaseVertexIndex = 0; IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC); @@ -4277,8 +4282,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice * WINED3DINDEXBUFFER_DESC IdxBufDsc; GLuint vbo; + if(This->stateBlock->streamIsUP) { + IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER); + This->stateBlock->streamIsUP = FALSE; + } pIB = This->stateBlock->pIndexData; - This->stateBlock->streamIsUP = FALSE; vbo = ((IWineD3DIndexBufferImpl *) pIB)->vbo; TRACE("(%p) : Type=(%d,%s), min=%d, CountV=%d, startIdx=%d, countP=%d\n", This,