CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2009
    Posts
    2

    Some Begginer C++ Questions

    After learning the basics of C++ and having coded a few basic console applications (Tic Tac toe, etc), I have a few questions that none of the tutorials seem to explain:

    1) Is it possible to draw to a specific part of the console rather than just printing to the next line (using cout)? That way it would be possible to learn C++ by trying to write more complex programs eg ping pong etc.

    2) Rather than just writing console applications it would be kinda nice to be able to write programs with a gui. I know that this is possible if I learn windows API, but I am also using linux and also mac occasionally... It would be good if it were possible to write multi-platform stuff. I know this is possible with the likes of gtk and qt etc but what happens when I want to add something other than a standard button or text box, for example, a box that displays a 3d view of something? If I did this without gtk would it be possible to port the program to linux easily?

    Also (please correct me if I'm wrong) applications like Firefox and iTunes etc are multi-platform, but don't use gtk or similiar? So they are either programed for windows to start off with, then ported to linux and mac, or, are they somehow coded for all 3 from the start?

    3) OpenGL, DirectX or neither? I have noticed on some 3d applications that the settings dialog has check box for OpenGL - this implies it is possible to program a 3d application from scratch?

    4) 2D applications - how do I create a graphical 2d application (eg a super-mario clone) that can be multi-platform? Also how is it possible to create a gui that has includes a graphical 2d view part of the gui (eg a music composition program, that includes a graphical 2d viewport displaying the music score)?

    And lastly, what is MS Visual C++ - at the moment I am using Code::Blocks on both my linux and windows desktop. Does visual c++ just do the same thing, or is it specifically meant for windows applications - if so is it possible to port these to linux or mac? I have noticed that Code::Blocks does not have any way of 'painting' a gui - for larger programs this would make the gui display bit very hard. Does MS "visual" C++ include something so as it is possible to visually place objects such as scrollbars and buttons?

    If anyone could shed some light on any of these questions it would be greatly appreciated! After having finished a few small applications I seem to have a lot more questions than when I started :-)

    Thanks!

  2. #2
    Join Date
    Nov 2008
    Location
    England
    Posts
    748

    Re: Some Begginer C++ Questions

    1) the console is text based. I never tried the gdi functions using the console handle, maybe they would work, but I doubt it. You can certainly control the cursor position but its platform specific. For windows you would need something like...
    Code:
    #include <windows.h> 
    void gotoxy( int x, int y ) 
    { 
       COORD coord; 
       coord.X = x;
       coord.Y = y; 
       SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coord ); 
    }
    2) To write multi-platform stuff its easiest with a multi-platform library. Something like Qt or wxwidgets. If you wanted to do something not covered by the library, you would need provide the routine yourself for each platform you wish to support. I dont know about firefox, it may be coded using a library or maybe not but a lot of multi-platform stuff is done using a library. Codeblocks for instance uses wxwidgets.

    3) doing basic 3d stuff is fairly simple using either directx or opengl but beyond the basics things can get highly maths oriented. You had better have a good understanding of maths and physics if you are thinking about 3d games programming.

    4) Use a library. There are a few available freely or write your own.

    MSVC is microsoft visual c/c++ compiler. The express version is freely available but its missing the resource editor so you have to use a 3rd party resource compiler or just create your gui in code. Its pretty much a compiler for windows only. GCC is probably better for multi-platform stuff. I only program for windows so I'm happy with msvc.
    Get Microsoft Visual C++ Express here or CodeBlocks here.
    Get STLFilt here to radically improve error messages when using the STL.
    Get these two can't live without C++ libraries, BOOST here and Loki here.
    Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
    Always use [code] code tags [/code] to make code legible and preserve indentation.
    Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.

  3. #3
    Join Date
    Feb 2009
    Posts
    2

    Re: Some Begginer C++ Questions

    Thanks! That answered a lot of my questions. Now I think I'll write something non console based (or at least attempt to) and see how I go :-)

  4. #4
    Join Date
    Aug 2007
    Posts
    858

    Re: Some Begginer C++ Questions

    3. IMO, neither, unless you are just interested in the 3D programming itself. If you actually want to make 3D games, save yourself a lot of time and work and use a 3D engine like OGRE.

    4. Allegro is one well established 2D lib aimed at games. It has its own (fairly horrible) GUI framework, but there is plenty of other stuff you can use with it.

  5. #5
    Join Date
    Jun 2008
    Posts
    37

    Re: Some Begginer C++ Questions

    I woult choose opengl for drawing, it's better and faster than directx in some aspeects
    directx is MS's, so it's developed better than the free opengl.
    Speed is aproblem depending on projects, mine needs fast, because our business is in webspider

  6. #6
    Join Date
    Sep 2008
    Posts
    15

    Re: Some Begginer C++ Questions

    I suggest image magic, it works like a charm to my 2d drawing application, the downside is the unfit incorporatability (understand ? ) with my MS compiler. It seems created with no care of the compiler in use for good performance.

  7. #7
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Some Begginer C++ Questions

    Quote Originally Posted by Belzeski View Post
    I woult choose opengl for drawing, it's better and faster than directx in some aspeects
    Not really.

    directx is MS's, so it's developed better than the free opengl.
    Not really.

    The main difference between the two is that DirectX comes in discreet versions, while OpenGL does not. If you're targeting DX9, you can be assured of all the features of DX9, and you can't hope to get any from DX10. If you're targeting OpenGL, you can access all the features that the physical card you're running on supports via OpenGL Extensions, regardless of OpenGL version. (The main difference between OpenGL 1 and 2 is that some extensions were folded into the core. OGL 3 has some API differences as well, but again most of the core functionality it has was available via 2.x extensions.)

    Thus Direct3D makes the developer's job a bit easier, while OpenGL makes for more flexible development if you're willing to put in the multiple code paths necessary to deal with missing or available features.

    Additionally, OpenGL is the only way to get "DX10-class" features to work on Windows XP, since DX10 itself artificially limits itself to Vista and above.

    And of course, OpenGL is the only one of the two that's cross-platform.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured