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

wined3d: Update the blit ortho on size changes.

SetupForBlit sets up the GL viewport and projection matrix for screen-cordinate access to the framebuffer. These settings were not updated if the other gl states were already set up for blitting. Guild Wars reads back an offscreen rendered texture from the framebuffer, which currently sets up CTXUSAGE_BLIT, then changes the render target, and draws to the texture, which has to be reloaded from system memory before it can be rendered to(since GW loaded some data into it). If the two render targets had different size this failed.
parent c4eae160
......@@ -610,6 +610,17 @@ void DestroyContext(IWineD3DDeviceImpl *This, WineD3DContext *context) {
RemoveContextFromArray(This, context);
}
static inline void set_blit_dimension(UINT width, UINT height) {
glMatrixMode(GL_PROJECTION);
checkGLcall("glMatrixMode(GL_PROJECTION)");
glLoadIdentity();
checkGLcall("glLoadIdentity()");
glOrtho(0, width, height, 0, 0.0, -1.0);
checkGLcall("glOrtho");
glViewport(0, 0, width, height);
checkGLcall("glViewport");
}
/*****************************************************************************
* SetupForBlit
*
......@@ -634,6 +645,14 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
TRACE("Setting up context %p for blitting\n", context);
if(context->last_was_blit) {
if(context->blit_w != width || context->blit_h != height) {
set_blit_dimension(width, height);
context->blit_w = width; context->blit_h = height;
/* No need to dirtify here, the states are still dirtified because they weren't
* applied since the last SetupForBlit call. Otherwise last_was_blit would not
* be set
*/
}
TRACE("Context is already set up for blitting, nothing to do\n");
return;
}
......@@ -756,14 +775,6 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
checkGLcall("glLoadIdentity()");
Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), StateTable);
glMatrixMode(GL_PROJECTION);
checkGLcall("glMatrixMode(GL_PROJECTION)");
glLoadIdentity();
checkGLcall("glLoadIdentity()");
glOrtho(0, width, height, 0, 0.0, -1.0);
checkGLcall("glOrtho");
Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION), StateTable);
context->last_was_rhw = TRUE;
Context_MarkStateDirty(context, STATE_VDECL, StateTable); /* because of last_was_rhw = TRUE */
......@@ -775,9 +786,11 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
glDisable(GL_CLIP_PLANE5); checkGLcall("glDisable(clip plane 5)");
Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_CLIPPING), StateTable);
glViewport(0, 0, width, height);
checkGLcall("glViewport");
set_blit_dimension(width, height);
context->blit_w = width; context->blit_h = height;
Context_MarkStateDirty(context, STATE_VIEWPORT, StateTable);
Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION), StateTable);
This->shader_backend->shader_fragment_enable((IWineD3DDevice *) This, FALSE);
}
......
......@@ -616,6 +616,7 @@ struct WineD3DContext {
unsigned char num_untracked_materials;
GLenum untracked_materials[2];
BOOL last_was_blit, last_was_ckey;
UINT blit_w, blit_h;
char texShaderBumpMap;
BOOL fog_coord;
......
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