Calling graphics3d multiple times?
Blitz3D Forums/Blitz3D Beginners Area/Calling graphics3d multiple times?
| ||
Upon coding, I realized I was going to be calling graphics3D twice (possibly more) during my game. I was wondering if this is a bad thing and I should avoid it? I'm calling it twice because my program flow is like this: graphics3d... variable declarations variable initialization (which include creating and pivoting the player, this is why I have to call graphics3d already) load ini (which has the user graphics settings) set graphics3d accordingly main loop I guess I could have the initialization AFTER the second graphics3d, but I like having declarations and initializations close to each other.. Thanks! |
| ||
Sorry, but on a side note, my program runs perfectly in debug compile, but when I compile it normally, it gives me an error: unable to set graphics mode. Any thoughts? |
| ||
I don't think calling Graphics3D multiple times will give you an issue. Can you post code so we can see what the problem might be (no thoughts spring to mind as Blitz3D is stable). |
| ||
Ok, here it is. All it's supposed to do is print the FPS. Also, include a file named "ini.xml" with the following content in the same folder:<?xml version="1.0" ?> <ini> <graphics x="1024" y="768" depth="16" mode="2" fps="60"> <antialiasing enable="1"/> <hwmultitextureing enable="1"/> <dithering enable="1"/> <wbuffering enable="1"/> </graphics> </ini> Alright, I also eliminated the includes. The last section of code is "blitzXML" functions. Hopefully the author wont be mad that I added them. There not my functions, if your interested in them, check the link I gave right above them. Here's the code: |
| ||
I think that the reason is, that when using windowmode 0 with Graphics, in debug mode, the program will be ran in a window mode, and in release mode, the program will be ran fullscreen. Windowmodes are usually not a problem, but not all fullscreen resolutions/bitdepths are available in DirectX. You should test if a mode exists with GFXModeExists(). I believe that when using Graphics3D twice, any graphics could be destroyed: Images become invalid, and I believe entities/textures as well. |
| ||
Well, that shouldn't be the problem because I created a small app which creates the ini file based on the users choice. The choices are generated with GFXModeExists(). |
| ||
You should use EndGraphics before using a new Graphics command. Not sure if it is the answer to your problem - but it is the law. |
| ||
I think Graphics already calls EndGraphics first though as a retard check, but Puki is right. John Wesley, can you ensure that your xml is actually giving you good data? print out the values before calling graphics. |
| ||
Yep, it has "good" data. To recap: - Calling graphics3d multiple times is fine, as long as EndGraphics is called before switching. Question: Warner mentioned any graphics and entities and textures will become invalid, is this true? - I get "unable to set graphics mode" if i compile it, but it runs fine when i debug compile it. |
| ||
Blitz3D will lose all the handles when calling Graphics - basically, Blitz3D becomes blind to what you have loaded. You either reassign everything manually by basically hacking Blitz3D on-the-fly, or you store the handles and hope that you can still re-address them after a new Graphics - but don't bank on it. EDIT: Actually, I don't know for sure what gets lost, if anything, with Graphics3D - basically, I have never bothered calling it more than once. |
| ||
Gah, I just switched some code around forcing myself to only have one graphics3d at the moment. It now works. I'm not sure if that was the error (I'm not convinced it was..). All that matters to me is that it runs fine now. Thanks for the help. |
| ||
haha, alright, well Im just going to put it in once to avoid all the troublesome errors.. |