Example #1
0
void CALL HGE_Impl::System_SetStateBool(hgeBoolState state, bool value)
{
	switch(state)
	{
		case HGE_WINDOWED:		if(VertArray || hwndParent) break;
								if(pD3DDevice && bWindowed != value)
								{
									if(d3dppW.BackBufferFormat==D3DFMT_UNKNOWN || d3dppFS.BackBufferFormat==D3DFMT_UNKNOWN) break;

									if(bWindowed) GetWindowRect(hwnd, &rectW);
									bWindowed=value;
									if(bWindowed) d3dpp=&d3dppW;
									else d3dpp=&d3dppFS;

									if(_format_id(d3dpp->BackBufferFormat) < 4) nScreenBPP=16;
									else nScreenBPP=32;

									_GfxRestore();
									_AdjustWindow();
								}
								else bWindowed=value;
								break;

		case HGE_ZBUFFER:		if(!pD3DDevice)	bZBuffer=value;
								break;

		case HGE_TEXTUREFILTER: bTextureFilter=value;
								if(pD3DDevice)
								{
									_render_batch();
									if(bTextureFilter)
									{
										pD3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
										pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
									}
									else
									{
										pD3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
										pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
									}
								}
								break;

		case HGE_USESOUND:		if(bUseSound!=value)
								{
									bUseSound=value;
									if(bUseSound && hwnd) _SoundInit();
									if(!bUseSound && hwnd) _SoundDone();
								}
								break;

		case HGE_HIDEMOUSE:		bHideMouse=value; break;

		case HGE_DONTSUSPEND:	bDontSuspend=value; break;

		#ifdef DEMO
		case HGE_SHOWSPLASH:	bDMO=value; break;
		#endif
	}
}
Example #2
0
void HGE_Impl::_FocusChange(bool bAct) {
	bActive=bAct;
	if(bActive) {
		_GfxRestore();
		if(procFocusGainFunc) procFocusGainFunc();
	}
	else {
		if(procFocusLostFunc) procFocusLostFunc();
	}
}
Example #3
0
void CALL HGE_Impl::System_SetStateInt(hgeIntState state, int value)
{
	switch(state)
	{
		case HGE_SCREENWIDTH:	if(!pD3DDevice) nScreenWidth=value; break;

		case HGE_SCREENHEIGHT:	if(!pD3DDevice) nScreenHeight=value; break;

		case HGE_SCREENBPP:		if(!pD3DDevice) nScreenBPP=value; break;

		case HGE_SAMPLERATE:	if(!hBass) nSampleRate=value;
								break;

		case HGE_FXVOLUME:		nFXVolume=value;
								_SetFXVolume(nFXVolume);
								break;

		case HGE_MUSVOLUME:		nMusVolume=value;
								_SetMusVolume(nMusVolume);
								break;

		case HGE_STREAMVOLUME:	nStreamVolume=value;
								_SetStreamVolume(nStreamVolume);
								break;

		case HGE_FPS:			if(VertArray) break;

								if(pD3DDevice)
								{
									if((nHGEFPS>=0 && value <0) || (nHGEFPS<0 && value>=0))
									{
										if(value==HGEFPS_VSYNC)
										{
											d3dppW.SwapEffect = D3DSWAPEFFECT_COPY;
											d3dppW.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
											d3dppFS.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
										}
										else
										{
											d3dppW.SwapEffect = D3DSWAPEFFECT_COPY;
											d3dppFS.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
										}
										//if(procFocusLostFunc) procFocusLostFunc();
										_GfxRestore();
										//if(procFocusGainFunc) procFocusGainFunc();
									}
								}
								nHGEFPS=value;
								if(nHGEFPS>0) nFixedDelta=int(1000.0f/value);
								else nFixedDelta=0;
								break;
	}
}
Example #4
0
void HGE_Impl::_Resize(int width, int height)
{
	if (hwndParent)
	{
		//if(procFocusLostFunc) procFocusLostFunc();

		//d3dppW.BufferDesc.Width = width;
		//d3dppW.BufferDesc.Height = height;
		nScreenWidth = width;
		nScreenHeight = height;

		_SetProjectionMatrix(nScreenWidth, nScreenHeight);
		_GfxRestore();

		//if(procFocusGainFunc) procFocusGainFunc();
	}
}
Example #5
0
bool CALL HGE_Impl::Gfx_BeginScene(HTARGET targ)
{
    LPDIRECT3DSURFACE8 pSurf=0, pDepth=0;
    D3DDISPLAYMODE Mode;
    CRenderTargetList *target=(CRenderTargetList *)targ;

    //
    // Test if we currently have access to the 3D surface
    // When not, for example because we lost focus, return false and try again later.
    // When we just got it back, restore some stuff
    //
    HRESULT hr = pD3DDevice->TestCooperativeLevel();
    if (hr == D3DERR_DEVICELOST) return false;
    else if (hr == D3DERR_DEVICENOTRESET)
    {
        if(bWindowed)
        {
            if(FAILED(pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &Mode)) || Mode.Format==D3DFMT_UNKNOWN) 
            {
                _PostError("Can't determine desktop video mode");
                return false;
            }

            d3dppW.BackBufferFormat = Mode.Format;
            if(_format_id(Mode.Format) < 4) nScreenBPP=16;
            else nScreenBPP=32;
        }

        if(!_GfxRestore()) return false; 
    }

    //
    // Sanity check, make sure we're not alreay busy drawing a scene
    //
    if(VertArray)
    {
        _PostError("Gfx_BeginScene: Scene is already being rendered");
        return false;
    }
    
    if(target != pCurTarget)
    {
        if(target)
        {
            target->pTex->GetSurfaceLevel(0, &pSurf);
            pDepth=target->pDepth;
        }
        else
        {
            pSurf=pScreenSurf;
            pDepth=pScreenDepth;
        }
        if(FAILED(pD3DDevice->SetRenderTarget(pSurf, pDepth)))
        {
            if(target) pSurf->Release();
            _PostError("Gfx_BeginScene: Can't set render target");
            return false;
        }
        if(target)
        {
            pSurf->Release();
            if(target->pDepth) pD3DDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE ); 
            else pD3DDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE ); 
            _SetProjectionMatrix(target->width, target->height);
        }
        else
        {
            if(bZBuffer) pD3DDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE ); 
            else pD3DDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );
            _SetProjectionMatrix(nScreenWidth, nScreenHeight);
        }

#ifdef UNDER_CE
        pD3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMMATRIX*)&matProj, D3DMFMT_D3DMVALUE_FLOAT);
        pD3DDevice->SetTransform(D3DTS_VIEW, (D3DMMATRIX*)&matView, D3DMFMT_D3DMVALUE_FLOAT);
#else
        pD3DDevice->SetTransform(D3DTS_PROJECTION, &matProj);
        pD3DDevice->SetTransform(D3DTS_VIEW, &matView);
#endif
        D3DXMatrixIdentity(&matView);

        pCurTarget=target;
    }

    pD3DDevice->BeginScene();
#ifdef UNDER_CE
    pVB->Lock( 0, 0, (void**)&VertArray, 0 );
#else
    pVB->Lock( 0, 0, (BYTE**)&VertArray, 0 );
#endif
    return true;
}