Ejemplo n.º 1
0
        public static void DisposeModel(RawModel model)
        {
            foreach (var vbo in model.vboIDs)
            {
                GL.DeleteBuffer(vbo);
            }

            for (int i = 0; i < vaos.Count; i++)
            {
                if (model.vaoID == vaos[i])
                {
                    GL.DeleteVertexArray(model.vaoID);
                    vaos.RemoveAt(i);
                    break;
                }
            }

            for (int i = 0; i < vbos.Count; i++)
            {
                for (int x = 0; x < model.vboIDs.Count; x++)
                {
                    if (model.vboIDs[x] == vbos[i])
                    {
                        vbos.RemoveAt(i);
                        i--;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static RawModel LoadToVAO(LoaderVertex vertexData, string vertexName)
        {
            if (rawModelTable.TryGetValue(vertexName, out var rawModel))
            {
                return(rawModel);
            }

            int        vaoID  = CreateVAO();
            List <int> vboIDs = new List <int>();

            BindIndicesBuffer(vertexData.indices);
            vboIDs.Add(FloatsToAttribute(0, 3, vertexData.positions));
            vboIDs.Add(FloatsToAttribute(1, 2, vertexData.textureCoords));
            vboIDs.Add(FloatsToAttribute(2, 3, vertexData.normals));

            UnbindVAO();

            var model = new RawModel(vaoID, vertexData.indices.Length, vboIDs, vertexData, vertexName);

            rawModelTable.Add(vertexName, model);

            return(model);
        }
Ejemplo n.º 3
0
 public TexturedModel(RawModel model, Texture tex)
 {
     rawModel = model;
     texture  = tex;
 }