PSET eqvt. in C/C++ ?

This is a discussion on PSET eqvt. in C/C++ ? within the Game Programming forums, part of the General Programming Boards category; Is there a PSET command equivalent in C/C++ ? i.e. In QBasic : PSET (X,Y), COLOR (to plot a pixel ...

  1. #1
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    PSET eqvt. in C/C++ ?

    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++ ?

  2. #2
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    This will be able to help you...

  3. #3
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    no,

    you'll need to use a library(OpenGL, Direct-X, Allegro, SDL, ect...) or ASM or something similar.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  4. #4
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    no...
    Sorry I thought he/she was referring to changing the color of text in console.

    If so then I'll just give the *** **** info.

    Code:
    SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), 6 | FOREGROUND_INTENSITY);
    Change the number 6 to a different number to get a different color. Get rid of | FOREGROUND_INTENSITY to make the colors less bright.

  5. #5
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    err...

    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 ?

  6. #6
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    Personally this seems pretty easy to me...

    Code:
    SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), 6 | FOREGROUND_INTENSITY);
    what you can do, though, is this...

    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
     }
    That's one way to neatly organize the color settings.

  7. #7
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    hmm...

    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.

  8. #8
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    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.

  9. #9
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    hmm..

    >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 ?

  10. #10
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    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.

  11. #11
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    hmm...

    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)

  12. #12
    Registered User JoshG's Avatar
    Join Date
    Mar 2002
    Posts
    326
    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

  13. #13
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    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

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21