本文整理汇总了C#中VertexBuffer.SafeDispose方法的典型用法代码示例。如果您正苦于以下问题:C# VertexBuffer.SafeDispose方法的具体用法?C# VertexBuffer.SafeDispose怎么用?C# VertexBuffer.SafeDispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexBuffer
的用法示例。
在下文中一共展示了VertexBuffer.SafeDispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderImage
//.........这里部分代码省略.........
if (x + nw > GUIGraphicsContext.Width)
{
nw = GUIGraphicsContext.Width - x;
}
if (y + nh > GUIGraphicsContext.Height)
{
nh = GUIGraphicsContext.Height - y;
}
CustomVertex.TransformedColoredTextured[] verts =
(CustomVertex.TransformedColoredTextured[])m_vbBuffer.Lock(0, 0);
// Lock the buffer (which will return our structs)
verts[0].X = x - 0.5f;
verts[0].Y = y + nh - 0.5f;
verts[0].Z = 0.0f;
verts[0].Rhw = 1.0f;
verts[0].Color = (int)lColorDiffuse;
verts[0].Tu = uoffs;
verts[0].Tv = voffs + vmax;
verts[1].X = x - 0.5f;
verts[1].Y = y - 0.5f;
verts[1].Z = 0.0f;
verts[1].Rhw = 1.0f;
verts[1].Color = (int)lColorDiffuse;
verts[1].Tu = uoffs;
verts[1].Tv = voffs;
verts[2].X = x + nw - 0.5f;
verts[2].Y = y + nh - 0.5f;
verts[2].Z = 0.0f;
verts[2].Rhw = 1.0f;
verts[2].Color = (int)lColorDiffuse;
verts[2].Tu = uoffs + umax;
verts[2].Tv = voffs + vmax;
verts[3].X = x + nw - 0.5f;
verts[3].Y = y - 0.5f;
verts[3].Z = 0.0f;
verts[3].Rhw = 1.0f;
verts[3].Color = (int)lColorDiffuse;
verts[3].Tu = uoffs + umax;
verts[3].Tv = voffs;
m_vbBuffer.Unlock();
GUIGraphicsContext.DX9Device.SetTexture(0, texture);
DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLOROP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG1, (int)D3DTA.D3DTA_TEXTURE);
DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG2, (int)D3DTA.D3DTA_DIFFUSE);
DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAOP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG1, (int)D3DTA.D3DTA_TEXTURE);
DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG2, (int)D3DTA.D3DTA_DIFFUSE);
DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLOROP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG1, (int)D3DTA.D3DTA_TEXTURE);
DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG2, (int)D3DTA.D3DTA_DIFFUSE);
DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAOP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG1, (int)D3DTA.D3DTA_TEXTURE);
DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG2, (int)D3DTA.D3DTA_DIFFUSE);
DXNative.FontEngineSetTextureStageState(1, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLOROP, (int)D3DTEXTUREOP.D3DTOP_DISABLE);
DXNative.FontEngineSetTextureStageState(1, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAOP, (int)D3DTEXTUREOP.D3DTOP_DISABLE);
int g_nAnisotropy = GUIGraphicsContext.DX9Device.DeviceCaps.MaxAnisotropy;
float g_fMipMapLodBias = 0.0f;
DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAXANISOTROPY, (uint)g_nAnisotropy);
DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPMAPLODBIAS, (uint)g_fMipMapLodBias);
DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAXANISOTROPY, (uint)g_nAnisotropy);
DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPMAPLODBIAS, (uint)g_fMipMapLodBias);
// Render the image
GUIGraphicsContext.DX9Device.SetStreamSource(0, m_vbBuffer, 0);
GUIGraphicsContext.DX9Device.VertexFormat = CustomVertex.TransformedColoredTextured.Format;
GUIGraphicsContext.DX9Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
// unset the texture and palette or the texture caching crashes because the runtime still has a reference
GUIGraphicsContext.DX9Device.SetTexture(0, null);
}
finally
{
if (m_vbBuffer != null)
{
m_vbBuffer.SafeDispose();
}
}
}
示例2: RenderImage
//.........这里部分代码省略.........
if (x > GUIGraphicsContext.Width)
x = GUIGraphicsContext.Width;
if (y < 0)
y = 0;
if (y > GUIGraphicsContext.Height)
y = GUIGraphicsContext.Height;
if (nw < 0)
nw = 0;
if (nh < 0)
nh = 0;
if (x + nw > GUIGraphicsContext.Width)
{
nw = GUIGraphicsContext.Width - x;
}
if (y + nh > GUIGraphicsContext.Height)
{
nh = GUIGraphicsContext.Height - y;
}
CustomVertex.TransformedColoredTextured[] verts =
(CustomVertex.TransformedColoredTextured[])m_vbBuffer.Lock(0, 0);
// Lock the buffer (which will return our structs)
verts[0].X = x - 0.5f;
verts[0].Y = y + nh - 0.5f;
verts[0].Z = 0.0f;
verts[0].Rhw = 1.0f;
verts[0].Color = (int)lColorDiffuse;
verts[0].Tu = uoffs;
verts[0].Tv = voffs + vmax;
verts[1].X = x - 0.5f;
verts[1].Y = y - 0.5f;
verts[1].Z = 0.0f;
verts[1].Rhw = 1.0f;
verts[1].Color = (int)lColorDiffuse;
verts[1].Tu = uoffs;
verts[1].Tv = voffs;
verts[2].X = x + nw - 0.5f;
verts[2].Y = y + nh - 0.5f;
verts[2].Z = 0.0f;
verts[2].Rhw = 1.0f;
verts[2].Color = (int)lColorDiffuse;
verts[2].Tu = uoffs + umax;
verts[2].Tv = voffs + vmax;
verts[3].X = x + nw - 0.5f;
verts[3].Y = y - 0.5f;
verts[3].Z = 0.0f;
verts[3].Rhw = 1.0f;
verts[3].Color = (int)lColorDiffuse;
verts[3].Tu = uoffs + umax;
verts[3].Tv = voffs;
m_vbBuffer.Unlock();
GUIGraphicsContext.DX9Device.SetTexture(0, texture);
GUIGraphicsContext.DX9Device.TextureState[0].ColorOperation = Direct3D.TextureOperation.Modulate;
GUIGraphicsContext.DX9Device.TextureState[0].ColorArgument1 = Direct3D.TextureArgument.TextureColor;
GUIGraphicsContext.DX9Device.TextureState[0].ColorArgument2 = Direct3D.TextureArgument.Diffuse;
GUIGraphicsContext.DX9Device.TextureState[0].AlphaOperation = Direct3D.TextureOperation.Modulate;
GUIGraphicsContext.DX9Device.TextureState[0].AlphaArgument1 = Direct3D.TextureArgument.TextureColor;
GUIGraphicsContext.DX9Device.TextureState[0].AlphaArgument2 = Direct3D.TextureArgument.Diffuse;
GUIGraphicsContext.DX9Device.TextureState[1].ColorOperation = Direct3D.TextureOperation.Disable;
GUIGraphicsContext.DX9Device.TextureState[1].AlphaOperation = Direct3D.TextureOperation.Disable;
int g_nAnisotropy = GUIGraphicsContext.DX9Device.DeviceCaps.MaxAnisotropy;
float g_fMipMapLodBias = 0.0f;
GUIGraphicsContext.DX9Device.SamplerState[0].MinFilter = TextureFilter.Linear;
GUIGraphicsContext.DX9Device.SamplerState[0].MagFilter = TextureFilter.Linear;
GUIGraphicsContext.DX9Device.SamplerState[0].MipFilter = TextureFilter.Linear;
GUIGraphicsContext.DX9Device.SamplerState[0].MaxAnisotropy = g_nAnisotropy;
GUIGraphicsContext.DX9Device.SamplerState[0].MipMapLevelOfDetailBias = g_fMipMapLodBias;
GUIGraphicsContext.DX9Device.SamplerState[1].MinFilter = TextureFilter.Linear;
GUIGraphicsContext.DX9Device.SamplerState[1].MagFilter = TextureFilter.Linear;
GUIGraphicsContext.DX9Device.SamplerState[1].MipFilter = TextureFilter.Linear;
GUIGraphicsContext.DX9Device.SamplerState[1].MaxAnisotropy = g_nAnisotropy;
GUIGraphicsContext.DX9Device.SamplerState[1].MipMapLevelOfDetailBias = g_fMipMapLodBias;
// Render the image
GUIGraphicsContext.DX9Device.SetStreamSource(0, m_vbBuffer, 0);
GUIGraphicsContext.DX9Device.VertexFormat = CustomVertex.TransformedColoredTextured.Format;
GUIGraphicsContext.DX9Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
// unset the texture and palette or the texture caching crashes because the runtime still has a reference
GUIGraphicsContext.DX9Device.SetTexture(0, null);
}
finally
{
if (m_vbBuffer != null)
{
m_vbBuffer.SafeDispose();
}
}
}