# HELP - Clear to Colour

This topic is 4485 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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 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 - http://scm-intranet.tees.ac.uk/users/u0018197/html/hapi.html the above 'milestone' is part of a practical in one module of my uni course. im a little rusty at programming, and have zilch experience in using vis studio2003. therefore after missing a few classes i'm drawing on all resources to dig me out of a hole before it gets too deep. (this is 1of3 milestones i have to do) any help would be appreciated as regards to the correct code/functions. i believe rand() is the best option for the starry background, however i could be wrong. [Edited by - Borderfox on November 10, 2005 11:33:17 AM]

##### Share on other sites

1) it is not a question. What are we supposed to do?
2) it look like homework, and it is not for you if we do your homework :)
3) the link doesn't work (and you must use html to specify link: this forum is not bbcode-powered)

Please correct me if I'm wrong.

Regards,

##### Share on other sites
Quote:
 Original post by Emmanuel DelogetI have some concerns about your "question"1) it is not a question. What are we supposed to do?2) it look like homework, and it is not for you if we do your homework :)3) the link doesn't work (and you must use html to specify link: this forum is not bbcode-powered)Please correct me if I'm wrong. Regards,

apologies my friend, you are quite right.
i have now amended my previous post.

its a practical that i must complete as part of my course, we're set milestones bi-weekly. im falling behind so could do with a little help from the pro's on forums such as this.

##### Share on other sites
Link still doesn't work, but moving on...

So what exactly have you got done so far? It seems like a pretty straight forward assignment, so you should be able to ace this bad boy with a little work [wink]

I would start with clearing the screen. With most API's that can be done with one function call. ie. ClearScreen(red, green, blue);

From there you write a function that changes a pixels color. You would probably write a function that looks like this:
void setPixel(int xPos, int yPos, int red, int green, int blue);

Then as you said, use rand to randomly create a star field:
ClearScreen(black);for(int i = 0; i < NUM_STARS; i++){    int x = rand() % SCREEN_WIDTH;    int y = rand() % SCREEN_HEIGHT;    // call your pixel function    setPixel(x, y, white);}

Hope that helps! But basically, you'll find people here are much more helpful when you come with an actual problem. Take a crack at the assignment, and when you hit a road block, then come ask for help.

Good luck!
Matt

##### Share on other sites
Quote:
 Original post by matthughsonI would start with clearing the screen. With most API's that can be done with one function call. ie. ClearScreen(red, green, blue);From there you write a function that changes a pixels color. You would probably write a function that looks like this:void setPixel(int xPos, int yPos, int red, int green, int blue);Then as you said, use rand to randomly create a star field:ClearScreen(black);for(int i = 0; i < NUM_STARS; i++){ int x = rand() % SCREEN_WIDTH; int y = rand() % SCREEN_HEIGHT; // call your pixel function setPixel(x, y, white);}Hope that helps! But basically, you'll find people here are much more helpful when you come with an actual problem. Take a crack at the assignment, and when you hit a road block, then come ask for help.Good luck!Matt

understand what u mean at the end there, will try to break the problem down more.

example
after calling the clearScreen function how would i go about passing the colours (red,green,blue) into a DWORD and from there looping through the screen buffer using memcpy?

i've wrote the DWORD as below,not to sure if its correct tho. (c is colour, the numbers being the no.of bits the bytes must be shifted)

DWORD c = ( a << 24 | r << 16 | g << 8 | b );

even if that above is correct, how can i use memcpy to loop thru the buffer?

##### Share on other sites
Let's back up a bit: Forget about the graphics and review your programming basics. If this is your first milestone and you're dumbstruck, you're in deeper trouble than you're going to get yourself out of asking people on a forum to do YOUR work for you.

Saying you decided to skip a few days at work and meetings and then asking the guys across the hall to "help you catch up" will get you about two weeks into the professional world. Give me "dude just help me out" all you want, and try to rephrase the question as many different ways as you can--DO YOUR OWN HOMEWORK.