Jump to content

[1.7.2+] Any way to hook into the OpenGL display loop?


Recommended Posts

So Minecraft seems to use LWJGL's Display object and OpenGL methods to update the game's graphics, right?


I'm experimenting with a new WorldType that calculates large geometric shapes to determine biomes across vast regions before any chunks generate, and I need a way to display a map of those shapes in-game so that I don't have to fly around the world for hours to debug their geometry. A simple 2D array of different colored pixels would do fine, maybe injected into Minecraft's main Display.update() loop.


Thing is, I don't know where that loop is (Guessing it lives somewhere in net.minecraft.client.renderer?), and even if I did it doesn't look like Forge has any hooks into it. But I'm assuming there are alternative ways to do what I'm trying to accomplish, and I'm hoping someone here can provide some guidance.


I really just need a way to:

-Convert an array of pixels to a format I can display

-Display that format on screen

Link to comment
Share on other sites

Uh duh, I see net.minecraftforge.client.event.RenderGameOverlayEvent now, I assume that's what you're referring to. Thank you, that does indeed look like the access I need (And thanks for writing it!).


I think I'll just read a few LWJGL tutorials to figure out how to get a byte array into a texture for the actual rendering since it looks like I can just use that event to trigger some GL11 calls? Seems a lot more straightforward than mucking around in, for example, Notch's Map tile entity code :P


EDIT: Yup, that was easier than expected. Here's my Debug class in case anyone's interested in displaying similar array of debug map data (Right now this just displays a 200 * 200 square of half-transparent blue behind the debug text, but it gives me the ability to write a setter method to add more complex info to a larger map later):


public class Debug{

private int textureID;
public static ByteBuffer textureBuffer;

public void onRenderDebug(RenderGameOverlayEvent event)
	if(event.isCancelable() || event.type != ElementType.DEBUG)

	textureBuffer = BufferUtils.createByteBuffer(200*200*4);
	textureID = GL11.glGenTextures();
	for (int i = 0; i < 200*200; i ++) {
		textureBuffer.put((byte) 0);
		textureBuffer.put((byte) 0);
		textureBuffer.put((byte) 255);
		textureBuffer.put((byte) 128);

	GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
	GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 200, 200, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, textureBuffer);


	GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

	GL11.glVertex3d(0, 0, 0);
	GL11.glVertex3d(0, 200, 0);
	GL11.glVertex3d(200, 200, 0);
	GL11.glVertex3d(200, 0, 0);



Link to comment
Share on other sites

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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

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