CRenderTexture* CGraphic::CreateDepthTexture(uint width, uint height) { CRenderTexture* pTexture = CDataSources::GetInst()->NewDepthTexture(); pTexture->SetRect(CIRect(0,0,width,height)); pTexture->SetUseDepthBuffer( false ); pTexture->Create(); pTexture->AddRef(); m_depthTexList.insert(pTexture); return pTexture; }
void CIWrapRect::Decompose(CIPoint A, CIPoint B) { clear(); while (A.x<0) A.x+=bx; while (A.y<0) A.y+=by; while (B.x<A.x) B.x+=bx; while (B.y<A.y) B.y+=by; while (B.x-bx>A.x) B.x-=bx; while (B.y-by>A.y) B.y-=by; if (B.x<bx) { if (B.y<by) { // no decomposition takes effect push_back(CIRect(A,B)); } else { // decompose in y push_back(CIRect(A, CIPoint(B.x,by-1))); push_back(CIRect(CIPoint(A.x,0), B)); } } else { if (B.y<by) { // decompose in x push_back(CIRect(A, CIPoint(bx-1,B.y))); push_back(CIRect(CIPoint(0, A.y), B)); } else { // decompose both in x and in y push_back(CIRect(A, CIPoint(bx-1,by-1))); push_back(CIRect(CIPoint(0,0), B)); push_back(CIRect(CIPoint(0,A.y), CIPoint(B.x,by-1))); push_back(CIRect(CIPoint(A.x,0), CIPoint(bx-1,B.y))); } } }
bool CGraphic::Initialize(void) { CVertexDeclaration* pVD; //VerPos顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerPos::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION);; //VerTex2顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerTex2::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,1); //VerTex顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerTex::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); //VerColor3D顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerColor3D::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_COLOUR,VES_DIFFUSE); //VerColorSize顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerColorSize::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_COLOUR,VES_DIFFUSE); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT1,VES_PSIZE); //Vertex3D顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(Vertex3D::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_COLOUR,VES_DIFFUSE); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); //VerColorTex1顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerColorTex1::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_COLOUR,VES_DIFFUSE); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,1); //VerNCST顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerNCST::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL); pVD->AddElement(0,pVD->GetVertexSize(0),VET_COLOUR,VES_DIFFUSE); pVD->AddElement(0,pVD->GetVertexSize(0),VET_COLOUR,VES_SPECULAR); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); //VerNCST1顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerNCST1::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL); pVD->AddElement(0,pVD->GetVertexSize(0),VET_COLOUR,VES_DIFFUSE); pVD->AddElement(0,pVD->GetVertexSize(0),VET_COLOUR,VES_SPECULAR); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,1); ////VerTerrain顶点格式FVF 顶点描述化 //pVD = CDataSources::GetInst()->NewVertexDeclaration(); //pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); //pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL); //pVD->AddElement(0,pVD->GetVertexSize(0),VET_COLOUR,VES_DIFFUSE); //pVD->AddElement(0,pVD->GetVertexSize(0),VET_COLOUR,VES_SPECULAR); //pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); //pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,1); //pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,2); //pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,3); //VerNorTex顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerNorTex::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); //VerNorTex顶点格式FVF 顶点描述化 // 加入的了顶点颜色了 2009/3/23 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerNorDiffuseTex::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT3,VES_DIFFUSE,0); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); //VerNorTex1顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerNorTex1::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,1); //VerNorTex2顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerNorTex2::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,1); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,2); //VerNorTex2顶点格式FVF + 洪培 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerNorTex2::Format| CVertexElement::GetBaseFormatID(1,VES_DIFFUSE,0)); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,1); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,2); pVD->AddElement(1,0,VET_COLOUR,VES_DIFFUSE); //VerNorDif顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerNorDif::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL); pVD->AddElement(0,pVD->GetVertexSize(0),VET_COLOUR,VES_DIFFUSE); //VerNCT顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerNCT::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL); pVD->AddElement(0,pVD->GetVertexSize(0),VET_COLOUR,VES_DIFFUSE); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); //VerNor顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerNor::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL); //VerText2D顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerText2D::Format); pVD->AddElement(0,0,VET_FLOAT4,VES_POSITIONT); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); //Vertex2D顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(Vertex2D::Format); pVD->AddElement(0,0,VET_FLOAT4,VES_POSITIONT); pVD->AddElement(0,pVD->GetVertexSize(0),VET_COLOUR,VES_DIFFUSE); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); //Vertex2DAlpha顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(Vertex2DAlpha::Format); pVD->AddElement(0,0,VET_FLOAT4,VES_POSITIONT); pVD->AddElement(0,pVD->GetVertexSize(0),VET_COLOUR,VES_DIFFUSE); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,1); //VerColor2D顶点格式FVF 顶点描述化 pVD = CDataSources::GetInst()->NewVertexDeclaration(VerColor2D::Format); pVD->AddElement(0,0,VET_FLOAT4,VES_POSITIONT); pVD->AddElement(0,pVD->GetVertexSize(0),VET_COLOUR,VES_DIFFUSE); //VertexSkeletalFormat顶点描述 pVD = CDataSources::GetInst()->NewVertexDeclaration(VertexSkeletalFormat::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,0); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,1); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT2,VES_TEXTURE_COORDINATES,2); pVD->AddElement(0,pVD->GetVertexSize(0),VET_FLOAT4,VES_BLEND_WEIGHTS); pVD->AddElement(0,pVD->GetVertexSize(0),VET_UBYTE4,VES_BLEND_INDICES); //VertexAniFormat::Tex1顶点描述 pVD = CDataSources::GetInst()->NewVertexDeclaration(VertexAniFormat::Tex1::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL); pVD->AddElement(1,0,VET_FLOAT3,VES_POSITION,1); pVD->AddElement(1,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL,1); pVD->AddElement(2,0,VET_FLOAT2,VES_TEXTURE_COORDINATES,0); //VertexAniFormat::Tex2顶点描述 pVD = CDataSources::GetInst()->NewVertexDeclaration(VertexAniFormat::Tex2::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL); pVD->AddElement(1,0,VET_FLOAT3,VES_POSITION,1); pVD->AddElement(1,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL,1); pVD->AddElement(2,0,VET_FLOAT2,VES_TEXTURE_COORDINATES,0); pVD->AddElement(3,0,VET_FLOAT2,VES_TEXTURE_COORDINATES,1); //VertexAniFormat::Tex3顶点描述 pVD = CDataSources::GetInst()->NewVertexDeclaration(VertexAniFormat::Tex3::Format); pVD->AddElement(0,0,VET_FLOAT3,VES_POSITION,0); pVD->AddElement(0,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL,0); pVD->AddElement(1,0,VET_FLOAT3,VES_POSITION,1); pVD->AddElement(1,sizeof(CVector3f),VET_FLOAT3,VES_NORMAL,1); pVD->AddElement(2,0,VET_FLOAT2,VES_TEXTURE_COORDINATES,0); pVD->AddElement(3,0,VET_FLOAT2,VES_TEXTURE_COORDINATES,1); pVD->AddElement(4,0,VET_FLOAT2,VES_TEXTURE_COORDINATES,2); if ( FAILED( m_DynamicVB.Create( DYNAMIC_VB_SIZE/2, DYNAMIC_VB_SIZE/4, 256 ) ) ) return false; if ( FAILED( m_EffectNpcVB.Create( DYNAMIC_VB_SIZE/2, DYNAMIC_VB_SIZE/4, 1024 ) ) ) return false; if ( FAILED( m_EffectSceneVB.Create( DYNAMIC_VB_SIZE/2, DYNAMIC_VB_SIZE/4, 1024 ) ) ) return false; if ( FAILED( m_TempVB.Create( DYNAMIC_VB_SIZE/4, DYNAMIC_VB_SIZE/8 ) ) ) return false; CPostProcessManager::Create(); if(!CSkeletalsMgr::HasInst()) CSkeletalsMgr::Create(); m_pActiveTarget = CMainWindowTarget::GetInst(); //CreateDefautTexture uint32 uTexData = 0; if ( FAILED(CGraphic::GetInst()->CreateEmptyTexture(1, 1, 1, TF_ARGB32, &m_pSysTexture[eSTT_BLACK])) ) GfkLogErrOnce(GraphicErr::GetErrTypeStr(RenderRuntime_Err), "创建黑色纹理失败"); else { uTexData = CColor4::Black.MakeDWordSafe(); m_pSysTexture[eSTT_BLACK]->FillFromMemory(&uTexData, TF_ARGB32, 1, CIRect(0,0,1,1), CIRect(0,0,1,1)); } if ( FAILED(CGraphic::GetInst()->CreateEmptyTexture(1, 1, 1, TF_ARGB32, &m_pSysTexture[eSTT_GRAY])) ) GfkLogErrOnce(GraphicErr::GetErrTypeStr(RenderRuntime_Err), "创建灰色纹理失败"); else { uTexData = CColor4::Gray.MakeDWordSafe(); m_pSysTexture[eSTT_GRAY]->FillFromMemory(&uTexData, TF_ARGB32, 1, CIRect(0,0,1,1), CIRect(0,0,1,1)); } if ( FAILED(CGraphic::GetInst()->CreateEmptyTexture(1, 1, 1, TF_ARGB32, &m_pSysTexture[eSTT_WHITE])) ) GfkLogErrOnce(GraphicErr::GetErrTypeStr(RenderRuntime_Err), "创建白色纹理失败"); else { uTexData = CColor4::White.MakeDWordSafe(); m_pSysTexture[eSTT_WHITE]->FillFromMemory(&uTexData, TF_ARGB32, 1, CIRect(0,0,1,1), CIRect(0,0,1,1)); } CRenderPipeline::GetInst()->_SetDefaultTexture(m_pSysTexture[eSTT_GRAY]); return true; }