diff options
author | nrootconauto <nrootconauto@gmail.com> | 2022-11-24 13:50:35 -0500 |
---|---|---|
committer | nrootconauto <nrootconauto@gmail.com> | 2022-11-24 13:50:35 -0500 |
commit | d00b79456d82c909e29f1e81f4efd0dfcee8023a (patch) | |
tree | 2829ce4b61d46cb96c793ac15499e1b775cac9b3 | |
parent | 4aae1dcd1df4ebce15074fdd4853b25272e66219 (diff) |
Updated HCRT_BC.BIN.v0.5.00
WIN_window.cpp now doesnt re-create target each frame.
Signed-off-by: nrootconauto <nrootconauto@gmail.com>
-rw-r--r-- | HCRT_BC.BIN | bin | 3244560 -> 3210256 bytes | |||
-rw-r--r-- | T/HCRT_BC.DBG.Z | bin | 271524 -> 270362 bytes | |||
-rw-r--r-- | WIN_window.cpp | 32 |
3 files changed, 18 insertions, 14 deletions
diff --git a/HCRT_BC.BIN b/HCRT_BC.BIN Binary files differindex ae3c74b..a083266 100644 --- a/HCRT_BC.BIN +++ b/HCRT_BC.BIN diff --git a/T/HCRT_BC.DBG.Z b/T/HCRT_BC.DBG.Z Binary files differindex d7234b9..dbd6d35 100644 --- a/T/HCRT_BC.DBG.Z +++ b/T/HCRT_BC.DBG.Z diff --git a/WIN_window.cpp b/WIN_window.cpp index c434bae..328dc5c 100644 --- a/WIN_window.cpp +++ b/WIN_window.cpp @@ -30,6 +30,7 @@ typedef struct CDrawWindow { char *texture_address; double dpi; ID2D1Factory *factory; + ID2D1HwndRenderTarget *target; _3DaysRenderer renderer_type; } CDrawWindow; static void StartInputScanner(); @@ -45,6 +46,17 @@ int32_t buf[640*480]; int64_t __3DaysSwapRGB() { return 0; } +static void SetWindowSz(int64_t x,int64_t y) { + if(!dw) return; + if(dw->target) + dw->target->Release(); + D2D1_SIZE_U size=SizeU(dw->sz_x=x,dw->sz_y=y); + dw->factory->CreateHwndRenderTarget( + RenderTargetProperties(), + HwndRenderTargetProperties(dw->win,size), + &dw->target + ); +} void __3DaysEnableScaling(int64_t s) { dw->scaling_enabled=s; } @@ -552,8 +564,8 @@ LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) { if(dw->renderer_type==_3D_REND_WIN32_GDI_SCALE) { WaitForSingleObject(mutex,INFINITE); GetClientRect(hwnd,&rct); - dw->sz_x=rct.right-rct.left; - dw->sz_y=rct.bottom-rct.top; + if(dw->sz_x!=rct.right-rct.left||dw->sz_y!=rct.bottom-rct.top) + SetWindowSz(rct.right-rct.left,rct.bottom-rct.top); float sx,sy,ox,oy,rx,ry; if(dw->scaling_enabled) { sx=dw->sz_y/480.*640.,sy=dw->sz_y; @@ -576,27 +588,19 @@ LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) { dw->gl_top=-sy; dw->gl_bottom=sy; int64_t x,y,b,b2,mul=4; - ID2D1HwndRenderTarget *target=NULL; ID2D1Bitmap *bmp; - D2D1_SIZE_U size=SizeU(dw->sz_x,dw->sz_y); - dw->factory->CreateHwndRenderTarget( - RenderTargetProperties(), - HwndRenderTargetProperties(hwnd,size), - &target - ); - target->BeginDraw(); + dw->target->BeginDraw(); D2D1_SIZE_U holyres=SizeU(640,480); D2D1_BITMAP_PROPERTIES prop; prop.pixelFormat=PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM,D2D1_ALPHA_MODE_IGNORE); prop.dpiX=96; prop.dpiY=96; - target->CreateBitmap(holyres,prop,&bmp); + dw->target->CreateBitmap(holyres,prop,&bmp); bmp->CopyFromMemory(NULL,dw->texture_address,640*4); D2D1_RECT_F dst_rct=RectF((dw->sz_x-rx)/2,(dw->sz_y-ry)/2,(dw->sz_x-rx)/2+rx,(dw->sz_y-ry)/2+ry); - target->DrawBitmap(bmp,&dst_rct,1.0,D2D1_BITMAP_INTERPOLATION_MODE_LINEAR,NULL); - target->EndDraw(); + dw->target->DrawBitmap(bmp,&dst_rct,1.0,D2D1_BITMAP_INTERPOLATION_MODE_LINEAR,NULL); + dw->target->EndDraw(); bmp->Release(); - target->Release(); ReleaseMutex(mutex); } |