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

Comparing deliantra/Deliantra-Client/DC/Texture.pm (file contents):
Revision 1.22 by root, Tue Jul 24 00:11:18 2007 UTC vs.
Revision 1.24 by root, Sun Jul 29 03:58:26 2007 UTC

39 $self 39 $self
40} 40}
41 41
42sub new_from_image { 42sub new_from_image {
43 my ($class, $image, %arg) = @_; 43 my ($class, $image, %arg) = @_;
44
45 Carp::confess "tried to create texture from undefined image"
46 unless defined $image;
44 47
45 $class->new (image => $image, internalformat => undef, %arg) 48 $class->new (image => $image, internalformat => undef, %arg)
46} 49}
47 50
48sub new_from_file { 51sub new_from_file {
105 ($dw, $dh) = @$self{qw(w h)}; 108 ($dw, $dh) = @$self{qw(w h)};
106 109
107 } elsif (exists $self->{render_cb}) { 110 } elsif (exists $self->{render_cb}) {
108 ($dw, $dh) = @$self{qw(w h)}; 111 ($dw, $dh) = @$self{qw(w h)};
109 112
110 } else { 113 } elsif (exists $self->{image}) {
111 ($self->{w}, $self->{h}, $data, my $internalformat, $self->{format}, $self->{type}) 114 ($self->{w}, $self->{h}, $data, my $internalformat, $self->{format}, $self->{type})
112 = CFPlus::load_image_inline $self->{image}; 115 = CFPlus::load_image_inline $self->{image};
113 116
114 $self->{internalformat} ||= $internalformat; 117 $self->{internalformat} ||= $internalformat;
115 ($dw, $dh) = @$self{qw(w h)}; 118 ($dw, $dh) = @$self{qw(w h)};
119 } else {
120 Carp::confess "tried to create texture that is not data, render or image";
116 } 121 }
117 122
118 my ($tw, $th) = ($dw, $dh); 123 my ($tw, $th) = ($dw, $dh);
119 124
120 defined $data or $self->{render_cb} or die; # some sanity check 125 defined $data or $self->{render_cb} or die; # some sanity check
164 ($dw, $dh) = ($tw, $th); 169 ($dw, $dh) = ($tw, $th);
165 } 170 }
166 } 171 }
167 172
168 if ($render) { 173 if ($render) {
169 $ox = int .5 * ($::WIDTH - $tw); 174 $ox = int .5 * ($::WIDTH - $rw);
170 $oy = int .5 * ($::HEIGHT - $th); 175 $oy = int .5 * ($::HEIGHT - $rh);
171 176
172 glViewport $ox, $oy, $tw, $th; 177 glViewport $ox, $oy, $tw, $th;
173 #glScissor 0, 0, $tw, $th; 178 #glScissor 0, 0, $tw, $th;
174 #glEnable GL_SCISSOR_TEST; 179 #glEnable GL_SCISSOR_TEST;
175 glMatrixMode GL_PROJECTION; 180 glMatrixMode GL_PROJECTION;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines