HRESULT Deferred::Init(ID3D11Device* device, ID3D11DeviceContext* deviceContext, IDXGISwapChain* swapChain,ShaderFactory* shaderFactory)
{
	HRESULT hr = S_OK;

	this->device = device;
	this->deviceContext = deviceContext;
	this->swapChain = swapChain;

	if(FAILED(InitDepthBuffer()))
		return E_FAIL;

	if (FAILED(InitBackBuffer()))
		return E_FAIL;
	
	if(FAILED(InitGBuffers()))
		return E_FAIL;

	if(FAILED(InitSSAOPass()))
		return E_FAIL;

	if(FAILED(InitLightPass()))
		return E_FAIL;

	if(FAILED(InitQuad()))
		return E_FAIL;

	mShader = shaderFactory->CreateDeferredShader();

	return hr;
}
ECode CPathInterpolator::ParseInterpolatorFromTypeArray(
    /* [in] */ ITypedArray* a)
{
    // If there is pathData defined in the xml file, then the controls points
    // will be all coming from pathData.
    Boolean has = FALSE;
    if (a->HasValue(R::styleable::PathInterpolator_pathData, &has), has) {
        String pathData;
        a->GetString(R::styleable::PathInterpolator_pathData, &pathData);
        AutoPtr<IPath> path = PathParser::CreatePathFromPathData(pathData);
        if (path == NULL) {
            // throw new InflateException("The path is null, which is created"
            //         + " from " + pathData);
            return E_INFLATE_EXCEPTION;
        }

        FAIL_RETURN(InitPath(path));
    } else {
        if (!(a->HasValue(R::styleable::PathInterpolator_controlX1, &has), has)) {
            // throw new InflateException("pathInterpolator requires the controlX1 attribute");
            return E_INFLATE_EXCEPTION;
        } else if (!a.hasValue(R.styleable.PathInterpolator_controlY1)) {
            // throw new InflateException("pathInterpolator requires the controlY1 attribute");
            return E_INFLATE_EXCEPTION;
        }
        Float x1 = 0f;
        a->GetFloat(R::styleable::PathInterpolator_controlX1, 0, &x1);
        Float y1 = 0f;
        a->GetFloat(R::styleable::PathInterpolator_controlY1, 0, &y1);

        Boolean hasX2 = FALSE;
        a->HasValue(R::styleable::PathInterpolator_controlX2, &hasX2);
        Boolean hasY2 = FALSE;
        a->HasValue(R::styleable::PathInterpolator_controlY2, &hasY2);

        if (hasX2 != hasY2) {
            // throw new InflateException(
            //         "pathInterpolator requires both controlX2 and controlY2 for cubic Beziers.");
            return E_INFLATE_EXCEPTION;
        }

        if (!hasX2) {
            FAIL_RETURN(InitQuad(x1, y1));
        } else {
            Float x2 = 0f;
            a->GetFloat(R::styleable::PathInterpolator_controlX2, 0, &x2);
            Float y2 = 0f;
            a->GetFloat(R::styleable::PathInterpolator_controlY2, 0, &y2);
            FAIL_RETURN(InitCubic(x1, y1, x2, y2));
        }
    }

    return NOERROR;
}
Exemplo n.º 3
0
//---------------------------------------------------------------------
//  Read the knob position
//---------------------------------------------------------------------
void  C_Knob::ReadPOSN(SStream *str)
{ if (0 == mgg) gtfo("Knob: need mother gauge");
  char txt[128];
  ReadString(txt,128,str);
  int px,py;
  int wx,hy;
  int nf = sscanf(txt,"%d , %d , %d , %d",&px,&py,&wx,&hy);
  if (4 != nf) gtfo("Invalide <posn>");
  x1  = short(px);
  y1  = short(py);
  wd  = short(wx);
  ht  = short(hy);
  InitQuad();
  return;
}
Exemplo n.º 4
0
//---------------------------------------------------------------------
//  Read parameters (Read from)
//---------------------------------------------------------------------
int C_Knob::Read(SStream *stream, Tag tag)
{   switch (tag) {
    case 'fixe':
        fixe = 1;
        return TAG_READ;
    case 'file':
    case 'bmap':
        rotn.GetTexture(stream);
        return TAG_READ;

    case 'rect':
    case 'size':
    {   ReadSIZE(stream,&x1,&y1,&wd,&ht);
        InitQuad();
        return TAG_READ;
    }

    case 'posn':
        ReadPOSN(stream);
        return TAG_READ;

    case 'proj':
        ReadPROJ(stream);
        return TAG_READ;

    case 'curs':
    {   char cart[64] = {0};
        ReadString (cart, 64, stream);
        if (cart[0] == 0)	TAG_READ;
        cTag = globals->cum->BindCursor (cart);
        return TAG_READ;
    }
    case 'help':
    {   ReadString (help, 64, stream);
        return TAG_READ;
    }
    }
    return TAG_IGNORED;
}
Exemplo n.º 5
0
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	HWND hWnd;
	WNDCLASSEX wcex;

	ZeroMemory(&wcex, sizeof(WNDCLASSEX));
	wcex.cbSize = sizeof(WNDCLASSEX);
	wcex.style = CS_HREDRAW | CS_VREDRAW;
	wcex.lpszClassName = L"Snake";
	wcex.lpfnWndProc = &WindowProc;
	wcex.hInstance = hInstance;

	RegisterClassEx(&wcex);

	hWnd = CreateWindowEx(NULL,
		wcex.lpszClassName,
		wcex.lpszClassName,
		WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		NULL,
		NULL,
		hInstance,
		NULL);

	ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);

	InitGameTime();

	InitDevice(hWnd);
	InitInputDevice(hWnd);
	InitQuad();
	InitGame();

	float last = GetGameTime();

	MSG msg;
	while (true)
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE | PM_NOYIELD))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

		if (msg.message == WM_QUIT)
			break;

		float time = GetGameTime();
		float dt = (time - last);
		deltaTime = dt;
		float fps = 1 / dt;

		char title[50];
		sprintf_s(title, 50 * sizeof(char), "%f", fps);

		SetWindowTextA(hWnd, title);

		Update();
		Render();

		last = time;
	}

	Destroy();

	UnregisterClass(wcex.lpszClassName, hInstance);

	return (int) msg.wParam;
}
ECode CPathInterpolator::constructor(
    /* [in] */ Float controlX,
    /* [in] */ Float controlY)
{
    return InitQuad(controlX, controlY);
}