Example #1
0
        private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs args)
        {
            OpenGL gl = openGLControl1.OpenGL;

            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);


            gl.LoadIdentity();

            gl.MatrixMode(OpenGL.GL_PROJECTION);
            gl.Perspective(cameraAngle, openGLControl1.Width / openGLControl1.Height, 1.0, 100.0);

            gl.LookAt(cameraPosition[0], cameraPosition[1], cameraPosition[2],
                      viewPosition[0], viewPosition[1], viewPosition[2],
                      0, 0, 1);

            SceneGrid gid = new SceneGrid(GridSize);

            gid.drawSceneGrid(gl);

            //draw all added geometries
            drawGeometries(gl);

            gl.Flush();
        }
Example #2
0
        private void openGLControl1_Resized(object sender, EventArgs e)
        {
            OpenGL gl = openGLControl1.OpenGL;

            //set ma tran viewport
            gl.Viewport(
                0, 0,
                openGLControl1.Width,
                openGLControl1.Height);

            gl.LoadIdentity();

            //set ma tran phep chieu
            gl.MatrixMode(OpenGL.GL_PROJECTION);
            gl.Perspective(cameraAngle,
                           openGLControl1.Width / openGLControl1.Height,
                           1.0, 100.0);

            //set ma tran model view
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.LookAt(cameraPosition[0], cameraPosition[1], cameraPosition[2],
                      viewPosition[0], viewPosition[1], viewPosition[2],
                      0, 0, 1);
        }