Code released by upstream: v1.45
authorMiriam Ruiz <miriam@debian.org>
Wed, 3 Dec 2008 00:20:47 +0000 (3 01:20 +0100)
committerMiriam Ruiz <miriam@debian.org>
Wed, 3 Dec 2008 00:20:47 +0000 (3 01:20 +0100)
Example/Stunt.png [new file with mode: 0644]
Example/Test.c [new file with mode: 0644]
glpng.htm [new file with mode: 0644]
include/GL/glpng.h [new file with mode: 0644]
src/Makefile.LINUX [new file with mode: 0644]
src/Makefile.SGI [new file with mode: 0644]
src/glpng.c [new file with mode: 0644]
src/glpng.pro [new file with mode: 0644]

diff --git a/Example/Stunt.png b/Example/Stunt.png
new file mode 100644 (file)
index 0000000..19a9a4f
Binary files /dev/null and b/Example/Stunt.png differ
diff --git a/Example/Test.c b/Example/Test.c
new file mode 100644 (file)
index 0000000..bfdf97f
--- /dev/null
@@ -0,0 +1,110 @@
+/*\r
+ * Test program for glpng\r
+ * by Ben Wyatt ben@wyatt100.freeserve.co.uk\r
+ * Featuring a shameless plug for my stunt course program\r
+ * Available from the same site as glpng\r
+ * http://www.wyatt100.freeserve.co.uk/download.htm\r
+ */\r
+\r
+#include <gl/glpng.h>\r
+#include <gl/glut.h>\r
+#include <stdlib.h>\r
+\r
+int angle = 0;\r
+\r
+/***** GLUT callback functions *****/\r
+\r
+void KeyPress(unsigned char key, int x, int y) {\r
+       switch (key) {\r
+               case 27: /*ESC*/ glutDestroyWindow(glutGetWindow()); exit(0); break;\r
+       }\r
+}\r
+\r
+void Update(void) {\r
+       angle = (angle+1)%360;\r
+       glutPostRedisplay();\r
+}\r
+\r
+void Display(void) {\r
+       const float w = 2, h = 2;\r
+\r
+       glClear(GL_COLOR_BUFFER_BIT);\r
+\r
+       glLoadIdentity();\r
+       glTranslatef(0, 0, -10);\r
+       glRotatef(angle, 0, 1, 0);\r
+\r
+       glBegin(GL_QUADS);\r
+               // Front\r
+               glTexCoord2f(1, 1); glVertex3f( w, -h, 0);\r
+               glTexCoord2f(1, 0); glVertex3f( w,  h, 0);\r
+               glTexCoord2f(0, 0); glVertex3f(-w,  h, 0);\r
+               glTexCoord2f(0, 1); glVertex3f(-w, -h, 0);\r
+\r
+               // Back\r
+               glTexCoord2f(1, 1); glVertex3f(-w, -h, 0);\r
+               glTexCoord2f(1, 0); glVertex3f(-w,  h, 0);\r
+               glTexCoord2f(0, 0); glVertex3f( w,  h, 0);\r
+               glTexCoord2f(0, 1); glVertex3f( w, -h, 0);\r
+       glEnd();\r
+\r
+       glutSwapBuffers();\r
+}\r
+\r
+void Reshape(int w, int h) {\r
+       glViewport(0, 0, w, h);\r
+       \r
+       glMatrixMode(GL_PROJECTION);\r
+       glLoadIdentity();\r
+       gluPerspective(30, (float) w/h, 1, 100);\r
+\r
+       glMatrixMode(GL_MODELVIEW);\r
+       Display();\r
+}\r
+\r
+/***** Main function *****/\r
+\r
+void main() {\r
+       pngInfo info;\r
+       GLuint  texture;\r
+\r
+       glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);\r
+       glutInitWindowSize(300, 300);\r
+       glutCreateWindow("glpng test");\r
+\r
+       #if 0 // Using pngLoad and setting texture parameters manually.\r
+               glGenTextures(1, &texture);\r
+               glBindTexture(GL_TEXTURE_2D, texture);\r
+\r
+               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);\r
+               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);\r
+               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);\r
+               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);\r
+\r
+               if (!pngLoad("Stunt.png", PNG_NOMIPMAP, PNG_SOLID, &info)) {\r
+                       puts("Can't load file");\r
+                       exit(1);\r
+               }\r
+       #else // Using pngLoadAndBind to set texture parameters automatically.\r
+               texture = pngBind("Stunt.png", PNG_NOMIPMAP, PNG_ALPHA, &info, GL_CLAMP, GL_NEAREST, GL_NEAREST);\r
+\r
+               if (texture == 0) {\r
+                       puts("Can't load file");\r
+                       exit(1);\r
+               }\r
+       #endif\r
+\r
+       printf("Size=%i,%i Depth=%i Alpha=%i\n", info.Width, info.Height, info.Depth, info.Alpha);\r
+\r
+       glEnable(GL_TEXTURE_2D);\r
+       glBindTexture(GL_TEXTURE_2D, texture);\r
+       glEnable(GL_CULL_FACE);\r
+       glColor3f(1, 1, 1);\r
+\r
+       glutKeyboardFunc(KeyPress);\r
+       glutIdleFunc(Update);\r
+       glutDisplayFunc(Display);\r
+       glutReshapeFunc(Reshape);\r
+\r
+       glutMainLoop();\r
+}\r
diff --git a/glpng.htm b/glpng.htm
new file mode 100644 (file)
index 0000000..bc49d34
--- /dev/null
+++ b/glpng.htm
@@ -0,0 +1,442 @@
+<html>\r
+\r
+<head>\r
+<meta http-equiv="Content-Type"\r
+content="text/html; charset=iso-8859-1">\r
+<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">\r
+<title>glpng</title>\r
+</head>\r
+\r
+<body bgcolor="#FFFFFF">\r
+\r
+<h2 align="center">PNG loader library for OpenGL v1.45 (10/7/2000)</h2>\r
+\r
+<p align="center">Ben Wyatt <a\r
+href="mailto:ben@wyatt100.freeserve.co.uk">ben@wyatt100.freeserve.co.uk</a></p>\r
+\r
+<h3>Introduction</h3>\r
+\r
+<p>This is a library for OpenGL to load PNG graphics files as an\r
+OpenGL texture as easily as possible. It also has a number of\r
+options for generating the alpha channel and mipmaps. It is\r
+implemented using modified versions of the LibPNG 1.0.2 and ZLib\r
+1.1.3 libraries.</p>\r
+\r
+<p>This software is provided 'as-is', without any express or\r
+implied warranty. In no event will the author be held liable for\r
+any damages arising from the use of this software.</p>\r
+\r
+<p>Permission is hereby granted to use, copy, modify, and\r
+distribute this source code, or portions hereof, for any purpose,\r
+without fee, subject to the following restrictions:</p>\r
+\r
+<ol>\r
+    <li>The origin of this source code must not be misrepresented.\r
+        You must not claim that you wrote the original software.\r
+        If you use this software in a product, an acknowledgment\r
+        in the product documentation would be appreciated but is\r
+        not required.</li>\r
+    <li>Altered versions must be plainly marked as such and must\r
+        not be misrepresented as being the original source.</li>\r
+    <li>This notice must not be removed or altered from any\r
+        source distribution.</li>\r
+</ol>\r
+\r
+<h3>Installation for MSDEV</h3>\r
+\r
+<p>Copy glpng.h to your include/GL folder and copy glpng.lib and\r
+glpngd.lib to your lib folder. Then just do #include &lt;GL/glpng.h&gt;\r
+and with a bit of luck, MSDEV will automatically link with glpng.lib\r
+(release lib) or glpngd.lib (debug lib).</p>\r
+\r
+<h3>Installation for Any Other Compiler</h3>\r
+\r
+<p>Copy glpng.h to your include/GL folder. Then you'll have to\r
+build the library yourself with the included source code.\r
+Included are makefiles for Linux and SGI. If you need to modify\r
+the source code to make it work on your system, please get in\r
+contact so I can make future versions compatible.</p>\r
+\r
+<h3>Compiling with LibPNG or ZLib</h3>\r
+\r
+<p>If you are using LibPNG or ZLib in your project there may be\r
+problems if you link with the glpng library. To solve this,\r
+include glpng.c in your project and, if you're using MSDEV,\r
+modify glpng.h to not automatically link with glpng.lib or glpngd.lib.</p>\r
+\r
+<h3>OpenGL DLL Dynamic Loading using glsetup</h3>\r
+\r
+<p>To use glpng with glsetup, include glpng.c, LibPNG and ZLib in\r
+your project. In glpng.c, change #include &lt;GL/gl.h&gt; to\r
+include the glsetup include and modify glpng.h to not\r
+automatically link with glpng.lib or glpngd.lib.</p>\r
+\r
+<h3>Functions</h3>\r
+\r
+<ul>\r
+    <li><a href="#pngLoad">pngLoad</a></li>\r
+    <li><a href="#pngLoadF">pngLoadF</a></li>\r
+    <li><a href="#pngBind">pngBind</a></li>\r
+    <li><a href="#pngBindF">pngBindF</a></li>\r
+    <li><a href="#pngLoadRaw">pngLoadRaw</a></li>\r
+    <li><a href="#pngLoadRawF">pngLoadRawF</a></li>\r
+    <li><a href="#SetStencil">pngSetStencil</a></li>\r
+    <li><a href="#pngSetAlphaCallback">pngSetAlphaCallback</a></li>\r
+    <li><a href="#pngSetViewingGamma">pngSetViewingGamma</a></li>\r
+    <li><a href="#pngSetStandardOrientation">pngSetStandardOrientation</a></li>\r
+</ul>\r
+\r
+<pre><a name="pngLoad"><strong>success = pngLoad(filename, mipmap, trans, info)</strong></a></pre>\r
+\r
+<blockquote>\r
+    <table border="1">\r
+        <tr>\r
+            <td valign="top">filename</td>\r
+            <td>Filename of PNG file, including &quot;.png&quot;</td>\r
+        </tr>\r
+        <tr>\r
+            <td valign="top">mipmap</td>\r
+            <td>Mipmapping parameter:<ul>\r
+                <li>0 or PNG_NOMIPMAP if no mipmap or for the\r
+                    base mipmap level</li>\r
+                <li>1,2,3... for mipmap detail level</li>\r
+                <li>PNG_BUILDMIPMAPS to call a clone of gluBuild2DMipmaps\r
+                    (box filter)</li>\r
+                <li>PNG_SIMPLEMIPMAPS to generate mipmaps without\r
+                    filtering (uses upper-left of each 2x2 box)</li>\r
+            </ul>\r
+            </td>\r
+        </tr>\r
+        <tr>\r
+            <td valign="top">trans</td>\r
+            <td>Transparency setting:<ul>\r
+                <li>PNG_ALPHA to use alpha channel in PNG file,\r
+                    if there is one</li>\r
+                <li>PNG_SOLID for no transparency</li>\r
+                <li><a name="PNG_STENCIL">PNG_STENCIL</a> to set\r
+                    pixels of a certain value to alpha 0,\r
+                    otherwise 1 (see <a href="#SetStencil">pngSetStencil</a>)</li>\r
+                <li>PNG_BLEND1 to set alpha to r+g+b</li>\r
+                <li>PNG_BLEND2 to set alpha to (r+g+b)/2</li>\r
+                <li>PNG_BLEND3 to set alpha to (r+g+b)/3</li>\r
+                <li>PNG_BLEND4 to set alpha to r<sup>2</sup>+g<sup>2</sup>+b<sup>2</sup></li>\r
+                <li>PNG_BLEND5 to set alpha to (r<sup>2</sup>+g<sup>2</sup>+b<sup>2</sup>)/2</li>\r
+                <li>PNG_BLEND6 to set alpha to (r<sup>2</sup>+g<sup>2</sup>+b<sup>2</sup>)/3</li>\r
+                <li>PNG_BLEND7 to set alpha to (r<sup>2</sup>+g<sup>2</sup>+b<sup>2</sup>)/4</li>\r
+                <li>PNG_BLEND8 to set alpha to sqrt(r<sup>2</sup>+g<sup>2</sup>+b<sup>2</sup>)</li>\r
+                <li><a name="PNG_CALLBACK">PNG_CALLBACK</a> to\r
+                    use the callback function defined by <a\r
+                    href="#pngSetAlphaCallback">pngSetAlphaCallback</a>.</li>\r
+            </ul>\r
+            </td>\r
+        </tr>\r
+        <tr>\r
+            <td valign="top">info</td>\r
+            <td>Pointer to a pngInfo structure to store texture\r
+            info or NULL if you don't care. The pngInfo fields\r
+            are:<ul>\r
+                <li>Width - width of the original image in pixels</li>\r
+                <li>Height - height of the original image in\r
+                    pixels</li>\r
+                <li>Depth - depth of the original image, where\r
+                    colours = 2<sup>Depth</sup></li>\r
+                <li>Alpha - the number of bits used for the alpha\r
+                    channel (0 if no alpha channel)</li>\r
+            </ul>\r
+            </td>\r
+        </tr>\r
+    </table>\r
+    <p>Loads a PNG file and calls glTexImage2D with appropriate\r
+    parameters. The texture will be resized if the dimensions are\r
+    not powers of 2 or over the maximum texture size. Should be\r
+    able to load all colour depths (except 64-bit) and alpha\r
+    channels if available. It converts them to an appropriate\r
+    format and gives them to glTexImage2D. The OpenGL paletted\r
+    texture extension is used if available.</p>\r
+    <p>Returns 1 on success or 0 if file could not be loaded.</p>\r
+</blockquote>\r
+\r
+<pre><a name="pngLoadF"><strong>success = pngLoadF(file, mipmap, trans, info)</strong></a></pre>\r
+\r
+<blockquote>\r
+    <table border="1">\r
+        <tr>\r
+            <td valign="top">file</td>\r
+            <td>FILE opened with fopen(&quot;something.png&quot;,\r
+            &quot;rb&quot;)</td>\r
+        </tr>\r
+    </table>\r
+    <p>This is used to load a PNG from an already opened file.\r
+    Handy if you want to batch all your data and textures into\r
+    one big data file.</p>\r
+</blockquote>\r
+\r
+<pre><a name="pngBind"><strong>id = pngBind(filename, mipmap, trans, info, wrapst, minfilter, magfilter)</strong></a><strong>\r
+</strong><a name="pngBindF"><strong>id = pngBindF(file, mipmap, trans, info, wrapst, minfilter, magfilter)</strong></a></pre>\r
+\r
+<blockquote>\r
+    <table border="1">\r
+        <tr>\r
+            <td valign="top">wrapst</td>\r
+            <td>GL_CLAMP or GL_REPEAT (look up glTexParameter)</td>\r
+        </tr>\r
+        <tr>\r
+            <td valign="top">minfilter</td>\r
+            <td>Minification function for filtering (look up\r
+            glTexParameter)</td>\r
+        </tr>\r
+        <tr>\r
+            <td valign="top">magfilter</td>\r
+            <td>Magnification function for filtering (look up\r
+            glTexParamter)</td>\r
+        </tr>\r
+    </table>\r
+    <p>Automates the process further - loads a PNG file, sets the\r
+    OpenGL parameters, binds it to an OpenGL texture and returns\r
+    it's ID, or 0 if the file couldn't be loaded.</p>\r
+</blockquote>\r
+\r
+<pre><a name="pngLoadRaw"><strong>success = pngLoadRaw(filename, rawinfo)</strong></a><strong>\r
+</strong><a name="pngLoadRawF"><strong>success = pngLoadRawF(file, rawinfo)</strong></a></pre>\r
+\r
+<blockquote>\r
+    <table border="1">\r
+        <tr>\r
+            <td valign="top">rawinfo</td>\r
+            <td>Pointer to a pngRawInfo structure in which to\r
+            store the PNG data. The pngRawInfo has these fields:<ul>\r
+                <li>Width, Height, Depth, Alpha - as in pngInfo</li>\r
+                <li>Components - number of colour components (1,\r
+                    2, 3 or 4)</li>\r
+                <li>Data - pointer to image data stored as RGBRGB...\r
+                    or RGBARGBA... or indices to the palette\r
+                    table. Must be freed manually using free()</li>\r
+                <li>Palette - pointer to palette table stored as\r
+                    RGBRGB... or RGBARGBA... Will be NULL if\r
+                    there is no palette table. Must be freed\r
+                    manually using free()</li>\r
+            </ul>\r
+            </td>\r
+        </tr>\r
+    </table>\r
+</blockquote>\r
+\r
+<pre><a name="SetStencil"><strong>pngSetStencil(red, green, blue)</strong></a></pre>\r
+\r
+<blockquote>\r
+    <table border="1">\r
+        <tr>\r
+            <td valign="top">red,green,blue</td>\r
+            <td>The colour to stencil out when using the <a\r
+            href="#PNG_STENCIL">PNG_STENCIL</a> option</td>\r
+        </tr>\r
+    </table>\r
+</blockquote>\r
+\r
+<blockquote>\r
+    <p>This selects the colour to stencil out when using <a\r
+    href="#PNG_STENCIL">PNG_STENCIL</a>. The parameters are 0 to\r
+    255. By default the colour is 0,0,0 (pure black).</p>\r
+</blockquote>\r
+\r
+<pre><a name="pngSetAlphaCallback"><strong>pngSetAlphaCallback(function)</strong></a></pre>\r
+\r
+<blockquote>\r
+    <table border="1">\r
+        <tr>\r
+            <td valign="top">function</td>\r
+            <td>Pointer to a function taking three unsigned char\r
+            parameters (red, green, blue) and returning an\r
+            unsigned char (alpha)</td>\r
+        </tr>\r
+    </table>\r
+</blockquote>\r
+\r
+<blockquote>\r
+    <p>This sets the function to be called when using <a\r
+    href="#PNG_CALLBACK">PNG_CALLBACK</a>. During the alpha\r
+    channel generation process, this function will be called for\r
+    every pixel, with the appropriate RGB values, and will use\r
+    the result for the alpha value. The RGB and alpha values all\r
+    range from 0 to 255. The default callback function simply\r
+    returns 255.</p>\r
+</blockquote>\r
+\r
+<pre><a name="pngSetViewingGamma"><strong>pngSetViewingGamma(gamma)</strong></a></pre>\r
+\r
+<blockquote>\r
+    <table border="1">\r
+        <tr>\r
+            <td valign="top">gamma</td>\r
+            <td>New gamma correction value</td>\r
+        </tr>\r
+    </table>\r
+    <p>By default, gamma correction is set to 1.0 for Windows, 1.7\r
+    for SGI and 1.45 for Macs. If the VIEWING_GAMMA environmental\r
+    variable is set, that is used instead. You can override both\r
+    of these values using pngSetViewingGamma().</p>\r
+</blockquote>\r
+\r
+<pre><a name="pngSetStandardOrientation"><strong>pngSetStandardOrientation(standardorientation)</strong></a></pre>\r
+\r
+<blockquote>\r
+    <table border="1">\r
+        <tr>\r
+            <td>standardorientation</td>\r
+            <td>If to use the standard orientation (0 is default)</td>\r
+        </tr>\r
+    </table>\r
+    <p>By default, the image is loaded so that texture\r
+    coordinates 0,0 represent the top-left - a result of me not\r
+    knowing the OpenGL spec :-). If you wish to use the standard\r
+    OpenGL representation where 0,0 is the bottom-left, set this\r
+    to 1.</p>\r
+</blockquote>\r
+\r
+<h3>Examples</h3>\r
+\r
+<p>Here's an example of pngLoad(), to load &quot;Texture.png&quot;\r
+with nearest filter, clamping on and no mipmaps or alpha channels...</p>\r
+\r
+<blockquote>\r
+    <pre>pngInfo info;\r
+GLuint id;</pre>\r
+    <pre>glGenTextures(1, &amp;id);\r
+glBindTexture(GL_TEXTURE_2D, id);</pre>\r
+    <pre>glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);\r
+glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);\r
+glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);\r
+glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);</pre>\r
+    <pre>if (pngLoad(&quot;Texture.png&quot;, PNG_NOMIPMAP, PNG_SOLID, &amp;info)) {\r
+   puts(&quot;Loaded Texture.png with resounding success&quot;);\r
+   printf(&quot;Size=%i,%i Depth=%i Alpha=%i\n&quot;, info.Width, info.Height, info.Depth, info.Alpha);\r
+}\r
+else {\r
+   puts(&quot;Can't load Texture.png&quot;);\r
+   exit(1);\r
+}</pre>\r
+</blockquote>\r
+\r
+<p>And here's an example to load the same texture with the same\r
+options using pngBind()...</p>\r
+\r
+<blockquote>\r
+    <pre>pngInfo info;\r
+GLuint id = pngBind(&quot;Texture.png&quot;, PNG_NOMIPMAP, PNG_SOLID, &amp;info, GL_CLAMP, GL_NEAREST, GL_NEAREST);</pre>\r
+    <pre>if (id != 0) {\r
+   puts(&quot;Loaded Texture.png with resounding success&quot;);\r
+   printf(&quot;Size=%i,%i Depth=%i Alpha=%i\n&quot;, info.Width, info.Height, info.Depth, info.Alpha);\r
+}\r
+else {\r
+   puts(&quot;Can't load Texture.png&quot;);\r
+   exit(1);\r
+}</pre>\r
+</blockquote>\r
+\r
+<p>If those two examples don't make sense, try the included full\r
+source example (which needs <a\r
+href="http://reality.sgi.com/opengl/glut3/glut3.html">GLUT</a>).</p>\r
+\r
+<h3>Bugs</h3>\r
+\r
+<ul>\r
+    <li>64-bit PNGs can't be loaded (missing LibPNG feature as\r
+        far as I can tell).</li>\r
+</ul>\r
+\r
+<h3>Possible Future Developments</h3>\r
+\r
+<ul>\r
+    <li>Better attempts could be made to find the optimal texture\r
+        format for OpenGL. At the moment, it converts everything\r
+        to 24 or 32 bit, or uses the paletted texture extension\r
+        in certain (easy to handle) cases.</li>\r
+    <li>Other mipmap generating algorithms could be implemented (wavelet\r
+        stuff?). Source donations are welcome.</li>\r
+    <li>Saving the frame buffer to a PNG file.</li>\r
+    <li>Support for GL_INTENSITY, GL_LUMINANCE_ALPHA and others.</li>\r
+</ul>\r
+\r
+<h3>History</h3>\r
+\r
+<table border="0">\r
+    <tr>\r
+        <td valign="top" nowrap>1.33 (20/5/99)</td>\r
+        <td valign="top">First public release.</td>\r
+    </tr>\r
+    <tr>\r
+        <td valign="top" nowrap>1.34 (27/5/99)</td>\r
+        <td valign="top">Optimised alpha channel generating,\r
+        added Alpha property to the pngInfo structure, illegal\r
+        texture sizes are resized.</td>\r
+    </tr>\r
+    <tr>\r
+        <td valign="top" nowrap>1.35 (4/6/99)</td>\r
+        <td valign="top">Added pngLoadRaw and pngLoadRawF\r
+        functions.</td>\r
+    </tr>\r
+    <tr>\r
+        <td valign="top" nowrap>1.36 (9/6/99)</td>\r
+        <td valign="top">Fixed problem causing linking warnings/errors\r
+        (I think) and reduced the size of the library\r
+        considerably.</td>\r
+    </tr>\r
+    <tr>\r
+        <td valign="top" nowrap>1.37 (13/6/99)</td>\r
+        <td valign="top">Added alpha channel generation callback\r
+        function.</td>\r
+    </tr>\r
+    <tr>\r
+        <td valign="top" nowrap>1.38 (22/6/99)</td>\r
+        <td valign="top">Stopped it from disabling texturing on\r
+        calls to pngBind and pngBindF.</td>\r
+    </tr>\r
+    <tr>\r
+        <td valign="top" nowrap>1.39 (8/7/99)</td>\r
+        <td valign="top">Fixed a bug in the extensions reading\r
+        code, which caused some machines to crash.</td>\r
+    </tr>\r
+    <tr>\r
+        <td valign="top" nowrap>1.40 (27/9/99)</td>\r
+        <td valign="top">Added support for SGI, Linux, and gamma\r
+        correction (thanks to Mark B. Allan!). Fixed bug in raw\r
+        reading of gray textures (thanks to Johann Scholtz!).\r
+        Removed all use of GLU functions to make it easier to\r
+        dynamically load opengl32.dll or 3dfxvgl.dll or whatever.\r
+        Added simple mipmap generator.</td>\r
+    </tr>\r
+    <tr>\r
+        <td valign="top" nowrap>1.41 (20/10/99)</td>\r
+        <td valign="top">Made a small optimisation and improved\r
+        documentation. Remembered to include the makefiles for\r
+        Linux and SGI in the zip (!).</td>\r
+    </tr>\r
+    <tr>\r
+        <td valign="top" nowrap>1.42 (01/03/00)</td>\r
+        <td valign="top">Fixed problems with compiling on SGI (thanks\r
+        to Thomas Sondergaard!). Added pngSetStandardOrientation\r
+        (thanks to Scott Franke!).</td>\r
+    </tr>\r
+    <tr>\r
+        <td valign="top" nowrap>1.43 (11/05/00)</td>\r
+        <td valign="top">Added debug library and fixed the crash\r
+        when there wasn't a terminating png info structure (thanks\r
+        to Dan Hawkins!).</td>\r
+    </tr>\r
+    <tr>\r
+        <td valign="top" nowrap>1.44 (01/07/00)</td>\r
+        <td valign="top">Fixed release and debug libraries so\r
+        they stop producing warnings and errors in MSDEV.</td>\r
+    </tr>\r
+    <tr>\r
+        <td valign="top" nowrap>1.45 (10/07/00)</td>\r
+        <td valign="top">Fixed bug where the standard orientation\r
+        flag was being ignored in pngLoadRawF (thanks to Mark B.\r
+        Allan!).</td>\r
+    </tr>\r
+</table>\r
+\r
+<p>Get the latest version from <a\r
+href="http://www.wyatt100.freeserve.co.uk/download.htm">http://www.wyatt100.freeserve.co.uk/download.htm</a></p>\r
+</body>\r
+</html>\r
diff --git a/include/GL/glpng.h b/include/GL/glpng.h
new file mode 100644 (file)
index 0000000..b98ab88
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * PNG loader library for OpenGL v1.45 (10/07/00)
+ * by Ben Wyatt ben@wyatt100.freeserve.co.uk
+ * Using LibPNG 1.0.2 and ZLib 1.1.3
+ *\r
+ * This software is provided 'as-is', without any express or implied warranty.\r
+ * In no event will the author be held liable for any damages arising from the\r
+ * use of this software.\r
+ *\r
+ * Permission is hereby granted to use, copy, modify, and distribute this\r
+ * source code, or portions hereof, for any purpose, without fee, subject to\r
+ * the following restrictions:\r
+ *\r
+ * 1. The origin of this source code must not be misrepresented. You must not\r
+ *    claim that you wrote the original software. If you use this software in\r
+ *    a product, an acknowledgment in the product documentation would be\r
+ *    appreciated but is not required.\r
+ * 2. Altered versions must be plainly marked as such and must not be\r
+ *    misrepresented as being the original source.\r
+ * 3. This notice must not be removed or altered from any source distribution.\r
+ */
+
+#ifndef _GLPNG_H_
+#define _GLPNG_H_
+
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef _MSC_VER
+       #ifdef _DEBUG\r
+               #pragma comment (lib, "glpngd.lib")\r
+       #else\r
+               #pragma comment (lib, "glpng.lib")\r
+       #endif
+#endif
+
+/* XXX This is from Win32's <windef.h> */
+#ifndef APIENTRY
+       #if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
+               #define APIENTRY    __stdcall
+       #else
+               #define APIENTRY
+       #endif
+#endif
+
+/* Mipmapping parameters */
+#define PNG_NOMIPMAPS      0 /* No mipmapping                        */
+#define PNG_BUILDMIPMAPS  -1 /* Calls a clone of gluBuild2DMipmaps() */\r
+#define PNG_SIMPLEMIPMAPS -2 /* Generates mipmaps without filtering  */\r
+\r
+/* Who needs an "S" anyway? */\r
+#define PNG_NOMIPMAP     PNG_NOMIPMAPS\r
+#define PNG_BUILDMIPMAP  PNG_BUILDMIPMAPS\r
+#define PNG_SIMPLEMIPMAP PNG_SIMPLEMIPMAPS\r
+
+/* Transparency parameters */\r
+#define PNG_CALLBACK  -3 /* Call the callback function to generate alpha   */
+#define PNG_ALPHA     -2 /* Use alpha channel in PNG file, if there is one */
+#define PNG_SOLID     -1 /* No transparency                                */
+#define PNG_STENCIL    0 /* Sets alpha to 0 for r=g=b=0, 1 otherwise       */
+#define PNG_BLEND1     1 /* a = r+g+b                                      */
+#define PNG_BLEND2     2 /* a = (r+g+b)/2                                  */
+#define PNG_BLEND3     3 /* a = (r+g+b)/3                                  */
+#define PNG_BLEND4     4 /* a = r*r+g*g+b*b                                */
+#define PNG_BLEND5     5 /* a = (r*r+g*g+b*b)/2                            */
+#define PNG_BLEND6     6 /* a = (r*r+g*g+b*b)/3                            */
+#define PNG_BLEND7     7 /* a = (r*r+g*g+b*b)/4                            */
+#define PNG_BLEND8     8 /* a = sqrt(r*r+g*g+b*b)                          */
+
+typedef struct {
+       unsigned int Width;
+       unsigned int Height;
+       unsigned int Depth;
+       unsigned int Alpha;
+} pngInfo;
+
+typedef struct {
+       unsigned int Width;
+       unsigned int Height;
+       unsigned int Depth;
+       unsigned int Alpha;
+
+       unsigned int Components;
+       unsigned char *Data;
+       unsigned char *Palette;
+} pngRawInfo;
+
+extern int APIENTRY pngLoadRaw(const char *filename, pngRawInfo *rawinfo);
+extern int APIENTRY pngLoadRawF(FILE *file, pngRawInfo *rawinfo);
+
+extern int APIENTRY pngLoad(const char *filename, int mipmap, int trans, pngInfo *info);
+extern int APIENTRY pngLoadF(FILE *file, int mipmap, int trans, pngInfo *info);
+
+extern unsigned int APIENTRY pngBind(const char *filename, int mipmap, int trans, pngInfo *info, int wrapst, int minfilter, int magfilter);
+extern unsigned int APIENTRY pngBindF(FILE *file, int mipmap, int trans, pngInfo *info, int wrapst, int minfilter, int magfilter);
+
+extern void APIENTRY pngSetStencil(unsigned char red, unsigned char green, unsigned char blue);
+extern void APIENTRY pngSetAlphaCallback(unsigned char (*callback)(unsigned char red, unsigned char green, unsigned char blue));
+extern void APIENTRY pngSetViewingGamma(double viewingGamma);
+extern void APIENTRY pngSetStandardOrientation(int standardorientation);\r
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/Makefile.LINUX b/src/Makefile.LINUX
new file mode 100644 (file)
index 0000000..55d1fc2
--- /dev/null
@@ -0,0 +1,250 @@
+#############################################################################
+# Makefile for building libglpng.a
+# Generated by tmake at 17:31, 1999/08/27
+#     Project: glpng
+#    Template: lib
+#############################################################################
+
+####### Compiler, tools and options
+
+CC     =       gcc
+CXX    =       g++
+CFLAGS =       -pipe -Wall -W -O2 -fno-strength-reduce
+CXXFLAGS=      -pipe -Wall -W -O2 -fno-strength-reduce
+INCPATH        =       -I../include
+AR     =       ar cqs
+RANLIB =       
+MOC    =       moc
+
+TAR    =       tar -cf
+GZIP   =       gzip -9f
+
+####### Files
+
+HEADERS =      png/png.h \
+               png/pngconf.h \
+               zlib/infblock.h \
+               zlib/infcodes.h \
+               zlib/inffast.h \
+               zlib/inffixed.h \
+               zlib/inftrees.h \
+               zlib/infutil.h \
+               zlib/zconf.h \
+               zlib/zlib.h \
+               zlib/zutil.h
+SOURCES =      glpng.c \
+               png/png.c \
+               png/pngerror.c \
+               png/pngget.c \
+               png/pngmem.c \
+               png/pngpread.c \
+               png/pngread.c \
+               png/pngrio.c \
+               png/pngrtran.c \
+               png/pngrutil.c \
+               png/pngset.c \
+               png/pngtrans.c \
+               zlib/adler32.c \
+               zlib/crc32.c \
+               zlib/infblock.c \
+               zlib/infcodes.c \
+               zlib/inffast.c \
+               zlib/inflate.c \
+               zlib/inftrees.c \
+               zlib/infutil.c \
+               zlib/zutil.c
+OBJECTS =      glpng.o \
+               png/png.o \
+               png/pngerror.o \
+               png/pngget.o \
+               png/pngmem.o \
+               png/pngpread.o \
+               png/pngread.o \
+               png/pngrio.o \
+               png/pngrtran.o \
+               png/pngrutil.o \
+               png/pngset.o \
+               png/pngtrans.o \
+               zlib/adler32.o \
+               zlib/crc32.o \
+               zlib/infblock.o \
+               zlib/infcodes.o \
+               zlib/inffast.o \
+               zlib/inflate.o \
+               zlib/inftrees.o \
+               zlib/infutil.o \
+               zlib/zutil.o
+SRCMOC =       
+OBJMOC =       
+DIST   =       
+TARGET =       libglpng.a
+
+####### Implicit rules
+
+.SUFFIXES: .cpp .cxx .cc .C .c
+
+.cpp.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cxx.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cc.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.C.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.c.o:
+       $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
+
+####### Build rules
+
+all: $(TARGET)
+
+staticlib: $(TARGET)
+
+$(TARGET): $(OBJECTS) $(OBJMOC) 
+       -rm -f ../lib/$(TARGET)
+       $(AR) $(TARGET) $(OBJECTS) $(OBJMOC)
+       mv $(TARGET) ../lib
+
+moc: $(SRCMOC)
+
+tmake: Makefile
+
+Makefile: glpng.pro
+       tmake glpng.pro -o Makefile
+
+dist:
+       $(TAR) glpng.tar glpng.pro $(SOURCES) $(HEADERS) $(DIST)
+       $(GZIP) glpng.tar
+
+clean:
+       -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(TARGET)
+       -rm -f *~ core *.bck
+
+####### Compile
+
+glpng.o: glpng.c \
+               png/png.h
+
+png/png.o: png/png.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngerror.o: png/pngerror.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngget.o: png/pngget.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngmem.o: png/pngmem.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngpread.o: png/pngpread.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngread.o: png/pngread.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngrio.o: png/pngrio.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngrtran.o: png/pngrtran.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngrutil.o: png/pngrutil.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngset.o: png/pngset.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngtrans.o: png/pngtrans.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+zlib/adler32.o: zlib/adler32.c \
+               zlib/zlib.h \
+               zlib/zconf.h
+
+zlib/crc32.o: zlib/crc32.c \
+               zlib/zlib.h \
+               zlib/zconf.h
+
+zlib/infblock.o: zlib/infblock.c \
+               zlib/zutil.h \
+               zlib/zlib.h \
+               zlib/zconf.h \
+               zlib/infblock.h \
+               zlib/inftrees.h \
+               zlib/infcodes.h \
+               zlib/infutil.h
+
+zlib/infcodes.o: zlib/infcodes.c \
+               zlib/zutil.h \
+               zlib/zlib.h \
+               zlib/zconf.h \
+               zlib/inftrees.h \
+               zlib/infblock.h \
+               zlib/infcodes.h \
+               zlib/infutil.h \
+               zlib/inffast.h
+
+zlib/inffast.o: zlib/inffast.c \
+               zlib/zutil.h \
+               zlib/zlib.h \
+               zlib/zconf.h \
+               zlib/inftrees.h \
+               zlib/infblock.h \
+               zlib/infcodes.h \
+               zlib/infutil.h \
+               zlib/inffast.h
+
+zlib/inflate.o: zlib/inflate.c \
+               zlib/zutil.h \
+               zlib/zlib.h \
+               zlib/zconf.h \
+               zlib/infblock.h
+
+zlib/inftrees.o: zlib/inftrees.c \
+               zlib/zutil.h \
+               zlib/zlib.h \
+               zlib/zconf.h \
+               zlib/inftrees.h \
+               zlib/inffixed.h
+
+zlib/infutil.o: zlib/infutil.c \
+               zlib/zutil.h \
+               zlib/zlib.h \
+               zlib/zconf.h \
+               zlib/infblock.h \
+               zlib/inftrees.h \
+               zlib/infcodes.h \
+               zlib/infutil.h
+
+zlib/zutil.o: zlib/zutil.c \
+               zlib/zutil.h \
+               zlib/zlib.h \
+               zlib/zconf.h
+
diff --git a/src/Makefile.SGI b/src/Makefile.SGI
new file mode 100644 (file)
index 0000000..cbcd271
--- /dev/null
@@ -0,0 +1,250 @@
+#############################################################################
+# Makefile for building libglpng.a
+# Generated by tmake at 13:41, 1999/08/27
+#     Project: glpng
+#    Template: lib
+#############################################################################
+
+####### Compiler, tools and options
+
+CC     =       CC
+CXX    =       CC
+CFLAGS =       -n32 LANG:bool\=ON -woff 3201,1209,1233,1314,1355,1375,1506 -fullwarn -DSGI
+CXXFLAGS=      -n32 LANG:bool\=ON -woff 3201,1209,1233,1314,1355,1375,1506 -fullwarn -DSGI
+INCPATH        =       -I../include
+AR     =       ar cq
+RANLIB =       
+MOC    =       moc
+
+TAR    =       tar -cf
+GZIP   =       gzip -9f
+
+####### Files
+
+HEADERS =      png/png.h \
+               png/pngconf.h \
+               zlib/infblock.h \
+               zlib/infcodes.h \
+               zlib/inffast.h \
+               zlib/inffixed.h \
+               zlib/inftrees.h \
+               zlib/infutil.h \
+               zlib/zconf.h \
+               zlib/zlib.h \
+               zlib/zutil.h
+SOURCES =      glpng.c \
+               png/png.c \
+               png/pngerror.c \
+               png/pngget.c \
+               png/pngmem.c \
+               png/pngpread.c \
+               png/pngread.c \
+               png/pngrio.c \
+               png/pngrtran.c \
+               png/pngrutil.c \
+               png/pngset.c \
+               png/pngtrans.c \
+               zlib/adler32.c \
+               zlib/crc32.c \
+               zlib/infblock.c \
+               zlib/infcodes.c \
+               zlib/inffast.c \
+               zlib/inflate.c \
+               zlib/inftrees.c \
+               zlib/infutil.c \
+               zlib/zutil.c
+OBJECTS =      glpng.o \
+               png/png.o \
+               png/pngerror.o \
+               png/pngget.o \
+               png/pngmem.o \
+               png/pngpread.o \
+               png/pngread.o \
+               png/pngrio.o \
+               png/pngrtran.o \
+               png/pngrutil.o \
+               png/pngset.o \
+               png/pngtrans.o \
+               zlib/adler32.o \
+               zlib/crc32.o \
+               zlib/infblock.o \
+               zlib/infcodes.o \
+               zlib/inffast.o \
+               zlib/inflate.o \
+               zlib/inftrees.o \
+               zlib/infutil.o \
+               zlib/zutil.o
+SRCMOC =       
+OBJMOC =       
+DIST   =       
+TARGET =       libglpng.a
+
+####### Implicit rules
+
+.SUFFIXES: .cpp .cxx .cc .C .c
+
+.cpp.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cxx.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cc.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.C.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.c.o:
+       $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
+
+####### Build rules
+
+all: $(TARGET)
+
+staticlib: $(TARGET)
+
+$(TARGET): $(OBJECTS) $(OBJMOC) 
+       -rm -f $(TARGET)
+       $(AR) $(TARGET) $(OBJECTS) $(OBJMOC)
+
+moc: $(SRCMOC)
+
+tmake: Makefile
+
+Makefile: glpng.pro
+       tmake glpng.pro -o Makefile
+
+dist:
+       $(TAR) glpng.tar glpng.pro $(SOURCES) $(HEADERS) $(DIST)
+       $(GZIP) glpng.tar
+
+clean:
+       -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(TARGET)
+       -rm -f so_locations
+       -rm -f *~ core
+
+####### Compile
+
+glpng.o: glpng.c \
+               png/png.h
+
+png/png.o: png/png.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngerror.o: png/pngerror.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngget.o: png/pngget.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngmem.o: png/pngmem.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngpread.o: png/pngpread.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngread.o: png/pngread.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngrio.o: png/pngrio.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngrtran.o: png/pngrtran.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngrutil.o: png/pngrutil.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngset.o: png/pngset.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+png/pngtrans.o: png/pngtrans.c \
+               png/png.h \
+               png/../zlib/zlib.h \
+               png/pngconf.h
+
+zlib/adler32.o: zlib/adler32.c \
+               zlib/zlib.h \
+               zlib/zconf.h
+
+zlib/crc32.o: zlib/crc32.c \
+               zlib/zlib.h \
+               zlib/zconf.h
+
+zlib/infblock.o: zlib/infblock.c \
+               zlib/zutil.h \
+               zlib/zlib.h \
+               zlib/zconf.h \
+               zlib/infblock.h \
+               zlib/inftrees.h \
+               zlib/infcodes.h \
+               zlib/infutil.h
+
+zlib/infcodes.o: zlib/infcodes.c \
+               zlib/zutil.h \
+               zlib/zlib.h \
+               zlib/zconf.h \
+               zlib/inftrees.h \
+               zlib/infblock.h \
+               zlib/infcodes.h \
+               zlib/infutil.h \
+               zlib/inffast.h
+
+zlib/inffast.o: zlib/inffast.c \
+               zlib/zutil.h \
+               zlib/zlib.h \
+               zlib/zconf.h \
+               zlib/inftrees.h \
+               zlib/infblock.h \
+               zlib/infcodes.h \
+               zlib/infutil.h \
+               zlib/inffast.h
+
+zlib/inflate.o: zlib/inflate.c \
+               zlib/zutil.h \
+               zlib/zlib.h \
+               zlib/zconf.h \
+               zlib/infblock.h
+
+zlib/inftrees.o: zlib/inftrees.c \
+               zlib/zutil.h \
+               zlib/zlib.h \
+               zlib/zconf.h \
+               zlib/inftrees.h \
+               zlib/inffixed.h
+
+zlib/infutil.o: zlib/infutil.c \
+               zlib/zutil.h \
+               zlib/zlib.h \
+               zlib/zconf.h \
+               zlib/infblock.h \
+               zlib/inftrees.h \
+               zlib/infcodes.h \
+               zlib/infutil.h
+
+zlib/zutil.o: zlib/zutil.c \
+               zlib/zutil.h \
+               zlib/zlib.h \
+               zlib/zconf.h
+
diff --git a/src/glpng.c b/src/glpng.c
new file mode 100644 (file)
index 0000000..1ddceac
--- /dev/null
@@ -0,0 +1,707 @@
+/*\r
+ * PNG loader library for OpenGL v1.45 (10/07/00)\r
+ * by Ben Wyatt ben@wyatt100.freeserve.co.uk\r
+ * Using LibPNG 1.0.2 and ZLib 1.1.3\r
+ *\r
+ * This software is provided 'as-is', without any express or implied warranty.\r
+ * In no event will the author be held liable for any damages arising from the\r
+ * use of this software.\r
+ *\r
+ * Permission is hereby granted to use, copy, modify, and distribute this\r
+ * source code, or portions hereof, for any purpose, without fee, subject to\r
+ * the following restrictions:\r
+ *\r
+ * 1. The origin of this source code must not be misrepresented. You must not\r
+ *    claim that you wrote the original software. If you use this software in\r
+ *    a product, an acknowledgment in the product documentation would be\r
+ *    appreciated but is not required.\r
+ * 2. Altered versions must be plainly marked as such and must not be\r
+ *    misrepresented as being the original source.\r
+ * 3. This notice must not be removed or altered from any source distribution.\r
+ */\r
+\r
+#ifdef _WIN32 /* Stupid Windows needs to include windows.h before gl.h */
+       #undef FAR
+       #include <windows.h>
+#endif
+
+#include <GL/glpng.h>
+#include <GL/gl.h>\r
+#include <stdlib.h>
+#include <math.h>
+#include "png/png.h"
+\r
+/* Used to decide if GL/gl.h supports the paletted extension */\r
+#ifdef GL_COLOR_INDEX1_EXT\r
+#define SUPPORTS_PALETTE_EXT\r
+#endif\r
+
+static unsigned char DefaultAlphaCallback(unsigned char red, unsigned char green, unsigned char blue) {
+       return 255;
+}
+
+static unsigned char StencilRed = 0, StencilGreen = 0, StencilBlue = 0;
+static unsigned char (*AlphaCallback)(unsigned char red, unsigned char green, unsigned char blue) = DefaultAlphaCallback;
+static int StandardOrientation = 0;\r
+
+#ifdef SUPPORTS_PALETTE_EXT\r
+#ifdef _WIN32
+static PFNGLCOLORTABLEEXTPROC glColorTableEXT = NULL;\r
+#endif
+#endif\r
+
+static int PalettedTextures = -1;
+static GLint MaxTextureSize = 0;
+
+/* screenGamma = displayGamma/viewingGamma
+ * displayGamma = CRT has gamma of ~2.2
+ * viewingGamma depends on platform. PC is 1.0, Mac is 1.45, SGI defaults
+ * to 1.7, but this can be checked and changed w/ /usr/sbin/gamma command.
+ * If the environment variable VIEWING_GAMMA is set, adjust gamma per this value.
+ */\r
+#ifdef _MAC\r
+       static double screenGamma = 2.2 / 1.45;\r
+#elif SGI\r
+       static double screenGamma = 2.2 / 1.7;\r
+#else /* PC/default */
+       static double screenGamma = 2.2 / 1.0;\r
+#endif\r
+\r
+static char gammaExplicit = 0; /*if  */
+\r
+static void checkForGammaEnv()
+{
+       double viewingGamma;
+       char *gammaEnv = getenv("VIEWING_GAMMA");
+
+       if(gammaEnv && !gammaExplicit)
+       {
+               sscanf(gammaEnv, "%lf", &viewingGamma);
+               screenGamma = 2.2/viewingGamma;
+       }
+}
+
+/* Returns a safe texture size to use (ie a power of 2), based on the current texture size "i" */
+static int SafeSize(int i) {
+       int p;
+
+       if (i > MaxTextureSize) return MaxTextureSize;
+
+       for (p = 0; p < 24; p++)
+               if (i <= (1<<p))
+                       return 1<<p;
+
+       return MaxTextureSize;
+}
+
+/* Resize the texture since gluScaleImage doesn't work on everything */
+static void Resize(int components, const png_bytep d1, int w1, int h1, png_bytep d2, int w2, int h2) {
+       const float sx = (float) w1/w2, sy = (float) h1/h2;
+       int x, y, xx, yy, c;
+       png_bytep d;
+
+       for (y = 0; y < h2; y++) {
+               yy = (int) (y*sy)*w1;
+
+               for (x = 0; x < w2; x++) {
+                       xx = (int) (x*sx);
+                       d = d1 + (yy+xx)*components;
+
+                       for (c = 0; c < components; c++)
+                               *d2++ = *d++;
+               }
+       }
+}
+\r
+static int ExtSupported(const char *x) {
+       static const GLubyte *ext = NULL;
+       const char *c;
+       int xlen = strlen(x);
+
+       if (ext == NULL) ext = glGetString(GL_EXTENSIONS);
+
+       c = (const char*)ext;
+
+       while (*c != '\0') {
+               if (strcmp(c, x) == 0 && (c[xlen] == '\0' || c[xlen] == ' ')) return 1;
+               c++;
+       }
+
+       return 0;
+}
+\r
+#define GET(o) ((int)*(data + (o)))\r
+\r
+static int HalfSize(GLint components, GLint width, GLint height, const unsigned char *data, unsigned char *d, int filter) {\r
+       int x, y, c;\r
+       int line = width*components;\r
+\r
+       if (width > 1 && height > 1) {\r
+               if (filter)\r
+                       for (y = 0; y < height; y += 2) {\r
+                               for (x = 0; x < width; x += 2) {\r
+                                       for (c = 0; c < components; c++) {\r
+                                               *d++ = (GET(0)+GET(components)+GET(line)+GET(line+components)) / 4;\r
+                                               data++;\r
+                                       }\r
+                                       data += components;\r
+                               }\r
+                               data += line;\r
+                       }\r
+               else\r
+                       for (y = 0; y < height; y += 2) {\r
+                               for (x = 0; x < width; x += 2) {\r
+                                       for (c = 0; c < components; c++) {\r
+                                               *d++ = GET(0);\r
+                                               data++;\r
+                                       }\r
+                                       data += components;\r
+                               }\r
+                               data += line;\r
+                       }\r
+       }\r
+       else if (width > 1 && height == 1) {\r
+               if (filter)\r
+                       for (y = 0; y < height; y += 1) {\r
+                               for (x = 0; x < width; x += 2) {\r
+                                       for (c = 0; c < components; c++) {\r
+                                               *d++ = (GET(0)+GET(components)) / 2;\r
+                                               data++;\r
+                                       }\r
+                                       data += components;\r
+                               }\r
+                       }\r
+               else\r
+                       for (y = 0; y < height; y += 1) {\r
+                               for (x = 0; x < width; x += 2) {\r
+                                       for (c = 0; c < components; c++) {\r
+                                               *d++ = GET(0);\r
+                                               data++;\r
+                                       }\r
+                                       data += components;\r
+                               }\r
+                       }\r
+       }\r
+       else if (width == 1 && height > 1) {\r
+               if (filter)\r
+                       for (y = 0; y < height; y += 2) {\r
+                               for (x = 0; x < width; x += 1) {\r
+                                       for (c = 0; c < components; c++) {\r
+                                               *d++ = (GET(0)+GET(line)) / 2;\r
+                                               data++;\r
+                                       }\r
+                               }\r
+                               data += line;\r
+                       }\r
+               else\r
+                       for (y = 0; y < height; y += 2) {\r
+                               for (x = 0; x < width; x += 1) {\r
+                                       for (c = 0; c < components; c++) {\r
+                                               *d++ = GET(0);\r
+                                               data++;\r
+                                       }\r
+                               }\r
+                               data += line;\r
+                       }\r
+       }\r
+       else {\r
+               return 0;\r
+       }\r
+\r
+       return 1;\r
+}\r
+\r
+#undef GET\r
+\r
+/* Replacement for gluBuild2DMipmaps so GLU isn't needed */\r
+static void Build2DMipmaps(GLint components, GLint width, GLint height, GLenum format, const unsigned char *data, int filter) {\r
+       int level = 0;\r
+       unsigned char *d = (unsigned char *) malloc((width/2)*(height/2)*components+4);\r
+       const unsigned char *last = data;\r
+\r
+       glTexImage2D(GL_TEXTURE_2D, level, components, width, height, 0, format, GL_UNSIGNED_BYTE, data);\r
+       level++;\r
+\r
+       while (HalfSize(components, width, height, last, d, filter)) {\r
+               if (width  > 1) width  /= 2;\r
+               if (height > 1) height /= 2;\r
+\r
+               glTexImage2D(GL_TEXTURE_2D, level, components, width, height, 0, format, GL_UNSIGNED_BYTE, d);\r
+               level++;\r
+               last = d;\r
+       }\r
+\r
+       free(d);\r
+}\r
+
+int APIENTRY pngLoadRaw(const char *filename, pngRawInfo *pinfo) {
+       int result;
+       FILE *fp = fopen(filename, "rb");
+       if (fp == NULL) return 0;
+
+       result = pngLoadRawF(fp, pinfo);
+
+       if (fclose(fp) != 0) {
+               if (result) {
+                       free(pinfo->Data);
+                       free(pinfo->Palette);
+               }
+               return 0;
+       }
+
+       return result;
+}
+
+int APIENTRY pngLoadRawF(FILE *fp, pngRawInfo *pinfo) {
+       unsigned char header[8];
+       png_structp png;
+       png_infop   info;
+       png_infop   endinfo;
+       png_bytep   data;
+   png_bytep  *row_p;
+   double      fileGamma;
+
+       png_uint_32 width, height;
+       int depth, color;
+
+       png_uint_32 i;
+
+       if (pinfo == NULL) return 0;
+
+       fread(header, 1, 8, fp);
+       if (!png_check_sig(header, 8)) return 0;
+
+       png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+       info = png_create_info_struct(png);
+       endinfo = png_create_info_struct(png);
+
+       // DH: added following lines\r
+       if (setjmp(png->jmpbuf))\r
+       {\r
+               png_destroy_read_struct(&png, &info, &endinfo);\r
+               return 0;\r
+       }\r
+       // ~DH\r
+\r
+       png_init_io(png, fp);
+       png_set_sig_bytes(png, 8);
+       png_read_info(png, info);
+       png_get_IHDR(png, info, &width, &height, &depth, &color, NULL, NULL, NULL);
+
+       pinfo->Width  = width;
+       pinfo->Height = height;
+       pinfo->Depth  = depth;
+
+       /*--GAMMA--*/
+       checkForGammaEnv();
+       if (png_get_gAMA(png, info, &fileGamma))
+               png_set_gamma(png, screenGamma, fileGamma);
+       else
+               png_set_gamma(png, screenGamma, 1.0/2.2);
+
+       png_read_update_info(png, info);
+
+       data = (png_bytep) malloc(png_get_rowbytes(png, info)*height);
+       row_p = (png_bytep *) malloc(sizeof(png_bytep)*height);
+\r
+       for (i = 0; i < height; i++) {
+               if (StandardOrientation)\r
+                       row_p[height - 1 - i] = &data[png_get_rowbytes(png, info)*i];\r
+               else\r
+                       row_p[i] = &data[png_get_rowbytes(png, info)*i];\r
+       }\r
+
+       png_read_image(png, row_p);
+       free(row_p);
+
+       if (color == PNG_COLOR_TYPE_PALETTE) {
+               int cols;
+               png_get_PLTE(png, info, (png_colorp *) &pinfo->Palette, &cols);
+       }
+       else {
+               pinfo->Palette = NULL;
+       }
+\r
+       if (color&PNG_COLOR_MASK_ALPHA) {
+               if (color&PNG_COLOR_MASK_PALETTE || color == PNG_COLOR_TYPE_GRAY_ALPHA)
+                       pinfo->Components = 2;
+               else
+                       pinfo->Components = 4;
+               pinfo->Alpha = 8;
+       }
+       else {
+               if (color&PNG_COLOR_MASK_PALETTE || color == PNG_COLOR_TYPE_GRAY)
+                       pinfo->Components = 1;
+               else
+                       pinfo->Components = 3;
+               pinfo->Alpha = 0;
+       }
+
+       pinfo->Data = data;
+
+   png_read_end(png, endinfo);
+       png_destroy_read_struct(&png, &info, &endinfo);
+
+       return 1;
+}
+
+int APIENTRY pngLoad(const char *filename, int mipmap, int trans, pngInfo *pinfo) {
+       int result;
+       FILE *fp = fopen(filename, "rb");
+       if (fp == NULL) return 0;
+
+       result = pngLoadF(fp, mipmap, trans, pinfo);
+
+       if (fclose(fp) != 0) return 0;
+
+       return result;
+}
+
+int APIENTRY pngLoadF(FILE *fp, int mipmap, int trans, pngInfo *pinfo) {
+       GLint pack, unpack;\r
+       unsigned char header[8];
+       png_structp png;
+       png_infop   info;
+       png_infop   endinfo;
+       png_bytep   data, data2;
+   png_bytep  *row_p;
+   double      fileGamma;
+
+       png_uint_32 width, height, rw, rh;
+       int depth, color;
+
+       png_uint_32 i;
+
+       fread(header, 1, 8, fp);
+       if (!png_check_sig(header, 8)) return 0;
+
+       png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+       info = png_create_info_struct(png);
+       endinfo = png_create_info_struct(png);
+
+       // DH: added following lines\r
+       if (setjmp(png->jmpbuf))\r
+       {\r
+               png_destroy_read_struct(&png, &info, &endinfo);\r
+               return 0;\r
+       }\r
+       // ~DH\r
+\r
+       png_init_io(png, fp);
+       png_set_sig_bytes(png, 8);
+       png_read_info(png, info);
+       png_get_IHDR(png, info, &width, &height, &depth, &color, NULL, NULL, NULL);
+
+       if (pinfo != NULL) {
+               pinfo->Width  = width;
+               pinfo->Height = height;
+               pinfo->Depth  = depth;
+       }
+
+       if (MaxTextureSize == 0)
+               glGetIntegerv(GL_MAX_TEXTURE_SIZE, &MaxTextureSize);
+
+       #ifdef SUPPORTS_PALETTE_EXT\r
+       #ifdef _WIN32
+               if (PalettedTextures == -1)\r
+                       PalettedTextures = ExtSupported("GL_EXT_paletted_texture") && (strstr((const char *) glGetString(GL_VERSION), "1.1.0 3Dfx Beta") == NULL);\r
+\r
+               if (PalettedTextures) {
+                       if (glColorTableEXT == NULL) {
+                               glColorTableEXT = (PFNGLCOLORTABLEEXTPROC) wglGetProcAddress("glColorTableEXT");
+                               if (glColorTableEXT == NULL)
+                                       PalettedTextures = 0;
+                       }
+               }\r
+       #endif
+       #endif
+\r
+       if (PalettedTextures == -1)\r
+               PalettedTextures = 0;\r
+
+       if (color == PNG_COLOR_TYPE_GRAY || color == PNG_COLOR_TYPE_GRAY_ALPHA)
+               png_set_gray_to_rgb(png);
+
+       if (color&PNG_COLOR_MASK_ALPHA && trans != PNG_ALPHA) {
+               png_set_strip_alpha(png);
+               color &= ~PNG_COLOR_MASK_ALPHA;
+       }
+
+       if (!(PalettedTextures && mipmap >= 0 && trans == PNG_SOLID))
+               if (color == PNG_COLOR_TYPE_PALETTE)
+                       png_set_expand(png);
+
+       /*--GAMMA--*/
+       checkForGammaEnv();
+       if (png_get_gAMA(png, info, &fileGamma))
+               png_set_gamma(png, screenGamma, fileGamma);
+       else
+               png_set_gamma(png, screenGamma, 1.0/2.2);
+
+       png_read_update_info(png, info);
+
+       data = (png_bytep) malloc(png_get_rowbytes(png, info)*height);
+       row_p = (png_bytep *) malloc(sizeof(png_bytep)*height);
+\r
+       for (i = 0; i < height; i++) {\r
+               if (StandardOrientation)
+                       row_p[height - 1 - i] = &data[png_get_rowbytes(png, info)*i];\r
+               else\r
+                       row_p[i] = &data[png_get_rowbytes(png, info)*i];\r
+       }\r
+
+       png_read_image(png, row_p);
+       free(row_p);
+
+       rw = SafeSize(width), rh = SafeSize(height);
+
+       if (rw != width || rh != height) {
+               const int channels = png_get_rowbytes(png, info)/width;
+
+               data2 = (png_bytep) malloc(rw*rh*channels);
+
+               /* Doesn't work on certain sizes */
+/*             if (gluScaleImage(glformat, width, height, GL_UNSIGNED_BYTE, data, rw, rh, GL_UNSIGNED_BYTE, data2) != 0)
+                       return 0;
+*/
+               Resize(channels, data, width, height, data2, rw, rh);
+
+               width = rw, height = rh;
+               free(data);
+               data = data2;
+       }
+
+       { /* OpenGL stuff */\r
+               glGetIntegerv(GL_PACK_ALIGNMENT, &pack);\r
+               glGetIntegerv(GL_UNPACK_ALIGNMENT, &unpack);\r
+               glPixelStorei(GL_PACK_ALIGNMENT, 1);\r
+               glPixelStorei(GL_UNPACK_ALIGNMENT, 1);\r
+\r
+               #ifdef SUPPORTS_PALETTE_EXT
+               if (PalettedTextures && mipmap >= 0 && trans == PNG_SOLID && color == PNG_COLOR_TYPE_PALETTE) {
+                       png_colorp pal;
+                       int cols;
+                       GLint intf;
+
+                       if (pinfo != NULL) pinfo->Alpha = 0;
+                       png_get_PLTE(png, info, &pal, &cols);
+
+                       switch (cols) {
+                               case 1<<1:  intf = GL_COLOR_INDEX1_EXT;  break;
+                               case 1<<2:  intf = GL_COLOR_INDEX2_EXT;  break;
+                               case 1<<4:  intf = GL_COLOR_INDEX4_EXT;  break;
+                               case 1<<8:  intf = GL_COLOR_INDEX8_EXT;  break;
+                               case 1<<12: intf = GL_COLOR_INDEX12_EXT; break;
+                               case 1<<16: intf = GL_COLOR_INDEX16_EXT; break;
+                               default:
+                                       /*printf("Warning: Colour depth %i not recognised\n", cols);*/
+                                       return 0;
+                       }
+                       glColorTableEXT(GL_TEXTURE_2D, GL_RGB8, cols, GL_RGB, GL_UNSIGNED_BYTE, pal);
+                       glTexImage2D(GL_TEXTURE_2D, mipmap, intf, width, height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, data);
+               }
+               else\r
+               #endif\r
+               if (trans == PNG_SOLID || trans == PNG_ALPHA || color == PNG_COLOR_TYPE_RGB_ALPHA || color == PNG_COLOR_TYPE_GRAY_ALPHA) {
+                       GLenum glformat;
+                       GLint glcomponent;
+
+                       switch (color) {
+                               case PNG_COLOR_TYPE_GRAY:
+                               case PNG_COLOR_TYPE_RGB:
+                               case PNG_COLOR_TYPE_PALETTE:
+                                       glformat = GL_RGB;
+                                       glcomponent = 3;
+                                       if (pinfo != NULL) pinfo->Alpha = 0;
+                                       break;
+
+                               case PNG_COLOR_TYPE_GRAY_ALPHA:
+                               case PNG_COLOR_TYPE_RGB_ALPHA:
+                                       glformat = GL_RGBA;
+                                       glcomponent = 4;
+                                       if (pinfo != NULL) pinfo->Alpha = 8;
+                                       break;
+
+                               default:
+                                       /*puts("glformat not set");*/
+                                       return 0;
+                       }
+
+                       if (mipmap == PNG_BUILDMIPMAPS)
+                               Build2DMipmaps(glcomponent, width, height, glformat, data, 1);\r
+                       else if (mipmap == PNG_SIMPLEMIPMAPS)\r
+                               Build2DMipmaps(glcomponent, width, height, glformat, data, 0);
+                       else
+                               glTexImage2D(GL_TEXTURE_2D, mipmap, glcomponent, width, height, 0, glformat, GL_UNSIGNED_BYTE, data);
+               }
+               else {
+                       png_bytep p, endp, q;
+                       int r, g, b, a;
+
+                       p = data, endp = p+width*height*3;
+                       q = data2 = (png_bytep) malloc(sizeof(png_byte)*width*height*4);
+
+                       if (pinfo != NULL) pinfo->Alpha = 8;
+
+                       #define FORSTART \
+                               do { \
+                                       r = *p++; /*red  */ \
+                                       g = *p++; /*green*/ \
+                                       b = *p++; /*blue */ \
+                                       *q++ = r; \
+                                       *q++ = g; \
+                                       *q++ = b;
+
+                       #define FOREND \
+                                       q++; \
+                               } while (p != endp);
+
+                       #define ALPHA *q
+
+                       switch (trans) {
+                               case PNG_CALLBACK:
+                                       FORSTART
+                                               ALPHA = AlphaCallback((unsigned char) r, (unsigned char) g, (unsigned char) b);
+                                       FOREND
+                                       break;
+
+                               case PNG_STENCIL:
+                                       FORSTART
+                                               if (r == StencilRed && g == StencilGreen && b == StencilBlue)
+                                                       ALPHA = 0;
+                                               else
+                                                       ALPHA = 255;
+                                       FOREND
+                                       break;
+
+                               case PNG_BLEND1:
+                                       FORSTART
+                                               a = r+g+b;
+                                               if (a > 255) ALPHA = 255; else ALPHA = a;
+                                       FOREND
+                                       break;
+
+                               case PNG_BLEND2:
+                                       FORSTART
+                                               a = r+g+b;
+                                               if (a > 255*2) ALPHA = 255; else ALPHA = a/2;
+                                       FOREND
+                                       break;
+
+                               case PNG_BLEND3:
+                                       FORSTART
+                                               ALPHA = (r+g+b)/3;
+                                       FOREND
+                                       break;
+
+                               case PNG_BLEND4:
+                                       FORSTART
+                                               a = r*r+g*g+b*b;
+                                               if (a > 255) ALPHA = 255; else ALPHA = a;
+                                       FOREND
+                                       break;
+
+                               case PNG_BLEND5:
+                                       FORSTART
+                                               a = r*r+g*g+b*b;
+                                               if (a > 255*2) ALPHA = 255; else ALPHA = a/2;
+                                       FOREND
+                                       break;
+
+                               case PNG_BLEND6:
+                                       FORSTART
+                                               a = r*r+g*g+b*b;
+                                               if (a > 255*3) ALPHA = 255; else ALPHA = a/3;
+                                       FOREND
+                                       break;
+
+                               case PNG_BLEND7:
+                                       FORSTART
+                                               a = r*r+g*g+b*b;
+                                               if (a > 255*255) ALPHA = 255; else ALPHA = (int) sqrt(a);
+                                       FOREND
+                                       break;
+                       }
+
+                       #undef FORSTART
+                       #undef FOREND
+                       #undef ALPHA
+
+                       if (mipmap == PNG_BUILDMIPMAPS)\r
+                               Build2DMipmaps(4, width, height, GL_RGBA, data2, 1);
+                       else if (mipmap == PNG_SIMPLEMIPMAPS)\r
+                               Build2DMipmaps(4, width, height, GL_RGBA, data2, 0);\r
+                       else
+                               glTexImage2D(GL_TEXTURE_2D, mipmap, 4, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data2);
+
+                       free(data2);
+               }
+\r
+               glPixelStorei(GL_PACK_ALIGNMENT, pack);\r
+               glPixelStorei(GL_UNPACK_ALIGNMENT, unpack);\r
+       } /* OpenGL end */
+
+   png_read_end(png, endinfo);
+       png_destroy_read_struct(&png, &info, &endinfo);
+
+       free(data);
+
+       return 1;
+}
+
+static unsigned int SetParams(int wrapst, int magfilter, int minfilter) {
+       unsigned int id;
+
+       glGenTextures(1, &id);
+       glBindTexture(GL_TEXTURE_2D, id);
+
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapst);
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapst);
+
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magfilter);
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minfilter);
+
+       return id;
+}
+
+unsigned int APIENTRY pngBind(const char *filename, int mipmap, int trans, pngInfo *info, int wrapst, int minfilter, int magfilter) {
+       unsigned int id = SetParams(wrapst, magfilter, minfilter);
+
+       if (id != 0 && pngLoad(filename, mipmap, trans, info))
+               return id;
+       return 0;
+}
+
+unsigned int APIENTRY pngBindF(FILE *file, int mipmap, int trans, pngInfo *info, int wrapst, int minfilter, int magfilter) {
+       unsigned int id = SetParams(wrapst, magfilter, minfilter);
+
+       if (id != 0 && pngLoadF(file, mipmap, trans, info))
+               return id;
+       return 0;
+}
+
+void APIENTRY pngSetStencil(unsigned char red, unsigned char green, unsigned char blue) {
+       StencilRed = red, StencilGreen = green, StencilBlue = blue;
+}
+
+void APIENTRY pngSetAlphaCallback(unsigned char (*callback)(unsigned char red, unsigned char green, unsigned char blue)) {
+       if (callback == NULL)
+               AlphaCallback = DefaultAlphaCallback;
+       else
+               AlphaCallback = callback;
+}
+
+void APIENTRY pngSetViewingGamma(double viewingGamma) {
+       if(viewingGamma > 0) {
+               gammaExplicit = 1;
+               screenGamma = 2.2/viewingGamma;
+       }
+       else {
+               gammaExplicit = 0;
+               screenGamma = 2.2;
+       }
+}
+\r
+void APIENTRY pngSetStandardOrientation(int standardorientation) {\r
+       StandardOrientation = standardorientation;\r
+}\r
diff --git a/src/glpng.pro b/src/glpng.pro
new file mode 100644 (file)
index 0000000..3fe5d45
--- /dev/null
@@ -0,0 +1,38 @@
+TARGET         = glpng
+TEMPLATE       = lib
+CONFIG         = staticlib warn_on release
+INCLUDEPATH    = ../include 
+#DEFINES               = SGI
+
+HEADERS                = png/png.h \
+                 png/pngconf.h \
+                 zlib/infblock.h \
+                 zlib/infcodes.h \
+                 zlib/inffast.h \
+                 zlib/inffixed.h \
+                 zlib/inftrees.h \
+                 zlib/infutil.h \
+                 zlib/zconf.h \
+                 zlib/zlib.h \
+                 zlib/zutil.h
+SOURCES                = glpng.c \
+                 png/png.c \
+                 png/pngerror.c \
+                 png/pngget.c \
+                 png/pngmem.c \
+                 png/pngpread.c \
+                 png/pngread.c \
+                 png/pngrio.c \
+                 png/pngrtran.c \
+                 png/pngrutil.c \
+                 png/pngset.c \
+                 png/pngtrans.c \
+                 zlib/adler32.c \
+                 zlib/crc32.c \
+                 zlib/infblock.c \
+                 zlib/infcodes.c \
+                 zlib/inffast.c \
+                 zlib/inflate.c \
+                 zlib/inftrees.c \
+                 zlib/infutil.c \
+                 zlib/zutil.c