RMstats.cpp
上传用户:garry_shen
上传日期:2015-04-15
资源大小:45647k
文件大小:8k
- #include "stdafx.h"
- #include "XMudClient.h"
- #include "MainWnd.h"
- extern D3DAppInfo* d3dapp;
- extern rmfullglobals myglobs;
- static struct {
- HFONT hFont;
- SIZE szFrameRate;
- SIZE szInfo;
- } statglobs;
- HFONT g_MessagehFont;
- HFONT g_MessagehFont1;
- HFONT g_MessagehFont2;
- HFONT g_MessagehFont3;
- HFONT g_MessagehFont4;
- BOOL WriteFrameRateBuffer(float fps, long tps)
- {
- HRESULT LastError;
- HDC hdc;
- RECT rc;
- char buf1[30], buf2[30], buf[60];
- int len;
-
- if (!myglobs.lpFrameRateBuffer)
- return TRUE;
- if (fps > 0.0f)
- wsprintf(buf1, "%d.%02d fps ",
- (int)( fps * 100 ) / 100,
- (int)( fps * 100 ) % 100);
- else
- buf1[0] = 0;
- if (tps > 0)
- wsprintf(buf2, "%ld tps ", tps);
- else
- buf2[0] = 0;
- len = wsprintf(buf, "%s%s", buf1, buf2);
- if (!myglobs.lpFrameRateBuffer)
- return FALSE;
- LastError = myglobs.lpFrameRateBuffer->GetDC(&hdc);
- if (LastError != DD_OK)
- {
- return TRUE;
- }
- SelectObject(hdc, statglobs.hFont);
- SetTextColor(hdc, RGB(255,255,0));
- SetBkColor(hdc, RGB(0,0,0));
- SetBkMode(hdc, OPAQUE);
- GetTextExtentPoint32(hdc, buf, len, &statglobs.szFrameRate);
- SetRect(&rc, 0, 0, statglobs.szFrameRate.cx, statglobs.szFrameRate.cy);
- ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, buf, len, NULL);
- myglobs.lpFrameRateBuffer->ReleaseDC(hdc);
- return TRUE;
- }
- BOOL WriteInfoBuffer(void)
- {
- HRESULT LastError;
- HDC hdc;
- RECT rc;
- char buf[40];
- int len;
-
- if (!myglobs.lpInfoBuffer)
- return TRUE;
- if (d3dapp->bFullscreen)
- len = wsprintf(buf, "%dx%dx%d (%s)", d3dapp->ThisMode.w, d3dapp->ThisMode.h, d3dapp->ThisMode.bpp,
- (d3dapp->ThisDriver.Desc.dcmColorModel == D3DCOLOR_MONO) ? "MONO" : "RGB");
- else
- len = wsprintf(buf, "%dx%d (%s)", d3dapp->szClient.cx, d3dapp->szClient.cy,
- (d3dapp->ThisDriver.Desc.dcmColorModel == D3DCOLOR_MONO) ? "MONO" : "RGB");
- if (!myglobs.lpInfoBuffer)
- return FALSE;
- LastError = myglobs.lpInfoBuffer->GetDC(&hdc);
- if (LastError != DD_OK) {
- //
- // This is not vital, don't report an error.
- //
- return TRUE;
- }
-
- SelectObject(hdc, statglobs.hFont);
- SetTextColor(hdc, RGB(255,255,0));
- SetBkColor(hdc, RGB(0,0,0));
- SetBkMode(hdc, OPAQUE);
- GetTextExtentPoint32(hdc, buf, len, &statglobs.szInfo);
- SetRect(&rc, 0, 0, statglobs.szInfo.cx, statglobs.szInfo.cy);
- ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, buf, len, NULL);
- myglobs.lpInfoBuffer->ReleaseDC(hdc);
- return TRUE;
- }
- BOOL InitFontAndTextBuffers(void)
- {
- DDCOLORKEY ddck;
- DDSURFACEDESC ddsd;
- HDC hdc;
- HRESULT ddrval;
- char dummyinfo[] = "000x000x00 (MONO) 0000";
- char dummyfps[] = "000.00 fps 00000000.00 tps 0000.00 mppps";
- RELEASE(myglobs.lpInfoBuffer);
- RELEASE(myglobs.lpFrameRateBuffer);
- if (statglobs.hFont != NULL) {
- DeleteObject(statglobs.hFont);
- }
- statglobs.hFont = CreateFont(
- -12,
- 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
- CHINESEBIG5_CHARSET,
- OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,
- DEFAULT_QUALITY,
- VARIABLE_PITCH,
- "穝灿