… | |
… | |
131 | sub render_chld { |
131 | sub render_chld { |
132 | my ($self) = @_; |
132 | my ($self) = @_; |
133 | my $chld = $self->get; |
133 | my $chld = $self->get; |
134 | my ($w, $h) = $self->size_request; |
134 | my ($w, $h) = $self->size_request; |
135 | |
135 | |
136 | $w = $h = 256; |
|
|
137 | |
|
|
138 | $self->{texture} = |
136 | $self->{texture} = |
139 | Crossfire::Client::Texture->new_from_opengl ( |
137 | Crossfire::Client::Texture->new_from_opengl ( |
140 | $w, $h, sub { |
138 | $w, $h, sub { $chld->draw } |
141 | glPushMatrix; |
|
|
142 | glLoadIdentity; |
|
|
143 | $chld->_draw; |
|
|
144 | glPopMatrix; |
|
|
145 | } |
|
|
146 | ); |
139 | ); |
147 | $self->{texture}->upload; |
140 | $self->{texture}->upload; |
148 | } |
141 | } |
149 | |
142 | |
150 | sub size_request { |
143 | sub size_request { |
… | |
… | |
155 | } |
148 | } |
156 | |
149 | |
157 | sub _draw { |
150 | sub _draw { |
158 | my ($self) = @_; |
151 | my ($self) = @_; |
159 | |
152 | |
160 | my ($w, $h) = $self->size_request; |
153 | my ($w, $h) = $self->size_request;#TODO# use widht/height of texture |
161 | my $tex = $self->{texture} |
154 | my $tex = $self->{texture} |
162 | or return; |
155 | or return; |
163 | |
156 | |
164 | glEnable GL_BLEND; |
157 | glEnable GL_BLEND; |
165 | glEnable GL_TEXTURE_2D; |
158 | glEnable GL_TEXTURE_2D; |
… | |
… | |
167 | glBindTexture GL_TEXTURE_2D, $tex->{name}; |
160 | glBindTexture GL_TEXTURE_2D, $tex->{name}; |
168 | |
161 | |
169 | glColor 1, 1, 1; |
162 | glColor 1, 1, 1; |
170 | |
163 | |
171 | glBegin GL_QUADS; |
164 | glBegin GL_QUADS; |
172 | glTexCoord 0, 0; glVertex 0 , 0; |
165 | glTexCoord 0, 0; glVertex 0, 0; |
173 | glTexCoord 0, 1; glVertex 0 , $h; |
166 | glTexCoord 0, 1; glVertex 0, $h; |
174 | glTexCoord 1, 1; glVertex $w , $h; |
167 | glTexCoord 1, 1; glVertex $w, $h; |
175 | glTexCoord 1, 0; glVertex $w , 0; |
168 | glTexCoord 1, 0; glVertex $w, 0; |
176 | glEnd; |
169 | glEnd; |
177 | |
170 | |
178 | glDisable GL_BLEND; |
171 | glDisable GL_BLEND; |
179 | glDisable GL_TEXTURE_2D; |
172 | glDisable GL_TEXTURE_2D; |
180 | } |
173 | } |
… | |
… | |
207 | glTexCoord 1, 0; glVertex $w + 4 , 0; |
200 | glTexCoord 1, 0; glVertex $w + 4 , 0; |
208 | glEnd; |
201 | glEnd; |
209 | |
202 | |
210 | glPushMatrix; |
203 | glPushMatrix; |
211 | glTranslate (2, 2, 0); |
204 | glTranslate (2, 2, 0); |
212 | $chld->_draw; |
205 | $chld->draw; |
213 | glPopMatrix; |
206 | glPopMatrix; |
214 | } |
207 | } |
215 | |
208 | |
216 | package Crossfire::Client::Widget::Table; |
209 | package Crossfire::Client::Widget::Table; |
217 | |
210 | |
… | |
… | |
280 | my $x = 0; |
273 | my $x = 0; |
281 | |
274 | |
282 | for (my $xi = 0; $xi <= $#{$self->{childs}->[$yi]}; $xi++) { |
275 | for (my $xi = 0; $xi <= $#{$self->{childs}->[$yi]}; $xi++) { |
283 | |
276 | |
284 | glPushMatrix; |
277 | glPushMatrix; |
285 | glTranslate ($x, $y, 0); |
278 | glTranslate ($x, $y, 0);#TODO#there must be no translate here, instead the widget must be moved |
286 | my $c = $self->{childs}->[$yi]->[$xi]; |
279 | my $c = $self->{childs}->[$yi]->[$xi]; |
287 | $c->_draw if $c; |
280 | $c->draw if $c; |
288 | glPopMatrix; |
281 | glPopMatrix; |
289 | |
282 | |
290 | $x += $self->max_col_width ($xi); |
283 | $x += $self->max_col_width ($xi); |
291 | } |
284 | } |
292 | |
285 | |
… | |
… | |
322 | my ($self) = @_; |
315 | my ($self) = @_; |
323 | |
316 | |
324 | my ($x, $y); |
317 | my ($x, $y); |
325 | for (@{$self->{childs} || []}) { |
318 | for (@{$self->{childs} || []}) { |
326 | glPushMatrix; |
319 | glPushMatrix; |
327 | glTranslate (0, $y, 0); |
320 | glTranslate (0, $y, 0);# see above TODO |
328 | $_->_draw; |
321 | $_->draw; |
329 | glPopMatrix; |
322 | glPopMatrix; |
330 | my ($w, $h) = $_->size_request; |
323 | my ($w, $h) = $_->size_request; |
331 | $y += $h; |
324 | $y += $h; |
332 | } |
325 | } |
333 | } |
326 | } |