Example #1
0
        public static void CreateGLControl()
        {
            GLControl = new CustomGLControl(FSAASamples)
            {
                BackColor = System.Drawing.Color.Black,
                Dock      = System.Windows.Forms.DockStyle.Fill,
                Location  = new System.Drawing.Point(0, 0),
                Name      = "glControl",
                Size      = new System.Drawing.Size(865, 758),
                TabIndex  = 0,
                VSync     = true
            };

            GLControl.Load           += new System.EventHandler(main.glControl_Load);
            GLControl.Paint          += new System.Windows.Forms.PaintEventHandler(main.glControl_Render);
            GLControl.MouseEnter     += new System.EventHandler(main.glControl_MouseEnter);
            GLControl.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(main.glControl_KeyDown);
            GLControl.KeyUp          += new System.Windows.Forms.KeyEventHandler(main.glControl_KeyUp);
            GLControl.MouseLeave     += new System.EventHandler(main.glControl_MouseLeave);
            GLControl.MouseDown      += new System.Windows.Forms.MouseEventHandler(main.glControl_MouseDown);
            GLControl.MouseMove      += new System.Windows.Forms.MouseEventHandler(main.glControl_MouseMove);
            GLControl.MouseUp        += new System.Windows.Forms.MouseEventHandler(main.glControl_MouseUp);
            GLControl.Resize         += new System.EventHandler(main.glControl_Resize);
            GLControl.LostFocus      += new EventHandler(main.glControl_LostFocus);

            main.splitViewportAndProblems.Panel1.Controls.Add(GLControl);
        }
Example #2
0
        public GLElement()
        {
            InitializeComponent();

            // create and wrap winforms control
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                var gm           = GraphicsMode.Default;
                var graphicsmode = new GraphicsMode(
                    gm.ColorFormat,
                    gm.Depth,
                    gm.Stencil,
                    gm.Samples, // 4 // anti-alias
                    gm.AccumulatorFormat,
                    gm.Buffers,
                    gm.Stereo);
                glControl = new GLControl(gm);

                //glControl.VSync = false;
                windowsFormsHost1.Child = glControl;
            }

            // initialize timer
            timer          = new DispatcherTimer(DispatcherPriority.Render);
            timer.Interval = TimeSpan.FromMilliseconds(10);
            timer.Tick    += new EventHandler(dispatcherTimer_Tick);

            System.Windows.Forms.Integration.WindowsFormsHost.EnableWindowsFormsInterop();
        }
Example #3
0
        private void RenderTexture(GLControl glControl1, NUT nut)
        {
            if (nut == null)
            {
                return;
            }
            glControl1.MakeCurrent();
            GL.Viewport(glControl1.ClientRectangle);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.ClearColor(Color.Black);
            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.MatrixMode(MatrixMode.Projection);

            foreach (NutTexture tex in nut.Nodes)
            {
                ScreenDrawing.DrawTexturedQuad(nut.glTexByHashId[tex.HashId].Id, tex.Width, tex.Height, true, true, true, true, true);
            }

            glControl1.SwapBuffers();
        }
 public override void OnRender(GLControl control)
 {
     GL.Enable(EnableCap.AlphaTest);
     GL.AlphaFunc(AlphaFunction.Gequal, 0.1f);
     GL.Enable(EnableCap.Blend);
     GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
 }
Example #5
0
        private SceneManager()
        {
            var flags = GraphicsContextFlags.Default;

            glControl = new GLControl(new GraphicsMode(32, 24), 2, 0, flags);
            glControl.MakeCurrent();
            glControl.Paint += Paint;
            glControl.Width  = 800;
            glControl.Height = 600;

            GL.Viewport(0, 0, glControl.Width, glControl.Height);
            GL.DepthRange(0.1, 500.0);
            GL.Enable(EnableCap.DepthTest);
            GL.DepthMask(true);
            GL.DepthFunc(DepthFunction.Lequal);
            GL.ClearColor(System.Drawing.Color.SkyBlue);

            shaderLoader = new ShaderLoader();
            texLoader    = new TexLoader();
            mdlLoader    = new MdlLoader();

            /* Initialize the camera */
            eye       = new OpenTK.Vector3(0, 0, 0);
            direction = new OpenTK.Vector3(0, 0, 1);
            top       = new OpenTK.Vector3(0, 1, 0);
        }
Example #6
0
        private void DrawModel(GLControl control, GFLXMesh m, ShaderProgram shader)
        {
            foreach (var group in m.PolygonGroups)
            {
                if (group.faces.Count <= 3)
                {
                    return;
                }

                var Material = m.ParentModel.GenericMaterials[group.MaterialIndex];

                SetUniforms(m.GetMaterial(group), shader, m, m.DisplayId);
                SetUniformBlocks(m.GetMaterial(group), shader, m, m.DisplayId);
                SetBoneUniforms(control, shader, m);
                SetVertexAttributes(m, shader);
                SetTextureUniforms(m.GetMaterial(group), m, shader);

                if (m.IsSelected)
                {
                    DrawModelSelection(group, shader);
                }
                else
                {
                    if (Runtime.RenderModels)
                    {
                        GL.DrawElements(PrimitiveType.Triangles, group.displayFaceSize, DrawElementsType.UnsignedInt, group.Offset);
                    }
                }
            }
        }
Example #7
0
        public void DrawAll(GLControl control, bool showstars, bool showstations)
        {
            if (ForceWhite)
            {
                populatedgrid.Color = (showstations) ? popcolour : Color.FromArgb(255, 212, 212, 212);
            }
            else
            {
                populatedgrid.Color = (showstations) ? popcolour : Color.Transparent;
            }

            if (showstars)
            {
                foreach (StarGrid grd in grids)
                {
                    if (grd != populatedgrid && grd != systemlistgrid)
                    {
                        grd.Color = (ForceWhite) ? Color.FromArgb(255, 212, 212, 212) : Color.Transparent;
                    }

                    grd.Draw(control);              // populated grid is in this list, so will be drawn..
                }
            }
            else if (showstations)                  // if only stations on, draw it specially.
            {
                populatedgrid.Draw(control);
            }
        }
Example #8
0
        /// <summary>
        /// バッファーを作成する
        /// </summary>
        /// <param name="viewport">描画対象</param>
        /// <param name="indicesCount">インデックス数</param>
        /// <param name="size">データ1つのサイズ</param>
        /// <param name="type">データの種類</param>
        Buffer(Viewport viewport, int indicesCount, int size, BeginMode type)
        {
            // 描画対象を設定
            this.target = viewport.glControl;

            // 描画対象を有効化
            this.target.MakeCurrent();


            // VBOを作成
            GL.GenBuffers(1, out this.vertexBuffer);

            // EBOを作成
            GL.GenBuffers(1, out this.elementBuffer);

            // VAOを作成
            GL.GenVertexArrays(1, out this.vertexArray);


            // インデックス数を設定
            this.indicesCount = indicesCount;

            // サイズを設定
            this.sizeInByte = size;

            // 描画モードを設定
            this.mode = type;
        }
Example #9
0
        // Methods
        public static void Init(GLControl viewport)
        {
            vp = viewport;
            GL.Enable(EnableCap.DepthTest);

            // Load the shaders
            Shaders.LoadAll();

            // Set Texture Parameters
            // TODO: Are these necessary?
            GL.TexParameter(TextureTarget.Texture2D,
                            TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat);

            GL.TexParameter(TextureTarget.Texture2D,
                            TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat);

            GL.TexParameter(TextureTarget.Texture2D,
                            TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);

            GL.TexParameter(TextureTarget.Texture2D,
                            TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);

            // Enable Blending
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha,
                         BlendingFactorDest.OneMinusSrcAlpha);

            vp.MakeCurrent();
            vp.VSync = true;
        }
Example #10
0
 public ModelGraphics(GLControl control)
 {
     Control         = control;
     _timer          = new Timer();
     _timer.Interval = 1000 / 60;
     _timer.Tick    += _timer_Tick;
 }
        public GLViewerControl()
        {
            InitializeComponent();
            Dock = DockStyle.Fill;

            Camera = new Camera();

            stopwatch = new Stopwatch();

            // Initialize GL control
            var flags = GraphicsContextFlags.ForwardCompatible;

#if DEBUG
            flags |= GraphicsContextFlags.Debug;
#endif

            GLControl                 = new GLControl(new GraphicsMode(32, 24, 0, 8), 3, 3, flags);
            GLControl.Load           += OnLoad;
            GLControl.Paint          += OnPaint;
            GLControl.Resize         += OnResize;
            GLControl.MouseEnter     += OnMouseEnter;
            GLControl.MouseLeave     += OnMouseLeave;
            GLControl.GotFocus       += OnGotFocus;
            GLControl.VisibleChanged += OnVisibleChanged;
            GLControl.Disposed       += OnDisposed;

            GLControl.Dock = DockStyle.Fill;
            glControlContainer.Controls.Add(GLControl);
        }
Example #12
0
            void InitializeComponent()
            {
                //clear controls in case init is called multiple times
                Controls.Clear();
                this.SuspendLayout();

                glControl           = new GLControl();
                glControl.BackColor = System.Drawing.Color.Black;
                glControl.Dock      = System.Windows.Forms.DockStyle.Fill;
                glControl.Location  = new Point(0, 0);
                //glControl.Name = "glControl";
                //glControl.Size = new Size(640, 480);
                glControl.TabIndex  = 0;
                glControl.VSync     = false;
                glControl.Load     += glControl_Load;
                glControl.Paint    += glControl_Paint;
                glControl.Resize   += glControl_Resize;
                glControl.Disposed += glControl_Disposed;
                //glControl.KeyPress += glControl_KeyPress;
                //glControl.KeyUp += glControl_KeyUp;
                glControl.MouseDown += glControl_MouseDown;
                glControl.MouseMove += glControl_MouseMove;
                glControl.MouseUp   += glControl_MouseUp;

                Controls.Add(glControl);
                this.Resize += OnResize;

                this.ResumeLayout(false);
            }
Example #13
0
        internal void OnMainEditorWindowLoaded(GLControl glControl)
        {
            m_glControl = glControl;

            // Delay the creation of the editor until the UI is created, so that we can fire off GL commands immediately in the editor.
            m_editor = new WWindEditor();
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs("WindEditor"));

            // Set up the Editor Tick Loop
            System.Windows.Forms.Timer editorTickTimer = new System.Windows.Forms.Timer();
            editorTickTimer.Interval = 16; //ms
            editorTickTimer.Tick    += (o, args) =>
            {
                DoApplicationTick();
            };
            editorTickTimer.Enabled = true;

            // Check the command line arguments to see if they've passed a folder, if so we'll try to open that.
            // This allows debugging through Visual Studio to open a map automatically.
            var cliArguments = Environment.GetCommandLineArgs();

            if (cliArguments.Length > 1)
            {
                if (System.IO.Directory.Exists(cliArguments[1]))
                {
                    m_editor.LoadProject(cliArguments[1], cliArguments[1]);
                }
            }
        }
Example #14
0
        /// <summary>
        /// プログラムを作成する
        /// </summary>
        /// <param name="viewport">描画対象</param>
        /// <param name="vertexSource">バーテックスシェーダのソース</param>
        /// <param name="geometrySource">ジオメトリシェーダのソース</param>
        /// <param name="fragmentSource">フラグメントシェーダのソース</param>
        public Program(
            Viewport viewport,
            string vertexSource,
            string geometrySource,
            string fragmentSource)
        {
            // コントロールを設定
            this.target = viewport.glControl;

            // コントロールを有効化
            this.target.MakeCurrent();

            // プログラムを作成
            this.ID = GL.CreateProgram();

            // 各シェーダーを作成して設定
            GL.AttachShader(this.ID, Program.CreateShader(vertexSource, ShaderType.VertexShader));
            GL.AttachShader(this.ID, Program.CreateShader(geometrySource, ShaderType.GeometryShader));
            GL.AttachShader(this.ID, Program.CreateShader(fragmentSource, ShaderType.FragmentShader));

            // プログラムをリンク
            GL.LinkProgram(this.ID);

            // バッファー群を初期化
            this.buffers = new List <Buffer>();
        }
Example #15
0
        public WorldForm()
        {
            InitializeComponent();

            SuspendLayout();
            var mode = GraphicsMode.Default;

            glCanvas = new GLControl(new GraphicsMode(mode.ColorFormat, mode.Depth, 8, mode.Samples, mode.AccumulatorFormat, mode.Buffers, mode.Stereo))
            {
                BackColor = System.Drawing.Color.Black,
                Dock      = DockStyle.Fill,
                Location  = new System.Drawing.Point(0, 0),
                Name      = "glCanvas",
                Size      = new System.Drawing.Size(763, 424),
                TabIndex  = 0,
                VSync     = false
            };
            glCanvas.Load    += glCanvas_Load;
            glCanvas.Paint   += glCanvas_Paint;
            glCanvas.KeyDown += WorldForm_KeyDown;
            Controls.Add(glCanvas);
            ResumeLayout(false);

            world = new World();
        }
Example #16
0
        protected virtual Control InitializeControl()
        {
            var panel = new Panel
            {
                Dock = DockStyle.Fill,
            };

            fpsLabel = new Label
            {
                Anchor   = AnchorStyles.Top | AnchorStyles.Left,
                AutoSize = true,
                Dock     = DockStyle.Top,
            };
            panel.Controls.Add(fpsLabel);

#if DEBUG
            glControl = new GLControl(new GraphicsMode(32, 24, 0, 8), 3, 3, GraphicsContextFlags.Debug);
#else
            glControl = new GLControl(new GraphicsMode(32, 24, 0, 8), 3, 3, GraphicsContextFlags.Default);
#endif
            glControl.Dock        = DockStyle.Fill;
            glControl.AutoSize    = true;
            glControl.Load       += OnLoad;
            glControl.Paint      += OnPaint;
            glControl.Resize     += OnResize;
            glControl.MouseEnter += (_, __) => Camera.MouseOverRenderArea = true;
            glControl.MouseLeave += (_, __) => Camera.MouseOverRenderArea = false;
            glControl.GotFocus   += OnGotFocus;

            panel.Controls.Add(glControl);
            return(panel);
        }
Example #17
0
        private static void SetBoneUniforms(GLControl control, ShaderProgram shader, GFLXMesh mesh)
        {
            int i = 0;

            foreach (var bone in mesh.ParentModel.Skeleton.bones)
            {
                Matrix4 transform = bone.invert * bone.Transform;

                GL.UniformMatrix4(GL.GetUniformLocation(shader.programs[control], String.Format("bones[{0}]", i++)), false, ref transform);
            }

            /*  foreach (var FaceGroup in fshp.Shape.FaceGroups)
             * {
             *    if (FaceGroup.BoneIndexList == null)
             *        continue;
             *
             *    for (int i = 0; i < FaceGroup.BoneIndexList.Length; i++)
             *    {
             *        GL.Uniform1(GL.GetUniformLocation(shader.programs[control], String.Format("boneIds[{0}]", i)), FaceGroup.BoneIndexList[i]);
             *
             *        Matrix4 transform = fmdl.Skeleton.Renderable.bones[(int)FaceGroup.BoneIndexList[i]].invert * fmdl.Skeleton.Renderable.bones[(int)FaceGroup.BoneIndexList[i]].Transform;
             *        GL.UniformMatrix4(GL.GetUniformLocation(shader.programs[control], String.Format("bones[{0}]", i)), false, ref transform);
             *    }
             * }*/
        }
        public void OnKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
            MouseOffset = Vector2.Zero;

            if (e.KeyChar.Equals(RIGHT_CHAR))
            {
                MoveCamera(Vector3.UnitX * DragFactor * 10);
            }
            else if (e.KeyChar.Equals(BACKWARDS_CHAR))
            {
                MoveCamera(Vector3.UnitZ * DragFactor * 10);
            }
            else if (e.KeyChar.Equals(FORWARDS_CHAR))
            {
                MoveCamera(-Vector3.UnitZ * DragFactor * 10);
            }
            else if (e.KeyChar.Equals(LEFT_CHAR))
            {
                MoveCamera(-Vector3.UnitX * DragFactor * 10);
            }

            GLControl renderCanvas = sender as GLControl;

            if (renderCanvas != null)
            {
                renderCanvas.Refresh();
            }
        }
Example #19
0
        public bool Update(float xp, float zp, float zoom, GLControl gl)               // Foreground UI thread, tells it if anything has changed..
        {
            Debug.Assert(Application.MessageLoop);

            StarGrid grd = null;

            bool displayed = false;

            while (computed.TryTake(out grd))                               // remove from the computed queue and mark done
            {
                grd.Display(gl);                                            // swap to using this one..
                Thread.MemoryBarrier();                                     // finish above before clearing working
                grd.Working = false;
                displayed   = true;
            }

            Thread.MemoryBarrier();                                         // finish above

            curx = xp;
            curz = zp;

            ewh.Set();                                                      // tick thread again to consider..

            return(displayed);                                              // return if we updated anything..
        }
Example #20
0
        public FrmMain()
        {
            //We need to add the control here cause we need to call the constructor with Graphics Mode.
            //This enables the higher precision Depth Buffer and a Stencil Buffer.
            Viewport = new GLControl(new GraphicsMode(32, 24, 8), 3, 3, GraphicsContextFlags.ForwardCompatible)
            {
                Dock  = DockStyle.Fill,
                Name  = "Viewport",
                VSync = true
            };

            Viewport.Load       += Viewport_Load;
            Viewport.Paint      += Viewport_Paint;
            Viewport.MouseDown  += Viewport_MouseDown;
            Viewport.MouseMove  += Viewport_MouseMove;
            Viewport.MouseWheel += Viewport_MouseWheel;
            Viewport.Resize     += Viewport_Resize;

            InitializeComponent();

            MainContainer.Panel1.Controls.Add(Viewport);

            TopMenu.Renderer   = new ToolsRenderer(TopMenu.BackColor);
            TopIcons.Renderer  = new ToolsRenderer(TopIcons.BackColor);
            SideIcons.Renderer = new ToolsRenderer(SideIcons.BackColor);
        }
Example #21
0
        public MainForm()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            StatusDelegate = UpdateStatus;
            Logger.SetLogControl(richTextBox1);
            glWin = new GLControl();
            splitContainer2.Panel2.Controls.Add(glWin);
            OpenTK.Toolkit.Init();
            glWin.CreateControl();
            glWin.CreateGraphics();
            glWin.Dock      = DockStyle.Fill;
            glWin.BackColor = Color.DarkGray;
            glWin.BringToFront();

            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //
            Scene.Init(glWin);
            glWin.KeyDown       += glWin_KeyPress;
            glWin.KeyUp         += glWin_KeyRelease;
            glWin.MouseMove     += glWin_MouseMove;
            glWin.MouseWheel    += glWin_MouseWheel;
            glWin.Paint         += glWin_Paint;
            RenderTimer.Interval = 15;
            RenderTimer.Tick    += Repaint;
            RenderTimer.Start();
        }
Example #22
0
        public CanvasForm(Control parent)
        {
            InitializeComponent();

            ContextContainer           = new Panel();
            ContextContainer.Padding   = new Padding(1);
            ContextContainer.Margin    = new Padding(0);
            ContextContainer.BackColor = Color.Black;

            Console.WriteLine(ContextContainer.Anchor);

            GraphicsMode mode = new GraphicsMode(
                new ColorFormat(8, 8, 8, 8),
                8, 8, MSAASamples,
                new ColorFormat(8, 8, 8, 8), 2, false
                );

            GLContext            = new GLControl(mode, 2, 0, GraphicsContextFlags.Default);
            GLContext.Dock       = DockStyle.Fill;
            GLContext.VSync      = true;
            GLContext.Paint     += new PaintEventHandler(this.GLContext_Paint);
            GLContext.MouseDown += new MouseEventHandler(this.GLContext_MouseDown);
            GLContext.MouseMove += new MouseEventHandler(this.GLContext_MouseMove);
            GLContext.MouseUp   += new MouseEventHandler(this.GLContext_MouseUp);

            ContextContainer.Controls.Add(GLContext);
            Controls.Add(ContextContainer);

            // Setup stuff
            TopLevel = false;
            parent.Controls.Add(this);
        }
Example #23
0
        public static void GlControl_Draw_End(GLControl glcontrol)
        {
            GL.Flush();
            glcontrol.SwapBuffers();
            if (Settings.Screenshot)
            {
                if ((DateTime.Now - Settings.ScreenShotTime).Milliseconds > 500)
                {
                    Settings.ScreenShotTime = DateTime.Now;
                    Image img = TakeScreenshot(glcontrol);

                    var            codecs = ImageCodecInfo.GetImageEncoders();
                    ImageCodecInfo ici    = null;
                    foreach (ImageCodecInfo codec in codecs)
                    {
                        if (codec.MimeType == "image/jpeg")
                        {
                            ici = codec;
                        }
                    }

                    //path where you need to save
                    //img.Save(@"\\0.0.0.0\screenshot.jpg", ImageFormat.Jpeg);
                }
            }
        }
Example #24
0
        private void BitmapFromString(TifFileInfo fi, string str, PointF p, bool title = false)
        {
            Font font = new Font("Times New Roman", 9, FontStyle.Regular);

            if (title)
            {
                font = new Font("Times New Roman", 9, FontStyle.Bold);
            }

            Bitmap bmp = new Bitmap(TextRenderer.MeasureText(str, font).Width,
                                    TextRenderer.MeasureText(str, font).Height,
                                    System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            RectangleF rect = new Rectangle(0, 0,
                                            TextRenderer.MeasureText(str, font).Width,
                                            TextRenderer.MeasureText(str, font).Height);

            //MessageBox.Show(rect.Width.ToString() + "\n" +                rect.Height.ToString());
            using (Graphics g = Graphics.FromImage(bmp))
            {
                g.FillRectangle(Brushes.White, rect);
                g.DrawString(str, font, Brushes.Black, rect);
                g.Flush();
            }

            int ID = IA.IDrawer.ImageTexture.LoadTexture(bmp);

            GLControl GLControl1 = IA.GLControl1;

            GL.Enable(EnableCap.Texture2D);

            GL.BindTexture(TextureTarget.Texture2D, ID);

            rect.Width  /= (float)fi.zoom;
            rect.Height /= (float)fi.zoom;

            rect = new RectangleF(p.X - rect.Width / 2, p.Y - rect.Height / 2,
                                  p.X + rect.Width / 2, p.Y + rect.Height / 2);

            GL.Begin(PrimitiveType.Quads);

            GL.Color3(Color.White);

            GL.TexCoord2(0, 0);
            GL.Vertex2(rect.X, rect.Y);

            GL.TexCoord2(0, 1);
            GL.Vertex2(rect.X, rect.Height);

            GL.TexCoord2(1, 1);
            GL.Vertex2(rect.Width, rect.Height);

            GL.TexCoord2(1, 0);
            GL.Vertex2(rect.Width, rect.Y);

            GL.End();

            GL.Disable(EnableCap.Texture2D);
        }
 public void UpdateModelMatrix(Matrix4 matrix, GLControl control)
 {
     modelMatrix = matrix;
     if (uniforms.ContainsKey("mtxMdl"))
     {
         GL.UniformMatrix4(uniforms["mtxMdl"], false, ref modelMatrix);
     }
 }
 void IDisposable.Dispose()
 {
     if (this.mainContextControl != null)
     {
         this.mainContextControl.Dispose();
         this.mainContextControl = null;
     }
 }
Example #27
0
        public MyCamera(GLControl glControl)
        {
            m_glControl = glControl;

            glControl.MouseDown += new MouseEventHandler(glControl_MouseDown);
            glControl.MouseMove += new MouseEventHandler(glControl_MouseMove);
            glControl.MouseUp   += new MouseEventHandler(glControl_MouseUp);
        }
Example #28
0
 public Camera(GLControl vp)
 {
     Viewport            = vp;
     Viewport.MouseDown += Viewport_MouseDown;
     Viewport.MouseUp   += Viewport_MouseUp;
     Viewport.KeyDown   += Viewport_KeyDown;
     Viewport.MouseMove += Viewport_MouseMove;
 }
Example #29
0
 public Renderer(GLControl g)
 {
     this._g    = g;
     xl         = -_g.Width / 2;
     yl         = -_g.Height / 2;
     TranslateX = _g.Width / 2 / Scale;
     TranslateY = -_g.Height / 2 / Scale;
 }
Example #30
0
        public StarNamesList(StarGrids sg, FormMap _fm, GLControl gl)
        {
            _stargrids = sg;
            _formmap   = _fm;
            _glControl = gl;

            _starnames = new Dictionary <Vector3, StarNames>();
        }
 public void Start(IApi platformImplementation, Action update, Action render)
 {
     this.update = update;
     this.render = render;
     ComponentDispatcher.ThreadIdle += (sender, e) => System.Windows.Forms.Application.RaiseIdle(e);
     glControl = new GLControl(new GraphicsMode(32, 24), 2, 0, GraphicsContextFlags.Default);
     glControl.Paint += (object sender, PaintEventArgs e) => {
         if (!loaded)
             return;
         render();
         glControl.SwapBuffers();
     };
     glControl.Dock = DockStyle.Fill;
     glControl.Load += (object sender, EventArgs e) => { this.loaded = true; };
     Application.Idle += (object sender, EventArgs e) => {
         double milliseconds = ComputeTimeSlice();
         Accumulate(milliseconds);
         update();
         Animate(milliseconds);
     };
     glControl.MakeCurrent();
 }