A C++ question

I realise that I might be better to ask this on a C++ forum, however I’ll give it a shot here first cause I know there’s lots of programming gurus here and answers to previous questions I’ve asked have always been very helpful.

Here’s the background and question…

background
I’m revisiting trying to get to grips with programming. Various people including people here have recommended C++ as a good place to start. I’m having some success with the basic concepts and have found lots of useful sites for information.

I’m currently having a go at writing statistics functions and (this is the key bit) wanting to be able to output nice graphs - colors and good graphics. However, I’m still at a very basic level of understanding and all I know to do is print (ie cout) stuff into the console window using arrays and iterative loops.

Very little of what I’ve read so far explains how to go about creating an output window other than the console window. I had a dabble with OpenGL (which I would guess is would be pretty useful) earlier this year, but I still don’t understand how to link the C++ stuff into OpenGL stuff and get the nice graphs… or whether it would be better to simply learn OpenGL

I’m not expecting miracles, but it would be really nice if I could understand how to link up the C++ stuff to an output window which is a bit more sophisticated than the console window and get a basic understanding of how to link the two

The question(s)

So…

  1. Should I simply continue to learn about C++ stuff… cause everything will become clearer in time?
  2. Is there a neat place where I can learn about the links between C++ stuff and basic graphics?
  3. Should I have another cup of tea and some provolone?
  4. Am I better to ask at a C++ forum

I’m on a mac using the Developer Tools if that makes any difference to the the answer…

What you need to do is find a library that will open windows, draw graphics in them, etc. for you. OpenGL is one such library, but is meant for doing 3D graphics using 3D graphics hardware. (It’s what Blender uses of course. GLUT is a library associated with OpenGL which is useful for basic stuff like windows and input. Blender’s GUI library is called Ghost-- I don’t know if it’s been seperated out from Blender yet).

I personally like wxWidgets (http://www.wxwidgets.org), because it supports Windows, Linux, Mac and some other platforms, therefore you will be able to support all of these platforms with just a little bit of effort. It’s free software, well designed and easy to understand – it’s not too big, and has a good community.

On the Mac, you can use all of Apple’s libraries too. You would want to look at their developer documentation (http://developer.apple.com, you may need to register etc.), under “Carbon” (This is what they call their collection of C++ libraries, Cocoa is Objective C) and “Core Foundation”.

Read Apple’s documentaion for XCode and for GCC (the compiler) for info on how to link your program to a library.

I’ll also add, that my own recommendation if you’re brand new at programming is Python (http://www.python.org). The basic syntax is slightly easier if you’re new to programming, you don’t have to worry about the details of compiling and linking which can be pretty annoying sometimes, and it comes with a large library of useful support libraries (modules) out of the box. You can use wxPython for GUI stuff if you want.

Knowing Python will also allow you to write scripts you can run inside Blender!

Perl is another good language, though parts of it are quite mysterious even to seasoned programmers :slight_smile: It has a huge collection of third party modules that do everything under the sun.

Thanks reed for the very helpful and detailed reply. I’m sticking with c++ for now cause otherwise I’ll get confused! I understand its pretty versatile and I want something which allow me to do a number of different things - stats and graphics mainly.

The Developer Tools are quite amazing and I have followed some cocoa and carbon tutorials which end up with you creating a window, dragging and dropping menu items and various buttons into it. Problem is that I don’t understand the fundamentals of writing the code - e.g. what header files I would need to include and how to give instructions to create a ‘picture’(graph) within the window.

From what you say, it sounds like OpenGL could do what I want it to do, but would be a bit over the top as I’m just wanting a simple 2d representation of some numbers. I’ll look into the wxWidgets community and see where I get to.

Thanks again

You should be able to find on the Apple developer sites both “API/Reference
Documentation” and example programs. There are a few examples that come with the Developer Tools too.

GCat wrote:

c++ for now cause otherwise I’ll get confused!

just a little note…

when you have the time open up a book on “c”…

because in the end, thats what everything comes down to :slight_smile:

cheers

lilo

Will do.

Infact, in amongst the web resources I found this site… (very good, clearly written stuff).
http://www.uow.edu.au/~nabg/ABC/ABC.html
Chapter 4 gives something of the history of programming languages

And my progress with getting that graphics window might just be a bit closer since I discovered these sites…

http://www.sci.brooklyn.cuny.edu/~cis22/opengl/

NeHe’s site

3Dbuzz.com is having a special ending on Dec. 1st.

Basicly they have a huge resorce of exelent video training on things mainly 3D related. But they do have some other “VTM’s” as they call it. Stands for video training magazines. I have yet to see a web page that has better video training than 3DBuzz.com. I highly recomend them. (did I mention most are free to download?)

So anyway the deal is on their C++ VTM’s (which are member sponsor content only, usually). You pre-order Issue’s 4 & 5 and you get Issue’s 1,2 and 3 for free!

I’m buying these myself. But, they ARE geared towards GAME PROGRAMMING. That doesn’t mean you won’t learn the basics and then some.

Oh, duh… they cost $50 each plus $10 shipping. So, you’re saving $150 dollars with this deal. Either that or you become a member sponsor for $30 a month and in three months you’ll have access to the first issue… then you have to complete the work in order to get the others.

Anyway, enough yapp’n here’s the link to their online shop with all the info: http://sv3.3dbuzz.com/xcart/customer/product.php?productid=19&cat=&page=

And the forum post that shows ALL the issues and specs on those: http://sv3.3dbuzz.com/vbforum/showthread.php?threadid=92372

EDIT: Did I mention that it equals over 17 HOURS of video training?? lol… Whoohoo! I can’t wait… hehehehe