File: glutils.h

package info (click to toggle)
glbinding 2.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 20,848 kB
  • ctags: 30,258
  • sloc: cpp: 255,369; xml: 46,343; python: 7,876; sh: 599; makefile: 494
file content (50 lines) | stat: -rw-r--r-- 1,492 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

#pragma once

#include <glbinding/gl32core/gl.h>

void compile_info(const gl32core::GLuint shader);
void link_info(const gl32core::GLuint program);

struct mat4
{
    mat4();

    inline gl::GLfloat & operator[](const int i) { return m[i]; }
    inline const gl::GLfloat & operator[](const int i) const { return m[i]; }

    static mat4 lookAt(gl::GLfloat eyex, gl::GLfloat eyey, gl::GLfloat eyez
        , gl::GLfloat centerx, gl::GLfloat centery, gl::GLfloat centerz, gl::GLfloat upx, gl::GLfloat upy, gl::GLfloat upz);

    static mat4 perspective(gl::GLfloat fovy, gl::GLfloat aspect, gl::GLfloat zNear, gl::GLfloat zFar);

    static mat4 translate(gl::GLfloat x, gl::GLfloat y, gl::GLfloat z);
    static mat4 scale(gl::GLfloat x, gl::GLfloat y, gl::GLfloat z);
    static mat4 rotate(gl::GLfloat angle, gl::GLfloat x, gl::GLfloat y, gl::GLfloat z);

    gl::GLfloat m[16];
};

mat4 operator*(const mat4 & a, const mat4 & b);

struct vec3
{
    vec3();
    vec3(gl::GLfloat x, gl::GLfloat y, gl::GLfloat z);

    inline gl::GLfloat & operator[](const int i) { return v[i]; }
    inline const gl::GLfloat & operator[](const int i) const { return v[i]; }

    vec3 & operator+(const vec3 & rhs);
    vec3 & operator-(const vec3 & rhs);
    vec3 & operator*(const vec3 & rhs);
    vec3 & operator/(const vec3 & rhs);

    gl::GLfloat length();
    void normalize();

    gl::GLfloat v[3];
};

vec3 crossp(const vec3 & a, const vec3 & b);
gl::GLfloat dotp(const vec3 & a, const vec3 & b);