… | |
… | |
87 | my ($class, $w, $h, $cb) = @_; |
87 | my ($class, $w, $h, $cb) = @_; |
88 | |
88 | |
89 | $class->new (w => $w || 1, h => $h || 1, render_cb => $cb) |
89 | $class->new (w => $w || 1, h => $h || 1, render_cb => $cb) |
90 | } |
90 | } |
91 | |
91 | |
92 | sub topot { |
|
|
93 | (grep $_ >= $_[0], 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768)[0] |
|
|
94 | } |
|
|
95 | |
|
|
96 | sub upload { |
92 | sub upload { |
97 | my ($self) = @_; |
93 | my ($self) = @_; |
98 | |
94 | |
99 | return unless $GL_VERSION; |
95 | return unless $GL_VERSION; |
100 | |
96 | |
… | |
… | |
116 | ($self->{w}, $self->{h}, $data, $self->{internalformat}, $self->{format}, $self->{type}) |
112 | ($self->{w}, $self->{h}, $data, $self->{internalformat}, $self->{format}, $self->{type}) |
117 | = CFClient::load_image_inline $self->{image}; |
113 | = CFClient::load_image_inline $self->{image}; |
118 | } |
114 | } |
119 | |
115 | |
120 | my ($tw, $th) = @$self{qw(w h)}; |
116 | my ($tw, $th) = @$self{qw(w h)}; |
121 | |
|
|
122 | unless ($tw > 0 && $th > 0) { |
|
|
123 | $tw = $th = 1; |
|
|
124 | $data = "\x00" x 64; |
|
|
125 | } |
|
|
126 | |
117 | |
127 | $self->{minified} ||= [CFClient::average $tw, $th, $data] |
118 | $self->{minified} ||= [CFClient::average $tw, $th, $data] |
128 | if $self->{minify}; |
119 | if $self->{minify}; |
129 | |
120 | |
130 | pad2pot $data, $tw, $th unless $GL_NPOT; |
121 | pad2pot $data, $tw, $th unless $GL_NPOT; |