public override void Update(ShaderProgram shader, int i = -1) { string s = String.Format(Name, i); if (shader.GetUniform(s) != -1) { GL.Uniform1(shader.GetUniform(s), Value); } }
public override void Update(ShaderProgram shader, int i = -1) { if (shader.GetAttribute(Name) != -1) { GL.BindBuffer(BufferTarget.ArrayBuffer, shader.GetBuffer(Name)); GL.BufferData<Vector3>(BufferTarget.ArrayBuffer, (IntPtr)(Value.Length * Vector3.SizeInBytes), Value, BufferUsageHint.StaticDraw); GL.VertexAttribPointer(shader.GetAttribute(Name), 3, VertexAttribPointerType.Float, Normalised, 0, 0); } }
public void Render(ShaderProgram shader, Camera camera) { int indiceat = 0; Matrix4 cameraPerspective = camera.PerspectiveMatrix; cameraMatrix.Value = cameraPerspective; cameraMatrix.Update(shader); cameraPosition.Value = camera.Position; cameraPosition.Update(shader); numberOfLights.Value = Lights.Count; numberOfLights.Update(shader); for (int i = 0; i < Lights.Count; i++) { lightIntensity.Value = Lights[i].Data.Intensity; lightIntensity.Update(shader, i); lightColor.Value = Lights[i].Data.Color; lightColor.Update(shader, i); lightPosition.Value = Lights[i].Data.Position; lightPosition.Update(shader, i); lightAttenuation.Value = Lights[i].Data.Attenuation; lightAttenuation.Update(shader, i); lightAmbient.Value = Lights[i].Data.Ambient; lightAmbient.Update(shader, i); lightConeAngle.Value = Lights[i].Data.ConeAngle; lightConeAngle.Update(shader, i); lightConeDirection.Value = Lights[i].Data.ConeDirection; lightConeDirection.Update(shader, i); } foreach (Volume v in ObjectManager.Instance.Objects) { IHasMaterial vMat = v as IHasMaterial; if (vMat != null) { var m = vMat.Material; materialDiffuse.Value = m.DiffuseColor; materialDiffuse.Update(shader); materialDiffuseTexture.Value = m.DiffuseTexture; materialDiffuseTexture.Update(shader); materialSpecular.Value = m.SpecularColor; materialSpecular.Update(shader); materialSpecularExponent.Value = m.SpecularExponent; materialSpecularExponent.Update(shader); } modelMatrix.Value = v.ModelMatrix; modelMatrix.Update(shader); GL.DrawElements(BeginMode.Triangles, v.IndiceCount, DrawElementsType.UnsignedInt, indiceat * sizeof(uint)); indiceat += v.IndiceCount; } }
public void Update(ShaderProgram shader, Camera camera, float time) { foreach (Light l in Lights) { l.Update(time); } List<Vector3> vertices = new List<Vector3>(); List<int> indices = new List<int>(); List<Vector3> colors = new List<Vector3>(); List<Vector2> textureCoords = new List<Vector2>(); List<Vector3> normals = new List<Vector3>(); int verticesCount = 0; foreach (Volume v in Objects) { v.Update(time); v.CalculateModelMatrix(); v.ViewProjectionMatrix = camera.PerspectiveMatrix; v.ModelViewProjectionMatrix = v.ModelMatrix * v.ViewProjectionMatrix; vertices.AddRange(v.GetVertices().ToList()); indices.AddRange(v.GetIndices(verticesCount).ToList()); colors.AddRange(v.GetColorData().ToList()); textureCoords.AddRange(v.GetTextureCoords().ToList()); normals.AddRange(v.GetNormals().ToList()); verticesCount += v.VerticesCount; } attributePositions.Value = vertices.ToArray(); attributePositions.Update(shader); attributeColor.Value = colors.ToArray(); attributeColor.Update(shader); attributeNormals.Value = normals.ToArray(); attributeNormals.Update(shader); attributeTextureCoords.Value = textureCoords.ToArray(); attributeTextureCoords.Update(shader); int[] indicesArray = indices.ToArray(); GL.BindBuffer(BufferTarget.ElementArrayBuffer, iboElements); GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(indicesArray.Length * sizeof(int)), indicesArray, BufferUsageHint.StaticDraw); GL.UseProgram(shader.ProgramID); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); }
public override void Update(ShaderProgram shader, int i = -1) { string s = String.Format(Name, i); if (shader.GetUniform(s) != -1) { GL.UniformMatrix4(shader.GetUniform(s), Transpose, ref Value); } }
public override void Update(ShaderProgram shader, int i = -1) { string s = String.Format(Name, i); if (shader.GetUniform(s) != -1) { GL.ActiveTexture(Value.Unit); GL.BindTexture(TextureTarget.Texture2D, Value.ID); GL.Uniform1(shader.GetUniform(s), Value.Unit - TextureUnit.Texture0); } }
public abstract void Update(ShaderProgram shader, int i = -1);