Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Two questions: begin/end GL and setResolution()
- - By Maverick Date 2011-07-07 04:14
1. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm assuming beginGL and endGL both push and pop the graphics stack respectively. However, when I used them in two different classes (using alpha), the second one will be dominate and the first one will have some weird effect. It may just be /me using the functions wrong/ but here's an example:

Before the boss health bar (drawn by Gosu's quads)
http://dl.dropbox.com/u/1333628/TechPics/MrCaffeine/error/before.png

After is appears (also drawn the same way)
http://dl.dropbox.com/u/1333628/TechPics/MrCaffeine/error/after.png

And here's that code
http://pastebin.com/a0BQSWy1

I realize that I don't need beginGL and endGL to draw the quads (as I was doing before) so I don't have this problem anymore, but I DID use them and the above pictures were the results. So it just raised my eyebrow if the pushing and popping had a bug??

2. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

My camera class uses the initial window size as the camera size. However, when using setResolution, this throws off the math going on in the background. For instance, some enemies do not spawn or update outside of camera view. This looks fine normally, but using a different resolution will throw off the math and enemies won't update or spawn until the "virtual camera" is in appropriate view which is very hard to determine.

So my question is what can I do do adjust the camera to the resolution size?
Parent - By Basic Date 2011-07-07 07:57
I think beginGL will draw everything that is queued up to that point then allow you to draw using your own gl. Also with transparences unless you are using shaders the order is very important.

For your camera you can use the getters to reset your virtual camera graphics().width() and graphics().height()
Parent - By jlnr (dev) Date 2011-07-07 08:22

> I'm assuming beginGL and endGL both push and pop the graphics stack respectively. However, when I used them in two different classes (using alpha), the second one will be dominate and the first one will have some weird effect.


beginGL basically flushes everything and then calls glPushAttrib(GL_ALL_ATTRIB_BITS); glDisable(GL_BLEND); - that should be the normal GL state because Gosu only messes with GL_BLEND.

As Basic pointed out, Gosu will flush everything and the normal Z order logic will be broken. If that might cause it, you should use enqueueGL instead :)

> setResolution


I think setResolution is undocumented or has some notice above it. I really want to kick it out now that we have scale(). I just have a lot of legacy code that relies on it :( - But I think there was also some question similar to yours: how to keep track of the current size without setResolution etc.
Up Topic Gosu / Gosu Exchange / Two questions: begin/end GL and setResolution()

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill