1
我已經運行了一些屏幕保護程序的開放源代碼,並且想要了解如何修改Color Verticies的顏色陣列以產生色調而不是GREEN10噸在OpenGL中更改顏色陣列以產生紅色色調
下面是筆者用來設置綠色代碼:
// Compute the new state of the color vertices
- (void) computeColorVertices
{
int i,maxi,c;
GLfloat g, gstep, cursorglow;
c = 0; // To suppress spurious warning
gstep = stripParams.colorCycleSpeed;
// First, run down the strip cycling colors to bright then back to dark
g = startColor;
maxi = cursorDrawing ? cursorPos : stripSize;
for (i=0; i < maxi; i++) {
for (c = 0; c < 4; c++) {
// Some shade of green if cell is not empty
colorArray[16*i + 4*c + 1] = (cellState[i] == 0) ? 0.0 : g;
// Cells which are very bright are slightly 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 is 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 the start color used above, to make the colors appear to fall
startColor -= stripParams.colorFallSpeed;
if (startColor < 0.2) {
startColor = 1.0;
}
// If the cursor's drawing, work up from its position making sure the cells aren't too dark
if (cursorDrawing) {
maxi = cursorPos - 1;
cursorglow = 0.8;
for (i = maxi; i >= 0 && cursorglow > 0.2; i--) {
// If there's some cursor-imparted glow left, use it
if (colorArray[16*i + 4*c + 1] < cursorglow) {
for (c = 0; c < 4; c++) {
// Some shade of green if cell is not empty
colorArray[16*i + 4*c + 1] = (cellState[i] == 0) ? 0.0 : cursorglow;
// Cells which are very bright are slightly 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 is empty, otherwise opaque
colorArray[16*i + 4*c + 3] = (cellState[i] == 0) ? 0.0 : 1.0;
}
}
cursorglow -= gstep;
}
}
}
我得到它的工作,感謝您的幫助。現在,它只是將圖形顯示爲紅色塊,而不是像它應該的字形。 –