Beispiel #1
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);
            GL.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.MatrixMode(MatrixMode.Modelview);
            Matrix4 modelView = Matrix4.Identity;

            modelView *= Matrix4.CreateRotationZ(ToRadians(rotZ));
            modelView *= Matrix4.CreateRotationY(ToRadians(rotY));
            modelView *= Matrix4.CreateRotationX(ToRadians(rotX));

            //modelView *= Matrix4.CreateRotationY( ToRadians( 45f ) ); // 35f
            modelView *= Matrix4.CreateRotationX(ToRadians(45f));                 // was 60
            ModelView  = modelView;

            GL.LoadMatrix(ref modelView);
            UpdateCulling();

            //GL.PolygonMode( MaterialFace.FrontAndBack, PolygonMode.Line );
            //GL.Disable( EnableCap.DepthTest );
            RenderTestMap();
            //GL.Enable( EnableCap.DepthTest );
            //GL.PolygonMode( MaterialFace.FrontAndBack, PolygonMode.Fill );


            GL.Color3(1f, 1f, 1f);
            GLUtils.Mode2D(width, height);
            renderer2d.Render();
            //gui.Render();
            GLUtils.Mode3D();

            /*GL.Color3( 1f, 0f, 0f );
             * GL.LineWidth( 3 );
             * GL.Begin( BeginMode.LineStrip );
             *
             * Vector2 mousePos = new Vector2( Mouse.X, Mouse.Y );
             * foreach( var pos in  GLUtils.UnProject( Projection, ModelView, this, mousePos ) ) {
             *      GL.Vertex3( pos.X, pos.Y, pos.Z );
             *      //GL.Vertex3( pos.Pos2.X, pos.Pos2.Y, pos.Pos2.Z );
             *
             * }
             * //GL.Vertex3( pos.X, pos.Y, pos.Z );
             * //GL.Vertex3( pos.X + 1, pos.Y, pos.Z );
             * //GL.Vertex3( pos.X + 1, pos.Y, pos.Z + 1 );
             * //GL.Vertex3( pos.X, pos.Y, pos.Z + 1 );
             * GL.End();*/

            GL.Color3(1f, 1f, 1f);

            UpdateTitleFps(e);
            SwapBuffers();
        }
Beispiel #2
0
        public void RenderBarracks()
        {
            if (keepId == -1)
            {
                keepData     = Make2DTexture(new Bitmap("5b.bmp"), 0, 0);
                barracksData = Make2DTexture(new Bitmap("5.bmp"), 0, 0);
                keep2Data    = Make2DTexture(new Bitmap("13.bmp"), 0, 0);
                keepId       = keepData.ID;
                barracksId   = barracksData.ID;
                keep2Id      = keep2Data.ID;
            }

            Mode2D();
            GL.Enable(EnableCap.Texture2D);
            GL.Disable(EnableCap.DepthTest);

            GL.BindTexture(TextureTarget.Texture2D, keepId);
            Texture texture = keepData;

            GL.Begin(BeginMode.Quads);
            RenderSprite(texture.X1, texture.Y1, texture.Width, texture.Height);
            //RenderSprite( texture.X1 + 2, texture.Y1, texture.Width, texture.Height );
            GL.End();

            //GL.BindTexture( TextureTarget.Texture2D, barracksId );
            //texture = barracksData;
            //GL.Begin( BeginMode.Quads );
            //RenderSprite( texture.X1, texture.Y1, texture.Width, texture.Height );
            //GL.End();

            GL.BindTexture(TextureTarget.Texture2D, keep2Id);
            texture = keep2Data;
            GL.Begin(BeginMode.Quads);
            RenderSprite(texture.X1 + 2, texture.Y1, texture.Width, texture.Height);
            GL.End();

            GL.Enable(EnableCap.DepthTest);
            GL.Disable(EnableCap.Texture2D);

            GLUtils.Mode3D();

            /*const float horSize = 3, verSize = 2f;
             * float height = -1.5f;
             * float x1 = 0, y1 = 0,
             * x2 = horSize, y2 = 0,
             * x3 = horSize, y3 = verSize,
             * x4 = 0, y4 = verSize;
             *
             *
             * GL.Disable( EnableCap.DepthTest );
             * TranslatePoint( ref x1, ref y1 );
             * TranslatePoint( ref x2, ref y2 );
             * TranslatePoint( ref x3, ref y3 );
             * TranslatePoint( ref x4, ref y4 );
             *
             * GL.PolygonMode( MaterialFace.FrontAndBack, PolygonMode.Line );
             * GL.Begin( BeginMode.Quads );
             * GL.Vertex3( x1, height + 1, y1 );
             * GL.Vertex3( x2, height + 1, y2 );
             * GL.Vertex3( x3, height + 1, y3 );
             * GL.Vertex3( x4, height + 1, y4 );
             * GL.End();
             * GL.PolygonMode( MaterialFace.FrontAndBack, PolygonMode.Fill );
             * GL.Enable( EnableCap.DepthTest );*/
        }