Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dodonutter

macrumors regular
Original poster
Nov 4, 2004
217
0
Deep South UK
Ok so I realise this is a forum for mac programming and i'm about to ask about windows but i'm a regular to macrumors, a student, and am doing a computing course mainly in C++ which we have to do in Visual C++ (or at least have to compile to run under windows) and I have no idea where else to get this information from!

Basically my problem is that i have created a program which among other things creates an object which models the heat over a 2D rectangle. This rectangle is split into a grid of 100x100 and the temperature is calculated at each point using a finite difference method to model the diffusion of the heat using certain boundary conditions.

But i'm having issues de-bugging. I would like to create a 100x100 box on the screen then display each pixel a colour according to the temperature at each point so i can see the diffusion of the heat as it happens and see if the thing is working as expected. Problem is I am using a PC and have no idea how to do that (saying that i don't know how to do it on a mac either but I'm going to teach myself obj-C and cocoa in a couple of months when i finish Uni)

If anyone knows of a simple library or method of doing this then I would appreciate the help. If, on the other hand, it is going to be a pain in the neck and be more hassle than its worth then i'll just stick to std::cout commands everywhere to debug.

Thanks in advance for any help and sorry about the lack of mac-ness in this question!
 

mwpeters8182

macrumors 6502
Apr 16, 2003
411
0
Boston, MA
Your best bet would probably be to write the data out to a file, and use some sort of plotting program or data analysis software (MATLAB, Octave, etc.) to view the output. Then, once you know it's working, you can worry about visualizing as part of the program.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Ok so I realise this is a forum for mac programming and i'm about to ask about windows but i'm a regular to macrumors, a student, and am doing a computing course mainly in C++ which we have to do in Visual C++ (or at least have to compile to run under windows) and I have no idea where else to get this information from!

Basically my problem is that i have created a program which among other things creates an object which models the heat over a 2D rectangle. This rectangle is split into a grid of 100x100 and the temperature is calculated at each point using a finite difference method to model the diffusion of the heat using certain boundary conditions.

But i'm having issues de-bugging. I would like to create a 100x100 box on the screen then display each pixel a colour according to the temperature at each point so i can see the diffusion of the heat as it happens and see if the thing is working as expected. Problem is I am using a PC and have no idea how to do that (saying that i don't know how to do it on a mac either but I'm going to teach myself obj-C and cocoa in a couple of months when i finish Uni)

If anyone knows of a simple library or method of doing this then I would appreciate the help. If, on the other hand, it is going to be a pain in the neck and be more hassle than its worth then i'll just stick to std::cout commands everywhere to debug.

Thanks in advance for any help and sorry about the lack of mac-ness in this question!

Is the visualization just intended to be a debugging tool, or is that a requirement for the project?

If the former, there's going to be much faster ways to debug things than a visualization library. I'd probably just write the values out, tab or comma delimited, with 100 fields per row and 100 rows. You can just write to stdout or stderr or to a file, whatever is easiest. I assume this is over some "ticks" of a clock, so after each one you can write things out to see how the values have changed.

-Lee
 

dodonutter

macrumors regular
Original poster
Nov 4, 2004
217
0
Deep South UK
Yeah the idea was mainly as a debugging tool but also to look pretty, not part of the project though. I have another section of the program writing the position of some particles to a file as a comma separated variable so I think i'll do the same here. Hadn't thought about matlab but that has a nice visualisation system in it or actually I might try python seeing as I can remember how to program that and Its free.

I think i was hoping there was a quick and easy way to do graphics seeing as all the ways I have looked at would require a lot of work but i suppose graphics just do!

Thanks for the replys
 

Sander

macrumors 6502a
Apr 24, 2008
521
67
Yeah the idea was mainly as a debugging tool but also to look pretty, not part of the project though. I have another section of the program writing the position of some particles to a file as a comma separated variable so I think i'll do the same here. Hadn't thought about matlab but that has a nice visualisation system in it or actually I might try python seeing as I can remember how to program that and Its free.

I think i was hoping there was a quick and easy way to do graphics seeing as all the ways I have looked at would require a lot of work but i suppose graphics just do!

Thanks for the replys

If you want to visualize this data "in real time", i.e., update it after each iteration, and simply outputting text data won't do, then you will have to look into some graphical library (I would suggest OpenGL), but be prepared for some extra learning curve. Since you say it's for debugging only, I would suggest writing out the data to a file which you can then visualize with a 3rd party tool.

It's not very hard to write out a BMP file, and I take this approach in my book (see my signature). BMP is a Windows format, but it can be visualized by pretty much every bitmap viewer app out there (including on Mac OS X and on Linux).
 

dodonutter

macrumors regular
Original poster
Nov 4, 2004
217
0
Deep South UK
Well in the end i just formatted the output to a file so the temperatures of each point were displayed as a grid every iteration so i just scrolled down the file to see the temperature diffusion. worked ok actually.

Second part of the project was to basically do a 3d version which was harder to visualise but there were no bugs as i used the same code from the 2D stuff but it was a little harder to visualise but it works.

As I have now done it and i have another day to work on it im going to play with OpenGL i think to see if i can get any visualisation going. bit more expandable than Python or MatLab and it would be good to know for when i move over to xcode programming in a month or so. assuming that you have to use the same basic calls as OpenGL is OpenGL whatever platform your using.

Thanks for the replies, does anyone know a good place for OpenGL (free) tutorials or if there is a way to figure out if my PC has OpenGL compatibility (if that even makes sense). I've seen http://www.glprogramming.com/red/ so will probably read through that.

Thanks again
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
<snip>
As I have now done it and i have another day to work on it im going to play with OpenGL i think to see if i can get any visualisation going. bit more expandable than Python or MatLab and it would be good to know for when i move over to xcode programming in a month or so. assuming that you have to use the same basic calls as OpenGL is OpenGL whatever platform your using.

Thanks for the replies, does anyone know a good place for OpenGL (free) tutorials or if there is a way to figure out if my PC has OpenGL compatibility (if that even makes sense). I've seen http://www.glprogramming.com/red/ so will probably read through that.

Thanks again

I'm not sure about good resources, but OpenGL is probably worth learning if you intend to do much visualization, especially cross-platform. OpenGL is a single API that should be supported from one OS to the next in the same way. I am sure there are platform-specific quirks, but you don't need to learn "Mac OpenGL" or "Windows OpenGL". There are certain video cards that accelerate certain parts of OpenGL, and this may require platform specific drivers. You shouldn't need to worry about that, though. If something can't be accelerated on a particular system it will be done in software.

I'm not sure what you are intending to start learning in a month, as XCode supports a lot of languages. If you are wanting to learn to develop graphical OS X applications you are going to need to learn Objective-C and how to use the Cocoa API. I would pick one thing at a time to deal with, though. if you want to start learning OpenGL, go for it. I just wouldn't try to make the first Objective-C program you code use the Cocoa or OpenGL APIs, as it will probably only stand to muddle things up.

Good luck!

-Lee
 

Cromulent

macrumors 604
Oct 2, 2006
6,812
1,100
The Land of Hope and Glory
I just wouldn't try to make the first Objective-C program you code use the Cocoa or OpenGL APIs, as it will probably only stand to muddle things up.

That was exactly the mistake I made. I tried to jump straight into learning OpenGL without a decent understanding of C. It didn't end very well, in fact I'm only now starting to get back into OpenGL. But if you are starting with OpenGL start out with GLUT it is much easier to use than the native UI frameworks and lets you get on with learning OpenGL properly.
 

dodonutter

macrumors regular
Original poster
Nov 4, 2004
217
0
Deep South UK
Thanks Lee, well I'm currently on C++ as i'm doing a programming module as part of my engineering degree but I have 3 months off once i finish before i start my job so thought i'd move over to obj-C and cocoa in Xcode so I can play on my PB. Wasn't going to focus on the graphics stuff at first as I can see it would add a whole new level of difficulty but as I have simple OOP going at the moment, including a little OpenGL if its not too much work can't be a bad thing. I'm sure i'll be back here with more questions when i'm working in Obj-C!

Cromulent - hadn't heard of GLUT but i'll have a look at that, looks like a nice intro and the sort of thing i need, thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.