Is there a PSET command equivalent in C/C++ ?
i.e.
In QBasic :
PSET (X,Y), COLOR
(to plot a pixel at (x,y) with COLOR)
is there any such thing in C/C++ ?
Printable View
Is there a PSET command equivalent in C/C++ ?
i.e.
In QBasic :
PSET (X,Y), COLOR
(to plot a pixel at (x,y) with COLOR)
is there any such thing in C/C++ ?
This will be able to help you...
no,
you'll need to use a library(OpenGL, Direct-X, Allegro, SDL, ect...) or ASM or something similar.
Sorry I thought he/she was referring to changing the color of text in console.Quote:
no...
If so then I'll just give the *** **** info.:)
Change the number 6 to a different number to get a different color. Get rid of | FOREGROUND_INTENSITY to make the colors less bright.Code:SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), 6 | FOREGROUND_INTENSITY);
isn't there an easier way to do it ?
like we put a matrix of values (colors) and then
read them over with a small function and then use PSET in QB ?
Personally this seems pretty easy to me...
what you can do, though, is this...Code:SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), 6 | FOREGROUND_INTENSITY);
That's one way to neatly organize the color settings.Code:#define yellow 6
#define red 4
#define green 2 //btw, i have no idea if 6 == yellow if 4 == red and if green == 2...just fiddle around w/ the colors
#define default 1
int color_choose(int color);
int main()
{
color_chooser(yellow); //if you want yellow text
cout << "yellow is the color";
}
int color_chooser(int color)
{
if(color == yellow)
SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), yellow | FOREGROUND_INTENSITY);
else if(color == green)
SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), green | FOREGROUND_INTENSITY);
//and son
}
Maybe I didn't ask my question properly..
it's not just about the color.... i want to put a "." (not the
textual dot, but a pixel or it's equivalent) at a point (x,y) on the
screen of a certain color...
in QB, it is
PSET (X,Y), COLOR
(where x, y and color are integers)
i was looking for a similar function in C/C++... without
using OpenGL, Allegro.
Well, I'm not sure if you're going to find every character you want to display on the screen, but this place has a list of ever single ASCII character that can be displayed on the screen using console. If you can't find it there, then you are going to have to venture into learning an API.
>Well, I'm not sure if you're going to find every character you want to display on the screen,
I'm not trying to show ascii characters on the screen..
i want to draw pictures pixel by pixel... you know what i mean?
so if i want to draw a 10 by 10 pixel picture... i keep telling
the location of each pixel and the color of it....
for example, let's say 0 is black and 1 is white..
0 0 1 0 0
0 1 1 1 0
1 1 1 1 1
will give a white triangle
(this way, i can draw jet planes, etc very easily)
so i want to draw each pixel seperately... i am looking for such
a function.
does it make sense ?
Yes, I understand what you are trying to say but there is no such function unless you use an API. C/C++ doesn't offer a built in graphics library so for doing that you are going to have to use an API. I personally recommend Allegro.
However, there might be an ASCII character that is similiar to a basic pixel that it will give the same effect. There are quite a few characters; you should take a look at them to see if any of them fir the bill.
yes, i can use the ascii characters but that way, i dont get the
resolution i want. I can't keep two ascii characters as close as
two pixels.
I don't know how to use API and i don't want to learn it right
now for this small thing that i want to do (too lazy.... and
college's gonna start next week anyway)
But in BGIDEMO file that i've seen sometime ago, i think this
was done (i dont have that file right now)
Think of C as just the barebones, just the rules, an API is what you apply the rules to. You don't make great programs with just C, you use an API like Win32 or Directx. It is sort of like english class. You learn all these rules, 'syntax', you don't use actual words. You say if a verb is here, a pronoun must be here. That is like C, but an API or a library is like actual words. Ehh, it makes sense to me :)
When you are ready to learn an API, many people here will suggest Allegro, however I personally like DirectX much better; I've started working with it, and I just [i]love it[i]...
just a thought