예제 #1
0
        public Terreno()
        {
            cantidadDeVertices = GetVertices().Length / 5;
            cantidadDeIndices  = GetIndices().Length;

            bufferDeVertices = new VerticesBuffer(GetVertices(), GetVertices().Length *sizeof(float));
            bufferDeIndices  = new IndicesBuffer(GetIndices(), GetIndices().Length);

            shader = new Shader("d:/ginno/documents/visual studio 2017/Projects/Tarea1Grafica/Tarea1Grafica/shader/shader.vert", "d:/ginno/documents/visual studio 2017/Projects/Tarea1Grafica/Tarea1Grafica/shader/shader.frag");
            shader.use();

            textura = new Textura("d:/ginno/Documents/Visual Studio 2017/Projects/Tarea1Grafica/Tarea1Grafica/Recursos/cesped.jpg");
            textura.Use();

            //Creamos el VertexArrayObject (VAO)
            arregloDeVertices = new VerticesArreglo();
            //GL.BindVertexArray(arregloDeVertices);
            arregloDeVertices.enlazar();

            //Enlazamos de nuevo los buffers
            //GL.BindBuffer(BufferTarget.ArrayBuffer, bufferDeVertices.);
            bufferDeVertices.enlazar();
            //
            //GL.BindBuffer(BufferTarget.ElementArrayBuffer, bufferDeElementosIndices);
            bufferDeIndices.enlazar();

            arregloDeVertices.añadirBuffer(bufferDeVertices, shader);

            //Al inicializarse, se calcula aqui la matriz modelo
            CalcularMatrizModelo();
        }
예제 #2
0
        public void añadirBuffer(VerticesBuffer verticeBuffer, Shader shader)
        {
            enlazar();
            verticeBuffer.enlazar();

            var locacionVertice = shader.GetAttribLocation("aPosition");

            GL.EnableVertexAttribArray(locacionVertice);
            GL.VertexAttribPointer(locacionVertice, 3, VertexAttribPointerType.Float, false, 5 * sizeof(float), 0);

            int locacionTexCoord = shader.GetAttribLocation("aTexCoord");

            GL.EnableVertexAttribArray(locacionTexCoord);
            GL.VertexAttribPointer(locacionTexCoord, 2, VertexAttribPointerType.Float, false, 5 * sizeof(float), 3 * sizeof(float));
        }
예제 #3
0
        public Piramide()
        {
            cantidadDeVertices = 5;
            cantidadDeIndices  = 18;

            bufferDeVertices = new VerticesBuffer(GetVertices(), GetVertices().Length *sizeof(float));
            bufferDeIndices  = new IndicesBuffer(GetIndices(), GetIndices().Length);

            shader = new Shader("d:/ginno/documents/visual studio 2017/Projects/Tarea1Grafica/Tarea1Grafica/shader/shader.vert", "d:/ginno/documents/visual studio 2017/Projects/Tarea1Grafica/Tarea1Grafica/shader/shader.frag");
            shader.use();

            textura = new Textura("d:/ginno/Documents/Visual Studio 2017/Projects/Tarea1Grafica/Tarea1Grafica/Recursos/cesped.jpg");
            textura.Use();

            arregloDeVertices = new VerticesArreglo();
            arregloDeVertices.enlazar();
            bufferDeVertices.enlazar();
            bufferDeIndices.enlazar();

            arregloDeVertices.añadirBuffer(bufferDeVertices, shader);

            CalcularMatrizModelo();
        }