Пример #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            gl3dcontroller = new Controller3D();
            gl3dcontroller.PaintObjects = ControllerDraw;
            gl3dcontroller.ZoomDistance = 100F;
            gl3dcontroller.MatrixCalc.PerspectiveNearZDistance = 0.1f;
            gl3dcontroller.Start(glwfc, new Vector3(0, 0, 0), new Vector3(110f, 0, 0f), 1F);

            gl3dcontroller.KeyboardTravelSpeed = (ms, eyedist) =>
            {
                return((float)ms / 20.0f);
            };

            {
                items.Add(new GLColorShaderWorld(), "COS");
                GLRenderState rl = GLRenderState.Lines(1);

                rObjects.Add(items.Shader("COS"), GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, rl,
                                                                                       GLShapeObjectFactory.CreateBox(400, 200, 40, new Vector3(0, 0, 0), new Vector3(0, 0, 0)),
                                                                                       new Color4[] { Color.Red, Color.Red, Color.Green, Color.Green }));
            }

            {
                items.Add(new GLTexturedShaderObjectTranslation(), "TEX");

                using (var bmp = BitMapHelpers.DrawTextIntoAutoSizedBitmap("200,100", new Size(200, 100), new Font("Arial", 10.0f), System.Drawing.Text.TextRenderingHint.ClearTypeGridFit, Color.Yellow, Color.Blue))
                {
                    items.Add(new GLTexture2D(bmp, SizedInternalFormat.Rgba8), "200,100");
                }

                using (var bmp = GLOFC.Utils.BitMapHelpers.DrawTextIntoAutoSizedBitmap("-200,-100", new Size(200, 100), new Font("Arial", 10.0f), System.Drawing.Text.TextRenderingHint.ClearTypeGridFit, Color.Yellow, Color.Blue))
                {
                    items.Add(new GLTexture2D(bmp, SizedInternalFormat.Rgba8), "-200,-100");
                }

                GLRenderState rq = GLRenderState.Quads();

                rObjects.Add(items.Shader("TEX"), GLRenderableItem.CreateVector4Vector2(items, PrimitiveType.Quads, rq,
                                                                                        GLShapeObjectFactory.CreateQuad(20.0f, 20.0f, new Vector3(-90f.Radians(), 0, 0)), GLShapeObjectFactory.TexQuadCW,
                                                                                        new GLRenderDataTranslationRotationTexture(items.Tex("200,100"), new Vector3(200, 0, 100))));

                rObjects.Add(items.Shader("TEX"), GLRenderableItem.CreateVector4Vector2(items, PrimitiveType.Quads, rq,
                                                                                        GLShapeObjectFactory.CreateQuad(20.0f, 20.0f, new Vector3(-90f.Radians(), 0, 0)), GLShapeObjectFactory.TexQuadCW,
                                                                                        new GLRenderDataTranslationRotationTexture(items.Tex("-200,-100"), new Vector3(-200, 0, -100))));
            }

            {
                items.Add(new GLStarPoints(), "STARS");

                Vector3[] stars = GLPointsFactory.RandomStars(10000, -200, 200, -100, 100, 20, -20);

                GLRenderState rp = GLRenderState.PointsByProgram();

                rObjects.Add(items.Shader("STARS"), "Stars", GLRenderableItem.CreateVector3Packed2(items, PrimitiveType.Points, rp,
                                                                                                   stars, new Vector3(50000, 50000, 50000), 16));
            }


            items.Add(new GLMatrixCalcUniformBlock(), "MCUB");      // def binding of 0

            Closed += ShaderTest_Closed;
        }