Jump to content

How can I use OpenGL directly in minecraft to draw a GUI?


Recommended Posts

Basically the title. I only need to draw in 2D. I know about GuiScreen and how to make a Gui with a Container, all that stuff. I just wanted to take a step forward and make a sort of Gui Framework offering a set of components and a layout manager. So one of my questions is, can I draw triangles??? Like this:


//vertices here


I ask because the game is all made of quads, apparently, and I needed triangles for my GUI, so maybe there's some limitation to the OpenGL environment?


Can I have a very simple example? I also don't know how to transform the coordinate system correctly before drawing the GUI, if the example could include that, it would be really appreciated.


(edit summary: typo)

Link to comment
Share on other sites



Minecraft has a wrapper on GL that server you with "nice" (depends) vertex format that has ability to make nice texturing/colorizing/stuff.


Anyway - when talking about GUIs - MC uses id=7 (look 1st link: GL_QUADS).

All vertex formats that are shape (meaning non-line like GL_LINES) are expected to be drawn ANTI-CLOCKWISE.


Mentioned "wrapper" for basic GL is (was) called Tesselator and currently all operations are in WorldRenderer (Tesselator.getInstance().getWorldRenderer()).


All possible examples are placed in Gui.class (and few others).


And yes - any other GL operations are possible/allowed during usage of WorldRenderer or not (it is really just a wrapper).




"I also don't know how to transform the coordinate system correctly"


I have no clue what you mean. top/left screen is 0/0. You just take some x/y and draw your stuff. Scaling is done automatically - depenging on GUISize - I am talking about that thing you can set in game options "large", "medium", "small", etc. , AND window scaling.

There are cases where you might need manual scaling - this can be taken from ScaledResolution (lookup callbacks of this class - gives you direct examples).

1.7.10 is no longer supported by forge, you are on your own.

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.

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.