use of net.minecraft.client.renderer.Tessellator in project Engine by VoltzEngine-Project.
the class Render2DHelper method drawTexturedModalRect.
/**
* Draws a textured rectangle at the stored z-value. Args: x, y, u, v, width, height
*/
public static void drawTexturedModalRect(int p_73729_1_, int p_73729_2_, int p_73729_3_, int p_73729_4_, int p_73729_5_, int p_73729_6_) {
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV((double) (p_73729_1_ + 0), (double) (p_73729_2_ + p_73729_6_), (double) zLevel, (double) ((float) (p_73729_3_ + 0) * f), (double) ((float) (p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double) (p_73729_1_ + p_73729_5_), (double) (p_73729_2_ + p_73729_6_), (double) zLevel, (double) ((float) (p_73729_3_ + p_73729_5_) * f), (double) ((float) (p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double) (p_73729_1_ + p_73729_5_), (double) (p_73729_2_ + 0), (double) zLevel, (double) ((float) (p_73729_3_ + p_73729_5_) * f), (double) ((float) (p_73729_4_ + 0) * f1));
tessellator.addVertexWithUV((double) (p_73729_1_ + 0), (double) (p_73729_2_ + 0), (double) zLevel, (double) ((float) (p_73729_3_ + 0) * f), (double) ((float) (p_73729_4_ + 0) * f1));
tessellator.draw();
}
use of net.minecraft.client.renderer.Tessellator in project Railcraft by Railcraft.
the class LocomotiveRendererDefault method renderLocomotive.
// @Override
// public IIcon[] getItemIcons() {
// return itemIcons;
// }
//
// @Override
// public void registerItemIcons(IIconRegister iconRegister) {
// String tag = "railcraft:locomotives/" + MiscTools.cleanTag(modelTag);
// itemIcons[0] = iconRegister.registerIcon(tag + ".primary");
// itemIcons[1] = iconRegister.registerIcon(tag + ".secondary");
// itemIcons[2] = iconRegister.registerIcon(tag + ".nocolor");
// }
@Override
public void renderLocomotive(ICartRenderer renderer, EntityMinecart cart, int primaryColor, int secondaryColor, @Nullable ResourceLocation emblemTexture, float light, float time) {
OpenGL.glPushMatrix();
OpenGL.glPushAttrib(GL11.GL_ENABLE_BIT);
// OpenGL.glEnable(GL11.GL_BLEND);
// OpenGL.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
OpenGL.glScalef(-1F, -1F, 1.0F);
color[0] = primaryColor;
color[1] = secondaryColor;
for (int pass = 0; pass < textures.length; pass++) {
renderer.bindTex(textures[pass]);
int c = color[pass];
float dim = 1.0F;
float c1 = (float) (c >> 16 & 255) / 255.0F;
float c2 = (float) (c >> 8 & 255) / 255.0F;
float c3 = (float) (c & 255) / 255.0F;
OpenGL.glColor4f(c1 * dim, c2 * dim, c3 * dim, SeasonPlugin.isGhostTrain(cart) ? 0.5F : 1);
model.render(cart, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
}
OpenGL.glPopAttrib();
if (emblemTexture != null) {
renderer.bindTex(emblemTexture);
Tessellator tess = Tessellator.getInstance();
VertexBuffer vertexBuffer = tess.getBuffer();
// float size = 0.22F;
// float offsetX = -0.25F;
// float offsetY = -0.25F;
// float offsetZ = -0.46F;
// TODO: Test this!
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
vertexBuffer.pos(emblemOffsetX - emblemSize, emblemOffsetY - emblemSize, emblemOffsetZ).tex(0, 0).endVertex();
vertexBuffer.pos(emblemOffsetX - emblemSize, emblemOffsetY + emblemSize, emblemOffsetZ).tex(0, 1).endVertex();
vertexBuffer.pos(emblemOffsetX + emblemSize, emblemOffsetY + emblemSize, emblemOffsetZ).tex(1, 1).endVertex();
vertexBuffer.pos(emblemOffsetX + emblemSize, emblemOffsetY + -emblemSize, emblemOffsetZ).tex(1, 0).endVertex();
vertexBuffer.pos(emblemOffsetX + emblemSize, emblemOffsetY + -emblemSize, -emblemOffsetZ).tex(0, 0).endVertex();
vertexBuffer.pos(emblemOffsetX + emblemSize, emblemOffsetY + emblemSize, -emblemOffsetZ).tex(0, 1).endVertex();
vertexBuffer.pos(emblemOffsetX - emblemSize, emblemOffsetY + emblemSize, -emblemOffsetZ).tex(1, 1).endVertex();
vertexBuffer.pos(emblemOffsetX - emblemSize, emblemOffsetY - emblemSize, -emblemOffsetZ).tex(1, 0).endVertex();
tess.draw();
}
// OpenGL.glDisable(GL11.GL_BLEND);
OpenGL.glPopMatrix();
}
use of net.minecraft.client.renderer.Tessellator in project Railcraft by Railcraft.
the class TESRSignals method doRenderAspect.
protected void doRenderAspect(double x, double y, double z) {
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexBuffer = tessellator.getBuffer();
final float depth = 1.95F * RenderTools.PIXEL;
OpenGL.glPushMatrix();
// no idea why this is necessary, but without it the texture brightness varies depending on what is on screen
GL11.glNormal3f(0.0F, 0.0F, 1.0F);
OpenGL.glEnable(GL11.GL_LIGHTING);
OpenGL.glColor3f(1, 1, 1);
OpenGL.glTranslated(x, y, z);
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
if (lampInfo.glow)
RenderTools.setBrightness(0.875F);
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
if (lampInfo.sides[2].render) {
TextureAtlasSprite texture = lampInfo.sides[2].texture;
vertexBuffer.pos(0, 0, depth).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(0, 1, depth).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(1, 1, depth).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(1, 0, depth).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(16)).endVertex();
}
if (lampInfo.sides[3].render) {
TextureAtlasSprite texture = lampInfo.sides[3].texture;
vertexBuffer.pos(0, 0, 1 - depth).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(1, 0, 1 - depth).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(1, 1, 1 - depth).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(0, 1, 1 - depth).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(0)).endVertex();
}
if (lampInfo.sides[4].render) {
TextureAtlasSprite texture = lampInfo.sides[4].texture;
vertexBuffer.pos(depth, 0, 0).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(depth, 0, 1).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(depth, 1, 1).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(depth, 1, 0).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(0)).endVertex();
}
if (lampInfo.sides[5].render) {
TextureAtlasSprite texture = lampInfo.sides[5].texture;
vertexBuffer.pos(1 - depth, 0, 0).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(16)).endVertex();
vertexBuffer.pos(1 - depth, 1, 0).tex(texture.getInterpolatedU(16), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(1 - depth, 1, 1).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(0)).endVertex();
vertexBuffer.pos(1 - depth, 0, 1).tex(texture.getInterpolatedU(0), texture.getInterpolatedV(16)).endVertex();
}
tessellator.draw();
if (lampInfo.glow)
RenderTools.resetBrightness();
lampInfo.resetSidesAndLight();
OpenGL.glPopMatrix();
}
use of net.minecraft.client.renderer.Tessellator in project Railcraft by Railcraft.
the class TESRTurbineGauge method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileSteamTurbine turbine, double x, double y, double z, float partialTicks, int destroyStage) {
if (!turbine.isStructureValid() || turbine.getPatternMarker() != 'W')
// not a gauge block
return;
// half width of the needle
double halfWidth = 0.5 / 16;
// length of the needle (along the center)
double len = 0.26;
// offset to prevent z-fighting
double zOffset = 0.001;
// average the value over time to smooth the needle
double value = turbine.mainGauge = (turbine.mainGauge * 14.0 + turbine.getMainGauge()) / 15.0;
// set the needle angle between 45° (= 0%) and 135° (= 100%)
double angle = Math.toRadians(90 * value + 45);
// vector towards the front of the gauge
int fx = 0, fz = 0;
// vector to the right when looking at the gauge
int rx = 0, rz = 0;
BlockPos patternPos = turbine.getPatternPosition();
if (turbine.getPatternIndex() == 0) {
if (patternPos.getX() == 1) {
fx = -1;
rz = 1;
} else if (patternPos.getX() == 2) {
x++;
z++;
fx = 1;
rz = -1;
}
} else if (turbine.getPatternIndex() == 1)
if (patternPos.getZ() == 1) {
x++;
fz = -1;
rx = -1;
} else if (patternPos.getZ() == 2) {
z++;
fz = 1;
rx = 1;
}
if (fx == 0 && fz == 0 || rx == 0 && rz == 0)
throw new IllegalStateException("can't detect gauge orientation");
// fix lightmap coords to use the brightness value in front of the block, not inside it (which would be just 0)
int lmCoords = turbine.getWorld().getCombinedLight(turbine.getPos().add(fx, 0, fz), 0);
int lmX = lmCoords % 65536;
int lmY = lmCoords / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lmX / 1.0F, lmY / 1.0F);
OpenGL.glDisable(GL11.GL_TEXTURE_2D);
OpenGL.glDisable(GL11.GL_LIGHTING);
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexBuffer = tessellator.getBuffer();
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
// move the origin to the center of the gauge
vertexBuffer.setTranslation(x + rx * 0.5 + fx * zOffset, y + 0.5, z + rz * 0.5 + fz * zOffset);
double cosA = Math.cos(angle);
double sinA = Math.sin(angle);
// displacement along the length of the needle
double glx = cosA * len;
double gly = sinA * len;
// displacement along the width of the needle
double gwx = sinA * halfWidth;
double gwy = cosA * halfWidth;
// half width of the horizontal needle part where it connects to the "case"
double baseOffset = 1. / Math.sin(angle) * halfWidth;
// set the needle color to dark-ish red
int red = 100;
int green = 0;
int blue = 0;
int alpha = 255;
vertexBuffer.pos(-rx * baseOffset, 0, -rz * baseOffset).color(red, green, blue, alpha).endVertex();
vertexBuffer.pos(rx * baseOffset, 0, rz * baseOffset).color(red, green, blue, alpha).endVertex();
vertexBuffer.pos(-rx * glx + rx * gwx, gly + gwy, -rz * glx + rz * gwx).color(red, green, blue, alpha).endVertex();
vertexBuffer.pos(-rx * glx - rx * gwx, gly - gwy, -rz * glx - rz * gwx).color(red, green, blue, alpha).endVertex();
tessellator.draw();
// resetting
vertexBuffer.setTranslation(0, 0, 0);
OpenGL.glEnable(GL11.GL_LIGHTING);
OpenGL.glEnable(GL11.GL_TEXTURE_2D);
}
use of net.minecraft.client.renderer.Tessellator in project LogisticsPipes by RS485.
the class GuiGraphics method drawSlotBackground.
public static void drawSlotBackground(Minecraft mc, int x, int y, int color) {
GuiGraphics.zLevel = 0;
GL11.glColor4f(Color.getRed(color), Color.getGreen(color), Color.getBlue(color), Color.getAlpha(color));
mc.renderEngine.bindTexture(GuiGraphics.SLOT_TEXTURE);
Tessellator var9 = Tessellator.instance;
var9.startDrawingQuads();
var9.addVertexWithUV(x, y + 18, GuiGraphics.zLevel, 0, 1);
var9.addVertexWithUV(x + 18, y + 18, GuiGraphics.zLevel, 1, 1);
var9.addVertexWithUV(x + 18, y, GuiGraphics.zLevel, 1, 0);
var9.addVertexWithUV(x, y, GuiGraphics.zLevel, 0, 0);
var9.draw();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
Aggregations