# HG changeset patch
# User Carli@Carli-PC
# Date 1243442933 -7200
# Node ID 868b7eff614ce2cd8716ec2fed3342d85ca5870e
# Parent  8fe3e2685f60c4d99b4cd27ebc4eef26c20cac20
Landscape shader is working

diff -r 8fe3e2685f60 -r 868b7eff614c engine/src/C4Landscape.cpp
--- a/engine/src/C4Landscape.cpp	Wed May 27 13:48:46 2009 +0200
+++ b/engine/src/C4Landscape.cpp	Wed May 27 18:48:53 2009 +0200
@@ -294,8 +294,17 @@
 	// blit landscape
 	if (Game.GraphicsSystem.ShowSolidMask)
 		Application.DDraw->Blit8Fast(Surface8, cgo.TargetX, cgo.TargetY, cgo.Surface, cgo.X,cgo.Y,cgo.Wdt,cgo.Hgt);
-	else
-		Application.DDraw->BlitLandscape(Surface32, AnimationSurface, &Game.GraphicsResource.sfcLiquidAnimation, cgo.TargetX, cgo.TargetY, cgo.Surface, cgo.X,cgo.Y,cgo.Wdt,cgo.Hgt,&Game.Material.Tex[0]);
+	else
+	{
+	    for (int i=0;i<C4M_MaxTexIndex+1;i++)
+	    {
+	    	Game.Material.Tex[i]=0;
+			if(Game.TextureMap.GetEntry(i))
+				if(Game.TextureMap.GetEntry(i)->getPattern().getSurface())
+					Game.Material.Tex[i]=(*Game.TextureMap.GetEntry(i)->getPattern().getSurface()->ppTex)->texName;
+	    };
+		Application.DDraw->BlitLandscape(Surface32, AnimationSurface, &Game.GraphicsResource.sfcLiquidAnimation, cgo.TargetX, cgo.TargetY, cgo.Surface, cgo.X,cgo.Y,cgo.Wdt,cgo.Hgt,&Game.Material.Tex[0]);
+	}
 	if (Modulation) Application.DDraw->DeactivateBlitModulation();
 	}
 
diff -r 8fe3e2685f60 -r 868b7eff614c engine/src/C4Material.cpp
--- a/engine/src/C4Material.cpp	Wed May 27 13:48:46 2009 +0200
+++ b/engine/src/C4Material.cpp	Wed May 27 18:48:53 2009 +0200
@@ -406,7 +406,6 @@
 		// search/create entry in texmap
 		Map[cnt].DefaultMatTex = Game.TextureMap.GetIndex(Map[cnt].Name, szTextureOverlay, TRUE,
 			FormatString("DefaultMatTex of mat %s", Map[cnt].Name).getData());
-		Tex[Map[cnt].DefaultMatTex%128] = 1;
 		// init PXS facet
 		SURFACE sfcTexture;
 		C4Texture * Texture;
@@ -416,8 +415,6 @@
 				if (sfcTexture=Texture->Surface32)
 				{
 					Map[cnt].PXSFace.Set(sfcTexture, Map[cnt].PXSGfxRt.x, Map[cnt].PXSGfxRt.y, Map[cnt].PXSGfxRt.Wdt, Map[cnt].PXSGfxRt.Hgt);
-					//(*Map[cnt].PXSFace.Surface->ppTex)->Unlock();
-					//Tex[Map[cnt].DefaultMatTex%128]=(*Map[cnt].PXSFace.Surface->ppTex)->texName;
 				};
             };
 		// evaluate reactions for that material
diff -r 8fe3e2685f60 -r 868b7eff614c standard/inc/StdDDraw2.h
--- a/standard/inc/StdDDraw2.h	Wed May 27 13:48:46 2009 +0200
+++ b/standard/inc/StdDDraw2.h	Wed May 27 18:48:53 2009 +0200
@@ -121,8 +121,8 @@
 // pattern
 class CPattern
 	{
-	private:
-		// pattern surface for new-style patterns
+	private:
+		// pattern surface for new-style patterns
 		class CSurface *sfcPattern32;
 		// Faster access
 		uint32_t * CachedPattern; int Wdt; int Hgt;
@@ -134,8 +134,9 @@
 		uint32_t *pClrs;
 		// alpha array for old-style patterns
 		uint32_t *pAlpha;
-	public:
-		CPattern& operator=(const CPattern&);
+	public:
+		CPattern& operator=(const CPattern&);
+		const CSurface *getSurface() const { return sfcPattern32; }
 		bool PatternClr(int iX, int iY, BYTE &byClr, DWORD &dwClr, CStdPalette &rPal) const;	// apply pattern to color
 		bool IsNewStyle() { if (sfcPattern32) return true; }
 		bool Set(class CSurface *sfcSource, int iZoom=0, bool fMonochrome=false);	// set and enable pattern
diff -r 8fe3e2685f60 -r 868b7eff614c standard/src/StdGL.cpp
--- a/standard/src/StdGL.cpp	Wed May 27 13:48:46 2009 +0200
+++ b/standard/src/StdGL.cpp	Wed May 27 18:48:53 2009 +0200
@@ -556,7 +556,10 @@
                             glEnable(GL_TEXTURE_2D);
                             glBindTexture(GL_TEXTURE_2D, mat[cnt]);
                             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-                            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+                            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
+							glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+							glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
 
                             glActiveTexture(GL_TEXTURE0);
 
@@ -868,8 +871,12 @@
 		"SGE tmp.r, tmp.b, 0.5015;\n" //Tunnel?
 		"MAD tmp.r, tmp.r, -0.5019, tmp.b;\n"
 		"SGE col.z, tmp.r, col.z;\n" //mat identified?
-		"SLT col.y, tmp.r, col.y;\n"
-        "TXP tmp, fragment.texcoord, texture[1], 2D;\n"
+		"SLT col.y, tmp.r, col.y;\n"
+		"TEMP coo;\n"
+		"MOV coo, fragment.texcoord;\n"
+		"MUL coo.x, coo.x, 7.0;\n"
+		"MUL coo.y, coo.y, 7.0;\n"
+        "TXP tmp, coo, texture[1], 2D;\n"
 		"MUL tmp.a, col.y, col.z;\n"
 		"SUB tmp.a, 1.0, tmp.a;\n"
 		;
diff -r 8fe3e2685f60 -r 868b7eff614c standard/src/StdSurface2.cpp
--- a/standard/src/StdSurface2.cpp	Wed May 27 13:48:46 2009 +0200
+++ b/standard/src/StdSurface2.cpp	Wed May 27 18:48:53 2009 +0200
@@ -401,7 +401,7 @@
 	}
 
 #ifdef USE_GL
-bool CSurface::CreatePrimaryGLTextures()
+/*bool CSurface::CreatePrimaryGLTextures()
 	{
 	if (!pGL) return false;
 	// primary OpenGL-surface: ensure context is selected
@@ -424,6 +424,7 @@
 	// done, success
 	return true;
 	}
+*/
 #endif
 
 #ifdef USE_DIRECTX
