Posted December 29, 20177 yr This may sound like a trivial question: how should I draw lines "on top" of the terrain? On top, as in, on a layer that's above the world so that they are visible whether they are underground or above ground. I am quite new to modding and frankly have no idea how Minecraft renders its screen. All I managed to find out was it uses the Tessellator and WorldRenderer (which is a BufferBuilder) objects to draw things. Currently, I'm using the same method as how Minecraft draws its block selection boxes (EXCEPT subscribed to the onWorldRenderFinish event instead of onDrawSelectionBox): /* the vanilla wireframe box renderer: */ GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); ... // some functions to set up the vertices Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); bufferbuilder.begin(3, DefaultVertexFormats.POSITION_COLOR); buffer.pos(minX, minY, minZ).color(red, green, blue, 0.0F).endVertex(); buffer.pos(minX, minY, minZ).color(red, green, blue, alpha).endVertex(); Tessellator.draw(); ... // a long chain of vertices GlStateManager.depthMask(true); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); I looked into the BufferBuilder class and it seems to create "ByteBuffers" which contain chains of vertices and their color. As for how the Tessellator or WorldRenderer actually draws it, I have no clue. I don't think the GlStateManager has anything to do with my issue, as it's mostly just for compositing already rendered images together. Please give some pointers or links to helpful documents.
December 29, 20177 yr If what you're trying to render is related to a block, tileentity, item or entity, then you would make an appropriate model and textures. However, it sounds like you want to do more of an "overlay" / HUD, meaning a visual guide for a player that isn't exactly any particular object? If the overlay is simple (like a 2D set of lines, or even 3D that is on top of everything else) then you can simply handle the RenderGameOverlay event. But I suspect you want something fancier where the lines have perspective and actually follow the terrain? The problem in that case is the order of rendering as some parts of your line would be behind other things in view. Is that what you want? Maybe if you drew an illustration it would better help those who try to advise you. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
December 29, 20177 yr Author Actually, what you described is exactly what I was trying to achieve. I was trying to draw 3D lines that overlay on top of the world. 3D as in they "physically" exist in the world, with 3D coordinates that align with the world. However, they are displayed on top of the world at all times. Kind of like how the old Zombe Mob Highlighter's lines work, except they are static and not attached to mobs. Edited December 29, 20177 yr by uranophane
December 29, 20177 yr Author Found the solution. It was the simple command GLStateManager.depthfunc(519); ... //draw stuff GLStateManager.depthfunc(515); Found it by digging through the glowing entity renderer.
December 29, 20177 yr Those numbers (519, 515) aren't magic. The decompiled minecraft code uses them because the numbers came from an enum. I'm away from dev, so I can't point you at the right place, but they stand for GL_ALWAYS and GL_LEQUAL respectively. I suggest you update your code to use the enum reference so that your code is more readable and doesn't contain these arbitrary magic numbers. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 29, 20177 yr Author 37 minutes ago, Draco18s said: I suggest you update your code to use the enum reference so that your code is more readable and doesn't contain these arbitrary magic numbers. I copied those numbers from the GL11 class, but I have trouble finding the file in which the Enum was declared. I haven't been using Eclipse for very long. Sorry if it sounds like I'm asking for a java tutorial, I just wish to know how I can navigate to the enum declaration. EDIT: Nevermind, there was no enum. Those constants were declared directly in the GL11 class. I ended up including it and doing GL11.GL_LESS. Edited December 29, 20177 yr by uranophane
December 29, 20177 yr 56 minutes ago, uranophane said: Nevermind, there was no enum. Those constants were declared directly in the GL11 class. I ended up including it and doing GL11.GL_LESS. Yep, that. That's what I meant. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.