… | |
… | |
1456 | |
1456 | |
1457 | $tex->draw_quad (0, 0, $s, $s); |
1457 | $tex->draw_quad (0, 0, $s, $s); |
1458 | |
1458 | |
1459 | glDisable GL_TEXTURE_2D; |
1459 | glDisable GL_TEXTURE_2D; |
1460 | glDisable GL_BLEND; |
1460 | glDisable GL_BLEND; |
|
|
1461 | } |
|
|
1462 | |
|
|
1463 | ############################################################################# |
|
|
1464 | |
|
|
1465 | package CFClient::UI::Image; |
|
|
1466 | |
|
|
1467 | our @ISA = CFClient::UI::Base::; |
|
|
1468 | |
|
|
1469 | use CFClient::OpenGL; |
|
|
1470 | use Carp qw/confess/; |
|
|
1471 | |
|
|
1472 | our %loaded_images; |
|
|
1473 | |
|
|
1474 | sub new { |
|
|
1475 | my $class = shift; |
|
|
1476 | |
|
|
1477 | my $self = $class->SUPER::new (@_); |
|
|
1478 | |
|
|
1479 | $self->{image} or confess "Image has 'image' not set. This is a fatal error!"; |
|
|
1480 | |
|
|
1481 | $loaded_images{$self->{image}} ||= |
|
|
1482 | new_from_file CFClient::Texture CFClient::find_rcfile $self->{image}, mipmap => 1; |
|
|
1483 | |
|
|
1484 | my $tex = $self->{tex} = $loaded_images{$self->{image}}; |
|
|
1485 | |
|
|
1486 | $self->{aspect} = $tex->{w} / $tex->{h}; |
|
|
1487 | |
|
|
1488 | $self |
|
|
1489 | } |
|
|
1490 | |
|
|
1491 | sub size_request { |
|
|
1492 | my ($self) = @_; |
|
|
1493 | |
|
|
1494 | ($self->{tex}->{w}, $self->{tex}->{h}) |
|
|
1495 | } |
|
|
1496 | |
|
|
1497 | sub _draw { |
|
|
1498 | my ($self) = @_; |
|
|
1499 | |
|
|
1500 | my $tex = $self->{tex}; |
|
|
1501 | |
|
|
1502 | my ($w, $h) = ($self->{w}, $self->{h}); |
|
|
1503 | |
|
|
1504 | if ($self->{rot90}) { |
|
|
1505 | glRotate 90, 0, 0, 1; |
|
|
1506 | glTranslate 0, -$self->{w}, 0; |
|
|
1507 | |
|
|
1508 | ($w, $h) = ($h, $w); |
|
|
1509 | } |
|
|
1510 | |
|
|
1511 | glEnable GL_BLEND; |
|
|
1512 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1513 | glEnable GL_TEXTURE_2D; |
|
|
1514 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
1515 | |
|
|
1516 | $tex->draw_quad (0, 0, $w, $h); |
|
|
1517 | |
|
|
1518 | glDisable GL_BLEND; |
|
|
1519 | glDisable GL_TEXTURE_2D; |
1461 | } |
1520 | } |
1462 | |
1521 | |
1463 | ############################################################################# |
1522 | ############################################################################# |
1464 | |
1523 | |
1465 | package CFClient::UI::VGauge; |
1524 | package CFClient::UI::VGauge; |