Jump to content

uranophane

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by uranophane

  1. In my mod, I have to render many 3d wireframe boxes. There are often thousands of wireframe cubes that need to be rendered, and my existing algorithm doesn't perform well enough (~3-5 FPS on an i7-7700 + GTX 1060). The code I currently use has the following flow (pseudocode): startGlState(); // this initializes the GlStateManager for (pos in coordinates){ glLineWidth(width); // width varies drawBox(pos, color); // both vary } endGlState(); // this restores the GlStateManager drawBox(pos, color){ getTessellator(); // this instatiates a tessellator startBufferBuilding(); // this instantiates a BufferBuilder buffer.pos(pos.offset).color(color).endVertex(); {...} tessellator.draw(); } As it is currently, I must call tesslator.draw() for every coordinate because the thickness of the lines vary. So I tried a new method: startGlState(); // this initializes the GlStateManager getTessellator(); // this instatiates a tessellator startBufferBuilding(); // this instantiates a BufferBuilder for (pos in coordinates){ bufferBox(pos, color); // both vary } tessellator.draw(); endGlState(); // this restores the GlStateManager bufferBox(pos, color){ buffer.pos(pos.offset).color(color).endVertex(); // add the edges of pos to the buffer {...} } This way, tesselator.draw() only gets called once per set of coordinates. However, line width remains static. The second way was faster than the first, but not significantly (only a speedup of 2x when the # of calls was reduced by a factor of a few thousand). The result was still unplayable. With this, I came to the conclusion that the vertex buffer was the slowest part. My question is: is there a faster way of drawing simple 3D lines? If so, how should I approach it? By directly making openGL calls, perhaps? The wireframe boxes must experience depth clipping along with the rest of the world.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.