English 中文(简体)
帮助开放或开放
原标题:helping for opengl or opentk in c#

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

问题回答

您可以举个例子,创建“Verctor2”角,并节省其起点和终点。 然后,根据这些职能,所有职能都是由来的。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签