-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathscm-render.hpp
115 lines (90 loc) · 3.08 KB
/
scm-render.hpp
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Copyright (C) 2011-2012 Robert Kooima
//
// LIBSCM is free software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 of the License, or (at your option) any later
// version.
//
// This program is distributed in the hope that it will be useful, but WITH-
// OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
#ifndef SCM_RENDER_HPP
#define SCM_RENDER_HPP
#include <GL/glew.h>
#include "util3d/glsl.h"
//------------------------------------------------------------------------------
class scm_sphere;
class scm_scene;
class scm_state;
class scm_frame;
//------------------------------------------------------------------------------
/// An scm_render manages the rendering of background and foreground spheres.
///
/// In the simplest case, this entails merely invoking the scm_sphere's render
/// function to draw geometry to the screen. However, the render manager also
/// supports motion blur and dissolve transitions. These features require the
/// sphere to be rendered first to an off-screen buffer which is then drawn to
/// the screen as a single rectangle with the appropriate shader enabled.
///
/// The render manager also maintains the wireframe debug option, which would
/// otherwise conflict with more sophisticated capabilities.
class scm_render
{
public:
scm_render(int, int);
~scm_render();
void set_size(int, int);
void set_blur(int);
void set_wire(bool);
int get_blur() const { return blur; }
bool get_wire() const { return wire; }
void render(scm_sphere *,
const scm_state *,
const double *,
const double *, int, int);
void render(scm_sphere *,
scm_scene *,
scm_scene *,
const double *,
const double *, int, int);
private:
bool check_blur(const double *, const double *, GLfloat *, double *);
void check_atmo(const double *, const double *, GLfloat *, GLfloat *);
bool check_fade(const scm_scene *, const scm_scene *,
const scm_scene *, const scm_scene *, double);
void init_uniforms(GLuint);
void init_matrices();
void init_ogl();
void free_ogl();
int width;
int height;
int blur;
bool wire;
scm_frame *frameA;
scm_frame *frame0;
scm_frame *frame1;
double A[16];
double B[16];
double C[16];
double D[16];
double previous_T[16][16];
glsl render_fade;
glsl render_blur;
glsl render_both;
glsl render_atmo;
GLint uniform_fade_t;
GLint uniform_both_t;
GLint uniform_blur_T;
GLint uniform_both_T;
GLint uniform_blur_n;
GLint uniform_both_n;
GLint uniform_atmo_c;
GLint uniform_atmo_r;
GLint uniform_atmo_T;
GLint uniform_atmo_p;
GLint uniform_atmo_P;
GLint uniform_atmo_H;
};
//------------------------------------------------------------------------------
#endif