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

Try to use GL11.glRect to draw rectangles.

But it don't work.

    @Override
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
    {
        super.drawScreen(mouseX, mouseY, partialTicks);
        GlStateManager.disableTexture2D();
        GL11.glColor4f(1.0f,0,0,1.0f);
        GL11.glRecti(10,10,50,50);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
        GL11.glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
        GL11.glPopMatrix();
        GlStateManager.enableTexture2D();
        GL11.glRecti(10,10,50,50);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
        GL11.glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
        GL11.glPopMatrix();
    }

image.png.04273efb62cb47f834ebee7502ef8322.png

But if I try this:

        glBegin(GL_POLYGON);
        glVertex2i(10,10);
        glVertex2i(10,50);
        glVertex2i(50,50);
        glVertex2i(50,10);
        glEnd();

It works.

I find that the difference between GL11.glRect and the above code  is

glRect(x1, y1, x2, y2) equal

glBegin(GL_POLYGON);
glVertex2(x1, y1);
glVertex2(x2, y1);
glVertex2(x2, y2);
glVertex2(x1, y2);
glEnd( );

but the work one is:

glBegin(GL_POLYGON);
glVertex2(x1, y1);
glVertex2(x1, y2);
glVertex2(x2, y2);
glVertex2(x2, y1);
glEnd( );


The difference between them is that the order of the vertices is different.

I don't understand why this is happening. I hope someone can answer. Thank you!

Edited by bxzsj
solved

Well, first of all Don't use GL directly. Whatever you are doing can be achieved by different means. In this case a BufferBuilder will do the trick just fine. In other cases use GlStateManager.

Secondly, MC expects vertices to be specified CCW, but glRect specifies them CW. You can most likely disable culling(or change the cull method) and see everything working just fine regardless of the order.

Also 1.10.x is outdated and you should update to the latest version(1.12.2).

  • Author

Thank you!

I use 

GlStateManager.disableCull();


and rectangle is correctly rendered.

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.