コード例 #1
0
ファイル: ACD3D.cpp プロジェクト: dgadens/ActionEngine
HRESULT ACD3D::Init(HWND hWnd, BOOL enableVSync, BOOL log)
{
	HRESULT hr = AC_OK;

	if (log)
		mpLOG = fopen("RenderLOG.txt", "w");

	Log("Begin Init");

	GeometryShaderSupport = true;

	//cria o retangulo para renderizacao
	RECT rc;
	GetClientRect( hWnd, &rc );
	UINT width = rc.right - rc.left;
	UINT height = rc.bottom - rc.top;

	if (FAILED(CreateGraphicsDevice(width, height)))
		return AC_FAIL;

	if (FAILED(CreateConstantBuffers()))
		return AC_FAIL;

	if (FAILED(AddViewport(hWnd, enableVSync)))
		return AC_FAIL;

	//inicializa os estados
	mCurrentShadeMode			= ACSHADEMODE::ACSM_TriangleList;
	
	//inicializa com o blend padrao
	mCurrentBlendState			= ACBLENDSTATE::ACBS_Default;	
	ACD3DConfigurations::DefineBlendStateDefault();

	//inicializa escrevendo no zbuffer
	mCurrentDepthBufferState	= ACDEPTHBUFFERSTATE::ACDBS_WriteEnable;	
	ACD3DConfigurations::DefineDepthStencilStateEnableDepthBuffer();

	//inicializa como solido anti-horario
	mCurrentRasterizationState	= ACRASTERIZESTATE::ACRS_SolidCullCCW;
	ACD3DConfigurations::DefineRasterizeStateSolidCullCCW();

	//inicializa todos os samplers states 16 o caso do d3d10
	for (int i = 0; i < 16; i++)
	{
		mCurrentSamplerState[i] = ACSAMPLERSTATE::ACSS_Bilinear_Wrap;
		ACD3DConfigurations::DefineSamplerStateBilinearWrap(i);
	}

	//cria o vertexmanager
	mpVManager = new ACD3DVertexManager(this, ACD3DGlobals::G_pD3dDevice, ACConfigurations::Instance()->GetMaxVerticesInBuffer(), ACConfigurations::Instance()->GetMaxIndicesInBuffer(), mpLOG);
	ACD3DGlobals::G_pVertexManager = static_cast<ACD3DVertexManager*>(mpVManager);
	
	Log("Init Success");

    return hr;
};
コード例 #2
0
bool DisplayManager::RegisterCamera(CameraComponent* camera_component) {
    std::string name = camera_component->GetName();

    // Do not add if a CameraComponent of the same name already exists.
    if(mCameras.count(name) != 0)
        return false;

    int start_size = mCameras.size();

    // Create the render window if this is the first CameraComponent.
    if(mCameras.size() == 0 && (mOgreRoot == nullptr || !mOgreRoot->isInitialised()))
        _CreateWindow();

    mCameras[name] = camera_component;

    if(start_size == 0) {
        AddViewport("main", name, true);
    }

    return true;
}
コード例 #3
0
bool DisplayManager::ActivateCamera(const std::string& name, const std::string& viewport_name) {
	// Do not change if the requested CameraComponent hasn't been registered.
    if(mCameras.count(name) == 0)
        return false;

    std::string change_viewport_name;

    //if there is no name of Viewport given
    if(viewport_name == "") {
        //if there is no main Viewport made
        if(mMainViewport == "") {
            //if we can create one
            if(AddViewport("main", name, true))
            {
                //set it as Viewport for camera
                change_viewport_name = mMainViewport;
            } else {
                //if we cannot set just return false
                return false;
            }
        //if there is main Viewport set
        } else {
            //just use it to activate camera with it
            change_viewport_name = mMainViewport;
        }
    //if someone gave name of Viewport to use
    } else {
        //then use it
        change_viewport_name = viewport_name;
    }

    // Do not activate if the requested Viewport hasn't been created.
    if(mViewports.count(change_viewport_name) == 0)
        return false;

    mViewports[change_viewport_name].setCamera(mCameras[name]->GetCamera());
    mViewportsCameras[change_viewport_name] = name;

    return true;
}