Ejemplo n.º 1
0
 public void DrawFilter(OpenGLControl gl, List <Layout> layouts)
 {
     foreach (var layout in layouts)
     {
         layout.FilterAccesses.ForEach(x => x.Filter(null, gl.OpenGL));
     }
 }
Ejemplo n.º 2
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (Template != null)
            {
                openGLControl   = Template.FindName("Viewport_3D", this) as OpenGLControl;
                hwndHostElement = Template.FindName("Ether_Viewport", this) as Control_Ether_HwndHost;
                sceneWindow     = Template.FindName("SceneWindow", this) as Grid;

                //TODO: Reference by name
                if (CommandArguments.TryGetArgument("ether"))
                {
                    sceneWindow.Children.RemoveAt(1);
                    return;
                }
                sceneWindow.Children.RemoveAt(2);


                CompositionTarget.Rendering += (sender, args) => openGLControl.DoRender();

                shaderErrorLabel = Template.FindName("Shader_Compiler_Error", this) as TextBlock;

                Hierarchy.FocusChangedEvent += o => cameraFocusPoint = o.Transform.Position;
            }
        }
Ejemplo n.º 3
0
        public override void Draw(OpenGLControl glControl)
        {
            //calculate to determine the points of the pentagon
            double angle      = 2 * Math.PI / 5;
            double x_Center   = (double)(firstPoint.X + secondPoint.X) / 2;
            double high       = (double)(firstPoint.Y - secondPoint.Y);
            double delta_y    = high * Math.Sin(angle / 2) / (Math.Sin(angle) + Math.Sin(angle / 2));
            double half_width = (secondPoint.X - firstPoint.X) / 2;
            double delta_x    = half_width * Math.Cos(angle) / (Math.Cos(angle) + 0.5);

            //set center
            _center.X = (int)x_Center;
            _center.Y = (int)((firstPoint.Y + 2 * secondPoint.Y + 2 * (firstPoint.Y - delta_y)) / 5);

            base.Draw(glControl);
            var glCtrl = glControl.OpenGL;

            //GL_LINE_LOOP: Connect the coordinates together in a specified order to a closed form
            glCtrl.Begin(OpenGL.GL_LINE_LOOP);

            glCtrl.Vertex(x_Center, glControl.Height - firstPoint.Y);//coordinates of point (x,y)
            glCtrl.Vertex(secondPoint.X, glControl.Height - (firstPoint.Y - delta_y));
            glCtrl.Vertex(secondPoint.X - delta_x, glControl.Height - secondPoint.Y);
            glCtrl.Vertex(firstPoint.X + delta_x, glControl.Height - secondPoint.Y);
            glCtrl.Vertex(firstPoint.X, glControl.Height - (firstPoint.Y - delta_y));

            glCtrl.End();
            glCtrl.Flush();
        }
Ejemplo n.º 4
0
        public static void InitEngine(OpenGLControl control)
        {
            if (XEngineContext.GLControl != null)
            {
                return;
            }
            XEngineContext.GLControl = control;

            Input.Init();

            foreach (var type in Assembly.GetEntryAssembly().GetTypes().Where(t => t.IsClass))
            {
                var engActivateAttr = type.GetCustomAttributes(typeof(XEngineActivationAttribute), false);
                if (engActivateAttr.Length == 0)
                {
                    continue;
                }
                var attr = (XEngineActivationAttribute)engActivateAttr[0];
                type.GetMethod(attr.MethodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, null);
            }

            XEngineContext.SkyboxShader = Shader.CreateInternal("skybox");

            Time.Init();

            SceneManager.LoadScene(SceneManager.MainSceneId);
        }
Ejemplo n.º 5
0
        public virtual void DrawControlPoint(OpenGLControl glControl, Color?color = null)
        {
            if (listControlPoint == null)
            {
                listControlPoint = new List <Point>();
            }
            else
            {
                listControlPoint.Clear();
            }
            listControlPoint.Add(new Point(upLeft.X, upLeft.Y));
            listControlPoint.Add(new Point(downRight.X, downRight.Y));
            listControlPoint.Add(new Point(upLeft.X, downRight.Y));
            listControlPoint.Add(new Point(downRight.X, upLeft.Y));
            listControlPoint.Add(new Point(upLeft.X, (upLeft.Y + downRight.Y) / 2));
            listControlPoint.Add(new Point(downRight.X, (upLeft.Y + downRight.Y) / 2));
            listControlPoint.Add(new Point((upLeft.X + downRight.X) / 2, upLeft.Y));
            listControlPoint.Add(new Point((upLeft.X + downRight.X) / 2, downRight.Y));

            Color choose = color ?? Color.Red;
            var   gl     = glControl.OpenGL;

            gl.Color(choose.R / 255.0, choose.G / 255.0, choose.B / 255.0);
            gl.PointSize(5f);
            gl.Begin(OpenGL.GL_POINTS);
            listControlPoint.ForEach(x => gl.Vertex(x.X, glControl.Height - x.Y));
            gl.End();
            gl.Flush();
        }
Ejemplo n.º 6
0
        public static void ThucHienVe(OpenGLControl openGLControl)
        {
            var gl = openGLControl.OpenGL;

            listDraw.ToList().ForEach(x => x.Draw(openGLControl));
            gl.Flush();
        }
Ejemplo n.º 7
0
        public static Point _BakMousePosition = new Point(0, 0);  //記錄原游標位置
        public static void OpenGLCtrl_MouseMove(object sender, MouseEventArgs e)
        {
            OpenGLControl ctrl = (OpenGLControl)sender;

            if (_3DMoveStatus == MoveStatus.Rotate)
            {
                _RoX += (e.X - _BakMousePosition.X) / 5.0f;
                _RoY += isNav * (e.Y - _BakMousePosition.Y) / 5.0f;
                if (_RoX < 0)
                {
                    _RoX += 360;
                }
                else if (_RoX > 360)
                {
                    _RoX -= 360;
                }
                if (_RoY < 0)
                {
                    _RoY += 360;
                }
                else if (_RoY > 360)
                {
                    _RoY -= 360;
                }
            }
            else if (_3DMoveStatus == MoveStatus.Shift)
            {
                _LX += (e.X - _BakMousePosition.X) / (70.0f + _LZ);
                _LY += (_BakMousePosition.Y - e.Y) / (70.0f + _LZ);
            }
            _BakMousePosition.X = e.X;
            _BakMousePosition.Y = e.Y;
        }
Ejemplo n.º 8
0
        public override void Draw(OpenGLControl glControl)
        {
            OpenGL gl = glControl.OpenGL;

            initPoint();
            gl.PushMatrix();
            gl.Rotate((float)angelX, (float)angelY, (float)angelZ);
            gl.Translate(tX, tY, tZ);
            gl.Scale(sX, sY, sZ);

            gl.Color(color.R / 255.0, color.G / 255.0, color.B / 255.0, 0);
            //Vẽ khối hoặc vẽ và dán texture
            if (isTexture)
            {
                DrawTexture(gl);
            }
            else
            {
                DrawRaw(gl);
            }

            //Viền khung
            border(gl);
            gl.PopMatrix();
            gl.Flush();
        }
Ejemplo n.º 9
0
        public void SetNearClipPlane(double fNear)
        {
            m_fNear = fNear;

            // Reset the projection matrix (coordinate system)
            OpenGLControl.glMatrixMode(OpenGLControl.GL_PROJECTION);
            OpenGLControl.glLoadIdentity();

            if (m_bPerspective)
            {
                // Perspective transformations.
                OpenGLControl.gluPerspective(m_fFovY, m_fAspect, m_fNear, m_fFar);
            }

            else
            {
                // Orthographic transformations.
                OpenGLControl.glOrtho(m_fLeft, m_fRight, m_fBottom, m_fTop, m_fNear, m_fFar);
            }

            // Save the Projection matrix.  This is used later for
            // conversion of mouse coordinates to world coordinates.
            OpenGLControl.glGetDoublev(OpenGLControl.GL_PROJECTION_MATRIX, m_dProjectionMatrix);

            // Reset the ModelView matrix
            OpenGLControl.glMatrixMode(OpenGLControl.GL_MODELVIEW);
        }
Ejemplo n.º 10
0
        public static void draw_GO_square(OpenGLControl openGLControl, int x_from, int y_from, int size, System.Drawing.Color _color)
        {
            //x_from -= mouse.ShiftedPosition.x;
            //y_from += mouse.ShiftedPosition.y;
            int x_to = x_from;
            int y_to = y_from;

            x_to += size;
            y_to += size;

            OpenGL gl = openGLControl.OpenGL;

            //  Clear the color and depth buffer.
            //  Load the identity matrix.
            gl.LoadIdentity();

            gl.Color((float)_color.R / 255, (float)_color.G / 255, (float)_color.B / 255, 1.0f); //Must have, weirdness!
            gl.Begin(OpenGL.GL_QUADS);

            Single Line_Height = +0.9f;

            gl.Vertex(x_to, y_to, Line_Height);
            gl.Vertex(x_to, y_from, Line_Height);
            gl.Vertex(x_from, y_from, Line_Height);
            gl.Vertex(x_from, y_to, Line_Height);


            gl.End();
        }
Ejemplo n.º 11
0
        public override void AnotherWay(OpenGLControl openGL)
        {
            Bitmap bitmap = new Bitmap(openGL.Width, openGL.Height);

            openGL.DrawToBitmap(bitmap, new Rectangle(openGL.Left, openGL.Top, openGL.Width, openGL.Height));
            FilterImage(bitmap);
        }
Ejemplo n.º 12
0
        public virtual void Draw(OpenGLControl glControl)
        {
            var gl = glControl.OpenGL;

            gl.LineWidth(_size);
            gl.Color(_color.R / 255.0, _color.G / 255.0, _color.B / 255.0);
        }
Ejemplo n.º 13
0
        public static void Translate(OpenGLControl openGLControl, Point start, Point end)
        {
            if (inside_shape == true)
            {
                if (selectedShape != null)
                {
                    selectedShape.firstPoint.X  += end.X - start.X;
                    selectedShape.firstPoint.Y  += end.Y - start.Y;
                    selectedShape.secondPoint.X += end.X - start.X;
                    selectedShape.secondPoint.Y += end.Y - start.Y;
                    selectedShape.Draw(openGLControl);
                    selectedShape.drawControlPoints(openGLControl);
                }
            }

            if (inside_polygon == true)
            {
                if (selectedPolygon != null)
                {
                    selectedPolygon.firstPoint.X  += end.X - start.X;
                    selectedPolygon.firstPoint.Y  += end.Y - start.Y;
                    selectedPolygon.secondPoint.X += end.X - start.X;
                    selectedPolygon.secondPoint.Y += end.Y - start.Y;
                    selectedPolygon.ChangePosition(openGLControl, start, end);
                    //selectedPolygon.SetData_ControlPoint(openGLControl);
                    selectedPolygon.drawPolygon(openGLControl);
                    selectedPolygon.drawControlPoints(openGLControl);
                }
            }
        }
Ejemplo n.º 14
0
 public void PostDrawFilter(OpenGLControl gl)
 {
     if (FilterType == FilterType.Image)
     {
         AnotherWay(gl);
     }
 }
Ejemplo n.º 15
0
        public static Object chooseObject(OpenGLControl openGLControl, int _chooseIcon, Vertex center)
        {
            Object _chooseObject = null;

            /*Choose a shape */

            switch (_chooseIcon)
            {
            case 1:                         //Cube
                _chooseObject = new Cube(); //màu nền, tâm, chiều dài cạnh, check đang chọn
                break;

            case 2:                            //Pyramid - Hình chóp đáy là hình vuông
                _chooseObject = new Pyramid(); //màu nền, tâm, chiều dài cạnh, check đang chọn, đỉnh chóp
                break;

            case 3:                             //Cylinder - Hình lăng trụ đáy là tam giác đều
                _chooseObject = new Cylinder(); //màu nền, tâm, chiều dài cạnh, check đang chọn
                break;

            //xem lại chú thích
            default:
                break;
            }
            if (_chooseObject != null) // nếu tạo được object
            {
                _chooseObject.name += Object._countObjects.ToString();
                listObject.Add(_chooseObject);
            }

            return(_chooseObject);
        }
Ejemplo n.º 16
0
        public override void Draw(OpenGLControl glControl)
        {
            OpenGL gl = glControl.OpenGL;

            Save();
            gl.PushMatrix();
            gl.Rotate((float)rX, (float)rY, (float)rZ);
            gl.Translate(pX, pY, pZ);
            gl.Scale(sX, sY, sZ);

            gl.Color(color.R / 255.0, color.G / 255.0, color.B / 255.0, 0);
            //Vẽ khối hoặc vẽ và dán texture
            if (isTexture)
            {
                Paste_Texture(gl);
            }
            else
            {
                DrawRaw(gl);
            }
            //Viền khung
            Borders(gl);
            gl.PopMatrix();
            gl.Flush();
        }
Ejemplo n.º 17
0
        public GameForm()
        {
            InitializeComponent();

            redrawTimer          = new Timer();
            redrawTimer.Enabled  = true;
            redrawTimer.Interval = 25;
            redrawTimer.Tick    += new EventHandler(redraw);


            hdc = (uint)this.Handle;
            string error = "";

            OpenGLControl.OpenGLInit(ref hdc, this.Width, this.Height, ref error);
            control.Cam.SetPerspective();
            Lighting.SetupLighting();

            ContentManager.SetTextureList("textures\\");
            ContentManager.LoadTextures();
            ContentManager.SetModelList("models\\");
            ContentManager.LoadModels();

            control.CreateObjects();
            GameControl.StartedRace = true;
        }
Ejemplo n.º 18
0
        public static Object chooseObject(OpenGLControl openGLControl, int chooseIcon, Point3D center)
        {
            Object chooseObject = null;

            /*Choose a shape */

            switch (chooseIcon)
            {
            case 1:                        //Cube
                chooseObject = new Cube(); //màu nền, tâm, chiều dài cạnh, check đang chọn
                break;

            case 2:                           //Pyramid - Hình chóp đáy là hình vuông
                chooseObject = new Pyramid(); //màu nền, tâm, chiều dài cạnh, check đang chọn, đỉnh chóp
                break;

            case 3:                         //Prism - Hình lăng trụ đáy là tam giác đều
                chooseObject = new Prism(); //màu nền, tâm, chiều dài cạnh, check đang chọn
                break;

            //xem lại chú thích
            default:
                break;
            }
            if (chooseObject != null) // nếu tạo được object
            {
                string name;
                chooseObject.name = Object.nums.ToString() + "." + chooseObject.name;
                listObject.Add(chooseObject);
            }

            return(chooseObject);
        }
Ejemplo n.º 19
0
        public Ventana()
        {
            InitializeComponent();
            //identificador del lugar en donde voy a dibujar
            hdc = (uint)this.Handle;
            //toma el error que sucedio
            string error = "";

            //Comando de inicializacion de la ventana grafica
            OpenGLControl.OpenGLInit(ref hdc, this.Width, this.Height, ref error);

            if (error != "")
            {
                MessageBox.Show("Ocurrio un error al inicializar OpenGl");
            }

            //inicia la posicion de la camara asi como define en angulo de perspectiva,etc etc
            //controladora.Camara.EstablecerPerspectiva();
            controladora.Camara.InitCamara();

            //Habilita las luces
            Lighting.SetupLighting();
            ContentManager.SetTextureList("texturas\\"); //especifico la ubicacion de las texturas
            ContentManager.LoadTextures();               //las cargo
            ContentManager.SetModelList("modelo\\");     // especifico la ubicacion de la oficina
            ContentManager.LoadModels();                 // la cargo
            AudioPlayback.SoundDir = "sonidos\\";
            AudioPlayback.LoadSounds();

            //Color de fondo
            Gl.glClearColor(0.3f, 0.6f, 1, 1);//red green blue alpha

            controladora.CrearObjetos();
        }
Ejemplo n.º 20
0
        public override void Draw(OpenGLControl glControl)
        {
            OpenGL gl = glControl.OpenGL;

            Save();
            gl.PushMatrix();
            gl.Rotate((float)angelX, (float)angelY, (float)angelZ);
            gl.Translate(tX, tY, tZ);
            gl.Scale(sX, sY, sZ);

            gl.Color(_color.R / 255.0, _color.G / 255.0, _color.B / 255.0, 0);
            //Vẽ khối hoặc vẽ và dán texture
            if (isTexture)
            {
                DrawTexture(gl);
            }
            else
            {
                DrawRaw(gl);
            }
            //Viền khung
            VienKhung(gl);
            gl.PopMatrix();
            gl.Flush();// Thực hiện lệnh vẽ ngay lập tức thay vì đợi sau 1 khoảng thời gian
        }
Ejemplo n.º 21
0
        public override void Draw(OpenGLControl glControl)
        {
            //center, radius R
            _center.X = (int)((firstPoint.X + secondPoint.X) / 2);
            _center.Y = (int)((firstPoint.Y + secondPoint.Y) / 2);
            R         = (int)(Math.Abs((firstPoint.Y - secondPoint.Y) / 2));

            double delta_Y = (double)(firstPoint.Y - secondPoint.Y) / 4;

            base.Draw(glControl);
            var glCtrl = glControl.OpenGL;

            glCtrl.Begin(OpenGL.GL_LINE_LOOP);

            //determine the points of hexagon
            glCtrl.Vertex(_center.X, glControl.Height - firstPoint.Y);
            glCtrl.Vertex(secondPoint.X, glControl.Height - (firstPoint.Y - delta_Y));
            glCtrl.Vertex(secondPoint.X, glControl.Height - (secondPoint.Y + delta_Y));
            glCtrl.Vertex(_center.X, glControl.Height - secondPoint.Y);
            glCtrl.Vertex(firstPoint.X, glControl.Height - (secondPoint.Y + delta_Y));
            glCtrl.Vertex(firstPoint.X, glControl.Height - (firstPoint.Y - delta_Y));

            glCtrl.End();
            glCtrl.Flush();
        }
Ejemplo n.º 22
0
        public void GetScreenCoord(double wX, double wY, double wZ,
                                   ref double scrX, ref double scrY, ref double scrZ)
        {
            unsafe
            {
                fixed(double *m_dModelViewMatrixPtr = m_dModelViewMatrix)
                {
                    fixed(double *m_dProjectionMatrixPtr = m_dProjectionMatrix)
                    {
                        fixed(int *m_iViewportPtr = m_iViewport)
                        {
                            double scrXVal = scrX;
                            double scrYVal = scrY;
                            double scrZVal = scrZ;

                            OpenGLControl.gluProject(wX, wY, wZ,
                                                     m_dModelViewMatrixPtr, m_dProjectionMatrixPtr, m_iViewportPtr,
                                                     &scrXVal, &scrYVal, &scrZVal);
                            scrX = scrXVal;
                            scrY = scrYVal;
                            scrZ = scrZVal;
                        }
                    }
                }
            }
            scrY  = m_iViewport[3] - scrY;
            scrZ += GetFocalLength();
        }
        public static Object chooseObject(OpenGLControl openGLControl, int _chooseIcon, Vertex center)
        {
            Object choose_Object = null;

            //Xử lý chọn Object để vẽ.
            switch (_chooseIcon)
            {
            case 1:    //Cube
                choose_Object = new Cube();
                break;

            case 2:    //Pyramid - Hình chóp đáy là hình vuông
                choose_Object = new Pyramid();
                break;

            case 3:    //Prism - Hình lăng trụ đáy là tam giác đều
                choose_Object = new Prism();
                break;

            default:
                break;
            }
            if (choose_Object != null) // nếu tạo được object
            {
                choose_Object.name += Object._countObjects.ToString();
                listObject.Add(choose_Object);
            }
            return(choose_Object);
        }
Ejemplo n.º 24
0
 public override void Init(OpenGLControl control, float width, float height)
 {
     control.MouseWheel += (s, e) => Scroll += e.Delta / System.Windows.Forms.SystemInformation.MouseWheelScrollDelta;
     LoadSceneData(control.OpenGL);
     BuildShaders(control.OpenGL);
     LoadEEGData(control.OpenGL);
 }
Ejemplo n.º 25
0
        public void Draw(OpenGLControl openGLControl, int size)
        {
            OpenGL gl = openGLControl.OpenGL;

            //Vẽ trục tọa độ tại gốc 0,0,0
            gl.LineWidth(3);
            gl.Begin(OpenGL.GL_LINES);
            gl.Color(1f, 0, 0, 0); // Chọn màu Red
            gl.Vertex(-size, 0, 0); gl.Vertex(size, 0, 0);

            gl.Color(0f, 1f, 0, 0); // Chọn màu Green
            gl.Vertex(0, -size, 0); gl.Vertex(0, size, 0);

            gl.Color(0f, 0, 1f, 0); // Chọn màu Blue
            gl.Vertex(0, 0, -size); gl.Vertex(0, 0, size);
            gl.End();

            //Vẽ lưới tọa độ
            gl.LineWidth(1);
            gl.Begin(OpenGL.GL_LINES);
            gl.LineWidth(0.1f);
            gl.Color(180.0 / 255.0, 180.0 / 255.0, 180.0 / 255.0, 0);

            for (float i = -size * 2; i <= size * 2; i += 0.5f)
            {
                if (i != 0)
                {
                    gl.Vertex(-size * 2, 0, i); gl.Vertex(size * 2, 0, i);
                    gl.Vertex(i, 0, -size * 2); gl.Vertex(i, 0, size * 2);
                }
            }
            gl.End();
        }
Ejemplo n.º 26
0
        int[] betValue = new int[3];                           //betvalue for betters
        public MainForm()
        {
            InitializeComponent();

            hdc = (uint)this.Handle;
            string error = "";

            OpenGLControl.OpenGLInit(ref hdc, this.Width, this.Height, ref error);

            control.Camara.SetPerspective();
            if (error != "")
            {
                MessageBox.Show("an error occurred ");
                this.Close();
            }


            //float[] lightAmbient = { 0.15F, 0.15F, 0.15F, 0.0F };

            //Lighting.LightAmbient = lightAmbient;

            Lighting.SetupLighting();

            ContentManager.SetTextureList("texturas\\");
            ContentManager.LoadTextures();
            ContentManager.SetModelList("modelos\\");
            ContentManager.LoadModels();
            control.CreateObjects();

            //Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE);
        }
Ejemplo n.º 27
0
        public override void Draw(OpenGLControl glControl)
        {
            var upRight = new Point(downRight.X, upLeft.Y);

            base.Draw(glControl);
            int angle;
            var gl = glControl.OpenGL;

            gl.PushMatrix();
            DrawALineWithAngle(glControl, 0, upLeft, upLeft, upRight);
            if ((downRight.Y < upLeft.Y && downRight.X > upLeft.X) || (downRight.Y > upLeft.Y && downRight.X < upLeft.X))
            {
                angle = 120;
            }
            else
            {
                angle = -120;
            }
            DrawALineWithAngle(glControl, angle, upLeft, upLeft, upRight);
            DrawALineWithAngle(glControl, angle, upRight, upLeft, upRight);
            DrawALineWithAngle(glControl, angle, upLeft, upLeft, upRight);
            DrawALineWithAngle(glControl, angle, upRight, upLeft, upRight);
            DrawALineWithAngle(glControl, angle, upLeft, upLeft, upRight);
            gl.PopMatrix();
            if (veDdk == true)
            {
                DrawControlPoint(glControl);
            }
        }
Ejemplo n.º 28
0
        void InitScene()
        {
            hdc = (uint)pnlViewPort.Handle;
            string error = "";

            OpenGLControl.OpenGLInit(ref hdc, pnlViewPort.Width, pnlViewPort.Height, ref error);


            if (error != "")
            {
                MessageBox.Show(error);
            }

            scene.Camera.InitCamera();

            float[] materialAmbient      = { 0.5F, 0.5F, 0.5F, 1.0F };
            float[] materialDiffuse      = { 1f, 1f, 1f, 1.0f };
            float[] materialShininess    = { 10.0F };                     // brillo
            float[] ambientLightPosition = { 0F, 0F, 0F, 1.0F };          // posicion
            float[] lightAmbient         = { 0.85F, 0.85F, 0.85F, 0.0F }; // intensidad de la luz

            Lighting.MaterialAmbient      = materialAmbient;
            Lighting.MaterialDiffuse      = materialDiffuse;
            Lighting.MaterialShininess    = materialShininess;
            Lighting.AmbientLightPosition = ambientLightPosition;
            Lighting.LightAmbient         = lightAmbient;

            Lighting.SetupLighting();

            ContentManager.SetTextureList("texturas\\");
            ContentManager.LoadTextures();
            scene.CreateScene();
            Gl.glClearColor(0, 0, 0, 1);//red green blue alpha
        }
Ejemplo n.º 29
0
        public override void DrawControlPoint(OpenGLControl glControl, Color?color = null)
        {
            Color choose  = color ?? Color.Red;
            var   upRight = new Point(downRight.X, upLeft.Y);
            int   angle;
            var   gl = glControl.OpenGL;

            gl.Color(choose.R / 255.0, choose.G / 255.0, choose.B / 255.0);
            gl.PointSize(5f);
            gl.PushMatrix();
            DrawPointWithAngle(glControl, 0, upLeft, upRight);
            if ((downRight.Y < upLeft.Y && downRight.X > upLeft.X) || (downRight.Y > upLeft.Y && downRight.X < upLeft.X))
            {
                angle = 120;
            }
            else
            {
                angle = -120;
            }
            DrawPointWithAngle(glControl, angle, upLeft, upLeft);
            DrawPointWithAngle(glControl, angle, upRight, upRight);
            DrawPointWithAngle(glControl, angle, upLeft, upLeft);
            DrawPointWithAngle(glControl, angle, upRight, upRight);
            DrawPointWithAngle(glControl, angle, upLeft, upLeft);
            gl.PopMatrix();
        }
Ejemplo n.º 30
0
        /*
         * Draw Control Points
         */

        public override void drawControlPoints(OpenGLControl gLControl)
        {
            /*Create a list control point contains 8 control points:
             * 4 points in 4 angles and 4 points in mid of lines cover shape
             */

            list_control_points = new List <Point>();

            list_control_points.Add(new Point(firstPoint.X, gLControl.Height - firstPoint.Y));
            list_control_points.Add(new Point(secondPoint.X, gLControl.Height - secondPoint.Y));

            var glCtrl = gLControl.OpenGL;

            //size control point
            glCtrl.PointSize(5f);

            //color
            Color clr = Color.Red;

            glCtrl.Color(clr.R / 255.0, clr.G / 255.0, clr.B / 255.0);

            //draw
            glCtrl.Begin(OpenGL.GL_POINTS);

            foreach (var lst in list_control_points)
            {
                glCtrl.Vertex((double)lst.X, lst.Y);
            }
            //list_control_points.ForEach(lst => glCtrl.Vertex(lst.X, lst.Y));
            glCtrl.End();

            glCtrl.Flush();
        }
        private static void InitView(OpenGLControl control, OpenGL gl)
        {
            gl.MatrixMode(MatrixMode.Projection);
            gl.LoadIdentity();
            gl.Ortho(0, control.ActualWidth, control.ActualHeight, 0, -10, 10);

            gl.MatrixMode(MatrixMode.Modelview);
        }
Ejemplo n.º 32
0
        public Renderer(OpenGLControl _renderer)
        {
            m_renderer = _renderer;

            m_renderer.OpenGLInitialized += Initialized;
            m_renderer.OpenGLDraw += Draw;
            m_renderer.Resized += Resized;
            m_renderer.DrawFPS = true;
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.SuspendLayout();
            this.components = new System.ComponentModel.Container();
            this.Text = "Form1";

            _openGLControl = App.Init(800, 600, false, this, "EBIN GAEM ENGINEER!!11one"); // Initializing the Form and OpenGL
           
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            //this.ClientSize = new System.Drawing.Size(300, 300);
            this.Controls.Add(this._openGLControl);
            this.ResumeLayout(false);
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Initializes and defines the OpenGLControl object needed to start the application
        /// </summary>
        /// <returns></returns>
        public static OpenGLControl Init(int Width, int Height, bool Fullscreen, Form1 F, string ProjectName = "GameEngine")
        {
            // Form1 Initialization

            // Set the global screen size
            Screen.Width = Width;
            Screen.Height = Height;

            F.Name = ProjectName;
            F.Text = ProjectName;

            if (Fullscreen == true)
            {
                F.FormBorderStyle = FormBorderStyle.None;
                F.WindowState = FormWindowState.Maximized;
            }
            else
            {
                F.ClientSize = new Size(Screen.Width, Screen.Height);
            }

            // OpenGL Initialization
            OpenGLControl _openGLControl = new OpenGLControl();
            _openGLControl.AccumBits = ((byte)(0));
            _openGLControl.AutoCheckErrors = false;
            _openGLControl.AutoFinish = false;
            _openGLControl.AutoMakeCurrent = false;
            _openGLControl.AutoSwapBuffers = true;
            _openGLControl.BackColor = System.Drawing.Color.Black;
            _openGLControl.ColorBits = ((byte)(32));
            _openGLControl.DepthBits = ((byte)(16));
            _openGLControl.Dock = System.Windows.Forms.DockStyle.Fill;
            _openGLControl.Location = new System.Drawing.Point(0, 0);
            _openGLControl.Name = "OpenGlControl";
            _openGLControl.Size = new System.Drawing.Size(Screen.Width, Screen.Height);
            _openGLControl.StencilBits = ((byte)(0));
            _openGLControl.TabIndex = 0;
            return _openGLControl;
        }
 public static void SetRender(OpenGLControl obj, IEnumerable<MarbleDiagram> value)
 {
     obj.SetValue(RenderProperty, value);
 }
 public static IEnumerable<MarbleDiagram> GetRender(OpenGLControl obj)
 {
     return (IEnumerable<MarbleDiagram>)obj.GetValue(RenderProperty);
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Initializes and defines the OpenGLControl object needed to start the application
 /// </summary>
 /// <param name="name">The given name to the application</param>
 /// <returns></returns>
 public static OpenGLControl Init(string name)
 {
     OpenGLControl _openGLControl = new OpenGLControl();
     _openGLControl.AccumBits = ((byte)(0));
     _openGLControl.AutoCheckErrors = false;
     _openGLControl.AutoFinish = false;
     _openGLControl.AutoMakeCurrent = false;
     _openGLControl.AutoSwapBuffers = true;
     _openGLControl.BackColor = System.Drawing.Color.Black;
     _openGLControl.ColorBits = ((byte)(32));
     _openGLControl.DepthBits = ((byte)(16));
     _openGLControl.Dock = System.Windows.Forms.DockStyle.Fill;
     _openGLControl.Location = new System.Drawing.Point(0, 0);
     _openGLControl.Name = name;
     _openGLControl.Size = new System.Drawing.Size(284, 264);
     _openGLControl.StencilBits = ((byte)(0));
     _openGLControl.TabIndex = 0;
     return _openGLControl;
 }