Beispiel #1
0
        protected void startup()
        {
            // Set up the graphics system
            graphics = new GraphicsContext();
            graphics.SetViewport(0, 0, graphics.Screen.Width, graphics.Screen.Height);
            graphics.SetClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            graphics.Enable(EnableMode.Blend);
            graphics.SetBlendFunc(BlendFuncMode.Add, BlendFuncFactor.SrcAlpha, BlendFuncFactor.OneMinusSrcAlpha);

            program = new ShaderProgram("/Application/shaders/Simple.cgx");

            program.SetUniformBinding(0, "WorldViewProj");
            program.SetAttributeBinding(0, "a_Position");
            program.SetAttributeBinding(1, "a_TexCoord");
            program.SetAttributeBinding(2, "a_Color");

            Matrix4 unitScreenMatrix = new Matrix4(
                 2.0f / graphics.Screen.Width, 0.0f, 0.0f, 0.0f,
                 0.0f, -2.0f / graphics.Screen.Height,  0.0f, 0.0f,
                 0.0f, 0.0f, 1.0f, 0.0f,
                 -1.0f, 1.0f, 0.0f, 1.0f
            );

            program.SetUniformValue(0, ref unitScreenMatrix);

            videoBuffer = new byte[VIDEO_WIDTH * VIDEO_HEIGHT * 4];

            texture = new Texture2D(512, 512, false, PixelFormat.Rgba);
            texture.SetFilter(VIDEO_FILTER ? TextureFilterMode.Linear : TextureFilterMode.Nearest);

            float tx = (float) VIDEO_WIDTH / (float) texture.Width;
            float ty = (float) VIDEO_HEIGHT / (float) texture.Height;

            screenTexcoords = new float[] {
                0.0f, 0.0f, // 0 top left.
                0.0f, ty, // 1 bottom left.
                tx, 0.0f, // 2 top right.
                tx, ty, // 3 bottom right.
            };

            defaultTexcoords = new float[] {
                0.0f, 0.0f, // 0 top left.
                0.0f, 1.0f, // 1 bottom left.
                1.0f, 0.0f, // 2 top right.
                1.0f, 1.0f, // 3 bottom right.
            };

            colors = new float[] {
                1.0f,   1.0f,   1.0f,   1.0f,   // 0 top left.
                1.0f,   1.0f,   1.0f,   1.0f,   // 1 bottom left.
                1.0f,   1.0f,   1.0f,   1.0f,   // 2 top right.
                1.0f,   1.0f,   1.0f,   1.0f,   // 3 bottom right.
            };

            vertexCount = vertices.Length / 3;

            vertexBuffer = new VertexBuffer(vertexCount,
                                            VertexFormat.Float3,
                                            VertexFormat.Float2,
                                            VertexFormat.Float4);

            //vertexBuffer.SetVertices(0, vertices);
            //vertexBuffer.SetVertices(1, texcoords);
            //vertexBuffer.SetVertices(2, colors);

            /////

            int fontSize = 14;

            normalFont = new Font(FontAlias.System, fontSize, FontStyle.Regular);

            /////

            emu = new EmulatorApplication(this);
            emu.initialize();

            statistics = new Statistics();
        }
Beispiel #2
0
 protected void startup()
 {
     statistics = new Statistics();
 }