Ejemplo n.º 1
0
 protected void LoadToUniform(int location, Matrix4 value)
 {
     GL.UniformMatrix4(location, false, ref value);
 }
Ejemplo n.º 2
0
 public new void Active(Color4 color, Matrix4 vpMatrix)
 {
     Active(color, vpMatrix, _texCoordBuffer);
 }
Ejemplo n.º 3
0
        public void LoadViewMatrix(Camera camera)
        {
            Matrix4 viewMatrix = Util.CreateViewMatrix(camera);

            LoadToUniform(handleViewMatrix, viewMatrix);
        }
Ejemplo n.º 4
0
 public void LoadProjectionMatrix(Matrix4 value)
 {
     LoadToUniform(handleProjectionMatrix, value);
 }
Ejemplo n.º 5
0
 public void LoadTransformationMatrix(Matrix4 value)
 {
     LoadToUniform(handleTransformationMatrix, value);
 }
Ejemplo n.º 6
0
        public Screen(int width, int height, string title) : base(width, height, GraphicsMode.Default, title)
        {
            Children = new ArrayList();

            projection = Matrix4.CreateOrthographicOffCenter(0.0f, width, 0.0f, height, 0.1f, 100.0f);
        }
Ejemplo n.º 7
0
        public void OnLoad()
        {
            // create and fill a vertex buffer
            this.vertexBuffer = new VertexBuffer <ColouredVertex>(ColouredVertex.Size);

            this.vertexBuffer.AddVertex(new ColouredVertex(new Vector3(-1, -1, -1.5f), Color4.Lime));
            this.vertexBuffer.AddVertex(new ColouredVertex(new Vector3(1, 1, -1.5f), Color4.Red));
            this.vertexBuffer.AddVertex(new ColouredVertex(new Vector3(1, -1, -1.5f), Color4.Blue));



            // load shaders
            #region Shaders

            var vertexShader = new Shader(ShaderType.VertexShader,
                                          @"#version 130

// a projection transformation to apply to the vertex' position
uniform mat4 projectionMatrix;

// attributes of our vertex
in vec3 vPosition;
in vec4 vColor;

out vec4 fColor; // must match name in fragment shader

void main()
{
    // gl_Position is a special variable of OpenGL that must be set
	gl_Position = projectionMatrix * vec4(vPosition, 1.0);
	fColor = vColor;
}"
                                          );
            var fragmentShader = new Shader(ShaderType.FragmentShader,
                                            @"#version 130

in vec4 fColor; // must match name in vertex shader

out vec4 fragColor; // first out variable is automatically written to the screen

void main()
{
    fragColor = fColor;
}"
                                            );

            #endregion

            // link shaders into shader program
            this.shaderProgram = new ShaderProgram(vertexShader, fragmentShader);



            // create vertex array to specify vertex layout
            this.vertexArray = new VertexArray <ColouredVertex>(
                this.vertexBuffer, shaderProgram,
                new VertexAttribute("vPosition", 3, VertexAttribPointerType.Float, ColouredVertex.Size, 0),
                new VertexAttribute("vColor", 4, VertexAttribPointerType.Float, ColouredVertex.Size, 12)
                );

            // create projection matrix uniform
            this.projectionMatrix        = new Matrix4Uniform("projectionMatrix");
            this.projectionMatrix.Matrix = Matrix4.CreatePerspectiveFieldOfView(
                MathHelper.PiOver2, 16f / 9, 0.1f, 100f);



            Player = new Player();



            Player.OutPutPlayerValuesToDebugger();
            //This is where you load all of your content
            //Images, Models, Fonts, Sounds.
        }