void CLrcMask::DrawBkMask() { HDC hTempDc = GetDC(m_hWnd); HDC hMenDc = CreateCompatibleDC(hTempDc); DuiLib::CDuiRect rc; GetClientRect(&rc); HBITMAP hbmp; BITMAPINFO bitmapinfo; bitmapinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bitmapinfo.bmiHeader.biBitCount = 32; bitmapinfo.bmiHeader.biHeight = rc.GetHeight(); bitmapinfo.bmiHeader.biWidth = rc.GetWidth(); bitmapinfo.bmiHeader.biPlanes = 1; bitmapinfo.bmiHeader.biCompression=BI_RGB; bitmapinfo.bmiHeader.biXPelsPerMeter=0; bitmapinfo.bmiHeader.biYPelsPerMeter=0; bitmapinfo.bmiHeader.biClrUsed=0; bitmapinfo.bmiHeader.biClrImportant=0; bitmapinfo.bmiHeader.biSizeImage = bitmapinfo.bmiHeader.biWidth * bitmapinfo.bmiHeader.biHeight * bitmapinfo.bmiHeader.biBitCount / 8; hbmp = CreateDIBSection(hMenDc,&bitmapinfo,0,NULL,0,0); SelectBitmap(hMenDc,hbmp); Graphics graphics(hMenDc); graphics.SetSmoothingMode(SmoothingModeAntiAlias); graphics.SetInterpolationMode(InterpolationModeHighQualityBicubic); SolidBrush brush(Color(50,200,200,200)); Pen pen1(Color(155,223,223,223)); Pen pen2(Color(55,223,223,223)); LPRECT lpRect = &rc; RectF rect((Gdiplus::REAL)lpRect->left,(Gdiplus::REAL)lpRect->top,(Gdiplus::REAL)(lpRect->right-lpRect->left),(Gdiplus::REAL)(lpRect->bottom-lpRect->top)); graphics.FillRectangle(&brush,rect); graphics.DrawRectangle(&pen1,rect.GetLeft()+2,rect.GetTop()+2,rect.Width - 4,rect.Height -4); graphics.DrawRectangle(&pen2,rect.GetLeft()+1,rect.GetTop()+1,rect.Width - 2,rect.Height -2); DuiLib::CDuiRect rtWnd; GetWindowRect(&rtWnd); DuiLib::CPoint dstPt(0,0); DuiLib::CPoint winPt(rtWnd.left,rtWnd.top); DuiLib::CSize size(rc.GetWidth(),rc.GetHeight()); BLENDFUNCTION blend = {AC_SRC_OVER,0,255,AC_SRC_ALPHA}; BOOL bret = ::UpdateLayeredWindow(m_hWnd,hTempDc,&winPt,&size,hMenDc,&dstPt,0,&blend,ULW_ALPHA); DeleteDC(hMenDc); ReleaseDC(m_hWnd,hTempDc); // assert(bret); }
CPoint CGraphicsCamera::GetScreenPtFrom3DPoint( const CPoint3D& modelSpacePt ) { GLint viewport[4]; GLdouble mvMatrix[16], projMatrix[16]; double winX = 0.0; double winY = 0.0; double winZ = 0.0; //depth value between 0 and 1 - for depth sorting CPoint winPt( 0, 0 ); HGLRC currentRC = wglGetCurrentContext(); if( currentRC || wglMakeCurrent( m_hDC, m_hGLRC ) ) { glGetIntegerv( GL_VIEWPORT, viewport ); glGetDoublev( GL_MODELVIEW_MATRIX, mvMatrix ); glGetDoublev( GL_PROJECTION_MATRIX, projMatrix ); if( mvMatrix[0] + mvMatrix[1] + mvMatrix[2] + mvMatrix[4] + mvMatrix[5] + mvMatrix[6] + mvMatrix[8] + mvMatrix[9] + mvMatrix[10] <= 1.0 ) { ASSERT(FALSE); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glGetDoublev(GL_MODELVIEW_MATRIX, mvMatrix); return winPt; } gluProject( modelSpacePt.x, modelSpacePt.y, modelSpacePt.z, mvMatrix, projMatrix, viewport, &winX, &winY, &winZ ); } //openGL convention (origin at lower left) winPt = CPoint( int(winX), int(winY) ); //windows convention (origin at upper left) CRect wndRect; ::GetClientRect( m_hWnd, wndRect ); winPt.y = wndRect.Height() - winPt.y; //TRACE("screen Y = %i\n", winPt.y ); return winPt; }