I m与开放式利比里亚公司合作,使用开放式图瓦卢公司的工具。
我的问题是:首先,我们要用冰川的线打下某种形状,我们开始根据纽斯敦活动,用钥匙(e)来完成,然后,我们想要打新线,窗户(ColorBufferBit)将清楚,一心知道必须做些什么?
for more explanation , i must say that when we are drawing line , we call
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
and when we finishid it and we will want to darwing new lines,Forcibly ,i must call
GL.Clear(ClearBufferMask.AccumBufferBit | ClearBufferMask.DepthBufferBit);
what must i do?
here is the code
using System;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Audio;
using OpenTK.Audio.OpenAL;
using OpenTK.Input;
using System.Drawing;
using System.Drawing.Imaging;
namespace FarmApp
{
class openGLfarm : GameWindow
{
bool flage, chechFirst;
float XMouseBegin_first, YMouseBegin_first;
//-----------------------------
public openGLfarm(GraphicsMode mode)
: base(700, 700, GraphicsMode.Default, "O Sample")
{
VSync = VSyncMode.On;
chechFirst = true;
Mouse.ButtonDown += new EventHandler<MouseButtonEventArgs>(Mouse_ButtonDown);
Mouse.ButtonUp += new EventHandler<MouseButtonEventArgs>(Mouse_ButtonUp);
Mouse.Move += new EventHandler<MouseMoveEventArgs>(Mouse_Move);
Mouse.ButtonDown += new EventHandler<MouseButtonEventArgs>(Mouse_ButtonDown);
Mouse.ButtonUp += new EventHandler<MouseButtonEventArgs>(Mouse_ButtonUp);
Mouse.Move += new EventHandler<MouseMoveEventArgs>(Mouse_Move);
iii
//-------------------------------
public openGLfarm()
{
// TODO: Complete member initialization
iii
void Mouse_Move(object sender, MouseMoveEventArgs e)
{
// Now use mouse_delta to move the camera
iii
void Mouse_ButtonUp(object sender, MouseButtonEventArgs e)
{
switch (e.Button)
{
case MouseButton.Left:
{
flage = true;
if (chechFirst)
{
chechFirst = false;
XMouseBegin_first = Mouse.X;
YMouseBegin_first = Mouse.Y;
iii
break;
iii
case MouseButton.Middle:
///camera_mode = ECameraMode.CAMERA_DOLLY;
break;
case MouseButton.Right:
//camera_mode = ECameraMode.CAMERA_ORBIT;
break;
iii
iii
void Mouse_ButtonDown(object sender, MouseButtonEventArgs e)
{
switch (e.Button)
{
case MouseButton.Left:
{
break;
iii
case MouseButton.Middle:
///camera_mode = ECameraMode.CAMERA_DOLLY;
break;
case MouseButton.Right:
//camera_mode = ECameraMode.CAMERA_ORBIT;
break;
iii
iii
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
iii
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
iii
protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);
if (Keyboard[Key.Escape])
Exit();
if (Keyboard[Key.E])
{
flage = false;
chechFirst = true;
iii
iii
void table(float count)
{
float x, y;
GL.Color4(Color4.Wheat);
float z = (2f) / (count);
x = -1;
y = -1;
for (double i = 0; i < count; i++)
{
GL.Begin(BeginMode.Lines);
GL.Vertex2(x + (z), -1);
GL.Vertex2(x + (z), 1);
GL.End();
x = x + (z);
iii
for (double i = 0; i < count; i++)
{
GL.Begin(BeginMode.Lines);
GL.Vertex2(-1, y + (z));
GL.Vertex2(1, y + (z));
GL.End();
y = y + (z);
iii
iii
public void DrawLine(float Xbegin, float Ybegin, float Xend, float Yend)
{
GL.Begin(BeginMode.Lines);
GL.Vertex2(Xbegin, Ybegin);
GL.Vertex2(Xend, Yend);
GL.End();
iii
protected override void OnRenderFrame(FrameEventArgs e)
{
//base.OnRenderFrame(e);
if (chechFirst)
GL.Clear(ClearBufferMask.AccumBufferBit | ClearBufferMask.DepthBufferBit);
else
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
table(Form1.co);
if (flage)
{
//flage = false;
DrawLine((XMouseBegin_first / 350f - 1f), -(YMouseBegin_first / 350f - 1f), (Mouse.X / 350f - 1f), -(Mouse.Y / 350f - 1f));
iii
SwapBuffers();
iii
iii
iii