Ejemplo n.º 1
0
int GameInit(){
	HRESULT r = 0;//return values

	g_pD3D = Direct3DCreate8(D3D_SDK_VERSION);//COM object
	if( g_pD3D == NULL){
		SetError("Could not create IDirect3D8 object");
		return E_FAIL;
	}

	r = InitDirect3DDevice(g_hWndMain, 640, 480, FALSE, D3DFMT_X8R8G8B8, g_pD3D, &g_pDevice);
	if(FAILED(r)){//FAILED is a macro that returns false if return value is a failure - safer than using value itself
		SetError("Initialization of the device failed");
		return E_FAIL;
	}

	return S_OK;
}
Ejemplo n.º 2
0
int Renderer::startEngine(HWND hwnd, Model& model) {
	HRESULT r = 0;//return values

	pD3D_ = Direct3DCreate9(D3D_SDK_VERSION);//COM object
	if (pD3D_ == NULL) {
		Errors::SetError(TEXT("Could not create IDirect3D9 object"));
		return E_FAIL;
	}

	//4th argument is TRUE or FALSE, where FALSE means fullscreen.
	r = InitDirect3DDevice(hwnd, model.getWidth(), model.getHeight(), WINDOWED_MODE, D3DFMT_X8R8G8B8, pD3D_, &pDevice_);
	if (FAILED(r)) {//FAILED is a macro that returns false if return value is a failure - safer than using value itself
		Errors::SetError(TEXT("Initialization of the device failed"));
		return E_FAIL;
	}

	r = pDevice_->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer_);
	if (FAILED(r)) {
		Errors::SetError(TEXT("Couldn't get backbuffer"));
	}

	return S_OK;
}