public GuiLayer(Window w, GlProgram pgm, IVertexCoder <GuiVertex> coder, Font fnt) { _win = w ?? throw new ArgumentNullException(nameof(w)); _pgm = pgm ?? throw new ArgumentNullException(nameof(pgm)); _array = new VertexArray <GuiVertex>(coder, 4) { [0] = new GuiVertex(new Vector2(0, 0), new Vector2(0, 1)), [1] = new GuiVertex(new Vector2(1, 0), new Vector2(1, 1)), [2] = new GuiVertex(new Vector2(1, 1), new Vector2(1, 0)), [3] = new GuiVertex(new Vector2(0, 1), new Vector2(0, 0)) }; _indices = new IndexBuffer(6, _array) { [0] = 0, [1] = 1, [2] = 2, [3] = 0, [4] = 2, [5] = 3, }; _font = fnt ?? throw new ArgumentNullException(nameof(fnt)); _uColor = pgm.GetUniform("uColor"); _uColor.EnsureType(new ShaderElementType(PrimitiveTypes.Float, 4)); _uTexture = pgm.GetUniform("uTexture"); _uTexture.EnsureType(new ShaderElementType(PrimitiveTypes.Sampler, 2)); _uTextureEnabled = pgm.GetUniform("uTextureEnabled"); _uTextureEnabled.EnsureType(new ShaderElementType(PrimitiveTypes.Bool, 1)); _uTransform = pgm.GetUniform("uTransform"); _uTransform.EnsureType(new ShaderElementType(PrimitiveTypes.Matrix, 4)); _uScale = pgm.GetUniform("uScale"); _uScale.EnsureType(new ShaderElementType(PrimitiveTypes.Float, 2)); }
public LightUniform(Uniform pos, Uniform col, Uniform its) { _position = pos ?? throw new ArgumentNullException(nameof(pos)); _color = col ?? throw new ArgumentNullException(nameof(col)); _intensity = its ?? throw new ArgumentNullException(nameof(its)); _position.EnsureType(Vec4); _color.EnsureType(Vec3); _intensity.EnsureType(Float); }
public MaterialUniform(Uniform amb, Uniform diff, Uniform col) { _ambient = amb ?? throw new ArgumentNullException(nameof(amb)); _diffusion = diff ?? throw new ArgumentNullException(nameof(diff)); _color = col ?? throw new ArgumentNullException(nameof(col)); _ambient.EnsureType(Float); _diffusion.EnsureType(Float); _color.EnsureType(Vec4); }
public RenderHandle(Window win, GlProgram program) { Window = win ?? throw new ArgumentNullException(nameof(win)); Program = program; _uModel = program.GetUniform(UNIFORM_MODEL); _uView = program.GetUniform(UNIFORM_VIEW); _uProjection = program.GetUniform(UNIFORM_PROJECTION); _uShade = program.GetUniform(UNIFORM_SHADE); _uMaterial = new MaterialUniform(program.GetUniform($"{UNIFORM_MATERIAL}.ambient"), program.GetUniform($"{UNIFORM_MATERIAL}.diffusion"), program.GetUniform($"{UNIFORM_MATERIAL}.color")); _uLightCount = program.GetUniform(UNIFORM_LIGHT_COUNT); for (uint i = 0; i < LIGHT_LIMIT; i++) { _uLight[i] = new LightUniform(program.GetUniform($"{UNIFORM_LIGHT}[{i}].position"), program.GetUniform($"{UNIFORM_LIGHT}[{i}].color"), program.GetUniform($"{UNIFORM_LIGHT}[{i}].intensity")); } _uModel.EnsureType(new ShaderElementType(PrimitiveTypes.Matrix, 4)); _uView.EnsureType(new ShaderElementType(PrimitiveTypes.Matrix, 4)); _uProjection.EnsureType(new ShaderElementType(PrimitiveTypes.Matrix, 4)); _uShade.EnsureType(new ShaderElementType(PrimitiveTypes.Bool, 1)); }