Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

or, you could use the hooks that are in place for rendering the hud and do the same thing it does for rendering pictures.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • Author

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;

@SubscribeEvent()
public void onRenderDebug(RenderGameOverlayEvent event)
{
	if(event.isCancelable() || event.type != ElementType.DEBUG)
	{  
		return;
	}

	textureBuffer = BufferUtils.createByteBuffer(200*200*4);
	textureBuffer.order(ByteOrder.nativeOrder());
	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);
	}
	textureBuffer.flip();

	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.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
	GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

	GL11.glEnable(GL11.GL_BLEND);
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
	GL11.glBegin(GL11.GL_QUADS);

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

	GL11.glEnd();
	GL11.glDisable(GL11.GL_BLEND);
}

}

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.