use of net.minecraft.client.renderer.VertexBuffer in project OpenModularTurrets by OpenModularTurretsTeam.
the class LaserRenderer method renderLaser.
@SuppressWarnings("unused")
private void renderLaser(LaserProjectile par1EntityLaser, double x, double y, double z, float entityYaw, float partialTicks) {
if (par1EntityLaser.getFramesRendered() <= 1) {
par1EntityLaser.setFramesRendered(par1EntityLaser.getFramesRendered() + 1);
return;
}
for (int i = 0; i <= 20; i++) {
par1EntityLaser.getEntityWorld().spawnParticle(EnumParticleTypes.SMOKE_NORMAL, x, y, z, 1.0D, 1.0D, 1.0D);
}
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.pushMatrix();
GlStateManager.disableLighting();
GlStateManager.translate((float) x, (float) y, (float) z);
GlStateManager.rotate(par1EntityLaser.prevRotationYaw + (par1EntityLaser.rotationYaw - par1EntityLaser.prevRotationYaw) * partialTicks - 90.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(par1EntityLaser.prevRotationPitch + (par1EntityLaser.rotationPitch - par1EntityLaser.prevRotationPitch) * partialTicks, 0.0F, 0.0F, 1.0F);
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexbuffer = tessellator.getBuffer();
GlStateManager.enableRescaleNormal();
float f9 = (float) par1EntityLaser.arrowShake - partialTicks;
if (f9 > 0.0F) {
float f10 = -MathHelper.sin(f9 * 3.0F) * f9;
GlStateManager.rotate(f10, 0.0F, 0.0F, 1.0F);
}
GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.scale(0.05625F, 0.05625F, 0.05625F);
GlStateManager.translate(-4.0F, 0.0F, 0.0F);
for (int j = 0; j < 4; ++j) {
GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.glNormal3f(0.0F, 0.0F, 0.05625F);
vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
vertexbuffer.pos(-8.0D, -2.0D, 0.0D).tex(0.0D, 0.0D).endVertex();
vertexbuffer.pos(8.0D, -2.0D, 0.0D).tex(0.5D, 0.0D).endVertex();
vertexbuffer.pos(8.0D, 2.0D, 0.0D).tex(0.5D, 0.15625D).endVertex();
vertexbuffer.pos(-8.0D, 2.0D, 0.0D).tex(0.0D, 0.15625D).endVertex();
tessellator.draw();
}
GlStateManager.disableRescaleNormal();
GlStateManager.enableLighting();
GlStateManager.popMatrix();
}
use of net.minecraft.client.renderer.VertexBuffer in project ImmersiveEngineering by BluSunrize.
the class ManualUtils method drawTexturedRect.
public static void drawTexturedRect(int x, int y, int w, int h, double... uv) {
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer worldrenderer = tessellator.getBuffer();
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
worldrenderer.pos(x, y + h, 0).tex(uv[0], uv[3]).endVertex();
worldrenderer.pos(x + w, y + h, 0).tex(uv[1], uv[3]).endVertex();
worldrenderer.pos(x + w, y, 0).tex(uv[1], uv[2]).endVertex();
worldrenderer.pos(x, y, 0).tex(uv[0], uv[2]).endVertex();
tessellator.draw();
}
use of net.minecraft.client.renderer.VertexBuffer in project minecolonies by Minecolonies.
the class Render method drawOutlineRect.
/**
* Draw an outlined untextured rectangle.
*
* @param x1 lower x
* @param y1 lower y
* @param x2 upper x
* @param y2 upper y
* @param lineWidth line thickness, default of 1.0
* @param color color
*/
public static void drawOutlineRect(final int x1, final int y1, final int x2, final int y2, final float lineWidth, final int color) {
if (lineWidth <= 0.0F) {
// If lineWidth is less than or equal to 0, a GL Error occurs
return;
}
final float a = (float) (((color >> ALPHA_SHIFT) & COLOR_MASK) / COLOR_DIVISOR);
final float r = (float) (((color >> RED_SHIFT) & COLOR_MASK) / COLOR_DIVISOR);
final float g = (float) (((color >> GREEN_SHIFT) & COLOR_MASK) / COLOR_DIVISOR);
final float b = (float) ((color & COLOR_MASK) / COLOR_DIVISOR);
final Tessellator tessellator = Tessellator.getInstance();
final VertexBuffer vertexBuffer = tessellator.getBuffer();
vertexBuffer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION);
GlStateManager.disableTexture2D();
GL11.glLineWidth(lineWidth);
GlStateManager.color(r, g, b, a);
//Since our points do not have any u,v this seems to be the correct code
vertexBuffer.pos(x1, y2, 0.0D).endVertex();
vertexBuffer.pos(x2, y2, 0.0D).endVertex();
vertexBuffer.pos(x2, y1, 0.0D).endVertex();
vertexBuffer.pos(x1, y1, 0.0D).endVertex();
tessellator.draw();
GlStateManager.enableTexture2D();
}
use of net.minecraft.client.renderer.VertexBuffer in project minecolonies by Minecolonies.
the class Pathfinding method renderDebugText.
@SideOnly(Side.CLIENT)
private static void renderDebugText(@NotNull final Node n) {
final String s1 = String.format("F: %.3f [%d]", n.getCost(), n.getCounterAdded());
final String s2 = String.format("G: %.3f [%d]", n.getScore(), n.getCounterVisited());
final FontRenderer fontrenderer = Minecraft.getMinecraft().fontRendererObj;
GlStateManager.pushAttrib();
GlStateManager.pushMatrix();
GlStateManager.translate(0.0F, 0.75F, 0.0F);
GlStateManager.glNormal3f(0.0F, 1.0F, 0.0F);
final RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
GlStateManager.rotate(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
GlStateManager.scale(-0.014F, -0.014F, 0.014F);
GlStateManager.translate(0.0F, 18F, 0.0F);
GlStateManager.depthMask(false);
GlStateManager.disableDepth();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.disableTexture2D();
final int i = Math.max(fontrenderer.getStringWidth(s1), fontrenderer.getStringWidth(s2)) / 2;
final Tessellator tessellator = Tessellator.getInstance();
final VertexBuffer vertexBuffer = tessellator.getBuffer();
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
vertexBuffer.pos((double) (-i - 1), -5.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
vertexBuffer.pos((double) (-i - 1), 12.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
vertexBuffer.pos((double) (i + 1), 12.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
vertexBuffer.pos((double) (i + 1), -5.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
tessellator.draw();
GlStateManager.enableTexture2D();
GlStateManager.translate(0.0F, -5F, 0.0F);
fontrenderer.drawString(s1, -fontrenderer.getStringWidth(s1) / 2, 0, 0xFFFFFFFF);
GlStateManager.translate(0.0F, 8F, 0.0F);
fontrenderer.drawString(s2, -fontrenderer.getStringWidth(s2) / 2, 0, 0xFFFFFFFF);
GlStateManager.enableDepth();
GlStateManager.depthMask(true);
GlStateManager.translate(0.0F, -8F, 0.0F);
fontrenderer.drawString(s1, -fontrenderer.getStringWidth(s1) / 2, 0, 0xFFFFFFFF);
GlStateManager.translate(0.0F, 8F, 0.0F);
fontrenderer.drawString(s2, -fontrenderer.getStringWidth(s2) / 2, 0, 0xFFFFFFFF);
GlStateManager.popMatrix();
GlStateManager.popAttrib();
}
use of net.minecraft.client.renderer.VertexBuffer in project ImmersiveEngineering by BluSunrize.
the class EntityRenderFluorescentTube method doRender.
@Override
public void doRender(EntityFluorescentTube entity, double x, double y, double z, float entityYaw, float partialTicks) {
Tessellator tes = Tessellator.getInstance();
VertexBuffer wr = tes.getBuffer();
GlStateManager.enableRescaleNormal();
ClientUtils.bindAtlas();
if (entity.active) {
GlStateManager.disableRescaleNormal();
GlStateManager.pushAttrib();
GlStateManager.enableBlend();
GlStateManager.disableLighting();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
if (entity.rgb != null && entity.rgb.length >= 3) {
float mult = .5F + (entity.active ? r.nextFloat() * .5F : 0);
GlStateManager.color(entity.rgb[0] * mult, entity.rgb[1] * mult, entity.rgb[2] * mult);
}
GlStateManager.pushMatrix();
GlStateManager.translate(x, y + 1, z);
GlStateManager.rotate(entityYaw + 90, 0, 1, 0);
GlStateManager.disableTexture2D();
GlStateManager.pushMatrix();
GlStateManager.translate(0, 0, .03125);
GlStateManager.rotate(entity.angleHorizontal, 1, 0, 0);
GlStateManager.scale(.0625, 1, .0625);
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
float size = entity.tubeLength / 2;
//sides
for (int i = 0; i < 8; i++) {
wr.pos(octagon[i][0], size, octagon[i][1]).endVertex();
wr.pos(octagon[(i + 1) % 8][0], size, octagon[(i + 1) % 8][1]).endVertex();
wr.pos(octagon[(i + 1) % 8][0], -size, octagon[(i + 1) % 8][1]).endVertex();
wr.pos(octagon[i][0], -size, octagon[i][1]).endVertex();
}
tes.draw();
GlStateManager.disableBlend();
GlStateManager.enableLighting();
if (!entity.active)
GlStateManager.disableRescaleNormal();
//caps
GlStateManager.color(0, 0, 0);
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
wr.pos(octagon[0][0], -size, octagon[0][1]).endVertex();
wr.pos(octagon[1][0], -size, octagon[1][1]).endVertex();
wr.pos(octagon[2][0], -size, octagon[2][1]).endVertex();
wr.pos(octagon[3][0], -size, octagon[3][1]).endVertex();
wr.pos(octagon[3][0], -size, octagon[3][1]).endVertex();
wr.pos(octagon[4][0], -size, octagon[4][1]).endVertex();
wr.pos(octagon[7][0], -size, octagon[7][1]).endVertex();
wr.pos(octagon[0][0], -size, octagon[0][1]).endVertex();
wr.pos(octagon[4][0], -size, octagon[4][1]).endVertex();
wr.pos(octagon[5][0], -size, octagon[5][1]).endVertex();
wr.pos(octagon[6][0], -size, octagon[6][1]).endVertex();
wr.pos(octagon[7][0], -size, octagon[7][1]).endVertex();
wr.pos(octagon[3][0], size, octagon[3][1]).endVertex();
wr.pos(octagon[2][0], size, octagon[2][1]).endVertex();
wr.pos(octagon[1][0], size, octagon[1][1]).endVertex();
wr.pos(octagon[0][0], size, octagon[0][1]).endVertex();
wr.pos(octagon[0][0], size, octagon[0][1]).endVertex();
wr.pos(octagon[7][0], size, octagon[7][1]).endVertex();
wr.pos(octagon[4][0], size, octagon[4][1]).endVertex();
wr.pos(octagon[3][0], size, octagon[3][1]).endVertex();
wr.pos(octagon[7][0], size, octagon[7][1]).endVertex();
wr.pos(octagon[6][0], size, octagon[6][1]).endVertex();
wr.pos(octagon[5][0], size, octagon[5][1]).endVertex();
wr.pos(octagon[4][0], size, octagon[4][1]).endVertex();
tes.draw();
if (entity.active)
GlStateManager.popAttrib();
GlStateManager.enableTexture2D();
GlStateManager.popMatrix();
GlStateManager.translate(-0.25, -1, 0);
GlStateManager.color(1, 1, 1);
if (tex == null)
tex = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/iron_block");
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
ClientUtils.renderTexturedBox(wr, 0, 0, 0, .0625, 1, .0625, tex.getMinU(), tex.getMinV(), tex.getMaxU(), tex.getMaxV());
ClientUtils.renderTexturedBox(wr, .0625, .9375, 0, .25, 1, .0625, tex.getMinU(), tex.getMinV(), tex.getMaxU(), tex.getMaxV());
tes.draw();
GlStateManager.popMatrix();
}
Aggregations