2015-01-24 11:40:16 -05:00
|
|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
|
#define INITGUID
|
|
|
|
//#define FULLHEXDUMP
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <ddraw.h>
|
|
|
|
#include "dxwnd.h"
|
|
|
|
#include "dxhook.h"
|
|
|
|
#include "ddrawi.h"
|
|
|
|
#include "dxwcore.hpp"
|
|
|
|
#include "stdio.h"
|
|
|
|
#include "hddraw.h"
|
|
|
|
#include "dxhelper.h"
|
|
|
|
#include "syslibs.h"
|
|
|
|
|
2016-06-04 12:45:32 -04:00
|
|
|
extern GetDC_Type pGetDCMethod();
|
|
|
|
extern ReleaseDC_Type pReleaseDCMethod();
|
2016-01-05 11:45:50 -05:00
|
|
|
extern Unlock1_Type pUnlockMethod(int);
|
2015-01-24 11:40:16 -05:00
|
|
|
|
|
|
|
void BlitToWindow(HWND w, LPDIRECTDRAWSURFACE s)
|
|
|
|
{
|
|
|
|
HDC shdc, thdc;
|
|
|
|
RECT client;
|
|
|
|
HRESULT res;
|
|
|
|
BOOL ret;
|
|
|
|
|
2015-11-02 11:40:21 -05:00
|
|
|
if(!s) return; // for surface color fill
|
2016-06-04 12:45:32 -04:00
|
|
|
res=(*pGetDCMethod())(s, &shdc);
|
2015-03-09 12:41:22 -04:00
|
|
|
if(res) {
|
|
|
|
OutTrace("ddraw GetDC error lpdds=%x res=%x(%s)\n", s, res, ExplainDDError(res));
|
|
|
|
return;
|
|
|
|
}
|
2015-01-24 11:40:16 -05:00
|
|
|
thdc=(*pGDIGetDC)(w);
|
2015-03-09 12:41:22 -04:00
|
|
|
if(!thdc) {
|
|
|
|
OutTrace("GDI GetDC error=%d\n", GetLastError());
|
|
|
|
return;
|
|
|
|
}
|
2015-04-26 12:40:41 -04:00
|
|
|
client = dxw.MapClientRect(NULL);
|
2015-01-24 11:40:16 -05:00
|
|
|
if(dxw.dwFlags5 & CENTERTOWIN){
|
|
|
|
int x, y;
|
2015-04-26 12:40:41 -04:00
|
|
|
x = (client.left + client.right - dxw.GetScreenWidth()) >> 1; // right-shift 1 bit means divide by 2!
|
|
|
|
y = (client.top + client.bottom - dxw.GetScreenHeight()) >> 1;
|
2015-01-24 11:40:16 -05:00
|
|
|
ret=(*pGDIBitBlt)(thdc, x, y, dxw.GetScreenWidth(), dxw.GetScreenHeight(), shdc, 0, 0, SRCCOPY);
|
|
|
|
if(!ret) OutTrace("BitBlt error=%d\n", GetLastError());
|
|
|
|
}
|
|
|
|
else{
|
2015-01-31 11:40:19 -05:00
|
|
|
if(dxw.dwFlags5 & BILINEARFILTER) {
|
|
|
|
ret=SetStretchBltMode(thdc, HALFTONE);
|
|
|
|
if((!ret) || (ret==ERROR_INVALID_PARAMETER)) OutTrace("GDI SetStretchBltMode error=%d\n", GetLastError());
|
|
|
|
}
|
2015-04-26 12:40:41 -04:00
|
|
|
ret=(*pGDIStretchBlt)(thdc,
|
|
|
|
client.left, client.top, client.right-client.left, client.bottom-client.top,
|
|
|
|
shdc, 0, 0, dxw.GetScreenWidth(), dxw.GetScreenHeight(), SRCCOPY);
|
2015-01-24 11:40:16 -05:00
|
|
|
if(!ret) OutTrace("GDI StretchBlt error=%d\n", GetLastError());
|
|
|
|
}
|
|
|
|
dxw.ShowOverlay(thdc);
|
2016-06-04 12:45:32 -04:00
|
|
|
res=(*pReleaseDCMethod())(s, shdc);
|
2015-01-24 11:40:16 -05:00
|
|
|
if(res) OutTrace("ddraw ReleaseDC error lpdds=%x res=%x(%s)\n", s, res, ExplainDDError(res));
|
|
|
|
ret=(*pGDIReleaseDC)(w, thdc);
|
|
|
|
if(!ret) OutTrace("GDI ReleaseDC error=%d\n", GetLastError());
|
2016-06-04 12:45:32 -04:00
|
|
|
}
|