@Override public void postRender() { Iterator<Map.Entry<TextCacheKey, Map<Material, Mesh>>> textIterator = cachedText.entrySet().iterator(); while (textIterator.hasNext()) { Map.Entry<TextCacheKey, Map<Material, Mesh>> entry = textIterator.next(); if (!usedText.contains(entry.getKey())) { entry.getValue().values().forEach(Mesh::dispose); textIterator.remove(); } } usedText.clear(); Iterator<Map.Entry<TextureCacheKey, Mesh>> textureIterator = cachedTextures.entrySet().iterator(); while (textureIterator.hasNext()) { Map.Entry<TextureCacheKey, Mesh> entry = textureIterator.next(); if (!usedTextures.contains(entry.getKey())) { entry.getValue().dispose(); textureIterator.remove(); } } usedTextures.clear(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND); }
/** * Renders a quad filling the whole currently set viewport. */ public static void renderFullscreenQuad() { glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); renderQuad(); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); }
public void renderMark(Vector3i blockPos) { Vector3f cameraPos = getCameraPosition(); glPushMatrix(); glTranslated(blockPos.x - cameraPos.x, blockPos.y - cameraPos.y, blockPos.z - cameraPos.z); glMatrixMode(GL_MODELVIEW); overlayMesh.render(); glPopMatrix(); }
public void renderMark2(Vector3i blockPos) { Vector3f cameraPos = getCameraPosition(); glPushMatrix(); glTranslated(blockPos.x - cameraPos.x, blockPos.y - cameraPos.y, blockPos.z - cameraPos.z); glMatrixMode(GL_MODELVIEW); overlayMesh2.render(); glPopMatrix(); }
private void renderChunkBoundingBox(RenderableChunk chunk, Vector3f chunkPosition, Vector3f cameraPosition) { GL11.glPushMatrix(); // chunkPositionRelativeToCamera = chunkCoordinates * chunkDimensions - cameraCoordinate final Vector3f chunkPositionRelativeToCamera = new Vector3f(chunkPosition.x * ChunkConstants.SIZE_X - cameraPosition.x, chunkPosition.y * ChunkConstants.SIZE_Y - cameraPosition.y, chunkPosition.z * ChunkConstants.SIZE_Z - cameraPosition.z); GL11.glTranslatef(chunkPositionRelativeToCamera.x, chunkPositionRelativeToCamera.y, chunkPositionRelativeToCamera.z); new AABBRenderer(chunk.getAABB()).renderLocally(1f); GL11.glPopMatrix(); // Resets the matrix stack after the rendering of a chunk. }
/** * Renders the phase-appropriate mesh of the chunk. I.e. if the RenderPhase is OPAQUE only the opaque mesh * is rendered: other meshes stored in an instance of this class are rendered in separate rendering steps. * * @param phase a RenderPhase value * @param chunkPosition a Vector3f storing the world position of the chunk. * @param cameraPosition a Vector3f storing the world position of the point of view from which the chunk is rendered. * @return Returns an integer representing the number of triangles rendered. */ public int render(ChunkMesh.RenderPhase phase, Vector3f chunkPosition, Vector3f cameraPosition) { GL11.glPushMatrix(); // chunkPositionRelativeToCamera = chunkCoordinates * chunkDimensions - cameraCoordinate final Vector3f chunkPositionRelativeToCamera = new Vector3f(chunkPosition.x * ChunkConstants.SIZE_X - cameraPosition.x, chunkPosition.y * ChunkConstants.SIZE_Y - cameraPosition.y, chunkPosition.z * ChunkConstants.SIZE_Z - cameraPosition.z); GL11.glTranslatef(chunkPositionRelativeToCamera.x, chunkPositionRelativeToCamera.y, chunkPositionRelativeToCamera.z); render(phase); // this is where the chunk is actually rendered GL11.glPopMatrix(); return triangleCount(); }
@Override public void drawMaterialAt(Material material, Rect2i drawRegion) { glPushMatrix(); glTranslatef(drawRegion.minX(), drawRegion.minY(), 0f); glScalef(drawRegion.width(), drawRegion.height(), 1); billboard.render(); glPopMatrix(); }
public void renderLocally(float lineThickness) { CoreRegistry.get(ShaderManager.class).enableDefault(); if (displayListWire == -1) { generateDisplayListWire(); } glPushMatrix(); glTranslated(0f, aabb.getCenter().y, 0f); glLineWidth(lineThickness); glCallList(displayListWire); glPopMatrix(); }
public void renderSolid() { CoreRegistry.get(ShaderManager.class).enableDefault(); glPushMatrix(); Vector3f cameraPosition = CoreRegistry.get(LocalPlayer.class).getViewPosition(); glTranslated(aabb.getCenter().x - cameraPosition.x, -cameraPosition.y, aabb.getCenter().z - cameraPosition.z); renderSolidLocally(); glPopMatrix(); }
/** * Renders this AABB. * <br><br> * * @param lineThickness The thickness of the line */ @Override public void render(float lineThickness) { CoreRegistry.get(ShaderManager.class).enableDefault(); glPushMatrix(); Vector3f cameraPosition = CoreRegistry.get(LocalPlayer.class).getViewPosition(); glTranslated(aabb.getCenter().x - cameraPosition.x, -cameraPosition.y, aabb.getCenter().z - cameraPosition.z); renderLocally(lineThickness); glPopMatrix(); }
public void renderSolidLocally() { CoreRegistry.get(ShaderManager.class).enableDefault(); if (displayListSolid == -1) { generateDisplayListSolid(); } glEnable(GL_BLEND); glPushMatrix(); glTranslated(0f, aabb.getCenter().y, 0f); glScalef(1.5f, 1.5f, 1.5f); glCallList(displayListSolid); glPopMatrix(); glDisable(GL_BLEND); }
private void renderBoneOrientation(EntityRef boneEntity) { LocationComponent loc = boneEntity.getComponent(LocationComponent.class); if (loc == null) { return; } glPushMatrix(); Vector3f worldPosA = loc.getWorldPosition(); Quat4f worldRot = loc.getWorldRotation(); Vector3f offset = new Vector3f(0, 0, 0.1f); worldRot.rotate(offset, offset); offset.add(worldPosA); glBegin(GL11.GL_LINES); glVertex3f(worldPosA.x, worldPosA.y, worldPosA.z); glVertex3f(offset.x, offset.y, offset.z); glEnd(); loc.getChildren().forEach(this::renderBoneOrientation); glPopMatrix(); }
glPopMatrix(); glDisable(GL11.GL_DEPTH_TEST);
private static void renderPlayerLook(EntityPlayer player, ItemStack stack) { List<BlockPos> coords = ItemAstrolabe.getBlocksToPlace(stack, player); if (ItemAstrolabe.hasBlocks(stack, player, coords)) { Block block = ItemAstrolabe.getBlock(stack); int meta = ItemAstrolabe.getBlockMeta(stack); GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); ShaderHelper.useShader(ShaderHelper.alpha, shader -> { int alpha = ARBShaderObjects.glGetUniformLocationARB(shader, "alpha"); ARBShaderObjects.glUniform1fARB(alpha, 0.4F); }); for(BlockPos coord : coords) renderBlockAt(block, meta, coord); ShaderHelper.releaseShader(); GL11.glPopMatrix(); } }
@Override public void doRender(@Nonnull EntityDireWolf entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) { super.doRender(entity, x, y, z, p_76986_8_, p_76986_9_); GL11.glPopMatrix(); // RenderUtil.renderEntityBoundingBox((EntityLiving) entity, x, y, z); }
void dsDrawTriangle (final float[] pos, final float[] R, final float[] v0, final float[] v1, final float[] v2, boolean solid) { if (current_state != 2) dsError ("drawing function called outside simulation loop"); setupDrawingMode(); GL11.glShadeModel (GL11.GL_FLAT); setTransform (pos,R); drawTriangle (v0, v1, v2, solid); GL11.glPopMatrix(); }
@Override public void renderHeadUpDisplay(double d, boolean day, boolean shifted, Minecraft mc, IHUDConfig config) { for (IHUDButton button : buttons) { GL11.glPushMatrix(); button.renderAlways(shifted); if (button.shouldRenderButton()) { button.renderButton(button.isFocused(), button.isblockFocused(), shifted); } GL11.glPopMatrix(); } }