Ejemplo n.º 1
0
static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
                                  const PaStreamParameters *inputParameters,
                                  const PaStreamParameters *outputParameters,
                                  double sampleRate )
{
    PaMacCoreHostApiRepresentation *macCoreHostApi = (PaMacCoreHostApiRepresentation*)hostApi;
    PaDeviceInfo *deviceInfo;
    
    PaError result = paNoError;
    if (inputParameters) {
        deviceInfo = macCoreHostApi->inheritedHostApiRep.deviceInfos[inputParameters->device];
        if (inputParameters->channelCount > deviceInfo->maxInputChannels)
            result = paInvalidChannelCount;
        else if (CheckFormat(macCoreHostApi->macCoreDeviceIds[inputParameters->device], inputParameters, sampleRate, 1) != kAudioHardwareNoError) {
            result = paInvalidSampleRate;
        }
    }
    if (outputParameters && result == paNoError) {
        deviceInfo = macCoreHostApi->inheritedHostApiRep.deviceInfos[outputParameters->device];
        if (outputParameters->channelCount > deviceInfo->maxOutputChannels)
            result = paInvalidChannelCount;
        else if (CheckFormat(macCoreHostApi->macCoreDeviceIds[outputParameters->device], outputParameters, sampleRate, 0) != kAudioHardwareNoError) {
            result = paInvalidSampleRate;
        }
    }

    return result;
}
Ejemplo n.º 2
0
void EditUpload::okData()
{
  if(!CheckFormat()) {
    QMessageBox::warning(this,tr("Unsupported Format"),
			 tr("The currently selected export format is unsupported on host ")+edit_station_box->currentText()+"!");
    return;
  }
  if(QUrl::isRelativeUrl(edit_url_edit->text())||
     (edit_url_edit->text().right(1)=="/")) {
    QMessageBox::warning(this,tr("Invalid URL"),tr("The URL is invalid!"));
    return;
  }
  RDUrl url(edit_url_edit->text());
  QString protocol=url.protocol();
  if((protocol!="ftp")&&(protocol!="file")&&
     (protocol!="scp")&&(protocol!="sftp")) {
    QMessageBox::warning(this,
			 tr("Invalid URL"),tr("Unsupported URL protocol!"));
    return;
  }
  if((protocol=="file")&&(edit_username_edit->text().isEmpty())) {
    QMessageBox::warning(this,tr("Missing Username"),
			 tr("You must specify a username!"));
    return;
  }
  if(!CheckEvent(false)) {
    QMessageBox::warning(this,tr("Duplicate Event"),
		     tr("An event with these parameters already exists!"));
    return;
  }
  Save();
  done(0);
}
Ejemplo n.º 3
0
BOOL CImageImpl::Load(const char* pBuffer, long lBufSize)
{
    USE_CLASS_DATA(CLASS_DATA_MEMBER_LIST);

    Clear();

    BYTE* pBuf = const_cast<BYTE*>((BYTE*)pBuffer);
    m_pImage = new CxImage;
    m_pImage->SetRetreiveAllFrames(true);
    ENUM_CXIMAGE_FORMATS enFormat = CheckFormat(pBuf, lBufSize);
    if (! m_pImage->Decode(pBuf, lBufSize, enFormat))
    {
        Clear();
        return FALSE;
    }

    LONG lNumFrames = m_pImage->GetNumFrames();
    if (lNumFrames <= 1)
        return TRUE;

    CComPtr<IStream> spStream;
    HRESULT hr = CreateStreamOnMemory(pBuf, lBufSize, &spStream);
    if (hr != S_OK)
    {
        return FALSE;
    }

    m_pBitmap = Gdiplus::Bitmap::FromStream(spStream);
    return TRUE;
}
Ejemplo n.º 4
0
void EditUpload::stationChangedData(const QString &str)
{
  if(!CheckFormat()) {
    QMessageBox::warning(this,tr("Unsupported Format"),
			 tr("The currently selected export format is unsupported on this host!"));
  }
}
Ejemplo n.º 5
0
bool CxImage::CheckFormat(BYTE * buffer, DWORD size, DWORD imagetype)
{
	if (buffer==NULL || size==0){
		strcpy(info.szLastError,"invalid or empty buffer");
		return false;
	}
	CxMemFile file(buffer,size);
	return CheckFormat(&file,imagetype);
}
Ejemplo n.º 6
0
bool CxImage::CheckFormat(uint8_t * buffer, uint32_t size, uint32_t imagetype)
{
	if (buffer==NULL || size==0){
		strcpy(info.szLastError,"invalid or empty buffer");
		return false;
	}
	CxMemFile file(buffer,size);
	return CheckFormat(&file,imagetype);
}
Ejemplo n.º 7
0
STDMETHODIMP CamShiftTracker::SetFormat(IplImage *image_header)
{
    HRESULT hr = CheckFormat(image_header);
    if (FAILED(hr))
        return hr;

    m_image_format = *image_header;

    set_window(cvRect(0, 0, image_header->width, image_header->height));

    return NOERROR;
}
	virtual uint16 GetVersion(FName Format) const override
	{
		CheckFormat(Format);
		uint32 GLSLVersion = 0;
		if (Format == NAME_GLSL_150)
		{
			GLSLVersion  = UE_SHADER_GLSL_150_VER;
		}
		else if (Format == NAME_GLSL_150_MAC)
		{
			GLSLVersion = UE_SHADER_GLSL_150_MAC_VER;
		}
		else if (Format == NAME_GLSL_430)
		{
			GLSLVersion = UE_SHADER_GLSL_430_VER;
		}
		else if (Format == NAME_GLSL_ES2)
		{
			GLSLVersion = UE_SHADER_GLSL_ES2_VER;
		}
		else if (Format == NAME_GLSL_150_ES2)
		{
			GLSLVersion = UE_SHADER_GLSL_150ES2_VER;
		}
		else if (Format == NAME_GLSL_150_ES3_1)
		{
			GLSLVersion = UE_SHADER_GLSL_150ES3_1_VER;
		}
		else if (Format == NAME_GLSL_150_ES2_NOUB)
		{
			GLSLVersion = UE_SHADER_GLSL_150ES2NOUB_VER;
		}
		else if (Format == NAME_GLSL_ES2_WEBGL)
		{
			GLSLVersion = UE_SHADER_GLSL_ES2_VER_WEBGL;
		}
		else if (Format == NAME_GLSL_ES2_IOS)
		{
			GLSLVersion = UE_SHADER_GLSL_ES2_IOS_VER;
		}
		else if (Format == NAME_GLSL_310_ES_EXT)
		{
			GLSLVersion = UE_SHADER_GLSL_310_ES_EXT_VER;
		}
		else
		{
			check(0);
		}
		const uint8 HLSLCCVersion = ((HLSLCC_VersionMajor & 0x0f) << 4) | (HLSLCC_VersionMinor & 0x0f);
		const uint16 Version = ((HLSLCCVersion & 0xff) << 8) | (GLSLVersion & 0xff);
		return Version;
	}
Ejemplo n.º 9
0
static int CheckNativeCoreScriptFile( char* pFileName )
{
    int ret = 0, bytes;
    char buf[1024*4]= {0};
    FILE* fp = fopen( pFileName, "rb" );
    if ( fp == NULL )
        return 0;

    bytes = (int)fread( buf, 1, sizeof(buf)-1, fp );
    if ( strstr( buf, "NATIVECORE" ) || strstr( buf, "TEST_SCRIPT" ) )
    {
        ret = TEST_SCRIPT;
    } else
    {
        ret = CheckFormat( (unsigned char*)buf, bytes );
    }
    fclose( fp );
    return ret;
}
Ejemplo n.º 10
0
//! Open file in the current directory
//!
void FOpen::FileOpenCurentDir(string str) 
{
      
    #ifdef __linux__ /* Open current directory for LINUX platform */
    char buffer[1024];
    if (getcwd(buffer, sizeof(buffer)) != NULL)
       {
            string PATH(buffer);
       }
    #elif _WIN32  /* Open current directoy for Windows platform*/
    char buffer[MAX_PATH];
	  GetCurrentDirectory(sizeof(buffer),buffer);
    string PATH(buffer);
    #endif

    //! Check for compatibility
    //{

    if ( CheckFormat(str,".txt") == false  ) { cout << " Not txt format (Please write with text format)\n"; return; }

    //}

    str = PATH + "\\" + str; //! Fold path
    const char *a = str.c_str(); //! Convert string to const char *
    F.open(a,ios::in); //! open file for reading
    if(!F.is_open()) //! Check for file existence
    {
        cout << " Can't open file (Please select correct file!)" << "\n";
    }
    else
    {
        if (str.empty() == true )
        {
            cout << " Error. Empty file" << "\n";
        }
        else if( str.empty() == false )
        {
            cout << str << "\n";
            cout << " All ok!" << "\n";
        }
    }
}
Ejemplo n.º 11
0
	virtual uint16 GetVersion(FName Format) const override
	{
		CheckFormat(Format);
		if (Format == NAME_PCD3D_SM5) 
		{
			return UE_SHADER_PCD3D_SM5_VER;
		}
		else if (Format == NAME_PCD3D_SM4) 
		{
			return UE_SHADER_PCD3D_SM4_VER;
		}
		else if (Format == NAME_PCD3D_ES3_1) 
		{
			return UE_SHADER_PCD3D_ES3_1_VER;
		}
		else if (Format == NAME_PCD3D_ES2)
		{
			return UE_SHADER_PCD3D_ES2_VER;
		}
		check(0);
		return 0;
	}
Ejemplo n.º 12
0
void RenderSetupDlg::OnLbnSelchangeList()
{
	// TODO: 在此添加控件通知处理程序代码
	m_nListBoxIndex=m_pLBox->GetCurSel();
	if(m_nListBoxIndex==0)
		CheckAdapter();
	else if(m_nListBoxIndex==1)
		CheckDevtype();
	else if(m_nListBoxIndex==2)
		CheckFullscreen();
	else if(m_nListBoxIndex==3)
		CheckFormat(m_nAdapter, m_DeviceType, m_bFullScreen);
	else if(m_nListBoxIndex==4)
		CheckFormatBuffer(m_nAdapter,m_DeviceType, StringToFmt(m_strDisplayFormat),m_bFullScreen);
	else if(m_nListBoxIndex==5)
		CheckResolution(m_nAdapter,StringToFmt(m_strDisplayFormat));
	else if(m_nListBoxIndex==6)
		CheckVP(m_nAdapter, m_DeviceType);
	else if(m_nListBoxIndex==7)
		CheckPI(m_nAdapter, m_DeviceType);
	else
		DeleteAllItem(m_pBox);
}
Ejemplo n.º 13
0
BOOL CImageImpl::Load(IStream* pStream)
{
    USE_CLASS_DATA(CLASS_DATA_MEMBER_LIST);

    Clear();

    CxIStreamFile xFile(pStream);
    m_pImage = new CxImage;
    m_pImage->SetRetreiveAllFrames(true);
    ENUM_CXIMAGE_FORMATS enFormat = CheckFormat(&xFile);
    if (! m_pImage->Decode(&xFile, enFormat)) 
    {
        Clear();
        return FALSE;
    }

    LONG lNumFrames = m_pImage->GetNumFrames();
    if (lNumFrames <= 1)
        return TRUE;

    m_pBitmap = Gdiplus::Bitmap::FromStream(pStream);
    return TRUE;
}
Ejemplo n.º 14
0
	virtual void CompileShader(FName Format, const struct FShaderCompilerInput& Input, struct FShaderCompilerOutput& Output,const FString& WorkingDirectory) const
	{
		CheckFormat(Format);
		if (Format == NAME_PCD3D_SM5)
		{
			CompileShader_Windows_SM5(Input, Output, WorkingDirectory);
		}
		else if (Format == NAME_PCD3D_SM4)
		{
			CompileShader_Windows_SM4(Input, Output, WorkingDirectory);
		}
		else if (Format == NAME_PCD3D_ES2)
		{
			CompileShader_Windows_ES2(Input, Output, WorkingDirectory);
		}
		else if (Format == NAME_PCD3D_ES3_1)
		{
			CompileShader_Windows_ES3_1(Input, Output, WorkingDirectory);
		}
		else
		{
			check(0);
		}
	}
Ejemplo n.º 15
0
HRESULT CTSParserInputPin::Receive(IMediaSample * pSample)
{
    // Lock this with the receiver lock
    CAutoLock lock(m_pReceiveLock);

    // Check all is well with the base class, if not, drop it.
    HRESULT hr = CBaseInputPin::Receive(pSample);
    if(hr != S_OK)
    {
        return hr;
    }

    // Send the sample to the table processor object for processing

    CHECK_BADPTR( TEXT("invalid sample"), pSample);

    BYTE* pData = NULL;
    hr = pSample->GetPointer(&pData);
    CHECK_ERROR( TEXT("pSample->GetPointer() failed"), hr);
    CHECK_BADPTR( TEXT("invalid data point"), pData);

    long lDataLen;
    lDataLen =  pSample->GetActualDataLength();

	//we need check TS format, to setup TSDemuxer
	if ( m_bIsSagePushSource && m_pFilter->m_dwDumpedBytes == 0 )
	{
		int uInputStreamFormat = CheckFormat( pData, lDataLen );
		if ( uInputStreamFormat && uInputStreamFormat != MPEG_TS )
		{
			ChangeDemuxerTSStreamType( m_pTSRemuxer, uInputStreamFormat );
		}
	}

	//use debug data file to replace input data for debug
	if  ( m_pFilter->m_hDebugFileSource != NULL )
	{
		int lReadBytes = (long)fread( pData, 1, lDataLen, m_pFilter->m_hDebugFileSource );
		if ( feof( m_pFilter->m_hDebugFileSource ) )
			fseek(  m_pFilter->m_hDebugFileSource, 0, SEEK_SET ); //looping reading
		lDataLen = lReadBytes;
	}

	if ( !m_pFilter->m_bParserEnabled )
		return hr;

	//pass thrus data pin
	DWORD Bytes, dwLength, UsedBytes;
	BYTE *pStart;
	DWORD dwAllocSize;
	pStart = pData;
	dwLength = lDataLen;

	if (  lDataLen > 0 && m_pFilter->m_dwDumpSize && m_pFilter->GetDumpSize( &dwAllocSize ) == S_OK &&
			m_pFilter->m_dwDumpedBytes < m_pFilter->m_dwDumpSize  )
	{
		while ( dwLength > 0   )
		{
			Bytes =  dwAllocSize > dwLength ? dwLength : dwAllocSize;
			m_pFilter->DumpOut( pStart, Bytes, &UsedBytes );
			dwLength -= UsedBytes;
			pStart += UsedBytes;
		}
	}
	m_pFilter->m_dwDumpedBytes += lDataLen;

	if ( m_pFilter->m_bPassThroughEnabled  )
	{
		pStart = pData;
		dwLength = lDataLen;
		if (  m_pFilter->GetPassThroughSize( &dwAllocSize ) == S_OK )
		{
			while ( dwLength > 0  )
			{
				Bytes =  dwAllocSize > dwLength ? dwLength : dwAllocSize;
				m_pFilter->PassThrough( pStart, Bytes, &UsedBytes );
				dwLength -= UsedBytes;
				pStart += UsedBytes;
			}
		}
	}


	//Remux data to push data out
	if ( !m_bScanChannel && m_pTSRemuxer && lDataLen ) 
	{
		int nUsedBytes;
		pStart   = pData;
		dwLength = lDataLen;
		if ( m_nExpectedBytes )
		{
			int nExpectedBytes2;
			memcpy( m_cAlignBuffer+m_nAlignBytes, pStart, m_nExpectedBytes );
			nUsedBytes = PushRemuxStreamData( m_pTSRemuxer, m_cAlignBuffer, m_nAlignBytes+m_nExpectedBytes, &nExpectedBytes2 );
			if ( nExpectedBytes2 == 0 )
			{
				pStart   +=  m_nExpectedBytes;
				dwLength -=  m_nExpectedBytes;
			}
		}

		nUsedBytes = PushRemuxStreamData( m_pTSRemuxer, pStart, dwLength, &m_nExpectedBytes );
		m_nAlignBytes = dwLength - nUsedBytes;
		ASSERT( m_nExpectedBytes+m_nAlignBytes <= sizeof(m_cAlignBuffer) );
		ASSERT( m_nAlignBytes >= 0 );
		if ( m_nAlignBytes > 0 && m_nAlignBytes + m_nExpectedBytes <= sizeof(m_cAlignBuffer))
		{
			memcpy( m_cAlignBuffer, pStart+nUsedBytes, m_nAlignBytes );

		} else
		{
			//drop data, because of asking too many
			m_nExpectedBytes = 0;
		}

	}

	if ( m_bScanChannel && m_pCScan )
	{
		m_pCScan->ProcessScan( pData, lDataLen );
	}

	if ( !m_pFilter->m_bDisableClockTimeout )
	{
		DWORD dwTickMs =  clock( )*1000/CLOCKS_PER_SEC;
		UpdateClock( m_pTSRemuxer, dwTickMs );
	}

    return hr;
} 
Ejemplo n.º 16
0
int main(int argc, char **argv){
	if(argc < 2){
		Usage(argv[0]);
		return(0);
	}
	// usage begin
	int option = 0;
	char optgot;
		// usage end
	int i, file_len;
	FILE *f;
	unsigned char *buffer;
	
	while ((option = getopt(argc, argv, "h:a:I:s:n:N:S:f:c:")) != -1){
		switch(option){
			case 'a':
				printf("file name inserted is %s\n", optarg);
				f = fopen(optarg, "rb");
				// now printing file size
				fseek(f, 0, SEEK_END);
				file_len = ftell(f);
				fseek(f, 0, SEEK_SET);
				printf("file size: %d KB\n", file_len / 1024);
				buffer = (unsigned char *)malloc(file_len); //allocate
				// now time to read the contents of the file
				fread(buffer, file_len, 1, f);
				CheckFormat(buffer, 'a', DEFAULT, DEFAULT2, DEFAULT3);
				free(buffer);
				fclose(f);
				break;
			case 'I':
				printf("file name inserted is %s\n", optarg);
				f = fopen(optarg, "rb");
				// now printing file size
				fseek(f, 0, SEEK_END);
				file_len = ftell(f);
				fseek(f, 0, SEEK_SET);
				printf("file size: %d bytes\n", file_len);
				buffer = (unsigned char *)malloc(file_len); //allocate
				// now time to read the contents of the file
				fread(buffer, file_len, 1, f);
				CheckFormat(buffer, 'I', DEFAULT, DEFAULT2, DEFAULT3);
				fclose(f);
				break;
			case 's':
				printf("file name inserted is %s\n", optarg);
				f = fopen(optarg, "rb");
				// now printing file size
				fseek(f, 0, SEEK_END);
				file_len = ftell(f);
				fseek(f, 0, SEEK_SET);
				printf("file size: %d bytes\n", file_len);
				buffer = (unsigned char *)malloc(file_len); //allocate
				// now time to read the contents of the file
				fread(buffer, file_len, 1, f);
				CheckFormat(buffer, 's', DEFAULT, DEFAULT2, DEFAULT3);
				fclose(f);
				break;
			case 'n':
				if(argc < 4){
					printf("option not completed -n <section name> <filename>\n");
					exit(-1);
				}
				printf("file name inserted is %s\n", argv[3]);
				f = fopen(argv[3], "rb");
				// now printing file size
				fseek(f, 0, SEEK_END);
				file_len = ftell(f);
				fseek(f, 0, SEEK_SET);
				printf("file size: %d bytes\n", file_len);
				buffer = (unsigned char *)malloc(file_len); //allocate
				// now time to read the contents of the file
				fread(buffer, file_len, 1, f);
				// printf("you choosed option with arg %s, %s", optarg, argv[3]);
				CheckFormat(buffer, 'n', optarg, DEFAULT2, DEFAULT3);
				fclose(f);
				break;
			case 'N':
				if(argc < 4){
					printf("option not completed -N <section name> <filename>\n");
					exit(-1);
				}
				printf("file name inserted is %s\n", argv[3]);
				f = fopen(argv[3], "rb");
				// now printing file size
				fseek(f, 0, SEEK_END);
				file_len = ftell(f);
				fseek(f, 0, SEEK_SET);
				printf("file size: %d bytes\n", file_len);
				buffer = (unsigned char *)malloc(file_len); //allocate
				// now time to read the contents of the file
				fread(buffer, file_len, 1, f);
				// printf("you choosed option with arg %s, %s", optarg, argv[3]);
				CheckFormat(buffer, 'N', optarg, DEFAULT2, DEFAULT3);
				fclose(f);
				break;
			case 'S':
				if(argc < 4){
					printf("option not completed -S <section name> <filename>\n");
					exit(-1);
				}
				printf("file name inserted is %s\n", argv[3]);
				f = fopen(argv[3], "rb");
				// now printing file size
				fseek(f, 0, SEEK_END);
				file_len = ftell(f);
				fseek(f, 0, SEEK_SET);
				printf("file size: %d bytes\n", file_len);
				buffer = (unsigned char *)malloc(file_len); //allocate
				// now time to read the contents of the file
				fread(buffer, file_len, 1, f);
				// printf("you choosed option with arg %s, %s", optarg, argv[3]);
				CheckFormat(buffer, 'S', optarg, DEFAULT2, DEFAULT3);
				fclose(f);
				break;
			case 'f':
				f = fopen(optarg, "rb");
				// // now printing file size
				fseek(f, 0, SEEK_END);
				file_len = ftell(f);
				fseek(f, 0, SEEK_SET);
				printf("file size: %d KB\n", file_len / 1024);
				buffer = (unsigned char *)malloc(file_len); //allocate
				// // now time to read the contents of the file
				fread(buffer, file_len, 1, f);
				CheckFormat(buffer, 'f', optarg, file_len, DEFAULT3);
				free(buffer);
				fclose(f);
				// fclose(fopdis);
				break;
			case 'c':
				if(argc < 4){
					printf("option not completed -c <offset> <length> <filename>\n");
					exit(-1);
				}
				printf("file name inserted is %s\n", argv[4]);
				f = fopen(argv[4], "rb");
				// now printing file size
				fseek(f, 0, SEEK_END);
				file_len = ftell(f);
				fseek(f, 0, SEEK_SET);
				printf("file size: %d bytes\n", file_len);
				buffer = (unsigned char *)malloc(file_len); //allocate
				// now time to read the contents of the file
				fread(buffer, file_len, 1, f);
				// printf("you choosed option with arg %s, %s", optarg, argv[3]);
				CheckFormat(buffer, 'c', optarg, DEFAULT2, argv[3]);
				fclose(f);
				break;
			default:
				Usage(argv[0]);
				// printf("Please Choose nicely\n");
				exit(-1);
		}
	}
	return(-1);
}
Ejemplo n.º 17
0
BOOL cGraphics::SetMode(HWND hWnd, BOOL Windowed, BOOL UseZBuffer, long Width, long Height, char BPP)
{
  D3DPRESENT_PARAMETERS d3dpp;
  D3DFORMAT             Format, AltFormat;
  RECT                  WndRect, ClientRect;
  long                  WndWidth, WndHeight;
  float                 Aspect;

  // Error checking
  if((m_hWnd = hWnd) == NULL)
    return FALSE;
  if(m_pD3D == NULL)
    return FALSE;

  // Get the current display format
  if(FAILED(m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &m_d3ddm)))
    return FALSE;

  // Configure width
  if(!Width) {
    // Default to screen width if fullscreen
    if(Windowed == FALSE) {
      m_Width = m_d3ddm.Width;
    } else {
      // Otherwise grab from client size
      GetClientRect(m_hWnd, &ClientRect);
      m_Width = ClientRect.right;
    }
  } else {
    m_Width = Width;
  }

  // Configure height
  if(!Height) {
    // Default to screen height if fullscreen
    if(Windowed == FALSE) {
      m_Height = m_d3ddm.Height;
    } else {
      // Otherwise grab from client size
      GetClientRect(m_hWnd, &ClientRect);
      m_Height = ClientRect.bottom;
    }
  } else {
    m_Height = Height;
  }

  // Configure BPP
  if(!(m_BPP = BPP) || Windowed == TRUE) {
    if(!(m_BPP = GetFormatBPP(m_d3ddm.Format)))
      return FALSE;
  }

  // Resize client window if using windowed mode
  if(Windowed == TRUE) {
    GetWindowRect(m_hWnd, &WndRect);
    GetClientRect(m_hWnd, &ClientRect);

    WndWidth  = (WndRect.right  - (ClientRect.right  - m_Width))  - WndRect.left;
    WndHeight = (WndRect.bottom - (ClientRect.bottom - m_Height)) - WndRect.top;

    MoveWindow(m_hWnd, WndRect.left, WndRect.top, WndWidth, WndHeight, TRUE);
  }

  // Clear presentation structure
  ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS));
  
  // Default to no hardware acceleration detected
  m_HAL = FALSE;

  // Setup Windowed or fullscreen usage
  if((m_Windowed = Windowed) == TRUE) {
    d3dpp.Windowed         = TRUE;
    d3dpp.SwapEffect       = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = m_d3ddm.Format;

    // See if card supports HAL
    if(CheckFormat(m_d3ddm.Format, TRUE, TRUE) == TRUE) {
      m_HAL = TRUE;
    } else {
      // Return error if not emulated
      if(CheckFormat(m_d3ddm.Format, TRUE, FALSE) == FALSE)
        return FALSE;
    }
  } else {
    d3dpp.Windowed   = FALSE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP;
  
    d3dpp.BackBufferWidth  = m_Width;
    d3dpp.BackBufferHeight = m_Height;
    d3dpp.FullScreen_RefreshRateInHz      = D3DPRESENT_RATE_DEFAULT;
    d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; // or D3DPRESENT_INTERVAL_DEFAULT or D3DPRESENT_INTERVAL_IMMEDIATE

    // Figure display format to use
    if(m_BPP == 32) {
      Format    = D3DFMT_X8R8G8B8;
      AltFormat = D3DFMT_X8R8G8B8;
    }
    if(m_BPP == 24) {
      Format    = D3DFMT_R8G8B8;
      AltFormat = D3DFMT_R8G8B8;
    }
    if(m_BPP == 16) {
      Format    = D3DFMT_R5G6B5;
      AltFormat = D3DFMT_X1R5G5B5;
    }
    if(m_BPP == 8) {
      Format    = D3DFMT_P8;
      AltFormat = D3DFMT_P8;
    }

    // Check for HAL device
    if(CheckFormat(Format, FALSE, TRUE) == TRUE) {
      m_HAL = TRUE;
    } else {
      // Check for HAL device in alternate format
      if(CheckFormat(AltFormat, FALSE, TRUE) == TRUE) {
        m_HAL = TRUE;
        Format = AltFormat;
      } else {
        // Check for Emulation device
        if(CheckFormat(Format, FALSE, FALSE) == FALSE) {
          // Check for Emulation device in alternate format
          if(CheckFormat(AltFormat, FALSE, FALSE) == FALSE)
            return FALSE;
          else
            Format = AltFormat;
        }
      }
    }

    d3dpp.BackBufferFormat = Format;
  }

  // Setup Zbuffer format - 16 bit
  if((m_ZBuffer = UseZBuffer) == TRUE) {
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
  } else {
    d3dpp.EnableAutoDepthStencil = FALSE;
  }

  // Create the Direct3D Device object
  if(FAILED(m_pD3D->CreateDevice(D3DADAPTER_DEFAULT, 
               (m_HAL == TRUE) ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF, 
               hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,
               &d3dpp, &m_pD3DDevice))) {

    // Try to create Direct3D without ZBuffer support 
    // if selected and first call failed.
    if(m_ZBuffer == TRUE) {
      m_ZBuffer = FALSE;
      d3dpp.EnableAutoDepthStencil = FALSE;

      if(FAILED(m_pD3D->CreateDevice(D3DADAPTER_DEFAULT, 
                   (m_HAL == TRUE) ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF, 
                   hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                   &d3dpp, &m_pD3DDevice)))
        return FALSE;
    } else                                   
      return FALSE;
  }

	//// create and set the render target surface
 //   // it should be lockable on XP and nonlockable on Vista
 //   if (FAILED(m_pD3DDevice->CreateRenderTarget(m_Width, m_Height, 
 //       D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, 
 //       TRUE, // lockable
 //       &m_pD3DSurface, NULL)))
 //   {
 //       return FALSE;
 //   }
 //   //m_pD3DDevice->SetRenderTarget(0, m_pD3DSurface);

  // Set default rendering states
  EnableLighting(FALSE);
  EnableZBuffer(m_ZBuffer);
  EnableAlphaBlending(FALSE);
  EnableAlphaTesting(FALSE);

  // Enable texture rendering stages and filter types
  m_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
  m_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
  m_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );

  m_pD3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
  m_pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);

  // Set default ambient color to white
  SetAmbientLight(255,255,255);

  // Calculate the aspect ratio based on window size
  Aspect = (float)m_Height / (float)m_Width;
  SetPerspective(D3DX_PI/4, Aspect, 1.0f, 10000.0f);

  // Create a sprite interface
  if(FAILED(D3DXCreateSprite(m_pD3DDevice, &m_pSprite)))
    return FALSE;

  return TRUE;
}
	virtual void CompileShader(FName Format, const struct FShaderCompilerInput& Input, struct FShaderCompilerOutput& Output,const FString& WorkingDirectory) const override
	{
		CheckFormat(Format);

		if (Format == NAME_GLSL_150)
		{
			CompileShader_Windows_OGL(Input, Output, WorkingDirectory, GLSL_150);
		}
		else if (Format == NAME_GLSL_150_MAC)
		{
			CompileShader_Windows_OGL(Input, Output, WorkingDirectory, GLSL_150_MAC);
		}
		else if (Format == NAME_GLSL_430)
		{
			CompileShader_Windows_OGL(Input, Output, WorkingDirectory, GLSL_430);
		}
		else if (Format == NAME_GLSL_ES2)
		{
			CompileShader_Windows_OGL(Input, Output, WorkingDirectory, GLSL_ES2);

			if (Input.DumpDebugInfoPath != TEXT("") && IFileManager::Get().DirectoryExists(*Input.DumpDebugInfoPath))
			{
				FShaderCompilerInput ES2Input = Input;
				ES2Input.DumpDebugInfoPath = ES2Input.DumpDebugInfoPath.Replace(TEXT("GLSL_150_ES2"), TEXT("GLSL_ES2"), ESearchCase::CaseSensitive);
				if (!IFileManager::Get().DirectoryExists(*ES2Input.DumpDebugInfoPath))
				{
					verifyf(IFileManager::Get().MakeDirectory(*ES2Input.DumpDebugInfoPath, true), TEXT("Failed to create directory for shader debug info '%s'"), *ES2Input.DumpDebugInfoPath);
				}

				FShaderCompilerOutput ES2Output;
				CompileShader_Windows_OGL(ES2Input, ES2Output, WorkingDirectory, GLSL_ES2);
			}

		}
		else if (Format == NAME_GLSL_ES2_WEBGL )
		{
			 CompileShader_Windows_OGL(Input, Output, WorkingDirectory, GLSL_ES2_WEBGL);
		}
		else if (Format == NAME_GLSL_ES2_IOS )
		{
			CompileShader_Windows_OGL(Input, Output, WorkingDirectory, GLSL_ES2_IOS);
		}
		else if (Format == NAME_GLSL_150_ES3_1)
		{
			CompileShader_Windows_OGL(Input, Output, WorkingDirectory, GLSL_150_ES3_1);
		}
		else if (Format == NAME_GLSL_150_ES2_NOUB)
		{
			CompileShader_Windows_OGL(Input, Output, WorkingDirectory, GLSL_150_ES2_NOUB);
		}
		else if (Format == NAME_GLSL_150_ES2)
		{
			CompileShader_Windows_OGL(Input, Output, WorkingDirectory, GLSL_150_ES2);

			if (Input.DumpDebugInfoPath != TEXT("") && IFileManager::Get().DirectoryExists(*Input.DumpDebugInfoPath))
			{
				FShaderCompilerInput ES2Input = Input;
				ES2Input.DumpDebugInfoPath = ES2Input.DumpDebugInfoPath.Replace(TEXT("GLSL_150_ES2"), TEXT("GLSL_ES2_150"), ESearchCase::CaseSensitive);
				if (!IFileManager::Get().DirectoryExists(*ES2Input.DumpDebugInfoPath))
				{
					verifyf(IFileManager::Get().MakeDirectory(*ES2Input.DumpDebugInfoPath, true), TEXT("Failed to create directory for shader debug info '%s'"), *ES2Input.DumpDebugInfoPath);
				}

				FShaderCompilerOutput ES2Output;
				CompileShader_Windows_OGL(ES2Input, ES2Output, WorkingDirectory, GLSL_ES2);
			}
		}
		else if (Format == NAME_GLSL_310_ES_EXT)
		{
			CompileShader_Windows_OGL(Input, Output, WorkingDirectory, GLSL_310_ES_EXT);
		}
		else
		{
			check(0);
		}
	}