July 27th, 2003, 03:20 PM
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
July 27th, 2003, 03:48 PM
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.
July 27th, 2003, 03:53 PM
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' )
July 27th, 2003, 05:35 PM
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 05:37 PM.
July 28th, 2003, 07:17 AM
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.
July 28th, 2003, 08:51 AM
Take a look on the net for Denthor's VGA tutorial series:
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.
July 28th, 2003, 10:35 AM
I'll take your advice, but i need to know how to do DOS before i can start using Win applications
July 28th, 2003, 11:34 AM
I've found loads of examples, but most of them aren't compatible with DevC++ and I dont know why. Help?
July 28th, 2003, 01:01 PM
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.
July 28th, 2003, 02:17 PM
Dev-C++ uses the MingW compiler, and I get the errors :
In this piece of code :
_AX = 0x0013;
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.)
July 28th, 2003, 02:28 PM
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.
July 28th, 2003, 05:01 PM
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:
July 28th, 2003, 06:30 PM
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.
Last edited by dog135; July 28th, 2003 at 06:32 PM.