void GOpenGLBoard::DrawGrabbedRect(const GLGrabbedRect& GrabbedRect, const GBool TexUnit0, const GBool SubPixel0, const GBool TexUnit1, const GBool SubPixel1) { GReal u, v; GReal subX0 = 0, subY0 = 0, subX1 = 0, subY1 = 0; #define ENLARGE_OFFSET (GReal)0.5 if (GrabbedRect.Target == GL_TEXTURE_2D) { u = (GReal)((GDouble)GrabbedRect.Width / (GDouble)GrabbedRect.TexWidth); v = (GReal)((GDouble)GrabbedRect.Height / (GDouble)GrabbedRect.TexHeight); if (SubPixel0) { subX0 = ENLARGE_OFFSET / (GrabbedRect.TexWidth); subY0 = ENLARGE_OFFSET / (GrabbedRect.TexHeight); } if (SubPixel1) { subX1 = ENLARGE_OFFSET / (GrabbedRect.TexWidth); subY1 = ENLARGE_OFFSET / (GrabbedRect.TexHeight); } } else { u = (GReal)GrabbedRect.Width; v = (GReal)GrabbedRect.Height; if (SubPixel0) { subX0 = ENLARGE_OFFSET; subY0 = ENLARGE_OFFSET; } if (SubPixel1) { subX1 = ENLARGE_OFFSET; subY1 = ENLARGE_OFFSET; } } GPoint2 p0(GrabbedRect.gExpandedLogicBox.Min()); GPoint2 p2(GrabbedRect.gExpandedLogicBox.Max()); GPoint2 p1(p0[G_X], p2[G_Y]); GPoint2 p3(p2[G_X], p0[G_Y]); glBegin(GL_POLYGON); if (TexUnit0) SetTextureVertex(0, 0 + subX0, v - subY0); if (TexUnit1) SetTextureVertex(1, 0 + subX1, v - subY1); #ifdef DOUBLE_REAL_TYPE glVertex2dv(p1.Data()); #else glVertex2fv(p1.Data()); #endif if (TexUnit0) SetTextureVertex(0, u - subX0, v - subY0); if (TexUnit1) SetTextureVertex(1, u - subX1, v - subY1); #ifdef DOUBLE_REAL_TYPE glVertex2dv(p2.Data()); #else glVertex2fv(p2.Data()); #endif if (TexUnit0) SetTextureVertex(0, u - subX0, 0 + subY0); if (TexUnit1) SetTextureVertex(1, u - subX1, 0 + subY1); #ifdef DOUBLE_REAL_TYPE glVertex2dv(p3.Data()); #else glVertex2fv(p3.Data()); #endif if (TexUnit0) SetTextureVertex(0, 0 + subX0, 0 + subY0); if (TexUnit1) SetTextureVertex(1, 0 + subX1, 0 + subY1); #ifdef DOUBLE_REAL_TYPE glVertex2dv(p0.Data()); #else glVertex2fv(p0.Data()); #endif glEnd(); }
void CDialogMsg::Render( C2DRender* p2DRender ) { CSize size; LPCUSTOMTEXT lpCustomText; // CD3DFont* pOldFont = p2DRender->GetFont(); // p2DRender->SetFont( CWndBase::m_Theme.m_pFontWndTitle ); LPDIRECT3DDEVICE9 pd3dDevice = p2DRender->m_pd3dDevice; pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, 1 ); pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, 1 ); pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_POINT ); pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT ); pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR ); TEXTUREVERTEX vertex[ 4 * 18 ]; CPoint point; int nIndex; for( int i = 0; i < m_textArray.GetSize(); i++ ) { lpCustomText = (LPCUSTOMTEXT) m_textArray.GetAt( i ); TEXTUREVERTEX* pVertices = vertex; if( !lpCustomText->m_bInfinite && lpCustomText->m_timer.TimeOut() ) { // 퀘스트 이모티콘을 다시 보이게 한다. if( lpCustomText->m_pObj->GetType() == OT_MOVER ) ((CMover*)lpCustomText->m_pObj)->m_bShowQuestEmoticon = TRUE; safe_delete( lpCustomText ); m_textArray.RemoveAt( i ); i --; } else { CObj* pObj = lpCustomText->m_pObj; if( lpCustomText->m_pTexture ) { if( pObj->IsCull() == FALSE ) { // 월드 좌표를 스크린 좌표로 프로젝션 한다. D3DXVECTOR3 vOut, vPos = pObj->GetPos(), vPosHeight; D3DVIEWPORT9 vp; const BOUND_BOX* pBB; if( pObj->m_pModel ) pBB = pObj->m_pModel->GetBBVector(); else return; pd3dDevice->GetViewport( &vp ); D3DXMATRIX matTrans; D3DXMATRIX matWorld; D3DXMatrixIdentity(&matWorld); D3DXMatrixTranslation( &matTrans, vPos.x, vPos.y , vPos.z); D3DXMatrixMultiply( &matWorld, &matWorld, &pObj->GetMatrixScale() ); D3DXMatrixMultiply( &matWorld, &matWorld, &pObj->GetMatrixRotation() ); D3DXMatrixMultiply( &matWorld, &matWorld, &matTrans ); vPosHeight = pBB->m_vPos[0]; vPosHeight.x = 0; vPosHeight.z = 0; D3DXVec3Project( &vOut, &vPosHeight, &vp, &pObj->GetWorld()->m_matProj, &pObj->GetWorld()->m_pCamera->m_matView, &matWorld); CPoint point; point.x = (LONG)( vOut.x - 32 / 2 ); point.y = (LONG)( vOut.y - 32 ); MakeEven( point.x ); p2DRender->RenderTexture( point, lpCustomText->m_pTexture ); } } else { LPCTSTR lpStr = lpCustomText->m_string; lpCustomText->m_pFont->GetTextExtent( (TCHAR*)lpStr, &size ); if( pObj->IsCull() == FALSE ) { int nAlpha = 200; if( !lpCustomText->m_bInfinite && lpCustomText->m_timer.GetLeftTime() > 4000 ) nAlpha = (int)( 200 - ( ( lpCustomText->m_timer.GetLeftTime() - 4000 )* 200 / 1000 ) ); // 월드 좌표를 스크린 좌표로 프로젝션 한다. D3DXVECTOR3 vOut, vPos = pObj->GetPos(), vPosHeight; D3DVIEWPORT9 vp; const BOUND_BOX* pBB; if( pObj->m_pModel ) pBB = pObj->m_pModel->GetBBVector(); else return; pd3dDevice->GetViewport( &vp ); D3DXMATRIX matTrans; D3DXMATRIX matWorld; D3DXMatrixIdentity(&matWorld); D3DXMatrixTranslation( &matTrans, vPos.x, vPos.y , vPos.z); D3DXMatrixMultiply( &matWorld, &matWorld, &pObj->GetMatrixScale() ); D3DXMatrixMultiply( &matWorld, &matWorld, &pObj->GetMatrixRotation() ); D3DXMatrixMultiply( &matWorld, &matWorld, &matTrans ); vPosHeight = pBB->m_vPos[0]; vPosHeight.x = 0; vPosHeight.z = 0; D3DXVec3Project( &vOut, &vPosHeight, &vp, &pObj->GetWorld()->m_matProj, &pObj->GetWorld()->m_pCamera->m_matView, &matWorld); CRect rect = lpCustomText->m_rect; vOut.x -= rect.Width() / 2; vOut.y -= rect.Height(); CPoint ptOrigin = p2DRender->GetViewportOrg(); vOut.y *= 0.9f; FLOAT x = vOut.x; FLOAT y = vOut.y; int nHeight = rect.Height() / 8; int nWidth = rect.Width() / 8; CTexture* pTexture; FLOAT fEdge = 8.0f; FLOAT fWidth = ( nWidth <= 5 ) ? rect.Width() * 0.7f : rect.Width() * 0.9f; FLOAT fHeight = rect.Height() * 0.75f; FLOAT fOffsetX = 0; FLOAT fOffsetY = 0; nIndex = 0; int i; if( lpCustomText->m_nKind == CHAT_SHOUT ) { char buffer[256] = { 0 }; // 텍스쳐렌더 버그 관련 수정 CTexture* pShoutTex = NULL; int nlen = _tcsclen(lpStr); if( nlen >= 1 && nlen <= 1 ) strcpy( buffer, "texDialogBoxShout00.bmp" ); else if( nlen >= 2 && nlen <= 3 ) strcpy( buffer, "texDialogBoxShout01.bmp" ); else if( nlen >= 4 && nlen <= 5 ) strcpy( buffer, "texDialogBoxShout02.bmp" ); else if( nlen >= 6 && nlen <= 9 ) strcpy( buffer, "texDialogBoxShout03.bmp" ); else if( nlen >= 10 && nlen <= 20 ) strcpy( buffer, "texDialogBoxShout04.bmp" ); else if( nlen >= 21 && nlen <= 40 ) strcpy( buffer, "texDialogBoxShout05.bmp" ); else if( nlen >= 41 && nlen <= 60 ) strcpy( buffer, "texDialogBoxShout06.bmp" ); else if( nlen >= 61 ) strcpy( buffer, "texDialogBoxShout07.bmp" ); pShoutTex = CWndBase::m_textureMng.AddTexture( g_Neuz.m_pd3dDevice, MakePath( DIR_THEME, buffer ), 0xffff00ff ); if( pShoutTex ) { p2DRender->RenderTextureEx( CPoint( (int)( x-20 ), (int)( y-20 ) ), CPoint( (int)( fWidth+50.0f ), (int)( fHeight+40.0f ) ), pShoutTex, nAlpha, 1.0f, 1.0f, FALSE ); goto g_ShoutChat; } } for( i=0; i<3; i++ ) { if( i==0 || i==2 ) fOffsetY=fEdge; else fOffsetY=fHeight; fOffsetX = 0; for( int j=0; j<3; j++ ) { if( j==0 || j==2 ) fOffsetX = fEdge; else fOffsetX = fWidth; pTexture = m_texPack_ex[lpCustomText->m_nKind].GetAt( nIndex ); SetTextureVertex( pVertices, x, y, pTexture->m_fuLT, pTexture->m_fvLT ); pVertices++; SetTextureVertex( pVertices, x+fOffsetX, y, pTexture->m_fuRT, pTexture->m_fvRT ); pVertices++; SetTextureVertex( pVertices, x, y+fOffsetY, pTexture->m_fuLB, pTexture->m_fvLB ); pVertices++; SetTextureVertex( pVertices, x, y+fOffsetY, pTexture->m_fuLB, pTexture->m_fvLB ); pVertices++; SetTextureVertex( pVertices, x+fOffsetX, y, pTexture->m_fuRT, pTexture->m_fvRT ); pVertices++; SetTextureVertex( pVertices, x+fOffsetX, y+fOffsetY, pTexture->m_fuRB, pTexture->m_fvRB ); pVertices++; x+=fOffsetX; nIndex++; } x = vOut.x; y+=fOffsetY; } // 꼬랑지 출력 if( nWidth >= 6 ) { point = CPoint( (int)( x + ( 3 * nWidth / 5 ) * 8 ), (int)( y ) ); nIndex = 9; } else if( nWidth == 4 || nWidth == 5 ) { point = CPoint( (int)( x + 3 * 8 ), (int)( y ) ); nIndex = 9; } else if( nWidth == 3 ) { point = CPoint( (int)( x + 1 * 8 ), (int)( y ) ); nIndex = 9; } pTexture = m_texPack_ex[lpCustomText->m_nKind].GetAt( nIndex ); SetTextureVertex( pVertices, (FLOAT)( point.x ), (FLOAT)( point.y ), pTexture->m_fuLT, pTexture->m_fvLT ); pVertices++; SetTextureVertex( pVertices, (FLOAT)( point.x + 8.0f ), (FLOAT)( point.y ), pTexture->m_fuRT, pTexture->m_fvRT); pVertices++; SetTextureVertex( pVertices, (FLOAT)( point.x ), (FLOAT)( point.y + 8.0f ), pTexture->m_fuLB, pTexture->m_fvLB); pVertices++; SetTextureVertex( pVertices, (FLOAT)( point.x + 8.0f ), (FLOAT)( point.y ), pTexture->m_fuRT, pTexture->m_fvRT); pVertices++; SetTextureVertex( pVertices, (FLOAT)( point.x ), (FLOAT)( point.y + 8.0f ), pTexture->m_fuLB, pTexture->m_fvLB); pVertices++; SetTextureVertex( pVertices, (FLOAT)( point.x + 8.0f ), (FLOAT)( point.y + 8.0f ), pTexture->m_fuRB, pTexture->m_fvRB); pVertices++; pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, D3DCOLOR_ARGB( nAlpha, 0, 0, 0 ) ); pd3dDevice->SetVertexShader( NULL ); pd3dDevice->SetTexture( 0, m_texPack_ex[lpCustomText->m_nKind].GetAt( 0 )->m_pTexture ); pd3dDevice->SetFVF( D3DFVF_TEXTUREVERTEX ); pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, 20, vertex, sizeof( TEXTUREVERTEX ) ); g_ShoutChat: /* CPoint point; point.x = vOut.x + 8;; point.y = vOut.y + 8;; */ x = vOut.x + 8; y = vOut.y + 8; x -= ptOrigin.x; y -= ptOrigin.y; /* point.x -= ptOrigin.x; MakeEven( point.x ); point.y -= ptOrigin.y; */ lpCustomText->m_string.SetAlpha( nAlpha ); // p2DRender->TextOut_EditString( point.x, point.y, lpCustomText->m_string, 0, 0, 0 ); p2DRender->TextOut_EditString( (int)( x ), (int)( y ), lpCustomText->m_string, 0, 0, 0 ); } } } } for( i = 0; i < m_VendortextArray.GetSize(); i++ ) { lpCustomText = (LPCUSTOMTEXT) m_VendortextArray.GetAt( i ); TEXTUREVERTEX* pVertices = vertex; LPCTSTR lpStr = lpCustomText->m_string; lpCustomText->m_pFont->GetTextExtent( (TCHAR*)lpStr, &size ); CObj* pObj = lpCustomText->m_pObj; if( pObj->IsCull() == FALSE ) { int nAlpha = 200; // 월드 좌표를 스크린 좌표로 프로젝션 한다. D3DXVECTOR3 vOut, vPos = pObj->GetPos(), vPosHeight; D3DVIEWPORT9 vp; const BOUND_BOX* pBB; if( pObj->m_pModel ) pBB = pObj->m_pModel->GetBBVector(); else return; pd3dDevice->GetViewport( &vp ); D3DXMATRIX matTrans; D3DXMATRIX matWorld; D3DXMatrixIdentity(&matWorld); D3DXMatrixTranslation( &matTrans, vPos.x, vPos.y , vPos.z); D3DXMatrixMultiply( &matWorld, &matWorld, &pObj->GetMatrixScale() ); D3DXMatrixMultiply( &matWorld, &matWorld, &pObj->GetMatrixRotation() ); D3DXMatrixMultiply( &matWorld, &matWorld, &matTrans ); vPosHeight = pBB->m_vPos[0]; vPosHeight.x = 0; vPosHeight.z = 0; D3DXVec3Project( &vOut, &vPosHeight, &vp, &pObj->GetWorld()->m_matProj, &pObj->GetWorld()->m_pCamera->m_matView, &matWorld); CRect rect = lpCustomText->m_rect; vOut.x -= rect.Width() / 2; vOut.y -= rect.Height(); DWORD dwMaxHeight = lpCustomText->m_pFont->GetMaxHeight(); CPoint ptOrigin = p2DRender->GetViewportOrg(); int x = (int)( vOut.x ); int y = (int)( vOut.y ); int nHeight = rect.Height() / 8; int nWidth = rect.Width() / 8; FLOAT fGap = 40; FLOAT fWidth = (FLOAT)( rect.Width() ); FLOAT fHeight = rect.Height()*0.8f; fGap += 2.0f; CPoint ptTex1; CPoint ptTex2; ptTex1.x = (LONG)( vOut.x-24 ); ptTex1.y = (LONG)( vOut.y-fGap ); p2DRender->RenderTexture(ptTex1, m_pTex[0], nAlpha, 1.0f, 1.0f ); ptTex1.x = (LONG)( vOut.x+8 ); ptTex1.y = (LONG)( vOut.y-fGap ); ptTex2.x = (int)fWidth; ptTex2.y = 32; p2DRender->RenderTextureEx( ptTex1, ptTex2, m_pTex[1], nAlpha, 1.0f, 1.0f ); ptTex1.x = (LONG)( (int)(vOut.x+8)+ptTex2.x ); ptTex1.y = (LONG)( vOut.y-fGap ); p2DRender->RenderTexture(ptTex1, m_pTex[2], nAlpha, 1.0f, 1.0f ); fGap -= 2.0f; x = (int)( vOut.x + 8 ); y = (int)( vOut.y + 8 ); x -= ptOrigin.x; y -= ptOrigin.y; lpCustomText->m_string.SetAlpha( 250 ); p2DRender->TextOut_EditString( x, (int)( y-fGap ), lpCustomText->m_string, 0, 0, 0 ); } } }