libreis  0.1.0
A simple header-based drop-in library
math.h
1 #ifndef REIS_INCLUDE_MATH_H_
2 #define REIS_INCLUDE_MATH_H_
3 
4 #include <reis/base.h>
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 #define PI 141592653589f
11 
12 #define rsC
13 
14 int isNum(const char *str);
15 
16 // OpenGL Mathematics
17 
18 #include <GL/gl.h>
19 
20 typedef struct { GLfloat x, y; } vec2;
21 typedef struct { GLfloat x, y, z; } vec3;
22 typedef struct { GLfloat x, y, z, w; } vec4;
23 
24 typedef struct { GLfloat a[3*3]; } mat3;
25 typedef struct { GLfloat a[4*4]; } mat4;
26 
27 typedef struct { GLfloat x, y, w, h; } rect;
28 
29 static inline vec2 rsNewvec2( GLfloat x, GLfloat y ) { return (vec2) {x, y}; }
30 static inline vec3 rsNewvec3( GLfloat x, GLfloat y, GLfloat z ) {
31  return (vec3) {x, y, z};
32 }
33 static inline vec4 rsNewvec4( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) {
34  return (vec4) {x, y, z, w};
35 }
36 static inline rect rsNewrect( GLfloat x, GLfloat y, GLfloat w, GLfloat h ) {
37  return (rect) {x, y, w, h};
38 }
39 
40 mat3 mat3_identity( void );
41 mat4 mat4_identity( void );
42 
43 mat4 mat4_ortho( GLfloat left, GLfloat right, GLfloat bot,
44  GLfloat top, GLfloat near, GLfloat far );
45 
46 #ifdef __cplusplus
47 }
48 #endif
49 
50 #endif
Shared types and functions, accounts for GNU Linux and MacOS specifications.
Definition: math.h:24
Definition: math.h:25
Definition: math.h:27
Definition: math.h:20
Definition: math.h:21
Definition: math.h:22