objective c - Changing Color array to produce Red Tint in OpenGL -


i have run across open source code screensaver , understand how modify color array of color verticies produce red tint instead of green tent

here code author uses set green color:

 // compute new state of color vertices - (void) computecolorvertices {    int i,maxi,c;    glfloat g, gstep, cursorglow;     c = 0; // suppress spurious warning    gstep = stripparams.colorcyclespeed;    // first, run down strip cycling colors bright dark    g = startcolor;    maxi = cursordrawing ? cursorpos : stripsize;    (i=0; < maxi; i++) {       (c = 0; c < 4; c++) {          // shade of green if cell not empty          colorarray[16*i + 4*c + 1] = (cellstate[i] == 0) ? 0.0 : g;          // cells bright whitened          colorarray[16*i + 4*c + 0] = ((g > 0.7) && (cellstate[i] != 0)) ? (g - 0.6) : 0.0;          colorarray[16*i + 4*c + 2] = ((g > 0.7) && (cellstate[i] != 0)) ? (g - 0.6) : 0.0;          // transparent if cell empty, otherwise opaque          colorarray[16*i + 4*c + 3] = (cellstate[i] == 0) ? 0.0 : 1.0;       }       g += gstep;       if (g > 1.0) {          g = 0.2;       }    }    // cycle start color used above, make colors appear fall    startcolor -= stripparams.colorfallspeed;    if (startcolor < 0.2) {       startcolor = 1.0;    }     // if cursor's drawing, work position making sure cells aren't dark    if (cursordrawing) {       maxi = cursorpos - 1;       cursorglow = 0.8;       (i = maxi; >= 0 && cursorglow > 0.2; i--) {       // if there's cursor-imparted glow left, use          if (colorarray[16*i + 4*c + 1] < cursorglow) {             (c = 0; c < 4; c++) {                // shade of green if cell not empty                colorarray[16*i + 4*c + 1] = (cellstate[i] == 0) ? 0.0 : cursorglow;                // cells bright whitened                colorarray[16*i + 4*c + 0] = ((cursorglow > 0.7) && (cellstate[i] != 0)) ? (cursorglow - 0.6) : 0.0;                colorarray[16*i + 4*c + 2] = ((cursorglow > 0.7) && (cellstate[i] != 0)) ? (cursorglow - 0.6) : 0.0;                // transparent if cell empty, otherwise opaque                colorarray[16*i + 4*c + 3] = (cellstate[i] == 0) ? 0.0 : 1.0;             }          }          cursorglow -= gstep;       }    } } 

from code seems that:

colorarray[... + 1] = green colorarray[... + 0] = red colorarray[... + 2] = blue colorarray[... + 3] = alpha 

(since ... part multiple of 4)

so should able change red swapping colorarray[... + 1] , colorarray[... + 0] everywhere. changing variable name g r helpful future sanity.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -