iMiniB3D can't create instance after release

BlitzMax Forums/MiniB3D Module/iMiniB3D can't create instance after release

ima747(Posted 2011) [#1]
Hoping someone else has a guess where I should look to resolve this...

I have an EAGLView that is created when the game starts play, and destroyed when the game exits play and returns to the main menu. This works fine. The second time the game starts play the EAGLView is created again, and the game begins. I've had to tweak and adjust some things in iMiniB3D to get the world to properly destroy and re-create, but it does so without crashing now, however alpha is not respected on the second (or more) entries into 3D. The first time everything works as expected, I use alpha on some vertexes for some generated meshes, everything looks right. But when I start a second game alpha is either on or off. If something has any alpha value it is solid, if it's zero it is, as expected, invisible. I can tell because I create a mesh with multiple points along it's length and fade them out from one end to the other. The result is that the mesh fades from it's start to it's end until it's fully transparent and then is freed. On second run the mesh pops out in segments, as in when a given segment would reach alpha 0 that segment vanishes, until then it is fully opaque.

Global::Graphics() is called each time the EAGLView (along with it's context) is created, so it isn't that some init in there is being missed. All alpha related flagging is done on the creation of the meshes that require them, so when a new mesh is made part of it's creation method flags it with vertex alpha (and again, it works the first time so I'm quite confident the code exists in the OpenGL implementation, not my init routines).

Any thoughts? It seems like some simple OpenGL flag isn't being set to enable alpha, but since Graphics() is being executed I'm not sure where to look... Perhaps it's something that is executed at init of the lib (i.e. application startup...) such as the creation of the root_ent pivot (which btw needs to either not be freed in clearworld, or to be created again in Graphics if you don't want things to crash and intend to clearworld...)

Last edited 2011


AdamRedwoods(Posted 2011) [#2]
two ideas:
1. is the gl drawing surface set up for 8-bit alpha? RGBA8. I don't know if iOS is reverse, BGRA8. It's something to check.

2.
http://stackoverflow.com/questions/297408/re-displaying-eaglview-in-simple-iphone-game


ima747(Posted 2011) [#3]
Yea, the EAGLLayer is rebuilt when the view is rebuilt, and as a result it has it's properties set, including kEAGLColorFormatRGBA8.

Thanks for the link, but I think he's having issues related to his context getting destroyed by the navigation controller. I'm releasing and re-creating the context every time as well.

I think it has something to do with the Graphics() call (just a guess...). I think perhaps glAlphaFunc() doesn't do what it's supposed to when it's called a second time... nothing to really base this on and trying to test it out.


ima747(Posted 2011) [#4]
It's something to do with the context... if I don't destroy the context, just reset the graphics when I remake the view it works! this means there's a context floating around as a static all the time which I'm not too keen on but it's a livable solution for me for now... maybe I'm not destroying the old one properly and that's borking up OpenGL... will dig further if I have time.