Beispiel #1
0
// CaptureRenderRequest
//
void plCaptureRenderRequest::Render(plPipeline* pipe, plPageTreeMgr* pageMgr)
{
    // If we don't have a render target, something has gone horribly wrong.
    if( !GetRenderTarget() )
    {
        hsAssert(false, "CaptureRenderRequest with no render target");
        return;
    }

    // Set ourselves up like the current pipeline, except with our screen size.
    plViewTransform vt = pipe->GetViewTransform();
    vt.SetViewPort(0, 0, fRenderTarget->GetWidth(), fRenderTarget->GetHeight());
    SetViewTransform(vt);
    SetClearColor(pipe->GetClearColor());
    SetClearDepth(pipe->GetClearDepth());

    // Clear our render target
    // Render the scene
    pipe->PushRenderRequest(this);
    plVirtualCam1::Refresh();

    pipe->ClearRenderTarget();

    pageMgr->Render(pipe);

    pipe->PopRenderRequest(this);
    plVirtualCam1::Refresh();

    // set up state so we can clear the z-buffer for every gui dialog (and therefore not have it
    // be obscured by other geometry)
    SetRenderState(GetRenderState() & ~plPipeline::kRenderClearColor);
    SetRenderState(GetRenderState() | plPipeline::kRenderClearDepth);
    SetClearDepth(1);

    // render all GUI items
    std::vector<plPostEffectMod*> guiRenderMods = pfGameGUIMgr::GetInstance()->GetDlgRenderMods();
    for (int i = (int)guiRenderMods.size() - 1; i >= 0; i--) // render in reverse, so dialogs on the bottom get rendered first
    {
        plPageTreeMgr* dlgPageMgr = guiRenderMods[i]->GetPageMgr();
        if (dlgPageMgr)
        {
            SetViewTransform(guiRenderMods[i]->GetViewTransform());
            pipe->PushRenderRequest(this);
            pipe->ClearRenderTarget();
            dlgPageMgr->Render(pipe);
            pipe->PopRenderRequest(this);
        }
    }

    // Callback on plCaptureRender to process the render target into a mipmap
    // and send it back to the requester.
    plCaptureRender::IProcess(pipe, GetAck(), GetRenderTarget());

    delete fRenderTarget;
    fRenderTarget = nil;
}
Beispiel #2
0
    // レンダーターゲットセット
    IZ_BOOL CGraphicsDevice::PushRenderTarget(CRenderTarget** rt, IZ_UINT num)
    {
        IZ_ASSERT(rt != IZ_NULL);
        IZ_ASSERT(num <= MAX_MRT_NUM);

        IZ_BOOL ret = IZ_FALSE;

        // 現在のレンダーターゲットをプッシュ
        for (IZ_UINT i = 0; i < num; ++i) {
            CRenderTarget* curRT = GetRenderTarget(i);

            if ((rt != IZ_NULL) && (curRT != rt[i]))
            {
                ret = m_RTMgr[i].Push(curRT);
                if (!ret) {
                    break;
                }
            }
        }

        if (ret) {
            SetRenderTarget(rt, num);
        }

        return ret;
    }
Beispiel #3
0
void SHotKeyCtrl::UpdateCaret()
{
    SStringT str=FormatHotkey();
    IRenderTarget *pRT=GetRenderTarget(NULL,OLEDC_NODRAW);
    CAutoRefPtr<IFont> oldFont;
    pRT->SelectObject(m_curFont,(IRenderObj**)&oldFont);
    SIZE szTxt;
    pRT->MeasureText(str,str.GetLength(),&szTxt);
    pRT->SelectObject(oldFont);
    ReleaseRenderTarget(pRT);
    
    CRect rcClient;
    GetClientRect(&rcClient);
    GetContainer()->SwndSetCaretPos(rcClient.left+EDIT_INSET+szTxt.cx,rcClient.top+(rcClient.Height()-szTxt.cy)/2);
}
SnippingWindow::SnippingWindow(HWND _parent)
    :WindowBase()
{
    auto up = std::make_unique<Yupei::CreateParam>(L"YupeiWindow");
    up->ParentWindow = _parent;
    SetCreateParam(std::move(up));
    auto rect = Yupei::DeviceHelper::GetResolution(GetWindowHandle());
    resolutionX = Yupei::GetRECTWidth<UINT>(rect);
    resolutionY = Yupei::GetRECTHeight<UINT>(rect);
    auto rt = GetRenderTarget();
    rt->CreateLayer(&topLayer);
    rt->CreateLayer(&shownLayer);
    rt->CreateSolidColorBrush(
        D2D1::ColorF(D2D1::ColorF::White, 0.5f), &whiteBrush);

}
Beispiel #5
0
void SListBoxEx::RedrawItem(int iItem)
{
    if(!IsVisible(TRUE)) return;
    CRect rcClient;
    GetClientRect(&rcClient);
    CRect rcItem=GetItemRect(iItem);
    CRect rcInter;
    rcInter.IntersectRect(&rcClient,&rcItem);
    if(rcInter.IsRectEmpty()) return;

    IRenderTarget * pRT=GetRenderTarget(&rcItem,OLEDC_PAINTBKGND);

    SSendMessage(WM_ERASEBKGND,(WPARAM)pRT);
    DrawItem(pRT,rcItem,iItem);

    ReleaseRenderTarget(pRT);
}
void SnippingWindow::OnRender()
{
    if (screenshot != nullptr)
    {
        auto fullRect = D2D1::RectF(0.f, 0.f,
                                    PixelsToDipsX<float>(resolutionX),
                                    PixelsToDipsY<float>(resolutionY));
        auto rt = GetRenderTarget();
        rt->DrawBitmap(screenshot, fullRect);
        rt->PushLayer(D2D1::LayerParameters(),
                      topLayer);
        rt->FillRectangle(fullRect, whiteBrush);
        rt->PopLayer();
        rt->PushLayer(D2D1::LayerParameters(toolbarCtrl->manager->RectangleToShot), shownLayer);
        rt->DrawBitmap(screenshot, fullRect);
        rt->PopLayer();
    }
}
Beispiel #7
0
void SHotKeyCtrl::OnSetFocus()
{
    IRenderTarget *pRT=GetRenderTarget(NULL,OLEDC_NODRAW);
    CAutoRefPtr<IFont> oldFont;
    pRT->SelectObject(m_curFont,(IRenderObj**)&oldFont);
    SIZE szTxt;
    pRT->MeasureText(_T("A"),1,&szTxt);
    pRT->SelectObject(oldFont);
    ReleaseRenderTarget(pRT);
    GetContainer()->SwndCreateCaret(NULL,1,szTxt.cy);

    CRect rcClient;
    GetClientRect(&rcClient);
    OnSetCaretValidateRect(&rcClient);

    UpdateCaret();
    GetContainer()->SwndShowCaret(TRUE);
}
Beispiel #8
0
void Camera::SaveToPng() {
    long millis = ((long)(GetMilliseconds() * 0.001));
    std::cout << "Saving camera to png.\n";

    std::ostringstream oss;
    oss << GetEecutablePath() << millis << "_color.png";

    if (GetEecutablePath() != "null" && m_eRenderMode == COLOR_DEPTH)
        GetRenderTarget()->SavePNG(oss.str().c_str(), GetNear(), GetFar());
    else
        std::cout << "Could not save image!\n";

    if (GetEecutablePath() != "null") {
        oss.clear();
        oss << GetEecutablePath() << millis << "_depth.png";
        GetDepthTarget()->SavePNG(oss.str().c_str(), GetNear(), GetFar());
    }
    else {
        std::cout << "Saved image (" << millis << ") to: " << GetEecutablePath() << "\n";
    }
}
Beispiel #9
0
void SListBox::RedrawItem(int iItem)
{
    if(!IsVisible(TRUE)) return;

    CRect rcClient;
    GetClientRect(&rcClient);
    int iFirstVisible = GetTopIndex();
    int nPageItems=(rcClient.Height()+m_nItemHei-1)/m_nItemHei+1;

    if(iItem>=iFirstVisible && iItem<GetCount() && iItem<iFirstVisible+nPageItems)
    {
        CRect rcItem(0,0,rcClient.Width(),m_nItemHei);
        rcItem.OffsetRect(0,m_nItemHei*iItem-m_ptOrigin.y);
        rcItem.OffsetRect(rcClient.TopLeft());
        IRenderTarget *pRT=GetRenderTarget(&rcItem,OLEDC_PAINTBKGND);

        SSendMessage(WM_ERASEBKGND,(WPARAM)(HDC)pRT);
        DrawItem(pRT,rcItem,iItem);

        ReleaseRenderTarget(pRT);
    }
}
Beispiel #10
0
void SetupWater(DiSceneManager* sm)
{
    // Render targets
    auto reflectMap = DiAssetManager::GetInstance().CreateOrReplaceAsset<DiTexture>("reflect_rt");
    reflectMap->SetDimensions(512, 512);
    reflectMap->SetFormat(PF_A8R8G8B8);
    reflectMap->SetUsage(TU_RENDER_TARGET);
    reflectMap->SetAutoMipmap(false);
    reflectMap->SetAddressing(AM_CLAMP);
    reflectMap->CreateTexture();
    auto reflectRT = reflectMap->GetRenderTarget();

    auto refractMap = DiAssetManager::GetInstance().CreateOrReplaceAsset<DiTexture>("refract_rt");
    refractMap->SetDimensions(512, 512);
    refractMap->SetFormat(PF_A8R8G8B8);
    refractMap->SetUsage(TU_RENDER_TARGET);
    refractMap->SetAutoMipmap(false);
    refractMap->SetAddressing(AM_CLAMP);
    refractMap->CreateTexture();
    auto refractRT = refractMap->GetRenderTarget();
    
    // Water plane 
    DiCullNode* nodePlane = sm->GetRootNode()->CreateChild();
    DiSimpleShapePtr model = make_shared<DiSimpleShape>();
    model->CreatePlane(100);

    auto waterMat = DiMaterial::QuickCreate("pool_fresnel_v", "pool_fresnel_p");
    auto shaderParam = waterMat->GetShaderParameter();

    shaderParam->WriteFloat("scale", 1.0f);
    shaderParam->WriteFloat("scroll", 0.05f);
    shaderParam->WriteFloat("fresnelBias", -0.1f);
    shaderParam->WriteFloat("fresnelScale", 1.8f);
    shaderParam->WriteFloat("fresnelPower", 8.0f);
    shaderParam->WriteFloat("noiseScale", 0.05f);
    shaderParam->WriteFloat4("tintColour", DiVec4(0, 0.05f, 0.05f, 1));
    shaderParam->WriteTexture2D("noiseMap", "waves2.dds");
    shaderParam->WriteTexture2D("reflectMap", "reflect_rt");
    shaderParam->WriteTexture2D("refractMap", "refract_rt");

    model->SetMaterial(waterMat);
    nodePlane->AttachObject(model);
    nodePlane->SetScale(7, 1, 13);

    // Add to scene manager with the callbacks
    DiCamera* cam = sm->GetCamera();
    cam->MoveRelative(DiVec3(0, 0, 700));
    
    sm->AddExtraRenderTarget(refractRT, cam,
        [nodePlane](DiRenderTarget*) {
            nodePlane->SetVisible(false);
        },
        [nodePlane](DiRenderTarget*) {
            nodePlane->SetVisible(true);
        }
    );

    sm->AddExtraRenderTarget(reflectRT, cam,
        [nodePlane, cam](DiRenderTarget*) {
            nodePlane->SetVisible(false);
            cam->EnableReflection(DiPlane(DiVec3::UNIT_Y, 0));
        },
        [nodePlane, cam](DiRenderTarget*) {
            nodePlane->SetVisible(true);
            cam->DisableReflection();
        }
    );
    
    DiPostEffectManager* peMgr = DiBase::Driver->GetMainRenderWindow()->GetPostEffectManager();
	DiPostEffect* bloom = peMgr->GetEffect("Bloom");
    if (bloom)
		bloom->SetEnable(false);
}
void Graphics_Mesh(bool isOpenGLMode)
{
	StartGraphicsTest();
	SetGLEnable(isOpenGLMode);

	ace::Log* log = ace::Log_Imp::Create(L"graphics.html", L"メッシュ");

	auto window = ace::Window_Imp::Create(640, 480, ace::ToAString(L"メッシュ").c_str());
	ASSERT_TRUE(window != nullptr);

	auto graphics = ace::Graphics_Imp::Create(window, isOpenGLMode, log, false);
	ASSERT_TRUE(graphics != nullptr);

	auto renderer3d = new ace::Renderer3D(graphics);
	ASSERT_TRUE(renderer3d != nullptr);
	renderer3d->SetWindowSize(ace::Vector2DI(640, 480));

	auto mesh1 = CreateMesh(graphics);
	auto mesh2 = CreateMesh(graphics);
	auto deformer = CreateDeformer(graphics);
	auto animation = CreateAnimation();

	auto cameraObject = new ace::RenderedCameraObject3D(graphics);
	cameraObject->SetPosition(ace::Vector3DF(0, 0, 10));
	cameraObject->SetFocus(ace::Vector3DF(0, 0, 0));
	cameraObject->SetFieldOfView(20.0f);
	cameraObject->SetZNear(1.0f);
	cameraObject->SetZFar(20.0f);
	cameraObject->SetWindowSize(ace::Vector2DI(800, 600));

	auto meshObject1 = new ace::RenderedModelObject3D(graphics);
	meshObject1->AddMeshGroup();
	meshObject1->AddMesh(0, mesh1);
	
	meshObject1->SetPosition(ace::Vector3DF(1, 0, 0));
	meshObject1->SetRotation(ace::Vector3DF(20.0f, 20.0f, 0.0f));

	auto meshObject2 = new ace::RenderedModelObject3D(graphics);
	meshObject2->AddMeshGroup();
	meshObject2->AddMesh(0, mesh2);
	meshObject2->SetDeformer(0, deformer.get());
	meshObject2->SetPosition(ace::Vector3DF(-1, 0, 0));
	meshObject2->SetRotation(ace::Vector3DF(20.0f, 20.0f, 0.0f));
	meshObject2->AddAnimationClip(ace::ToAString("anime1").c_str(), animation.get());
	meshObject2->PlayAnimation(ace::ToAString("anime1").c_str());

	auto lightObject = new ace::RenderedDirectionalLightObject3D(graphics);
	lightObject->SetRotation(ace::Vector3DF(30, 160, 0));

	renderer3d->AddObject(cameraObject);
	renderer3d->AddObject(meshObject1);
	renderer3d->AddObject(meshObject2);
	renderer3d->AddObject(lightObject);

	auto renderer2d = new ace::Renderer2D_Imp(graphics, log, window->GetSize());


	int32_t time = 0;
	while (window->DoEvent())
	{
		graphics->Begin();
		graphics->Clear(true, false, ace::Color(0, 0, 0, 255));

		renderer3d->Flip();

		renderer3d->BeginRendering();
		ace::Sleep(100);
		renderer3d->EndRendering();

		graphics->SetRenderTarget(nullptr, nullptr);

		ace::Vector2DF positions[4];
		ace::Color colors[4];
		ace::Vector2DF uvs[4];

		colors[0] = ace::Color(255, 255, 255, 255);
		colors[1] = ace::Color(255, 255, 255, 255);
		colors[2] = ace::Color(255, 255, 255, 255);
		colors[3] = ace::Color(255, 255, 255, 255);

		positions[0].X = 0;
		positions[0].Y = 0;
		positions[1].X = 640;
		positions[1].Y = 0;
		positions[2].X = 640;
		positions[2].Y = 480;
		positions[3].X = 0;
		positions[3].Y = 480;

		uvs[0].X = 0;
		uvs[0].Y = 0;
		uvs[1].X = 1;
		uvs[1].Y = 0;
		uvs[2].X = 1;
		uvs[2].Y = 1;
		uvs[3].X = 0;
		uvs[3].Y = 1;

		renderer2d->AddSprite(positions, colors, uvs, renderer3d->GetRenderTarget(), ace::eAlphaBlend::ALPHA_BLEND_BLEND, 0);
		renderer2d->DrawCache();
		renderer2d->ClearCache();

		graphics->Present();

		graphics->End();

		if (time == 10)
		{
			SAVE_SCREEN_SHOT(graphics, 0);
		}

		if (time == 11)
		{
			window->Close();
		}
		time++;
	}

	meshObject1->Release();
	meshObject2->Release();

	cameraObject->Release();
	lightObject->Release();

	delete renderer2d;
	delete renderer3d;

	graphics->Release();

	window->Release();
	delete log;
}