r4958 - in packages/trunk/antigrav/debian: . patches

Barry deFreese bddebian-guest at alioth.debian.org
Sat Dec 15 21:36:14 UTC 2007


Author: bddebian-guest
Date: 2007-12-15 21:36:14 +0000 (Sat, 15 Dec 2007)
New Revision: 4958

Added:
   packages/trunk/antigrav/debian/patches/
   packages/trunk/antigrav/debian/patches/01_fix_png_load.diff
   packages/trunk/antigrav/debian/patches/02_fix_sound.diff
   packages/trunk/antigrav/debian/patches/series
Modified:
   packages/trunk/antigrav/debian/changelog
   packages/trunk/antigrav/debian/control
   packages/trunk/antigrav/debian/rules
Log:
  * Add quilt patching system and move previous changes to patches:
    + 01_fix_png_load.diff - Fix loading of PNG images
    + 02_fix_sound.diff - Fix sound handling


Modified: packages/trunk/antigrav/debian/changelog
===================================================================
--- packages/trunk/antigrav/debian/changelog	2007-12-15 18:44:35 UTC (rev 4957)
+++ packages/trunk/antigrav/debian/changelog	2007-12-15 21:36:14 UTC (rev 4958)
@@ -9,6 +9,9 @@
   * Add VCS fields to control
   * Make distclean not ignore errors
   * Remove deprecated Encoding tag from desktop file
+  * Add quilt patching system and move previous changes to patches:
+    + 01_fix_png_load.diff - Fix loading of PNG images
+    + 02_fix_sound.diff - Fix sound handling
 
  -- Barry deFreese <bddebian at comcast.net>  Tue, 11 Dec 2007 12:35:27 -0500
 

Modified: packages/trunk/antigrav/debian/control
===================================================================
--- packages/trunk/antigrav/debian/control	2007-12-15 18:44:35 UTC (rev 4957)
+++ packages/trunk/antigrav/debian/control	2007-12-15 21:36:14 UTC (rev 4958)
@@ -3,7 +3,7 @@
 Priority: optional
 Maintainer: Debian Games Team <pkg-games-devel at lists.alioth.debian.org>
 Uploaders: Barry deFreese <bddebian at comcast.net>
-Build-Depends: debhelper (>> 5.0.0), autotools-dev, zlib1g-dev, libpng12-dev, libalut-dev, libopenal-dev, libsdl1.2-dev
+Build-Depends: debhelper (>> 5.0.0), autotools-dev, quilt, zlib1g-dev, libpng12-dev, libalut-dev, libopenal-dev, libsdl1.2-dev
 Standards-Version: 3.7.3
 Homepage: http://www.luolamies.org/software/antigrav/
 Vcs-Svn: svn://svn.debian.org/svn/pkg-games/packages/trunk/antigrav/

Added: packages/trunk/antigrav/debian/patches/01_fix_png_load.diff
===================================================================
--- packages/trunk/antigrav/debian/patches/01_fix_png_load.diff	                        (rev 0)
+++ packages/trunk/antigrav/debian/patches/01_fix_png_load.diff	2007-12-15 21:36:14 UTC (rev 4958)
@@ -0,0 +1,619 @@
+diff -urN antigrav-0.0.2.orig/src/m3dtexture.cpp antigrav-0.0.2/src/m3dtexture.cpp
+--- antigrav-0.0.2.orig/src/m3dtexture.cpp	2006-08-04 15:38:31.000000000 -0400
++++ antigrav-0.0.2/src/m3dtexture.cpp	2007-12-15 11:07:44.000000000 -0500
+@@ -104,6 +104,7 @@
+ 		if(loadPNG(texUnits[n].filename.c_str(), &data, &(texUnits[n].width), &(texUnits[n].height)) != 0)
+ 		{
+ 			fprintf(stderr, "Invalid: can't load texture %s\n", texUnits[n].filename.c_str());
++			fprintf(stderr, "Width %u, Height %u\n",&(texUnits[n].width), &(texUnits[n].height));
+ 			return -1;
+ 		}
+ 		
+@@ -148,6 +149,7 @@
+ 		if(loadPNG(texUnits[n].filename.c_str(), &data, &(texUnits[n].width), &(texUnits[n].height)) != 0)
+ 		{
+ 			fprintf(stderr, "Invalid: can't load texture %s\n", texUnits[n].filename.c_str());
++			fprintf(stderr, "Width %u, Height %u\n",&(texUnits[n].width), &(texUnits[n].height));
+ 			return -1;
+ 		}
+ 		
+@@ -204,7 +206,7 @@
+ 	@param height a pointer where to store the image width
+ 	@return 0 on success, -1 on failure
+ */
+-int m3dTexture::loadPNG(const char *filename, unsigned char **data, unsigned int *width, unsigned int *height)
++int m3dTexture::loadPNG(const char *filename, unsigned char **data, png_uint_32 *width, png_uint_32 *height)
+ {
+ 	FILE *f;
+ 	int result;
+@@ -221,7 +223,7 @@
+ 	return result;
+ }
+ 
+-int m3dTexture::loadPNG(unsigned char **data, unsigned int *width, unsigned int *height, void *handle, void (*pngReadCallback)(png_structp ctx, png_bytep area, png_size_t size))
++int m3dTexture::loadPNG(unsigned char **data, png_uint_32 *width, png_uint_32 *height, void *handle, void (*pngReadCallback)(png_structp ctx, png_bytep area, png_size_t size))
+ {
+ 	png_structp pngPtr;
+ 	png_infop pngInfoPtr;
+@@ -258,7 +260,7 @@
+ 	png_set_read_fn(pngPtr, handle, pngReadCallback);
+ 
+ 	png_read_info(pngPtr, pngInfoPtr);
+-	png_get_IHDR(pngPtr, pngInfoPtr, (png_uint_32*)width, (png_uint_32*)height, &bitDepth, &colorType, &interlaceType, NULL, NULL);
++	png_get_IHDR(pngPtr, pngInfoPtr, width, height, &bitDepth, &colorType, &interlaceType, NULL, NULL);
+ 
+ 	png_set_strip_16(pngPtr);
+ 
+@@ -279,7 +281,7 @@
+ 	}
+ 	
+ 	png_read_update_info(pngPtr, pngInfoPtr);
+-	png_get_IHDR(pngPtr, pngInfoPtr, (png_uint_32*)width, (png_uint_32*)height, &bitDepth, &colorType, &interlaceType, NULL, NULL);
++	png_get_IHDR(pngPtr, pngInfoPtr, width, height, &bitDepth, &colorType, &interlaceType, NULL, NULL);
+ 	
+ 	(*data) = new unsigned char[(*width) * (*height) * pngInfoPtr->channels];
+ 	if((*data) == NULL)
+@@ -312,7 +314,7 @@
+ 	return 0;
+ }
+ 
+-int m3dTexture::savePNG(const char *filename, const unsigned char *data, unsigned int width, unsigned int height)
++int m3dTexture::savePNG(const char *filename, const unsigned char *data, png_uint_32 width, png_uint_32 height)
+ {
+ 	FILE *f;
+ 	int result;
+@@ -345,7 +347,7 @@
+ 	fflush(f);
+ }
+ 
+-int m3dTexture::savePNG(const unsigned char *data, unsigned int width, unsigned int height, void *handle, void (*pngWriteCallback)(png_structp pngPtr, png_bytep data, png_size_t length), void (*pngFlushCallback)(png_structp pngPtr))
++int m3dTexture::savePNG(const unsigned char *data, png_uint_32 width, png_uint_32 height, void *handle, void (*pngWriteCallback)(png_structp pngPtr, png_bytep data, png_size_t length), void (*pngFlushCallback)(png_structp pngPtr))
+ {
+ 	png_structp pngPtr;
+ 	png_infop pngInfoPtr;
+@@ -435,7 +437,7 @@
+ GLuint m3dTexture::loadTexture(const char *filename)
+ {
+ 	unsigned char *data;
+-	unsigned int width, height;
++	png_uint_32 width, height;
+ 	GLuint tex;
+ 	
+ 	glGenTextures(1, &tex);
+@@ -443,6 +445,7 @@
+ 	if(m3dTexture::loadPNG(filename, &data, &width, &height) != 0)
+ 	{
+ 		fprintf(stderr, "Can't load texture %s\n", filename);
++		fprintf(stderr, "Width %d, Height %d\n",&width, &height);
+ 		return 0;
+ 	}
+ 		
+diff -urN antigrav-0.0.2.orig/src/m3dtexture.cpp.orig antigrav-0.0.2/src/m3dtexture.cpp.orig
+--- antigrav-0.0.2.orig/src/m3dtexture.cpp.orig	1969-12-31 19:00:00.000000000 -0500
++++ antigrav-0.0.2/src/m3dtexture.cpp.orig	2006-08-04 15:38:31.000000000 -0400
+@@ -0,0 +1,491 @@
++#define GL_GLEXT_PROTOTYPES
++#include "SDL_opengl.h"
++#include <stdlib.h>
++#include <stdio.h>
++#include <string>
++#include <png.h>
++
++using namespace std;
++
++#include "tinyxml.h"
++#include "m3dmaterial.h"
++#include "m3dtexture.h"
++#include "m3dmesh.h"
++
++#include "extensions.h"
++
++/// Create a new null object
++/**
++	Create a new object and reset rotation, scaling and transformation
++*/
++m3dTexture::m3dTexture()
++{
++	texUnits = NULL;
++	numTexUnits = 0;
++}
++
++m3dTexture::~m3dTexture()
++{
++// 	for(int i = 0; i < numTexUnits; i++)
++// 	{
++// 		glDeleteTextures(1, &texUnits[i].handle);
++// 	}
++	
++	delete[] texUnits;
++}
++
++int m3dTexture::loadFromXML(const TiXmlElement *root)
++{
++// 	for(int i = 0; i < numTexUnits; i++)
++// 	{
++// 		glDeleteTextures(1, &texUnits[i].handle);
++// 	}
++	
++	delete[] texUnits;
++	
++	if(string(root->Value()) != "Texture")
++	{
++		fprintf(stderr, "Unknown node type: %s  (required: %s)\n", root->Value(), "Texture");
++		return -1;
++	}
++	
++	if(root->QueryIntAttribute("units", &numTexUnits) != TIXML_SUCCESS) return -1;
++	
++	int maxTexUnits;
++	glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &maxTexUnits);
++	if(numTexUnits > maxTexUnits) numTexUnits = maxTexUnits;
++	
++	texUnits = new struct TextureUnit[numTexUnits];
++
++	int n = 0;
++	const TiXmlElement *element = root->FirstChildElement();
++	const char *attr;
++	string value;
++	while(element)
++	{
++		value = element->Value();
++		
++		if(value == "Image")
++		{
++			if(n >= numTexUnits)
++			{
++				fprintf(stderr, "Invalid: too many texture units!\n");
++				return -1;
++			}
++
++			attr = element->Attribute("filename");
++			if(attr == NULL)
++			{
++				fprintf(stderr, "Invalid: texture unit without filename!\n");
++				return -1;
++			}
++			
++			texUnits[n].filename = string(attr);
++
++			n++;
++		}
++		
++		element = element->NextSiblingElement();
++	}
++	
++	if(n != numTexUnits)
++	{
++		fprintf(stderr, "Invalid texture: incorrect number of texture units (wanted %d, got %d)!\n", numTexUnits, n);
++		return -1;
++	}
++	
++	for(n = 0; n < numTexUnits; n++)
++	{
++		unsigned char *data = NULL;
++		
++		glGenTextures(1, &(texUnits[n].handle));
++		// ERROR CHECK!
++		
++		if(loadPNG(texUnits[n].filename.c_str(), &data, &(texUnits[n].width), &(texUnits[n].height)) != 0)
++		{
++			fprintf(stderr, "Invalid: can't load texture %s\n", texUnits[n].filename.c_str());
++			return -1;
++		}
++		
++		glBindTexture(GL_TEXTURE_2D, texUnits[n].handle);
++		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texUnits[n].width, texUnits[n].height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
++		
++		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
++		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
++		// Advanced texture parameters here (anisotropy, mipmapping, different filters, etc)
++		delete[] data;
++	}
++	
++	return 0;
++}
++
++int m3dTexture::load(const char *filename)
++{
++	return load(1, &filename);
++}
++
++int m3dTexture::load(int num, const char *filenames[])
++{
++/*	for(int i = 0; i < numTexUnits; i++)
++	{
++		glDeleteTextures(1, &texUnits[i].handle);
++	}*/
++	
++	delete[] texUnits;
++	
++	numTexUnits = num;
++	texUnits = new struct TextureUnit[numTexUnits];
++	
++	for(int n = 0; n < numTexUnits; n++)
++	{
++		texUnits[n].filename = std::string(filenames[n]);
++		
++		unsigned char *data = NULL;
++		
++		glGenTextures(1, &(texUnits[n].handle));
++		// ERROR CHECK!
++		
++		if(loadPNG(texUnits[n].filename.c_str(), &data, &(texUnits[n].width), &(texUnits[n].height)) != 0)
++		{
++			fprintf(stderr, "Invalid: can't load texture %s\n", texUnits[n].filename.c_str());
++			return -1;
++		}
++		
++		glBindTexture(GL_TEXTURE_2D, texUnits[n].handle);
++		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texUnits[n].width, texUnits[n].height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
++		
++		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
++		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
++		// Advanced texture parameters here (anisotropy, mipmapping, different filters, etc)
++		delete[] data;
++	}
++	
++	return 0;
++}
++
++void m3dTexture::bind() const
++{
++	if(numTexUnits < 1) return;
++	
++#ifdef HAVE_MULTITEX
++	for(int i = 0; i < numTexUnits; i++)
++	{
++		mglActiveTextureARB(GL_TEXTURE0_ARB + i);
++// 		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
++		glEnable(GL_TEXTURE_2D);
++		glBindTexture(GL_TEXTURE_2D, texUnits[i].handle);
++	}
++#else
++    glEnable(GL_TEXTURE_2D);
++    glBindTexture(GL_TEXTURE_2D, texUnits[0].handle);
++#endif
++}
++
++int m3dTexture::getNumTexUnits() const
++{
++	return numTexUnits;
++}
++
++void m3dTexture::pngReadCallbackSTDIO(png_structp pngPtr, png_bytep data, png_size_t length)
++{
++	FILE *f;
++
++	f = (FILE*) png_get_io_ptr(pngPtr);
++	fread(data, length, 1, f);
++}
++
++/// Load a PNG image from a file
++/**
++	Only 32-bit RGBA images supported
++
++	@param filename the filename to load from
++	@param data a pointer to an uninitialized data area where the image data will be stored
++	@param width a pointer where to store the image width
++	@param height a pointer where to store the image width
++	@return 0 on success, -1 on failure
++*/
++int m3dTexture::loadPNG(const char *filename, unsigned char **data, unsigned int *width, unsigned int *height)
++{
++	FILE *f;
++	int result;
++	
++	f = fopen(filename, "rb");
++	if(f == NULL)
++	{
++		fprintf(stderr, "Can't open file %s\n", filename);
++		return -1;
++	}
++	
++	result = loadPNG(data, width, height, f, m3dTexture::pngReadCallbackSTDIO);
++	fclose(f);
++	return result;
++}
++
++int m3dTexture::loadPNG(unsigned char **data, unsigned int *width, unsigned int *height, void *handle, void (*pngReadCallback)(png_structp ctx, png_bytep area, png_size_t size))
++{
++	png_structp pngPtr;
++	png_infop pngInfoPtr;
++	int bitDepth, colorType, interlaceType;
++// 	unsigned char header[4];
++	volatile int ckey = -1;
++	png_color_16 *transv;
++	png_bytep *rowPointers;
++	unsigned int row;
++
++	pngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
++	if(!pngPtr)
++	{
++		*data = NULL;
++		return -1;
++	}
++	
++	pngInfoPtr = png_create_info_struct(pngPtr);
++	if(!pngInfoPtr)
++	{
++		png_destroy_read_struct(&pngPtr, NULL, NULL);
++		*data = NULL;
++		return -1;
++	}
++
++	if(setjmp(pngPtr->jmpbuf))
++	{
++		perror("setjmp");
++		png_destroy_read_struct(&pngPtr, &pngInfoPtr, NULL);
++		*data = NULL;
++		return -1;
++	}
++
++	png_set_read_fn(pngPtr, handle, pngReadCallback);
++
++	png_read_info(pngPtr, pngInfoPtr);
++	png_get_IHDR(pngPtr, pngInfoPtr, (png_uint_32*)width, (png_uint_32*)height, &bitDepth, &colorType, &interlaceType, NULL, NULL);
++
++	png_set_strip_16(pngPtr);
++
++	png_set_packing(pngPtr);
++
++	if(png_get_valid(pngPtr, pngInfoPtr, PNG_INFO_tRNS))
++	{
++		int num_trans;
++		unsigned char *trans;
++		png_get_tRNS(pngPtr, pngInfoPtr, &trans, &num_trans, &transv);
++		ckey = 0;
++	}
++	
++	if(colorType != PNG_COLOR_TYPE_RGB_ALPHA || bitDepth != 8 || pngInfoPtr->channels != 4)
++	{
++		fprintf(stderr, "Only 32-bit RGBA png images are supported\n");
++		return -1;
++	}
++	
++	png_read_update_info(pngPtr, pngInfoPtr);
++	png_get_IHDR(pngPtr, pngInfoPtr, (png_uint_32*)width, (png_uint_32*)height, &bitDepth, &colorType, &interlaceType, NULL, NULL);
++	
++	(*data) = new unsigned char[(*width) * (*height) * pngInfoPtr->channels];
++	if((*data) == NULL)
++	{
++		fprintf(stderr, "loadPng(): Out of memory !\n");
++		png_destroy_read_struct(&pngPtr, &pngInfoPtr, NULL);
++		*data = NULL;
++		return -1;
++	}
++	
++	rowPointers = new png_bytep[*height];
++	if(!rowPointers)
++	{
++		perror("malloc");
++		png_destroy_read_struct(&pngPtr, &pngInfoPtr, NULL);
++		delete[] (*data);
++		*data = NULL;
++		return -1;
++	}
++
++	for(row = 0; (unsigned int) row < (*height); row++)
++	{
++		rowPointers[row] = (png_bytep)*data + (row * (*width) * pngInfoPtr->channels);
++	}
++	png_read_image(pngPtr, rowPointers);
++	png_read_end(pngPtr, pngInfoPtr);
++
++	png_destroy_read_struct(&pngPtr, &pngInfoPtr, NULL);
++	delete[] rowPointers;
++	return 0;
++}
++
++int m3dTexture::savePNG(const char *filename, const unsigned char *data, unsigned int width, unsigned int height)
++{
++	FILE *f;
++	int result;
++	
++	f = fopen(filename, "wb");
++	if(f == NULL)
++	{
++		fprintf(stderr, "Can't open %s for writing!\n", filename);
++		return -1;
++	}
++	
++	result = savePNG(data, width, height, (void*)f, m3dTexture::pngWriteCallbackSTDIO, m3dTexture::pngFlushCallbackSTDIO);
++	fclose(f);
++	return result;
++}
++
++void m3dTexture::pngWriteCallbackSTDIO(png_structp pngPtr, png_bytep data, png_size_t length)
++{
++	FILE *f;
++
++	f = (FILE*) png_get_io_ptr(pngPtr);
++	fwrite(data, length, 1, f);
++}
++
++void m3dTexture::pngFlushCallbackSTDIO(png_structp pngPtr)
++{
++	FILE *f;
++
++	f = (FILE*) png_get_io_ptr(pngPtr);
++	fflush(f);
++}
++
++int m3dTexture::savePNG(const unsigned char *data, unsigned int width, unsigned int height, void *handle, void (*pngWriteCallback)(png_structp pngPtr, png_bytep data, png_size_t length), void (*pngFlushCallback)(png_structp pngPtr))
++{
++	png_structp pngPtr;
++	png_infop pngInfoPtr;
++	png_bytep *rowPointers;
++	int i;
++
++	pngPtr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
++	pngInfoPtr = png_create_info_struct(pngPtr);
++	png_set_write_fn(pngPtr, handle, pngWriteCallback, pngFlushCallback);
++
++	pngInfoPtr->width = width;
++	pngInfoPtr->height = height;
++	pngInfoPtr->rowbytes = width * 4;
++	pngInfoPtr->bit_depth = 8;
++	pngInfoPtr->interlace_type = 0;
++	pngInfoPtr->num_palette = 0;
++	pngInfoPtr->valid = 0;
++
++	pngInfoPtr->sig_bit.red = 8;
++	pngInfoPtr->sig_bit.green = 8;
++	pngInfoPtr->sig_bit.blue = 8;
++	pngInfoPtr->sig_bit.alpha = 8;
++
++	pngInfoPtr->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
++
++	png_write_info(pngPtr, pngInfoPtr);
++
++	rowPointers = new png_bytep[pngInfoPtr->height];
++
++	for(i = 0; (unsigned int) i < pngInfoPtr->height; i++)
++	{
++		rowPointers[i] = (unsigned char*)data + i * width * 4;
++	}
++
++	png_write_image(pngPtr, rowPointers);
++	png_write_end(pngPtr, pngInfoPtr);
++	delete rowPointers;
++	png_destroy_write_struct(&pngPtr, &pngInfoPtr);
++	return 0;
++}
++
++int m3dTexture::screenshot(const char *filename)
++{
++	unsigned char *data;
++	unsigned int width, height;
++	unsigned char *ptr1, *ptr2;
++	unsigned int i, j;
++	
++	unsigned char temp;
++	GLint viewport[4];
++	
++	glGetIntegerv(GL_VIEWPORT, viewport);
++	width = viewport[2];
++	height = viewport[3];
++	data = new unsigned char[width * height * 4];
++	if(data == NULL)
++	{
++		return -1;
++	}
++	
++	glReadBuffer(GL_COLOR_BUFFER_BIT);
++	glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3], GL_RGBA, GL_UNSIGNED_BYTE, data);
++	
++	ptr1 = data;
++	for(i = 0; i < height/2; i++)
++	{
++		ptr2 = data + (height - i - 1) * width * 4;
++		for(j = 0 ; j < width * 4; j++)
++		{
++			temp = *ptr1;
++			*ptr1++ = *ptr2;
++			*ptr2++ = temp;
++		}
++	}
++	
++	if(savePNG(filename, data, width, height) != 0)
++	{
++		delete data;
++		return -1;
++	}
++	
++	delete data;
++	return 0;
++}
++
++
++GLuint m3dTexture::loadTexture(const char *filename)
++{
++	unsigned char *data;
++	unsigned int width, height;
++	GLuint tex;
++	
++	glGenTextures(1, &tex);
++	
++	if(m3dTexture::loadPNG(filename, &data, &width, &height) != 0)
++	{
++		fprintf(stderr, "Can't load texture %s\n", filename);
++		return 0;
++	}
++		
++	glBindTexture(GL_TEXTURE_2D, tex);
++	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
++	delete[] data;
++	
++	if(glGetError() != GL_NO_ERROR)
++	{
++		return 0;
++	}
++		
++	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
++	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
++	
++	return tex;
++}
++
++m3dTexture &m3dTexture::operator=(const m3dTexture &t)
++{
++	if(&t == this) return *this;
++	
++// 	for(int i = 0; i < numTexUnits; i++)
++// 	{
++// 		glDeleteTextures(1, &texUnits[i].handle);
++// 	}
++
++	if(t.getNumTexUnits() != numTexUnits || texUnits == NULL)
++	{
++		delete[] texUnits;
++		texUnits = new struct TextureUnit[t.getNumTexUnits()];
++	}
++	
++	numTexUnits = t.getNumTexUnits();
++	
++	for(int i = 0; i < numTexUnits; i++)
++	{
++// 		texUnits[i].filename = t.texUnits[i].filename;
++		texUnits[i].handle = t.texUnits[i].handle;
++		texUnits[i].width = t.texUnits[i].width;
++		texUnits[i].height = t.texUnits[i].height;
++	}
++	
++	return *this;
++}
++
+diff -urN antigrav-0.0.2.orig/src/m3dtexture.h antigrav-0.0.2/src/m3dtexture.h
+--- antigrav-0.0.2.orig/src/m3dtexture.h	2006-08-04 15:38:31.000000000 -0400
++++ antigrav-0.0.2/src/m3dtexture.h	2007-12-15 11:07:44.000000000 -0500
+@@ -9,7 +9,7 @@
+ {
+ 	std::string filename;
+ 	GLuint handle;
+-	unsigned int width, height;
++	png_uint_32 width, height;
+ };
+ 
+ /// A texture
+@@ -34,8 +34,8 @@
+ 	
+ 	m3dTexture &operator=(const m3dTexture &t);
+ 
+-	static int loadPNG(const char *filename, unsigned char **data, unsigned int *width, unsigned int *height);
+-	static int savePNG(const char *filename, const unsigned char *data, unsigned int width, unsigned int height);
++	static int loadPNG(const char *filename, unsigned char **data, png_uint_32 *width, png_uint_32 *height);
++	static int savePNG(const char *filename, const unsigned char *data, png_uint_32 width, png_uint_32 height);
+ 	static int screenshot(const char *filename);
+ 	
+ 	static GLuint loadTexture(const char *filename);
+@@ -48,8 +48,8 @@
+ 	static void pngWriteCallbackSTDIO(png_structp pngPtr, png_bytep data, png_size_t length);
+ 	static void pngFlushCallbackSTDIO(png_structp pngPtr);
+ 	
+-	static int loadPNG(unsigned char **data, unsigned int *width, unsigned int *height, void *handle, void (*pngReadCallback)(png_structp ctx, png_bytep area, png_size_t size));
+-	static int savePNG(const unsigned char *data, unsigned int width, unsigned int height, void *handle, void (*pngWriteCallback)(png_structp pngPtr, png_bytep data, png_size_t length), void (*pngFlushCallback)(png_structp pngPtr));
++	static int loadPNG(unsigned char **data, png_uint_32 *width, png_uint_32 *height, void *handle, void (*pngReadCallback)(png_structp ctx, png_bytep area, png_size_t size));
++	static int savePNG(const unsigned char *data, png_uint_32 width, png_uint_32 height, void *handle, void (*pngWriteCallback)(png_structp pngPtr, png_bytep data, png_size_t length), void (*pngFlushCallback)(png_structp pngPtr));
+ };
+ 
+ #endif

Added: packages/trunk/antigrav/debian/patches/02_fix_sound.diff
===================================================================
--- packages/trunk/antigrav/debian/patches/02_fix_sound.diff	                        (rev 0)
+++ packages/trunk/antigrav/debian/patches/02_fix_sound.diff	2007-12-15 21:36:14 UTC (rev 4958)
@@ -0,0 +1,311 @@
+diff -urN antigrav-0.0.2.orig/src/main.cpp antigrav-0.0.2/src/main.cpp
+--- antigrav-0.0.2.orig/src/main.cpp	2006-08-04 15:38:31.000000000 -0400
++++ antigrav-0.0.2/src/main.cpp	2007-12-15 11:27:56.000000000 -0500
+@@ -22,6 +22,7 @@
+ MFNGLACTIVETEXTUREARBPROC mglActiveTextureARB = NULL;
+ #endif
+ 
++bool opt_sound = true;
+ bool opt_fullscreen = true;
+ bool opt_fsaa = false;
+ int opt_width = 1024;
+@@ -135,7 +136,8 @@
+ 	if(alutInit(&argc, argv) != AL_TRUE)
+ 	{
+ 		fprintf(stderr, "Can't initialize OpenAL: %s\n", alutGetErrorString(alutGetError()));
+-		return -1;
++		fprintf(stderr, "Turning off sound effects.\n");
++		opt_sound = false;
+ 	}
+ 
+ 	if(chdir(DATADIR) != 0)
+@@ -167,6 +169,11 @@
+ 	return 0;
+ }
+ 
++void swapWavBytes(Uint8 *buffer, Uint32 length)
++{
++       swab(buffer, buffer, length);
++}
++
+ ALuint loadWavBuffer(const char *filename)
+ {
+ 	ALuint buffer;
+@@ -188,20 +195,40 @@
+ 	
+ 	if(wav_spec.channels == 1)
+ 	{
+-		if(wav_spec.format == AUDIO_U8) format = AL_FORMAT_MONO8;
+-		else if(wav_spec.format == AUDIO_S16SYS) format = AL_FORMAT_MONO16;
+-		else
++		switch(wav_spec.format)
+ 		{
++		case AUDIO_U8:
++			format = AL_FORMAT_MONO8;
++			break;
++		case AUDIO_S16LSB:
++		case AUDIO_S16MSB:
++			format = AL_FORMAT_MONO16;
++			if (wav_spec.format != AUDIO_S16SYS)
++			{
++				swapWavBytes(wav_buffer, wav_length);
++			}
++			break;
++		default:
+ 			fprintf(stderr, "Can't open %s : unknown audio format\n", filename);
+ 			SDL_FreeWAV(wav_buffer);
+ 			return AL_NONE;
+ 		}
+ 	} else if(wav_spec.channels == 2)
+ 	{
+-		if(wav_spec.format == AUDIO_U8) format = AL_FORMAT_STEREO8;
+-		else if(wav_spec.format == AUDIO_S16SYS) format = AL_FORMAT_STEREO16;
+-		else
++		switch(wav_spec.format)
+ 		{
++		case AUDIO_U8:
++			format = AL_FORMAT_STEREO8;
++			break;
++		case AUDIO_S16LSB:
++		case AUDIO_S16MSB:
++			format = AL_FORMAT_STEREO16;
++			if (wav_spec.format != AUDIO_S16SYS)
++			{
++				swapWavBytes(wav_buffer, wav_length);
++			}
++			break;
++		default:
+ 			fprintf(stderr, "Can't open %s : unknown audio format\n", filename);
+ 			SDL_FreeWAV(wav_buffer);
+ 			return AL_NONE;
+diff -urN antigrav-0.0.2.orig/src/main.cpp.orig antigrav-0.0.2/src/main.cpp.orig
+--- antigrav-0.0.2.orig/src/main.cpp.orig	1969-12-31 19:00:00.000000000 -0500
++++ antigrav-0.0.2/src/main.cpp.orig	2006-08-04 15:38:31.000000000 -0400
+@@ -0,0 +1,227 @@
++#define GL_GLEXT_PROTOTYPES
++
++#include "SDL.h"
++#include "SDL_opengl.h"
++#include <AL/alut.h>
++#include <AL/al.h>
++#include <unistd.h>
++#include <cstdlib>
++#include <cstdio>
++#include <cmath>
++#include <ctime>
++
++#include <getopt.h>
++
++#include "antigrav.h"
++#include "extensions.h"
++
++void mainLoop(void);
++
++#ifdef HAVE_MULTITEX
++MFNGLMULTITEXCOORD2FVPROC mglMultiTexCoord2fv = NULL;
++MFNGLACTIVETEXTUREARBPROC mglActiveTextureARB = NULL;
++#endif
++
++bool opt_fullscreen = true;
++bool opt_fsaa = false;
++int opt_width = 1024;
++const char *help_msg =
++"Usage: antigrav [options]\n\
++Options:\n\
++  -h, --help\t\tprint this help, then exit\n\
++  -f, --fsaa\t\tenable full screen antialiasing\n\
++  -w, --windowed\trun in windowed mode\n\
++  -r, --resolution=RES\tset resolution to RES, 1024 for 1024x768, 800 for 800x600, etc\n";
++
++int parse_args(int argc, char *argv[])
++{
++	
++	while(true)
++	{
++		int option_index = 0;
++		static struct option long_options[] = {
++			{"help", no_argument, 0, 'h'},
++			{"fsaa", no_argument, 0, 'f'},
++			{"windowed", no_argument, 0, 'w'},
++			{"resolution", required_argument, 0, 'r'},
++			{0, 0, 0, 0}
++		};
++
++		int c = getopt_long(argc, argv, "hfwr:", long_options, &option_index);
++		if(c == -1)
++			break;
++		
++		switch(c)
++		{
++			case 'h':
++				printf(help_msg);
++				return 1;
++				break;
++			case 'f':
++				opt_fsaa = true;
++				break;
++			case 'w':
++				opt_fullscreen = false;
++				break;
++			case 'r':
++				opt_width = atoi(optarg);
++				break;
++			default:
++				puts(help_msg);
++				return 1;
++				break;
++		}
++	}
++	
++	return 0;
++}
++
++void cleanup()
++{
++	SDL_Quit();
++	alutExit();
++}
++
++int main(int argc, char *argv[])
++{
++	SDL_Surface *screen;
++	
++	(void)argc;
++	(void)argv;
++	
++	if(parse_args(argc, argv)) return 0;
++	
++	atexit(cleanup);
++
++	if(SDL_Init(SDL_INIT_VIDEO) != 0)
++	{
++		fprintf(stderr, "Can't initialize SDL: %s\n", SDL_GetError());
++		return -1;
++	}
++	
++// 	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
++// 	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
++// 	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
++// 	SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
++	if(opt_fsaa)
++	{
++		SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
++		SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
++	}
++
++	Uint32 flags = SDL_OPENGL;
++	if(opt_fullscreen) flags |= SDL_FULLSCREEN;
++	
++	int width = opt_width;
++	int height = width * 3 / 4;
++
++	screen = SDL_SetVideoMode(width, height, 0, flags);
++	if(screen == NULL)
++	{
++		fprintf(stderr, "Can't set video mode: %s\n", SDL_GetError());
++		return -1;
++	}
++	
++#ifdef HAVE_MULTITEX
++	mglActiveTextureARB = (MFNGLACTIVETEXTUREARBPROC)SDL_GL_GetProcAddress("glActiveTextureARB");
++	mglMultiTexCoord2fv = (MFNGLMULTITEXCOORD2FVPROC)SDL_GL_GetProcAddress("glMultiTexCoord2fv");
++	if(mglActiveTextureARB == NULL || mglMultiTexCoord2fv == NULL)
++	{
++		fprintf(stderr, "Multitexturing extensions not available!\n");
++		return -1;
++	}
++#endif
++
++	if(alutInit(&argc, argv) != AL_TRUE)
++	{
++		fprintf(stderr, "Can't initialize OpenAL: %s\n", alutGetErrorString(alutGetError()));
++		return -1;
++	}
++
++	if(chdir(DATADIR) != 0)
++	{
++		if(chdir("../data") != 0)
++		{
++			fprintf(stderr, "Can't find data directory in %s or %s\n", DATADIR, "../data");
++			return -1;
++		}
++	}
++	
++	SDL_WM_SetCaption("antigravitaattori", "antigravitaattori");
++	
++	// disable mouse cursor
++	SDL_ShowCursor(SDL_DISABLE);
++
++	Game &game = Game::getInstance();
++	if(game.init()) return 1;
++	if(Menu::init()) return 1;
++
++	Menu menu;
++	while(1) {
++		if(menu.show())
++			return 0;
++		if(game.gameLoop())
++			return 0;
++	}
++	
++	return 0;
++}
++
++ALuint loadWavBuffer(const char *filename)
++{
++	ALuint buffer;
++	alGenBuffers(1, &buffer);
++	if(!alIsBuffer(buffer)) return AL_NONE;
++	
++	SDL_AudioSpec wav_spec;
++	Uint8 *wav_buffer;
++	Uint32 wav_length;
++	if(SDL_LoadWAV(filename, &wav_spec, &wav_buffer, &wav_length) == NULL)
++	{
++		fprintf(stderr, "Can't open %s : %s\n", filename, SDL_GetError());
++		return AL_NONE;
++	}
++
++
++// 	AL_FORMAT_MONO8, AL_FORMAT_MONO16, AL_FORMAT_STEREO8, and AL_FORMAT_STEREO16.
++	int format;
++	
++	if(wav_spec.channels == 1)
++	{
++		if(wav_spec.format == AUDIO_U8) format = AL_FORMAT_MONO8;
++		else if(wav_spec.format == AUDIO_S16SYS) format = AL_FORMAT_MONO16;
++		else
++		{
++			fprintf(stderr, "Can't open %s : unknown audio format\n", filename);
++			SDL_FreeWAV(wav_buffer);
++			return AL_NONE;
++		}
++	} else if(wav_spec.channels == 2)
++	{
++		if(wav_spec.format == AUDIO_U8) format = AL_FORMAT_STEREO8;
++		else if(wav_spec.format == AUDIO_S16SYS) format = AL_FORMAT_STEREO16;
++		else
++		{
++			fprintf(stderr, "Can't open %s : unknown audio format\n", filename);
++			SDL_FreeWAV(wav_buffer);
++			return AL_NONE;
++		}
++	} else
++	{
++		fprintf(stderr, "Can't open %s : unknown audio format\n", filename);
++		SDL_FreeWAV(wav_buffer);
++		return AL_NONE;
++	}
++
++	alBufferData(buffer, format, wav_buffer, wav_length, wav_spec.freq);
++	SDL_FreeWAV(wav_buffer);
++	
++	if(alGetError() != AL_NO_ERROR)
++	{
++		fprintf(stderr, "Can't open %s : OpenAL error\n", filename);
++		return AL_NONE;
++	}
++
++	return buffer;
++}
++

Added: packages/trunk/antigrav/debian/patches/series
===================================================================
--- packages/trunk/antigrav/debian/patches/series	                        (rev 0)
+++ packages/trunk/antigrav/debian/patches/series	2007-12-15 21:36:14 UTC (rev 4958)
@@ -0,0 +1,2 @@
+01_fix_png_load.diff
+02_fix_sound.diff

Modified: packages/trunk/antigrav/debian/rules
===================================================================
--- packages/trunk/antigrav/debian/rules	2007-12-15 18:44:35 UTC (rev 4957)
+++ packages/trunk/antigrav/debian/rules	2007-12-15 21:36:14 UTC (rev 4958)
@@ -2,6 +2,8 @@
 # Uncomment this to turn on verbose mode.
 #export DH_VERBOSE=1
 
+include /usr/share/quilt/quilt.make
+
 # These are used for cross-compiling and for saving the configure script
 # from having to guess our platform (since we know it already)
 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
@@ -15,7 +17,7 @@
 	CFLAGS += -O2
 endif
 
-config.status: configure
+config.status: patch configure
 	dh_testdir
 	./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --bindir=\$${prefix}/games --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"
 
@@ -26,7 +28,7 @@
 	$(MAKE)
 	touch $@
 
-clean:
+clean: unpatch
 	dh_testdir
 	dh_testroot
 	rm -f build-stamp 




More information about the Pkg-games-commits mailing list