Beispiel #1
0
        private void DrawUi(OpenGL gl)
        {
            gl.DrawText(new Point(5, 5), Color.Black, 26, DebugText);

            var height = openGLControl1.Height;

            var mode = rotationMode ? $"Rotation: {sceneRotation}" : $"Move: {scenePosition}";

            gl.DrawText(new Point(5, height - 16), Color.Black, 16, mode);
        }
Beispiel #2
0
        private void drawMaze(OpenGL gl)
        {
            if (dataModel.MazeStructure.Origin != null)
            {
                //  Draw a coloured pyramid.
                gl.Begin(OpenGL.GL_TRIANGLES);

                gl.Color(0.0f, 1.0f, 0.0f);

                float x = dataModel.MazeStructure.Origin.Coordinates.X;
                float y = dataModel.MazeStructure.Origin.Coordinates.Y;
                float z = 1.0f;

                gl.Vertex(x, y, z);

                gl.DrawText(0, 0, 128.0f, 128.0f, 128.0f, "Arial", 12.0f, "Drawing maze");

                /*
                gl.Color(1.0f, 0.0f, 0.0f);
                gl.Vertex(0.0f, 1.0f, 0.0f);
                gl.Color(0.0f, 1.0f, 0.0f);
                gl.Vertex(-1.0f, -1.0f, 1.0f);
                gl.Color(0.0f, 0.0f, 1.0f);
                gl.Vertex(1.0f, -1.0f, 1.0f);
                gl.Color(1.0f, 0.0f, 0.0f);
                gl.Vertex(0.0f, 1.0f, 0.0f);
                gl.Color(0.0f, 0.0f, 1.0f);
                gl.Vertex(1.0f, -1.0f, 1.0f);
                gl.Color(0.0f, 1.0f, 0.0f);
                gl.Vertex(1.0f, -1.0f, -1.0f);
                gl.Color(1.0f, 0.0f, 0.0f);
                gl.Vertex(0.0f, 1.0f, 0.0f);
                gl.Color(0.0f, 1.0f, 0.0f);
                gl.Vertex(1.0f, -1.0f, -1.0f);
                gl.Color(0.0f, 0.0f, 1.0f);
                gl.Vertex(-1.0f, -1.0f, -1.0f);
                gl.Color(1.0f, 0.0f, 0.0f);
                gl.Vertex(0.0f, 1.0f, 0.0f);
                gl.Color(0.0f, 0.0f, 1.0f);
                gl.Vertex(-1.0f, -1.0f, -1.0f);
                gl.Color(0.0f, 1.0f, 0.0f);
                gl.Vertex(-1.0f, -1.0f, 1.0f);
                */
                gl.End();
            }

            if (dataModel != null)
                gl.DrawText(0, 0, 128.0f, 128.0f, 128.0f, "Arial", 12.0f, dataModel.SolverAgentList.Count.ToString());
        }
        /// <summary>
        /// Renders to the specified graphics.
        /// </summary>
        /// <param name="graphics">The graphics to render to.</param>
        protected void Render(Graphics graphics)
        {
            //  Start the stopwatch so that we can time the rendering.
            stopwatch.Restart();

            //	Make sure it's our instance of openSharpGL that's active.
            OpenGL.MakeCurrent();

            //	If there is a draw handler, then call it.
            DoOpenGLDraw(new RenderEventArgs(graphics));

            //  Draw the FPS.
            if (DrawFPS)
            {
                OpenGL.DrawText(5, 5, 1.0f, 0.0f, 0.0f, "Courier New", 12.0f,
                                string.Format("Draw Time: {0:0.0000} ms ~ {1:0.0} FPS", frameTime, 1000.0 / frameTime));
                OpenGL.Flush();
            }

            //	Blit our offscreen bitmap.
            var handleDeviceContext = graphics.GetHdc();

            OpenGL.Blit(handleDeviceContext);
            graphics.ReleaseHdc(handleDeviceContext);

            //  Perform GDI drawing.
            if (OpenGL.RenderContextProvider != null && OpenGL.RenderContextProvider.GDIDrawingEnabled)
            {
                DoGDIDraw(new RenderEventArgs(graphics));
            }

            //  Stop the stopwatch.
            stopwatch.Stop();

            //  Store the frame time.
            frameTime = stopwatch.Elapsed.TotalMilliseconds;
        }
Beispiel #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //  Start the stopwatch so that we can time the rendering.
            stopwatch.Restart();

            //	Make sure it's our instance of openSharpGL that's active.
            OpenGL.MakeCurrent();

            //	Do the scene drawing.
            scene.Draw();

            //	If there is a draw handler, then call it.
            DoOpenGLDraw(new RenderEventArgs(e.Graphics));

            //  Draw the FPS.
            if (DrawFPS)
            {
                OpenGL.DrawText(5, 5, 1.0f, 0.0f, 0.0f, "Courier New", 12.0f,
                                string.Format("Draw Time: {0:0.0000} ms ~ {1:0.0} FPS", frameTime, 1000.0 / frameTime));
                OpenGL.Flush();
            }

            //	Blit our offscreen bitmap.
            IntPtr handleDeviceContext = e.Graphics.GetHdc();

            OpenGL.Blit(handleDeviceContext);
            e.Graphics.ReleaseHdc(handleDeviceContext);

            //	If's there's a GDI draw handler, then call it.
            DoGDIDraw(new RenderEventArgs(e.Graphics));

            //  Stop the stopwatch.
            stopwatch.Stop();

            //  Store the frame time.
            frameTime = stopwatch.Elapsed.TotalMilliseconds;
        }
Beispiel #5
0
 public void Draw(OpenGL gl)
 {
     _starDrawTime.Reset();
     _starDrawTime.Start();
     if (StartupComplete)
     {
         renderEngine.RenderObjects(gl, GameObjects.ToArray());
         if (Paused)
         {
             gl.DrawText(100, 100, 1f, 1f, 1f, "verdana", 20, "Paused");
         }
     }
     else
     {
         gl.DrawText(100, 100, 1f, 1f, 1f, "verdana", 20, "Loading");
     }
     if (_level != null)
     {
         _level.Draw(gl);
     }
     _starDrawTime.Stop();
     DrawTime = (int)_starDrawTime.ElapsedMilliseconds;
 }
Beispiel #6
0
 //Draw the level(score or a hud)
 public override void Draw(OpenGL gl)
 {
     gl.DrawText(100, 100, 1f, 1f, 1f, "verdana", 20, _time.ToString());
 }
Beispiel #7
0
        public static void DrawText(this OpenGL gl, Point position, Color color, float fontSize, string text)
        {
            var cl = ConvertColor(color);

            gl.DrawText(position.X, position.Y, cl.Item1, cl.Item2, cl.Item3, "FACE", fontSize, text);
        }
Beispiel #8
0
        //  private float angleX = 0.0f, angleY = 0.0f, angleZ = 0.0f, x = 1;
        //  private int counter = 0;
        private void ModelRotater(OpenGL testObject)
        {
            testObject.Rotate(cord.getX(), 1.0f, 0.0f, 0.0f); //cord.getX()
            testObject.Rotate(cord.getZ(), 0.0f, 1.0f, 0.0f); //cord.getZ()
            testObject.Rotate(cord.getY(), 0.0f, 0.0f, 1.0f); //cord.getY()

            int h, w;
            h = openGLControl.Size.Height / 4;
            w = (openGLControl.Size.Width * 4) / 5;
            string text = "x: " + cord.getX().ToString(); // +", " + ComInput.osY.ToString() + ", " + ComInput.osZ.ToString();
            testObject.DrawText(w, h, 1, 1, 1, "faceName", 20, text);

            h = openGLControl.Size.Height / 5;
            text = "y: " + cord.getY().ToString();
            testObject.DrawText(w, h, 1, 1, 1, "faceName", 20, text);

            h = (openGLControl.Size.Height * 3) / 20;
            text = "z: " + cord.getZ().ToString();
            testObject.DrawText(w, h, 1, 1, 1, "faceName", 20, text);

            h = openGLControl.Size.Height / 10;
            text = "Work time: " + ComInput.fl.ToString();
            testObject.DrawText(w, h, 1, 1, 1, "faceName", 20, text);
        }