本文整理汇总了C#中DrawMode类的典型用法代码示例。如果您正苦于以下问题:C# DrawMode类的具体用法?C# DrawMode怎么用?C# DrawMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DrawMode类属于命名空间,在下文中一共展示了DrawMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ZeroIndexBuffer
/// <summary>
/// Wraps glDrawArrays(uint mode, int first, int count).
/// </summary>
/// <param name="mode">用哪种方式渲染各个顶点?(OpenGL.GL_TRIANGLES etc.)</param>
/// <param name="firstVertex">要渲染的第一个顶点的位置。<para>Index of first vertex to be rendered.</para></param>
/// <param name="vertexCount">要渲染多少个元素?<para>How many vertexes to be rendered?</para></param>
/// <param name="primCount">primCount in instanced rendering.</param>
internal ZeroIndexBuffer(DrawMode mode, int firstVertex, int vertexCount, int primCount = 1)
: base(mode, 0, vertexCount, vertexCount * sizeof(uint), primCount)
{
this.FirstVertex = firstVertex;
this.RenderingVertexCount = vertexCount;
//this.OriginalVertexCount = vertexCount;
}
示例2: GetLineSearcher
private static OneIndexLineSearcher GetLineSearcher(DrawMode mode)
{
if (lineSearcherDict == null)
{
var triangle = new OneIndexLineInTriangleSearcher();
var quad = new OneIndexLineInQuadSearcher();
var polygon = new OneIndexLineInPolygonSearcher();
var dict = new Dictionary<DrawMode, OneIndexLineSearcher>();
dict.Add(DrawMode.Triangles, triangle);
dict.Add(DrawMode.TrianglesAdjacency, triangle);
dict.Add(DrawMode.TriangleStrip, triangle);
dict.Add(DrawMode.TriangleStripAdjacency, triangle);
dict.Add(DrawMode.TriangleFan, triangle);
dict.Add(DrawMode.Quads, quad);
dict.Add(DrawMode.QuadStrip, quad);
dict.Add(DrawMode.Polygon, polygon);
lineSearcherDict = dict;
}
OneIndexLineSearcher result = null;
if (lineSearcherDict.TryGetValue(mode, out result))
{ return result; }
else
{ return null; }
}
示例3: AnimSprite
float viewOffset; // view offset moves sprite in direction of camera
#endregion Fields
#region Constructors
/// <summary>
/// Create a new animated sprite
/// </summary>
public AnimSprite(
AnimSpriteType type,
Vector3 position, float radius, float viewOffset,
Texture2D texture, int frameSizeX, int frameSizeY,
float frameRate, DrawMode mode, int player)
{
if (texture == null)
{
throw new ArgumentNullException("texture");
}
spriteType = type;
this.position = position;
this.radius = radius;
this.viewOffset = viewOffset;
this.texture = texture;
this.player = player;
this.frameRate = frameRate;
this.drawMode = mode;
// frame size
float sizeX = (float)frameSizeX / (float)texture.Width;
float sizeY = (float)frameSizeY / (float)texture.Height;
frameSize = new Vector2(sizeX, sizeY);
// number of frames
numberFramesX = texture.Width / frameSizeX;
numberFramesY = texture.Height / frameSizeY;
numberFrames = numberFramesX * numberFramesY;
// total animation time
totalTime = (float)numberFrames / frameRate;
elapsedTime = 0;
}
示例4: BackgroundComponent
public BackgroundComponent(Game game, Texture2D image, DrawMode drawMode)
{
Visible = true;
this.image = image;
this.drawMode = drawMode;
screenRectangle = new Rectangle(
0,
0,
game.Window.ClientBounds.Width,
game.Window.ClientBounds.Height);
//Nastaveni Rectanglu pro vykresleni bud na cely obraz nebo jen podle velikosti textury
switch (drawMode)
{
case DrawMode.Center:
destination = new Rectangle(
(screenRectangle.Width - image.Width) / 2,
(screenRectangle.Height - image.Height) / 2,
image.Width,
image.Height);
break;
case DrawMode.Fill:
destination = new Rectangle(
screenRectangle.X,
screenRectangle.Y,
screenRectangle.Width,
screenRectangle.Height);
break;
}
}
示例5: GraphicManager
protected int timerPerion; // частота отрисовки графиков в активном режиме
#endregion Fields
#region Constructors
/// <summary>
/// Инициализирует новый экземпляр класса
/// </summary>
/// <param name="GPanel">Панель которую будет обслуживать манеджер</param>
public GraphicManager(Panel GPanel)
{
mutex = new Mutex();
slim = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
mode = DrawMode.Default;
if (GPanel != null)
{
panel = GPanel;
//panel.StartTime = DateTime.Now;
panel.OnResize += new EventHandler(Sheet_Resize);
panel.Sheet.onOrientationChange += new EventHandler(Sheet_onOrientationChange);
panel.Sheet.onIntervalInCellChange += new EventHandler(Sheet_onIntervalInCellChange);
timerPerion = 500;
timer = new Timer(TimerCallback, null, Timeout.Infinite, timerPerion);
}
else
{
throw new ArgumentNullException();
}
}
示例6: ZeroAttributeModel
/// <summary>
/// Bufferable model with zero vertex attribute.
/// </summary>
/// <param name="mode">渲染模式。</param>
/// <param name="firstVertex">要渲染的第一个顶点的位置。<para>Index of first vertex to be rendered.</para></param>
/// <param name="vertexCount">要渲染多少个元素?<para>How many vertexes to be rendered?</para></param>
/// <param name="primCount">primCount in instanced rendering.</param>
public ZeroAttributeModel(DrawMode mode, int firstVertex, int vertexCount, int primCount = 1)
{
this.Mode = mode;
this.FirstVertex = firstVertex;
this.VertexCount = vertexCount;
this.PrimCount = primCount;
}
示例7: SetHighlightIndexes
/// <summary>
/// 设置要高亮显示的图元。
/// </summary>
/// <param name="mode">要高亮显示的图元类型</param>
/// <param name="indexes">要高亮显示的图元的索引。</param>
public void SetHighlightIndexes(DrawMode mode, params uint[] indexes)
{
int indexesLength = indexes.Length;
if (indexesLength > this.maxElementCount)
{
IndexBuffer original = this.indexBuffer;
this.indexBuffer = Buffer.Create(IndexBufferElementType.UInt, indexesLength, mode, BufferUsage.StaticDraw);
this.maxElementCount = indexesLength;
original.Dispose();
}
var indexBuffer = this.indexBuffer as OneIndexBuffer;
IntPtr pointer = indexBuffer.MapBuffer(MapBufferAccess.WriteOnly);
unsafe
{
var array = (uint*)pointer.ToPointer();
for (int i = 0; i < indexesLength; i++)
{
array[i] = indexes[i];
}
}
indexBuffer.UnmapBuffer();
indexBuffer.Mode = mode;
indexBuffer.ElementCount = indexesLength;
}
示例8: PictureBox3D
public PictureBox3D(DeviceManager initDM, SceneManager initSM)
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// initialize members
nameVisible = true; // show the name of this viewport on-screen?
_drawMode = DrawMode.wireFrame; // default to wireframe view
arcBall = new ArcBall(this);
arcBall.Radius = 1.0f;
BuildCameraMenu();
// new events
Midget.Events.EventFactory.DeselectObjects +=new Midget.Events.Object.Selection.DeselectObjectEventHandler(EventFactory_DeselectObjects);
Midget.Events.EventFactory.SelectAdditionalObject +=new Midget.Events.Object.Selection.SelectAdditionalObjectEventHandler(EventFactory_SelectAdditionalObject);
Midget.Events.EventFactory.AdjustCameraEvent +=new Midget.Events.User.AdjustCameraEventHandler(EventFactory_AdjustCameraEvent);
Midget.Events.EventFactory.SwitchEditModeEvent +=new Midget.Events.User.SwitchEditModeEventHandler(EventFactory_SwitchEditModeEvent);
selectedObjects = new ArrayList();
this.dm = initDM;
// attach listener for render event
dm.Render += new System.EventHandler(this.Viewport_Render);
this.renderView += new RenderSingleViewHandler(dm.OnRenderSingleView);
this.sm = initSM;
this.ConfigureRenderTarget();
}
示例9: Draw
public void Draw(DrawMode Mode,VertexBuffer VB)
{
if(VB == null)
throw new Exception("Must have Vertex Buffer");
if(VB.Normal != null)
{
gl.EnableClientState(NORMAL_ARRAY);
gl.BindBuffer((uint)VB.Normal.BType,VB.Normal.B);
gl.NormalPointer((uint)VB.Normal.T,0,null);
}
else gl.DisableClientState(NORMAL_ARRAY);
if(VB.TexCoord != null)
{
gl.EnableClientState(TEXTURE_COORD_ARRAY);
gl.BindBuffer((uint)VB.TexCoord.BType,VB.TexCoord.B);
gl.TexCoordPointer(VB.TexCoord.Size,(uint)VB.TexCoord.T,0,null);
}
else gl.DisableClientState(TEXTURE_COORD_ARRAY);
gl.EnableClientState(VERTEX_ARRAY);
gl.BindBuffer((uint)VB.BType,VB.B);
gl.VertexPointer(VB.Size,(uint)VB.T,0,null);
gl.DrawArrays((uint)Mode,0,VB.Count);
gl.DisableClientState(VERTEX_ARRAY);
gl.DisableClientState(NORMAL_ARRAY);
gl.DisableClientState(TEXTURE_COORD_ARRAY);
}
示例10: ArrangeIndexes
/// <summary>
/// 将共享点前移,构成2个图元组成的新的小小的索引。
/// </summary>
/// <param name="recognizedPrimitiveIndex0"></param>
/// <param name="recognizedPrimitiveIndex1"></param>
/// <param name="drawMode"></param>
/// <param name="lastIndex0"></param>
/// <param name="lastIndex1"></param>
/// <returns></returns>
private List<uint> ArrangeIndexes(
RecognizedPrimitiveInfo recognizedPrimitiveIndex0,
RecognizedPrimitiveInfo recognizedPrimitiveIndex1,
DrawMode drawMode,
out uint lastIndex0, out uint lastIndex1)
{
var sameIndexList = new List<uint>();
var array0 = new List<uint>(recognizedPrimitiveIndex0.VertexIds);
var array1 = new List<uint>(recognizedPrimitiveIndex1.VertexIds);
array0.Sort(); array1.Sort();
int p0 = 0, p1 = 0;
while (p0 < array0.Count && p1 < array1.Count)
{
if (array0[p0] < array1[p1])
{ p0++; }
else if (array0[p0] > array1[p1])
{ p1++; }
else
{
sameIndexList.Add(array0[p0]);
array0.RemoveAt(p0);
array1.RemoveAt(p1);
}
}
if (array0.Count == 0 && array1.Count == 0)
{ throw new Exception("Two primitives are totally the same!"); }
if (array0.Count > 0)
{ lastIndex0 = array0.Last(); }
else
{
if (sameIndexList.Count == 0)
{ throw new Exception("array0 is totally empty!"); }
lastIndex0 = sameIndexList.Last();
}
if (array1.Count > 0)
{ lastIndex1 = array1.Last(); }
else
{
if (sameIndexList.Count == 0)
{ throw new Exception("array1 is totally empty!"); }
lastIndex1 = sameIndexList.Last();
}
if (lastIndex0 == lastIndex1) { throw new Exception(); }
var result = new List<uint>();
result.AddRange(sameIndexList);
result.AddRange(array0);
result.Add(uint.MaxValue);// primitive restart index
result.AddRange(sameIndexList);
result.AddRange(array1);
return result;
}
示例11: DrawArgs
/// <summary>
/// Initializes a new instance of <see cref="DrawArgs"/>.
/// </summary>
public DrawArgs(
IRenderingSurface surface,
Screen screen,
DrawMode drawMode)
{
_renderingSurface = surface;
_screen = screen;
_drawMode = drawMode;
}
示例12: Create
public static PrimitiveRecognizer Create(DrawMode mode)
{
PrimitiveRecognizer recognizer = null;
switch (mode)
{
case DrawMode.Points:
recognizer = new PointsRecognizer();
break;
case DrawMode.LineStrip:
recognizer = new LineStripRecognizer();
break;
case DrawMode.LineLoop:
recognizer = new LineLoopRecognizer();
break;
case DrawMode.Lines:
recognizer = new LinesRecognizer();
break;
case DrawMode.LineStripAdjacency:
break;
case DrawMode.LinesAdjacency:
break;
case DrawMode.TriangleStrip:
recognizer = new TriangleStripRecognizer();
break;
case DrawMode.TriangleFan:
recognizer = new TriangleFanRecognizer();
break;
case DrawMode.Triangles:
recognizer = new TrianglesRecognizer();
break;
case DrawMode.TriangleStripAdjacency:
break;
case DrawMode.TrianglesAdjacency:
break;
case DrawMode.Patches:
break;
case DrawMode.QuadStrip:
recognizer = new QuadStripRecognizer();
break;
case DrawMode.Quads:
recognizer = new QuadsRecognizer();
break;
case DrawMode.Polygon:
break;
default:
break;
}
if (recognizer == null)
{
throw new NotImplementedException(string.Format(
"尚未实现[{0}]的recognizer!", mode));
}
return recognizer;
}
示例13: GenericMaterial
public GenericMaterial(Texture tex, Texture normalMap = null, Texture bumpMap = null)
{
CompileShaders();
Tex = tex;
NormalMap = normalMap;
bumpMap = bumpMap;
Color = Vector4.One;
Mode = GenericMaterial.DrawMode.TextureOnly;
}
示例14: Mesh
/// <summary>
/// 创建一个mesh对象,不使用索引缓冲
/// </summary>
/// <param name="pt"></param>
/// <param name="vb"></param>
/// <param name="vd"></param>
public Mesh(PrimitiveType pt, VertexBuffer vb, VertexDeclaration vd)
{
this.is_visible = true;
this.vertices_count = vb.SizeInBytes / vd.GetVertexStrideSize(0);
this.draw_mode = DrawMode.Primitive;
this.primitive_type = pt;
this.vb = vb;
this.vd = vd;
this.primitive_count = CalcPrimitiveCount();
}
示例15: Context
public Context(int width, int height)
{
Width = width;
Height = height;
_Context = new GraphicsContext(width,height, PixelFormat.Rgba, PixelFormat.Depth24,MultiSampleMode.Msaa4x);
AspectRatio = _Context.Screen.AspectRatio;
drawMode = DrawMode.Triangles;
}