wined3d: Small rhw vertex fix.
Fix the one pixel displacement and move the glOrtho code in a common function.
This commit is contained in:
parent
fc6ffb29e4
commit
5b8b776431
|
@ -180,25 +180,7 @@ static GLfloat invymat[16] = {
|
||||||
0.0f, 0.0f, 1.0f, 0.0f,
|
0.0f, 0.0f, 1.0f, 0.0f,
|
||||||
0.0f, 0.0f, 0.0f, 1.0f};
|
0.0f, 0.0f, 0.0f, 1.0f};
|
||||||
|
|
||||||
/* Setup views - Transformed & lit if RHW, else untransformed.
|
void d3ddevice_set_ortho(IWineD3DDeviceImpl *This) {
|
||||||
Only unlit if Normals are supplied
|
|
||||||
Returns: Whether to restore lighting afterwards */
|
|
||||||
static BOOL primitiveInitState(IWineD3DDevice *iface, BOOL vtx_transformed, BOOL vtx_lit, BOOL useVS) {
|
|
||||||
|
|
||||||
BOOL isLightingOn = FALSE;
|
|
||||||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
|
||||||
|
|
||||||
/* If no normals, DISABLE lighting otherwise, don't touch lighing as it is
|
|
||||||
set by the appropriate render state. Note Vertex Shader output is already lit */
|
|
||||||
if (vtx_lit || useVS) {
|
|
||||||
isLightingOn = glIsEnabled(GL_LIGHTING);
|
|
||||||
glDisable(GL_LIGHTING);
|
|
||||||
checkGLcall("glDisable(GL_LIGHTING);");
|
|
||||||
TRACE("Disabled lighting as no normals supplied, old state = %d\n", isLightingOn);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!useVS && vtx_transformed) {
|
|
||||||
|
|
||||||
/* If the last draw was transformed as well, no need to reapply all the matrixes */
|
/* If the last draw was transformed as well, no need to reapply all the matrixes */
|
||||||
if ( (!This->last_was_rhw) || (This->viewport_changed) ) {
|
if ( (!This->last_was_rhw) || (This->viewport_changed) ) {
|
||||||
|
|
||||||
|
@ -232,14 +214,34 @@ static BOOL primitiveInitState(IWineD3DDevice *iface, BOOL vtx_transformed, BOOL
|
||||||
|
|
||||||
/* Window Coord 0 is the middle of the first pixel, so translate by half
|
/* Window Coord 0 is the middle of the first pixel, so translate by half
|
||||||
a pixel (See comment above glTranslate below) */
|
a pixel (See comment above glTranslate below) */
|
||||||
glTranslatef(0.5, 0.5, 0);
|
glTranslatef(0.375, 0.375, 0);
|
||||||
checkGLcall("glTranslatef(0.5, 0.5, 0)");
|
checkGLcall("glTranslatef(0.375, 0.375, 0)");
|
||||||
if (This->renderUpsideDown) {
|
if (This->renderUpsideDown) {
|
||||||
glMultMatrixf(invymat);
|
glMultMatrixf(invymat);
|
||||||
checkGLcall("glMultMatrixf(invymat)");
|
checkGLcall("glMultMatrixf(invymat)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/* Setup views - Transformed & lit if RHW, else untransformed.
|
||||||
|
Only unlit if Normals are supplied
|
||||||
|
Returns: Whether to restore lighting afterwards */
|
||||||
|
static BOOL primitiveInitState(IWineD3DDevice *iface, BOOL vtx_transformed, BOOL vtx_lit, BOOL useVS) {
|
||||||
|
|
||||||
|
BOOL isLightingOn = FALSE;
|
||||||
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||||
|
|
||||||
|
/* If no normals, DISABLE lighting otherwise, don't touch lighing as it is
|
||||||
|
set by the appropriate render state. Note Vertex Shader output is already lit */
|
||||||
|
if (vtx_lit || useVS) {
|
||||||
|
isLightingOn = glIsEnabled(GL_LIGHTING);
|
||||||
|
glDisable(GL_LIGHTING);
|
||||||
|
checkGLcall("glDisable(GL_LIGHTING);");
|
||||||
|
TRACE("Disabled lighting as no normals supplied, old state = %d\n", isLightingOn);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!useVS && vtx_transformed) {
|
||||||
|
d3ddevice_set_ortho(This);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* Untransformed, so relies on the view and projection matrices */
|
/* Untransformed, so relies on the view and projection matrices */
|
||||||
|
|
|
@ -780,41 +780,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
|
||||||
/* glDrawPixels transforms the raster position as though it was a vertex -
|
/* glDrawPixels transforms the raster position as though it was a vertex -
|
||||||
we want to draw at screen position 0,0 - Set up ortho (rhw) mode as
|
we want to draw at screen position 0,0 - Set up ortho (rhw) mode as
|
||||||
per drawprim (and leave set - it will sort itself out due to last_was_rhw */
|
per drawprim (and leave set - it will sort itself out due to last_was_rhw */
|
||||||
if ( (!myDevice->last_was_rhw) || (myDevice->viewport_changed) ) {
|
d3ddevice_set_ortho(This->resource.wineD3DDevice);
|
||||||
|
|
||||||
double X, Y, height, width, minZ, maxZ;
|
|
||||||
myDevice->last_was_rhw = TRUE;
|
|
||||||
myDevice->viewport_changed = FALSE;
|
|
||||||
|
|
||||||
/* Transformed already into viewport coordinates, so we do not need transform
|
|
||||||
matrices. Reset all matrices to identity and leave the default matrix in world
|
|
||||||
mode. */
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
checkGLcall("glMatrixMode");
|
|
||||||
glLoadIdentity();
|
|
||||||
checkGLcall("glLoadIdentity");
|
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
checkGLcall("glMatrixMode");
|
|
||||||
glLoadIdentity();
|
|
||||||
checkGLcall("glLoadIdentity");
|
|
||||||
|
|
||||||
/* Set up the viewport to be full viewport */
|
|
||||||
X = myDevice->stateBlock->viewport.X;
|
|
||||||
Y = myDevice->stateBlock->viewport.Y;
|
|
||||||
height = myDevice->stateBlock->viewport.Height;
|
|
||||||
width = myDevice->stateBlock->viewport.Width;
|
|
||||||
minZ = myDevice->stateBlock->viewport.MinZ;
|
|
||||||
maxZ = myDevice->stateBlock->viewport.MaxZ;
|
|
||||||
TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, -minZ, -maxZ);
|
|
||||||
glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ);
|
|
||||||
checkGLcall("glOrtho");
|
|
||||||
|
|
||||||
/* Window Coord 0 is the middle of the first pixel, so translate by half
|
|
||||||
a pixel (See comment above glTranslate below) */
|
|
||||||
glTranslatef(0.5, 0.5, 0);
|
|
||||||
checkGLcall("glTranslatef(0.5, 0.5, 0)");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iface == implSwapChain->backBuffer || iface == myDevice->renderTarget) {
|
if (iface == implSwapChain->backBuffer || iface == myDevice->renderTarget) {
|
||||||
glDrawBuffer(GL_BACK);
|
glDrawBuffer(GL_BACK);
|
||||||
|
@ -2192,40 +2158,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
|
||||||
|
|
||||||
/* Draw a textured quad
|
/* Draw a textured quad
|
||||||
*/
|
*/
|
||||||
if ( TRUE ) {
|
d3ddevice_set_ortho(This->resource.wineD3DDevice);
|
||||||
double X, Y, height, width, minZ, maxZ;
|
|
||||||
myDevice->last_was_rhw = FALSE;
|
|
||||||
myDevice->viewport_changed = FALSE;
|
|
||||||
|
|
||||||
/* Transformed already into viewport coordinates, so we do not need transform
|
|
||||||
matrices. Reset all matrices to identity and leave the default matrix in world
|
|
||||||
mode. */
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
checkGLcall("glMatrixMode");
|
|
||||||
glLoadIdentity();
|
|
||||||
checkGLcall("glLoadIdentity");
|
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
checkGLcall("glMatrixMode");
|
|
||||||
glLoadIdentity();
|
|
||||||
checkGLcall("glLoadIdentity");
|
|
||||||
|
|
||||||
/* Set up the viewport to be full viewport */
|
|
||||||
X = myDevice->stateBlock->viewport.X;
|
|
||||||
Y = myDevice->stateBlock->viewport.Y;
|
|
||||||
height = myDevice->stateBlock->viewport.Height;
|
|
||||||
width = myDevice->stateBlock->viewport.Width;
|
|
||||||
minZ = myDevice->stateBlock->viewport.MinZ;
|
|
||||||
maxZ = myDevice->stateBlock->viewport.MaxZ;
|
|
||||||
TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, -minZ, -maxZ);
|
|
||||||
glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ);
|
|
||||||
checkGLcall("glOrtho");
|
|
||||||
|
|
||||||
/* Window Coord 0 is the middle of the first pixel, so translate by half
|
|
||||||
a pixel (See comment above glTranslate below) */
|
|
||||||
glTranslatef(0.375, 0.375, 0);
|
|
||||||
checkGLcall("glTranslatef(0.375, 0.375, 0)");
|
|
||||||
}
|
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
|
|
|
@ -597,8 +597,7 @@ typedef struct PrivateData
|
||||||
DWORD size;
|
DWORD size;
|
||||||
} PrivateData;
|
} PrivateData;
|
||||||
|
|
||||||
/* OpenGL ortho matrix setup */
|
void d3ddevice_set_ortho(IWineD3DDeviceImpl *This);
|
||||||
void d3ddevice_set_ortho(IWineD3DDeviceImpl *This, BOOL dontclip);
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* IWineD3DResource implementation structure
|
* IWineD3DResource implementation structure
|
||||||
|
|
Loading…
Reference in New Issue