/// <summary> /// Initializes a new instance of the <see cref="ColoredStaticMesh"/> class. /// </summary> /// <param name="viewProjection">The provider for the view and projection matrices to use when rendering.</param> /// <param name="vertices">The vertices of the mesh.</param> /// <param name="indices">The indices (into the provided vertices) to use for actually rendering the mesh.</param> public ColoredStaticMesh( IViewProjection viewProjection, IEnumerable <Vertex> vertices, IEnumerable <uint> indices) { this.viewProjection = viewProjection; if (program == null && programBuilder == null) { lock (ProgramStateLock) { if (program == null && programBuilder == null) { programBuilder = new GlProgramBuilder() .WithVertexShaderFromEmbeddedResource("Colored.Vertex.glsl") .WithFragmentShaderFromEmbeddedResource("Colored.Fragment.glsl") .WithDefaultUniformBlock <DefaultUniformBlock>() .WithSharedUniformBufferObject <CameraUniformBlock>("Camera", BufferUsageHint.DynamicDraw, 1); } } } this.vertexArrayObjectBuilder = new VertexArrayObjectBuilder(PrimitiveType.Triangles) .WithNewAttributeBuffer(BufferUsageHint.StaticDraw, vertices.ToArray()) .WithNewIndexBuffer(BufferUsageHint.StaticDraw, indices.ToArray()); }
/// <inheritdoc /> public void Load() { ThrowIfDisposed(); if (program == null) { lock (ProgramStateLock) { if (program == null) { program = programBuilder.Build(); programBuilder = null; } } } this.vertexArrayObject = (GlVertexArrayObject <Vertex>) this.vertexArrayObjectBuilder.Build(); this.vertexArrayObjectBuilder = null; }
/// <inheritdoc /> public void Load() { ThrowIfDisposed(); this.textures = new int[1]; this.textures[0] = Path.GetExtension(textureFilePath) == ".DDS" ? TextureLoader.LoadDDS(textureFilePath) : TextureLoader.LoadBMP(textureFilePath); if (program == null) { lock (ProgramStateLock) { if (program == null) { program = programBuilder.Build(); programBuilder = null; } } } this.vertexArrayObject = (GlVertexArrayObject <Vertex>) this.vertexArrayObjectBuilder.Build(); this.vertexArrayObjectBuilder = null; }