-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathscm-image.hpp
106 lines (79 loc) · 3 KB
/
scm-image.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
// 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_IMAGE_HPP
#define SCM_IMAGE_HPP
#include <GL/glew.h>
#include <string>
#include <vector>
//------------------------------------------------------------------------------
class scm_system;
class scm_cache;
//------------------------------------------------------------------------------
/// An scm_image represents an SCM data file in use by an scm_scene.
///
/// This object is largely responsible for mapping SCM data onto OpenGL state,
/// including OpenGL textures and GLSL uniforms. Notably, this includes those
/// parameters mapping texture coordinates onto a scm_cache texture atlas.
class scm_image
{
public:
scm_image(scm_system *);
~scm_image();
/// @name Configuration modifiers
/// @{
void set_scm (const std::string& s);
void set_name (const std::string& s);
void set_channel (int c);
void set_normal_min(float k);
void set_normal_max(float k);
/// @}
/// @name Configuration queries
/// @{
const std::string& get_scm() const { return scm; }
const std::string& get_name() const { return name; }
int get_channel() const { return channel; }
float get_normal_min() const { return k0; }
float get_normal_max() const { return k1; }
bool is_channel(int c) const { return (channel == c || channel == -1); }
bool is_height() const { return (height); }
/// @}
/// @name Internal Interface
/// @{
void init_uniforms(GLuint);
void bind(GLuint, GLuint) const;
void unbind(GLuint) const;
void bind_page(GLuint, int, int, long long) const;
void unbind_page(GLuint, int) const;
void touch_page( int, long long) const;
float get_page_sample(const double *) const;
void get_page_bounds(long long, float &, float &) const;
bool get_page_status(long long) const;
/// @}
private:
scm_system *sys;
std::string scm;
std::string name;
int channel;
bool height;
float k0;
float k1;
GLint uS;
GLint ur;
GLint uk0;
GLint uk1;
GLint ua[16];
GLint ub[16];
scm_cache *cache;
int index;
};
//------------------------------------------------------------------------------
#endif