// See method declaration for details.
	void SetColoredRenderingTask::SetColoredFVF(IDirect3DDevice9& device)
	{
		HRESULT result = device.SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE);
		if(FAILED(result) == true)
		{
			throw D3DError("avl::view::d3d::SetColoredRenderingTask::SetColoredFVF()", "Unable to set the flexible vertex format to colored mode.", result);
		}
	}
Exemplo n.º 2
0
	// See method declaration for details.
	void SetTextureTask::Execute(RenderContext& render_context)
	{
		HRESULT result = render_context.device.SetTexture(0, &texture);
		if(FAILED(result) == true)
		{
			throw D3DError("avl::view::d3d::SetTextureTask::Execute()", "Unable to set texture.", result);
		}
	}
Exemplo n.º 3
0
//////////////////////////////////////////////////////////////////////////////////
// Initializes all member variables
// is called from all constructors!
//////////////////////////////////////////////////////////////////////////////////
void CRMEngine::InitCRMEngine()
{
	HRESULT   rval;
	LPDIRECT3DRM lpD3DRMInterface;

	CDXLOG("START: CRMEngine::InitCRMEngine");
	CDXLOG("Initialize member vars");

	// initialize member variables
	m_Direct3D = NULL;
	m_IMDevice = NULL;
	m_RMDevice = NULL;

	m_Direct3DRM = NULL;
	m_lpDDClipper = NULL;

	m_Screen = NULL;

	CDXLOG("Create the Direct3D Retained Mode Interface");

	// create the main d3drm object
	rval = Direct3DRMCreate(&lpD3DRMInterface);
	if(rval != D3DRM_OK) {
		D3DError(rval, m_Screen->GetWindowHandle(), __FILE__, __LINE__);
	}

	CDXLOG("QueryInterface for a IDirect3DRM3 Interface");

    /* Get the interface IDirect3DRM3 */
    rval = lpD3DRMInterface->QueryInterface (IID_IDirect3DRM3,
                                                (LPVOID *) &m_Direct3DRM);

	CDXLOG("Release the old IDirect3DRM interface");

	/* Release the Old IDirect3DRM */
	RELEASE(lpD3DRMInterface);

	if(rval != D3DRM_OK) {
		D3DError(rval, m_Screen->GetWindowHandle(), __FILE__, __LINE__);
	}

	CDXLOG("END: CRMEngine::InitCRMEngine");
}
Exemplo n.º 4
0
//////////////////////////////////////////////////////////////////////////////////
// CRMEngine CreateFullScreen - creates a full screen application
//////////////////////////////////////////////////////////////////////////////////
HRESULT CRMEngine::CreateFullScreen(CDXScreen* pScreen, void *hWnd,
                                    int Width, int Height, int BPP)
{
	GUID d3dGUID;
	LPDIRECTDRAW lpDD;
	LPDIRECTDRAWSURFACE lpDDS;
	HRESULT rval;

	CDXLOG("START: CRMEngine::CreateFullScreen");

	CDXASSERT(BPP!=8);

	CDXLOG("Release any existing m_RMDevice we have");

	// first release everything that has been allocated
	RELEASE(m_RMDevice);

	CDXLOG("Save our Screen Pointer, and switch us to FullScreen mode");

	// create the CDXScreen object
	m_Screen = pScreen;
	if(FAILED(m_Screen->CreateFullScreen(hWnd, Width, Height, BPP))) {
    	CDXLOG("FullScreen mode switch failed");
		return D3DRMERR_NOTDONEYET;
	}

#if DIRECTDRAW_VERSION >= CDX_DDVER
	CDXLOG("QueryInterface for a IDirectDraw Interface");

	// query for a IDirectDraw object
	rval = m_Screen->GetDD()->QueryInterface(IID_IDirectDraw, (LPVOID*)&lpDD);
	if(rval != DD_OK) DDError(rval, NULL, __FILE__, __LINE__);

	CDXLOG("QueryInterface for a IDirectDrawSurface Interface");

	rval = m_Screen->GetBack()->GetDDS()->QueryInterface(IID_IDirectDrawSurface, (LPVOID*)&lpDDS);
	if(rval != DD_OK) DDError(rval, NULL, __FILE__, __LINE__);
#else
	CDXLOG("Save the DirectDraw and DirectDrawSurface pointers");

	lpDD = m_Screen->GetDD();
	lpDDS = m_Screen->GetBack()->GetDDS();
#endif

	CDXLOG("Attempt to CreateDeviceFromSurface");

	// create the d3d device
	rval = m_Direct3DRM->CreateDeviceFromSurface(FindDevice(BPP, &d3dGUID),
		lpDD, lpDDS,0, &m_RMDevice);
	if(FAILED(rval)) {
    	CDXLOG("Create attempt failed");
		D3DError(rval, m_Screen->GetWindowHandle(), __FILE__, __LINE__);
		return D3DRMERR_NOTDONEYET;
	}

	CDXLOG("Set the RMDevice buffer count = 2");

	/* in my doc it's specified that we should set this */
	m_RMDevice->SetBufferCount(2);

	CDXLOG("Set our defaults based on bit depth");

	// start our engine with default values based on color depth
	SetDefaults();

	CDXLOG("END: CRMEngine::CreateFullScreen");

	return D3DRM_OK;
}