Thread: Beginner, trying to learn how to make an image.

  1. #1
    Registered User
    Join Date
    Oct 2004

    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

    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.
    Last edited by shishkabob; 10-24-2004 at 08:29 PM.

  2. #2
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    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.


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

    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:


    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 04:17 AM
  2. Same old beginner question...
    By Sharmz in forum C Programming
    Replies: 15
    Last Post: 08-04-2008, 11:48 AM
  3. Replies: 6
    Last Post: 03-03-2005, 03:52 AM
  4. Memory Allocation in Intell Image processing liberary
    By nisar in forum Windows Programming
    Replies: 0
    Last Post: 01-12-2003, 07:29 AM