Index: Makefile
===================================================================
RCS file: /cvsroot/sauerbraten/sauerbraten/src/Makefile,v
retrieving revision 1.71
diff -r1.71 Makefile
7c7
< CLIENT_LIBS= -Lenet -lenet -L/usr/X11R6/lib `sdl-config --libs` -lSDL_image -lSDL_mixer -lz -lGL -lGLU 
---
> CLIENT_LIBS= -Lenet -lenet -L/usr/X11R6/lib `sdl-config --libs` -lSDL_image -lSDL_mixer -lz -lGL
Index: engine/engine.h
===================================================================
RCS file: /cvsroot/sauerbraten/sauerbraten/src/engine/engine.h,v
retrieving revision 1.295
diff -r1.295 engine.h
129c129
< extern void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipit, GLenum component = GL_RGB, GLenum target = GL_TEXTURE_2D, bool compress = false, bool filter = true);
---
> extern void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipit, GLenum component = GL_RGB, GLenum target = GL_TEXTURE_2D, bool compress = false, bool filter = true, int pw = 0, int ph = 0);
Index: engine/rendergl.cpp
===================================================================
RCS file: /cvsroot/sauerbraten/sauerbraten/src/engine/rendergl.cpp,v
retrieving revision 1.464
diff -r1.464 rendergl.cpp
679c679,680
<     gluPerspective(fovy, aspect, 0.54f, farplane);
---
>     GLdouble ydist = 0.54 * tan(fovy/2*RAD), xdist = ydist * aspect;
>     glFrustum(-xdist, xdist, -ydist, ydist, 0.54, farplane);
Index: engine/texture.cpp
===================================================================
RCS file: /cvsroot/sauerbraten/sauerbraten/src/engine/texture.cpp,v
retrieving revision 1.132
diff -r1.132 texture.cpp
5a6,64
> #define FUNCNAME(name) name##1
> #define DEFPIXEL uint OP(r, 0);
> #define PIXELOP OP(r, 0);
> #define BPP 1
> #include "scale.h"
> 
> #define FUNCNAME(name) name##2
> #define DEFPIXEL uint OP(r, 0), OP(g, 1);
> #define PIXELOP OP(r, 0); OP(g, 1);
> #define BPP 2
> #include "scale.h"
> 
> #define FUNCNAME(name) name##3
> #define DEFPIXEL uint OP(r, 0), OP(g, 1), OP(b, 2);
> #define PIXELOP OP(r, 0); OP(g, 1); OP(b, 2);
> #define BPP 3
> #include "scale.h"
> 
> #define FUNCNAME(name) name##4
> #define DEFPIXEL uint OP(r, 0), OP(g, 1), OP(b, 2), OP(a, 3);
> #define PIXELOP OP(r, 0); OP(g, 1); OP(b, 2); OP(a, 3);
> #define BPP 4
> #include "scale.h"
> 
> static void scaletexture(uchar *src, uint sw, uint sh, uint bpp, uchar *dst, uint dw, uint dh)
> {
>     if(sw == dw*2 && sh == dh*2)
>     {
>         switch(bpp)
>         {
>             case 1: return halvetexture1(src, sw, sh, dst);
>             case 2: return halvetexture2(src, sw, sh, dst);
>             case 3: return halvetexture3(src, sw, sh, dst);
>             case 4: return halvetexture4(src, sw, sh, dst);
>         }
>     }
>     else if(sw < dw || sh < dh || sw&(sw-1) || sh&(sh-1))
>     {
>         switch(bpp)
>         {
>             case 1: return scaletexture1(src, sw, sh, dst, dw, dh);
>             case 2: return scaletexture2(src, sw, sh, dst, dw, dh);
>             case 3: return scaletexture3(src, sw, sh, dst, dw, dh);
>             case 4: return scaletexture4(src, sw, sh, dst, dw, dh);
>         }
>     }
>     else
>     {
>         switch(bpp)
>         {
>             case 1: return shifttexture1(src, sw, sh, dst, dw, dh);
>             case 2: return shifttexture2(src, sw, sh, dst, dw, dh);
>             case 3: return shifttexture3(src, sw, sh, dst, dw, dh);
>             case 4: return shifttexture4(src, sw, sh, dst, dw, dh);
>         }
>     }
> }
> 
> 
200c259,304
< void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipit, GLenum component, GLenum subtarget, bool compress, bool filter)
---
> void resizetexture(int w, int h, bool mipmap, GLenum target, int &tw, int &th)
> {
>     int hwlimit = target==GL_TEXTURE_CUBE_MAP_ARB ? hwcubetexsize : hwtexsize,
>         sizelimit = mipmap && maxtexsize ? min(maxtexsize, hwlimit) : hwlimit;
>     w = min(w, sizelimit);
>     h = min(h, sizelimit);
>     if(mipmap || (!hasNP2 && (w&(w-1) || h&(h-1))))
>     {
>         tw = th = 1;
>         while(tw < w) tw *= 2;
>         while(th < h) th *= 2;
>         if(w < tw - tw/2) tw /= 2;
>         if(h < th - th/2) th /= 2;
>     }
>     else
>     {
>         tw = w;
>         th = h;
>     }
> }
> 
> void uploadtexture(GLenum target, GLenum internal, int tw, int th, GLenum format, GLenum type, void *pixels, int pw, int ph, bool mipmap)
> {
>     int bpp = formatsize(format);
>     uchar *buf = NULL;
>     if(pw!=tw || ph!=th) 
>     {
>         buf = new uchar[tw*th*bpp];
>         scaletexture((uchar *)pixels, pw, ph, bpp, buf, tw, th);
>     }
>     for(int level = 0;; level++)
>     {
>         uchar *src = buf ? buf : (uchar *)pixels;
>         if(target==GL_TEXTURE_1D) glTexImage1D(target, level, internal, tw, 0, format, type, src);
>         else glTexImage2D(target, level, internal, tw, th, 0, format, type, src);
>         if(!mipmap || (hasGM && hwmipmap) || max(tw, th) <= 1) break;
>         int srcw = tw, srch = th;
>         if(tw > 1) tw /= 2;
>         if(th > 1) th /= 2;
>         if(!buf) buf = new uchar[tw*th*bpp];
>         scaletexture(src, srcw, srch, bpp, buf, tw, th);
>     }
>     if(buf) delete[] buf;
> }
> 
> void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipit, GLenum component, GLenum subtarget, bool compress, bool filter, int pw, int ph)
265,275c369,372
<     uchar *scaled = NULL;
<     int hwlimit = target==GL_TEXTURE_CUBE_MAP_ARB ? hwcubetexsize : hwtexsize,
<         sizelimit = mipit && maxtexsize ? min(maxtexsize, hwlimit) : hwlimit;
<     if(pixels && max(w, h) > sizelimit && (!mipit || sizelimit < hwlimit))
<     {
<         int oldw = w, oldh = h;
<         while(w > sizelimit || h > sizelimit) { w /= 2; h /= 2; }
<         scaled = new uchar[w*h*formatsize(format)];
<         gluScaleImage(format, oldw, oldh, type, pixels, w, h, type, scaled);
<         pixels = scaled;
<     }
---
>     if(!pw) pw = w;
>     if(!ph) ph = h;
>     int tw, th;
>     resizetexture(w, h, mipit, target, tw, th);
278,291c375,376
<         GLenum compressed = compressedformat(component, w, h, compress);
<         if(target==GL_TEXTURE_1D)
<         {
<             if(hasGM && hwmipmap) glTexImage1D(subtarget, 0, compressed, w, 0, format, type, pixels);
<             else if(gluBuild1DMipmaps(subtarget, compressed, w, format, type, pixels))
<             {
<                 if(compressed==component || gluBuild1DMipmaps(subtarget, component, w, format, type, pixels)) conoutf(CON_ERROR, "could not build mipmaps");
<             }
<         }
<         else if(hasGM && hwmipmap) glTexImage2D(subtarget, 0, compressed, w, h, 0, format, type, pixels);
<         else if(gluBuild2DMipmaps(subtarget, compressed, w, h, format, type, pixels))
<         {
<             if(compressed==component || gluBuild2DMipmaps(subtarget, component, w, h, format, type, pixels)) conoutf(CON_ERROR, "could not build mipmaps");
<         }
---
>         GLenum compressed = compressedformat(component, tw, th, compress);
>         uploadtexture(subtarget, compressed, tw, th, format, type, pixels, pw, ph, true);
293,295c378
<     else if(target==GL_TEXTURE_1D) glTexImage1D(subtarget, 0, component, w, 0, format, type, pixels);
<     else glTexImage2D(subtarget, 0, component, w, h, 0, format, type, pixels);
<     if(scaled) delete[] scaled;
---
>     else uploadtexture(subtarget, component, tw, th, format, type, pixels, pw, ph, false); 
314,336d396
< static void resizetexture(int &w, int &h, bool mipit = true, GLenum format = GL_RGB, GLenum target = GL_TEXTURE_2D)
< {
<     if(mipit) return;
<     int hwlimit = target==GL_TEXTURE_CUBE_MAP_ARB ? hwcubetexsize : hwtexsize,
<         sizelimit = mipit && maxtexsize ? min(maxtexsize, hwlimit) : hwlimit;
<     int w2 = w, h2 = h;
<     if(!hasNP2 && (w&(w-1) || h&(h-1)))
<     {
<         w2 = h2 = 1;
<         while(w2 < w) w2 *= 2;
<         while(h2 < h) h2 *= 2;
<         if(w2 > sizelimit || (w - w2)/2 < (w2 - w)/2) w2 /= 2;
<         if(h2 > sizelimit || (h - h2)/2 < (h2 - h)/2) h2 /= 2;
<     }
<     while(w2 > sizelimit || h2 > sizelimit)
<     {
<         w2 /= 2;
<         h2 /= 2;
<     }
<     w = w2;
<     h = h2;
< }
< 
365,373c425
<     resizetexture(t->w, t->h, mipit, format);
<     uchar *pixels = (uchar *)s->pixels;
<     if(t->w != t->xs || t->h != t->ys)
<     {
<         if(t->w*t->h > t->xs*t->ys) pixels = new uchar[formatsize(format)*t->w*t->h];
<         gluScaleImage(format, t->xs, t->ys, GL_UNSIGNED_BYTE, s->pixels, t->w, t->h, GL_UNSIGNED_BYTE, pixels);
<     }
<     createtexture(t->id, t->w, t->h, pixels, clamp, mipit, format, GL_TEXTURE_2D, compress);
<     if(pixels!=s->pixels) delete[] pixels;
---
>     createtexture(t->id, t->w, t->h, s->pixels, clamp, mipit, format, GL_TEXTURE_2D, compress, true, t->xs, t->ys);
421c473
<     gluScaleImage(texformat(os->format->BitsPerPixel), os->w, os->h, GL_UNSIGNED_BYTE, os->pixels, w, h, GL_UNSIGNED_BYTE, ns->pixels);
---
>     scaletexture((uchar *)os->pixels, os->w, os->h, os->format->BytesPerPixel, (uchar *)ns->pixels, w, h);
477a530
>     if(max(s->w, s->h) > (1<<12)) { SDL_FreeSurface(s); conoutf(CON_ERROR, "texture size exceeded %dx%d pixels: %s", file, 1<<12, 1<<12); return NULL; }
926c979
<     resizetexture(cmw, cmh, true, GL_RGB5, GL_TEXTURE_CUBE_MAP_ARB);
---
>     resizetexture(cmw, cmh, true, GL_TEXTURE_CUBE_MAP_ARB, cmw, cmh);
930c983
<     int bufsize = 3*max(cmw, tsize)*max(cmh, tsize);
---
>     int bufsize = 3*tsize*tsize;
938d990
<         if(tw[i]!=cmw || th[i]!=cmh) gluScaleImage(GL_RGB, tw[i], th[i], GL_UNSIGNED_BYTE, pixels, cmw, cmh, GL_UNSIGNED_BYTE, pixels);
940,941c992,994
<         reorienttexture(pixels, cmw, cmh, 3, rpixels, side.flipx, side.flipy, side.swapxy); 
<         createtexture(!i ? tex : 0, cmw, cmh, rpixels, 3, true, GL_RGB5, side.target);
---
>         reorienttexture(pixels, tw[i], th[i], 3, rpixels, side.flipx, side.flipy, side.swapxy); 
>         if(side.swapxy) swap(tw[i], th[i]);
>         createtexture(!i ? tex : 0, cmw, cmh, rpixels, 3, true, GL_RGB5, side.target, false, true, tw[i], th[i]);
1000c1053
<     resizetexture(t->w, t->h, mipit, format, GL_TEXTURE_CUBE_MAP_ARB);
---
>     resizetexture(t->w, t->h, mipit, GL_TEXTURE_CUBE_MAP_ARB, t->w, t->h);
1007,1012c1060
<         if(s->w != t->w || s->h != t->h)
<         {
<             if(!pixels) pixels = new uchar[formatsize(format)*t->w*t->h];
<             gluScaleImage(format, s->w, s->h, GL_UNSIGNED_BYTE, s->pixels, t->w, t->h, GL_UNSIGNED_BYTE, pixels);
<         }
<         createtexture(!i ? t->id : 0, t->w, t->h, s->w != t->w || s->h != t->h ? pixels : s->pixels, 3, mipit, format, side.target, compress);
---
>         createtexture(!i ? t->id : 0, t->w, t->h, s->pixels, 3, mipit, format, side.target, compress, true, side.swapxy ? s->w : s->h, side.swapxy ? s->w : s->h);
1101,1102c1149
<         if(texsize<rendersize) gluScaleImage(GL_RGB, rendersize, rendersize, GL_UNSIGNED_BYTE, pixels, texsize, texsize, GL_UNSIGNED_BYTE, pixels);
<         createtexture(tex, texsize, texsize, pixels, 3, true, GL_RGB5, side.target);
---
>         createtexture(tex, texsize, texsize, pixels, 3, true, GL_RGB5, side.target, false, true, rendersize, rendersize);
Index: mingw/Makefile.mingw
===================================================================
RCS file: /cvsroot/sauerbraten/sauerbraten/src/mingw/Makefile.mingw,v
retrieving revision 1.28
diff -r1.28 Makefile.mingw
5c5
< CLIENT_LIBS=-Lenet -Lmingw/lib -lstdc++ -lenet -lmingw32 -lSDLmain -lSDL -lSDL_image -lSDL_mixer -mwindows -lz -lopengl32 -lglu32 -lws2_32 -lwinmm
---
> CLIENT_LIBS=-Lenet -Lmingw/lib -lstdc++ -lenet -lmingw32 -lSDLmain -lSDL -lSDL_image -lSDL_mixer -mwindows -lz -lopengl32 -lws2_32 -lwinmm
Index: mingw/sauerbraten.cbp
===================================================================
RCS file: /cvsroot/sauerbraten/sauerbraten/src/mingw/sauerbraten.cbp,v
retrieving revision 1.15
diff -r1.15 sauerbraten.cbp
47d46
< 			<Add library="glu32" />
Index: vcpp/cube.vcproj
===================================================================
RCS file: /cvsroot/sauerbraten/sauerbraten/src/vcpp/cube.vcproj,v
retrieving revision 1.72
diff -r1.72 cube.vcproj
89c89
< 				AdditionalDependencies="msvcrt.lib zdll.lib opengl32.lib glu32.lib SDLmain.lib SDL.lib SDL_image.lib ws2_32.lib SDL_mixer.lib winmm.lib dbghelp.lib kernel32.lib user32.lib"
---
> 				AdditionalDependencies="msvcrt.lib zdll.lib opengl32.lib SDLmain.lib SDL.lib SDL_image.lib ws2_32.lib SDL_mixer.lib winmm.lib dbghelp.lib kernel32.lib user32.lib"

