/** * ************************************************************************************************************************************************************************************************* * Initialization stuff comes in here... * ************************************************************************************************************************************************************************************************ */ private void init() { try { Display.setDisplayMode(new DisplayMode(640, 480)); Display.setVSyncEnabled(true); Display.setTitle("MS3D Loader [G36C]"); Display.create(); Keyboard.create(); } catch (LWJGLException e) { Sys.alert("Error", "Initialization failed!\n\n" + e.getMessage()); System.exit(0); } /* OpenGL */ int width = Display.getDisplayMode().getWidth(); int height = Display.getDisplayMode().getHeight(); GL11.glViewport(0, 0, width, height); // Reset The Current Viewport GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix GL11.glLoadIdentity(); // Reset The Projection Matrix GLU.gluPerspective( 45.0f, ((float) width / (float) height), 0.1f, 1000.0f); // Calculate The Aspect Ratio Of The Window GL11.glMatrixMode(GL11.GL_MODELVIEW); // Select The Modelview Matrix GL11.glLoadIdentity(); // Reset The Modelview Matrix GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Background color GL11.glClearDepth(1.0f); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); // Load model // g36c = new // MS3DModel(resourceLoader.loadResourceAsStream("models/gsg9.ms3d"),this.getClass().getResource("./data/textures").getPath()); g36c = new MS3DModel( resourceLoader.loadResourceAsStream("models/assassin.ms3d"), this.getClass().getResource("./data/textures").getPath()); // tdsLoader=new TDSLoader(); // try { // tdsLoader.load(resourceLoader.loadResourceAsStream("models/face.3ds")); // System.out.println(tdsLoader.getObjectSize()); // } catch (IOException e) { // e.printStackTrace(); // } // Load font font = new Font(resourceLoader.loadResourceAsStream("textures/font.bmp"), 12, width, height); // Init timer timer = new Timer(); }
private void drawLightningBolt(Entity entity) { glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); glColor3f(0, 0.6f, 1); glBegin(GL_QUADS); int lastX = 0; int lastY = 0; for (int i = 0; i < 60; i++) { int x = i * 2; int y = (int) (Math.sin(i * (Math.PI / 4) - entity.ticksExisted * 2.05f) * 2.5f); glColor3f(1, 1f, 1); glVertex3d(x + 0, y + 0, 0); glVertex3d(x + 0, y + 1, 0); glVertex3d(lastX, lastY + 1, 0); glVertex3d(lastX, lastY, 0); glColor3f(0, 0.6f, 1); glVertex3d(x + 0, y + 1, 0); glVertex3d(x + 0, y + 1.25, 0); glVertex3d(lastX, lastY + 1.25, 0); glVertex3d(lastX, lastY + 1, 0); glVertex3d(x + 0, y - 0.25, 0); glVertex3d(x + 0, y, 0); glVertex3d(lastX, lastY, 0); glVertex3d(lastX, lastY - 0.25, 0); lastX = x; lastY = y; } glEnd(); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); }
public static void drawLine( double x, double y, double x2, double y2, float red, float green, float blue, float lineWidth, float fadeSpeed) { int count = FMLClientHandler.instance().getClient().thePlayer.ticksExisted; float alpha = fadeSpeed + MathHelper.sin((float) (count + x)) * 0.3F + 0.3F; Tessellator var12 = Tessellator.instance; GL11.glPushMatrix(); GL11.glLineWidth(lineWidth); GL11.glDisable(3553); GL11.glEnable(3042); var12.startDrawing(3); var12.setColorRGBA_F(red, green, blue, alpha); var12.addVertex(x, y, 0.0D); var12.addVertex(x2, y2, 0.0D); var12.draw(); GL11.glBlendFunc(770, 771); GL11.glDisable(32826); GL11.glDisable(3042); GL11.glEnable(3553); GL11.glPopMatrix(); }
/** Render the EvolvedEndermans eyes */ protected int renderEyes( SCSednaEntityEvolvedEnderman par1EntityEvolvedEnderman, int par2, float par3) { if (par2 != 0) { return -1; } else { this.bindTexture(EvolvedEndermanEyesTexture); float f1 = 1.0F; GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); GL11.glDisable(GL11.GL_LIGHTING); if (par1EntityEvolvedEnderman.isInvisible()) { GL11.glDepthMask(false); } else { GL11.glDepthMask(true); } char c0 = 61680; int j = c0 % 65536; int k = c0 / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_LIGHTING); GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); return 1; } }
public static void setupLighting() { FloatBuffer lightPosition = BufferUtils.createFloatBuffer(4); lightPosition.put(0.0f).put(0.0f).put(0.0f).put(0.0f).flip(); FloatBuffer whiteLight = BufferUtils.createFloatBuffer(4); whiteLight.put(1.0f).put(1.0f).put(1.0f).put(1.0f).flip(); FloatBuffer lModelAmbient = BufferUtils.createFloatBuffer(4); lModelAmbient.put(0.4f).put(0.4f).put(0.4f).put(1.0f).flip(); glShadeModel(GL_SMOOTH); glMaterial(GL_FRONT, GL_SPECULAR, whiteLight); glMaterialf(GL_FRONT, GL_SHININESS, 50.0f); glLight(GL_LIGHT0, GL_POSITION, lightPosition); glLight(GL_LIGHT0, GL_SPECULAR, whiteLight); glLight(GL_LIGHT0, GL_DIFFUSE, whiteLight); glLightModel(GL_LIGHT_MODEL_AMBIENT, lModelAmbient); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); }
/** R_PolyBlend */ void R_PolyBlend() { if (gl_polyblend.value == 0.0f) return; if (v_blend[3] == 0.0f) return; GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glLoadIdentity(); // FIXME: get rid of these GL11.glRotatef(-90, 1, 0, 0); // put Z going up GL11.glRotatef(90, 0, 0, 1); // put Z going up GL11.glColor4f(v_blend[0], v_blend[1], v_blend[2], v_blend[3]); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(10, 100, 100); GL11.glVertex3f(10, -100, 100); GL11.glVertex3f(10, -100, -100); GL11.glVertex3f(10, 100, -100); GL11.glEnd(); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glColor4f(1, 1, 1, 1); }
private void renderOverlay( TileAnimationTablet tablet, ResourceLocation texture, int rotationMod, boolean useLighting, boolean useBlend, double size, float height, float forceDeg) { Minecraft mc = ClientHelper.minecraft(); mc.renderEngine.bindTexture(texture); GL11.glPushMatrix(); GL11.glDepthMask(false); if (!useLighting) GL11.glDisable(GL11.GL_LIGHTING); if (useBlend) { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } GL11.glTranslatef(0.5F, height, 0.5F); float deg = rotationMod == 0 ? forceDeg : (float) (tablet.ticksExisted * rotationMod % 360F); GL11.glRotatef(deg, 0F, 1F, 0F); GL11.glColor4f(1F, 1F, 1F, 1F); Tessellator tess = Tessellator.instance; double size1 = size / 2; double size2 = -size1; tess.startDrawingQuads(); tess.addVertexWithUV(size2, 0, size1, 0, 1); tess.addVertexWithUV(size1, 0, size1, 1, 1); tess.addVertexWithUV(size1, 0, size2, 1, 0); tess.addVertexWithUV(size2, 0, size2, 0, 0); tess.draw(); GL11.glDepthMask(true); if (!useLighting) GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopMatrix(); }
/** draws the vertical line cursor in the textbox */ private void drawCursorVertical(int par1, int par2, int par3, int par4) { int var5; if (par1 < par3) { var5 = par1; par1 = par3; par3 = var5; } if (par2 < par4) { var5 = par2; par2 = par4; par4 = var5; } Tessellator var6 = Tessellator.instance; GL11.glColor4f(0.0F, 0.0F, 255.0F, 255.0F); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_COLOR_LOGIC_OP); GL11.glLogicOp(GL11.GL_OR_REVERSE); var6.startDrawingQuads(); var6.addVertex((double) par1, (double) par4, 0.0D); var6.addVertex((double) par3, (double) par4, 0.0D); var6.addVertex((double) par3, (double) par2, 0.0D); var6.addVertex((double) par1, (double) par2, 0.0D); var6.draw(); GL11.glDisable(GL11.GL_COLOR_LOGIC_OP); GL11.glEnable(GL11.GL_TEXTURE_2D); }
protected void func_74190_a(String p_74190_1_, int p_74190_2_, int p_74190_3_) { GL11.glDisable('\u803a'); RenderHelper.func_74518_a(); GL11.glDisable(2896); GL11.glDisable(2929); int var4 = this.field_73886_k.func_78256_a(p_74190_1_); int var5 = p_74190_2_ + 12; int var6 = p_74190_3_ - 12; byte var8 = 8; this.field_73735_i = 300.0F; field_74196_a.field_77023_b = 300.0F; int var9 = -267386864; this.func_73733_a(var5 - 3, var6 - 4, var5 + var4 + 3, var6 - 3, var9, var9); this.func_73733_a(var5 - 3, var6 + var8 + 3, var5 + var4 + 3, var6 + var8 + 4, var9, var9); this.func_73733_a(var5 - 3, var6 - 3, var5 + var4 + 3, var6 + var8 + 3, var9, var9); this.func_73733_a(var5 - 4, var6 - 3, var5 - 3, var6 + var8 + 3, var9, var9); this.func_73733_a(var5 + var4 + 3, var6 - 3, var5 + var4 + 4, var6 + var8 + 3, var9, var9); int var10 = 1347420415; int var11 = (var10 & 16711422) >> 1 | var10 & -16777216; this.func_73733_a(var5 - 3, var6 - 3 + 1, var5 - 3 + 1, var6 + var8 + 3 - 1, var10, var11); this.func_73733_a( var5 + var4 + 2, var6 - 3 + 1, var5 + var4 + 3, var6 + var8 + 3 - 1, var10, var11); this.func_73733_a(var5 - 3, var6 - 3, var5 + var4 + 3, var6 - 3 + 1, var10, var10); this.func_73733_a(var5 - 3, var6 + var8 + 2, var5 + var4 + 3, var6 + var8 + 3, var11, var11); this.field_73886_k.func_78261_a(p_74190_1_, var5, var6, -1); this.field_73735_i = 0.0F; field_74196_a.field_77023_b = 0.0F; GL11.glEnable(2896); GL11.glEnable(2929); RenderHelper.func_74519_b(); GL11.glEnable('\u803a'); }
private void renderPortalOverlay(float var1, int var2, int var3) { if (var1 < 1.0F) { var1 *= var1; var1 *= var1; var1 = var1 * 0.8F + 0.2F; } GL11.glDisable(3008 /*GL_ALPHA_TEST*/); GL11.glDisable(2929 /*GL_DEPTH_TEST*/); GL11.glDepthMask(false); GL11.glBlendFunc(770, 771); GL11.glColor4f(1.0F, 1.0F, 1.0F, var1); GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, this.mc.renderEngine.getTexture("/terrain.png")); float var4 = (float) (Block.portal.blockIndexInTexture % 16) / 16.0F; float var5 = (float) (Block.portal.blockIndexInTexture / 16) / 16.0F; float var6 = (float) (Block.portal.blockIndexInTexture % 16 + 1) / 16.0F; float var7 = (float) (Block.portal.blockIndexInTexture / 16 + 1) / 16.0F; Tessellator var8 = Tessellator.instance; var8.startDrawingQuads(); var8.addVertexWithUV(0.0D, (double) var3, -90.0D, (double) var4, (double) var7); var8.addVertexWithUV((double) var2, (double) var3, -90.0D, (double) var6, (double) var7); var8.addVertexWithUV((double) var2, 0.0D, -90.0D, (double) var6, (double) var5); var8.addVertexWithUV(0.0D, 0.0D, -90.0D, (double) var4, (double) var5); var8.draw(); GL11.glDepthMask(true); GL11.glEnable(2929 /*GL_DEPTH_TEST*/); GL11.glEnable(3008 /*GL_ALPHA_TEST*/); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); }
public static void drawGradientRect( int x, int y, float z, int toX, int toY, Color color, Color colorFade) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glShadeModel(GL11.GL_SMOOTH); Tessellator tes = Tessellator.getInstance(); VertexBuffer vb = tes.getBuffer(); vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); vb.pos(toX, y, z) .color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()) .endVertex(); vb.pos(x, y, z) .color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()) .endVertex(); vb.pos(x, toY, z) .color(colorFade.getRed(), colorFade.getGreen(), colorFade.getBlue(), colorFade.getAlpha()) .endVertex(); vb.pos(toX, toY, z) .color(colorFade.getRed(), colorFade.getGreen(), colorFade.getBlue(), colorFade.getAlpha()) .endVertex(); tes.draw(); GL11.glShadeModel(GL11.GL_FLAT); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); }
/** Initialise the GL context */ protected void initGL() { Log.info("Starting display " + width + "x" + height); String extensions = GL11.glGetString(GL11.GL_EXTENSIONS); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_MODELVIEW); if (input == null) { input = new Input(height); } input.init(height); input.removeListener(lastGame); input.addListener(game); lastGame = game; }
@Override public void doRender(Entity entity, double x, double y, double z, float a, float b) { EntityRippleMark mark = (EntityRippleMark) entity; long dt = GameTimer.getTime() - mark.creationTime; GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, 0); GL11.glDepthMask(false); GL11.glPushMatrix(); GL11.glTranslated(x, y, z); for (int i = 0; i < timeOffsets.length; ++i) { GL11.glPushMatrix(); long mod = (dt - timeOffsets[i]) % CYCLE; float size = getSize(mod); GL11.glTranslatef(0, getHeight(mod), 0); GL11.glScalef(size, 1, size); material.color = mark.color.copy(); material.color.a *= getAlpha(mod); mesh.draw(material); GL11.glPopMatrix(); } GL11.glPopMatrix(); GL11.glDepthMask(true); GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.1f); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_DEPTH_TEST); }
public void thing() { glFrontFace(GL_CW); glCullFace(GL_BACK); glEnable(GL_TEXTURE_2D); glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); glActiveTexture(GL_TEXTURE0); GL11.glViewport(0, 0, window.getCanvas().getWidth(), window.getCanvas().getHeight()); scene.init(this); // these variables are here purely for ease of reading // i could just pass in the lastTime and time into update. // delta is necessary to not see any Jumps if the framerates gets lower(if you have a framerate // of 60 and do something like move(5) it will move 5 units 60 times per seconds // while if you have 30 fps it would only update 30 times per second so if you do move(5 * // delta) it doesnt matter what fps you have the object will move the same distance; float lastTime = (float) System.nanoTime() / (float) 1000000000L; float delta = 0; while (running) { float time = (float) System.nanoTime() / (float) 1000000000L; delta = time - lastTime; update(delta); delta = 0; render(); lastTime = time; } destroy(); }
/** R_DrawBeam */ void R_DrawBeam(entity_t e) { oldorigin[0] = e.oldorigin[0]; oldorigin[1] = e.oldorigin[1]; oldorigin[2] = e.oldorigin[2]; origin[0] = e.origin[0]; origin[1] = e.origin[1]; origin[2] = e.origin[2]; normalized_direction[0] = direction[0] = oldorigin[0] - origin[0]; normalized_direction[1] = direction[1] = oldorigin[1] - origin[1]; normalized_direction[2] = direction[2] = oldorigin[2] - origin[2]; if (Math3D.VectorNormalize(normalized_direction) == 0.0f) return; Math3D.PerpendicularVector(perpvec, normalized_direction); Math3D.VectorScale(perpvec, e.frame / 2, perpvec); for (int i = 0; i < 6; i++) { Math3D.RotatePointAroundVector( start_points[i], normalized_direction, perpvec, (360.0f / NUM_BEAM_SEGS) * i); Math3D.VectorAdd(start_points[i], origin, start_points[i]); Math3D.VectorAdd(start_points[i], direction, end_points[i]); } GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glDepthMask(false); float r = (d_8to24table[e.skinnum & 0xFF]) & 0xFF; float g = (d_8to24table[e.skinnum & 0xFF] >> 8) & 0xFF; float b = (d_8to24table[e.skinnum & 0xFF] >> 16) & 0xFF; r *= 1 / 255.0f; g *= 1 / 255.0f; b *= 1 / 255.0f; GL11.glColor4f(r, g, b, e.alpha); GL11.glBegin(GL11.GL_TRIANGLE_STRIP); float[] v; for (int i = 0; i < NUM_BEAM_SEGS; i++) { v = start_points[i]; GL11.glVertex3f(v[0], v[1], v[2]); v = end_points[i]; GL11.glVertex3f(v[0], v[1], v[2]); v = start_points[(i + 1) % NUM_BEAM_SEGS]; GL11.glVertex3f(v[0], v[1], v[2]); v = end_points[(i + 1) % NUM_BEAM_SEGS]; GL11.glVertex3f(v[0], v[1], v[2]); } GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDepthMask(true); }
@SideOnly(Side.CLIENT) public static void renderItem(GuiScreen gui, ItemStack stack, int x, int y, float scale) { GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); RenderHelper.enableGUIStandardItemLighting(); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glTranslated(x, y, 0); GL11.glScalef(scale, scale, scale); boolean flagBefore = gui.mc.fontRenderer.getUnicodeFlag(); gui.mc.fontRenderer.setUnicodeFlag(false); RenderItem.getInstance() .renderItemAndEffectIntoGUI(gui.mc.fontRenderer, gui.mc.getTextureManager(), stack, 0, 0); RenderItem.getInstance() .renderItemOverlayIntoGUI(gui.mc.fontRenderer, gui.mc.getTextureManager(), stack, 0, 0); gui.mc.fontRenderer.setUnicodeFlag(flagBefore); // GL+MC+NEI suck if (gui instanceof GuiBooklet) { RenderHelper.disableStandardItemLighting(); } GL11.glPopMatrix(); }
/** R_DrawParticles */ void R_DrawParticles() { if (gl_ext_pointparameters.value != 0.0f && qglPointParameterfEXT) { // GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glVertexPointer(3, 0, particle_t.vertexArray); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glColorPointer(4, true, 0, particle_t.getColorAsByteBuffer()); GL11.glDepthMask(false); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glPointSize(gl_particle_size.value); GL11.glDrawArrays(GL11.GL_POINTS, 0, r_newrefdef.num_particles); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); // GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_TEXTURE_2D); } else { GL_DrawParticles(r_newrefdef.num_particles); } }
private void renderCryogenicChamber( ItemRenderType type, RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) { GL11.glPushMatrix(); this.transform(type); FMLClientHandler.instance() .getClient() .renderEngine .bindTexture(ItemRendererMachine.chamberTexture0); this.model.renderPart("Main_Cylinder"); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(0.1F, 0.6F, 0.5F, 0.4F); this.model.renderPart("Shield_Torus"); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glPopMatrix(); }
@Override protected void renderModel( EntityDragonMinion par1EntityDragonMinion, float par2, float par3, float par4, float par5, float par6, float par7) { bindEntityTexture(par1EntityDragonMinion); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); mainModel.render(par1EntityDragonMinion, par2, par3, par4, par5, par6, par7); GL11.glDisable(GL11.GL_BLEND); if (par1EntityDragonMinion.hurtTime > 0) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.5F); mainModel.render(par1EntityDragonMinion, par2, par3, par4, par5, par6, par7); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDepthFunc(GL11.GL_LEQUAL); } }
public void renderNitroAndSpeed( RenderGameOverlayEvent.Pre event, int width, int height, EntityPlayer player) { int nitro = TFVehichleModeMotionManager.nitroMap.get(player.getDisplayName()) == null ? 0 : TFVehichleModeMotionManager.nitroMap.get(player.getDisplayName()); int speed = (int) ((TFVehichleModeMotionManager.velocityMap.get(player.getDisplayName()) == null ? 0 : TFVehichleModeMotionManager.velocityMap.get(player.getDisplayName())) * 100); int i = TFPlayerData.getTransformationTimer(player) * 30; GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(0F, 0F, 0F, 0.3F); drawTexturedModalRect(5 - i, height - 17, 0, 0, 202, 12); drawTexturedModalRect(5 - i, height - 25, 0, 0, 202, 6); GL11.glColor4f(0.0F, 1.0F, 1.0F, 0.5F); drawTexturedModalRect(6 - i, height - 16, 0, 0, (int) (nitro * 1.25F), 10); GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.5F); drawTexturedModalRect(6 - i, height - 24, 0, 0, (int) (speed * 1F), 4); GL11.glEnable(GL11.GL_TEXTURE_2D); drawCenteredString(mc.fontRenderer, "Nitro", 106 - i, height - 15, 0xffffff); drawCenteredString(mc.fontRenderer, speed + " km/h", 106 - i, height - 26, 0xffffff); }
public static void drawGradientRect( int minx, int miny, int maxx, int maxy, int zlevel, int color1, int color2) { float alpha1 = (float) (color1 >> 24 & 255) / 255.0F; float red1 = (float) (color1 >> 16 & 255) / 255.0F; float green1 = (float) (color1 >> 8 & 255) / 255.0F; float blue1 = (float) (color1 & 255) / 255.0F; float alpha2 = (float) (color2 >> 24 & 255) / 255.0F; float red2 = (float) (color2 >> 16 & 255) / 255.0F; float green2 = (float) (color2 >> 8 & 255) / 255.0F; float blue2 = (float) (color2 & 255) / 255.0F; GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glShadeModel(GL11.GL_SMOOTH); Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.setColorRGBA_F(red1, green1, blue1, alpha1); tessellator.addVertex((double) maxx, (double) miny, (double) zlevel); tessellator.addVertex((double) minx, (double) miny, (double) zlevel); tessellator.setColorRGBA_F(red2, green2, blue2, alpha2); tessellator.addVertex((double) minx, (double) maxy, (double) zlevel); tessellator.addVertex((double) maxx, (double) maxy, (double) zlevel); tessellator.draw(); GL11.glShadeModel(GL11.GL_FLAT); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); }
public void renderKatanaDash( RenderGameOverlayEvent.Pre event, int width, int height, EntityPlayer player) { if (player.getHeldItem() != null && player.getHeldItem().getItem() == TFItems.purgesKatana && !TFPlayerData.isInVehicleMode(player) && TFHelper.isPlayerPurge(player)) { int j = TFItems.purgesKatana.getMaxItemUseDuration(player.getHeldItem()) - player.getItemInUseCount(); double d = (double) j / 10; if (d > 2.0D) { d = 2.0D; } GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(0F, 0F, 0F, 0.15F); drawTexturedModalRect(width / 2 - 26, height / 2 + 9, 0, 0, 52, 12); GL11.glColor4f(1F, 0F, 0F, 0.25F); drawTexturedModalRect(width / 2 - 25, height / 2 + 10, 0, 0, (int) (d * 25), 10); GL11.glEnable(GL11.GL_TEXTURE_2D); } }
private void InitGL() { GL.createCapabilities(); System.out.println("OpenGL: " + glGetString(GL_VERSION)); glEnable(GL13.GL_MULTISAMPLE); glEnable(GL_DEPTH_TEST); glViewport(0, 0, pix_width, pix_height); }
/** Applies fixed function bindings from the context to OpenGL */ private void applyFixedFuncBindings(boolean forLighting) { if (forLighting) { glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, context.shininess); setMaterialColor(GL_AMBIENT, context.ambient, ColorRGBA.DarkGray); setMaterialColor(GL_DIFFUSE, context.diffuse, ColorRGBA.White); setMaterialColor(GL_SPECULAR, context.specular, ColorRGBA.Black); if (context.useVertexColor) { glEnable(GL_COLOR_MATERIAL); } else { glDisable(GL_COLOR_MATERIAL); } } else { // Ignore other values as they have no effect when // GL_LIGHTING is disabled. ColorRGBA color = context.color; if (color != null) { glColor4f(color.r, color.g, color.b, color.a); } else { glColor4f(1, 1, 1, 1); } } if (context.alphaTestFallOff > 0f) { glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, context.alphaTestFallOff); } else { glDisable(GL_ALPHA_TEST); } }
private void initGL() { try { Display.setDisplayMode(new DisplayMode(GS.FRAMEWIDTH, GS.FRAMEHEIGHT)); Display.setFullscreen(true); Display.create(); Display.setVSyncEnabled(true); } catch (LWJGLException e) { e.printStackTrace(); Display.destroy(); System.exit(1); } GL11.glEnable(GL11.GL_TEXTURE_2D); // GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearDepth(1.0f); // GL11.glEnable(GL11.GL_DEPTH_TEST); // GL11.glDepthFunc(GL11.GL_ADD); //Wenn nicht auskommentiert führt es zu Exception GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glViewport(0, 0, GS.FRAMEWIDTH, GS.FRAMEHEIGHT); GL11.glOrtho(0, GS.FRAMEWIDTH, GS.FRAMEHEIGHT, 0, 0, 128); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // GL11.glBlendEquation( BLENDING_EQUATIONS[blendingEquationIndex]); GL11.glShadeModel(GL11.GL_FLAT); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, 0); GL11.glCullFace(GL11.GL_BACK); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); GL11.glLoadIdentity(); }
public void initialize() { if (GLContext.getCapabilities().OpenGL12) { gl12 = true; } // Default values for certain GL state. glShadeModel(GL_SMOOTH); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Enable rescaling/normaling of normal vectors. // Fixes lighting issues with scaled models. if (gl12) { glEnable(GL12.GL_RESCALE_NORMAL); } else { glEnable(GL_NORMALIZE); } if (GLContext.getCapabilities().GL_ARB_texture_non_power_of_two) { caps.add(Caps.NonPowerOfTwoTextures); } else { logger.log( Level.WARNING, "Your graphics card does not " + "support non-power-of-2 textures. " + "Some features might not work."); } maxLights = glGetInteger(GL_MAX_LIGHTS); maxTexSize = glGetInteger(GL_MAX_TEXTURE_SIZE); }
/** Renders the dragon model. Called by renderModel. */ protected void renderDragonModel( EntityDragonBoss par1EntityDragonBoss, float par2, float par3, float par4, float par5, float par6, float par7) { if (par1EntityDragonBoss.deathTicks > 0) { float f6 = par1EntityDragonBoss.deathTicks / 200.0F; GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, f6); bindTexture(field_110842_f); mainModel.render(par1EntityDragonBoss, par2, par3, par4, par5, par6, par7); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); GL11.glDepthFunc(GL11.GL_EQUAL); } bindEntityTexture(par1EntityDragonBoss); mainModel.render(par1EntityDragonBoss, par2, par3, par4, par5, par6, par7); if (par1EntityDragonBoss.hurtTime > 0) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.5F); mainModel.render(par1EntityDragonBoss, par2, par3, par4, par5, par6, par7); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDepthFunc(GL11.GL_LEQUAL); } }
@Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glPushMatrix(); GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); GL11.glTranslated(x, y, z); if (tileentity instanceof IBoxesProvider) { for (Box b : ((IBoxesProvider) tileentity).getBoxes()) { if (b.isVisible) { RenderBox.doRender( TileEntityRendererDispatcher.instance.field_147553_e, getTexture(b.kind), b); } } } else if (tileentity instanceof IBoxProvider) { Box b = ((IBoxProvider) tileentity).getBox(); if (b.isVisible) { RenderBox.doRender( TileEntityRendererDispatcher.instance.field_147553_e, getTexture(b.kind), b); } } GL11.glPopMatrix(); GL11.glPopAttrib(); GL11.glPopMatrix(); }
/** Rotate and blurs the skybox view in the main menu */ private void rotateAndBlurSkybox(float p_73968_1_) { this.mc.getTextureManager().bindTexture(this.field_110351_G); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); GL11.glColorMask(true, true, true, false); Tessellator var2 = Tessellator.instance; var2.startDrawingQuads(); GL11.glDisable(GL11.GL_ALPHA_TEST); byte var3 = 3; for (int var4 = 0; var4 < var3; ++var4) { var2.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F / (float) (var4 + 1)); int var5 = this.width; int var6 = this.height; float var7 = (float) (var4 - var3 / 2) / 256.0F; var2.addVertexWithUV( (double) var5, (double) var6, (double) this.zLevel, (double) (0.0F + var7), 1.0D); var2.addVertexWithUV((double) var5, 0.0D, (double) this.zLevel, (double) (1.0F + var7), 1.0D); var2.addVertexWithUV(0.0D, 0.0D, (double) this.zLevel, (double) (1.0F + var7), 0.0D); var2.addVertexWithUV(0.0D, (double) var6, (double) this.zLevel, (double) (0.0F + var7), 0.0D); } var2.draw(); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glColorMask(true, true, true, true); }
public static void initOrtho(int width, int height) { glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_BLEND); // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE_MINUS_CONSTANT_COLOR); // GL11.glDisable(GL_BLEND); // GL11.glDepthMask(true); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.1f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix // Calculate The Aspect Ratio Of The Window glOrtho(0, width, 0, height, -99999, 99999); glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); }