Anyone know how to convert this C/C++ initialiser?! { {0,0}, 0.5 }

About Monkey 2 Forums Monkey 2 Programming Help Anyone know how to convert this C/C++ initialiser?! { {0,0}, 0.5 }

Tagged: , ,

This topic contains 4 replies, has 2 voices, and was last updated by  DruggedBunny 1 month ago.

Viewing 5 posts - 1 through 5 (of 5 total)

  • Author

    Posts

  • #16031


    DruggedBunny

    Participant

    Hi all,

    Does anyone know how to translate this C/C++ array initialisation (with nested {} braces) into a loop?

    The struct is just an array of RGB values as integers, and I need to iterate through each, but I can’t tell what the init part is actually doing!

    How would I translate this to something like this?

    I’m trying to port this palette/dither code to GLSL, so can’t use this style of initialiser, and I don’t understand what the {{0,0},0.5} thing is doing in regards to an integer value!

    #16032


    Danilo

    Participant

    When I search the site for “MixingPlan” I get more than one result, and it looks like you mix them up.

    1st, 2nd, 3rd search result are in the same source code:

    More search results containing “MixingPlan” show up.

    Later there is a source code with a new MixingPlan struct:

     

    Next one:

     

    And then, at round about the middle of the page (last search result):

    #16034


    DruggedBunny

    Participant

    Ah, thanks for pointing that out… the article is a little confusing, though I think the intent is to offer different options… I’ll look into that a little more closely.

    Any idea on the initialisation part? I just don’t get this, and it’s not something easily searched-for!

    #16035


    Danilo

    Participant

    This init part is for the struct with an array of 2 unsigned and 1 double.

     

    Your struct colors[64] does not use such initialization:

     

    As you can see, ‘ = { values }; ‘ is used for init, and the inner ‘{ values }’ is for array init.

     

    See also: cppreference.com >> C reference >> initialization >> array initialization

    Initialization from brace-enclosed lists

    Nested arrays

    #16036


    DruggedBunny

    Participant

    Oh, I see now! Thanks for that, Danilo, really appreciate it!

    Hopefully I can get this converted today… thanks again.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.