本文整理汇总了C#中OpenTK.GLControl.SwapBuffers方法的典型用法代码示例。如果您正苦于以下问题:C# GLControl.SwapBuffers方法的具体用法?C# GLControl.SwapBuffers怎么用?C# GLControl.SwapBuffers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenTK.GLControl
的用法示例。
在下文中一共展示了GLControl.SwapBuffers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
using (Form form = CreateForm())
{
var mGLControl = new GLControl
{
Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
BackColor = Color.LightGreen,
Location = new Point(1, 0),
Name = "GL Control",
Size = new Size(WIDTH, HEIGHT),
TabIndex = 0,
VSync = false
};
form.Controls.Add(mGLControl);
//have to set this to get a -1 to 1 system view
GL.Viewport(0, 0, WIDTH, HEIGHT);
mPositions = new[]
{
new Vector3(-1, -1, 0),
new Vector3(1, -1, 0),
new Vector3(0, 1, 0)
};
mColors = new[]
{
Color.Red, Color.Green,
Color.Blue
};
Application.Idle +=
delegate
{
mGLControl.MakeCurrent();
GL.ClearColor(mGLControl.BackColor);
GL.Clear(ClearBufferMask.ColorBufferBit);
RenderFrame();
mGLControl.SwapBuffers();
};
form.BringToFront();
Application.Run(form);
}
}
示例2: OnGraphicsContextInitialized
internal void OnGraphicsContextInitialized(GLControl context, WindowsFormsHost host)
{
m_control = context;
m_editorCore = new EditorCore();
m_intervalTimer = new System.Windows.Forms.Timer();
m_intervalTimer.Interval = 16; // 60 FPS roughly
m_intervalTimer.Enabled = true;
m_intervalTimer.Tick += (args, o) =>
{
Vector2 mousePosGlobal = new Vector2(System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y);
Vector2 glControlPosGlobal = new Vector2((float)host.PointToScreen(new Point(0, 0)).X, (float)host.PointToScreen(new Point(0, 0)).Y);
var delta = mousePosGlobal - glControlPosGlobal;
delta.X = MathE.Clamp(delta.X, 0, m_control.Width);
delta.Y = MathE.Clamp(delta.Y, 0, m_control.Height);
((MainWindow)Application.Current.MainWindow).Tick();
m_editorCore.GetWorldByName("main").Input.SetMousePosition(delta);
m_editorCore.Tick();
if (m_control != null)
m_control.SwapBuffers();
};
m_editorCore.PropertyChanged += OnEditorPropertyChanged;
EntityOutliner.m_world = m_editorCore.GetWorldByName("main");
}
示例3: SwapBuffers
public static void SwapBuffers(GLControl glControl)
{
glControl.SwapBuffers();
}
示例4: Run
public void Run()
{
using (Form form = CreateForm())
{
var mGLControl = new GLControl
{
Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
BackColor = Color.LightGreen,
Location = new Point(1, 0),
Name = "GL Control",
Size = new Size(WIDTH, HEIGHT),
TabIndex = 0,
VSync = false
};
form.Controls.Add(mGLControl);
//have to set this to get a -1 to 1 system view
GL.Viewport(0, 0, WIDTH, HEIGHT);
if (false)//!GL.SupportsExtension("VERSION_1_5"))
{
Assert.Fail("You need at least OpenGL 1.5 to run this example. Aborting.", "VBOs not supported");
}
var positions = new[]
{
new Vector3(-1, -1, 0),
new Vector3(1, -1, 0),
new Vector3(1, 1, 0),
new Vector3(-1, 1, 0),
};
var colors = new[]
{
new Vector3(1, 0, 0), new Vector3(0, 1, 0),
new Vector3(0, 0, 1), new Vector3(1, 1, 0)
};
var indices = new uint[] { 0, 1, 2, 0, 2, 3 };
LoadBuffers(positions, indices, colors);
Application.Idle +=
delegate
{
mGLControl.MakeCurrent();
GL.ClearColor(mGLControl.BackColor);
GL.Clear(ClearBufferMask.ColorBufferBit);
RenderFrame();
mGLControl.SwapBuffers();
};
form.BringToFront();
Application.Run(form);
}
}