public void Indexer() { var v = new bvec4(true, false, true, true); Assert.AreEqual(true, v[0]); Assert.AreEqual(false, v[1]); Assert.AreEqual(true, v[2]); Assert.AreEqual(true, v[3]); Assert.Throws <ArgumentOutOfRangeException>(() => { var s = v[-2147483648]; }); Assert.Throws <ArgumentOutOfRangeException>(() => { v[-2147483648] = false; }); Assert.Throws <ArgumentOutOfRangeException>(() => { var s = v[-1]; }); Assert.Throws <ArgumentOutOfRangeException>(() => { v[-1] = false; }); Assert.Throws <ArgumentOutOfRangeException>(() => { var s = v[4]; }); Assert.Throws <ArgumentOutOfRangeException>(() => { v[4] = false; }); Assert.Throws <ArgumentOutOfRangeException>(() => { var s = v[2147483647]; }); Assert.Throws <ArgumentOutOfRangeException>(() => { v[2147483647] = false; }); Assert.Throws <ArgumentOutOfRangeException>(() => { var s = v[5]; }); Assert.Throws <ArgumentOutOfRangeException>(() => { v[5] = false; }); v[3] = false; Assert.AreEqual(false, v[3]); v[3] = true; Assert.AreEqual(true, v[3]); }
public void PropertyValues() { var v = new bvec4(true, false, true, false); var vals = v.Values; Assert.AreEqual(true, vals[0]); Assert.AreEqual(false, vals[1]); Assert.AreEqual(true, vals[2]); Assert.AreEqual(false, vals[3]); Assert.That(vals.SequenceEqual(v.ToArray())); }
public void SerializationJson() { var v0 = new bvec4(true, true, true, false); var s0 = JsonConvert.SerializeObject(v0); var v1 = JsonConvert.DeserializeObject <bvec4>(s0); var s1 = JsonConvert.SerializeObject(v1); Assert.AreEqual(v0, v1); Assert.AreEqual(s0, s1); }
public void Operators() { var v1 = new bvec4(false, false, true, false); var v2 = new bvec4(false, false, true, false); var v3 = new bvec4(false, true, false, false); Assert.That(v1 == new bvec4(v1)); Assert.That(v2 == new bvec4(v2)); Assert.That(v3 == new bvec4(v3)); Assert.That(v1 == v2); Assert.That(v1 != v3); Assert.That(v2 != v3); }
public void Constructors() { { var v = new bvec4(true); Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(true, v.w); } { var v = new bvec4(true, false, true, false); Assert.AreEqual(true, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(false, v.w); } { var v = new bvec4(new bvec2(false, false)); Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } { var v = new bvec4(new bvec3(true, true, false)); Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } { var v = new bvec4(new bvec4(true, false, false, true)); Assert.AreEqual(true, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(true, v.w); } }
public void StringInterop() { var v = new bvec4(false, true, true, false); var s0 = v.ToString(); var s1 = v.ToString("#"); var v0 = bvec4.Parse(s0); var v1 = bvec4.Parse(s1, "#"); Assert.AreEqual(v, v0); Assert.AreEqual(v, v1); var b0 = bvec4.TryParse(s0, out v0); var b1 = bvec4.TryParse(s1, "#", out v1); Assert.That(b0); Assert.That(b1); Assert.AreEqual(v, v0); Assert.AreEqual(v, v1); b0 = bvec4.TryParse(null, out v0); Assert.False(b0); b0 = bvec4.TryParse("", out v0); Assert.False(b0); b0 = bvec4.TryParse(s0 + ", 0", out v0); Assert.False(b0); Assert.Throws <NullReferenceException>(() => { bvec4.Parse(null); }); Assert.Throws <FormatException>(() => { bvec4.Parse(""); }); Assert.Throws <FormatException>(() => { bvec4.Parse(s0 + ", 0"); }); var s2 = v.ToString(";", CultureInfo.InvariantCulture); Assert.That(s2.Length > 0); }
/// <summary> /// Returns true only if all components of x are true. /// </summary> /// <param name="x"></param> /// <returns></returns> public static bool all(bvec4 x) { return(false); }
/// <summary> /// Returns the component-wise compare of x != y. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public static bvec4 notEqual(bvec4 x, bvec4 y) { return(null); }
protected bvec4 not(bvec4 x, bvec4 y) { throw new NotImplementedException(); }
protected vec4 mix(vec4 x, vec4 y, bvec4 a) { throw new NotImplementedException(); }
/// <summary> /// Selects which vector each returned component comes from. For a component of a that is false, /// the corresponding component of x is returned. For a component of a that is true, /// the corresponding component of y is returned. Components of x and y that are not selected /// are allowed to be invalid floating point values and will have no effect on the results. /// Thus, this provides different functionality than, for example, /// genType Lerp(genType x, genType y, genType(a)) where a is a Boolean vector. /// </summary> protected internal static dvec4 Lerp(dvec4 x, dvec4 y, bvec4 a) { throw _invalidAccess; }
public static bool all(bvec4 x) { return x.x && x.y && x.z && x.w; }
protected extern bvec4 notEqual(bvec4 x, bvec4 y);
protected extern vec4 mix(vec4 x, vec4 y, bvec4 a);
/// <summary> /// Returns the component-wise logical complement of x. /// </summary> /// <param name="x"></param> /// <returns></returns> public static bvec4 not(bvec4 x) { return(null); }
public static bvec4 not(bvec4 x) { bvec4 r; r.x = !x.x; r.y = !x.y; r.z = !x.z; r.w = !x.w; return r; }
public static bool all(bvec4 a) { return(a.x && a.y && a.z && a.w); }
public static bool any(bvec4 a) { return(a.x || a.y || a.z || a.w); }
public static uvec4 mix(uvec4 a, uvec4 b, bvec4 t) { return(new uvec4(t.x ? a.x : b.x, t.y ? a.y : b.y, t.z ? a.z : b.z, t.w ? a.w : b.w)); }
/// <summary> /// </summary> /// <param name="uniformName"></param> /// <param name="values"></param> /// <returns></returns> public int SetUniform(string uniformName, bvec4[] values) { int location = GetUniformLocation(uniformName); if (location >= 0) { if (glUniform4iv == null) { glUniform4iv = OpenGL.GetDelegateFor<OpenGL.glUniform4iv>(); } int count = values.Length; var value = new int[count * 4]; int index = 0; for (int i = 0; i < value.Length; i++) { value[index++] = values[i].x ? 1 : 0; value[index++] = values[i].y ? 1 : 0; value[index++] = values[i].z ? 1 : 0; value[index++] = values[i].w ? 1 : 0; } glUniform4iv(location, count, value); } return location; }
protected extern bvec4 any(bvec4 x, bvec4 y);
protected extern bvec4 equal(bvec4 x, bvec4 y);
public static bvec4 notEqual(bvec4 x, bvec4 y) { bvec4 r; r.x = x.x != y.x; r.y = x.y != y.y; r.z = x.z != y.z; r.w = x.w != y.w; return r; }
protected extern bvec4 all(bvec4 x, bvec4 y);
public static bool any(bvec4 x) { return x.x || x.y || x.z || x.w; }
protected extern bvec4 not(bvec4 x, bvec4 y);
public static bvec4 equal(bvec4 x, bvec4 y) { bvec4 r; r.x = x.x == y.x; r.y = x.y == y.y; r.z = x.z == y.z; r.w = x.w == y.w; return r; }