本文整理汇总了C#中Texture2D.SetData方法的典型用法代码示例。如果您正苦于以下问题:C# Texture2D.SetData方法的具体用法?C# Texture2D.SetData怎么用?C# Texture2D.SetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture2D
的用法示例。
在下文中一共展示了Texture2D.SetData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public static void Initialize(Game game)
{
Game = game;
Content = game.Content;
DefaultFont = Content.Load<SpriteFont>("Fonts/Debug");
Texture1x1 = Texture2D.New(game.GraphicsDevice, 1, 1, PixelFormat.B8G8R8A8.UNorm);
Texture1x1.SetData(new Color[] { Color.White });
UpdateScreenSize();
}
示例2: DrawGuiLine
/// <summary>
/// Draws a line.
/// </summary>
/// <param name="sb">The spritebatch.</param>
/// <param name="p1">The first point.</param>
/// <param name="p2">The second point.</param>
/// <param name="color">The color.</param>
public static void DrawGuiLine(this SpriteBatch sb, Vector2 p1, Vector2 p2, Color color)
{
if (solidTexture == null)
{
solidTexture = new Texture2D(sb.GraphicsDevice, 1, 1);
solidTexture.SetData<Color>(new[] { Color.White });
}
sb.Draw(solidTexture, new Vector2(p1.X, p1.Y), null, color, (float)Math.Atan2(p2.Y - p1.Y, p2.X - p1.X), Vector2.Zero,
new Vector2(new Vector2(p1.X - p2.X, p1.Y - p2.Y).Length(), 1), SpriteEffects.None, 0);
}
示例3: Notifier
static Notifier() {
if (Main.dedServ) return;
frame1 = new Texture2D(Config.mainInstance.GraphicsDevice,1,56);
Color[] bgc = new Color[56];
for (int i = 0; i < bgc.Length; i++) bgc[i] = Color.Lerp(new Color(95,95,95),new Color(15,15,15),1f*i/bgc.Length);
bgc[0] = Color.Lerp(bgc[0],Color.White,.5f);
bgc[bgc.Length-1] = Color.Lerp(bgc[bgc.Length-1],Color.White,.5f);
frame1.SetData(bgc);
frame2 = new Texture2D(Config.mainInstance.GraphicsDevice,1,56);
for (int i = 1; i < bgc.Length-1; i++) bgc[i] = Color.Lerp(bgc[i],Color.White,.5f);
frame2.SetData(bgc);
}
示例4: Initialize
/// <summary>
/// /
/// </summary>
public override void Initialize ()
{
base.Initialize();
paramsCB = new ConstantBuffer( Game.GraphicsDevice, typeof(Params) );
CreateTargets();
LoadContent();
Random rand = new Random();
randomDir = new Texture2D( Game.GraphicsDevice, 64,64, ColorFormat.Rgba8, false );
randomDir.SetData( Enumerable.Range(0,4096).Select( i => rand.NextColor() ).ToArray() );
Game.GraphicsDevice.DisplayBoundsChanged += (s,e) => CreateTargets();
Game.Reloading += (s,e) => LoadContent();
}
示例5: LegCon
public LegCon(NPC S,NPC E,float s1 = -1f,float s2 = -1f,float c1 = -1f,float c2 = -1f,Color C = default(Color))
{
N = S;
N2 = E;
con = 0.785f;
pos = new Vector2[4];
Vector2 NC = N.position+new Vector2(N.width/2f,N.height/2f);
for(int i = 0; i < pos.Length; i++) pos[i] = NC;
if(s1 != -1f) conClose = s1;
if(s2 != -1f) conFar = s2;
if(c1 != -1f) CSize1 = c1;
if(c2 != -1f) CSize2 = c2;
if(C!=default(Color)) col = C;
//tex = Main.goreTexture[Config.goreID["Frostmaw CPath"]];
tex = new Texture2D(Config.mainInstance.GraphicsDevice,4,4);
Color[] ar = new Color[16]; for(int i = 0; i < ar.Length; i++) ar[i] = Color.White;
tex.SetData(ar , 0,16);
}
示例6: InitAtmosphere
void InitAtmosphere()
{
if(!Directory.Exists("cache/Atmosphere")) return;
var tindexes = new List<int>();
int rowsCount = 25;
int columnsCount = 25;
for (int row = 0; row < rowsCount - 1; row++) {
for (int col = 0; col < columnsCount - 1; col++) {
tindexes.Add(col + row * columnsCount);
tindexes.Add(col + (row + 1) * columnsCount);
tindexes.Add(col + 1 + row * columnsCount);
tindexes.Add(col + 1 + row * columnsCount);
tindexes.Add(col + (row + 1) * columnsCount);
tindexes.Add(col + 1 + (row + 1) * columnsCount);
}
}
atmosIB = new IndexBuffer(Game.GraphicsDevice, tindexes.Count);
atmosIB.SetData(tindexes.ToArray(), 0, tindexes.Count);
atmosVB = new VertexBuffer(Game.GraphicsDevice, typeof(GeoVert), rowsCount * columnsCount);
atmosTexture = new Texture2D(Game.GraphicsDevice, columnsCount, rowsCount, ColorFormat.Rgb32F, false);
atmosNextTexture = new Texture2D(Game.GraphicsDevice, columnsCount, rowsCount, ColorFormat.Rgb32F, false);
arrowTex = Game.Content.Load<Texture2D>("arrow.tga");
var verts = LoadGrid(Directory.GetFiles("cache/Atmosphere/Temperature")[0]);
atmosVB.SetData(verts.ToArray(), 0, verts.Count);
LoadWindAndTempFromFolder();
atmosTexture.SetData(atmosData[0]);
atmosNextTexture.SetData(atmosData[1]);
}
示例7: DayLight
public DayLight(Map map, double timeOfDay, TimeSpan startTime)
{
m_graphics = new Graphics();
m_timeOfDay = timeOfDay;
//m_currentTime = timeOfDay;
m_map = map;
m_maxLight = new Color4(1, 1, 1, 1);
//m_maxLight = new Color4(0.6f, 0.6f, 0.6f, 1);
m_maxDark = new Color4(0.1f, 0.1f, 0.05f, 1);
m_startTime = startTime;
m_currentTime = (1 - ConvertTimeToDayProgress(m_startTime)) * m_timeOfDay;
m_timeStartDay = new TimeSpan(07, 0, 0);
m_timeStartNight = new TimeSpan(19, 0, 0);
m_timeTransition = new TimeSpan(2, 0, 0);
//Framebuffers
m_framebufferAllLight = new Framebuffer();
m_textureLight = new Texture2D();
var size = Engine.Display.GetSize();
m_textureLight.SetData<Color4ub>(size.X, size.Y, null);
m_framebufferAllLight.Attach(m_textureLight);
}
示例8: Initialize
/// <summary>
///
/// </summary>
public override void Initialize ()
{
LoadContent();
constBuffer = new ConstantBuffer( Game.GraphicsDevice, typeof(CBMeshInstanceData) );
constBufferBones = new ConstantBuffer( Game.GraphicsDevice, typeof(Matrix), MaxBones );
defaultDiffuse = new Texture2D( Game.GraphicsDevice, 4,4, ColorFormat.Rgba8, false );
defaultDiffuse.SetData( Enumerable.Range(0,16).Select( i => Color.Gray ).ToArray() );
defaultSpecular = new Texture2D( Game.GraphicsDevice, 4,4, ColorFormat.Rgba8, false );
defaultSpecular.SetData( Enumerable.Range(0,16).Select( i => new Color(0,128,0,255) ).ToArray() );
defaultNormalMap = new Texture2D( Game.GraphicsDevice, 4,4, ColorFormat.Rgba8, false );
defaultNormalMap.SetData( Enumerable.Range(0,16).Select( i => new Color(128,128,255,255) ).ToArray() );
defaultEmission = new Texture2D( Game.GraphicsDevice, 4,4, ColorFormat.Rgba8, false );
defaultEmission.SetData( Enumerable.Range(0,16).Select( i => Color.Black ).ToArray() );
//Ubershader.AddEnumerator( "SceneRenderer", (t
Game.Reloading += (s,e) => LoadContent();
}
示例9: Initialize
/// <summary>
/// /
/// </summary>
public override void Initialize ()
{
paramsCB = new ConstantBuffer( Game.GraphicsDevice, typeof(Params) );
sampleDirectionsCB = new ConstantBuffer( Game.GraphicsDevice, typeof(Vector2), maxNumberOfSamples );
sampleDirectionData = getSampleDirections();
CreateTargets();
LoadContent();
randomDir = new Texture2D( Game.GraphicsDevice, 64,64, ColorFormat.Rgba8, false );
Color [] randVectors = new Color[4096];
for ( int i = 0; i < 4096; ++i ) {
#if false
var dir = rand.UniformRadialDistribution(1,1);
var color = new Color();
color.R = (byte)(dir.X * 127 + 128);
color.G = (byte)(dir.Y * 127 + 128);
color.B = (byte)(dir.Z * 127 + 128);
color.A = 128;
randVectors[i] = color;
#else
Color c = rand.NextColor();
while ((c.R * c.R + c.G * c.G + c.B * c.B) > 256*256) {
c = rand.NextColor();
}
randVectors[i] = c;
#endif
}
randomDir.SetData(randVectors);
Game.RenderSystem.DisplayBoundsChanged += (s,e) => CreateTargets();
Game.Reloading += (s,e) => LoadContent();
}
示例10: Initialize
/// <summary>
///
/// </summary>
public override void Initialize()
{
vertexBuffer = new VertexBuffer( Game.GraphicsDevice, typeof(SpriteVertex), MaxVertices, VertexBufferOptions.Dynamic );
indexBuffer = new IndexBuffer( Game.GraphicsDevice, MaxIndices );
var indices = new int[MaxIndices];
for (int i=0; i<MaxQuads; i++) {
indices[ i*6 + 0 ] = i * 4 + 0;
indices[ i*6 + 1 ] = i * 4 + 1;
indices[ i*6 + 2 ] = i * 4 + 2;
indices[ i*6 + 3 ] = i * 4 + 0;
indices[ i*6 + 4 ] = i * 4 + 2;
indices[ i*6 + 5 ] = i * 4 + 3;
}
indexBuffer.SetData( indices );
batches.Capacity = 128;
LoadContent();
vertices = new SpriteVertex[MaxVertices];
constBuffer = new ConstantBuffer(Game.GraphicsDevice, typeof(ConstData));
TextureWhite = new Texture2D( Game.GraphicsDevice, 8, 8, ColorFormat.Rgba8, false, false );
TextureBlack = new Texture2D( Game.GraphicsDevice, 8, 8, ColorFormat.Rgba8, false, false );
TextureRed = new Texture2D( Game.GraphicsDevice, 8, 8, ColorFormat.Rgba8, false, false );
TextureGreen = new Texture2D( Game.GraphicsDevice, 8, 8, ColorFormat.Rgba8, false, false );
TextureBlue = new Texture2D( Game.GraphicsDevice, 8, 8, ColorFormat.Rgba8, false, false );
var range = Enumerable.Range(0, 8*8);
TextureWhite .SetData( range.Select( i => Color.White ).ToArray() );
TextureBlack .SetData( range.Select( i => Color.Black ).ToArray() );
TextureRed .SetData( range.Select( i => Color.Red ).ToArray() );
TextureGreen .SetData( range.Select( i => Color.Green ).ToArray() );
TextureBlue .SetData( range.Select( i => Color.Blue ).ToArray() );
Game.Reloading += (s,e) => LoadContent();
}
示例11: Initialize
protected override void Initialize()
{
if (DedicatedServer)
return;
Lua.Initialize(SCRIPTS_PATH);
Commands.Initialize();
Lua.TryStartupScript();
Console.WriteLine("Core: Initialized");
Input.Start();
Window.Title = "WraithMod (v" + VersionString + ")";
Main.versionNumber = "Running on Terraria " + Main.versionNumber + " =)";
if (UseBanlist)
{
LoadBanlist();
}
base.Initialize();
Window.Title = "WraithMod (v" + VersionString + ")";
MemoryStream stream = new MemoryStream();
Assembly asm = Assembly.Load(new AssemblyName("Terraria"));
WorldGenWrapper = asm.GetType("Terraria.WorldGen");
MainWrapper = asm.GetType("Terraria.Main");
Texture2D t = new Texture2D(base.GraphicsDevice, 1, 1);
t.SetData<Color>(new Color[] { new Color(255, 255, 255, 255) });
DefaultTexture = t;
Console.WriteLine("Core: WraithMod v{0} Ready!", VersionString);
}
示例12: InternalFonts
static InternalFonts()
{
s_texture = new Lazy<Texture2D>(() =>
{
var bytes = new byte[c_width * c_height];
using (var mstream = new MemoryStream(s_bytes))
{
using (var cstream = new GZipStream(mstream, CompressionMode.Decompress))
{
cstream.Read(bytes, 0, bytes.Length);
}
}
var pixels = new Color4ub[c_width * c_height * 4];
for (int i = 0; i < c_width * c_height; i++)
{
pixels[i] = new Color4ub(0xFF, 0xFF, 0xFF, bytes[i]);
}
var texture = new Texture2D();
texture.SetData(c_width, c_height, pixels);
return texture;
});
s_regularSmallVariableWidthFont = new Lazy<Font>(() =>
{
var font = new Font(s_texture.Value, s_regularSmallVariableWidthFontGlyphs);
return font;
});
s_boldSmallVariableWidthFont = new Lazy<Font>(() =>
{
var font = new Font(s_texture.Value, s_boldSmallVariableWidthFontGlyphs);
return font;
});
s_italicSmallVariableWidthFont = new Lazy<Font>(() =>
{
var font = new Font(s_texture.Value, s_italicSmallVariableWidthFontGlyphs);
return font;
});
s_regularBigVariableWidthFont = new Lazy<Font>(() =>
{
var font = new Font(s_texture.Value, s_regularBigVariableWidthFontGlyphs);
return font;
});
s_regularSmallFixedWidthFont = new Lazy<Font>(() =>
{
var font = new Font(s_texture.Value, s_regularSmallFixedWidthFontGlyphs);
return font;
});
s_boldSmallFixedWidthFont = new Lazy<Font>(() =>
{
var font = new Font(s_texture.Value, s_boldSmallFixedWidthFontGlyphs);
return font;
});
s_italicSmallFixedWidthFont = new Lazy<Font>(() =>
{
var font = new Font(s_texture.Value, s_italicSmallFixedWidthFontGlyphs);
return font;
});
s_regularBigFixedWidthFont = new Lazy<Font>(() =>
{
var font = new Font(s_texture.Value, s_regularBigFixedWidthFontGlyphs);
return font;
});
}
示例13: LoadContentIfNecessary
/// <summary>
/// Loads the panel's content assets if they haven't already been loaded.
/// </summary>
private void LoadContentIfNecessary()
{
if (content != null)
return;
content = ContentManager.Create();
spriteBatch = SpriteBatch.Create();
var asm = Assembly.GetExecutingAssembly();
using (var stream = asm.GetManifestResourceStream("TwistedLogik.Ultraviolet.UI.Presentation.Resources.Content.Fonts.SegoeUITexture.png"))
font = content.LoadFromStream<SpriteFont>(stream, "png");
blankTexture = Texture2D.Create(1, 1);
blankTexture.SetData(new[] { Color.White });
}
示例14: Initialize
//.........这里部分代码省略.........
lightMeToggle = "255,255,0".Split(',');
mouseCoords = "138,43,226".Split(',');
teleportMessages = "0,255,255".Split(',');
timeMessage = "147,197,114".Split(',');
// Core Configuration
selectionColor = "255,100,0".Split(',');
#endregion
#region Gather Config Data (override the failsafes)
XmlReaderSettings readerSettings = new XmlReaderSettings { IgnoreComments = true, IgnoreWhitespace = true };
XmlReader reader = XmlReader.Create("BuildariaConfig.xml", readerSettings);
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
#region Defaults
if (reader.Name == "itemHax") itemHax = Convert.ToBoolean(reader.ReadString());
if (reader.Name == "godMode") godMode = Convert.ToBoolean(reader.ReadString());
if (reader.Name == "npcsEnabled") npcsEnabled = Convert.ToBoolean(reader.ReadString());
if (reader.Name == "hover") hover = Convert.ToBoolean(reader.ReadString());
if (reader.Name == "buildMode") buildMode = Convert.ToBoolean(reader.ReadString());
if (reader.Name == "itemsEnabled") itemsEnabled = Convert.ToBoolean(reader.ReadString());
if (reader.Name == "displayMessages") displayMessages = Convert.ToBoolean(reader.ReadString());
if (reader.Name == "lightMe") lightMe = Convert.ToBoolean(reader.ReadString());
if (reader.Name == "saveInventoriesOnSwitch") saveInventoriesOnSwitch = Convert.ToBoolean(reader.ReadString());
if (reader.Name == "gridMe") gridMe = Convert.ToBoolean(reader.ReadString());
#endregion
#region Chat Output Colors
if (reader.Name == "displayMessagesMsg") displayMessagesMsg = reader.ReadString().Split(',');
if (reader.Name == "otherToggles") otherToggles = reader.ReadString().Split(',');
if (reader.Name == "selectionMessages") selectionMessages = reader.ReadString().Split(',');
if (reader.Name == "undoMessage") undoMessage = reader.ReadString().Split(',');
if (reader.Name == "saveLoadInv") saveLoadInv = reader.ReadString().Split(',');
if (reader.Name == "setSpawnPoint") setSpawnPoint = reader.ReadString().Split(',');
if (reader.Name == "lightMeToggle") lightMeToggle = reader.ReadString().Split(',');
if (reader.Name == "mouseCoords") mouseCoords = reader.ReadString().Split(',');
if (reader.Name == "teleportMessages") teleportMessages = reader.ReadString().Split(',');
if (reader.Name == "timeMessage") timeMessage = reader.ReadString().Split(',');
#endregion
#region Custom Teleport Locations
if (reader.Name == "F1") ctlF1 = reader.ReadString().Split(',');
if (reader.Name == "F2") ctlF2 = reader.ReadString().Split(',');
if (reader.Name == "F3") ctlF3 = reader.ReadString().Split(',');
if (reader.Name == "F4") ctlF4 = reader.ReadString().Split(',');
if (reader.Name == "F5") ctlF5 = reader.ReadString().Split(',');
if (reader.Name == "F6") ctlF6 = reader.ReadString().Split(',');
if (reader.Name == "F7") ctlF7 = reader.ReadString().Split(',');
if (reader.Name == "F8") ctlF8 = reader.ReadString().Split(',');
if (reader.Name == "F9") ctlF9 = reader.ReadString().Split(',');
if (reader.Name == "F10") ctlF10 = reader.ReadString().Split(',');
if (reader.Name == "F11") ctlF11 = reader.ReadString().Split(',');
if (reader.Name == "F12") ctlF12 = reader.ReadString().Split(',');
#endregion
#region Core
if (reader.Name == "selectionColor") selectionColor = reader.ReadString().Split(',');
#endregion
}
}
#endregion
screenHeight = 720;
screenWidth = 1280;
base.Initialize();
spriteBatch = new SpriteBatch(base.GraphicsDevice);
Texture2D t = new Texture2D(base.GraphicsDevice, 1, 1);
t.SetData<Color>(new Color[] { new Color(255, 255, 255, 255) });
DefaultTexture = t;
TileSize = new Vector2(16, 16);
Window.Title = "Buildaria v" + VersionString;
Main.versionNumber = Window.Title + " on Terraria " + Main.versionNumber;
SelectionOverlay = new Color(Convert.ToByte(selectionColor[0]), Convert.ToByte(selectionColor[1]), Convert.ToByte(selectionColor[2]), 50);
MemoryStream stream = new MemoryStream();
Assembly asm = Assembly.Load(new AssemblyName("Terraria"));
WorldGenWrapper = asm.GetType("Terraria.WorldGen");
MainWrapper = asm.GetType("Terraria.Main");
Inventory.LoadInventories();
}
示例15: LoadNewHeightMap
public void LoadNewHeightMap(float[,] heightmap, float heightmapPixelPerWorldUnit, SharpDX.Toolkit.Graphics.GraphicsDevice graphicsDevice)
{
this.heightmapPixelPerWorldUnit = heightmapPixelPerWorldUnit;
// remove old textures
shader.Effect.Parameters["Heightmap"].SetResource<ShaderResourceViewSelector>((ShaderResourceViewSelector)null);
if (heightmapTexture != null)
heightmapTexture.Dispose();
// Create new heightmap.
heightmapTexture = Texture2D.New(graphicsDevice, heightmap.GetLength(0), heightmap.GetLength(1), MipMapCount.Auto, PixelFormat.R32.Float);
unsafe
{
fixed (float* p = heightmap)
{
heightmapTexture.SetData(new DataPointer(p, heightmap.GetLength(0) * heightmap.GetLength(1) * sizeof(float)), 0, 0);
}
}
// TODO? Mipmaps
Translation = new Vector3(-heightmapTexture.Width * 0.5f / heightmapPixelPerWorldUnit, 0, -heightmapTexture.Height * 0.5f / heightmapPixelPerWorldUnit);
// setup heightmap cbuffer
SetupTerrainConstants(graphicsDevice);
}