Beginner, trying to learn how to make an image.

• 10-24-2004
shishkabob
Beginner, trying to learn how to make an image.
Ok, so I'm trying to learn how to make ANYTHING in Direct X. I came across a bit of code, demonstrating how to do colors. Here it is

Code:

```struct SColor {     int r;     int g;     int b; }; SColor make_rgb( int r, int g, int b ) {     SColor ret;     ret.r = r;     ret.g = g;     ret.b = b;     return ret; }```
I don't know how structs work, so can someone please explain that, and can someone explain how this would work. Are these Functions? Sorry, I'm just a really enthusiastic beginner programmer, wanting to make a colorful circle or somthing.
• 10-24-2004
Dae
Well it is definetly not the full code to display any colors on your screen, its more just part of the explanation of how to make a color template to be reused for different combinations.

structures: http://www.cprogramming.com/tutorial/lesson7.html

//// now my senseless gabber comments that are probably incorrect, I dont like structs, grrawr

Code:

```struct SColor //start a struct {     int r; //get a color value red     int g; //get a color value for green     int b; //get a color value for blue }; //alright so its like a template that can be filled with defines outside SColor make_rgb( int r, int g, int b ) //make a function using the struct {     SColor ret; //sets to the struct to edit variables     ret.r = r; //uses 'ret' to set the 'r' in the struct up there to defined 'r'     ret.g = g; //same with 'g'     ret.b = b; //same with 'b'     return ret; // }```
I dont know much about C++, and even less about structs.. but its just .. example code on how to use basic code to set the colors to be used by direct x to draw.. this script though doesnt draw anything.. just gives you a shortcut so you can go like so:

make_rgb(10,5,9);

and have the 10 be the r, 5 be the g, and 9 be the b, so then instruct SColor you could use your direct x displaying code using those r/b/g inputs.