Solved

Looking for a nice free stable C/C++ platform to do some simple windows programming

Posted on 2004-09-10
10
205 Views
Last Modified: 2010-04-15
Hi.  I am trying to write a program that displays a small white square (8x8 pixels) on a black screen that is moving (using graphics), also the keyboard modifies the direction/acceleration of the square.  My problems are:
(1) I don't have C/C++ installed on my PC (I don't really know where to get a good free compiler)
(2) I'm not clear on how graphics work in C (will it be platform independent?)
(3) I can use the keyboard, but I need to detect every 10ms what the state of two keys are (up or down) to recalculate the cursor position, so its not detecting simple keypresses, etc.  I need to scan the key state every 10ms.

I know some of this stuff is easy, and I am familiar with C/C++, just haven't done it in a few years.  I'll even set this as a 150-point question just so that you're not wasting your time.

Any help would be welcome.  Thanks.

powertrain
0
Comment
Question by:powertrain
10 Comments
 
LVL 23

Expert Comment

by:Mysidia
ID: 12031966
As for a free C/C++ compiler... MingW32 http://www.mingw.org/

As for the graphics work, you will need to use a third party library such as SDL:
http://www.libsdl.org/index.php
0
 
LVL 23

Expert Comment

by:Mysidia
ID: 12032048
I mean as per the graphics, you have many options, but a graphics library isn't part of the basic
C++ language

You could also use DirectX for graphics, maybe someone else has a better link
http://mywebpage.netscape.com/PtrPck/directx.htm

Borland has "personal" versions of some of their development tools available for
free download... http://www.borland.com/products/downloads/download_cbuilderx.html

See here also: http://www.thefreecountry.com/compilers/cpp.shtml
0
 
LVL 11

Expert Comment

by:avizit
ID: 12032325
I found devcpp quite good

http://www.bloodshed.net/devcpp.html
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 1

Expert Comment

by:bsnh99
ID: 12032576
This may be a bit of a stretch if you prefer to stay on windows:

    linux: http://fedora.redhat.com/
    gcc: http://gcc.gnu.org/
    GDK is part of GNOME and could be used for graphics
    the keypress handling can be handled through the event/message mechanisms
0
 
LVL 22

Expert Comment

by:grg99
ID: 12034255
Don't forget the excellent www.openwatcom.org   compiler suite.  16 and 32-bits, real and DPMI and protect-mode.  Win 31, Win95/98/NT/XP.  Fast compiler nad good optimization.   Great manuals.
And good graphics libraries included.  And freee.  And still supported and being improved.

0
 
LVL 3

Expert Comment

by:CmdrRickHunter
ID: 12037265
2) as said above, C does not do graphics.  people write libraries (in C, but thats besides the point) that do graphics for you, such as openGL, or directX, or X, or the windows GUI API.  A library can be cross platform (openGL is), but usually the initialization (creating the initial window) is not.  You can look into GLUT if you really want cross-platform abilities.  GLUT is a GUI API that works under both Windows, and Unix (using X), and macintosh (obviously since osX is a unix variant, but I believe there is a GLUT variant for OS9) GLUT compiles into native API code for whatever system you compiled on (or are compiling for, if you do some command line tricks)
3) Reading the keyboard accuratly every 10ms is going to be hard.  under windows, DirectInput should be able to do similar.  But ask yourself how important is this EVERY 10ms?  If your harddrive is thrashing because the computer is bogged down, you might not get to execute your code every 10ms.  One thing you can do is track KEY_DOWN and KEY_UPs, and keep track of the state of the key.  A timer will then let you keep approximatly 10ms timing.  Threads will help you out for keeping the timers going at the right rate, but watch out for multirhtreading issues.

Are you actually using a keyboard?  10ms is 1/100th of a second.  Its hard for a human hand to have that kind of accuracy, and the human eye can't see that fast (I use PWM at these frequencies to give an LED the appearance of dimming).  Or is this a hacked apart connection to some hardware component that has 10ms accuracy.
0
 

Author Comment

by:powertrain
ID: 12146828
Re: open watcom (grg99), I went to the openwatcom site and it looks like you have to pay for it.... is that true?

Re: timing issues (CmdrRickHunter), well actually its for an experiment with some specific requirements.  In actuality I will need to scan the state of the keyboard (2 keys) every 1ms (and store it) and perform the calculation to display the tiny square every 10ms.  If I put it that way, do you think it will be any more possible
0
 
LVL 3

Accepted Solution

by:
CmdrRickHunter earned 150 total points
ID: 12148920
Windows is not a real-time OS (nor are most major OSes).  You can't be guarenteed to even run once per millisecond (much less check something every millisecond).  You might get lucky, and have it work, and be able to get the polling rate you want... or you might get unlucky and have your program get switched out of memory on you, and not be able to use it for 50ish ms.

as for displaying at 100Hz (10ms), it can be done, assuming your monitor does support 100Hz refresh rates.  be sure to tell the graphics language to "wait for refresh", and make sure you update at over 100Hz (so that you dont miss anything).

I dont know how strict your requirements are.  If you HAVE to poll every 1ms, on the ms, then you would have the best results writing a simple microcontroller to poll it, and tell the computer the states.  That way if it takes the computer 2ms to get around to executing your thread, it just has to handle two updates at once (not too hard).

If its okay to miss a poll every so often, you could try your luck with a OS specific keyboard reading function (something like DirectInput from the DirectX suite).  It might have the update rate you want, it might not.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question