use of org.blockartistry.lib.gfx.OpenGlState in project DynamicSurroundings by OreCruncher.
the class ParticleTextPopOff method renderParticle.
@Override
public void renderParticle(BufferBuilder worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
final float pitch = this.manager.playerViewX * (isThirdPersonView() ? -1 : 1);
final float yaw = -this.manager.playerViewY;
final float locX = ((float) (this.prevPosX + (this.posX - this.prevPosX) * partialTicks - interpX()));
final float locY = ((float) (this.prevPosY + (this.posY - this.prevPosY) * partialTicks - interpY()));
final float locZ = ((float) (this.prevPosZ + (this.posZ - this.prevPosZ) * partialTicks - interpZ()));
final OpenGlState glState = OpenGlState.push();
GlStateManager.translate(locX, locY, locZ);
GlStateManager.rotate(yaw, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(pitch, 1.0F, 0.0F, 0.0F);
GlStateManager.scale(-1.0F, -1.0F, 1.0F);
GlStateManager.scale(this.particleScale * 0.008D, this.particleScale * 0.008D, this.particleScale * 0.008D);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 0.003662109F);
this.font.drawString(this.text, this.drawX, this.drawY, SHADOW_COLOR, false);
GlStateManager.translate(-0.3F, -0.3F, -0.001F);
this.font.drawString(this.text, this.drawX, this.drawY, this.renderColor, false);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, OpenGlHelper.lastBrightnessX, OpenGlHelper.lastBrightnessY);
OpenGlState.pop(glState);
if (this.grow) {
this.particleScale *= 1.08F;
if (this.particleScale > SIZE * 3.0D) {
this.grow = false;
}
} else {
this.particleScale *= 0.96F;
}
}
use of org.blockartistry.lib.gfx.OpenGlState in project DynamicSurroundings by OreCruncher.
the class AuroraShaderBand method render.
@Override
public void render(final float partialTick) {
if (this.program == null)
return;
final Tessellator tess = Tessellator.getInstance();
final BufferBuilder renderer = tess.getBuffer();
final double tranY = getTranslationY(partialTick);
final double tranX = getTranslationX(partialTick);
final double tranZ = getTranslationZ(partialTick);
final OpenGlState glState = OpenGlState.push();
GlStateManager.translate(tranX, tranY, tranZ);
GlStateManager.scale(0.5D, 10.0D, 0.5D);
GlStateManager.disableLighting();
OpenGlUtil.setAuroraBlend();
GL11.glFrontFace(GL11.GL_CW);
try {
this.program.use(this.callback);
for (int b = 0; b < this.bands.length; b++) {
this.bands[b].translate(partialTick);
renderer.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_TEX);
final Node[] array = this.bands[b].getNodeList();
for (int i = 0; i < array.length - 1; i++) {
final float v1 = 0;
final float v2 = 1F;
final float u1 = i * this.panelTexWidth;
final float u2 = u1 + this.panelTexWidth;
final Node node = array[i];
final double posY = node.getModdedY();
final double posX = node.tetX;
final double posZ = node.tetZ;
final double zero = 0;
final double posX2;
final double posZ2;
final double posY2;
if (i < array.length - 2) {
final Node nodePlus = array[i + 1];
posX2 = nodePlus.tetX;
posZ2 = nodePlus.tetZ;
posY2 = nodePlus.getModdedY();
} else {
posX2 = node.posX;
posZ2 = node.getModdedZ();
posY2 = 0.0D;
}
renderer.pos(posX, zero, posZ).tex(u1, v1).endVertex();
renderer.pos(posX, posY, posZ).tex(u1, v2).endVertex();
renderer.pos(posX2, zero, posZ2).tex(u2, v1).endVertex();
renderer.pos(posX2, posY2, posZ2).tex(u2, v2).endVertex();
}
tess.draw();
}
} catch (final Exception ex) {
ex.printStackTrace();
this.program = null;
} finally {
try {
if (this.program != null)
this.program.unUse();
} catch (final Throwable t) {
;
}
}
GL11.glFrontFace(GL11.GL_CCW);
OpenGlState.pop(glState);
}
use of org.blockartistry.lib.gfx.OpenGlState in project DynamicSurroundings by OreCruncher.
the class LightLevelHUD method doRender.
@SubscribeEvent
public static void doRender(@Nonnull final RenderWorldLastEvent event) {
if (!showHUD || nextCoord == 0)
return;
final EntityPlayer player = EnvironState.getPlayer();
if (player == null)
return;
final RenderManager manager = Minecraft.getMinecraft().getRenderManager();
final OpenGlState glState = OpenGlState.push();
GlStateManager.enableTexture2D();
GlStateManager.disableLighting();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.enableDepth();
GlStateManager.depthFunc(GL11.GL_LEQUAL);
GlStateManager.depthMask(true);
if (useOldRenderMethod())
drawStringRender(player, manager);
else
textureRender(player, manager);
OpenGlState.pop(glState);
}
use of org.blockartistry.lib.gfx.OpenGlState in project DynamicSurroundings by OreCruncher.
the class ParticleBillboard method renderParticle.
@Override
public void renderParticle(final BufferBuilder buffer, final Entity entityIn, final float partialTicks, final float rotationX, final float rotationZ, final float rotationYZ, final float rotationXY, final float rotationXZ) {
// Fail safe...
if (this.text == null || this.text.isEmpty())
return;
if (!this.canBeSeen)
return;
// Calculate scale and position
final float pitch = this.manager.playerViewX * (isThirdPersonView() ? -1 : 1);
final float yaw = -this.manager.playerViewY;
final float locX = ((float) (this.prevPosX + (this.posX - this.prevPosX) * partialTicks - interpX()));
final float locY = ((float) (this.prevPosY + (this.posY - this.prevPosY) * partialTicks - interpY()));
final float locZ = ((float) (this.prevPosZ + (this.posZ - this.prevPosZ) * partialTicks - interpZ()));
final OpenGlState glState = OpenGlState.push();
GlStateManager.translate(locX, locY, locZ);
GlStateManager.rotate(yaw, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(pitch, 1.0F, 0.0F, 0.0F);
GlStateManager.scale(-this.scale * 0.015D, -this.scale * 0.015F, this.scale * 0.015D);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 0.003662109F);
final float saveLightX = OpenGlHelper.lastBrightnessX;
final float saveLightY = OpenGlHelper.lastBrightnessY;
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.enableAlpha();
// // Draw the background region
final float red = B_COLOR.red;
final float green = B_COLOR.green;
final float blue = B_COLOR.blue;
final float alpha = B_COLOR_ALPHA;
buffer.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_COLOR);
buffer.pos(this.left, this.top, 0.0D).color(red, green, blue, alpha).endVertex();
buffer.pos(this.left, this.bottom, 0.0D).color(red, green, blue, alpha).endVertex();
buffer.pos(this.right, this.top, 0.0D).color(red, green, blue, alpha).endVertex();
buffer.pos(this.right, this.bottom, 0.0D).color(red, green, blue, alpha).endVertex();
Tessellator.getInstance().draw();
GlStateManager.enableTexture2D();
GlStateManager.depthMask(true);
GlStateManager.translate(0, 0, -0.05F);
int lines = this.numberOfMessages;
for (int t = 0; t < this.numberOfMessages; t++) {
final String str = this.text.get(t);
final int offset = -lines * 9;
final int margin = -this.font.getStringWidth(str) / 2;
GlStateManager.disableDepth();
GlStateManager.depthMask(false);
this.font.drawString(str, margin, offset, F_COLOR_DEPTH.rgbWithAlpha(F_COLOR_ALPHA));
GlStateManager.enableDepth();
GlStateManager.depthMask(true);
this.font.drawString(str, margin, offset, F_COLOR.rgbWithAlpha(F_COLOR_ALPHA));
lines--;
}
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, saveLightX, saveLightY);
OpenGlState.pop(glState);
}
use of org.blockartistry.lib.gfx.OpenGlState in project DynamicSurroundings by OreCruncher.
the class AuroraClassic method render.
@Override
public void render(final float partialTick) {
final float alpha = getAlpha();
final Tessellator tess = Tessellator.getInstance();
final BufferBuilder renderer = tess.getBuffer();
final double tranY = getTranslationY(partialTick);
final double tranX = getTranslationX(partialTick);
final double tranZ = getTranslationZ(partialTick);
final Color base = getBaseColor();
final Color fade = getFadeColor();
final double zero = 0.0D;
final OpenGlState glState = OpenGlState.push();
GlStateManager.translate(tranX, tranY, tranZ);
GlStateManager.scale(0.5D, 8.0D, 0.5D);
GlStateManager.disableLighting();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.disableTexture2D();
GlStateManager.shadeModel(GL11.GL_SMOOTH);
GlStateManager.disableAlpha();
GlStateManager.disableCull();
GlStateManager.depthMask(false);
renderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR);
for (int b = 0; b < this.bands.length; b++) {
this.bands[b].translate(partialTick);
final Node[] array = this.bands[b].getNodeList();
for (int i = 0; i < array.length - 1; i++) {
final Node node = array[i];
final double posY = node.getModdedY();
final double posX = node.tetX;
final double posZ = node.tetZ;
final double tetX = node.tetX2;
final double tetZ = node.tetZ2;
final double posX2;
final double posZ2;
final double tetX2;
final double tetZ2;
final double posY2;
if (i < array.length - 2) {
final Node nodePlus = array[i + 1];
posX2 = nodePlus.tetX;
posZ2 = nodePlus.tetZ;
tetX2 = nodePlus.tetX2;
tetZ2 = nodePlus.tetZ2;
posY2 = nodePlus.getModdedY();
} else {
posX2 = tetX2 = node.posX;
posZ2 = tetZ2 = node.getModdedZ();
posY2 = 0.0D;
}
// Front
renderer.pos(posX, zero, posZ).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(posX, posY, posZ).color(fade.red, fade.green, fade.blue, 0).endVertex();
renderer.pos(posX2, posY2, posZ2).color(fade.red, fade.green, fade.blue, 0).endVertex();
renderer.pos(posX2, posY2, posZ2).color(fade.red, fade.green, fade.blue, 0).endVertex();
renderer.pos(posX2, zero, posZ2).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(posX, zero, posZ).color(base.red, base.green, base.blue, alpha).endVertex();
// Bottom
renderer.pos(posX, zero, posZ).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(posX2, zero, posZ2).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(tetX2, zero, tetZ2).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(tetX2, zero, tetZ2).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(tetX, zero, tetZ).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(posX, zero, posZ).color(base.red, base.green, base.blue, alpha).endVertex();
// Back
renderer.pos(tetX, zero, tetZ).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(tetX, posY, tetZ).color(fade.red, fade.green, fade.blue, 0).endVertex();
renderer.pos(tetX2, posY2, tetZ2).color(fade.red, fade.green, fade.blue, 0).endVertex();
renderer.pos(tetX2, posY2, tetZ2).color(fade.red, fade.green, fade.blue, 0).endVertex();
renderer.pos(tetX2, zero, tetZ2).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(tetX, zero, tetZ).color(base.red, base.green, base.blue, alpha).endVertex();
}
}
tess.draw();
OpenGlState.pop(glState);
}
Aggregations