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


C++ LPDIRECT3DDEVICE9::CreateTexture方法代码示例

本文整理汇总了C++中LPDIRECT3DDEVICE9::CreateTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE9::CreateTexture方法的具体用法?C++ LPDIRECT3DDEVICE9::CreateTexture怎么用?C++ LPDIRECT3DDEVICE9::CreateTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPDIRECT3DDEVICE9的用法示例。


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

示例1: CreateShadowMap

void DXDirectionalLight::CreateShadowMap(LPDIRECT3DDEVICE9 device, DWORD type, DWORD size)
{
	HRESULT hr;

	DXLight::CreateShadowMap(device, type, size);
	hr = device->CreateTexture(size, size, 1, D3DUSAGE_RENDERTARGET, D3DFMT_G32R32F, D3DPOOL_DEFAULT, &shadowmap, NULL);

	if( SUCCEEDED(hr) )
		hr = device->CreateTexture(size, size, 1, D3DUSAGE_RENDERTARGET, D3DFMT_G32R32F, D3DPOOL_DEFAULT, &blur, NULL);

	if( FAILED(hr) )
	{
		if( shadowmap )
			shadowmap->Release();

		shadowmap = blur = NULL;
	}

	if( !blurdeclforpointfordirectional )
	{
		D3DVERTEXELEMENT9 elem[] =
		{
			{ 0, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITIONT, 0 },
			{ 0, 16, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
			D3DDECL_END()
		};

		device->CreateVertexDeclaration(elem, &blurdeclforpointfordirectional);
	}
	else
		blurdeclforpointfordirectional->AddRef();
}
开发者ID:m10914,项目名称:tbill,代码行数:32,代码来源:Lights.cpp

示例2:

IDirect3DTexture9 *CreatTex(LPSTR dat)
{
	LPDIRECT3DTEXTURE9 pTex = NULL;
	UINT xx,yy;
	xx = *(UINT*)(dat+4);
	yy = *(UINT*)(dat+8);
	D3DLOCKED_RECT rc;
	HRESULT hr;

	if (*(DWORD*)(dat+0x28) == 'DXT3')
	{
		hr = g_pD3DDevice->CreateTexture(xx,yy,0,0 ,D3DFMT_DXT3,D3DPOOL_MANAGED,&pTex,NULL);
		if (hr != D3D_OK) return NULL;

		hr = pTex->LockRect(0,&rc,NULL,0);
		if (hr == D3D_OK)
		{
			CopyMemory(rc.pBits,dat+0x28+12,(xx/4) * (yy/4) * 16 );
			pTex->UnlockRect(0);
		}
		return pTex;
	}

	if (*(DWORD*)(dat+0x28) == 'DXT1')
	{
		hr = g_pD3DDevice->CreateTexture(xx,yy,0,0,D3DFMT_DXT1,D3DPOOL_MANAGED,&pTex,NULL);
		if (hr != D3D_OK) return NULL;

		hr = pTex->LockRect(0,&rc,NULL,0);
		if (hr == D3D_OK)
		{
			CopyMemory(rc.pBits,dat+0x28+12,(xx/4) * (yy/4) * 8  );
			pTex->UnlockRect(0);
		}
		return pTex;
	}

	hr = g_pD3DDevice->CreateTexture(xx,yy,0,0,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,&pTex,NULL);
	if (hr != D3D_OK) return NULL;

	hr = pTex->LockRect(0,&rc,NULL,0);
	if (hr == D3D_OK)
	{
		for (DWORD jy = 0; jy < yy; ++jy)
		{
			for (DWORD jx = 0; jx < xx; ++jx)
			{
				DWORD *pp  = (DWORD *)rc.pBits;
				BYTE  *idx = (BYTE  *)(dat+0x28+0x400);
				DWORD *pal = (DWORD *)(dat+0x28);
				pp[(yy-jy-1)*xx+jx] = pal[idx[jy*xx+jx]];
			}
		}
		pTex->UnlockRect(0);
	}
	return pTex;
}
开发者ID:fedaykinofdune,项目名称:ffxinfinity,代码行数:57,代码来源:TDWGame.cpp

示例3: defined

unsigned RageDisplay_D3D::CreateTexture( 
	RagePixelFormat pixfmt,
	RageSurface* img,
	bool bGenerateMipMaps )
{
	// texture must be power of two
	ASSERT( img->w == power_of_two(img->w) );
	ASSERT( img->h == power_of_two(img->h) );


	HRESULT hr;
	IDirect3DTexture9* pTex;
	hr = g_pd3dDevice->CreateTexture( img->w, img->h, 1, 0, D3DFORMATS[pixfmt], D3DPOOL_MANAGED, &pTex, NULL );

#if defined(XBOX)
	while(hr == E_OUTOFMEMORY)
	{
		if(!vmem_Manager.DecommitLRU())
			break;
		hr = g_pd3dDevice->CreateTexture( img->w, img->h, 1, 0, D3DFORMATS[pixfmt], D3DPOOL_MANAGED, &pTex );
	}
#endif

	if( FAILED(hr) )
		RageException::Throw( "CreateTexture(%i,%i,pixfmt=%i) failed: %s", 
		img->w, img->h, pixfmt, GetErrorString(hr).c_str() );

	unsigned uTexHandle = (unsigned)pTex;

	if( pixfmt == FMT_PAL )
	{
		// Save palette
		TexturePalette pal;
		memset( pal.p, 0, sizeof(pal.p) );
		for( int i=0; i<img->format->palette->ncolors; i++ )
		{
			RageSurfaceColor &c = img->format->palette->colors[i];
			pal.p[i].peRed = c.r;
			pal.p[i].peGreen = c.g;
			pal.p[i].peBlue = c.b;
			pal.p[i].peFlags = c.a;
		}

		ASSERT( g_TexResourceToTexturePalette.find(uTexHandle) == g_TexResourceToTexturePalette.end() );
		g_TexResourceToTexturePalette[uTexHandle] = pal;
	}

	UpdateTexture( uTexHandle, img, 0, 0, img->w, img->h );

	return uTexHandle;
}
开发者ID:augustg,项目名称:openitg,代码行数:51,代码来源:RageDisplay_D3D.cpp

示例4: InitResourceDX9

bool InitResourceDX9(void)
{
	// 取得Direct3D 9裝置
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
	// 設定視角轉換矩陣
	g_projection_matrix = GutMatrixPerspectiveRH_DirectX(g_fFOV, 1.0f, 0.1f, 100.0f);
	device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &g_projection_matrix);
	// 關閉打光
	device->SetRenderState(D3DRS_LIGHTING, FALSE);
	// 改變三角形正面的面向
	device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	// 使用自動normalize功能
	device->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);

	// 配置動態貼圖
	{
		device->CreateTexture(g_framebuffer_w, g_framebuffer_h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_pTexture, NULL);
		device->CreateDepthStencilSurface(g_framebuffer_w, g_framebuffer_h, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, 0, FALSE, &g_pDepthStencil, NULL);

		device->CreateTexture(g_framebuffer_w, g_framebuffer_h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_pBlurTextures[0], NULL);
		device->CreateTexture(g_framebuffer_w, g_framebuffer_h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_pBlurTextures[1], NULL);
	}

	// 載入模型
	{
		CGutModel::SetTexturePath("../../textures/");

		g_Model_DX9.ConvertToDX9Model(&g_Model);
		g_Terrain_DX9.ConvertToDX9Model(&g_Terrain);
	}

	// 設定貼圖內插方法
	{
		device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
		device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
		device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);

		device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
		device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);

		device->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
		device->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
		device->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_NONE);

		device->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
		device->SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
	}

	return true;
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:50,代码来源:render_dx9.cpp

示例5: InitEverything

//------------------------------------------------------------
// Initialization code
//------------------------------------------------------------
bool InitEverything(HWND hWnd)
{
	// init D3D
	if (!InitD3D(hWnd))
	{
		return false;
	}

	// create a fullscreen quad
	InitFullScreenQuad();

	// create a render target
	if (FAILED(gpD3DDevice->CreateTexture(WIN_WIDTH, WIN_HEIGHT,
		1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8,
		D3DPOOL_DEFAULT, &gpSceneRenderTarget, NULL)))
	{
		return false;
	}

	// loading models, shaders and textures
	if (!LoadAssets())
	{
		return false;
	}

	// load fonts
	if (FAILED(D3DXCreateFont(gpD3DDevice, 20, 10, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
		OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, (DEFAULT_PITCH | FF_DONTCARE),
		"Arial", &gpFont)))
	{
		return false;
	}

	return true;
}
开发者ID:popekim,项目名称:ShaderPrimer,代码行数:38,代码来源:ShaderFramework.cpp

示例6: CreateColorTex

static HRESULT CreateColorTex(LPDIRECT3DDEVICE9 device, DWORD color, LPDIRECT3DTEXTURE9* texture)
{
	UINT width = 4;
	UINT height = 4;

	D3DLOCKED_RECT rect;
	HRESULT hr = device->CreateTexture(width, height, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, texture, NULL);

	if( FAILED(hr) )
		return hr;

	(*texture)->LockRect(0, &rect, NULL, 0);

	for( UINT i = 0; i < height; ++i )
	{
		for( UINT j = 0; j < width; ++j )
		{
			DWORD* ptr = ((DWORD*)rect.pBits + i * width + j);
			*ptr = color;
		}
	}

	(*texture)->UnlockRect(0);
	return S_OK;
}
开发者ID:galek,项目名称:Asylum_Tutorials,代码行数:25,代码来源:main.cpp

示例7: InitStateDX9

void InitStateDX9(void)
{
	// 取得Direct3D 9裝置
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();

	// 關閉打光
	device->SetRenderState(D3DRS_LIGHTING, FALSE);
	// 使用trilinear
	device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
	//
	device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	//
	device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE);

	device->GetRenderTarget(0, &g_pMainFrameBuffer);
	device->GetDepthStencilSurface(&g_pMainDepthBuffer);

	int width, height;
	GutGetWindowSize(width, height);

	g_iFrameBufferWidth = width * 2;
	g_iFrameBufferHeight = height * 2;

	device->CreateTexture(g_iFrameBufferWidth, g_iFrameBufferHeight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_pTexture, NULL);
	device->CreateDepthStencilSurface(g_iFrameBufferWidth, g_iFrameBufferHeight, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, 0, FALSE, &g_pDepthStencil, NULL);
	g_pTexture->GetSurfaceLevel(0, &g_pFrameBuffer);
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:29,代码来源:render_dx9.cpp

示例8: Device

// 텍스처
// 생성자 (크기)
CTexture::CTexture(LPDIRECT3DDEVICE9 device, int w, int h)
	: Device(device), Texture(nullptr), TextureW(w), TextureH(h), OriginalW(w), OriginalH(h)
{
	device->CreateTexture(
		w, h, 1, D3DUSAGE_RENDERTARGET,
		D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &Texture, nullptr);
}
开发者ID:codebachi,项目名称:ProjectDirectX,代码行数:9,代码来源:Texture.cpp

示例9: renderer

	DistortingCallback( ::EffekseerRendererDX9::Renderer* renderer, 
		LPDIRECT3DDEVICE9 device, int texWidth, int texHeight )
		: renderer( renderer ), device( device )
	{
		device->CreateTexture( texWidth, texHeight, 1, D3DUSAGE_RENDERTARGET, 
			D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL );
	}
开发者ID:AndrewFM,项目名称:Effekseer,代码行数:7,代码来源:graphics_dx9.cpp

示例10: CreateTexture

bool CDynamicTexture::CreateTexture(LPDIRECT3DDEVICE9 device, UINT width, UINT height, D3DFORMAT format)
{
    assert(m_textureSystem == NULL && m_surfaceSystem == NULL
           && m_textureDefault == NULL && m_surfaceDefault == NULL);
    m_device = device;

    m_width = width;
    m_height = height;
    m_format = format;

    if (CreateDefaultTexture() == false)
        return false;

    if (FAILED(device->CreateTexture(width, height, 1,
                                     D3DUSAGE_DYNAMIC, format,
                                     D3DPOOL_SYSTEMMEM, &m_textureSystem, NULL)))
    {
        MessageBox(NULL, "Create Texture Error", "ERROR", 0);
        return false;
    }
    if (FAILED(m_textureSystem->GetSurfaceLevel(0, &m_surfaceSystem)))
    {
        m_textureSystem->Release();
        m_textureSystem = NULL;
        MessageBox(NULL, "Get Surface Error", "ERROR", 0);
        return false;
    }
    return true;
}
开发者ID:redclock,项目名称:GIEngine,代码行数:29,代码来源:DynamicTexture.cpp

示例11: load

/**
 * load() method loads in a lightmap from pixel buffer "data", using the
 * information found in face. The d3dFace parameter is the face used for
 * triangulating a BSP Face. The d3dFace also keeps track of the texture
 * coordinates used for the lightmap, which is why it is needed to load
 * the lightmap. The "device" parameter is used in making a texture from
 * the lightmap with Direct3D.
 */
void LightMap::load( char *data, BSP::Face *face, D3D::Face *d3dFace, LPDIRECT3DDEVICE9 device ) {

    // compute the width and height of this lightmap
    width = ceil( d3dFace->getMaxU() / 16 ) - floor( d3dFace->getMinU() / 16 ) + 1;
    height = ceil( d3dFace->getMaxV() / 16 ) - floor( d3dFace->getMinV() / 16 ) + 1;

    // The maximum width or height of a lightmap is 16 pixels
    if ( width > 16 ) {
        width = 16;
    }
    if ( height > 16 ) {
        height = 16;
    }

    // Copy the data from the data pointer into a temporary Pixel buffer
    vector< Pixel > pixels;
    pixels.resize( width * height );

    data += face->lightmap_offset;

    Pixel *copy = ( Pixel * ) data;

    for ( int i = 0; i < width * height; ++i ) {
        pixels[ i ].r = copy->b;
        pixels[ i ].g = copy->g;
        pixels[ i ].b = copy->r;
        pixels[ i ].a = 255;

        data += 3;
        copy = ( Pixel * ) data;
    }

    // Give DirectX our lightmap information
    D3DLOCKED_RECT lr;

    device->CreateTexture(width,
		height, 1, 0,
		D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture, NULL);

	texture->LockRect( 0, &lr, NULL, 0 );

	unsigned char* pRect = ( UCHAR* ) lr.pBits;

    // copy image to pRect
    memcpy( pRect, &pixels[ 0 ], width * height * sizeof( Pixel ) );

	texture->UnlockRect( 0 );

    //d3dFace->divideLMTexCoords( d3dFace->getMaxU() - d3dFace->getMinU(), d3dFace->getMaxV() - d3dFace->getMinV() );
    //d3dFace->shiftLMTexCoords( -d3dFace->getMinU(), -d3dFace->getMinV() );

    // Top-left corner is at luxel coord: (-8, -8)
    d3dFace->shiftLMTexCoords( -d3dFace->getMinU() - 8, -d3dFace->getMinV() - 8 );
    //d3dFace->shiftLMTexCoords( -d3dFace->getMinU() - 7, -d3dFace->getMinV() - 7 );
    //d3dFace->shiftLMTexCoords( -8, -8 );
    d3dFace->divideLMTexCoords( d3dFace->getMaxU() - d3dFace->getMinU(), d3dFace->getMaxV() - d3dFace->getMinV() );

};
开发者ID:zachangold,项目名称:Quake2Tribute,代码行数:66,代码来源:LightMapInfo.cpp

示例12:

HRESULT HookIDirect3DDevice9::CreateTexture(LPVOID _this, UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture9** ppTexture,HANDLE* pSharedHandle)
{
	LOG_API();
	HRESULT res = pD3Dev->CreateTexture(Width, Height, Levels, Usage, Format, Pool, ppTexture, pSharedHandle);
	if (Usage & D3DUSAGE_RENDERTARGET) {
		logmsg("RENDER_TARGET %d, %d = %x\n", Width, Height, *ppTexture);
	}
	return res;
}
开发者ID:zxmarcos,项目名称:bg4t_monitor,代码行数:9,代码来源:D3DWrapper.cpp

示例13: InitD3D

//-----------------------------------------------------------------------------
// Desc: 初始化Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D(HWND hWnd)
{
	//创建Direct3D对象, 该对象用于创建Direct3D设备对象
	if (NULL == (g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
		return E_FAIL;

	//设置D3DPRESENT_PARAMETERS结构, 准备创建Direct3D设备对象
	D3DPRESENT_PARAMETERS d3dpp;
	ZeroMemory(&d3dpp, sizeof(d3dpp));
	d3dpp.Windowed = TRUE;
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;

	//创建Direct3D设备对象
	if (FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
		D3DCREATE_SOFTWARE_VERTEXPROCESSING,
		&d3dpp, &g_pd3dDevice)))
	{
		return E_FAIL;
	}

	//禁用照明效果
	g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);

	g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

	HRESULT hr = g_pd3dDevice->CreateTexture(256, 256, 1, D3DUSAGE_RENDERTARGET,
		D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_pRenderTex, NULL);
	if (FAILED(hr))
	{
		return E_FAIL;
	}
	g_pRenderTex->GetSurfaceLevel(0, &g_pRenderSur);

	hr = g_pd3dDevice->CreateTexture(256, 256, 1, D3DUSAGE_RENDERTARGET,
		D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_pRender2Tex, NULL);
	if (FAILED(hr))
	{
		return E_FAIL;
	}
	g_pRender2Tex->GetSurfaceLevel(0, &g_pRender2Sur);

	return S_OK;
}
开发者ID:kristyfuwa,项目名称:TwiLight,代码行数:47,代码来源:D3D9_RenderToTexture.cpp

示例14:

bool CDX9TextureObject::MakeBlankTexture( UINT sizex, UINT sizey, UINT colordepth, IHashString * hformat, UINT mips )
{
	DeInit();

	LPDIRECT3DDEVICE9 pDevice;
	if( !m_Renderer )
	{
		return false;
	}
	pDevice = (LPDIRECT3DDEVICE9)m_Renderer->GetAPIDevice();
	if( !pDevice )
	{
		return false;
	}
	UINT numMips = mips;
	CDX9Renderer * crend = dynamic_cast<CDX9Renderer*>(m_Renderer);
	D3DFORMAT format = D3DFMT_A8R8G8B8;
	if( hformat )
	{
		format = EEDX9FormatFromString( hformat );
		if( format == D3DFMT_UNKNOWN )
		{
			format = D3DFMT_A8R8G8B8;
		}			
		m_Compressed = EEDX9IsCompressedFormat( format );
	}
	else
		format = EEDX9FormatFromColorBits( colordepth );

	//create new texture	
	LPDIRECT3DTEXTURE9 temptex;
	//TODO: more control over texture creation?
	if(FAILED(pDevice->CreateTexture( sizex, //width
									 sizey, //height
									numMips, //number of mips
									0,	//usage - 0 unless for render targets
									format,
									D3DPOOL_MANAGED, //TODO: managed vs. Unmanaged! unmanaged you can't lock!								
									&temptex,
									NULL)))
		{
			return false;
		}
		
	if( !temptex )
	{
		return false;
	}
	
	m_Texture = temptex;
	m_Height = sizey;
	m_Width = sizex;
	m_ColorDepth = colordepth;
	m_bRenderTarget = false;
	return true;
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:56,代码来源:CDX9TextureObject.cpp

示例15: sizeof

// ---------- framework : setup dx ----------
bool rtvsD3dApp::setupDX (LPDIRECT3DDEVICE9 pd3dDevice)
{
  pd3dDevice->SetRenderState( D3DRS_LIGHTING , TRUE );
  pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
  pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_GAUSSIANQUAD );

  // ---- create a texture object ----
  //D3DXCreateTextureFromFile( pd3dDevice, "image/baboon.jpg", &pTexture );

  // get mode
  D3DDISPLAYMODE mode;
  returnvalue = pd3dDevice->GetDisplayMode(0, &mode);
  if (FAILED(returnvalue))
    return E_FAIL;

  // try create texture
  returnvalue = pd3dDevice->CreateTexture(WIDTH, HEIGHT, 1, 0,
		mode.Format, D3DPOOL_MANAGED, &pTexture, NULL);

	if (FAILED(returnvalue))
    return E_FAIL;

	
	// ---- QUAD ----
  void *pVertices = NULL;
  // ---- initialise quad vertex data ----
 	QuadVertex quadVertices[] =
	{
		//    x      y     z      nx     ny     nz    tu     tv
		{  1.28f,  0.93f, 2.0f,   0.0f,  1.0f,  0.0f,  0.0f,  0.0f }, //top right
		{ -1.28f,  0.93f, 2.0f,   0.0f,  1.0f,  0.0f,  1.0f,  0.0f }, //top left
		{  1.28f, -0.93f, 2.0f,   0.0f,  1.0f,  0.0f,  0.0f,  1.0f },
		{ -1.28f, -0.93f, 2.0f,   0.0f,  1.0f,  0.0f,  1.0f,  1.0f }
	};

	// ---- create quad vertex buffer ----
	int numQuadVertices = sizeof(quadVertices) / ( sizeof(float) * 8 /* +  sizeof(DWORD)*/);
	numQuadTriangles = numQuadVertices / 2;
	pd3dDevice->CreateVertexBuffer( numQuadVertices*sizeof(QuadVertex),
                                      D3DUSAGE_WRITEONLY,
                                      QuadVertex::FVF_Flags,
                                      D3DPOOL_MANAGED, // does not have to be properly Released before calling IDirect3DDevice9::Reset
                                      //D3DPOOL_DEFAULT,   // must be Released properly before calling IDirect3DDevice9::Reset
                                      &pQuadVertexBuffer, NULL );

	// ---- block copy into quad vertex buffer ----
	pVertices = NULL;
	pQuadVertexBuffer->Lock( 0, sizeof(quadVertices), (void**)&pVertices, 0 );
	memcpy( pVertices, quadVertices, sizeof(quadVertices) );
	pQuadVertexBuffer->Unlock();

  setupAntTW(pd3dDevice);

	// ok
	return true;
}
开发者ID:iqabsent,项目名称:cge-raytracer,代码行数:57,代码来源:rtvsD3dApp.cpp


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