private VertexArrayObject AllocateVaoMemory(string path) { VertexArrayObject vao = null; using (AssimpModelLoader loader = new AssimpModelLoader(path)) { MeshVertexData meshData = loader.GetMeshData(); VertexBufferObjectTwoDimension <float> verticesVBO = new VertexBufferObjectTwoDimension <float>(meshData.Verts, BufferTarget.ArrayBuffer, 0, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate); VertexBufferObjectTwoDimension <float> normalsVBO = new VertexBufferObjectTwoDimension <float>(meshData.N_Verts, BufferTarget.ArrayBuffer, 1, 3, VertexBufferObjectBase.DataCarryFlag.Invalidate); VertexBufferObjectTwoDimension <float> texCoordsVBO = new VertexBufferObjectTwoDimension <float>(meshData.T_Verts, BufferTarget.ArrayBuffer, 2, 2, VertexBufferObjectBase.DataCarryFlag.Invalidate); var transformationVboTuples = PlantUserAttributeBuilder.GetInstacedTransformationBuffer(_plants, INIT_BUFFER_SIZE); var windVBO = PlantUserAttributeBuilder.GetInstancedWindBuffer(_plants, INIT_BUFFER_SIZE); var samplerVBO = PlantUserAttributeBuilder.GetInstanceSamplerBuffer(_plants, INIT_BUFFER_SIZE); vao = new VertexArrayObject(); vao.AddVBO(verticesVBO, normalsVBO, texCoordsVBO, transformationVboTuples.Item1.Item1, transformationVboTuples.Item1.Item2, transformationVboTuples.Item2.Item1, transformationVboTuples.Item2.Item2, windVBO, samplerVBO); vao.BindBuffersToVao(); } return(vao); }
private void postConstructor(Landscape terrain = null) { if (this._postConstructor) { AlignPlantsToTerrain(terrain); this._attribs = PlantUserAttributeBuilder.BuildReadyUserAttributeBuffer(_plants, _attribs); _buffer = new VAO(_attribs); VAOManager.genVAO(_buffer); VAOManager.setBufferData(BufferTarget.ArrayBuffer, _buffer); _shader = PoolProxy.GetResource <ObtainShaderPool, ShaderAllocationPolicy <PlantShader>, string, PlantShader>(ProjectFolders.ShadersPath + "plantVertexShader.glsl" + "," + ProjectFolders.ShadersPath + "plantFragmentShader.glsl"); this._postConstructor = !this._postConstructor; } }