… | |
… | |
47 | unless defined $image; |
47 | unless defined $image; |
48 | |
48 | |
49 | $class->new (image => $image, internalformat => undef, %arg) |
49 | $class->new (image => $image, internalformat => undef, %arg) |
50 | } |
50 | } |
51 | |
51 | |
52 | |
|
|
53 | sub new_from_file { |
52 | sub new_from_resource { |
54 | my ($class, $path, %arg) = @_; |
53 | my ($class, $path, %arg) = @_; |
55 | |
54 | |
56 | open my $fh, "<:raw", $path |
55 | $class->new (resource_path => $path, internalformat => undef, %arg) |
57 | or die "$path: $!"; |
|
|
58 | |
|
|
59 | local $/; |
|
|
60 | $class->new_from_image (<$fh>, %arg) |
|
|
61 | } |
56 | } |
62 | |
57 | |
63 | #sub new_from_surface { |
58 | #sub new_from_surface { |
64 | # my ($class, $surface) = @_; |
59 | # my ($class, $surface) = @_; |
65 | # |
60 | # |
… | |
… | |
121 | # $rw,$rh rendered/used size |
116 | # $rw,$rh rendered/used size |
122 | # $dw,$dh $data |
117 | # $dw,$dh $data |
123 | |
118 | |
124 | my ($data, $dw, $dh); |
119 | my ($data, $dw, $dh); |
125 | |
120 | |
|
|
121 | if (exists $self->{resource_path}) { |
|
|
122 | open my $fh, "<:raw", DC::find_rcfile $self->{resource_path}; |
|
|
123 | local $/; |
|
|
124 | delete $self->{internalformat}; |
|
|
125 | $self->{image} = <$fh>; |
|
|
126 | $self->{delete_image} = 1; |
|
|
127 | } |
|
|
128 | |
126 | if (defined $self->{data}) { |
129 | if (defined $self->{data}) { |
127 | $data = $self->{data}; |
130 | $data = $self->{data}; |
128 | ($dw, $dh) = @$self{qw(w h)}; |
131 | ($dw, $dh) = @$self{qw(w h)}; |
129 | |
132 | |
130 | } elsif ($self->{render_cb}) { |
133 | } elsif ($self->{render_cb}) { |
… | |
… | |
180 | $th >>= 1; |
183 | $th >>= 1; |
181 | } |
184 | } |
182 | |
185 | |
183 | # decide the amount of space used in the texture |
186 | # decide the amount of space used in the texture |
184 | my ($rw, $rh); |
187 | my ($rw, $rh); |
185 | my ($ox, $oy); # area shift to lessen effetc of buggy opengl implementations (nvida, ati) |
188 | my ($ox, $oy); # area shift to lessen effect of buggy opengl implementations (nvida, ati) |
186 | my $render; |
189 | my $render; |
187 | |
190 | |
188 | if ($self->{render_cb}) { |
191 | if ($self->{render_cb}) { |
189 | # use only part of the texture |
192 | # use only part of the texture |
190 | #$rw >>= 1 while $rw > $tw; |
193 | #$rw >>= 1 while $rw > $tw; |