#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    -
    Posts
    6
    Rep Power
    0

    Talking GFX in DOS for a newbie


    Hey, im a relative noob to C++, and i was wondering if anyone could help me to do GFX in a Consol Application.
    None of the standard include files don't seem to have anything to do with graphics, so I could really do with some help :)
    Thanks,
    JonWoG
  2. #2
  3. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
    You can't do graphics in just a Console App. The only thing you can do is ASCII graphics, like in Text Mode in DOS, but I don't think this is what you are looking for. You'll have to get into using the Windows GDI or DirectX (or OpenGL) for real graphics.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    -
    Posts
    6
    Rep Power
    0
    Erm...
    On your site, i've seen 3D examples done in DOS?
    I'm not fussed if i have to use DX or OpenGl, i just need to do GFX.
    (Preferably not in Windows tho' :))
  6. #4
  7. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
    Yes, you can do graphics in DOS. You were asking to do graphics in a Console Application, which means you are using a Windows Operating System. If you wish to program in DOS, then there are some graphic units you can use to access graphics modes supported by standard VGA. Some are easy enough that you can access them directly yourself without a graphics unit. For example, a simple interrupt call can change the video mode into mode 13h (320x200x256 colors), and the memory at 0xA0000 is a linear frame buffer of all 64,000 pixels (one byte per pixel). Mess with them as you please, and the display changes immediately, as this memory is mapped over the video memory for this mode. However, stuff like this CANNOT be done from within Windows. The purpose of windows was to provide a standard API to access anything available for hardware, and therefore direct accessing to interrupts and video memory is not allowed. If you wish to have the performance gains of such a set-up, go with DirectX, in which it allows direct access to video memory and hardware accelerated graphic function calls, for drawing polygons, etc.
    Last edited by Jason Doucette; July 27th, 2003 at 06:37 PM.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    -
    Posts
    6
    Rep Power
    0
    Cool...
    The thing is, I don't have any C++ books, so im just learning from what i've found on the net.
    The VGA thing sounds great, but could you tell me how to use it?
    ie. plotting pixels, drawing lines etc.
    Also, I had a look for the DX developers kit, and am currently downloading the DX9 kit - 223Mb on my 56K modem :)
    I was just wondering if this is the right thing to download - i don't want it to be a huge 223Mb waste :)
    I already have 4 years of programming behind me in QBasic, so Im not a complete noob to programming.
    Thanks,
    JonWoG
  10. #6
  11. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
    Take a look on the net for Denthor's VGA tutorial series:
    google

    There's a version somewhere that converts his original Pascal source into C (maybe C++, I don't remember).

    You should realize that DOS programming is dead. I recommend learning C/C++, the Win32 API, then DirectX. You won't ever regret this. Do not try to jump straight into DirectX without some understanding of C++ and the Win32 API. You'll want to download the DX9 SDK (software development kit), so if that's what you dl'ed, then that's the right thing.

    I started programming with Basic, as well, on a TI-99/4A. I never regretted that, either. It taught me that I needed to be smart with my code if I wanted anything to happen in real-time.
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    -
    Posts
    6
    Rep Power
    0
    Thanks :D
    I'll take your advice, but i need to know how to do DOS before i can start using Win applications
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    -
    Posts
    6
    Rep Power
    0
    Hey,
    I've found loads of examples, but most of them aren't compatible with DevC++ and I dont know why. Help?
  16. #9
  17. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
    You actually don't need to know DOS before programming in Windows, but the knowledge certainly will not hurt you. It will just take more time, since you are going to be learning a lot that will no longer be useful when you get into windows.

    When you said it's not compatible with Dev-C++, what do you mean? Did you find the C versions of the tutorial? Also, are you trying to compile a DOS program as a Console Application (i.e. a Windows program)? Also, does Dev-C++ allow for DOS compilation? Remember, his tutorials are probably programmed in real-mode, which are 16-bit applications (i.e. segment : offset for memory access that allows 20-bits of memory addressing), not 32-bit protected mode applications.
  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    -
    Posts
    6
    Rep Power
    0
    Dev-C++ uses the MingW compiler, and I get the errors :

    '_Ax' Undeclared

    In this piece of code :

    void SetMCGA()
    {
    _AX = 0x0013;
    geninterrupt (0x10);
    }

    I also get loads of other errors.

    I've found a lib called Allegro, which is a lib for gfx and stuff like that in DOS. It is reccomended for use with Dev-C++ and is well documented so i think i'll use that :).

    Two more questions :

    How do you make an application wait for say 2 seconds? (Like 'Sleep 2' In QBasic)

    Can you and if so, how can you do immediate Input? (Rather than having to type something, then press enter.)

    Thanks,
    JonWoG
  20. #11
  21. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
    geninterrupt() is probably a Pascal function, not a C function. I used inline assembly, so I have never used it. Again, did you find the version of the tutorial that has the pascal code converted into C? Dev-C++ will not compile Pascal code.

    sleep() makes an application wait for a specified period of time.

    You will have to process keyboard interrupts or use functions that access the keyboard buffer to get immediate input.
  22. #12
  23. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    3
    Rep Power
    0
    I've dabbled a little with the DOS VGA-subject as well and can tell you at once that you can't use Dev-C++ for it (i've had no luck at least, primarily because i prefered using the union REGS instead of inline assembly for the interrupt bios-calls. I'd better add at once that i'm much of a n00b to programming = )

    I've had luck with compilers like Pacific C and Open-Watcom for compiling DOS-programs that can use bios-calls in plain C. Here's some guides that i've found very helpful:

    http://www.brackeen.com/home/vga/index.html
    http://www3.bc.sympatico.ca/alexande...troduction.htm
  24. #13
  25. Doggie
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2003
    Location
    Seattle, WA
    Posts
    751
    Rep Power
    13
    Here's a class I made that uses the graphic tools with Turbo C++, a free
    compiler I downloaded off the web when I first started at my current job.
    Attached Files
    Last edited by dog135; July 28th, 2003 at 07:32 PM.

IMN logo majestic logo threadwatch logo seochat tools logo