Question:
How would i draw a red dot using c++ without using any headers?
xxxx1101xxxx
2009-06-07 18:38:07 UTC
I pretty much get how to do things in c++ so long as i keep w/e i'm doing confined to command lines. But i really don't have any idea how to do anything visual without a library like directx or opengl. But let's say i want to go about drawing a red dot somewhere on the screen. I'd like to do this w/o using any headers, even the windows header. This would probably really hard and ****, but i just want to see how its done.
Four answers:
mdigitale
2009-06-07 18:44:10 UTC
You can get rid of the headers if you do a lot of copy-paste...not sure why you would want to waste your time though.
Ratchetr
2009-06-08 02:33:43 UTC
In order to put a red dot on the screen, some bit of code somewhere needs to put the right 'data' into video card memory. In order to do that, you need a few things:

* You need to know the address of video memory.

* You need the OS to grant you write permission to that memory.

* You need to know the format of the video memory. This will vary depending on the resolution and the video card vendor.



#2 in that list is pretty much a show stopper in Windows. It's not going to let any arbitrary bit of code running from the command prompt to address video memory. Even if you could figure out that video memory was at 0xFF008100, and you created a pointer with that value, you're gonna crash when you try to write there. Only a device driver can do that.



If you really really want to do this, you would need either write a kernel mode driver for you video card/OS, or:

* Boot an OS like DOS that doesn't provide any form of memory/IO protection.

* Read the hardware manual for your video card. You'll have to do a bunch of 'stuff' to switch out of text mode into video mode. And what works on your video card probably won't work on other vendors cards.

* Understand how your video card maps bytes in video memory to pixels. This will depend on the video mode.

* Get a pointer to video memory. In DOS it's a bit painful, because you have to map small chunks of video memory into the 16-bit address space. I'm not even sure all modern video cards still support this. As an alternative, you might need to switch into protected mode. (Which is another huge can of worms).

* Finally, you can write the bytes of data into video memory that create the red dot.



Having done all of that hard stuff already myself, I'm rather thankful for libraries that abstract away all that complex stuff. Calling Pixel() or Circle() is a much more productive way to spend your time ;-)



Edit to add: Copy/Paste from the header files (even if you were willing) wouldn't work. Header files are just definitions of the functions you can call in a library. They aren't the implementation. The implementation is in the .DLL files, so you would need to duplicate that too (and you don't have the source code).
2009-06-08 02:08:25 UTC
You cant, the only way I see it is if you copy paste the imformation inside all the header files, until getting to the last



so you should, use opengl, directX, the windows api, any other library,
2009-06-08 01:50:29 UTC
php tutorial

http://phpfreak.info/


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...