… | |
… | |
140 | $th >>= 1; |
140 | $th >>= 1; |
141 | } |
141 | } |
142 | |
142 | |
143 | # decide the amount of space used in the texture |
143 | # decide the amount of space used in the texture |
144 | my ($rw, $rh); |
144 | my ($rw, $rh); |
|
|
145 | my $render; |
145 | |
146 | |
146 | if ($self->{render_cb}) { |
147 | if ($self->{render_cb}) { |
147 | # use only part of the texture |
148 | # use only part of the texture |
148 | #$rw >>= 1 while $rw > $tw; |
149 | #$rw >>= 1 while $rw > $tw; |
149 | #$rh >>= 1 while $rh > $th; |
150 | #$rh >>= 1 while $rh > $th; |
150 | $rw = min $dw, $tw; |
151 | $rw = min $dw, $tw; |
151 | $rh = min $dh, $th; |
152 | $rh = min $dh, $th; |
|
|
153 | ++$render; |
152 | } else { |
154 | } else { |
153 | if ($self->{wrap} || $tw < $dw || $th < $dh) { |
155 | if ($self->{wrap} || $tw < $dw || $th < $dh) { |
154 | # scale to the full texture size |
156 | # scale to the full texture size |
155 | ($rw, $rh) = ($tw, $th); |
157 | ($rw, $rh) = ($tw, $th); |
|
|
158 | ++$render; |
156 | } else { |
159 | } else { |
157 | # pad |
160 | # pad |
158 | pad $data, $dw, $dh, $tw, $th; |
161 | pad $data, $dw, $dh, $tw, $th; |
159 | ($rw, $rh) = ($dw, $dh); |
162 | ($rw, $rh) = ($dw, $dh); |
160 | ($dw, $dh) = ($tw, $th); |
163 | ($dw, $dh) = ($tw, $th); |
161 | } |
164 | } |
162 | } |
165 | } |
163 | |
|
|
164 | # rendering means we need to scale in some way |
|
|
165 | my $render = $self->{render_cb} || $rw != $dw || $th != $dh; |
|
|
166 | |
166 | |
167 | if ($render) { |
167 | if ($render) { |
168 | glViewport 0, 0, $tw, $th; |
168 | glViewport 0, 0, $tw, $th; |
169 | glClear 0, 0, 0, 0; |
169 | glClear 0, 0, 0, 0; |
170 | glMatrixMode GL_PROJECTION; |
170 | glMatrixMode GL_PROJECTION; |