Thread: Hardware Manipulation with C++?

  1. #1
    Registered User GoldenNeo64's Avatar
    Join Date
    Aug 2011
    Location
    The restaurant at the end of the universe
    Posts
    4

    Hardware Manipulation with C++?

    Hey everyone
    Firstly, I'm rather new to programming in general. So please bear with me if this is a stupid question.. :/ But simply put, I've been trawling through the depths of the web looking for a simple answer as to how to start manipulating hardware (Mouse, Keyboard, Monitor, that sort of thing, the basic tools of the computing trade.. :P), and I haven't found a single simple answer that I can understand (Then again, maybe it's just me ^.^")

    I'm currently using the Dev-C++ IDE which opens using the DOS window by default.. and as i'm hoping to get my foot in the door with game programming, learning how to manipulate graphics and the like would be a must..
    So if anybody could give me a simple answer as to how to go about learning this, It would be GREATLY appreciated

    Thanks for your time

  2. #2
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    These are two seperate things: (1)Manipulating hardware and (2) Game programming.

    (1) Accessing Hardware. This is OS specific, assuming you are using windows - based on your post - you would want to look at the Windows API. A good starting point is Forgers WinAPI Tutorial.

    (2) Game Programming: In this case the best place to start would be looking through our Game Programming Links. The two popular choices for developing games are OpenGL and DirectX. Again take a look through the links to see what you would prefer to work with.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    The simple answer: there is no simple answer.

    The means of "manipulating hardware" are specific to each operating system (or family of operating systems). Modern operating systems are designed to prevent direct manipulation of hardware. If you want to manipulate hardware, you generally use some API (application programming interface) to request the operating system do what you want. Those APIs are fairly complex, because they can do lots of things.

    There are some older operating systems that allow direct manipulation of hardware. Even on those, the techniques (API, etc) to manipulate hardware were often complex. But it was also found that too many programmers, if their software was allowed to directly manipulate hardware, would accidentally or deliberately find a way to mess up the host system. For example, writing over memory in use by other programs, corrupting a display, dropping bits of input inappropriately. It's still possible to mess things up via the API provided by a modern operating system, but is more difficult to screw things up completely.

    If you want to learn to manipulate hardware via a modern operating system, you need to dig into the documentation for your operating system of choice, your development environment of choice, and any libraries (for example, graphics libraries) you choose to use. If you want to use an older operating system that provides unfettered access to hardware, keep in mind that relatively few users will want to use your programs.

    Look up topics like game programming: they provide information on how to do things within bounds of the operating system.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > I'm currently using the Dev-C++ IDE which opens using the DOS window by default
    First, that black rectangle with the C:\> prompt is NOT DOS. It is a win32 console.
    There is none of the ancient 8.3 filename or 64KB segment nonsense.
    Nor is there any direct access to the hardware, so you can't for example make a pointer to 0xB800 and expect to see things "on screen" if you start writing there.

    Also, dev-c++ is an old (and unmaintained) IDE, with a similarly old version of gcc/mingw under the hood.

    Here are some more up to date offerings.
    Free Developer Tools - Visual Studio 2010 Express | Microsoft Visual Studio
    smorgasbordet - Pelles C
    Code::Blocks
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User GoldenNeo64's Avatar
    Join Date
    Aug 2011
    Location
    The restaurant at the end of the universe
    Posts
    4
    @AndrewHunter: So, have I wasted my time in learning C++ if i wanted to get into games design then? :s Or is it worth learning the language alongside DirectX or whatever medium I was going to use?

    @Salem: Thanks for the heads up Probably best to get all of the stupid mistakes like that out of the way before I get comfy with programming ^.^

    And last but not least :P @Grumpy: Thanks, the whole topic of API's was a little bit vague even after I did all the research and you've really cleared it up for me
    Last edited by GoldenNeo64; 08-18-2011 at 02:38 PM.

  6. #6
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by GoldenNeo64 View Post
    So, have I wasted my time in learning C++ if i wanted to get into games design then? :s Or is it worth learning the language alongside DirectX or whatever medium I was going to use?
    As I said before, game programming and hardware access are two seperate things. DirectX isn't a language, it provides an interface for graphics, input, output, sound, ect. This is what you will be doing when making games, using a programmatic methods to interface with the hardware. You still need to learn a programming language to use this interface.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  7. #7
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by GoldenNeo64 View Post
    @AndrewHunter: So, have I wasted my time in learning C++ if i wanted to get into games design then? :s Or is it worth learning the language alongside DirectX or whatever medium I was going to use?
    Last I heard, C++ was pretty much hands down the most popular language for writing games in. DirectX is a technology and not a language unto itself; to use the technology you would use the C++ DirectX API.

    So you are on the right path, but be patient, because it is not a quick and easy one.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  8. #8
    Registered User GoldenNeo64's Avatar
    Join Date
    Aug 2011
    Location
    The restaurant at the end of the universe
    Posts
    4
    Ah right, So DirectX is ,basically, an OS-independant API? (Sorry if i'm being a bit slow ^.^" The whole actual process of making a game is something I still haven't quite grasped yet i'm afraid)

  9. #9
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    DirectX is actually an OS dependent API. It is made by microsoft and works on microsoft compatible platforms, e.g. XBOX360, windows, ect. You may want to stick with learning C++ and once you have the basics and linguo down then move on to graphical programming to include DirectX or OpenGL games.

    EDIT: Also to get into game programming you are going to definitely want to get a newer compiler. If you decide to go the DirectX route, IMO the best compiler/IDE interface for that would be Visual Studio(see Salem's link) specifically for ease of installing and interfacing with the required libraries.
    Last edited by AndrewHunter; 08-18-2011 at 03:01 PM.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  10. #10
    Registered User GoldenNeo64's Avatar
    Join Date
    Aug 2011
    Location
    The restaurant at the end of the universe
    Posts
    4
    Right Thanks for the help and advice everyone, You've definetely answered my questions and more ^.^

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. hardware manipulation with pointers
    By TheSupremeAbode in forum Tech Board
    Replies: 3
    Last Post: 06-20-2011, 04:38 AM
  2. C for Hardware
    By biggiebigzz in forum Tech Board
    Replies: 2
    Last Post: 09-26-2007, 12:01 PM
  3. Hardware
    By GSLR in forum Tech Board
    Replies: 4
    Last Post: 03-06-2003, 12:32 PM
  4. hardware
    By onurak in forum C++ Programming
    Replies: 3
    Last Post: 07-18-2002, 08:36 PM
  5. anyone is well in hardware ?
    By black in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 06-27-2002, 04:22 AM

Tags for this Thread