当前位置: 首页>>代码示例>>C++>>正文


C++ V_RETURN函数代码示例

本文整理汇总了C++中V_RETURN函数的典型用法代码示例。如果您正苦于以下问题:C++ V_RETURN函数的具体用法?C++ V_RETURN怎么用?C++ V_RETURN使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了V_RETURN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: V_RETURN

//--------------------------------------------------------------------------------------
// Draw geometry using effect
//--------------------------------------------------------------------------------------
HRESULT CEffect::DrawGeom(char *a_TechniqueName, CGeom *a_Geom)
{
    UINT cPasses, iPass;
    HRESULT hr;

    V_RETURN( m_pEffect->SetTechnique( a_TechniqueName ) );
    V_RETURN( m_pEffect->Begin(&cPasses, 0) );

    for (iPass = 0; iPass < cPasses; iPass++)
    {
        V_RETURN( m_pEffect->BeginPass(iPass));

        //draw scene geometry
        V_RETURN(a_Geom->Draw());

        V_RETURN( m_pEffect->EndPass());
    }

    V_RETURN( m_pEffect->End());

    return S_OK;
}
开发者ID:FatGarfieldjteng,项目名称:cubemapgen,代码行数:25,代码来源:CEffectList.cpp

示例2: OnCreateDevice

//--------------------------------------------------------------------------------------
// Create any D3D9 resources that will live through a device reset (D3DPOOL_MANAGED)
// and aren't tied to the back buffer size
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
                                 void* pUserContext )
{
    HRESULT hr;

    V_RETURN( g_DialogResourceManager.OnD3D9CreateDevice( pd3dDevice ) );
    V_RETURN( g_SettingsDlg.OnD3D9CreateDevice( pd3dDevice ) );

    // Initialize the font
    V_RETURN( D3DXCreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
                              OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
                              L"Arial", &g_pFont ) );

    // Load the mesh
    V_RETURN( g_Mesh.Create( pd3dDevice, L"dwarf\\dwarf.x" ) );

    // Find the mesh's center, then generate a centering matrix.
    IDirect3DVertexBuffer9* pVB = NULL;
    V_RETURN( g_Mesh.m_pMesh->GetVertexBuffer( &pVB ) );

    void* pVertices = NULL;
    hr = pVB->Lock( 0, 0, &pVertices, 0 );
    if( FAILED( hr ) )
    {
        SAFE_RELEASE( pVB );
        return hr;
    }

    hr = D3DXComputeBoundingSphere( ( D3DXVECTOR3* )pVertices, g_Mesh.m_pMesh->GetNumVertices(),
                                    D3DXGetFVFVertexSize( g_Mesh.m_pMesh->GetFVF() ), &g_vObjectCenter,
                                    &g_fObjectRadius );

    pVB->Unlock();
    SAFE_RELEASE( pVB );

    if( FAILED( hr ) )
        return hr;

    D3DXMatrixTranslation( &g_mCenterWorld, -g_vObjectCenter.x, -g_vObjectCenter.y, -g_vObjectCenter.z );

    // Read the D3DX effect file
    TCHAR str[MAX_PATH];
    hr = DXUTFindDXSDKMediaFileCch( str, MAX_PATH, TEXT( "CompiledEffect.fxo" ) );
    if( FAILED( hr ) )
    {
        MessageBox( DXUTGetHWND(), TEXT( "Could not locate \"CompiledEffect.fxo\".\n\n" )
                                   TEXT( "This file is created as part of the project build process,\n" )
                                   TEXT( "so the associated project must be compiled inside Visual\n" )
                                   TEXT( "Studio before attempting to run this sample.\n\n" )
                                   TEXT( "If receiving this error even after compiling the project,\n" )
                                   TEXT( "it's likely there was a problem compiling the effect file.\n" )
                                   TEXT( "Check the build log to verify the custom build step was\n" )
                                   TEXT( "run and to look for possible fxc compile errors." ),
                                   TEXT( "File Not Found" ), MB_OK );
        return E_FAIL;
    }

    // Since we are loading a binary file here and this effect has already been compiled,
    // you can not pass compiler flags here (for example to debug the shaders). 
    // To debug the shaders, you must pass these flags to the compiler that generated the
    // binary (for example fxc.exe).  In this sample, there are 2 extra Visual Studio configurations
    // called "Debug Shaders" and "Unicode Debug Shaders" that pass the debug shader flags to fxc.exe.
    V_RETURN( D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, D3DXFX_NOT_CLONEABLE, NULL, &g_pEffect, NULL ) );

    // Setup the camera's view parameters
    D3DXVECTOR3 vecEye( 0.0f, 0.0f, -5.0f );
    D3DXVECTOR3 vecAt ( 0.0f, 0.0f, -0.0f );
    g_Camera.SetViewParams( &vecEye, &vecAt );

    return S_OK;
}
开发者ID:KNeal,项目名称:Oculus,代码行数:75,代码来源:CompiledEffect.cpp

示例3: V_RETURN

//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT SoftParticles::OnD3D11CreateDevice(ID3D11Device* pd3dDevice)
{
	HRESULT hr;

	V_RETURN( LoadEffectFromFile(pd3dDevice,  L"SoftParticles.hlsl", &g_pEffect11) );

	// Obtain the technique handles
	g_pRenderBillboardParticlesHard = g_pEffect11->GetTechniqueByName( "RenderBillboardParticles_Hard" );
	g_pRenderBillboardParticlesODepth = g_pEffect11->GetTechniqueByName( "RenderBillboardParticles_ODepth" );
	g_pRenderBillboardParticlesSoft = g_pEffect11->GetTechniqueByName( "RenderBillboardParticles_Soft" );
	g_pRenderBillboardParticlesODepthSoft = g_pEffect11->GetTechniqueByName( "RenderBillboardParticles_ODepthSoft" );
	g_pRenderVolumeParticlesHard = g_pEffect11->GetTechniqueByName( "RenderVolumeParticles_Hard" );
	g_pRenderVolumeParticlesSoft = g_pEffect11->GetTechniqueByName( "RenderVolumeParticles_Soft" );
	g_pRenderVolumeParticlesSoftMSAA = g_pEffect11->GetTechniqueByName( "RenderVolumeParticles_Soft_MSAA" );
	g_pRenderVolumeParticlesHardMSAA = g_pEffect11->GetTechniqueByName( "RenderVolumeParticles_Hard_MSAA" );
	g_pRenderBillboardParticlesSoftMSAA = g_pEffect11->GetTechniqueByName( "RenderBillboardParticles_Soft_MSAA" );
	g_pRenderBillboardParticlesODepthSoftMSAA = g_pEffect11->GetTechniqueByName( "RenderBillboardParticles_ODepthSoft_MSAA" );
  
	// Obtain the parameter handles
	g_pmWorldViewProj = g_pEffect11->GetVariableByName( "g_mWorldViewProj" )->AsMatrix();
	g_pmWorldView = g_pEffect11->GetVariableByName( "g_mWorldView" )->AsMatrix();
	g_pmWorld = g_pEffect11->GetVariableByName( "g_mWorld" )->AsMatrix();
	g_pmInvView = g_pEffect11->GetVariableByName( "g_mInvView" )->AsMatrix();
	g_pmInvProj = g_pEffect11->GetVariableByName( "g_mInvProj" )->AsMatrix();
	g_pfFadeDistance = g_pEffect11->GetVariableByName( "g_fFadeDistance" )->AsScalar();
	g_pfSizeZScale = g_pEffect11->GetVariableByName( "g_fSizeZScale" )->AsScalar();
	g_pvViewLightDir1 = g_pEffect11->GetVariableByName( "g_vViewLightDir1" )->AsVector();
	g_pvViewLightDir2 = g_pEffect11->GetVariableByName( "g_vViewLightDir2" )->AsVector();
	g_pvWorldLightDir1 = g_pEffect11->GetVariableByName( "g_vWorldLightDir1" )->AsVector();
	g_pvWorldLightDir2 = g_pEffect11->GetVariableByName( "g_vWorldLightDir2" )->AsVector();
	g_pvEyePt = g_pEffect11->GetVariableByName( "g_vEyePt" )->AsVector();
	g_pvViewDir = g_pEffect11->GetVariableByName( "g_vViewDir" )->AsVector();
	g_pvOctaveOffsets = g_pEffect11->GetVariableByName( "g_OctaveOffsets" )->AsVector();
	g_pvScreenSize = g_pEffect11->GetVariableByName( "g_vScreenSize" )->AsVector();
	g_pDiffuseTex = g_pEffect11->GetVariableByName( "g_txDiffuse" )->AsShaderResource();
	g_pNormalTex = g_pEffect11->GetVariableByName( "g_txNormal" )->AsShaderResource();
	g_pColorGradient = g_pEffect11->GetVariableByName( "g_txColorGradient" )->AsShaderResource();
	g_pVolumeDiffTex = g_pEffect11->GetVariableByName( "g_txVolumeDiff" )->AsShaderResource();
	g_pVolumeNormTex = g_pEffect11->GetVariableByName( "g_txVolumeNorm" )->AsShaderResource();
	g_pDepthTex = g_pEffect11->GetVariableByName( "g_txDepth" )->AsShaderResource();
	g_pDepthMSAATex = g_pEffect11->GetVariableByName( "g_txDepthMSAA" )->AsShaderResource();

	// Create our vertex input layouts
	D3DX11_PASS_DESC PassDesc;
	const D3D11_INPUT_ELEMENT_DESC particlelayout[] =
	{
		{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
		{ "VELOCITY", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
		{ "LIFE",     0, DXGI_FORMAT_R32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 },
		{ "SIZE",     0, DXGI_FORMAT_R32_FLOAT, 0, 28, D3D11_INPUT_PER_VERTEX_DATA, 0 },
	};
	g_pRenderBillboardParticlesHard->GetPassByIndex( 0 )->GetDesc( &PassDesc );
	V_RETURN( pd3dDevice->CreateInputLayout( particlelayout, sizeof(particlelayout)/sizeof(particlelayout[0]), PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize, &g_pParticleVertexLayout ) );

	// Create the particles
	V_RETURN( CreateParticleBuffers( pd3dDevice ) );

	// Create the noise volume
	V_RETURN( CreateNoiseVolume( pd3dDevice, 32 ) );

	// Load the Particle Texture
	V_RETURN( D3DX11CreateShaderResourceViewFromFile( pd3dDevice, L"Resource\\SmokeTexture\\smokevol1.dds", NULL, NULL, &g_pParticleTexRV, NULL ) );
	V_RETURN( D3DX11CreateShaderResourceViewFromFile( pd3dDevice, L"Resource\\SmokeTexture\\colorgradient.dds", NULL, NULL, &g_pColorGradTexRV, NULL ) );

	g_pfFadeDistance->SetFloat( g_fFadeDistance );

	//---------------------------------
	//resize swap chain
	//---------------------------------

	// Create a new Depth-Stencil texture to replace the DXUT created one
	D3D11_TEXTURE2D_DESC descDepth;
	descDepth.Width = 800;
	descDepth.Height = 600;
	descDepth.MipLevels = 1;
	descDepth.ArraySize = 1;
	descDepth.Format = DXGI_FORMAT_R32_TYPELESS; // Use a typeless type here so that it can be both depth-stencil and shader resource.
	// This will fail if we try a format like D32_FLOAT
	descDepth.SampleDesc.Count = 1;
	descDepth.SampleDesc.Quality = 0;
	descDepth.Usage = D3D11_USAGE_DEFAULT;
	descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
	descDepth.CPUAccessFlags = 0;
	descDepth.MiscFlags = 0;
	V_RETURN( pd3dDevice->CreateTexture2D( &descDepth, NULL, &g_pDepthStencilTexture ) );

	// Create the depth stencil view
	D3D11_DEPTH_STENCIL_VIEW_DESC descDSV;
	if( 1 == descDepth.SampleDesc.Count ) {
		descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
	} else {
		descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;
	}
	descDSV.Flags = 0;
	descDSV.Format = DXGI_FORMAT_D32_FLOAT;	// Make the view see this as D32_FLOAT instead of typeless
	descDSV.Texture2D.MipSlice = 0;
	V_RETURN( pd3dDevice->CreateDepthStencilView( g_pDepthStencilTexture, &descDSV, &g_pDepthStencilDSV ) );
//.........这里部分代码省略.........
开发者ID:denghc,项目名称:danmugame,代码行数:101,代码来源:SoftParticles.cpp

示例4: SAFE_RELEASE

HRESULT LineDraw_Hlsl_Shader::OnRestore(Scene *pScene)
{
	HRESULT hr = S_OK;

	SAFE_RELEASE(m_pEffect);
	SAFE_RELEASE(m_pcbDiffuseColor);
	SAFE_RELEASE(m_pVertexLayout11);
	SAFE_RELEASE(m_pcbChangePerFrame);
	SAFE_RELEASE(m_pcbRenderTargetSize);

	shared_ptr<D3DRenderer11> d3dRenderer11 = static_pointer_cast<D3DRenderer11>(pScene->GetRenderer());

	//========================================================
	// Set up the vertex shader and related constant buffers

	// Compile the vertex shader using the lowest possible profile for broadest feature level support
	ID3DBlob* pVertexShaderBuffer = NULL;

	std::string hlslFileName = "Effects\\LineDraw.hlsl";
	Resource resource(hlslFileName.c_str());
	shared_ptr<ResHandle> pResourceHandle = g_pApp->m_ResCache->GetHandle(&resource);  // this actually loads the HLSL file from the zip file

	// Compile effect from HLSL file into binary Blob in memory
	// The code in this function was found here - http://asawicki.info/news_1371_effects_in_directx_11.html

	ID3D10Blob *effectBlob = 0, *errorsBlob = 0;
	hr = D3DX11CompileFromMemory(
		pResourceHandle->Buffer(),                   // srcData
		pResourceHandle->Size(),                     // srcLen
		0, 0, 0, 0,                                  // fileName, pDefines, pInclude, functionName
		"fx_5_0", 0, 0, 0,                           // profile, flags1, flags2, pump
		&effectBlob, &errorsBlob, 0);                // shader, errorMsg, pResult
	assert(SUCCEEDED(hr) && effectBlob);
	if (errorsBlob) errorsBlob->Release();

	// Create D3DX11 effect from compiled binary memory block
	if (FAILED(D3DX11CreateEffectFromMemory(
		effectBlob->GetBufferPointer(), effectBlob->GetBufferSize(), 0, g_pDX11W->GetD3D11Device(), &m_pEffect)))
	{
			return hr;
	}

	effectBlob->Release();

	m_EffectTechnique = m_pEffect->GetTechniqueByIndex(0);
	AC_ASSERT(m_EffectTechnique && m_EffectTechnique->IsValid());

	m_EffectPass = m_EffectTechnique->GetPassByIndex(0);
	AC_ASSERT(m_EffectPass && m_EffectPass->IsValid());    

	D3DX11_PASS_SHADER_DESC effectVsDesc;
	m_EffectPass->GetVertexShaderDesc(&effectVsDesc);
	D3DX11_EFFECT_SHADER_DESC effectVsDesc2;
	effectVsDesc.pShaderVariable->GetShaderDesc(effectVsDesc.ShaderIndex, &effectVsDesc2);
	const void *vsCodePtr = effectVsDesc2.pBytecode;
	unsigned vsCodeLen = effectVsDesc2.BytecodeLength;

    if (SUCCEEDED (g_pDX11W->GetD3D11Device()->CreateInputLayout( D3D11VertexLayout_Position, ARRAYSIZE( D3D11VertexLayout_Position ), vsCodePtr, vsCodeLen, &m_pVertexLayout11)))
	{
		//DXUT_SetDebugName(m_pVertexLayout11, "Primary");

		// Setup constant buffers
		D3D11_BUFFER_DESC Desc;
		Desc.Usage = D3D11_USAGE_DYNAMIC;
		Desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
		Desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
		Desc.MiscFlags = 0;

		Desc.ByteWidth = sizeof(Vec4);
		V_RETURN(g_pDX11W->GetD3D11Device()->CreateBuffer(&Desc, NULL, &m_pcbRenderTargetSize));
		//DXUT_SetDebugName( m_pcbRenderTargetSize, "Vec4_RenderTargetSize" );

		Desc.ByteWidth = sizeof(Mat4x4);
		V_RETURN(g_pDX11W->GetD3D11Device()->CreateBuffer(&Desc, NULL, &m_pcbChangePerFrame));
		//DXUT_SetDebugName( m_pcbChangePerFrame, "LineDrawerChangePerFrameBuffer" );

		Desc.ByteWidth = sizeof(Vec4);
		V_RETURN(g_pDX11W->GetD3D11Device()->CreateBuffer(&Desc, NULL, &m_pcbDiffuseColor));
		//DXUT_SetDebugName( m_pcbDiffuseColor, "DiffuseColor" );
	}

    SAFE_RELEASE(pVertexShaderBuffer);

    return S_OK;
}
开发者ID:JDHDEV,项目名称:AlphaEngine,代码行数:85,代码来源:Shaders.cpp

示例5: InitGL

bool InitGL(HWND hwnd)
{
	HWND dummy = CreateWindow("TestClass", "Dummy", WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
		0, 0, 100, 100, 0, 0, GetModuleHandle(0), 0);

	PIXELFORMATDESCRIPTOR pfd =
	{
		sizeof(PIXELFORMATDESCRIPTOR),
		1,
		PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,
		PFD_TYPE_RGBA,
		32, // color
		0, 0, 0, 0, 0, 0,
		0, // alpha
		0, 0, 0, 0, 0, 0,
		24, 8, 0, // depth, stencil, aux
		PFD_MAIN_PLANE,
		0, 0, 0, 0
	};

	hdc = GetDC(dummy);
	V_RETURN(false, "InitGL(): Could not get device context", hdc);
	
	int pixelformat = ChoosePixelFormat(hdc, &pfd);
	V_RETURN(false, "InitGL(): Could not find suitable pixel format", pixelformat);

	BOOL success = SetPixelFormat(hdc, pixelformat, &pfd);
	V_RETURN(false, "InitGL(): Could not setup pixel format", success);

	hrc = wglCreateContext(hdc);
	V_RETURN(false, "InitGL(): Context creation failed", hrc);

	success = wglMakeCurrent(hdc, hrc);
	V_RETURN(false, "InitGL(): Could not acquire context", success);

	const char* str = (const char*)glGetString(GL_VENDOR);
	std::cout << "Vendor: " << str << "\n";

	str = (const char*)glGetString(GL_RENDERER);
	std::cout << "Renderer: " << str << "\n";

	str = (const char*)glGetString(GL_VERSION);
	std::cout << "OpenGL version: " << str << "\n\n";

	int major, minor;

	sscanf_s(str, "%1d.%2d %*s", &major, &minor);

	if( major < 3 || (major == 3 && minor < 2) )
	{
		std::cout << "Device does not support OpenGL 3.2\n";
		return false;
	}

	typedef const char* (APIENTRY *WGLGETEXTENSIONSSTRINGARBPROC)(HDC hdc);
	typedef HGLRC (APIENTRY *WGLCREATECONTEXTATTRIBSARBPROC)(HDC hDC, HGLRC hShareContext, const int *attribList);

	WGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL;
	WGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = (WGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");

	if( wglGetExtensionsStringARB )
	{
		if( Quadron::wIsSupported("WGL_ARB_pixel_format", hdc) )
		{
			std::cout << "WGL_ARB_pixel_format present, querying pixel formats...\n";

			typedef BOOL (APIENTRY *WGLGETPIXELFORMATATTRIBIVARBPROC)(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
			typedef BOOL (APIENTRY *WGLGETPIXELFORMATATTRIBFVARBPROC)(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
			typedef BOOL (APIENTRY *WGLCHOOSEPIXELFORMATARBPROC)(HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);

			WGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB = (WGLGETPIXELFORMATATTRIBIVARBPROC)wglGetProcAddress("wglGetPixelFormatAttribivARB");
			WGLGETPIXELFORMATATTRIBFVARBPROC wglGetPixelFormatAttribfvARB = (WGLGETPIXELFORMATATTRIBFVARBPROC)wglGetProcAddress("wglGetPixelFormatAttribfvARB");
			WGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = (WGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");

			int attrib[128];
			int i = 0;
			UINT numformats;

			memset(attrib, 0, sizeof(attrib));

			attrib[i++] = 0x2001;		// WGL_DRAW_TO_WINDOW_ARB;
			attrib[i++] = TRUE;
			attrib[i++] = 0x2003;		// WGL_ACCELERATION_ARB;
			attrib[i++] = 0x2027;		// WGL_FULL_ACCELERATION_ARB
			attrib[i++] = 0x2010;		// WGL_SUPPORT_OPENGL_ARB
			attrib[i++] = TRUE;
			attrib[i++] = 0x2011;		// WGL_DOUBLE_BUFFER_ARB
			attrib[i++] = TRUE;
			attrib[i++] = 0x2013;		// WGL_PIXEL_TYPE_ARB
			attrib[i++] = 0x202B;		// WGL_TYPE_RGBA_ARB
			attrib[i++] = 0x2014;		// WGL_COLOR_BITS_ARB
			attrib[i++] = pfd.cColorBits = 32;
			attrib[i++] = 0x201B;		// WGL_ALPHA_BITS_ARB
			attrib[i++] = pfd.cAlphaBits = 0;
			attrib[i++] = 0x2022;		// WGL_DEPTH_BITS_ARB
			attrib[i++] = pfd.cDepthBits = 24;
			attrib[i++] = 0x2023;		// WGL_STENCIL_BITS_ARB
			attrib[i++] = pfd.cStencilBits = 8;
			attrib[i++] = 0;

//.........这里部分代码省略.........
开发者ID:galek,项目名称:Asylum_Tutorials,代码行数:101,代码来源:othergl.cpp

示例6: OnD3D11CreateDevice

//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
                                      void* pUserContext )
{
    HRESULT hr;

    ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext();
    V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
    V_RETURN( g_D3DSettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
    g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );

   // D3DXVECTOR3 vCenter( 0.25767413f, -28.503521f, 111.00689f );
    FLOAT fObjectRadius = 378.15607f;
	lightpos = D3DXVECTOR3(300,300,-200);
	//test = new testing();
	hr = test.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext);
	hr = tessplane.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext);
	hr = tesscube.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,80,D3DXVECTOR3(300,50,-200));//D3DXVECTOR3(300,50,-200
	hr = lightsphere.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,10,lightpos);
	hr = fuse.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext);
	hr = board1.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,D3DXVECTOR3(300,-300,-1000));
	hr = deboard.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,D3DXVECTOR3(-300,-300,-1000));
	hr = geo_alien.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext);
	hr = FirePart.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,80,0); //0 = fire
	hr = sky.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,D3DXVECTOR3(0,0,0));
	hr = buildings.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext);
	hr = MissilePart.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,20,1);
    g_LightControl.SetRadius( 2000 );



	
    // Setup the camera's view parameters
    D3DXVECTOR3 vecEye( 0.0f, 50.0f, -1000.0f );
    D3DXVECTOR3 vecAt ( 0.0f, 0.0f, -0.0f );

	g_Camera.SetRotateButtons(true,false,false);
    g_Camera.SetViewParams( &vecEye, &vecAt );
	g_Camera.SetEnablePositionMovement( true );
	g_Camera.SetScalers( 0.005f, 500.0f );

	D3D11_DEPTH_STENCIL_DESC descDS;
	ZeroMemory(&descDS, sizeof(descDS));
	descDS.DepthEnable = false;
	descDS.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;	
	descDS.DepthFunc = D3D11_COMPARISON_LESS;	
	

	descDS.StencilEnable = FALSE;
	hr = pd3dDevice->CreateDepthStencilState( &descDS, &g_DepthState);

	//setup stuff for post process


	ID3DBlob* pVertexShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"PP1.hlsl", "VS", "vs_4_0", &pVertexShaderBuffer ) );

    ID3DBlob* pPixelShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"PP1.hlsl", "PS", "ps_4_0", &pPixelShaderBuffer ) );

	V_RETURN( pd3dDevice->CreateVertexShader( pVertexShaderBuffer->GetBufferPointer(),
                                              pVertexShaderBuffer->GetBufferSize(), NULL, &VSPPFirstPass ) );
    DXUT_SetDebugName( VSPPFirstPass, "VSPost1" );
    V_RETURN( pd3dDevice->CreatePixelShader( pPixelShaderBuffer->GetBufferPointer(),
                                             pPixelShaderBuffer->GetBufferSize(), NULL, &PSPPFirstPass ) );
    DXUT_SetDebugName( PSPPFirstPass, "PSPost1" );

	pVertexShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"Gaussblur.hlsl", "VS", "vs_4_0", &pVertexShaderBuffer ) );

    pPixelShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"Gaussblur.hlsl", "PS", "ps_4_0", &pPixelShaderBuffer ) );

	V_RETURN( pd3dDevice->CreateVertexShader( pVertexShaderBuffer->GetBufferPointer(),
                                              pVertexShaderBuffer->GetBufferSize(), NULL, &VSPPBlur ) );
    DXUT_SetDebugName( VSPPBlur, "VSBlur" );
    V_RETURN( pd3dDevice->CreatePixelShader( pPixelShaderBuffer->GetBufferPointer(),
                                             pPixelShaderBuffer->GetBufferSize(), NULL, &PSPPBlur ) );
    DXUT_SetDebugName( PSPPBlur, "PSBlur" );

	pVertexShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"bloom_combine.hlsl", "VS", "vs_4_0", &pVertexShaderBuffer ) );

    pPixelShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"bloom_combine.hlsl", "PS", "ps_4_0", &pPixelShaderBuffer ) );

	V_RETURN( pd3dDevice->CreateVertexShader( pVertexShaderBuffer->GetBufferPointer(),
                                              pVertexShaderBuffer->GetBufferSize(), NULL, &VSPPComb ) );
    DXUT_SetDebugName( VSPPComb, "VSComb" );
    V_RETURN( pd3dDevice->CreatePixelShader( pPixelShaderBuffer->GetBufferPointer(),
                                             pPixelShaderBuffer->GetBufferSize(), NULL, &PSPPComb ) );
    DXUT_SetDebugName( PSPPComb, "PSComb" );





	
//.........这里部分代码省略.........
开发者ID:AlexKLM,项目名称:DX11-Shader-Language-Coursework,代码行数:101,代码来源:BasicHLSL11.cpp

示例7: OnCreateDevice

//--------------------------------------------------------------------------------------
// This callback function will be called immediately after the Direct3D device has been 
// created, which will happen during application initialization and windowed/full screen 
// toggles. This is the best location to create D3DPOOL_MANAGED resources since these 
// resources need to be reloaded whenever the device is destroyed. Resources created  
// here should be released in the OnDestroyDevice callback. 
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
                                 void* pUserContext )
{
    HRESULT hr;


    V_RETURN( g_DialogResourceManager.OnD3D9CreateDevice( pd3dDevice ) );
    V_RETURN( g_SettingsDlg.OnD3D9CreateDevice( pd3dDevice ) );
    // Initialize the font
    V_RETURN( D3DXCreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
                              OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
                              L"Arial", &g_pFont ) );

    // Define DEBUG_VS and/or DEBUG_PS to debug vertex and/or pixel shaders with the 
    // shader debugger. Debugging vertex shaders requires either REF or software vertex 
    // processing, and debugging pixel shaders requires REF.  The 
    // D3DXSHADER_FORCE_*_SOFTWARE_NOOPT flag improves the debug experience in the 
    // shader debugger.  It enables source level debugging, prevents instruction 
    // reordering, prevents dead code elimination, and forces the compiler to compile 
    // against the next higher available software target, which ensures that the 
    // unoptimized shaders do not exceed the shader model limitations.  Setting these 
    // flags will cause slower rendering since the shaders will be unoptimized and 
    // forced into software.  See the DirectX documentation for more information about 
    // using the shader debugger.
    DWORD dwShaderFlags = D3DXFX_NOT_CLONEABLE;

#if defined( DEBUG ) || defined( _DEBUG )
    // Set the D3DXSHADER_DEBUG flag to embed debug information in the shaders.
    // Setting this flag improves the shader debugging experience, but still allows 
    // the shaders to be optimized and to run exactly the way they will run in 
    // the release configuration of this program.
    dwShaderFlags |= D3DXSHADER_DEBUG;
    #endif

#ifdef DEBUG_VS
    dwShaderFlags |= D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT;
#endif
#ifdef DEBUG_PS
    dwShaderFlags |= D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT;
#endif

    // Determine which LDPRT texture and SH coefficient cubemap formats are supported
    IDirect3D9* pD3D = DXUTGetD3D9Object();
    D3DCAPS9 Caps;
    pd3dDevice->GetDeviceCaps( &Caps );
    D3DDISPLAYMODE DisplayMode;
    pd3dDevice->GetDisplayMode( 0, &DisplayMode );

    GetSupportedTextureFormat( pD3D, &Caps, DisplayMode.Format, &g_fmtTexture, &g_fmtCubeMap );
    if( D3DFMT_UNKNOWN == g_fmtTexture || D3DFMT_UNKNOWN == g_fmtCubeMap )
        return E_FAIL;

    // Create the skybox
    g_Skybox.OnCreateDevice( pd3dDevice, 50, L"Light Probes\\rnl_cross.dds", L"SkyBox.fx" );
    V( D3DXSHProjectCubeMap( 6, g_Skybox.GetEnvironmentMap(), g_fSkyBoxLightSH[0], g_fSkyBoxLightSH[1],
                             g_fSkyBoxLightSH[2] ) );

    // Now compute the SH projection of the skybox...
    LPDIRECT3DCUBETEXTURE9 pSHCubeTex = NULL;
    V( D3DXCreateCubeTexture( pd3dDevice, 256, 1, 0, D3DFMT_A16B16G16R16F, D3DPOOL_MANAGED, &pSHCubeTex ) );

    SHCubeProj projData;
    projData.Init( g_fSkyBoxLightSH[0], g_fSkyBoxLightSH[1], g_fSkyBoxLightSH[2] );

    V( D3DXFillCubeTexture( pSHCubeTex, SHCubeFill, &projData ) );
    g_Skybox.InitSH( pSHCubeTex );

    // Read the D3DX effect file
    WCHAR str[MAX_PATH];
    V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, TEXT( "LocalDeformablePRT.fx" ) ) );

    // If this fails, there should be debug output as to they the .fx file failed to compile
    V_RETURN( D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, dwShaderFlags, NULL, &g_pEffect, NULL ) );

    V_RETURN( LoadTechniqueObjects( "bat" ) );

    V_RETURN( g_LightControl.StaticOnD3D9CreateDevice( pd3dDevice ) );
    g_LightControl.SetRadius( 2.0f );

    // Setup the camera's view parameters
    D3DXVECTOR3 vecEye( 0.0f, 0.0f, -5.0f );
    D3DXVECTOR3 vecAt ( 0.0f, 0.0f, 0.0f );
    g_Camera.SetViewParams( &vecEye, &vecAt );

    // Set the model's initial orientation
    D3DXQUATERNION quatRotation;
    D3DXQuaternionRotationYawPitchRoll( &quatRotation, -0.5f, 0.7f, 0.0f );
    g_Camera.SetWorldQuat( quatRotation );

    return hr;
}
开发者ID:KNeal,项目名称:Oculus,代码行数:98,代码来源:LocalDeformablePRT.cpp

示例8: V_RETURN

HRESULT WEHDR::Create(ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext)
{
    HRESULT hr;

    m_pd3dDevice = pd3dDevice;
    m_pImmediateContext = pd3dImmediateContext;

    // Create views.
    V_RETURN(CreateViews());

    // Create shaders.
    ID3DBlob* pPSBlob2x2 = NULL;
    ID3DBlob* pPSBlob3x3 = NULL;
    ID3DBlob* pPSBlobBrightPass = NULL;
    ID3DBlob* pPSBlobBloom = NULL;
    ID3DBlob* pPSBlobFinal = NULL;

    V_RETURN(WE::CompileShaderFromFile(L"shaders\\HDR.hlsl", NULL, "DownScale2x2_Lum", "ps_5_0", &pPSBlob2x2));
    V_RETURN(WE::CompileShaderFromFile(L"shaders\\HDR.hlsl", NULL, "DownScale3x3", "ps_5_0", &pPSBlob3x3));
    V_RETURN(WE::CompileShaderFromFile(L"shaders\\HDR.hlsl", NULL, "DownScale3x3_BrightPass", "ps_5_0", &pPSBlobBrightPass));
    V_RETURN(WE::CompileShaderFromFile(L"shaders\\HDR.hlsl", NULL, "Bloom", "ps_5_0", &pPSBlobBloom));
    V_RETURN(WE::CompileShaderFromFile(L"shaders\\HDR.hlsl", NULL, "FinalPass", "ps_5_0", &pPSBlobFinal));

    V_RETURN(pd3dDevice->CreatePixelShader(pPSBlob2x2->GetBufferPointer(), pPSBlob2x2->GetBufferSize(), NULL, &m_pPSDownScale2x2Lum));
    V_RETURN(pd3dDevice->CreatePixelShader(pPSBlob3x3->GetBufferPointer(), pPSBlob3x3->GetBufferSize(), NULL, &m_pPSDownScale3x3));
    V_RETURN(pd3dDevice->CreatePixelShader(pPSBlobBrightPass->GetBufferPointer(), pPSBlobBrightPass->GetBufferSize(), NULL, &m_pPSBrightPass));
    V_RETURN(pd3dDevice->CreatePixelShader(pPSBlobBloom->GetBufferPointer(), pPSBlobBloom->GetBufferSize(), NULL, &m_pPSBloom));
    V_RETURN(pd3dDevice->CreatePixelShader(pPSBlobFinal->GetBufferPointer(), pPSBlobFinal->GetBufferSize(), NULL, &m_pPSFinalPass));

    SAFE_RELEASE(pPSBlob2x2);
    SAFE_RELEASE(pPSBlob3x3);
    SAFE_RELEASE(pPSBlobBrightPass);    
    SAFE_RELEASE(pPSBlobBloom);    
    SAFE_RELEASE(pPSBlobFinal);

    // Create the texture sampler state.
    D3D11_SAMPLER_DESC samplerDesc;
    samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
    samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
    samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
    samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
    samplerDesc.MipLODBias = 0.0f;
    samplerDesc.MaxAnisotropy = 1;
    samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
    samplerDesc.BorderColor[0] = 0;
    samplerDesc.BorderColor[1] = 0;
    samplerDesc.BorderColor[2] = 0;
    samplerDesc.BorderColor[3] = 0;
    samplerDesc.MinLOD = 0;
    samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
    V_RETURN(WE::D3DDevice()->CreateSamplerState(&samplerDesc, &m_pSamplePoint));
    samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
    V_RETURN(WE::D3DDevice()->CreateSamplerState(&samplerDesc, &m_pSampleLinear)); 

    // Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
    D3D11_BUFFER_DESC bufferDesc;
    bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
    bufferDesc.ByteWidth = sizeof(BufferType);
    bufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
    bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
    bufferDesc.MiscFlags = 0;
    bufferDesc.StructureByteStride = 0;
    V_RETURN(pd3dDevice->CreateBuffer(&bufferDesc, NULL, &m_pcbBloom));

    //
    V_RETURN(CreateViews());

    return S_OK;
}
开发者ID:wchar,项目名称:WEAlpha,代码行数:69,代码来源:WEHDR.cpp

示例9: ZeroMemory

HRESULT DX11SceneRep::OnD3D11CreateDevice( ID3D11Device* pd3dDevice )
{
	HRESULT hr = S_OK;

	D3D11_BUFFER_DESC bDesc;
	ZeroMemory(&bDesc, sizeof(D3D11_BUFFER_DESC));
	bDesc.BindFlags	= D3D11_BIND_CONSTANT_BUFFER;
	bDesc.Usage	= D3D11_USAGE_DYNAMIC;
	bDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
	bDesc.MiscFlags	= 0;
	bDesc.ByteWidth	= sizeof(CB_VOXEL_HASH);
	V_RETURN(pd3dDevice->CreateBuffer(&bDesc, NULL, &s_VoxelHashCB));

	char blockSize[5];
	sprintf_s(blockSize, "%d", THREAD_GROUP_SIZE_SCENE_REP);
	D3D_SHADER_MACRO macro[] = {{"groupthreads", blockSize}, {0}};

	ID3DBlob* pBlob = NULL;
	V_RETURN(CompileShaderFromFile(L"Shaders\\SceneRep.hlsl", "integrateCS", "cs_5_0", &pBlob, macro));
	V_RETURN(pd3dDevice->CreateComputeShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &s_VoxelHashIntegrate));

	V_RETURN(CompileShaderFromFile(L"Shaders\\SceneRep.hlsl", "resetCS", "cs_5_0", &pBlob, macro));
	V_RETURN(pd3dDevice->CreateComputeShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &s_VoxelHashReset));

	V_RETURN(CompileShaderFromFile(L"Shaders\\SceneRep.hlsl", "starveCS", "cs_5_0", &pBlob, macro));
	V_RETURN(pd3dDevice->CreateComputeShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &s_VoxelHashStarve));

	V_RETURN(CompileShaderFromFile(L"Shaders\\SceneRep.hlsl", "starveVisibleCS", "cs_5_0", &pBlob, macro));
	V_RETURN(pd3dDevice->CreateComputeShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &s_VoxelHashStarveVisible));

	V_RETURN(CompileShaderFromFile(L"Shaders\\SceneRep.hlsl", "starveRegulizeNoiseCS", "cs_5_0", &pBlob, macro));
	V_RETURN(pd3dDevice->CreateComputeShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &s_VoxelHashStarveRegulizeNoise));

	D3D_SHADER_MACRO macro_out = {"MOVE_OUT_FRUSTUM", "1"};
	D3D_SHADER_MACRO macro_in = {"MOVE_IN_FRUSTUM", "1"};

	D3D_SHADER_MACRO macro_and_out[10];
	D3D_SHADER_MACRO macro_and_in[10];
	AddDefinitionToMacro(macro, macro_and_out, macro_out);
	AddDefinitionToMacro(macro, macro_and_in, macro_in);

	V_RETURN(CompileShaderFromFile(L"Shaders\\SceneRep.hlsl", "removeAndIntegrateCS", "cs_5_0", &pBlob, macro_and_out));
	V_RETURN(pd3dDevice->CreateComputeShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &s_VoxelHashRemoveAndIntegrateOutFrustum));

	V_RETURN(CompileShaderFromFile(L"Shaders\\SceneRep.hlsl", "removeAndIntegrateCS", "cs_5_0", &pBlob, macro_and_in));
	V_RETURN(pd3dDevice->CreateComputeShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &s_VoxelHashRemoveAndIntegrateInFrustum));

	V_RETURN(CompileShaderFromFile(L"Shaders\\SceneRep.hlsl", "integrateFromOtherCS", "cs_5_0", &pBlob, macro));
	V_RETURN(pd3dDevice->CreateComputeShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &s_VoxelHashIntegrateFromOther));

	V_RETURN(CompileShaderFromFile(L"Shaders\\SceneRep.hlsl", "removeFromOtherCS", "cs_5_0", &pBlob, macro));
	V_RETURN(pd3dDevice->CreateComputeShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &s_VoxelHashRemoveFromOther));

	SAFE_RELEASE(pBlob);

	return hr;
}
开发者ID:ZaneYang,项目名称:VoxelHashing,代码行数:57,代码来源:DX11SceneRep.cpp

示例10: D3DX11CompileEffectFromFile

	void EffectHelper::init(ID3D11Device *pD3D11Device, std::string effectFile)
	{
		DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
#ifdef _DEBUG
		// Set the D3DCOMPILE_DEBUG flag to embed debug information in the shaders.
		// Setting this flag improves the shader debugging experience, but still allows 
		// the shaders to be optimized and to run exactly the way they will run in 
		// the release configuration of this program.
		dwShaderFlags |= D3DCOMPILE_DEBUG;

		// Disable optimizations to further improve shader debugging
		dwShaderFlags |= D3DCOMPILE_SKIP_OPTIMIZATION;
#endif

#if D3D_COMPILER_VERSION >= 46
		// Read the D3DX effect file
		HRESULT hr = S_OK;
		D3DX11CompileEffectFromFile(L"tutorial11.fx", nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, dwShaderFlags, 0, pD3D11Device, &m_pEffect, nullptr);

#else
		ID3DBlob* pEffectBuffer = nullptr;
		V_RETURN(DXUTCompileFromFile(L"Tutorial11.fx", nullptr, "none", "fx_5_0", dwShaderFlags, 0, &pEffectBuffer));
		hr = D3DX11CreateEffectFromMemory(pEffectBuffer->GetBufferPointer(), pEffectBuffer->GetBufferSize(), 0, pd3dDevice, &m_pEffect);
		SAFE_RELEASE(pEffectBuffer);
		if (FAILED(hr))
			return hr;

#endif

		m_pEffectTechnique = m_pEffect->GetTechniqueByName("Render");

		std::vector<D3D11_INPUT_ELEMENT_DESC> vInputLayoutDesc;
		D3D11_INPUT_ELEMENT_DESC inputLayoutDesc;

		inputLayoutDesc.SemanticName         = "POSITION";
		inputLayoutDesc.SemanticIndex        = 0;
		inputLayoutDesc.Format               = DXGI_FORMAT_R32G32B32_FLOAT;
		inputLayoutDesc.InputSlot            = 0;
		inputLayoutDesc.AlignedByteOffset    = 0;
		inputLayoutDesc.InputSlotClass       = D3D11_INPUT_PER_VERTEX_DATA;
		inputLayoutDesc.InstanceDataStepRate = 0;
		vInputLayoutDesc.push_back(inputLayoutDesc);

		inputLayoutDesc.SemanticName         = "NORMAL";
		inputLayoutDesc.SemanticIndex        = 0;
		inputLayoutDesc.Format               = DXGI_FORMAT_R32G32B32_FLOAT;
		inputLayoutDesc.InputSlot            = 0;
		inputLayoutDesc.AlignedByteOffset    = 12;
		inputLayoutDesc.InputSlotClass       = D3D11_INPUT_PER_VERTEX_DATA;
		inputLayoutDesc.InstanceDataStepRate = 0;
		vInputLayoutDesc.push_back(inputLayoutDesc);

		inputLayoutDesc.SemanticName         = "TEXCOORD";
		inputLayoutDesc.SemanticIndex        = 0;
		inputLayoutDesc.Format               = DXGI_FORMAT_R32G32_FLOAT;
		inputLayoutDesc.InputSlot            = 0;
		inputLayoutDesc.AlignedByteOffset    = 24;
		inputLayoutDesc.InputSlotClass       = D3D11_INPUT_PER_VERTEX_DATA;
		inputLayoutDesc.InstanceDataStepRate = 0;
		vInputLayoutDesc.push_back(inputLayoutDesc);

		// Create the input layout
		D3DX11_PASS_DESC PassDesc;
		auto numElements = vInputLayoutDesc.size();
		m_pEffectTechnique->GetPassByIndex(0)->GetDesc(&PassDesc);
		pD3D11Device->CreateInputLayout(&vInputLayoutDesc[0], numElements, PassDesc.pIAInputSignature,
			PassDesc.IAInputSignatureSize, &m_pInputLayout);
	}
开发者ID:byhj,项目名称:byhj-Render,代码行数:68,代码来源:d3dEffect.cpp

示例11: OnD3D10CreateDevice

//--------------------------------------------------------------------------------------
// Create any D3D10 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D10CreateDevice( ID3D10Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
                                      void* pUserContext )
{
    HRESULT hr;

    V_RETURN( g_DialogResourceManager.OnD3D10CreateDevice( pd3dDevice ) );
    V_RETURN( g_D3DSettingsDlg.OnD3D10CreateDevice( pd3dDevice ) );
    V_RETURN( D3DX10CreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
                                OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
                                L"Arial", &g_pFont10 ) );
    V_RETURN( D3DX10CreateSprite( pd3dDevice, MAX_SPRITES, &g_pSprite10 ) );

    V_RETURN( CDXUTDirectionWidget::StaticOnD3D10CreateDevice( pd3dDevice ) );

    // Read the D3DX effect file
    WCHAR str[MAX_PATH];
    DWORD dwShaderFlags = D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY;
#if defined( DEBUG ) || defined( _DEBUG )
    // Set the D3D10_SHADER_DEBUG flag to embed debug information in the shaders.
    // Setting this flag improves the shader debugging experience, but still allows 
    // the shaders to be optimized and to run exactly the way they will run in 
    // the release configuration of this program.
    dwShaderFlags |= D3D10_SHADER_DEBUG;
    #endif
    V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"Exercise03.fx" ) );
    V_RETURN( D3DX10CreateEffectFromFile( str, NULL, NULL, "fx_4_0", dwShaderFlags, 0, pd3dDevice, NULL,
                                          NULL, &g_pEffect10, NULL, NULL ) );

    // Obtain the technique handles
    g_pRenderTextured = g_pEffect10->GetTechniqueByName( "RenderTextured" );
    g_pRenderPiece = g_pEffect10->GetTechniqueByName( "RenderPiece" );

    // Obtain the parameter handles
    g_pmWorldViewProj = g_pEffect10->GetVariableByName( "g_mWorldViewProj" )->AsMatrix();
    g_pmWorldView = g_pEffect10->GetVariableByName( "g_mWorldView" )->AsMatrix();
    g_pmWorld = g_pEffect10->GetVariableByName( "g_mWorld" )->AsMatrix();
    g_pmProj = g_pEffect10->GetVariableByName( "g_mProj" )->AsMatrix();
    g_pViewSpaceLightDir = g_pEffect10->GetVariableByName( "g_ViewSpaceLightDir" )->AsVector();
    g_pDiffuseTex = g_pEffect10->GetVariableByName( "g_txDiffuse" )->AsShaderResource();

    // Define our vertex data layout
    const D3D10_INPUT_ELEMENT_DESC layout[] =
    {
        { "POS", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
        { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 },
        { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0 },
    };
    UINT numElements = sizeof( layout ) / sizeof( layout[0] );
    D3D10_PASS_DESC PassDesc;
    g_pRenderPiece->GetPassByIndex( 0 )->GetDesc( &PassDesc );
    V_RETURN( pd3dDevice->CreateInputLayout( layout, numElements, PassDesc.pIAInputSignature,
                                             PassDesc.IAInputSignatureSize, &g_pVertexLayout ) );

    // Load our IB and VB with mesh data
    V_RETURN( LoadMesh( pd3dDevice ) );

    // Setup the camera's view parameters
    D3DXVECTOR3 vecEye( 0.0f, 0.0f, -8.0f );
    D3DXVECTOR3 vecAt( 0.0f,0.0f,0.0f );
    g_Camera.SetViewParams( &vecEye, &vecAt );

    return S_OK;
}
开发者ID:KNeal,项目名称:Oculus,代码行数:66,代码来源:Exercise03.cpp

示例12: LoadMesh


//.........这里部分代码省略.........
        -0.193009f, 1.358116f, -0.594020f, 0.093915f, 0.952699f, 0.289039f, 0.391077f, -0.905815f, 0.600000f,
        0.003630f, 0.946384f, -1.199212f, 0.475540f, 0.171919f, -0.862732f, 0.464690f, -0.660168f, 0.600000f,
        -0.707816f, 0.946384f, -0.968049f, -0.891821f, 0.171919f, -0.418450f, 0.371931f, -0.660168f, 0.600000f,
        0.000000f, 0.577163f, 0.000000f, -0.076035f, 0.969256f, -0.234012f, 0.232397f, -0.439883f, 0.000000f,
        0.636337f, 0.165431f, 0.000000f, 0.965927f, 0.072050f, -0.248584f, -0.237213f, -0.194237f, 0.000000f,
        0.196639f, 0.165431f, -0.605192f, 0.534905f, 0.072050f, -0.841834f, 0.480517f, -0.194237f, 0.000000f,
        0.636337f, 0.165431f, 0.000000f, 0.965927f, 0.072050f, -0.248584f, -0.237213f, -0.194237f, 0.000000f,
        0.803003f, 1.102575f, 1.045742f, 0.122381f, 0.171919f, 0.977480f, -0.073536f, -0.753354f, 0.000000f,
        0.196639f, 0.165431f, 0.605192f, 0.303425f, -0.189382f, 0.933846f, 0.017676f, -0.194237f, 0.000000f,
        0.803003f, 1.102575f, 1.045742f, 0.122381f, 0.171919f, 0.977480f, 0.926464f, -0.753354f, 0.000000f,
        0.636337f, 0.165431f, 0.000000f, 0.965927f, 0.072050f, -0.248584f, 0.762787f, -0.194237f, 0.000000f,
        1.242701f, 1.102575f, 0.440550f, 0.967456f, 0.171919f, -0.185666f, 0.821507f, -0.753354f, 0.000000f,
        0.000000f, 0.577163f, 0.000000f, -0.076035f, 0.969256f, -0.234012f, 0.232397f, -0.439883f, 0.000000f,
        1.242701f, 1.102575f, 0.440550f, 0.967456f, 0.171919f, -0.185666f, -0.178493f, -0.753354f, 0.000000f,
        0.636337f, 0.165431f, 0.000000f, 0.965927f, 0.072050f, -0.248584f, -0.237213f, -0.194237f, 0.000000f,
        1.242701f, 1.102575f, 0.440550f, 0.967456f, 0.171919f, -0.185666f, -0.178493f, -0.753354f, 0.000000f,
        0.000000f, 0.577163f, 0.000000f, -0.076035f, 0.969256f, -0.234012f, 0.232397f, -0.439883f, 0.000000f,
        0.606364f, 1.514307f, 0.440550f, -0.245871f, 0.952700f, -0.178636f, -0.099393f, -0.999001f, 0.000000f,
        0.196639f, 0.165431f, 0.605192f, 0.303425f, -0.189382f, 0.933846f, 0.017676f, -0.194237f, 0.000000f,
        0.606364f, 1.514307f, 0.440550f, -0.245871f, 0.952700f, -0.178636f, -0.099393f, -0.999001f, 0.000000f,
        0.000000f, 0.577163f, 0.000000f, -0.076035f, 0.969256f, -0.234012f, 0.232397f, -0.439883f, 0.000000f,
        0.606364f, 1.514307f, 0.440550f, -0.245871f, 0.952700f, -0.178636f, -0.099393f, -0.999001f, 0.000000f,
        0.196639f, 0.165431f, 0.605192f, 0.303425f, -0.189382f, 0.933846f, 0.017676f, -0.194237f, 0.000000f,
        0.803003f, 1.102575f, 1.045742f, 0.122381f, 0.171919f, 0.977480f, -0.073536f, -0.753354f, 0.000000f,
        -0.514807f, 0.165431f, -0.374029f, -0.927565f, 0.072050f, -0.366649f, 0.315994f, -0.194237f, 0.000000f,
        0.003630f, 0.946384f, -1.199212f, 0.475540f, 0.171919f, -0.862732f, 0.464690f, -0.660168f, 0.000000f,
        0.196639f, 0.165431f, -0.605192f, 0.534905f, 0.072050f, -0.841834f, 0.480517f, -0.194237f, 0.000000f,
        0.003630f, 0.946384f, -1.199212f, 0.475540f, 0.171919f, -0.862732f, 0.464690f, -0.660168f, 0.000000f,
        -0.514807f, 0.165431f, -0.374029f, -0.927565f, 0.072050f, -0.366649f, 0.315994f, -0.194237f, 0.000000f,
        -0.707816f, 0.946384f, -0.968049f, -0.891821f, 0.171919f, -0.418450f, 0.371931f, -0.660168f, 0.000000f,
        0.000000f, 0.577163f, 0.000000f, -0.076035f, 0.969256f, -0.234012f, 0.232397f, -0.439883f, 0.000000f,
        -0.707816f, 0.946384f, -0.968049f, -0.891821f, 0.171919f, -0.418450f, 0.371931f, -0.660168f, 0.000000f,
        -0.514807f, 0.165431f, -0.374029f, -0.927565f, 0.072050f, -0.366649f, 0.315994f, -0.194237f, 0.000000f,
        -0.707816f, 0.946384f, -0.968049f, -0.891821f, 0.171919f, -0.418450f, 0.371931f, -0.660168f, 0.000000f,
        0.000000f, 0.577163f, 0.000000f, -0.076035f, 0.969256f, -0.234012f, 0.232397f, -0.439883f, 0.000000f,
        -0.193009f, 1.358116f, -0.594020f, 0.093915f, 0.952699f, 0.289039f, 0.391077f, -0.905815f, 0.000000f,
        0.196639f, 0.165431f, -0.605192f, 0.534905f, 0.072050f, -0.841834f, 0.480517f, -0.194237f, 0.000000f,
        -0.193009f, 1.358116f, -0.594020f, 0.093915f, 0.952699f, 0.289039f, 0.391077f, -0.905815f, 0.000000f,
        0.000000f, 0.577163f, 0.000000f, -0.076035f, 0.969256f, -0.234012f, 0.232397f, -0.439883f, 0.000000f,
        -0.193009f, 1.358116f, -0.594020f, 0.093915f, 0.952699f, 0.289039f, 0.391077f, -0.905815f, 0.000000f,
        0.196639f, 0.165431f, -0.605192f, 0.534905f, 0.072050f, -0.841834f, 0.480517f, -0.194237f, 0.000000f,
        0.003630f, 0.946384f, -1.199212f, 0.475540f, 0.171919f, -0.862732f, 0.464690f, -0.660168f, 0.000000f,
        0.196639f, 0.165431f, 0.605192f, 0.303425f, -0.189382f, 0.933846f, 0.017676f, -0.194237f, 0.000000f,
        -0.688515f, 0.868289f, 0.908647f, -0.891821f, 0.171919f, 0.418449f, 0.126479f, -0.613575f, 0.000000f,
        -0.514807f, 0.165431f, 0.374029f, -0.927565f, 0.072050f, 0.366649f, 0.174170f, -0.194237f, 0.000000f,
        -0.688515f, 0.868289f, 0.908647f, -0.891821f, 0.171919f, 0.418449f, 0.126479f, -0.613575f, 0.000000f,
        0.196639f, 0.165431f, 0.605192f, 0.303425f, -0.189382f, 0.933846f, 0.017676f, -0.194237f, 0.000000f,
        0.022931f, 0.868289f, 1.139810f, 0.475540f, 0.171919f, 0.862732f, 0.032802f, -0.613575f, 0.000000f,
        0.000000f, 0.577163f, 0.000000f, -0.076035f, 0.969256f, -0.234012f, 0.232397f, -0.439883f, 0.000000f,
        0.022931f, 0.868289f, 1.139810f, 0.475540f, 0.171919f, 0.862732f, 0.032802f, -0.613575f, 0.000000f,
        0.196639f, 0.165431f, 0.605192f, 0.303425f, -0.189382f, 0.933846f, 0.017676f, -0.194237f, 0.000000f,
        0.022931f, 0.868289f, 1.139810f, 0.475540f, 0.171919f, 0.862732f, 0.032802f, -0.613575f, 0.000000f,
        0.000000f, 0.577163f, 0.000000f, -0.076035f, 0.969256f, -0.234012f, 0.232397f, -0.439883f, 0.000000f,
        -0.173708f, 1.280021f, 0.534618f, 0.093915f, 0.952699f, -0.289039f, 0.105600f, -0.859222f, 0.000000f,
        -0.514807f, 0.165431f, 0.374029f, -0.927565f, 0.072050f, 0.366649f, 0.174170f, -0.194237f, 0.000000f,
        -0.173708f, 1.280021f, 0.534618f, 0.093915f, 0.952699f, -0.289039f, 0.105600f, -0.859222f, 0.000000f,
        0.000000f, 0.577163f, 0.000000f, -0.076035f, 0.969256f, -0.234012f, 0.232397f, -0.439883f, 0.000000f,
        -0.173708f, 1.280021f, 0.534618f, 0.093915f, 0.952699f, -0.289039f, 0.105600f, -0.859222f, 0.000000f,
        -0.514807f, 0.165431f, 0.374029f, -0.927565f, 0.072050f, 0.366649f, 0.174170f, -0.194237f, 0.000000f,
        -0.688515f, 0.868289f, 0.908647f, -0.891821f, 0.171919f, 0.418449f, 0.126479f, -0.613575f, 0.000000f,
    };

    static DWORD treeIndexData[] =
    {
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
        23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
        50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
        77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
        103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113
    };

    HRESULT hr = S_OK;
    g_NumIndices = sizeof( treeIndexData ) / sizeof( DWORD );
    g_VertStride = sizeof( TREE_VERTEX );

    D3D10_BUFFER_DESC bd;
    bd.Usage = D3D10_USAGE_DEFAULT;
    bd.ByteWidth = sizeof( treeVertexData );
    bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
    bd.CPUAccessFlags = 0;
    bd.MiscFlags = 0;
    D3D10_SUBRESOURCE_DATA InitData;
    InitData.pSysMem = treeVertexData;
    V_RETURN( pd3dDevice->CreateBuffer( &bd, &InitData, &g_pVB ) );

    bd.Usage = D3D10_USAGE_DEFAULT;
    bd.ByteWidth = sizeof( treeIndexData );
    bd.BindFlags = D3D10_BIND_INDEX_BUFFER;
    bd.CPUAccessFlags = 0;
    bd.MiscFlags = 0;
    InitData.pSysMem = treeIndexData;
    V_RETURN( pd3dDevice->CreateBuffer( &bd, &InitData, &g_pIB ) );

    // Load the Texture
    WCHAR strPath[MAX_PATH] = {0};
    DXUTFindDXSDKMediaFileCch( strPath, sizeof( strPath ) / sizeof( WCHAR ), L"bark_diff.dds" );
    hr = D3DX10CreateShaderResourceViewFromFile( pd3dDevice, strPath, NULL, NULL, &g_pMeshTexRV, NULL );

    return hr;
}
开发者ID:KNeal,项目名称:Oculus,代码行数:101,代码来源:Exercise04.cpp

示例13: OnD3D9CreateDevice

//--------------------------------------------------------------------------------------
// Create any D3D9 resources that will live through a device reset (D3DPOOL_MANAGED)
// and aren't tied to the back buffer size 
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D9CreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
                                     void* pUserContext )
{
	MessageBox(0, L"We aren't using DirectX9", L"We aren't using DirectX9", 0);
	exit(1);
	
	HRESULT hr;

    V_RETURN( g_DialogResourceManager.OnD3D9CreateDevice( pd3dDevice ) );
    V_RETURN( g_D3DSettingsDlg.OnD3D9CreateDevice( pd3dDevice ) );

    // Initialize the font
    V_RETURN( D3DXCreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
                              OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
                              L"Arial", &g_pFont9 ) );

    // Load the mesh
    V_RETURN( LoadMesh( pd3dDevice, L"tiny\\tiny.x", &g_pMesh9 ) );

    D3DXVECTOR3* pData;
    D3DXVECTOR3 vCenter;
    FLOAT fObjectRadius;
    V( g_pMesh9->LockVertexBuffer( 0, ( LPVOID* )&pData ) );
    V( D3DXComputeBoundingSphere( pData, g_pMesh9->GetNumVertices(),
                                  D3DXGetFVFVertexSize( g_pMesh9->GetFVF() ), &vCenter, &fObjectRadius ) );
    V( g_pMesh9->UnlockVertexBuffer() );

    D3DXMatrixTranslation( &g_mCenterMesh, -vCenter.x, -vCenter.y, -vCenter.z );
    D3DXMATRIXA16 m;
    D3DXMatrixRotationY( &m, D3DX_PI );
    g_mCenterMesh *= m;
    D3DXMatrixRotationX( &m, D3DX_PI / 2.0f );
    g_mCenterMesh *= m;

    V_RETURN( CDXUTDirectionWidget::StaticOnD3D9CreateDevice( pd3dDevice ) );
    g_LightControl.SetRadius( fObjectRadius );

    // Read the D3DX effect file
    WCHAR str[MAX_PATH];
    DWORD dwShaderFlags = D3DXFX_NOT_CLONEABLE | D3DXSHADER_NO_PRESHADER | D3DXFX_LARGEADDRESSAWARE;
#ifdef DEBUG_VS
        dwShaderFlags |= D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT;
    #endif
#ifdef DEBUG_PS
        dwShaderFlags |= D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT;
    #endif
    V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"BasicHLSL.fx" ) );
    V_RETURN( D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, dwShaderFlags, NULL, &g_pEffect9, NULL ) );

    // Create the mesh texture from a file
    V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"tiny\\tiny_skin.dds" ) );

    V_RETURN( D3DXCreateTextureFromFileEx( pd3dDevice, str, D3DX_DEFAULT, D3DX_DEFAULT,
                                           D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
                                           D3DX_DEFAULT, D3DX_DEFAULT, 0,
                                           NULL, NULL, &g_pMeshTexture9 ) );

    // Set effect variables as needed
    D3DXCOLOR colorMtrlDiffuse( 1.0f, 1.0f, 1.0f, 1.0f );
    D3DXCOLOR colorMtrlAmbient( 0.35f, 0.35f, 0.35f, 0 );

    D3DXHANDLE hMaterialAmbientColor = g_pEffect9->GetParameterByName( NULL, "g_MaterialAmbientColor" );
    D3DXHANDLE hMaterialDiffuseColor = g_pEffect9->GetParameterByName( NULL, "g_MaterialDiffuseColor" );
    D3DXHANDLE hMeshTexture = g_pEffect9->GetParameterByName( NULL, "g_MeshTexture" );

    V_RETURN( g_pEffect9->SetValue( hMaterialAmbientColor, &colorMtrlAmbient, sizeof( D3DXCOLOR ) ) );
    V_RETURN( g_pEffect9->SetValue( hMaterialDiffuseColor, &colorMtrlDiffuse, sizeof( D3DXCOLOR ) ) );
    V_RETURN( g_pEffect9->SetTexture( hMeshTexture, g_pMeshTexture9 ) );

    g_hLightDir = g_pEffect9->GetParameterByName( NULL, "g_LightDir" );
    g_hLightDiffuse = g_pEffect9->GetParameterByName( NULL, "g_LightDiffuse" );
    g_hmWorldViewProjection = g_pEffect9->GetParameterByName( NULL, "g_mWorldViewProjection" );
    g_hmWorld = g_pEffect9->GetParameterByName( NULL, "g_mWorld" );
    g_hMaterialDiffuseColor = g_pEffect9->GetParameterByName( NULL, "g_MaterialDiffuseColor" );
    g_hfTime = g_pEffect9->GetParameterByName( NULL, "g_fTime" );
    g_hnNumLights = g_pEffect9->GetParameterByName( NULL, "g_nNumLights" );
    g_hRenderSceneWithTexture1Light = g_pEffect9->GetTechniqueByName( "RenderSceneWithTexture1Light" );
    g_hRenderSceneWithTexture2Light = g_pEffect9->GetTechniqueByName( "RenderSceneWithTexture2Light" );
    g_hRenderSceneWithTexture3Light = g_pEffect9->GetTechniqueByName( "RenderSceneWithTexture3Light" );

    // Setup the camera's view parameters
    D3DXVECTOR3 vecEye( 0.0f, 0.0f, -15.0f );
    D3DXVECTOR3 vecAt ( 0.0f, 0.0f, -0.0f );
    g_Camera.SetViewParams( &vecEye, &vecAt );
    g_Camera.SetRadius( fObjectRadius * 3.0f, fObjectRadius * 0.5f, fObjectRadius * 10.0f );

    return S_OK;
}
开发者ID:Igings,项目名称:A-3D-game-in-a-2D-paradigm,代码行数:92,代码来源:BasicHLSL9.cpp

示例14: D3DXVECTOR3

//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependent on the back buffer
//--------------------------------------------------------------------------------------
HRESULT PerlinFire::OnD3D11CreateDevice( ID3D11Device * pd3dDevice)
{
	HRESULT hr;
	
	m_time = 0.0f;
	FirePosition = D3DXVECTOR3(0,0,0);
	const float lengthOfSide = 0.5f;
	//const float myparameter = 1.0f;
	SimpleVertex vertices[] =
	{
		{ D3DXVECTOR3( -lengthOfSide, lengthOfSide, -lengthOfSide ) ,D3DXVECTOR3(0,0,0),D3DXVECTOR2(0,0)},
		{ D3DXVECTOR3( lengthOfSide, lengthOfSide, -lengthOfSide ) ,D3DXVECTOR3(0,0,0),D3DXVECTOR2(0,0)},
		{ D3DXVECTOR3( lengthOfSide, lengthOfSide, lengthOfSide ) ,D3DXVECTOR3(0,0,0),D3DXVECTOR2(0,0)},
		{ D3DXVECTOR3( -lengthOfSide, lengthOfSide, lengthOfSide ) ,D3DXVECTOR3(0,0,0),D3DXVECTOR2(0,0)},
		{ D3DXVECTOR3( -lengthOfSide, -lengthOfSide, -lengthOfSide ) ,D3DXVECTOR3(0,0,0),D3DXVECTOR2(0,0)},
		{ D3DXVECTOR3( lengthOfSide, -lengthOfSide, -lengthOfSide ) ,D3DXVECTOR3(0,0,0),D3DXVECTOR2(0,0)},
		{ D3DXVECTOR3( lengthOfSide, -lengthOfSide, lengthOfSide ) ,D3DXVECTOR3(0,0,0),D3DXVECTOR2(0,0)},
		{ D3DXVECTOR3( -lengthOfSide, -lengthOfSide, lengthOfSide ) ,D3DXVECTOR3(0,0,0),D3DXVECTOR2(0,0)},
	};
	D3D11_BUFFER_DESC bd;
	ZeroMemory( &bd, sizeof(bd) );
	bd.Usage = D3D11_USAGE_DEFAULT;
	bd.ByteWidth = sizeof( SimpleVertex ) * 8;
	bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
	bd.CPUAccessFlags = 0;
	D3D11_SUBRESOURCE_DATA InitData;
	ZeroMemory( &InitData, sizeof(InitData) );
	InitData.pSysMem = vertices;
	V_RETURN(pd3dDevice->CreateBuffer( &bd, &InitData, &g_pBuffer ));

	WORD indices[] =
	{
		3,1,0,
		2,1,3,

		0,5,4,
		1,5,0,

		3,4,7,
		0,4,3,

		1,6,5,
		2,6,1,

		2,7,6,
		3,7,2,

		6,4,5,
		7,4,6,
	};
	bd.Usage = D3D11_USAGE_DEFAULT;
	bd.ByteWidth = sizeof( WORD ) * 36;        // 36 vertices needed for 12 triangles in a triangle list
	bd.BindFlags = D3D11_BIND_INDEX_BUFFER;
	bd.CPUAccessFlags = 0;
	InitData.pSysMem = indices;
	V_RETURN(pd3dDevice->CreateBuffer( &bd, &InitData, &g_pIndex ));

	V_RETURN(LoadEffectFromFile(pd3dDevice,L"PerlinFire.hlsl",&g_pEffect));

	// Obtain techniques
	g_pPerlinFire3D = g_pEffect->GetTechniqueByName( "PerlinFire3D" );
	g_pPerlinFire3DFlow = g_pEffect->GetTechniqueByName( "PerlinFire3DFlow" );
	g_pPerlinFire4D = g_pEffect->GetTechniqueByName( "PerlinFire4D" );
	g_pGeometryTechnique = g_pEffect->GetTechniqueByName( "RenderGeometry" );
	g_pGeometryTechniqueAux = g_pEffect->GetTechniqueByName( "RenderGeometryAux" );

	g_pCurrentTechnique = g_pPerlinFire4D;

	// Obtain texture variables

	g_ptxScreenDepth = g_pEffect->GetVariableByName( "ScreenDepth" )->AsShaderResource();
	g_ptxSceneTexture = g_pEffect->GetVariableByName( "SceneTexture" )->AsShaderResource();
	g_ptxFireTex = g_pEffect->GetVariableByName( "FireShape" )->AsShaderResource();
	g_ptxJitterTex = g_pEffect->GetVariableByName( "JitterTexture" )->AsShaderResource();
	g_ptxPermTex = g_pEffect->GetVariableByName( "PermTexture" )->AsShaderResource();
	g_pCubeMapTextureVariable = g_pEffect->GetVariableByName( "ShadowMap" )->AsShaderResource();

	// Obtain miscellaneous variables

	g_pmCubeViewMatrixVariable = g_pEffect->GetVariableByName( "CubeViewMatrices" )->AsMatrix();
	g_pmCubeProjMatrixVariable = g_pEffect->GetVariableByName( "CubeProjectionMatrix" )->AsMatrix();
	g_pmWorldViewProj = g_pEffect->GetVariableByName( "WorldViewProj" )->AsMatrix();
	g_pvEyePos = g_pEffect->GetVariableByName( "EyePos" )->AsVector();
	g_pvLightPos = g_pEffect->GetVariableByName( "LightPos" )->AsVector();
	g_pfLightIntensity = g_pEffect->GetVariableByName( "LightIntensity" )->AsScalar();
	g_pfStepSize = g_pEffect->GetVariableByName( "StepSize" )->AsScalar();
	g_pfTime = g_pEffect->GetVariableByName( "Time" )->AsScalar();
	g_pfNoiseScale = g_pEffect->GetVariableByName( "NoiseScale" )->AsScalar();
	g_pfRoughness = g_pEffect->GetVariableByName( "Roughness" )->AsScalar();
	g_pfFrequencyWeights = g_pEffect->GetVariableByName( "FrequencyWeights" )->AsScalar();
	g_pbJitter = g_pEffect->GetVariableByName( "bJitter" )->AsScalar();
	g_piCubeMapFace = g_pEffect->GetVariableByName( "CubeMapFace" )->AsScalar();

	// Set input layouts

	D3DX11_PASS_DESC PassDesc;

//.........这里部分代码省略.........
开发者ID:denghc,项目名称:danmugame,代码行数:101,代码来源:PerlinFire.cpp

示例15: V_RETURN

HRESULT CSkybox11::OnD3D11CreateDevice( ID3D11Device* pd3dDevice, float fSize, 
    ID3D11Texture2D* pCubeTexture, ID3D11ShaderResourceView* pCubeRV )
{
    HRESULT hr;

    m_pd3dDevice11 = pd3dDevice;
    m_fSize = fSize;
    m_pEnvironmentMap11 = pCubeTexture;
    m_pEnvironmentRV11 = pCubeRV;

    ID3DBlob* pBlobVS = NULL;
    ID3DBlob* pBlobPS = NULL;

    // Create the shaders
    tstring filePath = GetFilePath::GetFilePath(_T("skybox.hlsl"));
    //    V_RETURN( CompileShaderFromFile( L"skybox11.hlsl", "SkyboxVS", "vs_4_0", &pBlobVS ) );
    //    V_RETURN( CompileShaderFromFile( L"skybox11.hlsl", "SkyboxPS", "ps_4_0", &pBlobPS ) );
    V_RETURN( CompileShaderFromFile( (WCHAR *)filePath.c_str(), "SkyboxVS", "vs_4_0", &pBlobVS ) );
    V_RETURN( CompileShaderFromFile( (WCHAR *)filePath.c_str(), "SkyboxPS", "ps_4_0", &pBlobPS ) );

    V_RETURN( pd3dDevice->CreateVertexShader( pBlobVS->GetBufferPointer(), pBlobVS->GetBufferSize(), NULL, &m_pVertexShader ) );
    V_RETURN( pd3dDevice->CreatePixelShader( pBlobPS->GetBufferPointer(), pBlobPS->GetBufferSize(), NULL, &m_pPixelShader ) );

    // Create an input layout
    V_RETURN( pd3dDevice->CreateInputLayout( g_aVertexLayout, 1, pBlobVS->GetBufferPointer(),
        pBlobVS->GetBufferSize(), &m_pVertexLayout11 ) );

    SAFE_RELEASE( pBlobVS );
    SAFE_RELEASE( pBlobPS );

    // Query support for linear filtering on DXGI_FORMAT_R32G32B32A32
    UINT FormatSupport = 0;
    V_RETURN( pd3dDevice->CheckFormatSupport( DXGI_FORMAT_R32G32B32A32_FLOAT, &FormatSupport ) );

    // Setup linear or point sampler according to the format Query result
    D3D11_SAMPLER_DESC SamDesc;
    SamDesc.Filter = ( FormatSupport & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE ) > 0 ? D3D11_FILTER_MIN_MAG_MIP_LINEAR : D3D11_FILTER_MIN_MAG_MIP_POINT;
    SamDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
    SamDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
    SamDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
    SamDesc.MipLODBias = 0.0f;
    SamDesc.MaxAnisotropy = 1;
    SamDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
    SamDesc.BorderColor[0] = SamDesc.BorderColor[1] = SamDesc.BorderColor[2] = SamDesc.BorderColor[3] = 0;
    SamDesc.MinLOD = 0;
    SamDesc.MaxLOD = 0;
    V_RETURN( pd3dDevice->CreateSamplerState( &SamDesc, &m_pSam ) );  

    // Setup constant buffer
    D3D11_BUFFER_DESC Desc;
    Desc.Usage = D3D11_USAGE_DYNAMIC;
    Desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
    Desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
    Desc.MiscFlags = 0;
    Desc.ByteWidth = sizeof( CB_VS_PER_OBJECT );
    V_RETURN( pd3dDevice->CreateBuffer( &Desc, NULL, &m_pcbVSPerObject ) );

    // Depth stencil state
    D3D11_DEPTH_STENCIL_DESC DSDesc;
    ZeroMemory( &DSDesc, sizeof( D3D11_DEPTH_STENCIL_DESC ) );
    DSDesc.DepthEnable = FALSE;
    DSDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
    DSDesc.DepthFunc = D3D11_COMPARISON_LESS;
    DSDesc.StencilEnable = FALSE;
    V_RETURN( pd3dDevice->CreateDepthStencilState( &DSDesc, &m_pDepthStencilState11 ) );

    return S_OK;
}
开发者ID:xiaohuaxiong,项目名称:hello-world,代码行数:68,代码来源:skybox.cpp


注:本文中的V_RETURN函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。