Beispiel #1
0
void DiD3D9TextureDrv::CreateTexture()
{
    mD3DUsage = 0;
    mPool = D3DPOOL_MANAGED;
    if (mParent->GetResourceUsage() & RU_DYNAMIC)
    {
        mD3DUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY;
        mPool = D3DPOOL_DEFAULT;
    }

    if (mParent->GetUsage() & TU_DEPTH_STENCIL)
    {
        mD3DUsage |= D3DUSAGE_DEPTHSTENCIL;
        mPool = D3DPOOL_DEFAULT;
    }
    if (mParent->GetUsage() & TU_RENDER_TARGET)
    {
        mD3DUsage |= D3DUSAGE_RENDERTARGET;
        mPool = D3DPOOL_DEFAULT;
    }

    uint32 width = mParent->GetWidth();
    uint32 height = mParent->GetHeight();
    uint32 numLevels = mParent->GetNumLevels();
    DiPixelFormat fmt = mParent->GetFormat();

    D3DFORMAT d3dfmt = DiD3D9Mappings::D3D9FormatMapping[fmt];

    if (mD3DUsage & D3DUSAGE_DEPTHSTENCIL)
    {
        mTexture = nullptr;
        mSurface = DiD3D9Driver::CreateDepthStencil(width, height, d3dfmt);
        DI_ASSERT(mSurface);
        DI_DEBUG("D3D9 Depth stencil buffer created: (%d,%d), ptr:%x", width, height, (void*)mSurface);
    }
    else
    {
        if (mParent->GetTextureType() == TEXTURE_2D)
        {
            IDirect3DTexture9* tex2D = DiD3D9Driver::CreateTexture(width, height,
                                       numLevels, mD3DUsage, d3dfmt, mPool);
            DI_ASSERT(tex2D);
            tex2D->GetSurfaceLevel(0, &mSurface);
            mTexture = tex2D;
            DI_DEBUG("D3D9 2D texture created: (%d,%d), pool:%d, usage:%d, ptr:%x", width, height, mPool, mD3DUsage, (void*)tex2D);
        }
        else if (mParent->GetTextureType() == TEXTURE_CUBE)
        {
            DI_ASSERT(width == height);
            IDirect3DCubeTexture9* texCUBE = DiD3D9Driver::CreateCubeTexture(width, numLevels,
                                             mD3DUsage, d3dfmt, mPool);
            DI_ASSERT(texCUBE);
            mTexture = texCUBE;
            mSurface = nullptr;
        }
    }
}
Beispiel #2
0
void DiD3D9TextureDrv::Release()
{
    DI_DEBUG("D3D9 texture released: %x", (void*)mTexture);
    SAFE_RELEASE(mTexture);
    if (mD3DUsage & D3DUSAGE_DEPTHSTENCIL)
    {
        DI_DEBUG("D3D9 depth/stencil buffer released: %x", (void*)mSurface);
        SAFE_RELEASE(mSurface);
    }
}
Beispiel #3
0
 void DiEditorManager::DeleteEditorObject(DiBaseEditorObj* obj)
 {
     if(mLastCreatedObject == obj)
         mLastCreatedObject = nullptr;
     
     if(obj->GetType() == "ParticleSystem")
     {
         if(dynamic_cast<DiParticleSystemObj*>(obj)->GetParticleSystem() == mSelectingFx)
         {
             if(mSelectingFx)
             {
                 DI_DEBUG("Change selecting ps from [name = %s] to nullptr", mSelectingFx->GetName().c_str());
             }
             
             mSelectingFx = nullptr;
         }
     }
     
     bool triggerChangemodel = obj->GetType() == "ReferenceModel";
         
     DI_ASSERT(obj);
     obj->Release();
     SAFE_DELETE(obj);
     
     mCurrentSel = nullptr;
     
     if(triggerChangemodel)
     {
         DiEditorManager::Get()->TriggerEvent("RefModel");
     }
 }
Beispiel #4
0
    DiTexture::~DiTexture()
    {
        DI_DEBUG("Releasing texture: %s", mName.c_str());

        Release();

        SAFE_DELETE(mTextureDrv);

        if (Driver)
            Driver->RemoveDeviceLostListener(this);
    }
Beispiel #5
0
    void DiEditorManager::SetCurrentSelection(DiBaseEditorObj* sel)
    {
        if (mCurrentSel != sel)
        {
            mCurrentSel = sel;

            SetGizmoMode(mGlobalGizmoMode);
            
            auto psParent = mCurrentSel->LookForParent("ParticleSystem");
            if(!psParent)
                return;
            
            auto psObj = dynamic_cast<DiParticleSystemObj*>(psParent);
            
            mSelectingFx = psObj->GetParticleSystem();
            DI_DEBUG("Change selecting ps to [name = %s]", mSelectingFx->GetName().c_str());
        }
    }
Beispiel #6
0
    void DiShaderManager::UnloadAllShaders()
    {
        DI_DEBUG("unloading all shaders..");

        ShaderLibsIt it;
        ShaderLibsIt itEnd = mShaderLibs.end();

        for(it = mShaderLibs.begin(); it != itEnd; ++it)
        {
            DiMap<uint64,DiShaderProgram*>::iterator fIt;
            DiMap<uint64,DiShaderProgram*>::iterator fItEnd = it->second.end();
            for(fIt = it->second.begin(); fIt != fItEnd; ++fIt)
            {
                SAFE_DELETE(fIt->second);
            }
        }

        mShaderLibs.clear();
    }
Beispiel #7
0
    void FilesView::notifyTreeNodeSelected(MyGUI::TreeControl* pTreeControl, MyGUI::TreeControl::Node* pNode)
    {
        if (!pNode || pNode->emptyData())
            return;

        DiFileTree* filetree = *(pNode->getData<DiFileTree*>(false));
        if (!filetree || filetree->folder)
            return;

        DiString fullpath = pNode->getText().asUTF8().c_str();
        MyGUI::TreeControl::Node* cur = pNode->getParent();
        while (cur->getParent())
        {
            fullpath = cur->getText().asUTF8().c_str() + DiString("/") + fullpath;
            cur = cur->getParent();
        }
        DI_DEBUG("Model %s selected", fullpath.c_str());
        HonViewerApp::GetViewerApp()->GetModelViewer()->LoadModel(fullpath);
    }
Beispiel #8
0
 void DiD3D9DepthBuffer::Release()
 {
     DI_DEBUG("D3D9 depth/stencil buffer released: %x", (void*)mDepthBuffer);
     SAFE_RELEASE(mDepthBuffer);
 }