Commit d4b63bbd authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Store the scissor rect in the stateblock.

parent 222c531b
......@@ -3180,6 +3180,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetScissorRect(IWineD3DDevice *iface, C
RECT windowRect;
UINT winHeight;
This->updateStateBlock->set.scissorRect = TRUE;
This->updateStateBlock->changed.scissorRect = TRUE;
memcpy(&This->updateStateBlock->scissorRect, pRect, sizeof(*pRect));
if(This->isRecordingState) {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
GetClientRect(((IWineD3DSwapChainImpl *)This->swapchains[0])->win_handle, &windowRect);
/* Warning: glScissor uses window coordinates, not viewport coordinates, so our viewport correction does not apply
* Warning2: Even in windowed mode the coords are relative to the window, not the screen
......@@ -3197,17 +3206,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetScissorRect(IWineD3DDevice *iface, C
static HRESULT WINAPI IWineD3DDeviceImpl_GetScissorRect(IWineD3DDevice *iface, RECT* pRect) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
GLint scissorBox[4];
ENTER_GL();
/** FIXME: Windows uses a top,left origin openGL uses a bottom Right? **/
glGetIntegerv(GL_SCISSOR_BOX, scissorBox);
pRect->left = scissorBox[0];
pRect->top = scissorBox[1];
pRect->right = scissorBox[0] + scissorBox[2];
pRect->bottom = scissorBox[1] + scissorBox[3];
memcpy(pRect, &This->updateStateBlock->scissorRect, sizeof(pRect));
TRACE("(%p)Returning a Scissor Rect of %d:%d-%d:%d\n", This, pRect->left, pRect->top, pRect->right, pRect->bottom);
LEAVE_GL();
return WINED3D_OK;
}
......
......@@ -78,6 +78,7 @@ void stateblock_savedstates_copy(
dest->vertexDecl = source->vertexDecl;
dest->pixelShader = source->pixelShader;
dest->vertexShader = source->vertexShader;
dest->scissorRect = dest->scissorRect;
/* Fixed size arrays */
memcpy(dest->streamSource, source->streamSource, bsize * MAX_STREAMS);
......@@ -115,6 +116,7 @@ void stateblock_savedstates_set(
states->vertexDecl = value;
states->pixelShader = value;
states->vertexShader = value;
states->scissorRect = value;
/* Fixed size arrays */
memset(states->streamSource, value, bsize * MAX_STREAMS);
......@@ -168,6 +170,7 @@ void stateblock_copy(
Dest->material = This->material;
Dest->pixelShader = This->pixelShader;
Dest->glsl_program = This->glsl_program;
memcpy(&Dest->scissorRect, &This->scissorRect, sizeof(Dest->scissorRect));
/* Fixed size arrays */
memcpy(Dest->vertexShaderConstantB, This->vertexShaderConstantB, sizeof(BOOL) * MAX_CONST_B);
......@@ -484,6 +487,14 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
memcpy(&This->viewport, &targetStateBlock->viewport, sizeof(WINED3DVIEWPORT));
}
if(This->set.scissorRect && memcmp(&targetStateBlock->scissorRect,
&This->scissorRect,
sizeof(targetStateBlock->scissorRect)))
{
TRACE("Updating scissor rect\n");
memcpy(&targetStateBlock->scissorRect, &This->scissorRect, sizeof(targetStateBlock->scissorRect));
}
for (i = 0; i < MAX_STREAMS; i++) {
if (This->set.streamSource[i] &&
((This->streamStride[i] != targetStateBlock->streamStride[i]) ||
......@@ -656,6 +667,9 @@ should really perform a delta so that only the changes get updated*/
if (This->set.viewport && This->changed.viewport)
IWineD3DDevice_SetViewport(pDevice, &This->viewport);
if (This->set.scissorRect && This->changed.scissorRect)
IWineD3DDevice_SetScissorRect(pDevice, &This->scissorRect);
/* TODO: Proper implementation using SetStreamSource offset (set to 0 for the moment)\n") */
for (i=0; i<MAX_STREAMS; i++) {
if (This->set.streamSource[i] && This->changed.streamSource[i])
......
......@@ -1155,6 +1155,7 @@ typedef struct SAVEDSTATES {
BOOL vertexShaderConstantsB[MAX_CONST_B];
BOOL vertexShaderConstantsI[MAX_CONST_I];
BOOL *vertexShaderConstantsF;
BOOL scissorRect;
} SAVEDSTATES;
typedef struct {
......@@ -1243,6 +1244,9 @@ struct IWineD3DStateBlockImpl
/* Current GLSL Shader Program */
struct glsl_shader_prog_link *glsl_program;
/* Scissor test rectangle */
RECT scissorRect;
};
extern void stateblock_savedstates_set(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment