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.26 by root, Wed Apr 12 02:00:06 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) = @_;
170} 172}
171 173
172sub upload { 174sub upload {
173 my ($self) = @_; 175 my ($self) = @_;
174 176
175 return unless $SDL::App::USING_OPENGL; 177 return unless $GL_VERSION;
176 178
177 my $data; 179 my $data;
178 180
179 if (exists $self->{data}) { 181 if (exists $self->{data}) {
180 $data = $self->{data}; 182 $data = $self->{data};
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 my $pb = new Gtk2::Gdk::PixbufLoader; 195 ($self->{w}, $self->{h}, $data, $self->{internalformat}, $self->{format}, $self->{type})
194 $pb->write ($self->{image}); 196 = CFClient::load_image_inline $self->{image};
195 $pb->close;
196
197 $pb = $pb->get_pixbuf;
198 $pb = $pb->add_alpha (0, 0, 0, 0);
199
200 $self->{w} = $pb->get_width;
201 $self->{h} = $pb->get_height;
202
203 $data = $pb->get_pixels;
204 } 197 }
205 198
206 my ($tw, $th) = @$self{qw(w h)}; 199 my ($tw, $th) = @$self{qw(w h)};
207 200
208 unless ($tw && $th) { 201 unless ($tw && $th) {
239 glTexImage2D GL_TEXTURE_2D, 0, 232 glTexImage2D GL_TEXTURE_2D, 0,
240 $self->{internalformat}, 233 $self->{internalformat},
241 $tw, $th, # need to pad texture first 234 $tw, $th, # need to pad texture first
242 0, 235 0,
243 $self->{format}, 236 $self->{format},
244 GL_UNSIGNED_BYTE, 237 $self->{type},
245 $data; 238 $data;
246 glGetError and die; 239 glGetError and die;
247 } else { 240 } else {
248 glCopyTexImage2D GL_TEXTURE_2D, 0, 241 glCopyTexImage2D GL_TEXTURE_2D, 0,
249 $self->{internalformat}, 242 $self->{internalformat},

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines