… | |
… | |
39 | $self |
39 | $self |
40 | } |
40 | } |
41 | |
41 | |
42 | sub new_from_image { |
42 | sub 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 | |
48 | sub new_from_file { |
51 | sub 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 |