… | |
… | |
53 | |
53 | |
54 | open CFG, ">$file" |
54 | open CFG, ">$file" |
55 | or return; |
55 | or return; |
56 | |
56 | |
57 | { |
57 | { |
|
|
58 | require Data::Dumper; |
58 | local $Data::Dumper::Purity = 1; |
59 | local $Data::Dumper::Purity = 1; |
59 | $::CFG->{VERSION} = $::VERSION; |
60 | $::CFG->{VERSION} = $::VERSION; |
60 | print CFG Data::Dumper->Dump ([$::CFG], [qw/CFG/]); |
61 | print CFG Data::Dumper->Dump ([$::CFG], [qw/CFG/]); |
61 | } |
62 | } |
62 | |
63 | |
… | |
… | |
124 | } |
125 | } |
125 | |
126 | |
126 | sub new_from_opengl { |
127 | sub new_from_opengl { |
127 | my ($class, $w, $h, $cb) = @_; |
128 | my ($class, $w, $h, $cb) = @_; |
128 | |
129 | |
129 | $class->_new (width => $w, height => $h, render => $cb) |
130 | $class->_new (width => $w, height => $h, rendercb => $cb) |
130 | } |
131 | } |
131 | |
132 | |
132 | sub upload { |
133 | sub upload { |
133 | my ($self) = @_; |
134 | my ($self) = @_; |
134 | |
135 | |
… | |
… | |
138 | |
139 | |
139 | if (exists $self->{data}) { |
140 | if (exists $self->{data}) { |
140 | $data = $self->{data}; |
141 | $data = $self->{data}; |
141 | } elsif (exists $self->{rendercb}) { |
142 | } elsif (exists $self->{rendercb}) { |
142 | glViewport 0, 0, $self->{width}, $self->{height}; |
143 | glViewport 0, 0, $self->{width}, $self->{height}; |
|
|
144 | glMatrixMode GL_PROJECTION; |
|
|
145 | glLoadIdentity; |
|
|
146 | glOrtho 0, $self->{width}, $self->{height}, 0, -100, 100; |
|
|
147 | glMatrixMode GL_MODELVIEW; |
|
|
148 | glPushmatrix; |
|
|
149 | glLoadIdentity; |
143 | glClear GL_COLOR_BUFFER_BIT; |
150 | glClear GL_COLOR_BUFFER_BIT; |
144 | |
151 | |
145 | $self->{rendercb}->($self, $self->{width}, $self->{height}); |
152 | $self->{rendercb}->($self, $self->{width}, $self->{height}); |
146 | } else { |
153 | } else { |
147 | my $pb = new Gtk2::Gdk::PixbufLoader; |
154 | my $pb = new Gtk2::Gdk::PixbufLoader; |
… | |
… | |
173 | 0, |
180 | 0, |
174 | GL_RGBA, |
181 | GL_RGBA, |
175 | GL_UNSIGNED_BYTE, |
182 | GL_UNSIGNED_BYTE, |
176 | $data; |
183 | $data; |
177 | } else { |
184 | } else { |
|
|
185 | warn "I{DTEDRAW TEX: $self->{width} $self->{height} \n"; |
|
|
186 | warn "ERR: ". (glGetError). "\n"; |
|
|
187 | my ($bd, $br) = (glGet (GL_DRAW_BUFFER), glGet (GL_READ_BUFFER)); |
|
|
188 | warn "BUF:[$bd $br]\n"; |
|
|
189 | |
178 | glCopyTexImage2D GL_TEXTURE_2D, 0, |
190 | glCopyTexImage2D GL_TEXTURE_2D, 0, |
179 | GL_RGBA8, |
191 | GL_RGBA8, |
180 | 0, 0, |
192 | 0, 0, |
181 | $self->{width}, $self->{height}, |
193 | $self->{width}, $self->{height}, |
182 | 0; |
194 | 0; |
|
|
195 | glPopmatrix; |
|
|
196 | warn "ERR: ". (glGetError). "\n"; |
|
|
197 | sleep 1; |
183 | } |
198 | } |
184 | } |
199 | } |
185 | |
200 | |
186 | sub DESTROY { |
201 | sub DESTROY { |
187 | my ($self) = @_; |
202 | my ($self) = @_; |