void MusicPlayer::Previous() { 
    if (playlist.size() == 0) return;
    if (random)
        SwitchTo(RandomNumber());
    else
        SwitchTo(PreviousNumber());
}
void MusicPlayer::Next() {
    if (playlist.size() == 0) return;
    if (random)
        SwitchTo(RandomNumber());
    else
        SwitchTo(NextNumber());
}
Ejemplo n.º 3
0
/** \fn LiveTVChain::SwitchToNext(bool)
 *  \brief Sets the recording to switch to.
 *  \param up Set to true to switch to the next recording,
 *            false to switch to the previous recording.
 */
void LiveTVChain::SwitchToNext(bool up)
{
    //VERBOSE(VB_PLAYBACK, LOC + "SwitchToNext("<<(up?"up":"down")<<")");
    if (up && HasNext())
        SwitchTo(m_curpos + 1);
    else if (!up && HasPrev())
        SwitchTo(m_curpos - 1);
}
Ejemplo n.º 4
0
/** \fn LiveTVChain::SwitchToNext(bool)
 *  \brief Sets the recording to switch to.
 *  \param up Set to true to switch to the next recording,
 *            false to switch to the previous recording.
 */
void LiveTVChain::SwitchToNext(bool up)
{
#if 0
    LOG(VB_PLAYBACK, LOG_DEBUG, LOC + "SwitchToNext("<<(up?"up":"down")<<")");
#endif
    if (up && HasNext())
        SwitchTo(m_curpos + 1);
    else if (!up && HasPrev())
        SwitchTo(m_curpos - 1);
}
//==============================================================================================================================
bool DebugGBufferDeferredShader::RenderDepth11(ID3D11ShaderResourceView* texture, Camera* camera)
{
	cbInvMatrixBuffer cMB;
	cMB.g_InvViewProj = camera->InvViewProj4x4();
	// Map the matrix buffer
	{
		D3D11_MAPPED_SUBRESOURCE mapped_res2;
		m_pD3DSystem->GetDeviceContext()->Map(m_pMatrixCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_res2);
		{
			assert(mapped_res2.pData);
			*(cbInvMatrixBuffer*)mapped_res2.pData = cMB;
		}
		m_pD3DSystem->GetDeviceContext()->Unmap(m_pMatrixCB, 0);
	}

	ID3D11Buffer* ps_cbs[1] = { m_pMatrixCB };
	m_pD3DSystem->GetDeviceContext()->PSSetConstantBuffers(0, 1, ps_cbs);

	// Assign Texture
	ID3D11ShaderResourceView* ps_srvs[1] = { texture };
	ID3D11SamplerState* ps_samp[1] = { m_pD3DSystem->Point() };

	if (!m_Wireframe)
	{
		m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 1, ps_srvs);
		m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 1, ps_samp);

		SwitchTo("DebugGBufferDepthDeferredPS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
	}
	else
	{
		SwitchTo("DebugGBufferDeferredWireframePS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
	}

	m_pD3DSystem->TurnOnAdditiveBlending();

	SetVertexShader();
	SetPixelShader();

	//Perform Drawing onto a fullscreen quad with a NULL Input Layout
	RenderDraw11(4);

	m_pD3DSystem->TurnOffAdditiveBlending();

	// Unbind
	if (!m_Wireframe)
	{
		ps_samp[0] = NULL;
		m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 1, ps_samp);
		ps_srvs[0] = NULL;
		m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 1, ps_srvs);
	}

	return true;
}
Ejemplo n.º 6
0
CfgMgrBldr::CfgMgrBldr() : doc(nullptr), volatile_doc(nullptr), r(false)
{
    TiXmlBase::SetCondenseWhiteSpace(false);
    wxString personality(Manager::Get()->GetPersonalityManager()->GetPersonality());

    if (personality.StartsWith(_T("http://")))
    {
        SwitchToR(personality);
        return;
    }

    cfg = FindConfigFile(personality + _T(".conf"));

    if (cfg.IsEmpty())
    {
        #ifdef __WINDOWS__
        cfg = GetPortableConfigDir() + wxFILE_SEP_PATH + personality + _T(".conf");
        #else
        cfg = wxStandardPathsBase::Get().GetUserDataDir() + wxFILE_SEP_PATH + personality + _T(".conf");
        #endif
        doc = new TiXmlDocument();
        doc->InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
        doc->InsertEndChild(TiXmlElement("CodeBlocksConfig"));
        doc->FirstChildElement("CodeBlocksConfig")->SetAttribute("version", CfgMgrConsts::version);
        return;
    }
    SwitchTo(cfg);
}
Ejemplo n.º 7
0
CfgMgrBldr::CfgMgrBldr() : doc(nullptr), volatile_doc(nullptr), r(false)
{
    ConfigManager::MigrateFolders();

    TiXmlBase::SetCondenseWhiteSpace(false);
    wxString personality(Manager::Get()->GetPersonalityManager()->GetPersonality());

    if (personality.StartsWith(_T("http://")))
    {
        SwitchToR(personality);
        return;
    }

    cfg = FindConfigFile(personality + _T(".conf"));

    if (cfg.IsEmpty())
    {
        cfg = ConfigManager::GetConfigFolder() + wxFILE_SEP_PATH + personality + _T(".conf");
        doc = new TiXmlDocument();
        doc->InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
        doc->InsertEndChild(TiXmlElement("CodeBlocksConfig"));
        doc->FirstChildElement("CodeBlocksConfig")->SetAttribute("version", CfgMgrConsts::version);
        return;
    }
    SwitchTo(cfg);
}
Ejemplo n.º 8
0
        inline void Write(const void* ptr, size_t len) {
            In_.Reset(ptr, len);

            while (In_.Avail()) {
                SwitchTo();
            }
        }
Ejemplo n.º 9
0
void LinkForm::OnRelink( const Json::Value &json )
{
	bool link = json["link"].asBool();
	if(link)
	{
		SwitchTo(LINK_SUCCESS);
		
		StdClosure cb = nbase::Bind(&LinkForm::OnTimeup, this);
		auto weak_cb = timer_.ToWeakCallback(cb);
		nbase::ThreadManager::PostDelayedTask(weak_cb, nbase::TimeDelta::FromSeconds(2));
	}
	else
	{
		SwitchTo(LINK_TIP);
	}
}
Ejemplo n.º 10
0
void TextureRender::RenderToTexture(int field){
    if(hasParent)
        parent->RenderToTexture(field);

    SwitchTo();
    Render(field);
}
Ejemplo n.º 11
0
bool LinkForm::OnClicked( ui::EventArgs* msg )
{
	std::wstring name = msg->pSender->GetName();
	if(name == L"btn_relink")
	{
		SwitchTo(LINK_ING);

		LoginCallback::ReLogin();
	}
	return true;
}
//==============================================================================================================================
bool DebugGBufferDeferredShader::Render11(ID3D11ShaderResourceView* texture)
{
	// Assign Texture
	ID3D11ShaderResourceView* ps_srvs[1] = { texture };
	ID3D11SamplerState* ps_samp[1] = { m_pD3DSystem->Point() };
	
	if (!m_Wireframe)
	{
		m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 1, ps_srvs);
		m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 1, ps_samp);
		
		SwitchTo("DebugGBufferDeferredPS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
	}
	else
	{
		SwitchTo("DebugGBufferDeferredWireframePS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
	}
	
	m_pD3DSystem->TurnOnAdditiveBlending();
	
	SetVertexShader();
	SetPixelShader();
	
	//Perform Drawing onto a fullscreen quad with a NULL Input Layout
	RenderDraw11(4);
	
	m_pD3DSystem->TurnOffAdditiveBlending();
	
	// Unbind
	if (!m_Wireframe)
	{
		ps_samp[0] = NULL;
		m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 1, ps_samp);
		ps_srvs[0] = NULL;
		m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 1, ps_srvs);
	}
	
	return true;
}
Ejemplo n.º 13
0
void LinkForm::InitWindow()
{
	if (nim_ui::UserConfig::GetInstance()->GetIcon() > 0)
	{
		SetIcon(nim_ui::UserConfig::GetInstance()->GetIcon());
	}

	m_pRoot->AttachBubbledEvent(ui::kEventClick, nbase::Bind(&LinkForm::OnClicked, this, std::placeholders::_1));

	SwitchTo(LINK_TIP);

	unregister_cb.Add(NotifyCenter::GetInstance()->RegNotify(NT_LINK, nbase::Bind(&LinkForm::OnRelink, this, std::placeholders::_1)));
}
Ejemplo n.º 14
0
void CfgMgrBldr::SwitchToR(const wxString& absFileName)
{
    if (doc)
        delete doc;
    doc = new TiXmlDocument();
    doc->ClearError();

    cfg = absFileName;

    wxURL url(absFileName);
    url.SetProxy(ConfigManager::GetProxy());
    if (url.GetError() == wxURL_NOERR)
    {
        wxInputStream *is = url.GetInputStream();
        if (is && is->IsOk())
        {
            size_t size = is->GetSize();
            wxString str;
            #if wxCHECK_VERSION(2, 9, 0)
            wxChar* c = wxStringBuffer(str, size);
            #else
            wxChar* c = str.GetWriteBuf(size);
            #endif
            is->Read(c, size);
            #if !wxCHECK_VERSION(2, 9, 0)
            str.UngetWriteBuf(size);
            #endif

            doc = new TiXmlDocument();

            if (doc->Parse(cbU2C(str)))
            {
                doc->ClearError();
                delete is;
                return;
            }
            if (Manager::Get()->GetLogManager())
            {
                Manager::Get()->GetLogManager()->DebugLog(_T("##### Error loading or parsing remote config file"));
                Manager::Get()->GetLogManager()->DebugLog(cbC2U(doc->ErrorDesc()));
                doc->ClearError();
            }
        }
        delete is;
    }
    cfg.Empty();
    SwitchTo(wxEmptyString); // fall back
}
Ejemplo n.º 15
0
//==============================================================================================================================
bool OBJMeshShader::Render
(	int startIndex
,	int indexCount
,	ZShadeSandboxMesh::MeshRenderParameters mrp
,	ZShadeSandboxLighting::ShaderMaterial* material
)
{
	ID3D11ShaderResourceView* diffuseArrayTexture = 0;
	ID3D11ShaderResourceView* diffuseTexture = 0;
	ID3D11ShaderResourceView* ambientTexture = 0;
	ID3D11ShaderResourceView* specularTexture = 0;
	ID3D11ShaderResourceView* emissiveTexture = 0;
	ID3D11ShaderResourceView* normalMapTexture = 0;
	ID3D11ShaderResourceView* blendMapTexture = 0;
	ID3D11ShaderResourceView* detailMapTexture = 0;
	ID3D11ShaderResourceView* alphaMapTexture = 0;
	ID3D11ShaderResourceView* shadowMapTexture = 0;
	ID3D11ShaderResourceView* ssaoTexture = 0;
	ID3D11ShaderResourceView* displacementMapTexture = 0;

	material->GetTextures(
		diffuseArrayTexture,
		diffuseTexture,
		ambientTexture,
		specularTexture,
		emissiveTexture,
		normalMapTexture,
		blendMapTexture,
		detailMapTexture,
		alphaMapTexture,
		shadowMapTexture,
		ssaoTexture,
		displacementMapTexture
	);

	material->BuildMaterialConstantBuffer(m_pShadingCB, mrp.camera->Position(), mrp.clipplane);
	
	mrp.camera->BuildCameraConstantBuffer(m_pD3DSystem, m_pMatrixCB, mrp.world, mrp.reflection);
	
	ZShadeSandboxLighting::LightManager::Instance()->BuildFinalLightBuffers(m_pLightCB, m_pSunCB);

	// Set the shading constant buffer and matrix constant buffer into the Vertex Shader
	ID3D11Buffer* vs_cbs[2] = { m_pShadingCB, m_pMatrixCB };
	m_pD3DSystem->GetDeviceContext()->VSSetConstantBuffers(2, 2, vs_cbs);
	
	// Set the shading constant buffer into the Pixel Shader
	ID3D11Buffer* ps_cbs[3] = { m_pLightCB, m_pSunCB, m_pShadingCB };
	m_pD3DSystem->GetDeviceContext()->PSSetConstantBuffers(0, 3, ps_cbs);
	
	ID3D11ShaderResourceView* ps_srvs[11] = { diffuseArrayTexture, diffuseTexture, ambientTexture, specularTexture, emissiveTexture, normalMapTexture, blendMapTexture, detailMapTexture, alphaMapTexture, shadowMapTexture, ssaoTexture };
	ID3D11SamplerState* ps_samp[1] = { m_pD3DSystem->Linear() };
	
	if (!m_Wireframe)
	{
		m_pD3DSystem->TurnOffCulling();

		// Set the texture into the Pixel Shader
		m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 11, ps_srvs);
		m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 1, ps_samp);

		SwitchTo("OBJMeshPS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
	}
	else
	{
		SwitchTo("OBJMeshWireframePS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
	}

	// Tell the shader what input layout to use
	SetInputLayout("OBJMeshShader");
	
	// Assign the shaders to render the mesh
	SetVertexShader();
	SetPixelShader();
	
	//Perform Drawing
	RenderIndex11(startIndex, indexCount);

	// Unbind
	if (!m_Wireframe)
	{
		m_pD3DSystem->TurnOnCulling();

		ps_samp[0] = NULL;
		m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 1, ps_samp);

		for (int i = 0; i < 11; i++) ps_srvs[i] = NULL;
		m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 11, ps_srvs);
	}
	
	return true;
}
//==============================================================================================================================
bool MaterialTessellationShader::Render11
(	int indexCount
,	int instanceCount
,	ZShadeSandboxMesh::MeshRenderParameters mrp
,	ZShadeSandboxLighting::ShaderMaterial* material
)
{
	ID3D11ShaderResourceView* diffuseArrayTexture = 0;
	ID3D11ShaderResourceView* diffuseTexture = 0;
	ID3D11ShaderResourceView* ambientTexture = 0;
	ID3D11ShaderResourceView* specularTexture = 0;
	ID3D11ShaderResourceView* emissiveTexture = 0;
	ID3D11ShaderResourceView* normalMapTexture = 0;
	ID3D11ShaderResourceView* blendMapTexture = 0;
	ID3D11ShaderResourceView* detailMapTexture = 0;
	ID3D11ShaderResourceView* alphaMapTexture = 0;
	ID3D11ShaderResourceView* shadowMapTexture = 0;
	ID3D11ShaderResourceView* ssaoTexture = 0;
	ID3D11ShaderResourceView* displacementMapTexture = 0;

	material->GetTextures(
		diffuseArrayTexture,
		diffuseTexture,
		ambientTexture,
		specularTexture,
		emissiveTexture,
		normalMapTexture,
		blendMapTexture,
		detailMapTexture,
		alphaMapTexture,
		shadowMapTexture,
		ssaoTexture,
		displacementMapTexture
	);
	
	material->BuildMaterialTessellationBuffer(m_pTessellationCB, mrp.camera->Position());
	material->BuildMaterialDomainBuffer(m_pDomainCB, mrp.world, mrp.camera, mrp.clipplane, mrp.reflection);
	material->BuildMaterialConstantBuffer(m_pShadingCB, mrp.camera->Position(), mrp.clipplane);
	
	ZShadeSandboxLighting::LightManager::Instance()->BuildFinalLightBuffers(m_pLightCB, m_pSunCB);
	
	ID3D11Buffer* vs_cbs[1] = { m_pShadingCB };
	m_pD3DSystem->GetDeviceContext()->VSSetConstantBuffers(4, 1, vs_cbs);

	// Set the tessellation constant buffer into the Hull Shader
	ID3D11Buffer* hs_cbs[1] = { m_pTessellationCB };
	m_pD3DSystem->GetDeviceContext()->HSSetConstantBuffers(2, 1, hs_cbs);
	
	// Set the matrix constant buffer into the Domain Shader
	ID3D11Buffer* ds_cbs[2] = { m_pDomainCB, m_pShadingCB };
	m_pD3DSystem->GetDeviceContext()->DSSetConstantBuffers(3, 2, ds_cbs);
	
	ID3D11Buffer* ps_cbs[5] = { m_pLightCB, m_pSunCB, m_pTessellationCB, m_pDomainCB, m_pShadingCB };
	m_pD3DSystem->GetDeviceContext()->PSSetConstantBuffers(0, 5, ps_cbs);

	ID3D11ShaderResourceView* ps_srvs[11] = { diffuseArrayTexture, diffuseTexture, ambientTexture, specularTexture, emissiveTexture, normalMapTexture, blendMapTexture, detailMapTexture, alphaMapTexture, shadowMapTexture, ssaoTexture };
	ID3D11SamplerState* ps_samp[2] = { m_pD3DSystem->Point(), m_pD3DSystem->Linear() };

	ID3D11ShaderResourceView* disp_srvs[1] = { displacementMapTexture };

	if (!m_Wireframe)
	{
		// Assign Texture
		
		m_pD3DSystem->GetDeviceContext()->VSSetSamplers(0, 2, ps_samp);
		m_pD3DSystem->GetDeviceContext()->DSSetSamplers(0, 2, ps_samp);
		m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 2, ps_samp);
		
		m_pD3DSystem->GetDeviceContext()->VSSetShaderResources(11, 1, disp_srvs);
		m_pD3DSystem->GetDeviceContext()->DSSetShaderResources(11, 1, disp_srvs);
		m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 11, ps_srvs);
		
		switch (mType)
		{
			case ZShadeSandboxLighting::EMaterialTessellationType::Type::eQuad:
				SwitchTo("QuadMaterialTessellationPS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
			break;
			case ZShadeSandboxLighting::EMaterialTessellationType::Type::eTri:
				SwitchTo("TriMaterialTessellationPS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
			break;
		}
	}
	else
	{
		switch (mType)
		{
			case ZShadeSandboxLighting::EMaterialTessellationType::Type::eQuad:
				SwitchTo("QuadMaterialTessellationWireframePS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
			break;
			case ZShadeSandboxLighting::EMaterialTessellationType::Type::eTri:
				SwitchTo("TriMaterialTessellationWireframePS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
			break;
		}
	}
	
	if (mrp.useInstancing)
	{
		SetInputLayout("MaterialTessellationShaderInstance");
		switch (mType)
		{
			case ZShadeSandboxLighting::EMaterialTessellationType::Type::eQuad:
				SwitchTo("QuadMaterialTessellationInstanceVS", ZShadeSandboxShader::EShaderTypes::ST_VERTEX);
			break;
			case ZShadeSandboxLighting::EMaterialTessellationType::Type::eTri:
				SwitchTo("TriMaterialTessellationInstanceVS", ZShadeSandboxShader::EShaderTypes::ST_VERTEX);
			break;
		}
	}
	else
	{
		SetInputLayout("MaterialTessellationShader");
		switch (mType)
		{
			case ZShadeSandboxLighting::EMaterialTessellationType::Type::eQuad:
				SwitchTo("QuadMaterialTessellationVS", ZShadeSandboxShader::EShaderTypes::ST_VERTEX);
			break;
			case ZShadeSandboxLighting::EMaterialTessellationType::Type::eTri:
				SwitchTo("TriMaterialTessellationVS", ZShadeSandboxShader::EShaderTypes::ST_VERTEX);
			break;
		}
	}
	
	SetVertexShader();
	SetHullShader();
	SetDomainShader();
	SetPixelShader();
	
	//Perform Drawing
	if (mrp.useInstancing)
	{
		RenderIndexInstanced11(indexCount, instanceCount);
	}
	else
	{
		RenderIndex11(indexCount);
	}

	// Unbind
	if (!m_Wireframe)
	{
		ps_samp[0] = NULL;
		m_pD3DSystem->GetDeviceContext()->VSSetSamplers(0, 2, ps_samp);
		m_pD3DSystem->GetDeviceContext()->DSSetSamplers(0, 2, ps_samp);
		m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 2, ps_samp);
		
		disp_srvs[0] = NULL;
		m_pD3DSystem->GetDeviceContext()->VSSetShaderResources(11, 1, disp_srvs);
		m_pD3DSystem->GetDeviceContext()->DSSetShaderResources(11, 1, disp_srvs);

		for (int i = 0; i < 11; i++) ps_srvs[i] = NULL;
		m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 11, ps_srvs);
	}
	
	// Set Hull, Domain and Geometry Shaders to null in case they are not needed
	m_pD3DSystem->GetDeviceContext()->HSSetShader(NULL, NULL, 0);
	m_pD3DSystem->GetDeviceContext()->DSSetShader(NULL, NULL, 0);
	m_pD3DSystem->GetDeviceContext()->GSSetShader(NULL, NULL, 0);

	return true;
}
Ejemplo n.º 17
0
//==============================================================================================================================
bool MaterialShader::Render11
(	int indexCount
    ,	int instanceCount
    ,	ZShadeSandboxMesh::MeshRenderParameters mrp
    ,	ZShadeSandboxLighting::ShaderMaterial* material
)
{
    ID3D11ShaderResourceView* diffuseArrayTexture = 0;
    ID3D11ShaderResourceView* diffuseTexture = 0;
    ID3D11ShaderResourceView* ambientTexture = 0;
    ID3D11ShaderResourceView* specularTexture = 0;
    ID3D11ShaderResourceView* emissiveTexture = 0;
    ID3D11ShaderResourceView* normalMapTexture = 0;
    ID3D11ShaderResourceView* blendMapTexture = 0;
    ID3D11ShaderResourceView* detailMapTexture = 0;
    ID3D11ShaderResourceView* alphaMapTexture = 0;
    ID3D11ShaderResourceView* shadowMapTexture = 0;
    ID3D11ShaderResourceView* ssaoTexture = 0;
    ID3D11ShaderResourceView* displacementMapTexture = 0;

    if (material == 0) return false;

    material->GetTextures(
        diffuseArrayTexture,
        diffuseTexture,
        ambientTexture,
        specularTexture,
        emissiveTexture,
        normalMapTexture,
        blendMapTexture,
        detailMapTexture,
        alphaMapTexture,
        shadowMapTexture,
        ssaoTexture,
        displacementMapTexture
    );

    material->fBlendAmount = mrp.blendAmount;

    material->BuildMaterialConstantBuffer(m_pShadingCB, mrp.camera->Position(), mrp.clipplane);

    // Use the default light if there is no light
    if (mrp.light == 0)
    {
        MaterialShader::mDefaultLight->Update();
        mrp.light = MaterialShader::mDefaultLight;
    }

    mrp.camera->BuildCameraConstantBuffer(m_pD3DSystem, m_pMatrixCB, mrp.light, mrp.world, mrp.reflection);

    if (m_pD3DSystem->GetEngineOptions()->m_DimType == DimType::ZSHADE_3D)
        ZShadeSandboxLighting::LightManager::Instance()->BuildFinalLightBuffers(m_pLightCB, m_pSunCB);
    else
    {
        material->bEnableLighting = false;
        material->bHasDetailMapTexture = false;
    }

    ID3D11Buffer* vs_cbs[2] = { m_pShadingCB, m_pMatrixCB };
    m_pD3DSystem->GetDeviceContext()->VSSetConstantBuffers(2, 2, vs_cbs);

    ID3D11Buffer* ps_cbs[3] = { m_pLightCB, m_pSunCB, m_pShadingCB };
    m_pD3DSystem->GetDeviceContext()->PSSetConstantBuffers(0, 3, ps_cbs);

    ID3D11ShaderResourceView* ps_srvs[11] = { diffuseArrayTexture, diffuseTexture, ambientTexture, specularTexture, emissiveTexture, normalMapTexture, blendMapTexture, detailMapTexture, alphaMapTexture, shadowMapTexture, ssaoTexture };
    ID3D11SamplerState* ps_samp[2] = { m_pD3DSystem->Point(), m_pD3DSystem->Linear() };

    ID3D11ShaderResourceView* vs_srvs[1] = { displacementMapTexture };

    if (!m_Wireframe)
    {
        // Assign Texture

        m_pD3DSystem->GetDeviceContext()->VSSetSamplers(0, 2, ps_samp);
        m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 2, ps_samp);

        m_pD3DSystem->GetDeviceContext()->VSSetShaderResources(11, 1, vs_srvs);
        m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 11, ps_srvs);

        SwitchTo("MaterialShaderPS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
    }
    else
    {
        SwitchTo("MaterialShaderWireframePS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
    }

    if (mrp.useInstancing)
    {
        SetInputLayout("MaterialShaderInstance");
        SwitchTo("MaterialShaderInstanceVS", ZShadeSandboxShader::EShaderTypes::ST_VERTEX);
    }
    else
    {
        SetInputLayout("MaterialShader");
        SwitchTo("MaterialShaderVS", ZShadeSandboxShader::EShaderTypes::ST_VERTEX);
    }

    SetVertexShader();
    SetPixelShader();

    //Perform Drawing
    if (mrp.useInstancing)
    {
        RenderIndexInstanced11(indexCount, instanceCount);
    }
    else
    {
        RenderIndex11(indexCount);
    }

    // Unbind
    if (!m_Wireframe)
    {
        ps_samp[0] = NULL;
        ps_samp[1] = NULL;
        m_pD3DSystem->GetDeviceContext()->VSSetSamplers(0, 2, ps_samp);
        m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 2, ps_samp);

        vs_srvs[0] = NULL;
        m_pD3DSystem->GetDeviceContext()->VSSetShaderResources(11, 1, vs_srvs);

        for (int i = 0; i < 11; i++) ps_srvs[i] = NULL;
        m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 11, ps_srvs);
    }

    return true;
}
Ejemplo n.º 18
0
//==============================================================================================================================
bool DeferredShader::Render11
(	int indexCount
,	Camera* camera
,	XMMATRIX world
,	XMFLOAT2 specularPowerRange
,	float specularIntensity
,	float specularPower
,	ID3D11ShaderResourceView* texture
)
{
	cbPackBuffer cPB;
	cPB.g_SpecularPowerRange = specularPowerRange;
	cPB.g_SpecularIntensity = specularIntensity;
	cPB.g_SpecularPower = specularPower;
	// Map the pack buffer
	{
		D3D11_MAPPED_SUBRESOURCE mapped_res2;
		m_pD3DSystem->GetDeviceContext()->Map(m_pPackCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_res2);
		{
			assert(mapped_res2.pData);
			*(cbPackBuffer*)mapped_res2.pData = cPB;
		}
		m_pD3DSystem->GetDeviceContext()->Unmap(m_pPackCB, 0);
	}
	
	cbMatrixBuffer cMB;
	cMB.g_matWorld = ZShadeSandboxMath::ZMath::GMathMF(XMMatrixTranspose(world));
	cMB.g_matView = camera->View4x4();
	cMB.g_matProj = camera->Proj4x4();
	// Map the matrix buffer
	{
		D3D11_MAPPED_SUBRESOURCE mapped_res2;
		m_pD3DSystem->GetDeviceContext()->Map(m_pMatrixCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_res2);
		{
			assert(mapped_res2.pData);
			*(cbMatrixBuffer*)mapped_res2.pData = cMB;
		}
		m_pD3DSystem->GetDeviceContext()->Unmap(m_pMatrixCB, 0);
	}
	
	ID3D11Buffer* vs_cbs[1] = { m_pMatrixCB };
	m_pD3DSystem->GetDeviceContext()->VSSetConstantBuffers(1, 1, vs_cbs);
	
	ID3D11Buffer* ps_cbs[1] = { m_pPackCB };
	m_pD3DSystem->GetDeviceContext()->PSSetConstantBuffers(0, 1, ps_cbs);
	
	// Assign Texture
	ID3D11ShaderResourceView* ps_srvs[1] = { texture };
	ID3D11SamplerState* ps_samp[1] = { m_pD3DSystem->Linear() };
	
	if (!m_Wireframe)
	{
		m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 1, ps_srvs);
		m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 1, ps_samp);

		SwitchTo("DeferredShaderPS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
	}
	else
	{
		SwitchTo("DeferredShaderWireframePS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
	}

	SetInputLayout("DeferredShader");
	
	SetVertexShader();
	SetPixelShader();
	
	//Perform Drawing
	RenderIndex11(indexCount);

	// Unbind
	if (!m_Wireframe)
	{
		m_pD3DSystem->TurnOnCulling();

		ps_samp[0] = NULL;
		m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 1, ps_samp);
		ps_srvs[0] = NULL;
		m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 1, ps_srvs);
	}

	return true;
}
Ejemplo n.º 19
0
void LiveTVChain::JumpTo(int num, int pos)
{
    m_jumppos = pos;
    SwitchTo(num);
}
Ejemplo n.º 20
0
 inline void Finish() {
     if (!Finished_) {
         Finished_ = true;
         SwitchTo();
     }
 }
Ejemplo n.º 21
0
int EView::ExecCommand(int Command, ExState &State) {
    switch (Command) {
    case ExSwitchTo:
        return SwitchTo(State);
    case ExFilePrev:
        return FilePrev();
    case ExFileNext:
        return FileNext();
    case ExFileLast:
        return FileLast();
    case ExFileOpen:
        return FileOpen(State);
    case ExFileOpenInMode:
        return FileOpenInMode(State);
    case ExFileSaveAll:
        return FileSaveAll();
    case ExListRoutines:
        return ViewRoutines(State);
    case ExDirOpen:
        return DirOpen(State);
    case ExViewMessages:
        return ViewMessages(State);
    case ExCompile:
        return Compile(State);
    case ExRunCompiler:
        return RunCompiler(State);
    case ExCompilePrevError:
        return CompilePrevError(State);
    case ExCompileNextError:
        return CompileNextError(State);
    case ExCvs:
        return Cvs(State);
    case ExRunCvs:
        return RunCvs(State);
    case ExViewCvs:
        return ViewCvs(State);
    case ExClearCvsMessages:
        return ClearCvsMessages(State);
    case ExCvsDiff:
        return CvsDiff(State);
    case ExRunCvsDiff:
        return RunCvsDiff(State);
    case ExViewCvsDiff:
        return ViewCvsDiff(State);
    case ExCvsCommit:
        return CvsCommit(State);
    case ExRunCvsCommit:
        return RunCvsCommit(State);
    case ExViewCvsLog:
        return ViewCvsLog(State);
    case ExSvn:
        return Svn(State);
    case ExRunSvn:
        return RunSvn(State);
    case ExViewSvn:
        return ViewSvn(State);
    case ExClearSvnMessages:
        return ClearSvnMessages(State);
    case ExSvnDiff:
        return SvnDiff(State);
    case ExRunSvnDiff:
        return RunSvnDiff(State);
    case ExViewSvnDiff:
        return ViewSvnDiff(State);
    case ExSvnCommit:
        return SvnCommit(State);
    case ExRunSvnCommit:
        return RunSvnCommit(State);
    case ExViewSvnLog:
        return ViewSvnLog(State);
    case ExViewBuffers:
        return ViewBuffers(State);
    case ExShowKey:
        return ShowKey(State);
    case ExToggleSysClipboard:
        return ToggleSysClipboard(State);
    case ExSetPrintDevice:
        return SetPrintDevice(State);
    case ExShowVersion:
        return ShowVersion();
    case ExViewModeMap:
        return ViewModeMap(State);
    case ExClearMessages:
        return ClearMessages();
    case ExTagNext:
        return TagNext(this);
    case ExTagPrev:
        return TagPrev(this);
    case ExTagPop:
        return TagPop(this);
    case ExTagClear:
        TagClear();
        return 1;
    case ExTagLoad:
        return TagLoad(State);
    case ExShowHelp:
        return SysShowHelp(State, 0);
    case ExConfigRecompile:
        return ConfigRecompile(State);
    case ExRemoveGlobalBookmark:
        return RemoveGlobalBookmark(State);
    case ExGotoGlobalBookmark:
        return GotoGlobalBookmark(State);
    case ExPopGlobalBookmark:
        return PopGlobalBookmark();
    }
    return Model ? Model->ExecCommand(Command, State) : 0;
}
//==============================================================================================================================
bool AmbientLightDeferredShader::Render11
(	Camera* camera
,	ZShadeSandboxLighting::AmbientLight* light
,	XMFLOAT3 ambientUp
,	XMFLOAT3 ambientDown
,	ID3D11ShaderResourceView* colorTexture
,	ID3D11ShaderResourceView* normalTexture
,	ID3D11ShaderResourceView* depthTexture
)
{
	cbDeferredLightBuffer cLB;
	cLB.g_AmbientLightColor = light->DiffuseColor();
	cLB.g_AmbientDown = ambientDown;
	cLB.padding1 = 0;
	cLB.g_AmbientUp = ambientUp;
	cLB.padding2 = 0;
	cLB.g_InvViewProj = camera->InvViewProj4x4();
	// Map the light buffer
	{
		D3D11_MAPPED_SUBRESOURCE mapped_res2;
		m_pD3DSystem->GetDeviceContext()->Map(m_pLightCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_res2);
		{
			assert(mapped_res2.pData);
			*(cbDeferredLightBuffer*)mapped_res2.pData = cLB;
		}
		m_pD3DSystem->GetDeviceContext()->Unmap(m_pLightCB, 0);
	}
	
	ID3D11Buffer* ps_cbs[1] = { m_pLightCB };
	m_pD3DSystem->GetDeviceContext()->PSSetConstantBuffers(0, 1, ps_cbs);
	
	// Assign Texture
	ID3D11ShaderResourceView* ps_srvs[3] = { colorTexture, normalTexture, depthTexture };
	ID3D11SamplerState* ps_samp[2] = { m_pD3DSystem->Point(), m_pD3DSystem->Linear() };
	
	if (!m_Wireframe)
	{
		m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 3, ps_srvs);
		m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 2, ps_samp);
		
		SwitchTo("AmbientLightDeferredPS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
	}
	else
	{
		SwitchTo("AmbientLightDeferredWireframePS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
	}
	
	m_pD3DSystem->TurnOnAdditiveBlending();
	//m_pD3DSystem->TurnOnAlphaBlending();
	
	SetVertexShader();
	SetPixelShader();
	
	//Perform Drawing onto a fullscreen quad with a NULL Input Layout
	RenderDraw11(4);
	
	//m_pD3DSystem->TurnOffAlphaBlending();
	m_pD3DSystem->TurnOffAdditiveBlending();
	
	// Unbind
	if (!m_Wireframe)
	{
		ps_samp[0] = NULL;
		ps_samp[1] = NULL;
		m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 2, ps_samp);
		ps_srvs[0] = NULL;
		ps_srvs[1] = NULL;
		ps_srvs[2] = NULL;
		m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 3, ps_srvs);
	}
	
	return true;
}
//==============================================================================================================================
bool TriMaterialTessellationShader::Render11(int indexCount, ZShadeSandboxMath::XMMath4 clipplane, Camera* camera, float tessFactor, ZShadeSandboxLighting::ShaderMaterial* material)
{
	int useDiffuseArrayTexture = 0;
	int useDiffuseTexture = 0;
	int useNormalMapTexture = 0;
	int useBlendMapTexture = 0;
	int useDetailMapTexture = 0;
	int useAlphaMapTexture = 0;
	
	ID3D11ShaderResourceView* diffuseArrayTexture = 0;
	ID3D11ShaderResourceView* diffuseTexture = 0;
	ID3D11ShaderResourceView* normalMapTexture = 0;
	ID3D11ShaderResourceView* blendMapTexture = 0;
	ID3D11ShaderResourceView* detailMapTexture = 0;
	ID3D11ShaderResourceView* alphaMapTexture = 0;
	
	for (int i = 0; i < material->TextureCount(); i++)
	{
		switch (material->GetMaterialTextureType(i))
		{
			case ZShadeSandboxLighting::EMaterialTextureType::eDiffuseArray:
				useDiffuseArrayTexture = 1;
				diffuseArrayTexture = material->GetTexture(i)->getTexture11();
			break;
			case ZShadeSandboxLighting::EMaterialTextureType::eDiffuse:
				useDiffuseTexture = 1;
				diffuseTexture = material->GetTexture(i)->getTexture11();
			break;
			case ZShadeSandboxLighting::EMaterialTextureType::eNormal:
				useNormalMapTexture = 1;
				normalMapTexture = material->GetTexture(i)->getTexture11();
			break;
			case ZShadeSandboxLighting::EMaterialTextureType::eBlend:
				useBlendMapTexture = 1;
				blendMapTexture = material->GetTexture(i)->getTexture11();
			break;
			case ZShadeSandboxLighting::EMaterialTextureType::eDetail:
				useDetailMapTexture = 1;
				detailMapTexture = material->GetTexture(i)->getTexture11();
			break;
			case ZShadeSandboxLighting::EMaterialTextureType::eAlpha:
				useAlphaMapTexture = 1;
				alphaMapTexture = material->GetTexture(i)->getTexture11();
			break;
		}
	}
	
	Const_Per_Frame per_frame;
	per_frame.g_EyePosW = camera->Position();
	per_frame.g_ClipPlane = XMFLOAT4(clipplane.x, clipplane.y, clipplane.z, clipplane.w);
	per_frame.g_MaterialDiffuseColor = material->DiffuseColor();
	per_frame.g_MaterialAmbientColor = material->AmbientColor();
	per_frame.g_MaterialSpecularPower = material->SpecularPower();
	per_frame.g_MaterialSpecularIntensity = material->SpecularIntensity();
	per_frame.g_UsingDiffuseArrayTexture = useDiffuseArrayTexture;
	per_frame.g_UsingDiffuseTexture = useDiffuseArrayTexture;
	per_frame.g_UsingNormalMapTexture = useNormalMapTexture;
	per_frame.g_UsingBlendMapTexture = useBlendMapTexture;
	per_frame.g_UsingDetailMapTexture = useDetailMapTexture;
	per_frame.g_UseAlphaMapTexture = useAlphaMapTexture;
	per_frame.g_EnableTransparency = material->EnableTransparency();
	per_frame.g_EnableLighting = material->EnableLighting();
	per_frame.g_DetailBrightness = material->DetailBrightness();
	per_frame.g_AlphaToCoverageValue = material->AlphaToCoverageValue(); // Value that clips pixel during alpha blending
	per_frame.g_FlipTextureH = (bFlipHorizontally == true) ? 1 : 0;
	per_frame.g_FlipTextureV = (bFlipVertically == true) ? 1 : 0;
	per_frame.padding = 0;
	
	Const_Per_Object per_object;
	
	if (m_UseCustomWorld)
	{
		XMFLOAT4X4 world = ZShadeSandboxMath::ZMath::GMathMF(XMMatrixTranspose(mWorld.Get()));
		per_object.g_matWorld = world;
	}
	else
		per_object.g_matWorld = camera->World4x4();

	if (m_UseCustomView)
	{
		per_object.g_matView = mView;
	}
	else
		per_object.g_matView = camera->View4x4();

	if (m_pD3DSystem->GetEngineOptions()->m_DimType == DimType::ZSHADE_2D)
		per_object.g_matProj = camera->Ortho4x4();
	else if (m_pD3DSystem->GetEngineOptions()->m_DimType == DimType::ZSHADE_3D)
		per_object.g_matProj = camera->Proj4x4();

	if (m_UseOrtho)
	{
		per_object.g_matProj = camera->Ortho4x4();
	}
	
	ZShadeSandboxLighting::cbLightBuffer cLB;
	ZShadeSandboxLighting::cbAmbientLightBuffer alb;
	ZShadeSandboxLighting::cbDirectionalLightBuffer dlb;
	ZShadeSandboxLighting::cbSpotLightBuffer slb;
	ZShadeSandboxLighting::cbPointLightBuffer plb;
	ZShadeSandboxLighting::cbCapsuleLightBuffer clb;

	for (int i = 0; i < material->GetLightBuffer()->g_AmbientLightCount; i++)
	{
		alb.g_AmbientColor = material->GetLightBuffer()->g_AmbientLight[i].g_AmbientColor;
		cLB.g_AmbientLight[i] = alb;
	}
	for (int i = 0; i < material->GetLightBuffer()->g_DirectionalLightCount; i++)
	{
		dlb.g_Direction = material->GetLightBuffer()->g_DirectionalLight[i].g_LightDirection;
		dlb.padding = 0;
		dlb.g_Ambient = material->GetLightBuffer()->g_DirectionalLight[i].g_AmbientColor;
		dlb.g_Diffuse = material->GetLightBuffer()->g_DirectionalLight[i].g_DiffuseColor;
		cLB.g_DirectionalLight[i] = dlb;
	}
	for (int i = 0; i < material->GetLightBuffer()->g_SpotLightCount; i++)
	{
		slb.g_AmbientColor = material->GetLightBuffer()->g_SpotLight[i].g_AmbientColor;
		slb.g_DiffuseColor = material->GetLightBuffer()->g_SpotLight[i].g_DiffuseColor;
		slb.g_LightPosition = material->GetLightBuffer()->g_SpotLight[i].g_LightPosition;
		slb.padding = 0;
		slb.g_LightRange = material->GetLightBuffer()->g_SpotLight[i].g_LightRange;
		slb.g_SpotCosOuterCone = material->GetLightBuffer()->g_SpotLight[i].g_SpotCosOuterCone;
		slb.g_SpotInnerConeReciprocal = material->GetLightBuffer()->g_SpotLight[i].g_SpotInnerConeReciprocal;
		slb.g_CosineAngle = material->GetLightBuffer()->g_SpotLight[i].g_CosineAngle;
		cLB.g_SpotLight[i] = slb;
	}
	for (int i = 0; i < material->GetLightBuffer()->g_PointLightCount; i++)
	{
		plb.g_LightPosition = material->GetLightBuffer()->g_PointLight[i].g_LightPosition;
		plb.g_LightRange = material->GetLightBuffer()->g_PointLight[i].g_LightRange;
		plb.g_Attenuation = material->GetLightBuffer()->g_PointLight[i].g_Attenuation;
		plb.padding = 0;
		plb.g_AmbientColor = material->GetLightBuffer()->g_PointLight[i].g_AmbientColor;
		plb.g_DiffuseColor = material->GetLightBuffer()->g_PointLight[i].g_DiffuseColor;
		cLB.g_PointLight[i] = plb;
	}
	for (int i = 0; i < material->GetLightBuffer()->g_CapsuleLightCount; i++)
	{
		clb.g_LightPosition = material->GetLightBuffer()->g_CapsuleLight[i].g_LightPosition;
		clb.g_LightRange = material->GetLightBuffer()->g_CapsuleLight[i].g_LightRange;
		clb.g_LightDirection = material->GetLightBuffer()->g_CapsuleLight[i].g_LightDirection;
		clb.g_DiffuseColor = material->GetLightBuffer()->g_CapsuleLight[i].g_DiffuseColor;
		clb.g_LightLength = material->GetLightBuffer()->g_CapsuleLight[i].g_LightLength;
		clb.g_CapsuleDirectionLength = material->GetLightBuffer()->g_CapsuleLight[i].g_CapsuleDirectionLength;
		clb.g_CapsuleIntensity = material->GetLightBuffer()->g_CapsuleLight[i].g_CapsuleIntensity;
		cLB.g_CapsuleLight[i] = clb;
	}
	cLB.g_AmbientLightCount = material->GetLightBuffer()->g_AmbientLightCount;
	cLB.g_DirectionalLightCount = material->GetLightBuffer()->g_DirectionalLightCount;
	cLB.g_SpotLightCount = material->GetLightBuffer()->g_SpotLightCount;
	cLB.g_PointLightCount = material->GetLightBuffer()->g_PointLightCount;
	cLB.g_CapsuleLightCount = material->GetLightBuffer()->g_CapsuleLightCount;
	cLB.g_AmbientDown = material->GetLightBuffer()->g_AmbientDown;
	cLB.g_AmbientUp = material->GetLightBuffer()->g_AmbientUp;
	cLB.padding = 0;
	
	ZShadeSandboxLighting::cbSunLightBuffer cSLB;
	cSLB.g_SunDir = material->GetSunLightBuffer()->g_SunDir;
	cSLB.g_EnableSun = material->GetSunLightBuffer()->g_EnableSun;
	cSLB.g_SunDiffuseColor = material->GetSunLightBuffer()->g_SunDiffuseColor;
	cSLB.padding = XMFLOAT3(0, 0, 0);
	cSLB.g_SunShineness = material->GetSunLightBuffer()->g_SunShineness;
	
	cTessellationBuffer cTB;
	cTB.g_TessellationFactor = tessFactor;
	cTB.padding = XMFLOAT3(0, 0, 0);
	
	// Map tessellation constants
	{
		D3D11_MAPPED_SUBRESOURCE mapped_res;
		m_pD3DSystem->GetDeviceContext()->Map(m_pTessellationCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_res);
		{
			assert(mapped_res.pData);
			*(cTessellationBuffer*)mapped_res.pData = cTB;
		}
		m_pD3DSystem->GetDeviceContext()->Unmap(m_pTessellationCB, 0);
	}
	
	// Map the per frame constants
	{
	D3D11_MAPPED_SUBRESOURCE mapped_res;
		m_pD3DSystem->GetDeviceContext()->Map(m_pPerFrameCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_res);
		{
			assert(mapped_res.pData);
			*(Const_Per_Frame*)mapped_res.pData = per_frame;
		}
		m_pD3DSystem->GetDeviceContext()->Unmap(m_pPerFrameCB, 0);
	}
	
	// Map the matrix constants
	{
		D3D11_MAPPED_SUBRESOURCE mapped_res2;
		m_pD3DSystem->GetDeviceContext()->Map(m_pPerObjectCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_res2);
		{
			assert(mapped_res2.pData);
			*(Const_Per_Object*)mapped_res2.pData = per_object;
		}
		m_pD3DSystem->GetDeviceContext()->Unmap(m_pPerObjectCB, 0);
	}
	
	// Map light shading constants
	{
		D3D11_MAPPED_SUBRESOURCE mapped_res;
		m_pD3DSystem->GetDeviceContext()->Map(m_pLightCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_res);
		{
			assert(mapped_res.pData);
			*(ZShadeSandboxLighting::cbLightBuffer*)mapped_res.pData = cLB;
		}
		m_pD3DSystem->GetDeviceContext()->Unmap(m_pLightCB, 0);
	}
	
	// Map sun light shading constants
	{
		D3D11_MAPPED_SUBRESOURCE mapped_res;
		m_pD3DSystem->GetDeviceContext()->Map(m_pSunCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_res);
		{
			assert(mapped_res.pData);
			*(ZShadeSandboxLighting::cbSunLightBuffer*)mapped_res.pData = cSLB;
		}
		m_pD3DSystem->GetDeviceContext()->Unmap(m_pSunCB, 0);
	}
	
	// Set the tessellation constant buffer into the Hull Shader
	ID3D11Buffer* hs_cbs[1] = { m_pTessellationCB };
	m_pD3DSystem->GetDeviceContext()->HSSetConstantBuffers(0, 1, hs_cbs);
	
	// Set the matrix constant buffer into the Domain Shader
	ID3D11Buffer* ds_cbs[2] = { m_pPerFrameCB, m_pPerObjectCB };
	m_pD3DSystem->GetDeviceContext()->DSSetConstantBuffers(0, 2, ds_cbs);
	
	//ID3D11Buffer* vs_cbs[2] = { m_pPerFrameCB, m_pPerObjectCB };
	//m_pD3DSystem->GetDeviceContext()->VSSetConstantBuffers(0, 2, vs_cbs);
	
	ID3D11Buffer* ps_cbs[3] = { m_pPerFrameCB, m_pLightCB, m_pSunCB };
	m_pD3DSystem->GetDeviceContext()->PSSetConstantBuffers(0, 3, ps_cbs);

	ID3D11ShaderResourceView* ps_srvs[6] = { diffuseArrayTexture, diffuseTexture, normalMapTexture, blendMapTexture, detailMapTexture, alphaMapTexture };
	
	if (!m_Wireframe)
	{
		// Assign Texture
		m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 6, ps_srvs);

		SwitchTo("MaterialTessellationShaderPS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
	}
	else
	{
		SwitchTo("MaterialTessellationShaderWireframePS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
	}
	
	SetVertexShader();
	SetHullShader();
	SetDomainShader();
	SetPixelShader();

	SetInputLayout("TriMaterialTessellationShader");

	//Perform Drawing
	RenderIndex11(indexCount);

	// Unbind
	if (!m_Wireframe)
	{
		for (int i = 0; i < 6; i++) ps_srvs[i] = NULL;
		m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 6, ps_srvs);
	}
	
	// Set Hull, Domain and Geometry Shaders to null in case they are not needed
	m_pD3DSystem->GetDeviceContext()->HSSetShader(NULL, NULL, 0);
	m_pD3DSystem->GetDeviceContext()->DSSetShader(NULL, NULL, 0);
	m_pD3DSystem->GetDeviceContext()->GSSetShader(NULL, NULL, 0);

	return true;
}
Ejemplo n.º 24
0
MRESULT EXPENTRY
fnwpWxTaskWidget( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
  MRESULT mrc = 0;
  // get widget data from QWL_USER (stored there by WM_CREATE)
  PXCENTERWIDGET pWidget = (PXCENTERWIDGET)WinQueryWindowPtr( hwnd, QWL_USER );
  // this ptr is valid after WM_CREATE

  switch( msg )
  {
    /*
     * WM_CREATE:
     *      as with all widgets, we receive a pointer to the
     *      XCENTERWIDGET in mp1, which was created for us.
     *
     *      The first thing the widget MUST do on WM_CREATE
     *      is to store the XCENTERWIDGET pointer (from mp1)
     *      in the QWL_USER window word by calling:
     *
     *          WinSetWindowPtr(hwnd, QWL_USER, mp1);
     *
     *      We could use XCENTERWIDGET.pUser for allocating
     *      another private memory block for our own stuff,
     *      for example to be able to store fonts and colors.
     *      We ain't doing this in the minimal sample.
     */

    case WM_CREATE:
      WinSetWindowPtr(hwnd, QWL_USER, mp1);
      pWidget = (PXCENTERWIDGET)mp1;
      if(( !pWidget ) || ( !pWidget->pfnwpDefWidgetProc )) {
        // shouldn't happen... stop window creation!!
        mrc = (MPARAM)TRUE;
      }

      hwndMenu = WinCreateWindow( hwnd, WC_MENU, 0, 0, 0, 0, 0, 0,
                                  hwnd, HWND_TOP, ID_MENU_TASKS, 0, 0 );

      ico_tasks  = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_TASKS  );
      ico_detach = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_DETACH );
      ico_dos    = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_DOS    );
      ico_os2fs  = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_OS2FS  );
      ico_os2vio = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_OS2VIO );
      ico_pm     = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_PM     );
      break;

    /*
     * WM_BUTTON1CLICK:
     *      clicked on the window
     */

    case WM_BUTTON1CLICK:
    {
      mrc = (MPARAM)WgtControl( pWidget, mp1, mp2 );

      RECTL  rcl;
      POINTL ptl;
      SWP    swp;

      // Check if Ctrl is pressed
      if( WinGetKeyState( HWND_DESKTOP, VK_CTRL ) & 0x8000 ) {
        bType = TRUE;
      } else {
        bType = FALSE;
      }

      // Fill it with items
      FillMenu( hwndMenu );

      // Place popup according to xCenter position
      if( pWidget->pGlobals->ulPosition == XCENTER_BOTTOM )
      {
        WinQueryWindowRect( hwnd, &rcl );
        ptl.y = rcl.yTop + 1;
        ptl.x = rcl.xLeft;
        WinMapWindowPoints( HWND_DESKTOP, hwnd, &ptl, 0 );
      }
      else
      {
        WinQueryWindowRect( hwnd, &rcl );
        ptl.y = rcl.yBottom;
        ptl.x = rcl.xLeft;
        WinMapWindowPoints( HWND_DESKTOP, hwnd, &ptl, 0 );
        memset( &swp, 0, sizeof(SWP));
        swp.fl = SWP_SIZE;
        WinSendMsg( hwndMenu, WM_ADJUSTWINDOWPOS, MPFROMP(&swp), 0 );
        ptl.y -= swp.cy;
      }

      // Show menu
      WinPopupMenu( hwnd, hwnd, hwndMenu, ptl.x, ptl.y, 0,
                    PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_HCONSTRAIN | PU_VCONSTRAIN );
      break;
    }

    case WM_COMMAND:
    {
      char      szPid[1024];
      MENUITEM  mi;
      SHORT     id;
      TASKDATA* data;

      // Get menu id and data
      id = SHORT1FROMMP(mp1);
      WinSendMsg( hwndMenu, MM_QUERYITEM, MPFROM2SHORT( id, FALSE ), MPFROMP( &mi ));
      data = (TASKDATA*)mi.hItem;

      // Is it "our" item ??
      if( id >= ID_ITEM_FIRST && id < 10000 )
      {
        if( bType )
        {
          // Ctrl was pressed on icon, kill pid
          if( WinGetKeyState( HWND_DESKTOP, VK_CTRL ) & 0x8000 )
          {
            // Ctrl was pressed on menu item, use external kill
            sprintf( szPid, "Kill this process (%d) using fastio$ ?", data->pid );

            if( WinMessageBox( HWND_DESKTOP, hwnd, szPid, "xCenter", 0,
                               MB_ICONQUESTION | MB_YESNO    |
                               MB_APPLMODAL    | MB_MOVEABLE | MB_DEFBUTTON2 ) == MBID_YES )
            {
              DosKillFastIo( data->pid );
            }
          } else {
            sprintf( szPid, "Are you sure that you want to kill this process (%d)?", data->pid );

            if( WinMessageBox( HWND_DESKTOP, hwnd, szPid, "xCenter", 0,
                               MB_ICONQUESTION | MB_YESNO    |
                               MB_APPLMODAL    | MB_MOVEABLE | MB_DEFBUTTON2) == MBID_YES )
            {
              DosKillProcess( DKP_PROCESS, data->pid );
            }
          }
        } else {
          // No Ctrl, its a switch to task
          SwitchTo( data );
        }
      } else {
        // Its Ulrichs menu, forward
        mrc = pWidget->pfnwpDefWidgetProc( hwnd, msg, mp1, mp2 );
      }

      break;
    }

    /*
     * WM_CONTROL:
     *      process notifications/queries from the XCenter.
     */

    case WM_CONTROL:
      mrc = (MPARAM)WgtControl( pWidget, mp1, mp2 );
      break;

    /*
     * WM_PAINT:
     *      well, paint the widget.
     */

    case WM_PAINT:
      WgtPaint( hwnd, pWidget );
      break;

    /*
     * WM_PRESPARAMCHANGED:
     *      A well-behaved widget would intercept
     *      this and store fonts and colors.
     */

    case WM_PRESPARAMCHANGED:
      break;

    case WM_MEASUREITEM:
      return MeasureMenuItem((POWNERITEM)mp2 );

    case WM_DRAWITEM:
      return DrawMenuItem((POWNERITEM)mp2 );

    /*
     * WM_DESTROY:
     *      clean up. This _must_ be passed on to
     *      ctrDefWidgetProc.
     */

    case WM_DESTROY:
      // If we had any user data allocated in WM_CREATE
      // or elsewhere, we'd clean this up here.
      // We _MUST_ pass this on, or the default widget proc
      // cannot clean up.
      WinDestroyWindow ( hwndMenu   );
      WinDestroyPointer( ico_tasks  );
      WinDestroyPointer( ico_detach );
      WinDestroyPointer( ico_dos    );
      WinDestroyPointer( ico_os2fs  );
      WinDestroyPointer( ico_os2vio );
      WinDestroyPointer( ico_pm     );

      mrc = pWidget->pfnwpDefWidgetProc( hwnd, msg, mp1, mp2 );
      break;

    default:
      mrc = pWidget->pfnwpDefWidgetProc( hwnd, msg, mp1, mp2 );
  }

  return (mrc);
}
Ejemplo n.º 25
0
//==============================================================================================================================
bool OBJMeshShader::Render(int startIndex, int indexCount, Camera* camera, XMMATRIX wvp, XMFLOAT4 clipplane, XMFLOAT4 difColor, bool hasTexture,
	ID3D11ShaderResourceView* texture)
{
	cbOBJShadingConst cSC;
	cbMatrixBuffer cMB;
	
	cMB.g_WVPMatrix = ZShadeSandboxMath::ZMath::GMathMF(XMMatrixTranspose(wvp));
	
	//if (m_UseCustomWorld)
	//	cMB.g_WorldMatrix = ZShadeSandboxMath::ZMath::GMathMF(XMMatrixTranspose(mWorld.Get()));
	//else
	//	cMB.g_WorldMatrix = camera->World4x4();
	
	cSC.g_ClipPlane = clipplane;
	cSC.g_DifColor = difColor;
	cSC.padding = XMFLOAT2(0, 0);
	cSC.g_FarPlane = fFarPlane;
	cSC.g_hasTexture = (hasTexture == true) ? 1 : 0;
	
	// Map shading constants
	{
		D3D11_MAPPED_SUBRESOURCE mapped_res;
		m_pD3DSystem->GetDeviceContext()->Map(m_pOBJShadingCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_res);
		{
			assert(mapped_res.pData);
			*(cbOBJShadingConst*)mapped_res.pData = cSC;
		}
		m_pD3DSystem->GetDeviceContext()->Unmap(m_pOBJShadingCB, 0);
	}
	
	// Map matrix constants
	{
		D3D11_MAPPED_SUBRESOURCE mapped_res;
		m_pD3DSystem->GetDeviceContext()->Map(m_pMatrixBufferCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_res);
		{
			assert(mapped_res.pData);
			*(cbMatrixBuffer*)mapped_res.pData = cMB;
		}
		m_pD3DSystem->GetDeviceContext()->Unmap(m_pMatrixBufferCB, 0);
	}
	
	// Set the shading constant buffer and matrix constant buffer into the Vertex ZShadeSandboxShader::Shader
	ID3D11Buffer* vs_cbs[2] = { m_pOBJShadingCB, m_pMatrixBufferCB };
	m_pD3DSystem->GetDeviceContext()->VSSetConstantBuffers(0, 2, vs_cbs);
	
	// Set the shading constant buffer into the Pixel Shader
	ID3D11Buffer* ps_cbs[1] = { m_pOBJShadingCB };
	m_pD3DSystem->GetDeviceContext()->PSSetConstantBuffers(0, 1, ps_cbs);
	
	ID3D11ShaderResourceView* ps_srvs[1] = { texture };
	ID3D11SamplerState* ps_samp[1] = { m_pD3DSystem->Linear() };
	
	if (!m_Wireframe)
	{
		m_pD3DSystem->TurnOffCulling();

		// Set the texture into the Pixel Shader
		if (hasTexture)
		{
			m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 1, ps_srvs);
			m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 1, ps_samp);
		}

		SwitchTo("OBJMeshPS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
	}
	else
	{
		SwitchTo("OBJMeshWireframePS", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);
	}

	// Tell the shader what input layout to use
	SetInputLayout("OBJMeshShader");
	
	// Assign the shaders to render the mesh
	SetVertexShader();
	SetPixelShader();
	
	//Perform Drawing
	RenderIndex11(startIndex, indexCount);

	if (!m_Wireframe)
	{
		m_pD3DSystem->TurnOnCulling();
	}

	// Unbind
	if (!m_Wireframe && hasTexture)
	{
		ps_samp[0] = NULL;
		m_pD3DSystem->GetDeviceContext()->PSSetSamplers(0, 1, ps_samp);

		ps_srvs[0] = NULL;
		m_pD3DSystem->GetDeviceContext()->PSSetShaderResources(0, 1, ps_srvs);
	}
	
	return true;
}