… | |
… | |
31 | %GL_EXT = map +($_ => 1), split /\s+/, gl_extensions; |
31 | %GL_EXT = map +($_ => 1), split /\s+/, gl_extensions; |
32 | |
32 | |
33 | $GL_NPOT = $GL_EXT{GL_ARB_texture_non_power_of_two} || $GL_VERSION >= 2; |
33 | $GL_NPOT = $GL_EXT{GL_ARB_texture_non_power_of_two} || $GL_VERSION >= 2; |
34 | |
34 | |
35 | Crossfire::Client::Texture::restore_state (); |
35 | Crossfire::Client::Texture::restore_state (); |
36 | |
|
|
37 | # $GL_NPOT=0;#d# |
|
|
38 | } |
36 | } |
39 | |
37 | |
40 | sub find_rcfile($) { |
38 | sub find_rcfile($) { |
41 | my $path; |
39 | my $path; |
42 | |
40 | |
… | |
… | |
131 | # width => $surface->width, |
129 | # width => $surface->width, |
132 | # height => $surface->height, |
130 | # height => $surface->height, |
133 | # ) |
131 | # ) |
134 | #} |
132 | #} |
135 | |
133 | |
136 | sub new_from_text { |
134 | sub new_from_layout { |
137 | my ($class, $text, $height) = @_; |
135 | my ($class, $layout) = @_; |
138 | |
136 | |
139 | my ($w, $h, $data) = Crossfire::Client::font_render $text, $height; |
137 | my ($w, $h, $data) = $layout->render; |
140 | |
138 | |
141 | $class->new ( |
139 | $class->new ( |
142 | width => $w, |
140 | width => $w, |
143 | height => $h, |
141 | height => $h, |
144 | data => $data, |
142 | data => $data, |
… | |
… | |
191 | $data = $pb->get_pixels; |
189 | $data = $pb->get_pixels; |
192 | } |
190 | } |
193 | |
191 | |
194 | my ($tw, $th) = @$self{qw(width height)}; |
192 | my ($tw, $th) = @$self{qw(width height)}; |
195 | |
193 | |
196 | unless ($NPOT) { |
194 | unless ($GL_NPOT) { |
197 | $tw = topot $tw; |
195 | $tw = topot $tw; |
198 | $th = topot $th; |
196 | $th = topot $th; |
199 | |
197 | |
200 | if (defined $data) { |
198 | if (defined $data) { |
201 | $data = pack "(a$tw)*", (unpack "(a$self->{width})*", $data); |
199 | my $bpp = (length $data) / ($self->{width} * $self->{height}); |
|
|
200 | $data = pack "(a" . ($tw * $bpp) . ")*", |
|
|
201 | unpack "(a" . ($self->{width} * $bpp) . ")*", $data; |
202 | $data .= ("\x00" x $tw) x ($th - $self->{height}); |
202 | $data .= ("\x00" x ($tw * $bpp)) x ($th - $self->{height}); |
203 | } |
203 | } |
204 | } |
204 | } |
205 | |
205 | |
206 | $self->{u} = $self->{width} / $tw; |
206 | $self->{s} = $self->{width} / $tw; |
207 | $self->{v} = $self->{height} / $th; |
207 | $self->{t} = $self->{height} / $th; |
208 | |
208 | |
209 | $self->{name} ||= (glGenTextures 1)->[0]; |
209 | $self->{name} ||= (glGenTextures 1)->[0]; |
210 | |
210 | |
211 | glBindTexture GL_TEXTURE_2D, $self->{name}; |
211 | glBindTexture GL_TEXTURE_2D, $self->{name}; |
212 | |
212 | |
213 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST; |
213 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR; |
214 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST;#_MIPMAP_LINEAR; |
214 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR;#_MIPMAP_LINEAR; |
215 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP; |
215 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP; |
216 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP; |
216 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP; |
217 | |
217 | |
218 | glGetError; |
218 | glGetError; |
219 | if (defined $data) { |
219 | if (defined $data) { |