ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC.pm (file contents):
Revision 1.28 by root, Wed Apr 12 20:06:36 2006 UTC vs.
Revision 1.29 by root, Wed Apr 12 20:42:52 2006 UTC

104 my ($class, %data) = @_; 104 my ($class, %data) = @_;
105 105
106 my $self = bless { 106 my $self = bless {
107 internalformat => GL_RGBA, 107 internalformat => GL_RGBA,
108 format => GL_RGBA, 108 format => GL_RGBA,
109 type => GL_UNSIGNED_BYTE,
109 %data, 110 %data,
110 }, $class; 111 }, $class;
111 112
112 push @textures, $self; 113 push @textures, $self;
113 Scalar::Util::weaken $textures[-1]; 114 Scalar::Util::weaken $textures[-1];
154 w => $w, 155 w => $w,
155 h => $h, 156 h => $h,
156 data => $data, 157 data => $data,
157 internalformat => GL_ALPHA4, 158 internalformat => GL_ALPHA4,
158 format => GL_ALPHA, 159 format => GL_ALPHA,
160 type => GL_UNSIGNED_BYTE,
159 ) 161 )
160} 162}
161 163
162sub new_from_opengl { 164sub new_from_opengl {
163 my ($class, $w, $h, $cb) = @_; 165 my ($class, $w, $h, $cb) = @_;
188 glLoadIdentity; 190 glLoadIdentity;
189 glClear GL_COLOR_BUFFER_BIT; 191 glClear GL_COLOR_BUFFER_BIT;
190 $self->{render_cb}->($self, $self->{w}, $self->{h}); 192 $self->{render_cb}->($self, $self->{w}, $self->{h});
191 193
192 } else { 194 } else {
193 use Gtk2;#d# TODO kill 195 ($self->{w}, $self->{h}, $data, $self->{internalformat}, $self->{format}, $self->{type})
194 my $pb = new Gtk2::Gdk::PixbufLoader; 196 = CFClient::load_image_inline $self->{image};
195 $pb->write ($self->{image});
196 $pb->close;
197
198 $pb = $pb->get_pixbuf;
199 $pb = $pb->add_alpha (0, 0, 0, 0);
200
201 $self->{w} = $pb->get_width;
202 $self->{h} = $pb->get_height;
203
204 $data = $pb->get_pixels;
205 } 197 }
206 198
207 my ($tw, $th) = @$self{qw(w h)}; 199 my ($tw, $th) = @$self{qw(w h)};
208 200
209 unless ($tw && $th) { 201 unless ($tw && $th) {
240 glTexImage2D GL_TEXTURE_2D, 0, 232 glTexImage2D GL_TEXTURE_2D, 0,
241 $self->{internalformat}, 233 $self->{internalformat},
242 $tw, $th, # need to pad texture first 234 $tw, $th, # need to pad texture first
243 0, 235 0,
244 $self->{format}, 236 $self->{format},
245 GL_UNSIGNED_BYTE, 237 $self->{type},
246 $data; 238 $data;
247 glGetError and die; 239 glGetError and die;
248 } else { 240 } else {
249 glCopyTexImage2D GL_TEXTURE_2D, 0, 241 glCopyTexImage2D GL_TEXTURE_2D, 0,
250 $self->{internalformat}, 242 $self->{internalformat},

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines