Jump to content

Recommended Posts

Posted

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:

 

glBegin(GL_TRIANGLE_STRIP);
//vertices here
glEnd();

 

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)

Posted

https://en.wikibooks.org/wiki/OpenGL_Programming/GLStart/Tut3

 

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).

 

EDIT

 

"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.

Posted

Thanks! Good to know I can draw anything. About the coordinate system, based on what you said it seems minecraft already transforms it for us when drawing a GUI then, which is also very good to know. Thanks for the reply!

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...

×   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.