예제 #1
0
void CreateD3DDevice()
{
	ZeroMemory( &g_D3DParams, sizeof( g_D3DParams ) );

	RECT ClientRect;
	GetClientRect( g_pHWND, &ClientRect );

	g_D3DParams.Windowed = TRUE;
	g_D3DParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
	g_D3DParams.BackBufferWidth = ClientRect.right;
	g_D3DParams.BackBufferHeight = ClientRect.bottom;
	g_D3DParams.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
	g_D3DParams.BackBufferFormat = D3DFMT_X8R8G8B8;
	//g_D3DParams.EnableAutoDepthStencil = TRUE;
	//g_D3DParams.AutoDepthStencilFormat = D3DFMT_D24S8;
	g_D3DParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

	HRESULT hr = g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_pHWND, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &g_D3DParams, &g_pD3DDevice );
	if ( FAILED(hr) )
	{
		OutputDebugString( DXGetErrorDescription( hr ) );
		return;
	}
}
예제 #2
0
//-----------------------------------------------------------------------------
// Name: InitD3D()
// Desc: Initializes Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
    // Create the D3D object.
    if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
        return E_FAIL;

    // Set up the structure used to create the D3DDevice. Since we are now
    // using more complex geometry, we will create a device with a zbuffer.
    D3DPRESENT_PARAMETERS d3dpp;
    //ZeroMemory( &d3dpp, sizeof( d3dpp ) );
	vp_os_memset(&d3dpp, 0, sizeof( d3dpp ));
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

    // Create the D3DDevice
    if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                      &d3dpp, &g_pd3dDevice ) ) )
    {
        return E_FAIL;
    }

    // Turn off culling
    g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );

    // Turn off D3D lighting
    g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );

    // Turn on the zbuffer
    g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );

    return S_OK;
}
예제 #3
0
HRESULT InitD3D( HWND hWnd )
{
    // Create the D3D object, which is needed to create the D3DDevice.
    if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
    {
        MessageBoxA(NULL, "Create D3D9 object failed!", "Error", 0) ;
        return E_FAIL;
    }

    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory( &d3dpp, sizeof(d3dpp) );

    d3dpp.Windowed = TRUE; // use window mode, not full screen
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;

    // Create device
    if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                      &d3dpp, &g_pd3dDevice ) ) )
    {
        MessageBoxA(NULL, "Create D3D9 device failed!", "Error", 0) ;
        return E_FAIL;
    }

    // Disable lighting, since we didn't specify color for vertex
    g_pd3dDevice->SetRenderState( D3DRS_LIGHTING , FALSE );

    // Create teapot
    D3DXCreateTeapot(g_pd3dDevice, &g_pMesh, NULL) ;

    // Create camera
    g_Camera = new FirstPersonViewCamera() ;

    return S_OK;
}
예제 #4
0
void Cleanup()
{
    if (g_pMeshMaterials)
        delete[] g_pMeshMaterials;

    if (g_pMeshTextures)
    {
        for (DWORD i = 0; i < g_dwNumMaterials; i++)
        {
            if (g_pMeshTextures[i])
                g_pMeshTextures[i]->Release();
        }
        delete[] g_pMeshTextures;
    }

    if (g_pMesh)
        g_pMesh->Release();

    if (g_pd3dDevice)
        g_pd3dDevice->Release();

    if (g_pD3D)
        g_pD3D->Release();
}
예제 #5
0
///Create Direct3D Device
HRESULT initD3D(HWND hWnd){

	if(NULL == (g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
		return E_FAIL;
	D3DPRESENT_PARAMETERS d3dpp;
	ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS));
	d3dpp.Windowed = TRUE;
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
	d3dpp.EnableAutoDepthStencil = TRUE;
	d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

	if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
		D3DCREATE_HARDWARE_VERTEXPROCESSING,
		&d3dpp, &g_pDevice ) ) ){
			return E_FAIL;
	}

	g_pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	g_pDevice->SetRenderState(D3DRS_ZENABLE, TRUE);//default is open

	setupViewProjMatrix();
	return S_OK;
}
예제 #6
0
파일: d2.cpp 프로젝트: anokata/AllInOne
// this function initializes and prepares Direct3D for use
void initD3D(HWND hWnd)
{
    d3d = Direct3DCreate9(D3D_SDK_VERSION);

    D3DPRESENT_PARAMETERS d3dpp;

    ZeroMemory(&d3dpp, sizeof(d3dpp));
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.hDeviceWindow = hWnd;
    d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
    d3dpp.BackBufferWidth = SCREEN_WIDTH;
    d3dpp.BackBufferHeight = SCREEN_HEIGHT;

    // create a device class using this information and the info from the d3dpp stuct
    d3d->CreateDevice(D3DADAPTER_DEFAULT,
                      D3DDEVTYPE_HAL,
                      hWnd,
                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                      &d3dpp,
                      &d3ddev);

    init_graphics();    // call the function to initialize the triangle
}
예제 #7
0
//-----------------------------------------------------------------------------
// Name: Cleanup()
// Desc: Releases all previously initialized objects
//-----------------------------------------------------------------------------
VOID Cleanup()
{
	// release all textures used
	if ( g_pTexture != NULL )
		g_pTexture->Release();

	if ( g_pTexture2 != NULL )
		g_pTexture2->Release();

	if ( marbleTexture != NULL )
		marbleTexture->Release();

	if ( backgroundTexture != NULL )
		backgroundTexture->Release();

	if( g_pMeshMaterials != NULL ) 
		delete[] g_pMeshMaterials;

	if( g_pMeshTextures )
	{
		for( DWORD i = 0; i < g_dwNumMaterials; i++ )
		{
			if( g_pMeshTextures[i] )
				g_pMeshTextures[i]->Release();
		}
		delete[] g_pMeshTextures;
	}
	if( g_pMesh != NULL )
		g_pMesh->Release();

	if( g_pd3dDevice != NULL )
		g_pd3dDevice->Release();

	if( g_pD3D != NULL )
		g_pD3D->Release();
}
예제 #8
0
bool Direct3D_Init(HWND window, int width, int height, bool fullscreen)
{
    //initialize Direct3D
    d3d = Direct3DCreate9(D3D_SDK_VERSION);
    if (!d3d) return false;

    //set Direct3D presentation parameters
    D3DPRESENT_PARAMETERS d3dpp; 
    ZeroMemory(&d3dpp, sizeof(d3dpp));
    d3dpp.hDeviceWindow = window;
    d3dpp.Windowed = (!fullscreen);
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.EnableAutoDepthStencil = 1;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
    d3dpp.Flags = D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL;
    d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
    d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
    d3dpp.BackBufferCount = 1;
    d3dpp.BackBufferWidth = width;
    d3dpp.BackBufferHeight = height;

    //create Direct3D device
    d3d->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window,
        D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
    if (!d3ddev) return false;


    //get a pointer to the back buffer surface
    d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);


    //create sprite object
    D3DXCreateSprite(d3ddev, &spriteobj);

    return 1;
}
예제 #9
0
VOID cleanup(){
	if(g_pMeshMaterials != NULL)
		delete [] g_pMeshMaterials;

	if(g_pMeshTextures){
		for(DWORD i=0; i<g_dwNumMaterials; ++i){
			if(g_pMeshTextures[i])
				g_pMeshTextures[i]->Release();
		}
		delete [] g_pMeshTextures;
	}

	if(g_pMesh != NULL)
		g_pMesh->Release();

	if(g_pShutter != NULL)
		g_pShutter->Release();

	if(g_pDevice != NULL)
		g_pDevice->Release();

	if(g_pD3D != NULL)
		g_pD3D->Release();
}
예제 #10
0
HRESULT InitD3D( HWND hWnd )
{
    g_pD3D = Direct3DCreate9( D3D_SDK_VERSION );

    if( !g_pD3D ) return E_FAIL;

    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory( &d3dpp, sizeof(d3dpp) );
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;

    if( FAILED( g_pD3D->CreateDevice( 
                    D3DADAPTER_DEFAULT,
                    D3DDEVTYPE_HAL,
                    hWnd,
                    D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                    &d3dpp, &g_pd3dDevice ) ) )
    {
        return E_FAIL;
    }

    return S_OK;
}
예제 #11
0
//-----------------------------------------------------------------------------
// Name: Cleanup()
// Desc: Releases all previously initialized objects
//-----------------------------------------------------------------------------
VOID Cleanup()
{
	if( g_pMeshMaterials != NULL )
		delete[] g_pMeshMaterials;
	if( g_pMeshMaterials2 != NULL )
		delete[] g_pMeshMaterials2;

	if( g_pMeshTextures )
	{
		for( DWORD i = 0; i < g_dwNumMaterials; i++ )
		{
			if( g_pMeshTextures[i] )
				g_pMeshTextures[i]->Release();
		}
		delete[] g_pMeshTextures;
	}
	if( g_pMeshTextures2 )
	{
		for( DWORD i = 0; i < g_dwNumMaterials2; i++ )
		{
			if( g_pMeshTextures2[i] )
				g_pMeshTextures2[i]->Release();
		}
		delete[] g_pMeshTextures2;
	}
	if( g_pMesh != NULL )
		g_pMesh->Release();
	
	if( g_pMesh2 != NULL )
		g_pMesh2->Release();
	if( g_pd3dDevice != NULL )
		g_pd3dDevice->Release();

	if( g_pD3D != NULL )
		g_pD3D->Release();
}
예제 #12
0
HRESULT HookIDirect3D9::CreateDevice(LPVOID _this, UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface)
{

	LOG_API();
#if 1
	HRESULT res = 0;
#if 0
	if (configMgr.GetConfig(TTX_CONFIG_WINDOWED))
	{

		D3DPRESENT_PARAMETERS d3dpp;
		RECT rect;

		ShowWindow(hFocusWindow, SW_HIDE);
		GetClientRect(hFocusWindow, &rect);
		AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
		SetWindowLong(hFocusWindow, GWL_STYLE, WS_OVERLAPPEDWINDOW);
		SetWindowPos(hFocusWindow, HWND_TOPMOST, 100, 100, rect.right, rect.bottom, SWP_FRAMECHANGED | SWP_NOCOPYBITS);
		ShowWindow(hFocusWindow, SW_SHOWNORMAL);
		ShowCursor(TRUE);
		InvalidateRect(hFocusWindow, NULL, TRUE);

		logmsg("--%d,%d,%d,%d\n", rect.left,rect.top,rect.right,rect.bottom);

		ZeroMemory(&d3dpp, sizeof(d3dpp));


		GetClientRect(pPresentationParameters->hDeviceWindow, &rect);

		logmsg("Area = %d,%d\n", pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);
		d3dpp.BackBufferHeight = pPresentationParameters->BackBufferHeight;
		d3dpp.BackBufferWidth = pPresentationParameters->BackBufferWidth;
		d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
		d3dpp.BackBufferFormat = pPresentationParameters->BackBufferFormat;
		d3dpp.BackBufferCount = pPresentationParameters->BackBufferCount;
		d3dpp.Windowed = TRUE;
		d3dpp.hDeviceWindow = NULL;//pPresentationParameters->hDeviceWindow;
		d3dpp.FullScreen_RefreshRateInHz = 0;
		d3dpp.PresentationInterval = pPresentationParameters->PresentationInterval;
		d3dpp.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
		d3dpp.Flags = pPresentationParameters->Flags;
		d3dpp.EnableAutoDepthStencil = TRUE;


		res = pD3D->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, &d3dpp, &pD3Dev);
	} else 
#endif
		logmsg("RES %dx%d\n", pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);
		//pPresentationParameters->BackBufferWidth = 1920;
		//pPresentationParameters->BackBufferHeight = 1080;
		res = pD3D->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, &pD3Dev);
	if (FAILED(res)) {
		logmsg("Err = %X\n", res);
		MessageBox(hFocusWindow, DXGetErrorDescriptionA(res), "Erro Direct3D", MB_OK);
		*ppReturnedDeviceInterface = NULL;
	} else {
		*ppReturnedDeviceInterface = (IDirect3DDevice9*) pD3DevWrapper;
	}

	return res;
#else
	return pD3D->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
#endif
}
예제 #13
0
HMONITOR HookIDirect3D9::GetAdapterMonitor(LPVOID _this, UINT Adapter)
{
	LOG_API();
	return pD3D->GetAdapterMonitor(Adapter);
}
예제 #14
0
HRESULT HookIDirect3D9::GetDeviceCaps(LPVOID _this, UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps)
{
	LOG_API();
	return pD3D->GetDeviceCaps(Adapter, DeviceType, pCaps);
}
예제 #15
0
HRESULT HookIDirect3D9::CheckDeviceFormatConversion(LPVOID _this, UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SourceFormat,D3DFORMAT TargetFormat)
{
	LOG_API();
	return pD3D->CheckDeviceFormatConversion(Adapter, DeviceType, SourceFormat, TargetFormat);
}
예제 #16
0
HRESULT HookIDirect3D9::GetAdapterDisplayMode(LPVOID _this, UINT Adapter,D3DDISPLAYMODE* pMode)
{
	LOG_API();
	return pD3D->GetAdapterDisplayMode(Adapter, pMode);
}
예제 #17
0
UINT HookIDirect3D9:: GetAdapterModeCount(LPVOID _this, UINT Adapter,D3DFORMAT Format)
{
	LOG_API();
	return pD3D->GetAdapterModeCount(Adapter, Format);
}
예제 #18
0
UINT HookIDirect3D9:: GetAdapterCount(LPVOID _this)
{
	LOG_API();
	return pD3D->GetAdapterCount();
}
예제 #19
0
ULONG HookIDirect3D9::Release(LPVOID _this)
{
	LOG_API();
	return pD3D->Release();
}
예제 #20
0
HRESULT HookIDirect3D9::QueryInterface(LPVOID _this, REFIID riid,LPVOID *ppvObj)
{
	LOG_API();
	return pD3D->QueryInterface(riid, ppvObj);
}
예제 #21
0
ULONG HookIDirect3D9::AddRef(LPVOID _this)
{
	LOG_API();
	return pD3D->AddRef();
}
예제 #22
0
bool InitialiseDirectX()
{
    const D3DFORMAT backBufferFormat = D3DFMT_D16;
    const D3DFORMAT textureFormat = D3DFMT_A8R8G8B8;

    if(FAILED(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
    {
        ShowMessageBox("Direct3D interface creation has failed");
        return false;
    }

    // Build present params
    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory(&d3dpp, sizeof(d3dpp));

    D3DMULTISAMPLE_TYPE antiAliasingLvl;
    bool antiAliasing = false;
    if(SUCCEEDED(d3d->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, 
        D3DDEVTYPE_HAL, textureFormat, true, D3DMULTISAMPLE_2_SAMPLES, nullptr)))
    {
        d3dpp.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
        antiAliasingLvl = D3DMULTISAMPLE_2_SAMPLES;
        antiAliasing = true;
    }

    d3dpp.hDeviceWindow = hWnd;
    d3dpp.Windowed = true;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = textureFormat;
    d3dpp.BackBufferWidth = WINDOW_WIDTH; 
    d3dpp.BackBufferHeight = WINDOW_HEIGHT;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = backBufferFormat; 

    if(FAILED(d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, 
        D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &d3ddev)))
    {
        ShowMessageBox("Direct3D interface creation has failed");
        return false;
    }

    // Create Z-buffer
    if(FAILED(d3ddev->CreateDepthStencilSurface(WINDOW_WIDTH, WINDOW_HEIGHT, backBufferFormat,
        antiAliasing ? antiAliasingLvl : D3DMULTISAMPLE_NONE, NULL, TRUE, &backBuffer, NULL)))
    {
        ShowMessageBox("Z-buffer creation has failed");
        return false;
    }
    d3ddev->SetRenderTarget(0,backBuffer);

    // Set render states
    d3ddev->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, antiAliasing);

    // Check shader capabilities
    D3DCAPS9 caps;
    d3ddev->GetDeviceCaps(&caps);

    // Check for vertex shader version 2.0 support.
    if(caps.VertexShaderVersion < D3DVS_VERSION(2, 0)) 
    {
        ShowMessageBox("Shader model 2.0 or higher is required");
        return false;
    }

    return true;
}
예제 #23
0
HRESULT HookIDirect3D9::RegisterSoftwareDevice(LPVOID _this, void* pInitializeFunction)
{
	LOG_API();
	return pD3D->RegisterSoftwareDevice(pInitializeFunction);
}
예제 #24
0
HRESULT HookIDirect3D9::CheckDeviceType(LPVOID _this, UINT Adapter,D3DDEVTYPE DevType,D3DFORMAT AdapterFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed)
{
	LOG_API();
	return pD3D->CheckDeviceType(Adapter, DevType, AdapterFormat, BackBufferFormat, bWindowed);
}
예제 #25
0
HRESULT HookIDirect3D9::GetAdapterIdentifier(LPVOID _this, UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier)
{
	LOG_API();
	return pD3D->GetAdapterIdentifier(Adapter, Flags, pIdentifier);
}
예제 #26
0
HRESULT HookIDirect3D9::CheckDeviceFormat(LPVOID _this, UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat)
{
	LOG_API();
	return pD3D->CheckDeviceFormat(Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat);
}
예제 #27
0
HRESULT HookIDirect3D9::EnumAdapterModes(LPVOID _this, UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode)
{
	LOG_API();
	return pD3D->EnumAdapterModes(Adapter, Format, Mode, pMode);
}
예제 #28
0
HRESULT HookIDirect3D9::CheckDeviceMultiSampleType(LPVOID _this, UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels)
{
	LOG_API();
	return pD3D->CheckDeviceMultiSampleType(Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels);
}
예제 #29
0
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void InitWindow()
{
	WNDCLASS wndClass;
	wchar_t szClassNme[]      =  L"RuntimeSample";
	wndClass.style         = CS_HREDRAW | CS_VREDRAW;
	wndClass.lpfnWndProc   = WndProc;
	wndClass.cbClsExtra    = 0;
	wndClass.cbWndExtra    = 0;
	wndClass.hInstance     = GetModuleHandle(0);
	wndClass.hIcon         = NULL;
	wndClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
	wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wndClass.lpszMenuName  = NULL;
	wndClass.lpszClassName = szClassNme;
	RegisterClass(&wndClass);
	g_window_handle = CreateWindow(
		szClassNme,
		L"RuntimeSample",
		WS_SYSMENU,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		g_window_width,
		g_window_height,
		NULL,
		NULL,
		GetModuleHandle(0),
		NULL);
	ShowWindow( g_window_handle, true );
	UpdateWindow( g_window_handle );
	
	// COMの初期化
	CoInitializeEx( NULL, NULL );

	// DirectX9の初期化を行う
	D3DPRESENT_PARAMETERS d3dp;
	ZeroMemory(&d3dp, sizeof(d3dp));
	d3dp.BackBufferWidth = g_window_width;
	d3dp.BackBufferHeight = g_window_height;
	d3dp.BackBufferFormat = D3DFMT_X8R8G8B8;
    d3dp.BackBufferCount = 1;      
	d3dp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dp.Windowed = TRUE;
	d3dp.hDeviceWindow = g_window_handle;
	d3dp.EnableAutoDepthStencil = TRUE;
    d3dp.AutoDepthStencilFormat = D3DFMT_D16;

	g_d3d = Direct3DCreate9(D3D_SDK_VERSION);
	
	g_d3d->CreateDevice( 
		D3DADAPTER_DEFAULT,
		D3DDEVTYPE_HAL,
		g_window_handle,
		D3DCREATE_HARDWARE_VERTEXPROCESSING,
		&d3dp,
		&g_d3d_device );
	
	// XAudio2の初期化を行う
	XAudio2Create( &g_xa2 );

	g_xa2->CreateMasteringVoice( &g_xa2_master );
}
예제 #30
0
HRESULT HookIDirect3D9::CheckDepthStencilMatch(LPVOID _this, UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat)
{
	LOG_API();
	return pD3D->CheckDepthStencilMatch(Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
}