本文整理汇总了C#中RenderEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# RenderEventArgs类的具体用法?C# RenderEventArgs怎么用?C# RenderEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RenderEventArgs类属于命名空间,在下文中一共展示了RenderEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoRender
/// <summary>
///
/// </summary>
/// <param name="arg"></param>
protected override void DoRender(RenderEventArgs arg)
{
mat4 projection = arg.Camera.GetProjectionMatrix();
mat4 view = arg.Camera.GetViewMatrix();
mat4 model = this.GetModelMatrix().Value;
this.SetUniform("mvp", projection * view * model);
if (this.textColorRecord.IsMarked())
{
this.SetUniform("textColor", this.textColor);
this.textColorRecord.CancelMark();
}
if (this.textRecord.IsMarked())
{
TextModel textModel = this.textModel;
if (textModel != null)
{
textModel.SetText(this.text, this.fontTexture);
this.textRecord.CancelMark();
}
}
blendState.On();
base.DoRender(arg);
blendState.Off();
}
示例2: renderedControl1_Rendered
private void renderedControl1_Rendered(object sender, RenderEventArgs e)
{
int tickCount = Environment.TickCount;
float deltaTime = (tickCount - _previousTickCount) / 1000f;
_previousTickCount = tickCount;
_simulator.Update(deltaTime);
_framesCount++;
int secondsCount = (tickCount - _startTickCount)/1000;
if(secondsCount != 0)
label.Text = String.Format("FPS: {0}", _framesCount / secondsCount);
//draw scene
var render = e.Render;
render.BeginScene();
render.Draw(() =>
{
_simulator.ActorsFactory.AcceptVisit(_renderingVisitor);
},
Lights.Point(new Vector3(0, 5, -6), new Vector3(1, 1, 1)),
Cameras.LookAt(new Vector3(0, 15, -30), new Vector3(0, 0, 0), new Vector3(0, 1, 0)),
Cameras.Perspective(render.GetAspectRatio()),
Buffers.Clear(0.2f, 0.2f, 0.4f, 1),
Buffers.ClearDepth(),
Shaders.Phong
);
render.EndScene();
renderedControl1.Invalidate();
}
示例3: DoRender
/// <summary>
///
/// </summary>
/// <param name="arg"></param>
protected override void DoRender(RenderEventArgs arg)
{
// RULE: 用于渲染UI元素的模型,其范围最好是在(-0.5, -0.5, -0.5)到(-0.5, -0.5, -0.5)之间,即保持其边长为1,且位于坐标系中心。这样,就可以用mat4 model = glm.scale(mat4.identity(), new vec3(this.Size.Width, this.Size.Height, 1));来设定其缩放比例了。简单方便。
mat4 projection = this.GetOrthoProjection();
//vec3 position = (this.camera.Position - this.camera.Target).normalize();
mat4 view = glm.lookAt(new vec3(0, 0, 1), new vec3(0, 0, 0), new vec3(0, 1, 0));
//float length = Math.Max(glText.Size.Width, glText.Size.Height) / 2;
float length = this.Size.Height;// / 2;
mat4 model = glm.scale(mat4.identity(), new vec3(length, length, length));
//model = mat4.identity();
var renderer = this.Renderer as Renderer;
renderer.SetUniform("mvp", projection * view * model);
if (this.textColorRecord.IsMarked())
{
renderer.SetUniform("textColor", this.textColor);
this.textColorRecord.CancelMark();
}
if (this.textRecord.IsMarked())
{
TextModel textModel = this.textModel;
if (textModel != null)
{
textModel.SetText(this.text, this.fontTexture);
this.textRecord.CancelMark();
}
}
blendState.On();
base.DoRender(arg);
blendState.Off();
}
示例4: Render
/// <summary>
/// 在使用<see cref="VertexArrayObject"/>后,此方法只会执行一次。
/// </summary>
/// <param name="e"></param>
/// <param name="shaderProgram"></param>
public override void Render(RenderEventArgs e, Shaders.ShaderProgram shaderProgram)
{
uint location = shaderProgram.GetAttributeLocation(this.VarNameInVertexShader);
GL.BindBuffer(BufferTarget.ArrayBuffer, this.BufferID);
GL.VertexAttribPointer(location, this.DataSize, this.DataType, false, 0, IntPtr.Zero);
GL.EnableVertexAttribArray(location);
}
示例5: DoRender
protected override void DoRender(RenderEventArgs arg)
{
float deltaTime = (float)random.NextDouble() * 5;
time += (float)random.NextDouble() * 5;
IntPtr attractors = this.attractorBuffer.MapBufferRange(
0, 64 * Marshal.SizeOf(typeof(vec4)),
MapBufferRangeAccess.MapWriteBit | MapBufferRangeAccess.MapInvalidateBufferBit);
unsafe
{
var array = (vec4*)attractors.ToPointer();
for (int i = 0; i < 64; i++)
{
array[i] = new vec4(
(float)(Math.Sin(time)) * 50.0f,
(float)(Math.Cos(time)) * 50.0f,
(float)(Math.Cos(time)) * (float)(Math.Sin(time)) * 5.0f,
ParticleModel.attractor_masses[i]);
}
}
this.attractorBuffer.UnmapBuffer();
// Activate the compute program and bind the position and velocity buffers
computeProgram.Bind();
OpenGL.BindImageTexture(0, this.velocityTexture.Id, 0, false, 0, OpenGL.GL_READ_WRITE, OpenGL.GL_RGBA32F);
OpenGL.BindImageTexture(1, this.positionTexture.Id, 0, false, 0, OpenGL.GL_READ_WRITE, OpenGL.GL_RGBA32F);
// Set delta time
computeProgram.SetUniform("dt", deltaTime);
// Dispatch
OpenGL.GetDelegateFor<OpenGL.glDispatchCompute>()(ParticleModel.particleGroupCount, 1, 1);
}
示例6: DoRender
protected override void DoRender(RenderEventArgs arg)
{
mat4 projection = arg.Camera.GetProjectionMatrix();
mat4 view = arg.Camera.GetViewMatrix();
mat4 inverseView = glm.inverse(view);
//mat4 model = this.GetModelMatrix();
this.SetUniform("u_projectionMatrix", projection);
this.SetUniform("u_viewMatrix", view);
this.SetUniform("u_inverseViewNormalMatrix", new mat3(new vec3(view[0]), new vec3(view[1]), new vec3(view[2])));
this.SetUniform("u_passedTime", passedTime);
this.SetUniform("u_waveParameters", WaterTextureRenderer.ToFloat(WaterTextureRenderer.waveParameters));
this.SetUniform("u_waveDirections", WaterTextureRenderer.ToFloat(WaterTextureRenderer.waveDirections));
this.cullfaceState.On();
this.backgroundRenderer.passedTime = passedTime;
this.backgroundRenderer.Render(arg);
this.waterTextureRenderer.passedTime = passedTime;
this.waterTextureRenderer.Render(arg);
base.DoRender(arg);
this.cullfaceState.Off();
passedTime += deltaTime;
}
示例7: Search
/// <summary>
/// 在三角形图元中拾取指定位置的Line
/// </summary>
/// <param name="arg">渲染参数</param>
/// <param name="x">mouse position(Left Down is (0, 0)).</param>
/// <param name="y">mouse position(Left Down is (0, 0)).</param>
/// <param name="lastVertexId">三角形图元的最后一个顶点</param>
/// <param name="modernRenderer">目标Renderer</param>
/// <returns></returns>
internal override uint[] Search(RenderEventArgs arg,
int x, int y,
uint lastVertexId, ZeroIndexRenderer modernRenderer)
{
// 创建临时索引
OneIndexBuffer buffer = Buffer.Create(IndexBufferElementType.UInt, 6, DrawMode.Lines, BufferUsage.StaticDraw);
unsafe
{
var array = (uint*)buffer.MapBuffer(MapBufferAccess.WriteOnly);
array[0] = lastVertexId - 1; array[1] = lastVertexId - 0;
array[2] = lastVertexId - 2; array[3] = lastVertexId - 1;
array[4] = lastVertexId - 0; array[5] = lastVertexId - 2;
buffer.UnmapBuffer();
}
// 用临时索引渲染此三角形图元(仅渲染此三角形图元)
modernRenderer.Render4InnerPicking(arg, buffer);
// id是拾取到的Line的Last Vertex Id
uint id = ColorCodedPicking.ReadStageVertexId(x, y);
buffer.Dispose();
// 对比临时索引,找到那个Line
if (id + 2 == lastVertexId)
{ return new uint[] { id + 2, id, }; }
else
{ return new uint[] { id - 1, id, }; }
}
示例8: DoRender
protected override void DoRender(RenderEventArgs e)
{
GL.BindTexture(GL.GL_TEXTURE_3D, this.textureName[0]);
GL.ActiveTexture(GL.GL_TEXTURE0);
//GL.Color(1f, 1f, 1f, 1f);
GL.Begin(PrimitiveModes.QuadStrip);
{
GL.Vertex(this.positiveX, this.positiveY, this.positiveZ);
GL.TexCoord3f(this.positiveTexX, this.positiveTexY, this.positiveTexZ);
GL.Vertex(this.positiveX, this.positiveY, this.negativeZ);
GL.TexCoord3f(this.positiveTexX, this.positiveTexY, this.negativeTexZ);
GL.Vertex(this.negativeX, this.positiveY, this.positiveZ);
GL.TexCoord3f(this.negativeTexX, this.positiveTexY, this.positiveTexZ);
GL.Vertex(this.negativeX, this.positiveY, this.negativeZ);
GL.TexCoord3f(this.negativeTexX, this.positiveTexY, this.negativeTexZ);
GL.Vertex(this.negativeX, this.negativeY, this.positiveZ);
GL.TexCoord3f(this.negativeTexX, this.negativeTexY, this.positiveTexZ);
GL.Vertex(this.negativeX, this.negativeY, this.negativeZ);
GL.TexCoord3f(this.negativeTexX, this.negativeTexY, this.negativeTexZ);
GL.Vertex(this.positiveX, this.negativeY, this.positiveZ);
GL.TexCoord3f(this.positiveTexX, this.negativeTexY, this.positiveTexZ);
GL.Vertex(this.positiveX, this.negativeY, this.negativeZ);
GL.TexCoord3f(this.positiveTexX, this.negativeTexY, this.negativeTexZ);
}
GL.End();
GL.BindTexture(GL.GL_TEXTURE_3D, 0);
}
示例9: DoRender
/// <summary>
///
/// </summary>
/// <param name="arg"></param>
protected override void DoRender(RenderEventArgs arg)
{
this.SetUniform("billboardCenter_worldspace", this.WorldPosition);
if (labelHeightRecord.IsMarked())
{
this.SetUniform("labelHeight", this.LabelHeight);
labelHeightRecord.CancelMark();
}
if (textRecord.IsMarked())
{
if (this.DataSource != null)
{
(this.DataSource as TextModel).SetText(this.text, this.fontTexture);
}
}
if (discardTransparencyRecord.IsMarked())
{
bool discard = this.DiscardTransparency;
this.SetUniform("discardTransparency", discard);
this.blendState.Enabled = discard;
discardTransparencyRecord.CancelMark();
}
int[] viewport = OpenGL.GetViewport();
this.SetUniform("viewportSize", new vec2(viewport[2], viewport[3]));
mat4 projection = arg.Camera.GetProjectionMatrix();
mat4 view = arg.Camera.GetViewMatrix();
this.SetUniform("projection", projection);
this.SetUniform("view", view);
base.DoRender(arg);
}
示例10: OnRender
protected internal override void OnRender(RenderEventArgs e)
{
base.OnRender(e);
e.Canvas.FillRectangle(0, 0, Size.Width, Size.Height, mvarBackgroundColor);
#region Left Arrow
e.Canvas.FillRectangle(0, 0, 8, Size.Height - 1, Colors.LightGray);
e.Canvas.Color = Colors.Black;
e.Canvas.DrawRectangle(0, 0, 8, Size.Height - 1);
e.Canvas.DrawLine(8 - 1, 4, 0, Size.Height / 2);
e.Canvas.DrawLine(8, Size.Height - 4, 0, Size.Height / 2);
#endregion
#region Thumb
double thw = 9;
double thx = (this.Size.Width * ((this.Value - this.Minimum) / (this.Maximum - this.Minimum))) - (thw * 2), thy = 0;
e.Canvas.FillRectangle(9 + thx, thy, Size.Height - 1, Size.Height - 1, Colors.LightGray);
e.Canvas.Color = Colors.Black;
e.Canvas.DrawRectangle(9 + thx, thy, Size.Height - 1, Size.Height - 1);
e.Canvas.Translate(0, 14);
e.Canvas.DrawText("#", 9 + thx + 5, thy);
e.Canvas.Translate(0, -14);
#endregion
#region Right Arrow
e.Canvas.FillRectangle(Size.Width - 8, 0, 8, Size.Height - 1, Colors.LightGray);
e.Canvas.Color = Colors.Black;
e.Canvas.DrawRectangle(Size.Width - 8, 0, 8, Size.Height - 1);
e.Canvas.DrawLine(Size.Width - 8 - 1, 4, Size.Width - 1, Size.Height / 2);
e.Canvas.DrawLine(Size.Width - 8, Size.Height - 4, Size.Width - 1, Size.Height / 2);
#endregion
}
示例11: DoRender
protected override void DoRender(RenderEventArgs arg)
{
mat4 projection = arg.Camera.GetProjectionMatrix();
mat4 view = arg.Camera.GetViewMatrix();
mat4 model = this.GetModelMatrix().Value;
this.SetUniform("mvp", projection * view * model);
base.DoRender(arg);
}
示例12: DoRender
protected override void DoRender(RenderEventArgs arg)
{
mat4 model = mat4.identity();
mat4 view = arg.Camera.GetViewMat4();
mat4 projection = arg.Camera.GetProjectionMat4();
this.SetUniform("mvp", projection * view * model);
base.DoRender(arg);
}
示例13: glCanvas1_OpenGLDraw
void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
{
GL.ClearColor(0x87 / 255.0f, 0xce / 255.0f, 0xeb / 255.0f, 0xff / 255.0f);
GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
var arg = new RenderEventArgs(RenderModes.Render, this.camera);
element.Render(arg);
uiAxis.Render(arg);
}
示例14: RenderedControl1InitializeRender
private void RenderedControl1InitializeRender(object sender, RenderEventArgs e)
{
_boxModel = Models.Cube.Translated(-0.5f, -0.5f, -0.5f).Scaled(1, 1, 1).Allocate(e.Render);
_planeModel = Models.PlaneXZ.Scaled(10, 5, 5).Allocate(e.Render);
SetupSimulation();
//initializing the timer
_startTickCount = Environment.TickCount;
}
示例15: DoRender
protected override void DoRender(RenderEventArgs arg)
{
mat4 projection = arg.Camera.GetProjectionMatrix();
mat4 view = arg.Camera.GetViewMatrix();
//mat4 model = this.GetModelMatrix();
this.SetUniform("u_projectionMatrix", projection);
this.SetUniform("u_modelViewMatrix", view);
base.DoRender(arg);
}