mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-20 22:16:57 +00:00
Cherry pick several improvements from #455
- Use texture over texture2D - the latter was deprecated in GLSL 1.30. - Cache the tbo buffer - this saves an allocation when monitors update. Closes #455. While the rest of the PR has some nice changes, it performs signlificantly worse on my system.
This commit is contained in:
parent
085ae2e74a
commit
014bf55cd4
@ -35,6 +35,7 @@ import static dan200.computercraft.shared.peripheral.monitor.TileMonitor.RENDER_
|
||||
public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMonitor>
|
||||
{
|
||||
private static final float MARGIN = (float) (TileMonitor.RENDER_MARGIN * 1.1);
|
||||
private static ByteBuffer tboContents;
|
||||
|
||||
@Override
|
||||
public void render( @Nonnull TileMonitor tileEntity, double posX, double posY, double posZ, float f, int i, float f2 )
|
||||
@ -162,7 +163,14 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
||||
|
||||
if( redraw )
|
||||
{
|
||||
ByteBuffer monitorBuffer = GLAllocation.createDirectByteBuffer( width * height * 3 );
|
||||
int size = width * height * 3;
|
||||
if( tboContents == null || tboContents.capacity() < size )
|
||||
{
|
||||
tboContents = GLAllocation.createDirectByteBuffer( size );
|
||||
}
|
||||
|
||||
ByteBuffer monitorBuffer = tboContents;
|
||||
monitorBuffer.position( 0 );
|
||||
for( int y = 0; y < height; y++ )
|
||||
{
|
||||
TextBuffer text = terminal.getLine( y ), textColour = terminal.getTextColourLine( y ), background = terminal.getBackgroundColourLine( y );
|
||||
|
@ -35,6 +35,6 @@ void main() {
|
||||
int bg = int(texelFetch(u_tbo, index + 2).r * 255.0);
|
||||
|
||||
vec2 pos = (term_pos - corner) * vec2(FONT_WIDTH, FONT_HEIGHT);
|
||||
vec4 img = texture2D(u_font, (texture_corner(character) + pos) / 256.0);
|
||||
vec4 img = texture(u_font, (texture_corner(character) + pos) / 256.0);
|
||||
colour = vec4(mix(u_palette[bg], img.rgb * u_palette[fg], img.a * mult), 1.0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user