ManicMonkey Posted March 28, 2016 Posted March 28, 2016 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) Quote
Ernio Posted March 28, 2016 Posted March 28, 2016 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). Quote 1.7.10 is no longer supported by forge, you are on your own.
ManicMonkey Posted March 28, 2016 Author Posted March 28, 2016 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! Quote
ManicMonkey Posted March 28, 2016 Author Posted March 28, 2016 Oh, just one more thing. The wrapper you told me about, you know what OpenGL version it uses? (equal to or greater than 3.1?) Quote
coolAlias Posted March 29, 2016 Posted March 29, 2016 Last I checked it was 2.9, but you should be able to find out by looking at your project's referenced libraries. Quote http://i.imgur.com/NdrFdld.png[/img]
Recommended Posts
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.