~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/glut/glx/glut_ppm.c

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2011-08-04 16:25:08 UTC
  • mfrom: (1.2.37 upstream)
  • Revision ID: james.westby@ubuntu.com-20110804162508-kujg82moxerjg1kk
Tags: 7.11-0ubuntu1
* Fake merge from Debian experimental, updating previous changelog entries.
  New upstream release fixes infrequent X crash (LP: #800778).
  Remaining Ubuntu changes:
 - debian/control
    + Drop lesstif-dev from Build-Depends; it's in Universe.
    + Comment out GLw libs since it depends on lesstif-dev.
    + Drop i686 swx11 libgl package.
    + Add libdrm-dev to mesa-common-dev Depends.
    + Drop libwayland-dev from Build-Depends; it's in Universe.
    + Update Breaks for Ubuntu versions
    + Enable llvm on armel as well as i386 and amd64
  - debian/rules
    + Use --disable-glw for swx11 targets too.
    + Don't enable motif for swx11 targets.
    + Use lzma compression for binary debs to save CD space.
    + Drop unloved mach64 driver.
    + Use --enable-shared-dricore to claw back CD space.
    + Enable llvmpipe software rasteriser.
    + Enable llvm on armel as well as i386 and amd64
  - debian/patches
    + 100_no_abi_tag.patch
    + 101_ubuntu_hidden_glname.patch
    + 103_savage-expose_fbmodes_with_nonzero_alpha.patch
  - rules, libgl1-mesa-{glx,dev,swx11,swx11-dev}.install.in,
    libgl1-mesa-{glx,swx11}.{postinst,prerm}.in, libgl1-mesa-dev.links.in:
    Install libGL.so* in /usr/lib/mesa to allow things to work with
    alternatives.
  - debian/not-installed:
    + Drop i686 files; we don't build 686-optimised packages in the first
      place.
  - debian/gbp.conf
    + Point at Ubuntu branch to make git-buildpackage less narky.
  - 113_fix_tls.diff: Fix crashes in unrelated code due to TLS usage.
  - debian/patches/111_export_searchdirs_in_dripc.diff:
    + Add drisearchdirs variable to dri.pc so the Xserver can pick up the
      alternate DRI driver dirs.
  - debian/patches/115_llvm_dynamic_linking.diff
    + Dynamically link DRI drivers to libllvm.  Saves ~6MiB per DRI driver.
  - debian/patches/116_use_shared_galliumcore.diff:
  - debian/libgl1-mesa-dri.install.in:
    + Link gallium DRI drivers against shared gallium routines to save CD
      space.
* debian/rules:
* debian/libgl1-mesa-dri-experimental.install.{i386,amd64}.in
  - Explicitly install i915g only when it has been built, matching what is
    done with r300g.
* debian/rules:
* debian/control:
* debian/libegl1-mesa{,-dev}.install.in:
* debian/libegl1-mesa.symbols:
  - Enable the Wayland EGL backend.
* debian/rules:
* debian/libegl1-mesa.{postinst,prerm,install}.in:
* debian/libegl1-mesa-dev.{install,links}.in:
* debian/libgles{1,2}-mesa.install.in:
* debian/libgles{1,2}-mesa-dev.links.in:
* debian/libopenvg1-mesa{,-dev}.install.in:
* debian/libopenvg1-mesa-dev.links.in:
  - Use alternatives for libEGL to match the handling of libGL.
    libEGL (and associated GL|ES and OpenVG libraries) now live in
    /usr/lib/$MULTIARCH/mesa-egl.  (LP: #812639)
* debian/patches/118_fix_24bpp_software_rendering.diff:
  - Cherry pick upstream patch from master fixing graphical corruption when
    using a 24bpp framebuffer and software rendering. (LP: #810339)
* debian/rules:
* debian/clean:
  - Generate xmlpool pot file and clean up other po files for
    pkgbinarymangler's benefit (LP: #410264).
* debian/patches/119_r600g_gnome_shell_rendering_fix.diff:
  - Cherry pick upstream commit fixing rendering corruption in gnome-shell
    (and therefore likely Unity as well).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * PPM file output
3
 
 * Brian Paul
4
 
 * 8 Dec 2008
5
 
 */
6
 
 
7
 
#include <assert.h>
8
 
#include <stdio.h>
9
 
#include <stdlib.h>
10
 
#include "glutint.h"
11
 
 
12
 
 
13
 
static void
14
 
write_ppm_file(const char *filename, const GLubyte *buffer,
15
 
               int width, int height)
16
 
{
17
 
   const int binary = 1;
18
 
   FILE *f = fopen( filename, "w" );
19
 
   if (f) {
20
 
      const GLubyte *ptr = buffer;
21
 
      int i, x, y;
22
 
      if (binary) {
23
 
         fprintf(f,"P6\n");
24
 
         fprintf(f,"# ppm-file created by GLUT\n");
25
 
         fprintf(f,"%i %i\n", width, height);
26
 
         fprintf(f,"255\n");
27
 
         fclose(f);
28
 
         f = fopen( filename, "ab" );  /* reopen in binary append mode */
29
 
         for (y = height - 1; y >= 0; y--) {
30
 
            for (x = 0; x < width; x++) {
31
 
               i = (y * width + x) * 4;
32
 
               fputc(ptr[i], f);   /* write red */
33
 
               fputc(ptr[i+1], f); /* write green */
34
 
               fputc(ptr[i+2], f); /* write blue */
35
 
            }
36
 
         }
37
 
      }
38
 
      else {
39
 
         /*ASCII*/
40
 
         int counter = 0;
41
 
         fprintf(f,"P3\n");
42
 
         fprintf(f,"# ascii ppm file created by GLUT\n");
43
 
         fprintf(f,"%i %i\n", width, height);
44
 
         fprintf(f,"255\n");
45
 
         for (y = height - 1; y >= 0; y--) {
46
 
            for (x = 0; x < width; x++) {
47
 
               i = (y * width + x) * 4;
48
 
               fprintf(f, " %3d %3d %3d", ptr[i], ptr[i+1], ptr[i+2]);
49
 
               counter++;
50
 
               if (counter % 5 == 0)
51
 
                  fprintf(f, "\n");
52
 
            }
53
 
         }
54
 
      }
55
 
      fclose(f);
56
 
   }
57
 
}
58
 
 
59
 
 
60
 
/**
61
 
 * Called from SwapBuffers if the GLUT_PPM_FILE env var is set.
62
 
 */
63
 
void __glutWritePPMFile(void)
64
 
{
65
 
   int w = glutGet(GLUT_WINDOW_WIDTH);
66
 
   int h = glutGet(GLUT_WINDOW_HEIGHT);
67
 
   GLubyte *buf;
68
 
 
69
 
   assert(__glutPPMFile);
70
 
 
71
 
   buf = (GLubyte *) malloc(w * h * 4);
72
 
   if (buf) {
73
 
      /* XXX save/restore pixel packing */
74
 
      glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buf);
75
 
      write_ppm_file(__glutPPMFile, buf, w, h);
76
 
      free(buf);
77
 
   }
78
 
 
79
 
   __glutPPMFile = NULL; /* only write one file */
80
 
}