I need help.. how do I draw a pixel? I'm making a very simple-designed program (not a game, and the pixel will not move) and all I need to know is how to draw one pixel.
I need help.. how do I draw a pixel? I'm making a very simple-designed program (not a game, and the pixel will not move) and all I need to know is how to draw one pixel.
Last edited by SMB3Master; 05-23-2003 at 06:41 PM.
It would help to know things like:
1) Are you talking about drawing a pixel on a console window, on a graphical window, etc.
2) What operating system you're compiling it for
Console, DOS.
Then it's going to be a royal pain in the ass, unless you have an old compiler from the DOS days, and Windows' DOS emulation is good enough to handle your compiler's graphics routines.
You can try to get an ancient compiler, and write a DOS program with graphics, but there are no standards at all for how to do graphics pre-Windows. Before windows universalized the Software->OS->Driver->Hardware model for accessing hardware, it was kind of a mess. Modern compilers don't do DOS graphics (in fact, many won't even do DOS programs; you can do GUI Windows programs, or console Windows programs).
I believe some of the old Borland compilers can generate graphics code that will still work under XP's DOS emulation, but I haven't programmed DOS graphics since sometime around 1993. Dunno how well Borland's old compilers like running under Windows; I've heard it's tricky to make them work right.
If you have a DOS compiler that will allow inline assembly (or you have an assembler that will do real-mode assembly) you might try BIOS interrupts. Int10h, function 00h sets graphics mode; Int10h function 0Ch writes a graphics pixel. I have no clue what would happen when you execute them on the virtual DOS machine that WinNT uses. Again, it's not something I've done since the pre-Win3.1 days (OK, Win 3.1 existed in 1993 but I didn't use it very much).
This will almost certainly screw up any text output you had planned. Back the, there were 2 display modes: text and graphics. In text mode, you could only display characters, in graphics mode, you got only graphics; you had to use special functions to draw text in a graphics mode (standard text output was no good).
Last edited by Cat; 05-23-2003 at 07:12 PM.
So you program in windows now? I wanna learn but its so confusing
Any advice on starting?
Last edited by SMB3Master; 05-23-2003 at 07:30 PM.
Check out the FAQ, and check the Windows programming forum, and try the links in:
http://cboard.cprogramming.com/showt...threadid=39585
It's not THAT hard, just go slowly and try to understand each step in turn.
It's really just a different WAY of thinking. At its heart, you have:
* A message pump in every thread which receives messages and dispatches them to your windows
* A procedure for each window that responds to messages
Messages are really the key to everything. Stuff happens to respond to a message, and if you want something else to happen, you send a message.
Last edited by Cat; 05-23-2003 at 08:24 PM.
A Single pixel:
#define _WIN32_WINNT 0x0500 //this should be the first line of your program
#include <windows.h>//this should be the second
//use this whenever you need it
HWND hwnd=GetConsoleWindow();
HDC hdc=GetDC(hwnd);
SetPixel(hdc, 10, 10, RGB(0,0,0));
ReleaseDC(hwnd, hdc);
Note, you need to have win2k or higher I think for this to work.
That will work fine, once he does Windows programming.
He's compiling for DOS at the moment.
Might not be very helpfull but i know the old Borld Turbo PAscal compiler would allow drawing in dos.
Search around the net for win32 tutorials, and you'll get the hang of it. If you just want to plot a few pixels, you'll find it is quite easy. Make sure you read what the tutorials tell you, and don't just mess with their code - since understanding how windows works (i.e. messages) is very important. It's really not so bad.Originally posted by SMB3Master
So you program in windows now? I wanna learn but its so confusing
Any advice on starting?
jaso n i must say that chess game and 3ds you have are amazing. the tunnel is fun to stare at
He said console. A console program is a windows program, a lot of it is just hidden from the programmer.Originally posted by Cat
That will work fine, once he does Windows programming.
He's compiling for DOS at the moment.
I interpreted "Console, DOS" to mean he was writing for DOS and running it under the virtual DOS emulation of WinNT or somesuch.
You are correct, console WINDOWS programs can use WinAPI functions.
Don't use interrupt calls to manipulate pixels. Too slow. Edit the video memory directly. If I remember right, VGA cards working under mode 13h's memory starts at 0xA0000000. Only use the interrupt calls to set the graphics mode.
If you can use dos.h you don't even need assembly. Look at www.brackeen.com/home/vga/ for info about DOS graphics. It even covers Mode X junk. I also found a site somewhere that was just interrupt calls, and you can find some cool graphics modes that way. There is a mode similiar to Mode 13h that works in 640x480 that not many know about, but I forget the interrupt number for it.
I would also check out Denthor's Asphyxia Tutorials if you wish to learn about mode 13h in DOS.
Iamien, thanks. Yeah, the tunnel effect was pretty cool. It's very simple, too. The idea just popped into my head one day, and it only took me 30 minutes to code. Fairly simple to convert into assembly, as well. The chess game is not that great, since it lacks hash tables, but it is ok for what was required for the project. If I had time, I would reprogram it from scratch and try to polish it off a little nicer.