mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 21:52:59 +00:00 
			
		
		
		
	Merge pull request #367 from SquidDev-CC/feature/texture-spacing
Fix texture artifacts when rendering monitors
This commit is contained in:
		| @@ -20,7 +20,7 @@ import java.util.Arrays; | |||||||
|  |  | ||||||
| public class FixedWidthFontRenderer | public class FixedWidthFontRenderer | ||||||
| { | { | ||||||
|     public static ResourceLocation font = new ResourceLocation( "computercraft", "textures/gui/term_font.png" ); |     private static ResourceLocation font = new ResourceLocation( "computercraft", "textures/gui/term_font.png" ); | ||||||
|     public static ResourceLocation background = new ResourceLocation( "computercraft", "textures/gui/term_background.png" ); |     public static ResourceLocation background = new ResourceLocation( "computercraft", "textures/gui/term_background.png" ); | ||||||
|  |  | ||||||
|     public static int FONT_HEIGHT = 9; |     public static int FONT_HEIGHT = 9; | ||||||
| @@ -52,12 +52,15 @@ public class FixedWidthFontRenderer | |||||||
|         float g = (float)colour[1]; |         float g = (float)colour[1]; | ||||||
|         float b = (float)colour[2]; |         float b = (float)colour[2]; | ||||||
|  |  | ||||||
|         renderer.pos( x, y, 0.0 ).tex( (double) (column * FONT_WIDTH) / 256.0, (double) (row * FONT_HEIGHT ) / 256.0 ).color( r, g, b, 1.0f ).endVertex(); |         int xStart = 1 + column * (FONT_WIDTH + 2); | ||||||
|         renderer.pos( x, y + FONT_HEIGHT, 0.0 ).tex( (double) (column * FONT_WIDTH) / 256.0, (double) ((row + 1) * FONT_HEIGHT) / 256.0 ).color( r, g, b, 1.0f ).endVertex(); |         int yStart = 1 + row * (FONT_HEIGHT + 2); | ||||||
|         renderer.pos( x + FONT_WIDTH, y, 0.0 ).tex( (double) ((column + 1) * FONT_WIDTH) / 256.0, (double) (row * FONT_HEIGHT) / 256.0 ).color( r, g, b, 1.0f ).endVertex(); |  | ||||||
|         renderer.pos( x + FONT_WIDTH, y, 0.0 ).tex( (double) ((column + 1) * FONT_WIDTH) / 256.0, (double) (row * FONT_HEIGHT) / 256.0 ).color( r, g, b, 1.0f ).endVertex(); |         renderer.pos( x, y, 0.0 ).tex( xStart / 256.0, yStart / 256.0 ).color( r, g, b, 1.0f ).endVertex(); | ||||||
|         renderer.pos( x, y + FONT_HEIGHT, 0.0 ).tex( (double) (column * FONT_WIDTH) / 256.0, (double) ((row + 1) * FONT_HEIGHT) / 256.0 ).color( r, g, b, 1.0f ).endVertex(); |         renderer.pos( x, y + FONT_HEIGHT, 0.0 ).tex( xStart / 256.0, (yStart + FONT_HEIGHT) / 256.0 ).color( r, g, b, 1.0f ).endVertex(); | ||||||
|         renderer.pos( x + FONT_WIDTH, y + FONT_HEIGHT, 0.0 ).tex( (double) ((column + 1) * FONT_WIDTH) / 256.0, (double) ((row + 1) * FONT_HEIGHT) / 256.0 ).color( r, g, b, 1.0f ).endVertex(); |         renderer.pos( x + FONT_WIDTH, y, 0.0 ).tex( (xStart + FONT_WIDTH) / 256.0, yStart / 256.0 ).color( r, g, b, 1.0f ).endVertex(); | ||||||
|  |         renderer.pos( x + FONT_WIDTH, y, 0.0 ).tex( (xStart + FONT_WIDTH) / 256.0, yStart / 256.0 ).color( r, g, b, 1.0f ).endVertex(); | ||||||
|  |         renderer.pos( x, y + FONT_HEIGHT, 0.0 ).tex( xStart / 256.0, (yStart + FONT_HEIGHT) / 256.0 ).color( r, g, b, 1.0f ).endVertex(); | ||||||
|  |         renderer.pos( x + FONT_WIDTH, y + FONT_HEIGHT, 0.0 ).tex( (xStart + FONT_WIDTH) / 256.0, (yStart + FONT_HEIGHT) / 256.0 ).color( r, g, b, 1.0f ).endVertex(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void drawQuad( VertexBuffer renderer, double x, double y, int color, double width, Palette p, boolean greyscale ) |     private void drawQuad( VertexBuffer renderer, double x, double y, int color, double width, Palette p, boolean greyscale ) | ||||||
| @@ -164,7 +167,7 @@ public class FixedWidthFontRenderer | |||||||
|         if( s != null && textColour != null ) |         if( s != null && textColour != null ) | ||||||
|         { |         { | ||||||
|             // Bind the font texture |             // Bind the font texture | ||||||
|             m_textureManager.bindTexture( font ); |             bindFont(); | ||||||
|              |              | ||||||
|             // Draw the quads |             // Draw the quads | ||||||
|             drawStringTextPart( x, y, s, textColour, greyScale, p ); |             drawStringTextPart( x, y, s, textColour, greyScale, p ); | ||||||
| @@ -179,4 +182,10 @@ public class FixedWidthFontRenderer | |||||||
|         } |         } | ||||||
|         return s.length() * FONT_WIDTH; |         return s.length() * FONT_WIDTH; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public void bindFont() | ||||||
|  |     { | ||||||
|  |         m_textureManager.bindTexture( font ); | ||||||
|  |         GlStateManager.glTexParameteri( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP ); | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -180,7 +180,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon | |||||||
|                         GlStateManager.resetColor(); |                         GlStateManager.resetColor(); | ||||||
|  |  | ||||||
|                         // Draw text |                         // Draw text | ||||||
|                         mc.getTextureManager().bindTexture( FixedWidthFontRenderer.font ); |                         fontRenderer.bindFont(); | ||||||
|                         if( redraw ) |                         if( redraw ) | ||||||
|                         { |                         { | ||||||
|                             // Build text display list |                             // Build text display list | ||||||
| @@ -208,7 +208,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon | |||||||
|                         GlStateManager.resetColor(); |                         GlStateManager.resetColor(); | ||||||
|  |  | ||||||
|                         // Draw cursor |                         // Draw cursor | ||||||
|                         mc.getTextureManager().bindTexture( FixedWidthFontRenderer.font ); |                         fontRenderer.bindFont(); | ||||||
|                         if( redraw ) |                         if( redraw ) | ||||||
|                         { |                         { | ||||||
|                             // Build cursor display list |                             // Build cursor display list | ||||||
|   | |||||||
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 3.7 KiB | 
		Reference in New Issue
	
	Block a user
	 Daniel Ratcliffe
					Daniel Ratcliffe