Social Icons

Sunday 24 June 2012

[TUT] using glScissor for better scrollable areas

Credit TO:=  jonalu
I have recently been fully recoding the jClient GUI and thought that scrollable hack lists would be nice for a resizable window gui. Well, my first guess was to simply show the rows and scroll down one row for each 120° wheel. (that may sound complicated, you cant really explain it)
demonstration on main menu changelog:
[Image: 6cqUEuiw0E.png]

[Image: LwYOO2BXkS.png]

As you can see, you cant simply make it scroll like half a row, it would go over the rectangle. hope i explained that well.
Now the fix I made:
[Image: TRLMDg2EO2.png]

[Image: snbCY6rBkW.png]

you can see that you cant see all of the text, but only a bit. I think it looks much better and smoother than the other one. You could even add some effects such as a small shadow gradient to it or whatever. How I actually did this:
There is a function in lwjgl that lets you define a scissor box. using it is a bit complicated as its axis start in the bottom left corner and it ignores glscale. When you defined a scissor box, you can glEnable a "filter" called GL_SCISSOR_TEST. that will not draw any pixels outside of that box. like that you can "cut them off". When you want to change it back to normal, just glDisable GL_SCISSOR_TEST again. The code to set up a scissor box I made:
[Image: k6pQFwUe8y.png]

it basically calculates the first corner x and y, calculates width and height of the rect and calculates the guiscale minecraft uses with it.
Basically:

  1. you call that code with the rect you want to fill
  2. you glEnable GL_SCISSORS_TEST before drawing that area
  3. you disable it again after finishing that area.


That is basically it. I do know I cant explain shit, but if you dont understand how to use this, then simply dont. I would love some credit if you use this, but I will probably never get credits in the griefing section ;)
I will not answer anything about this on skype if you dont know me for longer already.

No comments:

Post a Comment