This file is indexed.

/usr/lib/x86_64-linux-gnu/perl5/5.26/pods/SDL/Cookbook/OpenGL.pod is in libsdl-perl 2.546-3build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
=pod

=head1 NAME

SDL::Cookbook::OpenGL - Using SDL with OpenGL

=head1 CATEGORY

Cookbook

=head1 DESCRIPTION

As of release 2.5 SDL no longer maintains it's own bindings of OpenGL. Support for OpenGL has been moved over to a more mature implementation. 

This implementation is the POGL project. L<OpenGL> is faster and more complete; and works with SDL seamlessly.

=head2 EXAMPLE

Expanded from Floyd-ATC's OpenGL example.


	use strict;
	use warnings;
	use SDL;
	use SDLx::App;
	use SDL::Mouse;
	use SDL::Video;
	use SDL::Events;
	use SDL::Event;
	use OpenGL qw(:all);

You can use OpenGL as needed here.

	my ($SDLAPP, $WIDTH, $HEIGHT, $SDLEVENT);

	$| = 1;
	$WIDTH = 1024;
	$HEIGHT = 768;
	$SDLAPP = SDLx::App->new(title => "OpenGL App", width => $WIDTH, height => $HEIGHT, gl => 1);
	$SDLEVENT = SDL::Event->new;

SDLx::App can start an OpenGL application with the parameter gl => 1.

	glEnable(GL_DEPTH_TEST);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity;
	gluPerspective(60, $WIDTH / $HEIGHT, 1, 1000);
	glTranslatef(0, 0, -20);

Above we enable GL and set the correct perspective

	while (1) {
	  &handlepolls;
	  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	  glRotatef(.1, 1, 1, 1);
	  &drawscene;
	  $SDLAPP->sync;
	}

For SDLx::App sync handles the GL buffer clean.

	sub drawscene {
	  my ($color, $x, $y, $z);

	  for (-2 .. 2) {
	    glPushMatrix;
	    glTranslatef($_ * 3, 0, 0);
	    glColor3d(1, 0, 0);
	    &draw_cube;
	    glPopMatrix;
	  }

	  return "";
	}


	sub draw_cube {
	  my (@indices, @vertices, $face, $vertex, $index, $coords);

	  @indices = qw(4 5 6 7   1 2 6 5   0 1 5 4
			0 3 2 1   0 4 7 3   2 3 7 6);
	  @vertices = ([-1, -1, -1], [ 1, -1, -1],
		       [ 1,  1, -1], [-1,  1, -1],
		       [-1, -1,  1], [ 1, -1,  1],
		       [ 1,  1,  1], [-1,  1,  1]);

	  glBegin(GL_QUADS);

	  foreach my $face (0..5) {
	    foreach my $vertex (0..3) {
	      $index  = $indices[4 * $face + $vertex];
	      $coords = $vertices[$index];
	      
	      glVertex3d(@$coords);
	    }
	  }

	  glEnd;

	  return "";
	}

Below we can use SDL::Events as normal:

	sub handlepolls {
	  my ($type, $key);

	  SDL::Events::pump_events();

	  while (SDL::Events::poll_event($SDLEVENT)) {
	    $type = $SDLEVENT->type();
	    $key = ($type == 2 or $type == 3) ? $SDLEVENT->key_sym : "";

	    if ($type == 4) { printf("You moved the mouse! x=%s y=%s xrel=%s yrel=%s\n", $SDLEVENT->motion_x, $SDLEVENT->motion_y, $SDLEVENT->motion_xrel, $SDLEVENT->motion_yrel) }
	    elsif ($type == 2) { print "You are pressing $key\n" }
	    elsif ($type == 3) { print "You released $key\n" }
	    elsif ($type == 12) { exit }
	    else { print "TYPE $type UNKNOWN!\n" }

	    if ($type == 2) {
	      if ($key eq "q" or $key eq "escape") { exit }
	    }
	  }

	  return "";
	}

=head1 SEE ALSO

L<perl> L<SDLx::App> L<OpenGL> 

=head1 AUTHORS

See L<SDL/AUTHORS>.


=cut