示例#1
0
        public void Render(TexturedModel texturedModel)
        {
            GL.Enable(EnableCap.Texture2D);
            RawModel model = texturedModel.GetRawModel();

            GL.BindVertexArray(model.GetVaoID());

            GL.EnableVertexAttribArray(0);
            GL.EnableVertexAttribArray(1);
            GL.ActiveTexture(TextureUnit.Texture0);

            GL.BindTexture(TextureTarget.Texture2D, texturedModel.GetTexture().GetID());

            GL.DrawElements(BeginMode.Triangles, model.GetVertexCount(), DrawElementsType.UnsignedInt, 0);
            GL.DisableVertexAttribArray(0);
            GL.DisableVertexAttribArray(1);
            GL.BindVertexArray(0);
            GL.Disable(EnableCap.Texture2D);
        }
示例#2
0
        void Window_Load(Object sender, EventArgs e)
        {
            loader   = new Loader();
            renderer = new Renderer();

            shader = new StaticShader();


            float[] vertices =
            {
                -0.5f,  0.5f, 0, //V0
                -0.5f, -0.5f, 0, //V1
                0.5f,  -0.5f, 0, //V2
                0.5f,   0.5f, 0  //V3
            };

            int[] indices =
            {
                0, 1, 3,        //Top left triangle (V0,V1,V3)
                3, 1, 2         //Bottom right triangle (V3,V1,V2)
            };

            float[] textureCoords =
            {
                0, 0,       // V0
                0, 1,       //V1
                1, 1,       //V2
                1, 0        //V3
            };


            RawModel model = loader.LoadToVAO(vertices, textureCoords, indices);

            GL.ActiveTexture(TextureUnit.Texture0);
            ModelTexture texture = new ModelTexture(loader.LoadTexture("image"));

            texturedModel = new TexturedModel(model, texture);


            //Console.WriteLine(GL.GetError());
        }
 public TexturedModel(RawModel model, ModelTexture textures)
 {
     this.rawModel = model;
     this.texture  = textures;
 }