Esempio n. 1
0
        void FrostAdapter::DrawEffect(_In_ IEffect * effect)
        {
            if (!effect)
            {
                m_Core->GetLogger()->LogMessage(VSLog_ModError, VOODOO_FROST_NAME, VSTR("Unable to draw null shader."));
                return;
            }

            ITechniqueRef tech = effect->GetDefaultTechnique();

            if (!tech)
            {
                m_Core->GetLogger()->LogMessage
                (
                    VSLog_ModError, VOODOO_FROST_NAME,
                    Format("No default technique given for shader %1%.") << effect 
                );
                return;
            }

            glMatrixMode(GL_PROJECTION);
            glPushMatrix();
            glLoadIdentity();
            glOrtho(0, 250.0, 250.0, 0, -1, 1);
            glMatrixMode(GL_MODELVIEW);
            glPushMatrix();
            glLoadIdentity();

            this->SetEffect(effect);
            uint32_t passes = tech->GetPassCount();

            for (size_t curpass = 0; curpass < passes; ++curpass)
            {
                IPassRef pass = tech->GetPass(curpass);

                this->SetPass(pass.get());
                //this->DrawGeometry(0, 0, nullptr, VF_None);
                this->ResetPass();

                ITextureRef target = pass->GetTarget(0);

                if (target)
                {
                    Variant targetVar = CreateVariant();
                    if (SUCCEEDED(target->GetProperty(PropIds::OpenGLTexture, &targetVar)) && targetVar.Type == UT_UInt32)
                    {
                        GLuint passtarget = (GLuint) targetVar.VUInt32.X;

                        glBindTexture(GL_TEXTURE_2D, passtarget);
                        glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 250, 250, 0);
                    }
                }
            }
            this->ResetEffect();

            glMatrixMode(GL_PROJECTION);
            glPopMatrix();
            glMatrixMode(GL_MODELVIEW);
            glPopMatrix();
        }
Esempio n. 2
0
        void FrostAdapter::SetGLRC(_In_opt_ HGLRC hglrc)
        {
            m_GLRC = hglrc;

            if (hglrc != nullptr)
            {
                // Setup resources
                TextureDesc desc = { {256, 256, 0}, false, true, VSFmtRGBA8};

                m_TexDepthFrame = this->CreateTexture(L":depthframe", desc);
                m_TexThisFrame = this->CreateTexture(L":thisframe", desc);
                m_TexLastPass = this->CreateTexture(L":lastpass", desc);
                m_TexLastShader = this->CreateTexture(L":lastshader", desc);

                Variant textureVar = CreateVariant();
                if (SUCCEEDED(m_TexDepthFrame->GetProperty(PropIds::OpenGLTexture, &textureVar)))
                {
                    gDepthTexture = (GLint)textureVar.VInt32.X;
                }
                if (SUCCEEDED(m_TexDepthFrame->GetProperty(PropIds::OpenGLTexture, &textureVar)))
                {
                    gThisFrame = (GLint)textureVar.VInt32.X;
                }
                if (SUCCEEDED(m_TexDepthFrame->GetProperty(PropIds::OpenGLTexture, &textureVar)))
                {
                    gLastPass = (GLint)textureVar.VInt32.X;
                }
                if (SUCCEEDED(m_TexDepthFrame->GetProperty(PropIds::OpenGLTexture, &textureVar)))
                {
                    gLastShader = (GLint)textureVar.VInt32.X;
                }

                // Load shader
                IFile * shaderFile = m_Core->GetFileSystem()->GetFile(L"test.fx");
                gpTestEffect = m_Core->CreateEffect(shaderFile);
            }
            else
            {
                m_TexLastPass = nullptr;
                m_TexLastShader = nullptr;

                gpTestEffect = nullptr;
            }
        }
Esempio n. 3
0
        VOODOO_METHODDEF(VSParameterDX9::SetTexture)(_In_ ITexture * pVal)
        {
            VOODOO_DEBUG_FUNCLOG(m_Core->GetLogger());

            if (m_Desc.Type < VSPT_Texture || m_Desc.Type > VSPT_TextureCube) return VSFERR_INVALIDCALL;

            m_Texture = pVal;

            ParameterList::iterator child = m_Attached.begin();
            while (child != m_Attached.end())
            {
                (*child)->SetTexture(pVal);
            }

            if (m_Effect && m_Handle)
            {
                Variant propVar = CreateVariant();
                if (FAILED(pVal->GetProperty(PropIds::D3D9Texture, &propVar)))
                {
                    m_Core->GetLogger()->LogMessage(VSLog_PlugError, VOODOO_D3D9_NAME, StringFormat("Unable to get hardware texture from texture %1%.") << pVal);
                    return VSFERR_INVALIDPARAMS;
                }

                LPDIRECT3DTEXTURE9 pDXTexture = reinterpret_cast<LPDIRECT3DTEXTURE9>(propVar.VPVoid);

                HRESULT hr = m_Effect->m_Handle->SetTexture(m_Handle, pDXTexture);

                if (FAILED(hr))
                {
                    m_Core->GetLogger()->LogMessage(VSLog_PlugError, VOODOO_D3D9_NAME, StringFormat("Unable to bind texture %1% to parameter %2%.") << pVal << this);
                    return VSFERR_INVALIDCALL;
                }

                m_Core->GetLogger()->LogMessage(VSLog_PlugDebug, VOODOO_D3D9_NAME, StringFormat("Bound texture %1% to parameter %2%.") << pVal << this);
            }

            return VSF_OK;
        }
Esempio n. 4
0
 ns3__Variant* Soap::Serialize(soap* s, const OpcUa::Variant& var)
 {
   return CreateVariant(s, var);
 }