| 65 | double alpha = 0; // use to make a simple funny effect; |
| 66 | |
| 67 | static void updateFloatTexture() { |
| 68 | int count = 0; |
| 69 | for (float x=0; x < NUM_NODES; ++x ) { |
| 70 | data[count].x = 0.2*pow(cos(alpha), 3) + (sin(alpha)*3. + 3.5) * x/NUM_NODES * cos(alpha + x/NUM_NODES * 16. * M_PI); |
| 71 | data[count].y = 0.2*pow(sin(alpha), 3) + (sin(alpha)*3. + 3.5) * x/NUM_NODES * sin(alpha + x/NUM_NODES * 16. * M_PI); |
| 72 | data[count].s = (16. + 16. * cos(alpha + x/NUM_NODES * 32. * M_PI)) + 8.;// * fmod(x/NUM_NODES + alpha, 1.) + 5.; |
| 73 | data[count].c = 0.5 + 0.5 * sin(alpha + x/NUM_NODES * 32. * M_PI); |
| 74 | ++count; |
| 75 | } |
| 76 | glBindTexture(GL_TEXTURE_2D, nodeTexture); |
| 77 | #ifdef __EMSCRIPTEN__ // In GLES2 and WebGL1, we must use unsized texture internal formats. |
| 78 | const GLenum internalFormat = GL_RGBA; |
| 79 | #else |
| 80 | // In desktop GL, we can also use sized internal formats. |
| 81 | const GLenum internalFormat = GL_RGBA32F; |
| 82 | #endif |
| 83 | glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, NUM_NODES, 1, 0, GL_RGBA, GL_FLOAT, data); |
| 84 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 85 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 86 | glBindTexture(GL_TEXTURE_2D, 0); |
| 87 | alpha -= 0.001; |
| 88 | } |
| 89 | |
| 90 | static void glut_draw_callback(void) { |
| 91 | glDisable(GL_CULL_FACE); |
no test coverage detected