| 133 | |
| 134 | |
| 135 | static void |
| 136 | MakeNewTexture(struct winthread *wt) |
| 137 | { |
| 138 | #define TEX_SIZE 128 |
| 139 | static float step = 0.0; |
| 140 | GLfloat image[TEX_SIZE][TEX_SIZE][4]; |
| 141 | GLint width; |
| 142 | int i, j; |
| 143 | |
| 144 | for (j = 0; j < TEX_SIZE; j++) { |
| 145 | for (i = 0; i < TEX_SIZE; i++) { |
| 146 | float dt = 5.0 * (j - 0.5 * TEX_SIZE) / TEX_SIZE; |
| 147 | float ds = 5.0 * (i - 0.5 * TEX_SIZE) / TEX_SIZE; |
| 148 | float r = dt * dt + ds * ds + step; |
| 149 | image[j][i][0] = |
| 150 | image[j][i][1] = |
| 151 | image[j][i][2] = 0.75 + 0.25 * cos(r); |
| 152 | image[j][i][3] = 1.0; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | step += 0.5; |
| 157 | |
| 158 | glBindTexture(GL_TEXTURE_2D, TexObj); |
| 159 | |
| 160 | glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width); |
| 161 | if (width) { |
| 162 | assert(width == TEX_SIZE); |
| 163 | /* sub-tex replace */ |
| 164 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, TEX_SIZE, TEX_SIZE, |
| 165 | GL_RGBA, GL_FLOAT, image); |
| 166 | } |
| 167 | else { |
| 168 | /* create new */ |
| 169 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 170 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 171 | |
| 172 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEX_SIZE, TEX_SIZE, 0, |
| 173 | GL_RGBA, GL_FLOAT, image); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | |
| 178 | |