Browse Source

Implement constructors for V2 and RGBA

rexim 4 years ago
parent
commit
af1f340d4c
1 changed files with 10 additions and 0 deletions
  1. 10 0
      oglt_math.h

+ 10 - 0
oglt_math.h

@@ -7,12 +7,22 @@ typedef struct {
     float x, y;
     float x, y;
 } V2;
 } V2;
 
 
+static inline V2 v2(float x, float y)
+{
+    return (V2) {.x = x, .y = y};
+}
+
 #define RGBA_COUNT 4
 #define RGBA_COUNT 4
 
 
 typedef struct {
 typedef struct {
     float r, g, b, a;
     float r, g, b, a;
 } RGBA;
 } RGBA;
 
 
+static inline RGBA rgba(float r, float g, float b, float a)
+{
+    return (RGBA) {.r = r, .g = g, .b = b, .a = a};
+}
+
 static inline float lerp(float a, float b, float t)
 static inline float lerp(float a, float b, float t)
 {
 {
     return a + (b - a) * t;
     return a + (b - a) * t;