1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-04-28 05:00:29 +02:00

gnu: perl-pdl: Make printing text work with glut backend, too.

* gnu/packages/patches/pdl-2.019-glut-bitmap-fonts.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/perl-maths.scm (perl-pdl)[source]: Use it.

Change-Id: I0331b1192d75a69831168d2fd634cadaa6260cd4
This commit is contained in:
Danny Milosavljevic
2024-12-17 21:40:47 +01:00
parent 7167aa686c
commit e5a1284289
3 changed files with 48 additions and 1 deletions

View File

@@ -1924,6 +1924,7 @@ dist_patch_DATA = \
%D%/packages/patches/password-store-tree-compat.patch \
%D%/packages/patches/pciutils-hurd64.patch \
%D%/packages/patches/pdfpc-build-with-vala-0.56.patch \
%D%/packages/patches/pdl-2.019-glut-bitmap-fonts.patch \
%D%/packages/patches/petri-foo-0.1.87-fix-recent-file-not-exist.patch \
%D%/packages/patches/plasma-framework-fix-KF5PlasmaMacros.cmake.patch \
%D%/packages/patches/plasp-fix-normalization.patch \

View File

@@ -0,0 +1,43 @@
Author: Danny Milosavljevic <dannym@friendly-machines.com>
Date: 2024-12-17 21:00:00 CET
Subject: Make bitmap fonts work even in glut
License: Same as Perl.
--- orig/PDL-2.019/Graphics/TriD/POGL/OpenGL.pm 2018-05-05 19:56:29.000000000 +0200
+++ PDL-2.019/Graphics/TriD/POGL/OpenGL.pm 2024-12-17 22:56:30.043984134 +0100
@@ -358,9 +358,34 @@
=cut
+use OpenGL qw(GL_COMPILE GLUT_BITMAP_9_BY_15 GLUT_BITMAP_8_BY_13);
+use constant GLUT_FONTS => {
+ '9x15' => GLUT_BITMAP_9_BY_15,
+ '8x13' => GLUT_BITMAP_8_BY_13,
+};
+
sub glpRasterFont{
my($this,@args) = @_;
- OpenGL::glpRasterFont($args[0],$args[1],$args[2],$this->{Display});
+ # see also OpenGL::glpPrintString($::lb,$header);
+ if ( $this->{window_type} eq 'glut' ) {
+ my $font_name = $args[0] || '8x13';
+ my $font = GLUT_FONTS->{$font_name} || GLUT_FONTS->{'8x13'};
+ my $start_char = $args[1] || 0;
+ my $num_chars = $args[2] || 128;
+ my $cache_key = "${font_name};${start_char};${num_chars}";
+ unless (exists $this->{font_cache}{$cache_key}) {
+ my $base = OpenGL::glGenLists($num_chars);
+ for my $i (0..($num_chars - 1)) {
+ OpenGL::glNewList($base + $i, GL_COMPILE);
+ OpenGL::glutBitmapCharacter($font, $start_char + $i);
+ OpenGL::glEndList();
+ }
+ $this->{font_cache}{$cache_key} = $base;
+ }
+ return $this->{font_cache}{$cache_key};
+ } else {
+ OpenGL::glpRasterFont($args[0],$args[1],$args[2],$this->{Display});
+ }
}

View File

@@ -21,6 +21,7 @@
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix build-system perl)
#:use-module (gnu packages)
#:use-module (gnu packages gcc)
#:use-module (gnu packages gd)
#:use-module (gnu packages gl)
@@ -85,7 +86,9 @@ It implements the data type \"matrix of real numbers\" (and consequently also
(uri (string-append "https://www.cpan.org/modules/by-module/PDL/PDL-" version
".tar.gz"))
(sha256
(base32 "1zkp5pm351qjr6sb3xivpxy5vjfl72ns0hb4dx5vpm8xvgp7p92i"))))
(base32 "1zkp5pm351qjr6sb3xivpxy5vjfl72ns0hb4dx5vpm8xvgp7p92i"))
(patches
(search-patches "pdl-2.019-glut-bitmap-fonts.patch"))))
(build-system perl-build-system)
(arguments
`(#:phases