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

Hello, I'm fairly new to modding and currently, I'm trying to learn how to do some simple rendering on either the HUD or objects within the game by using the raw OpenGL methods. I've tried messing around with the code already built into Minecraft with little success. I've noticed several common attributes (Almost all beginning with GL11.glPushMatrix() and typically ending with GL11.glPopMatrix()) however, I still have little understanding of the Tessellator and OpenGL. Can anyone explain this to me or point me to a site that could explain these things to me? Thank you in advance.

So OpenGL works with matrix. Basically you can draw stuff and transform the matrix itself. You draw stuff using GL11.glVertex#f (where f can be either f (floats), i (ints) and d (doubles) and # can be 2, 3 or 4 (representing the number of dimensions you are working on) and other methods (GL11.glBegin and GL11.glEnd) and trasform matrix with GL11.glTranslate#f, GL11.glRotatef. You can also save your matrix to the stack in order to get back after a series of matrix transformation with GL11.glPushMatrix and GL11.glPopMatrix.

 

Example:

GL11.glPushMatrix(); //save the current matrix

// Your transformation here

// Your rendering here

GL11.glPopMatrix(); //revert everything

 

For each PushMatrix there must be a PopMatrix or the code will break and it'll start spamming a lot of openGL errors :P

 

About Tessellator, that's just a bridge beetwen OpenGL and your code. It has some useful code (transforming quads to triangles, for instance) and it uses VetrexBuffers instead of glVertex calls.

 

I suggest you to take a look on some openGL guides (they are universal, don't look for java specific) and at Tessellator.java itself.

  • Author

Thank you so much! I think I'm sort of getting it now :). However, I am somewhat confused on what I'm doing incorrect in this bit of code. I basically have an Item set up to call the rendering method when right clicked. The code is this:

{
GL11.glPushMatrix();
GL11.glColor3f(0F, 1F, 0F);
GL11.glVertex2f(x, y);
GL11.glVertex2f(x+10F, y);
GL11.glVertex2f(x+10F, y+10F);
GL11.glVertex2f(x, y+10F);
GL11.glPopMatrix();
}

where x and y are floats preset to 10F. When run, all it appears to do is make the sky green. Am I just making a really n00bish mistake? :)

Thank you so much! I think I'm sort of getting it now :). However, I am somewhat confused on what I'm doing incorrect in this bit of code. I basically have an Item set up to call the rendering method when right clicked. The code is this:

{
GL11.glPushMatrix();
GL11.glColor3f(0F, 1F, 0F);
GL11.glVertex2f(x, y);
GL11.glVertex2f(x+10F, y);
GL11.glVertex2f(x+10F, y+10F);
GL11.glVertex2f(x, y+10F);
GL11.glPopMatrix();
}

where x and y are floats preset to 10F. When run, all it appears to do is make the sky green. Am I just making a really n00bish mistake? :)

 

The color isn't part of the Matrix so you have to reset it manually.

 

Add a GL11.glColor3f(1F, 1F, 1F); just before (or after) that glPopMatrix.

  • Author

Oh, that makes sense thank you :). So then how would I create a 2D overlay on the screen like the hotbar or your inventory when opened? I learn best by code, so if you could supply a small sample of something simple like a square that would be much appreciated. Thank you once again for the response, N1xx1.

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.