Clear To Colour

This is a discussion on Clear To Colour within the Game Programming forums, part of the General Programming Boards category; trying to write code to clear the screen to an arbitrary colour, pretty basic stuff i know but im a ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    13

    Clear To Colour

    trying to write code to clear the screen to an arbitrary colour, pretty basic stuff i know but im a bit rusty and could do with some assistance, could possibly use a DWORD if thats any help.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Clear screen for what mode, OS, environment, etc?

    Console? Win32 API? DOS? DirectX? OpenGL?

  3. #3
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    287
    for the random can use something like:
    Code:
    srand((unsigned)time(0));
    int rd,gd,bd;
    char rh[3],gh[3],bh[3];
    rd=rand()%255;
    gd=rand()%255;
    bd=rand()%255;
    sprintf(rh,"%x",rd);if(strlen(rh)<2) {sprintf(rh,"0%s",rh);}
    sprintf(gh,"%x",gd);if(strlen(gh)<2) {sprintf(gh,"0%s",gh);}
    sprintf(bh,"%x",bd);if(strlen(bh)<2) {sprintf(bh,"0%s",bh);}
    printf("RGB(d):%d %d %d\n",rd,gd,bd);
    printf("RGB(h):%s %s %s\n",rh,gh,bh);
    but before attend to bubba's observation
    Niara

  4. #4
    Registered User
    Join Date
    Nov 2005
    Posts
    13
    Quote Originally Posted by Bubba
    Clear screen for what mode, OS, environment, etc?

    Console? Win32 API? DOS? DirectX? OpenGL?
    woops sorry!

    its win32 using visual studio 2003.

    the object being to 'create a functionality that will clear the screen to an arbitrary colour'

  5. #5
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    Create a window. Make it fullscreen. Set the background color to your color of choice.

    This is a very generic and unhelpful answer because it's a very generic und vague question. Post a specific question and I'm pretty sure you will get helpful answers.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  6. #6
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    Quote Originally Posted by mindofpoison
    woops sorry!

    its win32 using visual studio 2003.

    the object being to 'create a functionality that will clear the screen to an arbitrary colour'
    You left out the most important part, the API. You doing it with OpenGL, DirectX, SDL, or some other library?

  7. #7
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Read Eber's post. We can't help you yet. More info.

  8. #8
    Registered User
    Join Date
    Nov 2005
    Posts
    13
    Quote Originally Posted by Bubba
    Read Eber's post. We can't help you yet. More info.
    The requirements for this milestone are to create functionality that:

    - Allows the screen to be cleared to an arbitrary colour
    - Allows a pixel on the screen to be set to an arbitrary colour
    - Runs at a decent frame rate

    As with all milestones the code should be bug free, well commented, maintainable and contain error checking .

    In order to test that the milestone requirements have been met you need to show:

    - Clearing the screen to a colour
    - Drawing a star filled background

    using:
    -win32 program
    -c++ code
    -visual studio 2003
    -the API is HAPI

  9. #9
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Ok now this sounds like homework.

    How bout some 16-bit asm:

    Code:
    ...
    les   di,0b800h
    mov  ax,80
    mob  bx,25
    mul   ax,bc
    mov  cx,ax
    xor   ax,ax
    mov ah,color
    rep  stosw
    and  cx,03h
    rep  stosb
    No that probably won't help you. But we don't help with homework.
    Last edited by VirtualAce; 11-10-2005 at 01:16 PM.

  10. #10
    ---
    Join Date
    May 2004
    Posts
    1,379
    If it is homework then you should have been taught how to do it. Your project is in fact quite simple. Go read an intro tutorial for DX or OpenGL.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-24-2006, 07:36 PM
  2. Replies: 5
    Last Post: 03-01-2003, 03:52 PM
  3. DirectDraw colour matching
    By Hunter2 in forum Game Programming
    Replies: 2
    Last Post: 12-10-2002, 01:17 PM
  4. Using a button to clear a list box!
    By Unregistered in forum C++ Programming
    Replies: 13
    Last Post: 08-23-2002, 07:44 PM
  5. Colour theory... (weird title)
    By Magos in forum C++ Programming
    Replies: 5
    Last Post: 11-25-2001, 03:16 PM

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