1. ## drawing a rectangle!

Hi!
I`m trying to draw a rectangle in c++ but it doesnt run!
it compiles successfully! but when i run it ,it doesnt show anything on the screen
plz guys! what should i do?
this is my code:
Code:
```void box(int startx, int starty, int endx, int endy, int color)
{
line(startx , starty , endx , starty , color) ;
line(startx , starty , startx , endy , color) ;
line(startx , endy , endx , endy , color) ;
line(endx , starty , endx , endy , color) ;
}
void line(int startx, int starty, int endx, int endy, int color)
{
register int t , distance ;
int xerr = 0 , yerr = 0 , deltax , deltay ;
int incx , incy ;
deltax = endx - startx ;
deltay = endy - starty ;
if(deltax > 0)
incx = 1 ;
else if(deltax == 0)
incx = 0 ;
else
incx =- 1 ;
if(deltay > 0)
incy = 1 ;
else if(deltay == 0)
incy = 0 ;
else
incy =- 1 ;
deltax = abs(deltax) ;
deltay = abs(deltay) ;
if(deltax > deltay)
distance = deltax ;
else
distance = deltay ;
for(t = 0 ; t < distance + 1 ; t++)  {
mempoint(startx , starty , color) ;
xerr += deltax ;
yerr += deltay ;
if(xerr > distance) {
xerr -= distance ;
startx+=incx ;
}
if(yerr > distance) {
yerr -= distance ;
starty+=incy ;
}
}
}```

2. Are you capable of running that sort of DOS code on your current operating system?

3. yes and also i use <windows.h> but still shows nothing

4. Looking at that, I would imagine its some sort of DOS point plotting function, correct? I am more than acquainted with the Win32 API and mempoint() is not how you'd do this in windows. If I had more info as to what sort of graphics API you are using I could help you more.

5. I use Dev-c++ .i check its include`s file and it does have the dos.h.
it doesnt have any error but it shows nothing in the console.

6. Ok, thats why bud. You need a DOS compiler to do what you are attempting to do (I knew mempoint() sounded familiar for some reason). Try downloading Allegro or something similar for basic graphics. Dev-C++ ships with that dos.h header for reasons not entirely known to me since it doesn't include a DOS compiler. What is your level of experience in programming?

7. well this is my first time doing graphics.Im a freshman in computer science but I`m pretty good at programming c/c++. do u have any idea how to draw a rectangle in a windows compiler?thanks

8. Well to be honest, you will be disappointed if you enjoy programming in the functions for lines, or elated if you happen to dislike tedious code such as that. Since I think you first need to get familiar with how to create a window in windows, you would benefit from reading a tutorial.

http://www.winprog.org/tutorial/

Is very good, so read this, mess with the code a bit, and feel free to ask further questions from that. This will of course bring you over to the dark side and you will be able to ask more questions in the windows board. If you are familiar with C++ at all I know some very good platform independent libraries so that you can write code that is portable.

9. Hmmm this is on the C++ board, so I will go out on a limb and say you do know C++.

http://irrlicht.sourceforge.net

I may be a little off base here, but I think this is library is more the direction you are going with your line of questions here. Also, if you are quickly feeling overwhelmed, rest assure you can program 2d graphics (easily) using this library too. If this is satisfactory you can disregard the last link I posted for now, but I still think its beneficial for you to be able to actually write OS specific code at some point in your life. But that doesn't have to be today

10. thanks a lot for your help.:X

11. No problem.

12. Originally Posted by 3pid
well this is my first time doing graphics.Im a freshman in computer science but I`m pretty good at programming c/c++. do u have any idea how to draw a rectangle in a windows compiler?thanks
http://nehe.gamedev.net

Dozens of OpenGL tutorials, starting with just popping up an empty window. Source code is downloadable for several compilers/languages. If you're using Visual Studio, download, open project, and build it. From there, you can play around with it and learn.