Posted September 4, 20187 yr 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(); } 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 September 4, 20187 yr by bxzsj solved
September 4, 20187 yr 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).
September 4, 20187 yr 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.