...

How can i draw in c++

aimenkawaz
10-11-2002, 11:04 PM
How can i draw in c++ using many colors not only 16 color???

Bosko
10-11-2002, 11:08 PM
Draw what?Which OS?GUI or terminal application?

aimenkawaz
10-11-2002, 11:18 PM
the operating system is dos & the language is c++

Bosko
10-12-2002, 02:06 PM
With Unix like OS' you can use the (N)curses library,I am not sure if such a thing exisits for DOS.

firepages
10-12-2002, 03:12 PM
There are C/C++ API's for the GTK toolkit (http://www.gtk.org) and for imagemagick (http://www.imagemagick.org)

though whether they let you use more than 16 colours I dont know :) , though the GIMP (PS for Linux) is GTK based so I can only assume yes.

aimenkawaz
10-12-2002, 03:27 PM
What is the N courses library & where can i find it???

aimenkawaz
10-12-2002, 04:36 PM
firepages can u explain me more pls

Bosko
10-12-2002, 06:02 PM
Originally posted by aimenkawaz
What is the N courses library & where can i find it???

You need to learn how to read and how to ask questions,it's called Ncurses and as far as know only available for Unices,so since you are using DOS I dont know how you can draw colors.You can always make a GUI app.

aimenkawaz
10-12-2002, 06:24 PM
How can i make a GUI application???

Shawn Curry
10-13-2002, 09:24 AM
You're gonna need to learn some Windows API. You can set up a DOS like shell in a win32 app with
#define WIN32_LEAN_AND_MEAN
and then link with the libraries for whatever you decide to draw with (DirectX, OpenGL, etc) but first of all you need to be able to write a windows shell to handle the windows messages.

Good Luck!

maes
10-13-2002, 05:24 PM
this is some code that i used about 7 years ago, on a TC compiler (I have no idea what version it was)
So it is possble that it won't work. it isn't standard C so I doubt it will work with other compilers then TC.
But if I were you, I wouldn't waste my time learning graphics for DOS. Go with Directx (or OpenGL). DOS is dead (my opinion) Programming for the console or DOS is only good for learning. People these days want a nice GUI to work with. And if you want to make a presentation or a game, use a recent graphics library

If you're interested, here's the code. But like I said, it isn't going to work I think. it should draw a circle.
BTW, straal means radious.

#include <graphics.h> //Compiler dependant code
#include <stdlib.h>
#include <stdio.h>
#include <conio.h> //Compiler dependant code


int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int x,y,straal;

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");

/* read result of initialization */
errorcode = graphresult();
/* an error occurred */
if (errorcode != grOk)
{
printf("Graphics error: %s\n",
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}


clrscr(); //Also Compiler dependant
printf("\nX-coord : ");
scanf("%i",&x);
printf("Y-coord : ");
scanf("%i",&y);
printf("straal : ");
scanf("%i",&straal);

circle(x,y,straal);
}

aimenkawaz
10-14-2002, 10:09 AM
maes, i know that i want to draw with many colors....

Shawn Curry
10-14-2002, 03:42 PM
Well, like I said you need to learn OpenGL or DirectX. Don't waste your time with anything else. In fact, if you dont know either of these, learn OpenGL first. It's platform-independant; you can use it on a Windows, Linux, or Mac box with only small modifications(to the GUI shell).

maes
10-14-2002, 04:06 PM
Originally posted by aimenkawaz
maes, i know that i want to draw with many colors....
Then you have to set your pallete collors. If I remember correctly, you can only have a few ( I think it is 16) colors on your screen at the same time. but you can choose any of the rgb values.

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
/* select a driver and mode that supports the use */
/* of the setrgbpalette function. */
int gdriver = VGA, gmode = VGAHI, errorcode;
struct palettetype pal;
int i, ht, y, xmax;

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");

/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}

/* grab a copy of the palette */
getpalette(&pal);

/* create gray scale */
for (i=0; i<pal.size; i++)
setrgbpalette(pal.colors[i], i*4, i*4, i*4);

/* display the gray scale */
ht = getmaxy() / 16;
xmax = getmaxx();
y = 0;
for (i=0; i<pal.size; i++)
{
setfillstyle(SOLID_FILL, i);
bar(0, y, xmax, y+ht);
y += ht;
}

/* clean up */
getch();
closegraph();
return 0;
}

if you mess around with the "i*4, i*4, i*4" you can get different collors. for example: "i*1, i*1, i*3" will give you different shades of blue

I hope this is what you're looking for

maes
10-14-2002, 04:14 PM
This is an example that came with the TC compiler. Perhaps you've seen, if not, here it is
I learned alot from it.


edit:
Notepad messed up the code.
try here (http://users.skynet.be/wiseguy/code/files/BGIDEMO.C)

aimenkawaz
10-15-2002, 03:53 PM
I know all of these programs:D
but i still don't know how to draw with many colors :(

maes
10-15-2002, 05:07 PM
sorry then , that's all I know from DOS graphics :o

But maybe they can help you here: www.cprogramming.com

aimenkawaz
10-15-2002, 09:48 PM
Thank u very much maes



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum