Properly end 3d
BlitzMax Forums/MiniB3D Module/Properly end 3d
| ||
My app starts with a maxgui window, then when the user clicks a button it inits my 3D space with Graphics3D() and builds cameras etc. When the user is done in 3D it frees all the entitys and cameras then calls ClearWorld() just to be safe, then EndGraphics() to go back to the gui. If the user then starts 3D again it doesn't seem to initialize properly (the textures are all wrong, the drawing text to the screen just draws white space, etc. it's all totally broken), and I assume it's because there's something left over. How do I properly close down and clean up the 3D space so that I can start again fresh? |
| ||
After more poking it seems like openGL isn't getting released properly when EndGraphics() is called. The next time you call Graphics3D() it seems like it's trying to access textures and buffers that no longer exist, like the pointers aren't going to the right place... How can you force Graphics3D() to init a new OpenGL context and forget about anything it might have had? |
| ||
You could try ClearList TTexture.tex_list although the old textures may still not be flushed correctly If this doesn't help there are also Global lists held by camera and others that may also need help resetting. |
| ||
I'm releasing my cameras etc. and calling clearworld. it happens even before the textures. for example, I have some loading text drawn as follows right after Graphics3D()Cls() text(GraphicsWidth()/2, GraphicsHeight()/2, "Loading") Flip() this draws fine on the first run (where everything works. but after closing and unloading everything. then calling Graphics3D() again I just get a white box where the text should be... which leads me to believe it's trying to draw to, or flip from a buffer that no longer exists... |
| ||
Here's a simple example of the crux of the problemSuperStrict Import sidesign.minib3d Graphics3D(1024, 768, 32, 1) While(Not KeyHit(KEY_ESCAPE)) Cls() text(15, 15, "Sample text") Flip() Wend FlushKeys() EndGraphics() Graphics3D(1024, 768, 32, 1) While(Not KeyHit(KEY_ESCAPE)) Cls() text(15, 15, "Sample text") Flip() Wend FlushKeys() EndGraphics() |
| ||
After some more testing this happens on mac an PC. I'm quite lost as to how to go about fixing this. I seem to recall another project of mine dropped 3D to bring up a save file dialog and then went back without incident, but that was a long time ago so probably a different version of minib3d... |
| ||
Your sample here, on BlitzMax 1.28 (I know, old version, but I tweaked it a lot to my needs) it works, no problems at all... Since you mention it fails both on MAC and PC, it can't be a driver issue. Maybe something on the newer BMax? What version of BMax are you trying? What hardware (Specially the video card)? I really don't understand - a simple program that just calls graphics and then writes text to screen should work, after all the graphics3D call is just this: SetGraphicsDriver(GLMax2DDriver()) Graphics(width,height,depth,rate,GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER|GRAPHICS_ACCUMBUFFER) You could try going to TGlobal.bmx, function Graphics3D, and removing the "|GRAPHICS_ACCUMBUFFER" part, which sometimes may cause problems in certain graphics cards... rebuild the module and see if that works. Other than that, without being able to reproduce I have no idea how to even suggest something to you :( Maybe someone with more knowledge than me can help you... |
| ||
Dropping the accumulation buffer didn't make a difference. Systems I've tested on (rough specs) newest model mac mini with 10.6 newest model mac mini with 10.5 Mac pro with an nvida and an ATI card (tested through both cards, same problem) and vista x64 based PC with nvidia 8800gt Going to try downgrading to 1.28 as I know I was able to drop and re-enter 3D using that some time ago. |
| ||
HA!, the test app runs fine in 1.28, so it's a blitzmax bug! |