From 82162578224add30ecb15a05c34a8a874a20e5dd Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Sat, 16 Apr 2011 20:35:16 +0200 Subject: [PATCH 1/2] Properly align plates by compensating for the half-pixel offset of Direct3D 9. --HG-- branch : cursors extra : rebase_source : 107d1a43f6e3826dcc21edd326af4cb9b406c5b8 --- .../Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp index 4df7f818..b80710b0 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp @@ -11664,7 +11664,11 @@ void plDXPlateManager::IDrawToDevice( plPipeline *pipe ) fD3DDevice->SetFVF(dxPipe->fSettings.fCurrFVFFormat = PLD3D_PLATEFVF); fD3DDevice->SetStreamSource( 0, fVertBuffer, 0, sizeof( plPlateVertex ) ); plProfile_Inc(VertexChange); - fD3DDevice->SetTransform( D3DTS_VIEW, &d3dIdentityMatrix ); + // To get plates properly pixel-aligned, we need to compensate for D3D9's weird half-pixel + // offset (see http://drilian.com/2008/11/25/understanding-half-pixel-and-half-texel-offsets/ + // or http://msdn.microsoft.com/en-us/library/bb219690(VS.85).aspx). + D3DXMatrixTranslation(&mat, -0.5f/scrnWidthDiv2, -0.5f/scrnHeightDiv2, 0.0f); + fD3DDevice->SetTransform( D3DTS_VIEW, &mat ); oldCullMode = dxPipe->fCurrCullMode; for( plate = fPlates; plate != nil; plate = plate->GetNext() ) From a0fd28cc50d440eb75e51d51e96e534fdd62204d Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Sat, 16 Apr 2011 21:05:23 +0200 Subject: [PATCH 2/2] Display cursors pixel-by-pixel rather than scaling them to 34.56x34.56 pixels. This fixes the blurring caused by scaling up the 32x32 px cursor bitmaps. --HG-- branch : cursors extra : rebase_source : 8b6410754810df4f9fcc33caacf81ee66c579cb2 --- .../Plasma/PubUtilLib/plInputCore/plInputDevice.cpp | 7 ++----- .../Sources/Plasma/PubUtilLib/plPipeline/plPlates.h | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp index bcc02193..a4bc7fc3 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp @@ -39,14 +39,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "../plPipeline/plPlates.h" #include "../plPipeline/plDebugText.h" +#include "../plGImage/plMipmap.h" #include "hsWindows.h" #include "../NucleusLib/inc/plPipeline.h" -// base size of the cursor -#define CURSOR_SIZE_X 0.0675f -#define CURSOR_SIZE_Y 0.09f - // The resolution that uses the base size of the cursor. // All other resolutions will scale the cursor size to keep the same physical size. #define BASE_WIDTH 1024 @@ -454,7 +451,7 @@ void plMouseDevice::IUpdateCursorSize() if(fCursor) { // set the size of the cursor based on resolution. - fCursor->SetSize( CURSOR_SIZE_X * BASE_WIDTH / fWidth, CURSOR_SIZE_Y * BASE_HEIGHT / fHeight ); + fCursor->SetSize( 2*fCursor->GetMipmap()->GetWidth()/fWidth, 2*fCursor->GetMipmap()->GetHeight()/fHeight ); } } diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h index 91d6541a..7c0e8da5 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plPlates.h @@ -110,6 +110,7 @@ class plPlate hsMatrix44 &GetTransform( void ) { return fXformMatrix; } const char *GetTitle( void ) { return fTitle; } UInt32 GetFlags( void ) { return fFlags; } + const plMipmap *GetMipmap( void ) { return fMipmap; } void SetVisible( hsBool vis ) { if( vis ) fFlags |= kFlagVisible; else fFlags &= ~kFlagVisible; } hsBool IsVisible( void );