void RenderMessagePicture(CDrawPort *pdp) { CCompMessage &cm = _acmMessages[_iActiveMessage]; // try to try { // load image _toPicture.SetData_t(cm.cm_fnmPicture); ((CTextureData*)_toPicture.GetData())->Force(TEX_CONSTANT); // if failed } catch(char *strError) { // report error CPrintF("Cannot load '%s':\n%s\n", (CTString&)cm.cm_fnmPicture, strError); // do nothing return; } // get image and box sizes PIX pixImgSizeI = _toPicture.GetWidth(); PIX pixImgSizeJ = _toPicture.GetHeight(); PIXaabbox2D boxPic(PIX2D(_pixMarginI, _pixMarginJ), PIX2D(_boxMsgImage.Size()(1)-_pixMarginI, _boxMsgImage.Size()(2)-_pixMarginJ)); PIX pixBoxSizeI = boxPic.Size()(1); PIX pixBoxSizeJ = boxPic.Size()(2); PIX pixCenterI = _boxMsgImage.Size()(1)/2; PIX pixCenterJ = _boxMsgImage.Size()(2)/2; // find image stretch to fit in box FLOAT fStretch = Min(FLOAT(pixBoxSizeI)/pixImgSizeI, FLOAT(pixBoxSizeJ)/pixImgSizeJ); // draw the image pdp->PutTexture(&_toPicture, PIXaabbox2D( PIX2D(pixCenterI-pixImgSizeI*fStretch/2, pixCenterJ-pixImgSizeJ*fStretch/2), PIX2D(pixCenterI+pixImgSizeI*fStretch/2, pixCenterJ+pixImgSizeJ*fStretch/2))); }
extern void LCDSetDrawport(CDrawPort *pdp) { _pdp = pdp; _pixSizeI = _pdp->GetWidth(); _pixSizeJ = _pdp->GetHeight(); _boxScreen = PIXaabbox2D ( PIX2D(0,0), PIX2D(_pixSizeI, _pixSizeJ)); }
PIXaabbox2D CWndTerrainTilePalette::GetTileBBox( INDEX iTile) { PIXaabbox2D boxScr=PIXaabbox2D( PIX2D( (iTile%m_ctPaletteTilesH)*PIX_TILE_WIDTH+1, (iTile/m_ctPaletteTilesH)*PIX_TILE_HEIGHT+1), PIX2D( (iTile%m_ctPaletteTilesH+1)*PIX_TILE_WIDTH+1, (iTile/m_ctPaletteTilesH+1)*PIX_TILE_HEIGHT+1) ); // return calculated box return boxScr; }
static PIXaabbox2D GetMsgListBox(INDEX i) { PIX pixI0 = _boxMsgList.Min()(1)+_pixMarginI; PIX pixI1 = _boxMsgList.Max()(1)-_pixMarginI*3; PIX pixJ0 = _boxMsgList.Min()(2)+_pixMarginJ; PIX pixDJ = _pixCharSizeJ; return PIXaabbox2D( PIX2D(pixI0, pixJ0+pixDJ*i), PIX2D(pixI1, pixJ0+pixDJ*(i+1)-1)); }
static PIXaabbox2D GetSliderBox(INDEX iFirst, INDEX iVisible, INDEX iTotal, PIXaabbox2D boxFull) { FLOAT fSize = ClampUp(FLOAT(iVisible)/iTotal, 1.0f); PIX pixFull = boxFull.Size()(2); PIX pixSize = PIX(pixFull*fSize); pixSize = ClampDn(pixSize, boxFull.Size()(1)); PIX pixTop = pixFull*(FLOAT(iFirst)/iTotal)+boxFull.Min()(2); PIX pixI0 = boxFull.Min()(1); PIX pixI1 = boxFull.Max()(1); return PIXaabbox2D(PIX2D(pixI0, pixTop), PIX2D(pixI1, pixTop+pixSize)); }
static PIXaabbox2D GetMsgSliderSpace(void) { PIX pixSizeI = _boxMsgList.Size()(1); PIX pixSizeJ = _boxMsgList.Size()(2); PIX pixSliderSizeI = _pixMarginI*2; if (pixSliderSizeI<5) { pixSliderSizeI=5; } return PIXaabbox2D( PIX2D(pixSizeI-pixSliderSizeI, 0), PIX2D(pixSizeI, pixSizeJ)); }
PIXaabbox2D CBrushPaletteWnd::GetBrushBBox( INDEX iBrush) { CRect rectClient; // get window's client area GetClientRect( &rectClient); PIX DX = (rectClient.Width()+1 - 2*CLIENT_BORDER)/BRUSHES_PER_X; PIX DY = (rectClient.Height()+1 - 2*CLIENT_BORDER)/BRUSHES_PER_Y; // calculate starting pixel for current Brush PIX pixXS = CLIENT_BORDER + (iBrush%BRUSHES_PER_X)*DX; PIX pixYS = CLIENT_BORDER + (iBrush/BRUSHES_PER_X)*DY; // return calculated box return PIXaabbox2D( PIX2D(pixXS, pixYS), PIX2D(pixXS+DX-1, pixYS+DY-1) ); }
static void PaintScreen() { if(_pdpDrawPort==NULL) { return; } _pdpDrawPort->SetAsCurrent(); // clear browsing window _pdpDrawPort->FillZBuffer( ZBUF_BACK); _pdpDrawPort->Fill( C_GRAY | CT_OPAQUE); if(_pfdCurrentFont!=NULL && _pfdCurrentFont->fd_ptdTextureData!=NULL && _ptdGrid!=NULL) { PIX pixWidth = _pfdCurrentFont->fd_ptdTextureData->GetPixWidth(); PIX pixHeight = _pfdCurrentFont->fd_ptdTextureData->GetPixHeight(); PIXaabbox2D rectPict; rectPict = PIXaabbox2D( PIX2D(0, 0), PIX2D(pixWidth, pixHeight)); if(_bShowTexture) { // Show texture _toPreview.SetData(_pfdCurrentFont->fd_ptdTextureData); _pdpDrawPort->PutTexture(&_toPreview,rectPict); // if grid must be shown if(_bShowGrid) { // Show character grid _toPreview.SetData(_ptdGrid); _pdpDrawPort->PutTexture(&_toPreview,rectPict); } // Show texture grid _pdpDrawPort->DrawLine(0,0,pixWidth,0,0xFFFF00FF); _pdpDrawPort->DrawLine(0,0,0,pixHeight,0xFFFF00FF); _pdpDrawPort->DrawLine(0,pixHeight,pixWidth,pixHeight,0xFFFF00FF); _pdpDrawPort->DrawLine(pixWidth,0,pixWidth,pixHeight,0xFFFF00FF); _toPreview.SetData(NULL); } else { char strSampleText[2048]; GetDlgItemText(_hWnd,IEC_SAMPLE_TEXT,strSampleText,2047); _pdpDrawPort->SetFont( _pfdCurrentFont); _pdpDrawPort->PutText( strSampleText, 0, 0, 0xFFFFFFFF); } } if(_pvpViewPort!=NULL) { // swap it _pvpViewPort->SwapBuffers(); } }
void CBrushPaletteWnd::OnLButtonUp(UINT nFlags, CPoint point) { PIXaabbox2D boxPoint( PIX2D( point.x, point.y), PIX2D(point.x, point.y) ); // for all brushes for( INDEX iBrush=0; iBrush<CT_BRUSHES; iBrush++) { if( (GetBrushBBox( iBrush) & boxPoint) == boxPoint) { theApp.m_fCurrentTerrainBrush=iBrush; break; } } // destroy brush palette _pBrushPalette = NULL; delete this; theApp.m_ctTerrainPageCanvas.MarkChanged(); }
void CBrushPaletteWnd::OnRButtonDown(UINT nFlags, CPoint point) { PIXaabbox2D boxPoint( PIX2D( point.x, point.y), PIX2D(point.x, point.y) ); // for all brushes for( INDEX iBrush=0; iBrush<CT_BRUSHES; iBrush++) { if( (GetBrushBBox( iBrush) & boxPoint) == boxPoint) { // destroy brush palette _pBrushPalette = NULL; delete this; // invoke edit terrain dlg CDlgEditTerrainBrush dlg; dlg.m_iBrush=iBrush; dlg.DoModal(); break; } } }
void CMGTrigger::Render(CDrawPort *pdp) { SetFontMedium(pdp); PIXaabbox2D box = FloatBoxToPixBox(pdp, mg_boxOnScreen); PIX pixIL = box.Min()(1) + box.Size()(1)*0.45f; PIX pixIR = box.Min()(1) + box.Size()(1)*0.55f; PIX pixJ = box.Min()(2); COLOR col = GetCurrentColor(); if (!mg_bVisual || mg_strValue == "") { CTString strValue = mg_strValue; if (mg_bVisual) { strValue = TRANS("none"); } if (mg_iCenterI == -1) { pdp->PutText(mg_strLabel, box.Min()(1), pixJ, col); pdp->PutTextR(strValue, box.Max()(1), pixJ, col); } else { pdp->PutTextR(mg_strLabel, pixIL, pixJ, col); pdp->PutText(strValue, pixIR, pixJ, col); } } else { CTString strLabel = mg_strLabel + ": "; pdp->PutText(strLabel, box.Min()(1), pixJ, col); CTextureObject to; try { to.SetData_t(mg_strValue); CTextureData *ptd = (CTextureData *)to.GetData(); PIX pixSize = box.Size()(2); PIX pixCX = box.Max()(1) - pixSize / 2; PIX pixCY = box.Center()(2); pdp->PutTexture(&to, PIXaabbox2D( PIX2D(pixCX - pixSize / 2, pixCY - pixSize / 2), PIX2D(pixCX - pixSize / 2 + pixSize, pixCY - pixSize / 2 + pixSize)), C_WHITE | 255); } catch (char *strError) { CPrintF("%s\n", strError); } to.SetData(NULL); } }
void CWndTerrainTilePalette::OnLButtonUp(UINT nFlags, CPoint point) { PIXaabbox2D boxPoint( PIX2D( point.x, point.y), PIX2D(point.x, point.y) ); // for all tiles for( INDEX iTile=0; iTile<m_dcTileInfo.Count(); iTile++) { if( (GetTileBBox(iTile) & boxPoint) == boxPoint) { CTerrainLayer *ptlLayer=GetLayer(); if(ptlLayer==NULL) return; if( ptlLayer->tl_ltType==LT_TILE) { ASSERTALWAYS("Undone"); // ptlLayer->tl_iSelectedTile=iTile; } break; } } DestroyWindow(); DeleteTempMap(); }
void CDlgCreateSpecularTexture::DrawPreview( CDrawPort *pdp, FLOAT fExp) { BOOL bErrorOcured = FALSE; if( (m_moModel.GetData() == NULL) || (m_moModel.mo_toTexture.GetData() == NULL) || (m_moModel.mo_toSpecular.GetData() == NULL) ) // obtain components for rendering try { DECLARE_CTFILENAME( fnBCGTexture, "Models\\Editor\\SpecularPreviewBCG.tex"); m_toBackground.SetData_t( fnBCGTexture); DECLARE_CTFILENAME( fnTeapotModel, "Models\\Editor\\Teapot.mdl"); DECLARE_CTFILENAME( fnTeapotTexture, "Models\\Editor\\Teapot.tex"); m_moModel.SetData_t( fnTeapotModel); m_moModel.mo_toTexture.SetData_t( fnTeapotTexture); m_moModel.mo_toSpecular.SetData_t( CTString("temp\\SpecularTemp.tex")); } catch( char *strError) { (void) strError; bErrorOcured = TRUE; } if( !bErrorOcured) { ((CModelData*)m_moModel.GetData())->md_colSpecular = m_colorSpecular.GetColor(); PIXaabbox2D screenBox = PIXaabbox2D( PIX2D(0,0), PIX2D(pdp->GetWidth(), pdp->GetHeight()) ); //pdp->PutTexture( &m_moModel.mo_toSpecular, screenBox); //return; pdp->PutTexture( &m_toBackground, screenBox); pdp->FillZBuffer( ZBUF_BACK); CRenderModel rmRenderModel; CPerspectiveProjection3D prPerspectiveProjection; a3dObjectAngles += a3dObjectRotation; a3dLightAngles += a3dLightRotation; m_plPlacement.pl_OrientationAngle = a3dObjectAngles; AnglesToDirectionVector( a3dLightAngles, rmRenderModel.rm_vLightDirection); prPerspectiveProjection.FOVL() = AngleDeg(50.0f); prPerspectiveProjection.ScreenBBoxL() = FLOATaabbox2D( FLOAT2D(0.0f,0.0f),FLOAT2D((float)pdp->GetWidth(), (float)pdp->GetHeight())); prPerspectiveProjection.AspectRatioL() = 1.0f; prPerspectiveProjection.FrontClipDistanceL() = 0.05f; prPerspectiveProjection.ViewerPlacementL().pl_PositionVector = FLOAT3D(0.0f,0.0f,0.0f); prPerspectiveProjection.ViewerPlacementL().pl_OrientationAngle = ANGLE3D( 0, -20, 0); prPerspectiveProjection.Prepare(); CAnyProjection3D apr; apr = prPerspectiveProjection; BeginModelRenderingView(apr, pdp); _mrpModelRenderPrefs.SetRenderType( RT_TEXTURE|RT_SHADING_PHONG); m_plPlacement.pl_PositionVector = FLOAT3D( 0.0f, -0.19f, -0.35f); rmRenderModel.SetObjectPlacement(m_plPlacement); rmRenderModel.rm_colLight = m_colorLight.GetColor(); rmRenderModel.rm_colAmbient = m_colorAmbient.GetColor(); m_moModel.SetupModelRendering(rmRenderModel); m_moModel.RenderModel(rmRenderModel); EndModelRenderingView(); } /* pdp->Fill(C_GREEN|CT_OPAQUE); PIX pixSizeI = pdp->GetWidth(); PIX pixSizeJ = pdp->GetHeight(); for (PIX pixI=0; pixI<pixSizeI; pixI++) { for (PIX pixJ=0; pixJ<pixSizeJ; pixJ++) { FLOAT fX = pixI*2.0f/pixSizeI-1; FLOAT fY = pixJ*2.0f/pixSizeJ-1; FLOAT fZ; FLOAT fZ2 = 1-fX*fX-fY*fY; if (fZ2<0) { fZ = 0; } else { fZ = Sqrt(fZ2); } FLOAT fZN = FLOAT(pow(fZ, fExp)); ASSERT(fZN>=0 && fZN<=1); UBYTE ub = UBYTE(fZN*255); pdp->Fill(pixI, pixJ, 1,1, RGBToColor(ub,ub,ub)|CT_OPAQUE); } } */ }
// update screen geometry static void UpdateSize(CDrawPort *pdp) { // get screen size PIX pixSizeI = pdp->GetWidth(); PIX pixSizeJ = pdp->GetHeight(); // remember new size _pixSizeI = pixSizeI; _pixSizeJ = pixSizeJ; // determine scaling _fScaling = 1.0f; _fScaling2 = 1.0f; if (pixSizeJ<384) { _fScaling = 1.0f; _fScaling2 = pixSizeJ/480.0f; } // remember font size CFontData *pfd = _pfdConsoleFont; _pixCharSizeI = pfd->fd_pixCharWidth + pfd->fd_pixCharSpacing; _pixCharSizeJ = pfd->fd_pixCharHeight + pfd->fd_pixLineSpacing; _pixCharSize2I = _pixCharSizeI*_fScaling2; _pixCharSize2J = _pixCharSizeJ*_fScaling2; _pixCharSizeI = _pixCharSizeI*_fScaling; _pixCharSizeJ = _pixCharSizeJ*_fScaling; _pixMarginI = 5*_fScaling2; _pixMarginJ = 5*_fScaling2; PIX pixBoxMarginI = 10*_fScaling2; PIX pixBoxMarginJ = 10*_fScaling2; PIX pixJ0Dn = pixBoxMarginJ; PIX pixJ1Up = pixJ0Dn+_pixCharSize2J+_pixMarginI*2; PIX pixJ1Dn = pixJ1Up+pixBoxMarginJ; PIX pixJ2Up = pixJ1Dn+_pixCharSize2J*6*2+pixBoxMarginJ; PIX pixJ2Dn = pixJ2Up+pixBoxMarginJ; PIX pixJ3Up = _pixSizeJ-pixBoxMarginJ; PIX pixI0Rt = pixBoxMarginI; PIX pixI1Lt = pixI0Rt+_pixCharSize2I*20+pixBoxMarginI; PIX pixI1Rt = pixI1Lt+pixBoxMarginI; PIX pixI2Lt = _pixSizeI/2-pixBoxMarginI/2; PIX pixI2Rt = _pixSizeI/2+pixBoxMarginI/2; PIX pixI4Lt = _pixSizeI-pixBoxMarginI; PIX pixI3Rt = pixI4Lt-pixBoxMarginI*2-_pixCharSize2I*10; PIX pixI3Lt = pixI3Rt-pixBoxMarginI; // calculate box sizes _boxTitle = PIXaabbox2D( PIX2D(0, pixJ0Dn-1), PIX2D(pixI3Lt, pixJ1Up)); _boxExit = PIXaabbox2D( PIX2D( pixI3Rt, pixJ0Dn-1), PIX2D(_pixSizeI, pixJ1Up)); PIX pixD = 5; PIX pixH = (pixJ2Up-pixJ1Dn-pixD*(CMT_COUNT-1))/CMT_COUNT; INDEX i; for( i=0; i<CMT_COUNT; i++) { _boxButton[i] = PIXaabbox2D( PIX2D(0, pixJ1Dn+(pixH+pixD)*i), PIX2D(pixI1Lt, pixJ1Dn+(pixH+pixD)*i+pixH)); } _boxMsgList = PIXaabbox2D( PIX2D(pixI1Rt, pixJ1Dn), PIX2D(pixI4Lt, pixJ2Up)); if (GetSP()->sp_bCooperative) { _boxMsgText = PIXaabbox2D( PIX2D(pixI2Rt, pixJ2Dn), PIX2D(pixI4Lt, pixJ3Up)); _boxMsgImage= PIXaabbox2D( PIX2D(pixI0Rt, pixJ2Dn), PIX2D(pixI2Lt, pixJ3Up)); } else { _boxMsgText = PIXaabbox2D( PIX2D(pixI0Rt, pixJ2Dn), PIX2D(pixI4Lt, pixJ3Up)); _boxMsgImage= PIXaabbox2D(); } FLOAT fSlideSpeed = Max(_pixSizeI, _pixSizeJ*2L); FLOAT fGroup0 = ClampDn((1-fComputerFadeValue)*fSlideSpeed-_pixSizeJ, 0.0f); FLOAT fGroup1 = (1-fComputerFadeValue)*fSlideSpeed; // animate box positions _boxTitle -= PIX2D( fGroup1, 0); _boxExit += PIX2D( fGroup1, 0); for( i=0; i<CMT_COUNT; i++) { FLOAT fOffs = ClampDn(fGroup1-(CMT_COUNT-i)*_pixMarginJ*10, 0.0f); _boxButton[i] -= PIX2D(fOffs, 0); } _boxMsgList -= PIX2D(0, fGroup0); _boxMsgText += PIX2D(fGroup0, 0); _boxMsgImage+= PIX2D(0, fGroup0); _ctMessagesOnScreen = (_boxMsgList.Size()(2) - _pixMarginJ*2) / _pixCharSizeJ; _ctTextCharsPerRow = (_boxMsgText.Size()(1) - _pixMarginI*4) / _pixCharSizeI; _ctTextLinesOnScreen = (_boxMsgText.Size()(2) - _pixMarginJ*2 - _pixMarginJ*4) / _pixCharSizeJ; }
void CWndDisplayTexture::OnPaint() { { CPaintDC dc(this); } // device context for painting if( m_iTimerID==-1) m_iTimerID = (int)SetTimer( 1, 50, NULL); if( m_pViewPort==NULL && m_pDrawPort==NULL) { // initialize canvas for active texture button _pGfx->CreateWindowCanvas( m_hWnd, &m_pViewPort, &m_pDrawPort); } // get texture data CTextureData *pTD = (CTextureData*)m_toTexture.GetData(); BOOL bAlphaChannel = FALSE; // if there is a valid drawport, and the drawport can be locked if( m_pDrawPort!=NULL && m_pDrawPort->Lock()) { // if it has any texture if( pTD!=NULL) { PIX pixWidth = pTD->GetPixWidth(); PIX pixHeight = pTD->GetPixHeight(); // adjust for effect texture if( pTD->td_ptegEffect != NULL) { pixWidth = pTD->td_pixBufferWidth; pixHeight = pTD->td_pixBufferHeight; } // get window / texture factor if( pixWidth >= pixHeight) { m_fWndTexRatio = FLOAT(m_pDrawPort->GetWidth()) /pixWidth; } else { m_fWndTexRatio = FLOAT(m_pDrawPort->GetHeight()) /pixHeight; } // get width and height of texture window m_pixWinWidth = pixWidth *m_fWndTexRatio; m_pixWinHeight = pixHeight*m_fWndTexRatio; m_pixWinOffsetU = (m_pDrawPort->GetWidth() -m_pixWinWidth ) /2; m_pixWinOffsetV = (m_pDrawPort->GetHeight()-m_pixWinHeight) /2; // determine texture's alpha channel presence bAlphaChannel = pTD->td_ulFlags&TEX_ALPHACHANNEL; } else { // whole screen m_fWndTexRatio = 1.0f; m_pixWinWidth = m_pDrawPort->GetWidth(); m_pixWinHeight = m_pDrawPort->GetHeight(); m_pixWinOffsetU = 0; m_pixWinOffsetV = 0; } // clear window background m_pDrawPort->Fill( C_GRAY|CT_OPAQUE); // if chequered alpha flag is turned on #define CHESS_BOX_WIDTH 16 #define CHESS_BOX_HEIGHT 16 if( m_bChequeredAlpha && bAlphaChannel) { // create chess looking background for( INDEX iVert=0; iVert<(m_pixWinHeight/CHESS_BOX_HEIGHT)+1; iVert++) { // create chess looking background for( INDEX iHoriz=0; iHoriz<(m_pixWinWidth/CHESS_BOX_WIDTH)+1; iHoriz++) { COLOR colBox = C_WHITE; if( (iHoriz+iVert)&1) colBox = C_lGRAY; // fill part of a drawport with a given color m_pDrawPort->Fill( iHoriz*CHESS_BOX_WIDTH +m_pixWinOffsetU, iVert *CHESS_BOX_HEIGHT+m_pixWinOffsetV, CHESS_BOX_WIDTH, CHESS_BOX_HEIGHT, colBox|CT_OPAQUE); } } } // if it has any texture if( pTD!=NULL) { // create rectangle proportional with texture ratio covering whole draw port PIXaabbox2D rectPict = PIXaabbox2D( PIX2D( m_pixWinOffsetU, m_pixWinOffsetV), PIX2D( m_pixWinOffsetU+m_pixWinWidth, m_pixWinOffsetV+m_pixWinHeight)); // draw texture m_pDrawPort->PutTexture( &m_toTexture, rectPict); } // draw line on left mouse move if( m_bDrawLine) { m_pDrawPort->DrawLine(m_pixLineStartU, m_pixLineStartV, m_pixLineStopU, m_pixLineStopV, C_WHITE|CT_OPAQUE, 0xCCCCCCCC); m_pDrawPort->DrawLine(m_pixLineStartU, m_pixLineStartV, m_pixLineStopU, m_pixLineStopV, C_BLACK|CT_OPAQUE, 0x33333333); } // unlock the drawport m_pDrawPort->Unlock(); // swap if there is a valid viewport if( m_pViewPort!=NULL) m_pViewPort->SwapBuffers(); } // if this is effect texture if( pTD!=NULL && pTD->td_ptegEffect!=NULL) { // display rendering speed DOUBLE dMS = pTD->td_ptegEffect->GetRenderingTime() * 1000.0; // only if valid if( dMS>0) { char achrSpeed[256]; CDlgCreateEffectTexture *pDialog = (CDlgCreateEffectTexture*)GetParent(); sprintf( achrSpeed, "Rendering speed: %.2f ms", dMS); pDialog->m_strRendSpeed = achrSpeed; pDialog->UpdateData( FALSE); } // reset statistics STAT_Reset(); } }
void CBrushPaletteWnd::OnPaint() { { CPaintDC dc(this); // device context for painting } // skip if already drawing extern BOOL _bInTestGame; if( _bInTestGame) return; if( m_iTimerID == -1) { m_iTimerID = (int) SetTimer( 1, 10, NULL); } POINT ptMouse; GetCursorPos( &ptMouse); ScreenToClient( &ptMouse); // if there is a valid drawport, and the drawport can be locked if( m_pDrawPort != NULL ) { m_pDrawPort->SetAsCurrent(); CWorldEditorView *pWorldEditorView = theApp.GetActiveView(); ASSERT( pWorldEditorView != NULL); // clear background m_pDrawPort->Fill( C_lGRAY|CT_OPAQUE); // erase z-buffer m_pDrawPort->FillZBuffer(ZBUF_BACK); // for all brushes for( INDEX iBrush=0; iBrush<CT_BRUSHES; iBrush++) { // get current brush's box in pixels inside window PIXaabbox2D boxBrush = GetBrushBBox( iBrush); RenderBrushShape( iBrush, boxBrush, m_pDrawPort); TIME tm=_pTimer->GetRealTimeTick(); // if we are drawing selected brush if(iBrush==theApp.m_fCurrentTerrainBrush) { m_pDrawPort->SetAsCurrent(); FLOAT fFactor=sin(tm*8)/2.0f+0.5f; COLOR colSelected=LerpColor(C_lGRAY,C_RED,fFactor); m_pDrawPort->DrawBorder(boxBrush.Min()(1)-1, boxBrush.Min()(2)-1, boxBrush.Max()(1)-boxBrush.Min()(1)+2, boxBrush.Max()(2)-boxBrush.Min()(2)+2, colSelected|CT_OPAQUE); } PIXaabbox2D boxPoint( PIX2D( ptMouse.x, ptMouse.y), PIX2D(ptMouse.x, ptMouse.y) ); if( (boxBrush & boxPoint) == boxPoint) { m_pDrawPort->SetAsCurrent(); INDEX iRot=((ULONG)(tm*25.0f))&7; ULONG ulLineType=0x0f0f0f0f<<iRot; m_pDrawPort->DrawBorder(boxBrush.Min()(1)-1, boxBrush.Min()(2)-1, boxBrush.Max()(1)-boxBrush.Min()(1)+2, boxBrush.Max()(2)-boxBrush.Min()(2)+2, C_BLUE|CT_OPAQUE, ulLineType); } } // if there is a valid viewport if (m_pViewPort!=NULL) { m_pViewPort->SwapBuffers(); } } }