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.27 by root, Wed Apr 12 18:09:21 2006 UTC vs.
Revision 1.30 by root, Wed Apr 12 21:35:10 2006 UTC

31sub gl_init { 31sub gl_init {
32 $GL_VERSION = gl_version * 1; 32 $GL_VERSION = gl_version * 1;
33 %GL_EXT = map +($_ => 1), split /\s+/, gl_extensions; 33 %GL_EXT = map +($_ => 1), split /\s+/, gl_extensions;
34 34
35 $GL_NPOT = $GL_EXT{GL_ARB_texture_non_power_of_two} || $GL_VERSION >= 2; 35 $GL_NPOT = $GL_EXT{GL_ARB_texture_non_power_of_two} || $GL_VERSION >= 2;
36
37 glClearColor 0.45, 0.45, 0.45, 1;
38 36
39 glEnable GL_TEXTURE_2D; 37 glEnable GL_TEXTURE_2D;
40 glEnable GL_COLOR_MATERIAL; 38 glEnable GL_COLOR_MATERIAL;
41 glShadeModel GL_FLAT; 39 glShadeModel GL_FLAT;
42 glDisable GL_DEPTH_TEST; 40 glDisable GL_DEPTH_TEST;
104 my ($class, %data) = @_; 102 my ($class, %data) = @_;
105 103
106 my $self = bless { 104 my $self = bless {
107 internalformat => GL_RGBA, 105 internalformat => GL_RGBA,
108 format => GL_RGBA, 106 format => GL_RGBA,
107 type => GL_UNSIGNED_BYTE,
109 %data, 108 %data,
110 }, $class; 109 }, $class;
111 110
112 push @textures, $self; 111 push @textures, $self;
113 Scalar::Util::weaken $textures[-1]; 112 Scalar::Util::weaken $textures[-1];
154 w => $w, 153 w => $w,
155 h => $h, 154 h => $h,
156 data => $data, 155 data => $data,
157 internalformat => GL_ALPHA4, 156 internalformat => GL_ALPHA4,
158 format => GL_ALPHA, 157 format => GL_ALPHA,
158 type => GL_UNSIGNED_BYTE,
159 ) 159 )
160} 160}
161 161
162sub new_from_opengl { 162sub new_from_opengl {
163 my ($class, $w, $h, $cb) = @_; 163 my ($class, $w, $h, $cb) = @_;
188 glLoadIdentity; 188 glLoadIdentity;
189 glClear GL_COLOR_BUFFER_BIT; 189 glClear GL_COLOR_BUFFER_BIT;
190 $self->{render_cb}->($self, $self->{w}, $self->{h}); 190 $self->{render_cb}->($self, $self->{w}, $self->{h});
191 191
192 } else { 192 } else {
193 my $pb = new Gtk2::Gdk::PixbufLoader; 193 ($self->{w}, $self->{h}, $data, $self->{internalformat}, $self->{format}, $self->{type})
194 $pb->write ($self->{image}); 194 = 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 } 195 }
205 196
206 my ($tw, $th) = @$self{qw(w h)}; 197 my ($tw, $th) = @$self{qw(w h)};
207 198
208 unless ($tw && $th) { 199 unless ($tw && $th) {
239 glTexImage2D GL_TEXTURE_2D, 0, 230 glTexImage2D GL_TEXTURE_2D, 0,
240 $self->{internalformat}, 231 $self->{internalformat},
241 $tw, $th, # need to pad texture first 232 $tw, $th, # need to pad texture first
242 0, 233 0,
243 $self->{format}, 234 $self->{format},
244 GL_UNSIGNED_BYTE, 235 $self->{type},
245 $data; 236 $data;
246 glGetError and die; 237 glGetError and die;
247 } else { 238 } else {
248 glCopyTexImage2D GL_TEXTURE_2D, 0, 239 glCopyTexImage2D GL_TEXTURE_2D, 0,
249 $self->{internalformat}, 240 $self->{internalformat},

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines