rays 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +5 -5
  2. data/.doc/ext/rays/bitmap.cpp +22 -76
  3. data/.doc/ext/rays/bounds.cpp +95 -125
  4. data/.doc/ext/rays/color.cpp +224 -45
  5. data/.doc/ext/rays/color_space.cpp +137 -45
  6. data/.doc/ext/rays/defs.cpp +183 -0
  7. data/.doc/ext/rays/font.cpp +39 -21
  8. data/.doc/ext/rays/image.cpp +26 -37
  9. data/.doc/ext/rays/matrix.cpp +186 -29
  10. data/.doc/ext/rays/native.cpp +12 -6
  11. data/.doc/ext/rays/noise.cpp +53 -0
  12. data/.doc/ext/rays/painter.cpp +120 -308
  13. data/.doc/ext/rays/point.cpp +82 -77
  14. data/.doc/ext/rays/polygon.cpp +287 -0
  15. data/.doc/ext/rays/polygon_line.cpp +96 -0
  16. data/.doc/ext/rays/polyline.cpp +161 -0
  17. data/.doc/ext/rays/rays.cpp +0 -13
  18. data/.doc/ext/rays/shader.cpp +83 -9
  19. data/README.md +1 -1
  20. data/Rakefile +21 -9
  21. data/VERSION +1 -1
  22. data/ext/rays/bitmap.cpp +22 -80
  23. data/ext/rays/bounds.cpp +100 -128
  24. data/ext/rays/color.cpp +232 -51
  25. data/ext/rays/color_space.cpp +140 -46
  26. data/ext/rays/defs.cpp +183 -0
  27. data/ext/rays/defs.h +26 -2
  28. data/ext/rays/extconf.rb +1 -2
  29. data/ext/rays/font.cpp +39 -22
  30. data/ext/rays/image.cpp +27 -39
  31. data/ext/rays/matrix.cpp +198 -30
  32. data/ext/rays/native.cpp +12 -6
  33. data/ext/rays/noise.cpp +55 -0
  34. data/ext/rays/painter.cpp +129 -315
  35. data/ext/rays/point.cpp +89 -81
  36. data/ext/rays/polygon.cpp +301 -0
  37. data/ext/rays/polygon_line.cpp +99 -0
  38. data/ext/rays/polyline.cpp +170 -0
  39. data/ext/rays/rays.cpp +0 -14
  40. data/ext/rays/shader.cpp +84 -9
  41. data/include/rays.h +10 -2
  42. data/include/rays/bitmap.h +14 -26
  43. data/include/rays/bounds.h +21 -4
  44. data/include/rays/color.h +25 -14
  45. data/include/rays/color_space.h +11 -8
  46. data/include/rays/coord.h +114 -0
  47. data/include/rays/debug.h +22 -0
  48. data/include/rays/defs.h +3 -0
  49. data/include/rays/font.h +4 -4
  50. data/include/rays/image.h +11 -17
  51. data/include/rays/matrix.h +50 -24
  52. data/include/rays/noise.h +42 -0
  53. data/include/rays/opengl.h +2 -50
  54. data/include/rays/painter.h +57 -99
  55. data/include/rays/point.h +44 -51
  56. data/include/rays/polygon.h +164 -0
  57. data/include/rays/polyline.h +65 -0
  58. data/include/rays/rays.h +3 -0
  59. data/include/rays/ruby.h +7 -1
  60. data/include/rays/ruby/bounds.h +1 -1
  61. data/include/rays/ruby/color.h +1 -1
  62. data/include/rays/ruby/color_space.h +1 -1
  63. data/include/rays/ruby/font.h +1 -1
  64. data/include/rays/ruby/matrix.h +1 -1
  65. data/include/rays/ruby/point.h +1 -1
  66. data/include/rays/ruby/polygon.h +52 -0
  67. data/include/rays/ruby/polyline.h +41 -0
  68. data/include/rays/ruby/shader.h +1 -1
  69. data/include/rays/shader.h +36 -8
  70. data/lib/rays.rb +6 -1
  71. data/lib/rays/bitmap.rb +0 -15
  72. data/lib/rays/bounds.rb +17 -23
  73. data/lib/rays/color.rb +20 -47
  74. data/lib/rays/color_space.rb +13 -13
  75. data/lib/rays/image.rb +2 -6
  76. data/lib/rays/matrix.rb +28 -0
  77. data/lib/rays/module.rb +4 -19
  78. data/lib/rays/painter.rb +60 -97
  79. data/lib/rays/point.rb +13 -21
  80. data/lib/rays/polygon.rb +50 -0
  81. data/lib/rays/polygon_line.rb +36 -0
  82. data/lib/rays/polyline.rb +32 -0
  83. data/lib/rays/shader.rb +20 -1
  84. data/rays.gemspec +5 -7
  85. data/src/bitmap.h +36 -0
  86. data/src/bounds.cpp +74 -11
  87. data/src/color.cpp +58 -23
  88. data/src/color_space.cpp +50 -32
  89. data/src/color_space.h +22 -0
  90. data/src/coord.cpp +170 -0
  91. data/src/coord.h +35 -0
  92. data/src/font.cpp +118 -0
  93. data/src/font.h +64 -0
  94. data/src/frame_buffer.cpp +37 -71
  95. data/src/frame_buffer.h +4 -4
  96. data/src/image.cpp +171 -97
  97. data/src/image.h +25 -0
  98. data/src/ios/bitmap.mm +107 -105
  99. data/src/ios/font.mm +48 -60
  100. data/src/ios/helper.h +2 -2
  101. data/src/ios/opengl.mm +19 -4
  102. data/src/ios/rays.mm +3 -0
  103. data/src/matrix.cpp +111 -26
  104. data/src/matrix.h +30 -0
  105. data/src/noise.cpp +74 -0
  106. data/src/opengl.cpp +9 -27
  107. data/src/opengl.h +37 -0
  108. data/src/osx/bitmap.mm +111 -106
  109. data/src/osx/font.mm +48 -61
  110. data/src/osx/helper.h +2 -2
  111. data/src/osx/opengl.mm +19 -83
  112. data/src/osx/rays.mm +3 -0
  113. data/src/painter.cpp +780 -696
  114. data/src/painter.h +24 -0
  115. data/src/point.cpp +140 -119
  116. data/src/polygon.cpp +1100 -0
  117. data/src/polygon.h +32 -0
  118. data/src/polyline.cpp +158 -0
  119. data/src/polyline.h +67 -0
  120. data/src/render_buffer.cpp +11 -4
  121. data/src/render_buffer.h +2 -2
  122. data/src/shader.cpp +163 -106
  123. data/src/shader.h +38 -0
  124. data/src/shader_program.cpp +533 -0
  125. data/src/{program.h → shader_program.h} +28 -16
  126. data/src/shader_source.cpp +140 -0
  127. data/src/shader_source.h +52 -0
  128. data/src/texture.cpp +136 -160
  129. data/src/texture.h +65 -0
  130. data/src/win32/bitmap.cpp +62 -52
  131. data/src/win32/font.cpp +11 -13
  132. data/src/win32/font.h +24 -0
  133. data/src/win32/gdi.h +6 -6
  134. data/test/helper.rb +0 -3
  135. data/test/test_bitmap.rb +31 -7
  136. data/test/test_bounds.rb +36 -0
  137. data/test/test_color.rb +59 -19
  138. data/test/test_color_space.rb +95 -0
  139. data/test/test_image.rb +24 -20
  140. data/test/test_matrix.rb +106 -0
  141. data/test/test_painter.rb +92 -46
  142. data/test/test_painter_shape.rb +57 -0
  143. data/test/test_point.rb +21 -0
  144. data/test/test_polygon.rb +234 -0
  145. data/test/test_polygon_line.rb +167 -0
  146. data/test/test_polyline.rb +145 -0
  147. data/test/test_shader.rb +9 -9
  148. metadata +88 -67
  149. data/.doc/ext/rays/texture.cpp +0 -138
  150. data/ext/rays/texture.cpp +0 -149
  151. data/include/rays/ruby/texture.h +0 -41
  152. data/include/rays/texture.h +0 -71
  153. data/lib/rays/texture.rb +0 -24
  154. data/src/program.cpp +0 -648
  155. data/test/test_texture.rb +0 -27
@@ -0,0 +1,22 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_SRC_COLOR_SPACE_H__
4
+ #define __RAYS_SRC_COLOR_SPACE_H__
5
+
6
+
7
+ #include <rays/color_space.h>
8
+ #include "opengl.h"
9
+
10
+
11
+ namespace Rays
12
+ {
13
+
14
+
15
+ void ColorSpace_get_gl_format_and_type (
16
+ GLenum* format, GLenum* type, const ColorSpace& cs);
17
+
18
+
19
+ }// Rays
20
+
21
+
22
+ #endif//EOH
@@ -0,0 +1,170 @@
1
+ #include "coord.h"
2
+
3
+
4
+ #include <xot/string.h>
5
+ #include "rays/exception.h"
6
+
7
+
8
+ namespace Rays
9
+ {
10
+
11
+
12
+ Coord2&
13
+ Coord2::reset (coord value)
14
+ {
15
+ return reset(value, value);
16
+ }
17
+
18
+ Coord2&
19
+ Coord2::reset (coord x, coord y)
20
+ {
21
+ this->x = x;
22
+ this->y = y;
23
+ return *this;
24
+ }
25
+
26
+ size_t
27
+ Coord2::size () const
28
+ {
29
+ return SIZE;
30
+ }
31
+
32
+ String
33
+ Coord2::inspect () const
34
+ {
35
+ return Xot::stringf("x=%f y=%f", x, y);
36
+ }
37
+
38
+ coord&
39
+ Coord2::operator [] (size_t index)
40
+ {
41
+ if (index >= 2)
42
+ argument_error(__FILE__, __LINE__);
43
+
44
+ return array[index];
45
+ }
46
+
47
+ const coord&
48
+ Coord2::operator [] (size_t index) const
49
+ {
50
+ return const_cast<Coord2*>(this)->operator[](index);
51
+ }
52
+
53
+
54
+ Coord3&
55
+ Coord3::operator = (const Coord2& rhs)
56
+ {
57
+ x = rhs.x;
58
+ y = rhs.y;
59
+ z = 0;
60
+ return *this;
61
+ }
62
+
63
+ Coord3&
64
+ Coord3::reset (coord value)
65
+ {
66
+ return reset(value, value);
67
+ }
68
+
69
+ Coord3&
70
+ Coord3::reset (coord x, coord y, coord z)
71
+ {
72
+ this->x = x;
73
+ this->y = y;
74
+ this->z = z;
75
+ return *this;
76
+ }
77
+
78
+ size_t
79
+ Coord3::size () const
80
+ {
81
+ return SIZE;
82
+ }
83
+
84
+ String
85
+ Coord3::inspect () const
86
+ {
87
+ return Xot::stringf("x=%f y=%f z=%f", x, y, z);
88
+ }
89
+
90
+ coord&
91
+ Coord3::operator [] (size_t index)
92
+ {
93
+ if (index >= 3)
94
+ argument_error(__FILE__, __LINE__);
95
+
96
+ return array[index];
97
+ }
98
+
99
+ const coord&
100
+ Coord3::operator [] (size_t index) const
101
+ {
102
+ return const_cast<Coord3*>(this)->operator[](index);
103
+ }
104
+
105
+
106
+ Coord4&
107
+ Coord4::operator = (const Coord2& rhs)
108
+ {
109
+ x = rhs.x;
110
+ y = rhs.y;
111
+ z = 0;
112
+ w = 1;
113
+ return *this;
114
+ }
115
+
116
+ Coord4&
117
+ Coord4::operator = (const Coord3& rhs)
118
+ {
119
+ x = rhs.x;
120
+ y = rhs.y;
121
+ z = rhs.z;
122
+ w = 1;
123
+ return *this;
124
+ }
125
+
126
+ Coord4&
127
+ Coord4::reset (coord value)
128
+ {
129
+ return reset(value, value, value);
130
+ }
131
+
132
+ Coord4&
133
+ Coord4::reset (coord x, coord y, coord z, coord w)
134
+ {
135
+ this->x = x;
136
+ this->y = y;
137
+ this->z = z;
138
+ this->w = w;
139
+ return *this;
140
+ }
141
+
142
+ size_t
143
+ Coord4::size () const
144
+ {
145
+ return SIZE;
146
+ }
147
+
148
+ String
149
+ Coord4::inspect () const
150
+ {
151
+ return Xot::stringf("x=%f y=%f z=%f w=%f", x, y, z, w);
152
+ }
153
+
154
+ coord&
155
+ Coord4::operator [] (size_t index)
156
+ {
157
+ if (index >= 4)
158
+ argument_error(__FILE__, __LINE__);
159
+
160
+ return array[index];
161
+ }
162
+
163
+ const coord&
164
+ Coord4::operator [] (size_t index) const
165
+ {
166
+ return const_cast<Coord4*>(this)->operator[](index);
167
+ }
168
+
169
+
170
+ }// Rays
@@ -0,0 +1,35 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_SRC_COORD_H__
4
+ #define __RAYS_SRC_COORD_H__
5
+
6
+
7
+ #include <glm/vec2.hpp>
8
+ #include <glm/vec3.hpp>
9
+ #include <rays/coord.h>
10
+
11
+
12
+ namespace Rays
13
+ {
14
+
15
+
16
+ typedef glm::tvec3<coord, glm::defaultp> Vec3;
17
+
18
+ typedef glm::tvec4<coord, glm::defaultp> Vec4;
19
+
20
+
21
+ inline Vec3& to_glm ( Coord3& val) {return *( Vec3*) &val;}
22
+
23
+ inline const Vec3& to_glm (const Coord3& val) {return *(const Vec3*) &val;}
24
+
25
+ template <typename T>
26
+ inline T& to_rays ( Vec3& val) {return *( T*) &val;}
27
+
28
+ template <typename T>
29
+ inline const T& to_rays (const Vec3& val) {return *(const T*) &val;}
30
+
31
+
32
+ }// Rays
33
+
34
+
35
+ #endif//EOH
@@ -0,0 +1,118 @@
1
+ #include "font.h"
2
+
3
+
4
+ #include <assert.h>
5
+
6
+
7
+ namespace Rays
8
+ {
9
+
10
+
11
+ struct Font::Data
12
+ {
13
+
14
+ RawFont rawfont;
15
+
16
+ mutable RawFont rawfont_for_pixel_density;
17
+
18
+ mutable float for_pixel_density = 1;
19
+
20
+ const RawFont& get_raw (float pixel_density) const
21
+ {
22
+ assert(pixel_density > 0);
23
+
24
+ if (!rawfont || pixel_density == 1)
25
+ return rawfont;
26
+
27
+ if (pixel_density != for_pixel_density)
28
+ {
29
+ rawfont_for_pixel_density =
30
+ RawFont(rawfont.name(), rawfont.size() * pixel_density);
31
+ for_pixel_density = pixel_density;
32
+ }
33
+
34
+ return rawfont_for_pixel_density;
35
+ }
36
+
37
+ };// Font::Data
38
+
39
+
40
+ const Font&
41
+ default_font ()
42
+ {
43
+ static const Font FONT(NULL);
44
+ return FONT;
45
+ }
46
+
47
+ const RawFont&
48
+ Font_get_raw (const Font& font, float pixel_density)
49
+ {
50
+ return font.self->get_raw(pixel_density);
51
+ }
52
+
53
+ coord
54
+ Font_get_width (const Font& font, float pixel_density, const char* str)
55
+ {
56
+ return Font_get_raw(font, pixel_density).get_width(str);
57
+ }
58
+
59
+ coord
60
+ Font_get_height (
61
+ const Font& font, float pixel_density,
62
+ coord* ascent, coord* descent, coord* leading)
63
+ {
64
+ return Font_get_raw(font, pixel_density)
65
+ .get_height(ascent, descent, leading);
66
+ }
67
+
68
+
69
+ Font::Font ()
70
+ {
71
+ }
72
+
73
+ Font::Font (const char* name, coord size)
74
+ {
75
+ self->rawfont = RawFont(name, size);
76
+ }
77
+
78
+ Font::~Font ()
79
+ {
80
+ }
81
+
82
+ String
83
+ Font::name () const
84
+ {
85
+ return self->rawfont.name();
86
+ }
87
+
88
+ coord
89
+ Font::size () const
90
+ {
91
+ return self->rawfont.size();
92
+ }
93
+
94
+ coord
95
+ Font::get_width (const char* str) const
96
+ {
97
+ return self->rawfont.get_width(str);
98
+ }
99
+
100
+ coord
101
+ Font::get_height (coord* ascent, coord* descent, coord* leading) const
102
+ {
103
+ return self->rawfont.get_height(ascent, descent, leading);
104
+ }
105
+
106
+ Font::operator bool () const
107
+ {
108
+ return !!self->rawfont;
109
+ }
110
+
111
+ bool
112
+ Font::operator ! () const
113
+ {
114
+ return !operator bool();
115
+ }
116
+
117
+
118
+ }// Rays
@@ -0,0 +1,64 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_SRC_FONT_H__
4
+ #define __RAYS_SRC_FONT_H__
5
+
6
+
7
+ #include <rays/defs.h>
8
+ #include <rays/font.h>
9
+
10
+
11
+ namespace Rays
12
+ {
13
+
14
+
15
+ class RawFont
16
+ {
17
+
18
+ public:
19
+
20
+ RawFont ();
21
+
22
+ RawFont (const char* name, coord size = 0);
23
+
24
+ ~RawFont ();
25
+
26
+ void draw_string (
27
+ void* context, coord context_height,
28
+ const char* str, coord x, coord y) const;
29
+
30
+ String name () const;
31
+
32
+ coord size () const;
33
+
34
+ coord get_width (const char* str) const;
35
+
36
+ coord get_height (
37
+ coord* ascent = NULL,
38
+ coord* descent = NULL,
39
+ coord* leading = NULL) const;
40
+
41
+ operator bool () const;
42
+
43
+ bool operator ! () const;
44
+
45
+ struct Data;
46
+
47
+ Xot::PSharedImpl<Data> self;
48
+
49
+ };// RawFont
50
+
51
+
52
+ const RawFont& Font_get_raw (const Font& font, float pixel_density);
53
+
54
+ coord Font_get_width (const Font& font, float pixel_density, const char* str);
55
+
56
+ coord Font_get_height (
57
+ const Font& font, float pixel_density,
58
+ coord* ascent = NULL, coord* descent = NULL, coord* leading = NULL);
59
+
60
+
61
+ }// Rays
62
+
63
+
64
+ #endif//EOH
@@ -3,8 +3,8 @@
3
3
 
4
4
  #include <vector>
5
5
  #include "rays/exception.h"
6
- #include "rays/texture.h"
7
- #include "rays/opengl.h"
6
+ #include "rays/debug.h"
7
+ #include "texture.h"
8
8
  #include "render_buffer.h"
9
9
 
10
10
 
@@ -15,17 +15,12 @@ namespace Rays
15
15
  struct FrameBuffer::Data
16
16
  {
17
17
 
18
- int id;
18
+ int id = -1;
19
19
 
20
20
  Texture texture;
21
21
 
22
22
  RenderBuffer render_buffer;
23
23
 
24
- Data ()
25
- : id(-1)
26
- {
27
- }
28
-
29
24
  ~Data ()
30
25
  {
31
26
  clear();
@@ -37,7 +32,7 @@ namespace Rays
37
32
 
38
33
  GLuint id_ = 0;
39
34
  glGenFramebuffers(1, &id_);
40
- check_error(__FILE__, __LINE__);
35
+ OpenGL_check_error(__FILE__, __LINE__);
41
36
 
42
37
  id = id_;
43
38
  }
@@ -51,7 +46,7 @@ namespace Rays
51
46
  {
52
47
  GLuint id_ = id;
53
48
  glDeleteFramebuffers(1, &id_);
54
- check_error(__FILE__, __LINE__);
49
+ OpenGL_check_error(__FILE__, __LINE__);
55
50
  }
56
51
 
57
52
  id = -1;
@@ -83,21 +78,17 @@ namespace Rays
83
78
  {
84
79
  switch (status)
85
80
  {
81
+ case GL_FRAMEBUFFER_UNSUPPORTED: return "GL_FRAMEBUFFER_UNSUPPORTED";
82
+ case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: return "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
83
+ case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: return "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
84
+ case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: return "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE";
86
85
  #ifdef IOS
87
- case GL_FRAMEBUFFER_UNSUPPORTED_OES: return "GL_FRAMEBUFFER_UNSUPPORTED_OES";
88
- case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES: return "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES";
89
- case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES: return "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES";
90
- case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES: return "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES";
91
- case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES: return "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES";
86
+ case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: return "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
92
87
  #else
93
- case GL_FRAMEBUFFER_UNDEFINED: return "GL_FRAMEBUFFER_UNDEFINED";
94
- case GL_FRAMEBUFFER_UNSUPPORTED: return "GL_FRAMEBUFFER_UNSUPPORTED";
95
- case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: return "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
96
- case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: return "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
97
- case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: return "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER";
98
- case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: return "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER";
99
- case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: return "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE";
100
- //case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: return "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS";
88
+ case GL_FRAMEBUFFER_UNDEFINED: return "GL_FRAMEBUFFER_UNDEFINED";
89
+ case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: return "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER";
90
+ case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: return "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER";
91
+ //case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: return "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS";
101
92
  #endif
102
93
  }
103
94
  return "UNKNOWN STATUS";
@@ -114,14 +105,13 @@ namespace Rays
114
105
  FrameBufferBinder binder(id());
115
106
 
116
107
  glFramebufferTexture2D(
117
- GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
118
- GL_TEXTURE_2D, texture.id(), 0);
119
- check_error(__FILE__, __LINE__);
108
+ GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture.id(), 0);
109
+ OpenGL_check_error(__FILE__, __LINE__);
120
110
 
121
111
  self->texture = texture;
122
112
 
123
113
  #if 0
124
- int w = texture.width(), h = texture.height();
114
+ int w = texture.reserved_width(), h = texture.reserved_height();
125
115
  if (
126
116
  w != self->render_buffer.width() ||
127
117
  h != self->render_buffer.height())
@@ -131,7 +121,7 @@ namespace Rays
131
121
  glFramebufferRenderbuffer(
132
122
  GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
133
123
  GL_RENDERBUFFER, rb.id());
134
- check_error(__FILE__, __LINE__);
124
+ OpenGL_check_error(__FILE__, __LINE__);
135
125
 
136
126
  self->render_buffer = rb;
137
127
  }
@@ -185,7 +175,9 @@ namespace Rays
185
175
  return false;
186
176
 
187
177
  const RenderBuffer& r = self->render_buffer;
188
- if (r && (t.width() != r.width() || t.height() != r.height()))
178
+ int w = t.reserved_width();
179
+ int h = t.reserved_height();
180
+ if (r && (r.width() != w || r.height() != h))
189
181
  return false;
190
182
 
191
183
  return true;
@@ -201,12 +193,12 @@ namespace Rays
201
193
  FrameBufferBinder::FrameBufferBinder (GLuint id)
202
194
  : id(id)
203
195
  {
204
- bind_frame_buffer(id);
196
+ FrameBuffer_bind(id);
205
197
  }
206
198
 
207
199
  FrameBufferBinder::~FrameBufferBinder ()
208
200
  {
209
- unbind_frame_buffer();
201
+ FrameBuffer_unbind();
210
202
  }
211
203
 
212
204
  GLuint
@@ -216,59 +208,33 @@ namespace Rays
216
208
  }
217
209
 
218
210
 
219
- struct FrameBufferID
220
- {
221
-
222
- GLuint draw, read;
223
-
224
- FrameBufferID ()
225
- : draw(0), read(0)
226
- {
227
- }
228
-
229
- FrameBufferID (GLuint draw, GLuint read)
230
- : draw(draw), read(read)
231
- {
232
- }
233
-
234
- };// FrameBufferID
211
+ static std::vector<GLuint> frame_buffer_bind_stack;
235
212
 
236
- static std::vector<FrameBufferID> frame_buffer_bind_stack;
237
213
 
238
-
239
- static void
240
- bind_frame_buffer (GLuint draw, GLuint read)
214
+ void
215
+ FrameBuffer_bind (GLuint id)
241
216
  {
242
- FrameBufferID id;
243
- glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, (GLint*) &id.draw);
244
- glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, (GLint*) &id.read);
245
- check_error(__FILE__, __LINE__);
217
+ GLuint current = 0;
218
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*) &current);
219
+ OpenGL_check_error(__FILE__, __LINE__);
246
220
 
247
- frame_buffer_bind_stack.push_back(id);
221
+ frame_buffer_bind_stack.push_back(current);
248
222
 
249
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, draw);
250
- glBindFramebuffer(GL_READ_FRAMEBUFFER, read);
251
- check_error(__FILE__, __LINE__);
252
- }
253
-
254
- void
255
- bind_frame_buffer (GLuint id)
256
- {
257
- bind_frame_buffer(id, id);
223
+ glBindFramebuffer(GL_FRAMEBUFFER, id);
224
+ OpenGL_check_error(__FILE__, __LINE__);
258
225
  }
259
226
 
260
227
  void
261
- unbind_frame_buffer ()
228
+ FrameBuffer_unbind ()
262
229
  {
263
230
  if (frame_buffer_bind_stack.empty())
264
- rays_error(__FILE__, __LINE__, "frame_buffer_bind_stack is empty.");
231
+ rays_error(__FILE__, __LINE__, "frame_buffer_bind_stack underflow.");
265
232
 
266
- FrameBufferID id = frame_buffer_bind_stack.back();
233
+ GLuint id = frame_buffer_bind_stack.back();
267
234
  frame_buffer_bind_stack.pop_back();
268
235
 
269
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, id.draw);
270
- glBindFramebuffer(GL_READ_FRAMEBUFFER, id.read);
271
- check_error(__FILE__, __LINE__);
236
+ glBindFramebuffer(GL_FRAMEBUFFER, id);
237
+ OpenGL_check_error(__FILE__, __LINE__);
272
238
  }
273
239
 
274
240