Hi guys, i am having serious problems with closing my game window (always crashes). i decided to switch to vc++ so i can use the debugger but here it compiles but crashes at the Setup::SetupScreen(.. function. can any one help? please. ore send me an empty vc++ openlayer prroject so i can see if its my code (which i doubt it is) i am just getting confused here.
Here is the debuggers message
| 1 | using namespace ol; |
| 2 | |
| 3 | bool Game::gameSetup() |
| 4 | { |
| 5 | // Setup the libraries and all drivers // |
| 6 | Setup::SetupProgram(); |
| 7 | //joystick?? |
| 8 | |
| 9 | //static bool SetupScreen(int width, int height, |
| 10 | // bool fullscreen = true,int colorDepth = 32, |
| 11 | // int zDepth = 8,int refreshRate = [automatic] ); |
| 12 | // Setup 32-bit fullscreen mode with the resolution of 1024 x 768 // |
| 13 | Setup::SetupScreen( 1024, 768, false, 32 ); |
| 14 | |
| 15 | //===================================================================================== |
| 16 | // DEBUGGER!! |
| 17 | //===================================================================================== |
| 18 | loaded. |
| 19 | 'Penalty Kick.exe': Unloaded 'C:\WINDOWS\system32\mcd32.dll' |
| 20 | First-chance exception at 0x104817fd in Penalty Kick.exe: 0xC0000005: Access violation writing location 0x0000000f. |
| 21 | Unhandled exception at 0x104817fd in Penalty Kick.exe: 0xC0000005: Access violation writing location 0x0000000f. |
Could you compile OL with debugging information so that it'd tell where exactly it crashes? Do the demos work when compiled? Do you have any global Bitmaps or TextRenderers? (those are initialized in SetupScreen)
apologies for the thread hi-jack, but (not know if the offline manual has been updated since the last version), I've uploaded 2.1 manual onto the website 
ps, you have loads of link errors in the manual where it jumps to the textrenderer version of a method instead of a bitmap version. Why not just produce a doxygen version, that way you won't have to update html all the time.
pps, I wish you'd make a wiki as some of the documentation is way too ambiguous and unclear.
I've had exactly (or so I think) same problem.
Been trying this and that and it seems this only occurs when I try to make a debug build of my game.
That indicates that I have built some dependency wrong, no?
Unfortually I've been too lazy to make a debug version of OL, but I did stick some OlLog() calls in some of the OL .cpp files trying to figure out where it bails out.
OpenLayer started up succesfully
allegro_gl_clear_settings()
allegro_gl_set(1)
allegro_gl_set(2)
allegro_gl_set(3)
allegro_gl_set(4)
allegro_gl_set(5)
allegro_gl_set(6)
Calling allegro set_gfx_mode
Setup::SetupScreen - GLDriver::Get()
Setup::SetupScreen - Settings::SetOrthographicsProjection()
Setup::SetupScreen - Blenders::Set()
Setup::SetupScreen - Transforms::xzy()
Setup::SetupScreen - Settings::SetAntialiasing()
Setup::SetupScreen - Canvas::SetTo()
Setup::SetupScreen - Canvas::Fill()
Setup::SetupScreen - Canvas::Refresh()
Setup::SetupScreen - Canvas::Fill()
OlGetCollection()
OlGetCollection() - creating new
ExecuteQueues()
std::list
Auto Loader: Executing 0 pending loading commands
I know its not a pretty log, but I did it just for myself so I could try to track down wtf is going on.
Here is the part that makes the last line in that log:
[url][/url]
GarbageCollector.cpp
| 1 | void GarbageCollection:: |
| 2 | ExecuteQueues() { |
| 3 | OlLog("ExecuteQueues()"); |
| 4 | std::list< GarbageCollected *> pendings = collection; |
| 5 | OlLog("std::list"); |
| 6 | OlLog( std::string( "\nAuto Loader: Executing " ) + ToString( pendings.size() ) + " pending loading commands" ); |
| 7 | |
| 8 | while( !pendings.empty()) { |
| 9 | |
| 10 | unsigned int numPendings = pendings.size(); |
| 11 | |
| 12 | for( std::list< GarbageCollected *> ::iterator iter = pendings.begin(); iter != pendings.end(); ) { |
| 13 | OlLoadResult result = (*iter)->ExecuteQueuedCommands(); |
| 14 | |
| 15 | bool removeItem = true; |
| 16 | |
| 17 | switch( result ) { |
| 18 | case OL_LR_FAILURE: |
| 19 | OlError( "Auto Loader: Couldn't load a resource!" ); |
| 20 | break; |
| 21 | case OL_LR_SUCCESS: |
| 22 | break; |
| 23 | case OL_LR_PENDING: |
| 24 | removeItem = false; |
| 25 | break; |
| 26 | default: |
| 27 | OlError( "Auto Loader: Unknown OlLoadResult enumeration!" ); |
| 28 | } |
| 29 | |
| 30 | if( removeItem ) |
| 31 | iter = pendings.erase( iter ); |
| 32 | else |
| 33 | iter++; |
| 34 | } |
| 35 | |
| 36 | if( pendings.size() >= numPendings ) { |
| 37 | OlError( "Auto Loader: Circular dependancy detected! Bailing out!" ); |
| 38 | break; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | OlLog( "Auto Loader: Completed\n" ); |
| 43 | } |
As you can see, I've added OlLog("std::list") on row 5, it is shown in the log, but not the next OlLog() call. It is quite weird .. and what is even weirder is that I recall it crashing at some other place before.
My testing code: (Ignore the apeg stuff, as it never even reaches that part)
| 1 | #include <allegro.h> |
| 2 | #include <OpenLayer.hpp> |
| 3 | #include <loadpng.h> |
| 4 | |
| 5 | #include "apegplay.h" |
| 6 | |
| 7 | using namespace ol; |
| 8 | bool Init(void); |
| 9 | void MainLoop(void); |
| 10 | void DeInit(void); |
| 11 | int main() { |
| 12 | if(!Init()) return 1; |
| 13 | apegplay("./data/ogg/logo.ogg"); |
| 14 | MainLoop(); |
| 15 | DeInit(); |
| 16 | return 0; |
| 17 | } |
| 18 | END_OF_MAIN() |
| 19 | void MainLoop(void) |
| 20 | { |
| 21 | while( !key[KEY_ESC] ) { |
| 22 | Canvas::Fill( Rgba::BLACK ); |
| 23 | Line(0,0,SCREEN_W,SCREEN_H).Draw(Rgba(255,0,0)); |
| 24 | Canvas::Refresh(); |
| 25 | rest(0); |
| 26 | } |
| 27 | } |
| 28 | void DeInit(void) |
| 29 | { |
| 30 | } |
| 31 | bool Init(void) |
| 32 | { |
| 33 | if(!Setup::SetupProgram()) |
| 34 | return false; |
| 35 | Setup::SetupScreen( 800, 600, WINDOWED ); |
| 36 | return true; |
| 37 | } |
I'll try to make a debug version of OL tomorrow if I'm not too tired.
Speaking of which, I'm going to sleep now
the release version of mine also crashes. if only someone could kindly make a vc++ project template a tried and tested version tht works and is added to your vc++ wen u install ol (ol for vc8 also needs an installer i think. like dev c++ dev paks).
thanks for the replys so far
Neil, it uses my own "doxygen", as I wanted to get it to look exatly as I wanted it to. These days I'd make it in a different way though. A wiki has been planned a long time. But just tell me which part of the documentation needs updating and I'll do something about it.
About the problem, I'll try running the demo game through Fortity, maybe it finds something... It's linux only, though (I think) so MSVC binaries won't work. But maybe there's a memory overwrite problem or something, and in GCC it doesn't show for some reason.
PM sent
People got OpenLayer to work on MSVC? How?
Getting to get OpenLayer to work with MSVC is not simple, at least I think so.
There are quite a bunch of dependencies you need to compile in a way that they work with MSVC.
Allegro and AllegroGL for example are prepared with "fix.bat msvc8" and compiled with MinGW.
Most other things that OpenLayer requires have a project/sollution you can use directly from MSVC. But some don't, so you have to make your own project and add the sources yourself (LoadPNG comes to mind).
Keep in mind that you compile everything with the same runtime setting, I've been using /MT (Multi-Threading).
Once you got every dependency ready, you can take on OpenLayer itself.
For OL to work with MSVC, you need to make a Sollution for it with cmake.
There are some quirks with cmake like, you need to tell it the paths to include directories and libraries separately for all the dependencies. You won't notice all the missing paths at first, but just press "Configure" every time you change a path and it will detect whats missing next.
Don't know why it does that instead of reporting ALL the missing paths at once.
Not sure if it is stated in some document somehwere, but you should tell cmake to output the resulting solution into a directory OUTSIDE of the real OpenLayer basedirectory. Hmm, maybe I should just show instead, probably more clear.
c:\temp\build\OpenLayer\ <-- Where you unpacked your OpenLayer zip archive
c:\temp\build\OpenLayer_MSCV\ <-- This is where you should output your MSVC sollution to
Once you press "OK" in cmake, it might take a good while, seems the program has crashed because nothing happens.
Dont worry, it is working but doesn't give you any kind of progressbar or anything. Once its done cmake closes itself and you can open the solution in MSVC.
Remember to choose the same runtime enviroment as you did for your dependencies.
I might have missed something trivial, perhaps something very important 
Just ask away if something is unclear, I might be able to answer or someone else who has used OpenLayer with MSVC.
As for the OP and my reply earlier, I'll look into it later today when I get home.
Cannot install MSVC on this computer I'm on right now 
[Edit]
Unfortually, I haven't had the time to do anything but calling stupid fkn idiot paperpushers who cant get anything straight. Yet again, I need to nag my friends to lend me money so I can pay my bills 
</rant>
Hopefully tomorrow, unless something else fucks up
This thread seems to be following down the path of http://www.allegro.cc/forums/thread/593353/699935#target