本文整理汇总了C#中Texture2D类的典型用法代码示例。如果您正苦于以下问题:C# Texture2D类的具体用法?C# Texture2D怎么用?C# Texture2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Texture2D类属于命名空间,在下文中一共展示了Texture2D类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: LoadResources
public void LoadResources()
{
if (m_Disposed == true)
{
Buffer = new Texture2D(GameEnvironment.Device, new Texture2DDescription()
{
Format = m_Format,
Width = m_Width,
Height = m_Height,
OptionFlags = ResourceOptionFlags.None,
MipLevels = 1,
ArraySize = 1,
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default
});
View = new RenderTargetView(GameEnvironment.Device, Buffer);
ResourceView = new ShaderResourceView(GameEnvironment.Device, Buffer);
Viewport = new Viewport(0, 0, Buffer.Description.Width, Buffer.Description.Height);
m_Disposed = false;
}
}
开发者ID:RugCode,项目名称:drg-pt,代码行数:25,代码来源:BloomLayer.cs
示例2: AddTextureAsset
public void AddTextureAsset(String path, Object user, Int32 u, Int32 v)
{
if (String.IsNullOrWhiteSpace(path))
throw new ArgumentException();
if (user == null)
throw new ArgumentNullException();
Vector2i tiles = new Vector2i(u, v);
if (TextureAssetsByUsers.ContainsKey(path))
{
if (TextureAssetsByUsers[path].TextureInfo.NumTiles != tiles)
throw new ArgumentException("Duplicate texture asset with different tiles: " + path);
TextureAssetsByUsers[path].AddUser(user);
}
else
{
Texture2D t = new Texture2D(path, false);
TextureInfo ti = new TextureInfo(t, tiles);
TextureAssetsByUsers[path] = new TextureUsers(ti, user);
}
}
开发者ID:artron33,项目名称:PsmFramework,代码行数:25,代码来源:TextureManager.cs
示例3: TitleScene
public TitleScene()
{
this.Camera.SetViewFromViewport();
_texture = new Texture2D("Application/images/title.png",false);
_ti = new TextureInfo(_texture);
SpriteUV titleScreen = new SpriteUV(_ti);
titleScreen.Scale = _ti.TextureSizef;
titleScreen.Pivot = new Vector2(0.5f,0.5f);
titleScreen.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width/2,
Director.Instance.GL.Context.GetViewport().Height/2);
this.AddChild(titleScreen);
Vector4 origColor = titleScreen.Color;
titleScreen.Color = new Vector4(0,0,0,0);
var tintAction = new TintTo(origColor,10.0f);
ActionManager.Instance.AddAction(tintAction,titleScreen);
tintAction.Run();
_titleSong = new Bgm("/Application/audio/titlesong.mp3");
if(_songPlayer != null)
_songPlayer.Dispose();
_songPlayer = _titleSong.CreatePlayer();
Scheduler.Instance.ScheduleUpdateForTarget(this,0,false);
// Clear any queued clicks so we dont immediately exit if coming in from the menu
Touch.GetData(0).Clear();
}
开发者ID:simar7,项目名称:playstation-sandbox,代码行数:29,代码来源:TitleScene.cs
示例4: MakePixel
public static Texture2D MakePixel(Color color)
{
Texture2D tex = new Texture2D(1, 1, TextureFormat.RGBA32, false);
tex.SetPixel(0, 0, color);
tex.Apply();
return tex;
}
开发者ID:Naphier,项目名称:NGTools,代码行数:7,代码来源:TextureExtensions.cs
示例5: Sprite
public Sprite(GraphicsContext graphics, Texture2D texture)
{
if(shaderProgram == null)
{
shaderProgram = new ShaderProgram("/Application/shaders/Sprite.cgx");
shaderProgram.SetUniformBinding(0, "u_WorldMatrix");
}
if (texture == null)
{
throw new Exception("ERROR: texture is null.");
}
this.graphics = graphics;
this.texture = texture;
this.width = texture.Width;
this.height = texture.Height;
indices = new ushort[indexSize];
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
indices[3] = 3;
vertexBuffer = new VertexBuffer(4, indexSize, VertexFormat.Float3,
VertexFormat.Float2, VertexFormat.Float4);
}
开发者ID:andierocca,项目名称:destructive-santa,代码行数:27,代码来源:Sprite.cs
示例6: TextureAtlas
public TextureAtlas(string filename)
{
sprites = new Dictionary<string, Bounds2>();
sizes = new Dictionary<string, Vector2i>();
XDocument doc = XDocument.Load(filename + ".xml");
var lines = from sprite in doc.Root.Elements("sprite")
select new
{
Name = sprite.Attribute("n").Value,
X1 = (float)sprite.Attribute("x"),
Y1 = (float)sprite.Attribute("y"),
Height = (float)sprite.Attribute("h"),
Width = (float)sprite.Attribute("w")
};
texAtlas = new Texture2D(filename + ".png", false);
texAtlasInfo = new TextureInfo(texAtlas);
foreach (var curLine in lines)
{
sprites.Add(curLine.Name, new Bounds2(new Vector2(curLine.X1 / texAtlas.Width, 1 - (curLine.Y1 / texAtlas.Height)), new Vector2((curLine.X1 + curLine.Width) / texAtlas.Width, 1 -((curLine.Y1 + curLine.Height) / texAtlas.Height))));
sizes.Add(curLine.Name, new Vector2i((int)curLine.Width, (int)curLine.Height));
}
}
开发者ID:DarthRofh,项目名称:PS-Mobile-Helper,代码行数:26,代码来源:TextureAtlas.cs
示例7: LoadContent
protected override void LoadContent()
{
tex = Content.Load<Texture2D>("Logo.jpg");
mouse = Content.Load<Texture2D>("Mouse.png");
BasicFont = this.Content.Load<SpriteFont>("wryh");
base.LoadContent();
}
开发者ID:TPDT,项目名称:TPDT.LogicGraph,代码行数:7,代码来源:LogicGraph.cs
示例8: FighterCarrier
public FighterCarrier(Texture2D texture, Vector2 location, SpriteBatch spriteBatch, Texture2D droneTexture, bool isAlly)
: base(texture, location, spriteBatch, isAlly)
{
//UseCenterAsOrigin = true;
//Init drones
if (!StateManager.NetworkData.IsMultiplayer)
{
Drones.Add(new Drone(droneTexture, location, spriteBatch, this) { DroneState = CoreTypes.DroneState.Stowed });
Drones[0].Rotation.Radians = MathHelper.Pi;
Drones.Add(new Drone(droneTexture, location, spriteBatch, this) { DroneState = CoreTypes.DroneState.Stowed });
Drones[1].Rotation.Radians = MathHelper.TwoPi;
StateManager.InputManager.DebugControlManager.DroneSuicide += new EventHandler<DroneEventArgs>(DebugControlManager_DroneSuicide);
}
//BulletTexture = GameContent.Assets.Images.Ships.Bullets[ShipType.FighterCarrier, ShipTier.Tier1];
DelayBetweenShots = TimeSpan.FromMilliseconds(100);
DamagePerShot = 2;
_initHealth = 100;
MovementSpeed = Vector2.One * 2f;
this.TierChanged += new EventHandler(FighterCarrier_TierChanged);
DamagePerShot = 2;
this.PlayerType = PlayerType.Ally;
ShootSound = GameContent.Assets.Sound[SoundEffectType.FighterCarrierFire];
}
开发者ID:GreatMindsRobotics,项目名称:PGCGame,代码行数:26,代码来源:FighterCarrier.cs
示例9: UserTexture
/// <summary>
/// Creates texture from file in memory
/// </summary>
/// <param name="rs"></param>
/// <param name="texture"></param>
public UserTexture ( RenderSystem rs, byte[] data, bool forceSRgb )
{
this.texture = new Texture2D( rs.Device, data, forceSRgb );
this.Width = texture.Width;
this.Height = texture.Height;
this.Srv = texture;
}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:12,代码来源:UserTexture.cs
示例10: OnInit
protected override void OnInit(object sender, EventArgs e)
{
//OdysseyUI.RemoveHooks(Global.FormOwner);
ImageLoadInformation imageLoadInfo = new ImageLoadInformation()
{
BindFlags = BindFlags.None,
CpuAccessFlags = CpuAccessFlags.Read,
FilterFlags = FilterFlags.None,
Format = SlimDX.DXGI.Format.R8G8B8A8_UNorm,
MipFilterFlags = FilterFlags.None,
OptionFlags = ResourceOptionFlags.None,
Usage = ResourceUsage.Staging,
MipLevels = 1
};
// Make texture 3D
Texture2D sourceTexture = Texture2D.FromFile(Game.Context.Device, "medusa.jpg", imageLoadInfo);
stereoTexture = Stereo.Make3D(sourceTexture);
backBuffer = Game.Context.GetBackBuffer();
stereoSourceBox = new ResourceRegion
{
Front = 0,
Back = 1,
Top = 0,
Bottom = Game.Context.Settings.ScreenHeight,
Left = 0,
Right = Game.Context.Settings.ScreenWidth
};
}
开发者ID:yong-ja,项目名称:starodyssey,代码行数:31,代码来源:StereoImageRenderer.cs
示例11: SimpleSprite
/// <summary>コンストラクタ。</summary>
public SimpleSprite(GraphicsContext graphics, Texture2D texture)
{
if(shaderProgram == null)
{
shaderProgram=CreateSimpleSpriteShader();
}
if (texture == null)
{
throw new Exception("ERROR: texture is null.");
}
this.graphics = graphics;
this.texture = texture;
this.width = texture.Width;
this.height = texture.Height;
indices = new ushort[indexSize];
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
indices[3] = 3;
//@e Vertex coordinate, Texture coordinate, Vertex color
//@j 頂点座標, テクスチャ座標, 頂点色
vertexBuffer = new VertexBuffer(4, indexSize, VertexFormat.Float3, VertexFormat.Float2, VertexFormat.Float4);
}
开发者ID:Transwarmer,项目名称:Transwarmer,代码行数:28,代码来源:SimpleSprite.cs
示例12: DiscTexture
/// <summary>
///
/// </summary>
/// <param name="rs"></param>
/// <param name="texture"></param>
private DiscTexture ( RenderSystem rs, Texture2D texture )
{
this.texture = texture;
this.Width = texture.Width;
this.Height = texture.Height;
this.Srv = texture;
}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:12,代码来源:DiscTexture.cs
示例13: Skybox
public Skybox(GraphicsDevice device)
{
float x = 0.525731f;
float z = 0.850651f;
var vertices = new SkyboxVertex[12]
{
new SkyboxVertex(-x, 0f, z), new SkyboxVertex(x, 0f, z),
new SkyboxVertex(-x, 0f, -z), new SkyboxVertex(x, 0f, -z),
new SkyboxVertex(0f, z, x), new SkyboxVertex(0f, z, -x),
new SkyboxVertex(0f, -z, x), new SkyboxVertex(0f, -z, -x),
new SkyboxVertex(z, x, 0f), new SkyboxVertex(-z, x, 0f),
new SkyboxVertex(z, -x, 0f), new SkyboxVertex(-z, -x, 0f),
};
var indices = new int[60]
{
1,4,0, 4,9,0, 4,5,9, 8,5,4, 1,8,4,
1,10,8, 10,3,8, 8,3,5, 3,2,5, 3,7,2,
3,10,7, 10,6,7, 6,11,7, 6,0,11, 6,1,0,
10,1,6, 11,0,9, 2,11,9, 5,2,9, 11,2,7
};
vertexBuffer = Buffer<SkyboxVertex>.New(device, vertices, BufferFlags.VertexBuffer);
indexBuffer = Buffer<int>.New(device, indices, BufferFlags.IndexBuffer);
skyboxEffect = EffectLoader.Load(@"Graphics/Shaders/Skybox.fx");
skyboxTex = Texture2D.Load(device, @"G:\Users\Athrun\Documents\Stratum\trunk\src\Stratum\WorldEngine\Earth\milkyWay.tif");
}
开发者ID:ukitake,项目名称:Stratum,代码行数:28,代码来源:Skybox.cs
示例14: TextureFactory
public TextureFactory(Engine engine)
{
_missingTexture = engine.Content.Load<Texture2D>("Textures\\missing-texture");
_landCache = new Cache<int, Texture2D>(TimeSpan.FromMinutes(5), 0x1000);
_lastCacheClean = DateTime.MinValue;
_textures = new Textures(engine);
}
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:7,代码来源:TextureFactory.cs
示例15: LoadContent
protected override void LoadContent()
{
texture = game.Content.Load<Texture2D>(textureFilename);
origin.X = texture.Width / 2;
origin.Y = texture.Height / 2;
base.LoadContent();
}
开发者ID:ninetailsdev,项目名称:ZombieShooter,代码行数:7,代码来源:particleSystem.cs
示例16: LoadResources
public void LoadResources()
{
if (m_Disposed == true)
{
if (m_Filename != null)
{
m_ImposterTexture = Texture2D.FromFile(GameEnvironment.Device, Helper.ResolvePath(m_Filename));
TextureView = new ShaderResourceView(GameEnvironment.Device, m_ImposterTexture);
}
m_Vertices = new SlimDX.Direct3D11.Buffer(GameEnvironment.Device, new BufferDescription()
{
BindFlags = BindFlags.VertexBuffer,
CpuAccessFlags = CpuAccessFlags.Write,
OptionFlags = ResourceOptionFlags.None,
SizeInBytes = 4 * Marshal.SizeOf(typeof(Vertex2D)),
Usage = ResourceUsage.Dynamic
});
m_VerticesBindings = new VertexBufferBinding(m_Vertices, Marshal.SizeOf(typeof(Vertex2D)), 0);
WriteRectangle();
m_Disposed = false;
}
}
开发者ID:RugCode,项目名称:drg-pt,代码行数:26,代码来源:ImageBox.cs
示例17: RenderTexture
/// <summary>
/// Constructor
/// Creates the texture we will render to based on the supplied width and height
/// </summary>
/// <param name="device">The device we will create the texture with</param>
/// <param name="texWidth"></param>
/// <param name="texHeight"></param>
public RenderTexture(Device device, int texWidth, int texHeight)
{
Texture2DDescription textureDescription = new Texture2DDescription()
{
Width = texWidth,
Height = texHeight,
MipLevels = 1,
ArraySize = 1,
Format = SlimDX.DXGI.Format.R32G32B32A32_Float,
SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.None,
Usage = ResourceUsage.Default,
};
Texture = new Texture2D(device, textureDescription);
RenderTargetViewDescription renderTargetViewDescription = new RenderTargetViewDescription()
{
Format = textureDescription.Format,
Dimension = RenderTargetViewDimension.Texture2D,
MipSlice = 0,
};
renderTargetView = new RenderTargetView(device, Texture, renderTargetViewDescription);
ShaderResourceViewDescription shaderResourceViewDescription = new ShaderResourceViewDescription()
{
Format = textureDescription.Format,
Dimension = ShaderResourceViewDimension.Texture2D,
MostDetailedMip = 0,
MipLevels = 1
};
shaderResourceView = new ShaderResourceView(device, Texture, shaderResourceViewDescription);
}
开发者ID:nickudell,项目名称:PigmentFramework,代码行数:42,代码来源:RenderTexture.cs
示例18: Saucer
public Saucer(GraphicsContext g, Texture2D t, Vector3 p, Player pl)
: base(g,t,p, pl)
{
player = pl;
vel= (new Vector3(.5f*(float)gen.Next(3,5),.7f*(float)gen.Next(3,5),0));
graphics=g;
}
开发者ID:andierocca,项目名称:destructive-santa,代码行数:7,代码来源:Saucer.cs
示例19: Render
public void Render( Texture2D texture, Scene scene)
{
TextureInfo ti1 = new TextureInfo();
//if(flip)
ti1.Texture = texture;
// else
// ti1.Texture = texture1;
SpriteUV sprite1 = new SpriteUV();
sprite1.TextureInfo = ti1;
if(type==0)
sprite1.Quad.S = ti1.TextureSizef.Multiply(.3f);
if(type==1)
sprite1.Quad.S = ti1.TextureSizef.Multiply(.05f);
sprite1.CenterSprite();
sprite1.Position = position;// scene.Camera.CalcBounds().Center;
sprite1.Rotate(-rotation);//*Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Pi/180);
scene.AddChild(sprite1);
}
开发者ID:cytricks,项目名称:PSMSS,代码行数:25,代码来源:ShotClass.cs
示例20: TextureFromBitmap
public static Texture2D TextureFromBitmap(Bitmap image)
{
BitmapData data = image.LockBits(new Rectangle(0, 0, image.Width, image.Height),
ImageLockMode.ReadWrite, image.PixelFormat);
int bytes = data.Stride*image.Height;
DataStream stream = new DataStream(bytes, true, true);
stream.WriteRange(data.Scan0, bytes);
stream.Position = 0;
DataRectangle dRect = new DataRectangle(data.Stride, stream);
Texture2DDescription texDesc = new Texture2DDescription
{
ArraySize = 1,
MipLevels = 1,
SampleDescription = new SampleDescription(1, 0),
Format = Format.B8G8R8A8_UNorm,
CpuAccessFlags = CpuAccessFlags.None,
BindFlags = BindFlags.ShaderResource,
Usage = ResourceUsage.Immutable,
Height = image.Height,
Width = image.Width
};
image.UnlockBits(data);
image.Dispose();
Texture2D texture = new Texture2D(Game.Context.Device, texDesc, dRect);
stream.Dispose();
return texture;
}
开发者ID:yong-ja,项目名称:starodyssey,代码行数:29,代码来源:ImageHelper.cs
注:本文中的Texture2D类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论