Ejemplo n.º 1
0
        private void OpenGLControl_Resized(object sender, OpenGLEventArgs args)
        {
            //  Get the OpenGL instance.
            var gl = args.OpenGL;

            //  Project.
            gl.MatrixMode(MatrixMode.Projection);
            gl.LoadIdentity();
            camera.TransformProjectionMatrix(args.OpenGL);
            gl.MatrixMode(MatrixMode.Modelview);

            modelView  = gl.GetModelViewMatrix();
            projection = gl.GetProjectionMatrix();
            //  TODO: this should be to mat3
            normalMatrix = new Matrix(gl.GetModelViewMatrix());
            normalMatrix.FromOtherMatrix(gl.GetModelViewMatrix(), 3, 3);

            return;

            time += elapsedMilliseconds;
            if (time > InitialPause && (LoopForever || theta < 360))
            {
                theta += elapsedMilliseconds * 0.1f;
            }

            /*
             * mat4 rotation = mat4::Rotate(theta, vec3(0, 1, 0));
             * mat4 translation = mat4::Translate(0, 0, -7);
             *
             * rc.Modelview = rotation * translation;
             * rc.NormalMatrix = rc.Modelview.ToMat3();
             *
             * rc.Projection = mat4::Frustum(-S, S, -H, H, 4, 10);
             */
            float S = 0.46f;
            float H = S * (float)openGlCtrl.ActualHeight / (float)openGlCtrl.ActualWidth;

            args.OpenGL.MatrixMode(MatrixMode.Projection);
            args.OpenGL.LoadIdentity();
            args.OpenGL.Frustum(-S, S, -H, H, 4, 10);
            args.OpenGL.MatrixMode(MatrixMode.Modelview);
        }
Ejemplo n.º 2
0
        private void OpenGLControl_Resized(object sender, OpenGLEventArgs args)
        {
            //  Get the OpenGL instance.
            var gl = args.OpenGL;

            //  Project.
            gl.MatrixMode(MatrixMode.Projection);
            gl.LoadIdentity();
            camera.TransformProjectionMatrix(args.OpenGL);
            gl.MatrixMode(MatrixMode.Modelview);

            modelView = gl.GetModelViewMatrix();
            projection = gl.GetProjectionMatrix();
            //  TODO: this should be to mat3
            normalMatrix = new Matrix(gl.GetModelViewMatrix());
            normalMatrix.FromOtherMatrix(gl.GetModelViewMatrix(), 3, 3);

            return;

    time += elapsedMilliseconds;
    if (time > InitialPause && (LoopForever || theta < 360))
    {
        theta += elapsedMilliseconds * 0.1f;
    }
            /*
    mat4 rotation = mat4::Rotate(theta, vec3(0, 1, 0));
    mat4 translation = mat4::Translate(0, 0, -7);

    rc.Modelview = rotation * translation;
    rc.NormalMatrix = rc.Modelview.ToMat3();

    rc.Projection = mat4::Frustum(-S, S, -H, H, 4, 10);
            */
    float S = 0.46f;
    float H = S * (float)openGlCtrl.ActualHeight / (float)openGlCtrl.ActualWidth;

            args.OpenGL.MatrixMode(MatrixMode.Projection);
            args.OpenGL.LoadIdentity();
            args.OpenGL.Frustum(-S, S, -H, H, 4, 10);
            args.OpenGL.MatrixMode(MatrixMode.Modelview);
        }