It is currently Sun Oct 22, 2017 5:07 am

All times are UTC - 5 hours




 Page 1 of 1 [ 10 posts ] 
Author Message
 Post subject: OpenGL VMK 2 - PNG Textures
PostPosted: Mon Jan 09, 2012 9:21 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
The code written in C++ VMK 24 PNG Loader (viewtopic.php?t=653) is carried forward into this VMK where the texture manager is expanded to include the ability to use PNG texture files in the game engine.


Offline
 Profile  
 
 Post subject: Need Help Trouble Shooting
PostPosted: Thu Jan 12, 2012 3:35 pm 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 449
This is my GhostToast version in VS2008

I am at the point in the video where we just finished writing the function LoadPNG() in texture.cpp. For both cases my project builds out with 0 errors. I've tried the library both ways and neither work. I build the pnglib in debug and release using VS2010. I've tried with both .dll's in the GameEngines directory and set the path's appropriately. The same function call for pnglib is falling, but in different locations for the release vs debug versions. I am always building my GameEngine in debug. the function call that is failing is:

png_read_png( png.pStruct, png.pInfo, PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_PACKING | PNG_TRANSFORM_EXPAND | PNG_TRANSFORM_GRAY_TO_RGB, NULL );

I get the same type of error when running. Unhandled exception at some memory address with an Access violation writing at some location for both .dll types.

Release: The break point shows in pngrio.c

Debug: The break point shows in fread.c

Now, I took this same png file you included for this series and loaded it into the png project that is a win32 console, and the program read the data bits, however this console project was done using VS2010.

I don't know what else to try.

However when I get a chance to, I will try to include this png option in my current GameEngine written in VS2010 where I have just recently reached the Physics Series.


Offline
 Profile  
 
 Post subject: Re: OpenGL VMK 2 - PNG Textures
PostPosted: Thu Jan 12, 2012 9:57 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
Did you confirm that the runtime library used by the png library is the same as the runtime library used in your game engine? If they don't match you will get exception errors thrown just like the ones you are describing.


Offline
 Profile  
 
 Post subject: Re: OpenGL VMK 2 - PNG Textures
PostPosted: Fri Jan 13, 2012 4:26 am 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 449
Yes. They do match, I just don't know if it is from trying to use the libraries debug build or not.


Last edited by skilz80 on Fri Jan 13, 2012 1:27 pm, edited 1 time in total.

Offline
 Profile  
 
 Post subject: Re: OpenGL VMK 2 - PNG Textures
PostPosted: Fri Jan 13, 2012 5:04 am 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 449
Ok, I went back to the previous vmk project in the c++ series, and set up everything in debug mode accordingly. All projects built correctly for the pngLoader projects, however when I run the debugger it fails. I then tried to run the debugger without debugging and on the command prompt it says ../../../../pngLoader/testImage.png can not be opened. I need to investigate more to why it can not open the file in debug mode.


Offline
 Profile  
 
 Post subject: Re: OpenGL VMK 2 - PNG Textures
PostPosted: Fri Jan 13, 2012 7:37 am 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 449
I got the win32 console app to run in debug mode and it opened, read the file and printed the results to the screen. I trippled check all the project settings between the console app, my library directory for the pngLib and my GhostToast Game engine. In both debug and release modes; character type and code generation, for all projects in each solution do match appropriately.

The win32 console app works fine, however the gameEngine still crashes on the same function call.

Now the frustration kicks in :(

... continuing to investigate.


Last edited by skilz80 on Fri Jan 13, 2012 1:32 pm, edited 1 time in total.

Offline
 Profile  
 
 Post subject: Re: OpenGL VMK 2 - PNG Textures
PostPosted: Fri Jan 13, 2012 8:44 am 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 449
Ok, I went to my current GameEngine project which is written in VS2010, this game engine is the one where I found the bug in the physics engine. There is no TextureManager class in this engine yet, so to load in a texture uses the older style like in the GameEngine VMKS. I added the function to load in png files, and the structure to store its data in Texture.h and Texture.cpp and updated the Load function in Texture.cpp. Then I went and set up the projects properties to link in the dll in this version of the game engine. It compiles and builds. When I put a break point on the function call that was giving me problems from the above post, I press f10 on the keyboard and sure enough it goes to the next line and executes. It WORKS!!! I don't understand why my GhostToast version in 2008 is complaining with this function call where the 2010 GameEngine version does not. I checked all settings about 5 times now lol.

Since my GameEngine in VS2010 does run:
This is telling me so far that 1. The library itself is ok, I don't need to modify it anymore. 2. That my source code is fine. It has to be someother configuration in Visual Studio, that is different between 2008 and 2010. I just don't know what it is.

As a note the pngLib was built out in VS2010.


Offline
 Profile  
 
 Post subject: Re: OpenGL VMK 2 - PNG Textures
PostPosted: Fri Jan 13, 2012 4:12 pm 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 449
I ran both GhostToast version from VS2008 and GameEngine from VS2010 side by side. I debugged them stepping into each function call to try and find the point where execution is throwing the access violation. The exception is not being thrown from fread.c itself. There is a function call in
fread.c called _lock_str(); with a value of stream passed in as an argument. This is where my final break point is located, which is line 105 in fread.c. In my GameEngine VS2010 when I press F11 to step into this function the debugger then goes inside of _file.c. For the VS2010 everything works perfect!!!. In my GhostToast VS2008 version when I press F11 Visual Studio brings up a dialog box looking for _file.c and gives a message can not locate source.

Knowing this; in my vs2010 version I right click on _file.c and choose open containing folder. It points to this directory C:\Program Files\Microsoft Visual Studio 10.0\VC\crt\src. I use this as a reference and go into My Computer and check the folder location
C:\Program Files\Microsoft Visual Studio 9.0\VC\crt\src and sure enough _file.c is in this directory,
but for some reason Visual Studio is not locating it. I hope this is enough information for you to help me determine how to resolve this issue. Thank You in advance! :)

Other than this bug. Great tutorial :)


Offline
 Profile  
 
 Post subject: Re: OpenGL VMK 2 - PNG Textures
PostPosted: Fri Jan 13, 2012 10:25 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
Are you mixing your builds across different versions of visual studio? If you build the png library in VS2010 then you must also build the game engine in VS2010 for the code to work. If the png library is built in VS2010 and the game engine is in VS2008 then there is no guaranty that the code will link up correctly since the runtime library in VS2008 maybe different in spots as compared to VS2010.


Offline
 Profile  
 
 Post subject: Re: OpenGL VMK 2 - PNG Textures
PostPosted: Fri Jan 13, 2012 11:43 pm 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 449
Thank you for the advice, I will go ahead in my ProgramFiles\ProgrammingLibraries folder and split it between 08 and 10. Hopefully this will resolve the problem.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 10 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron