@@ -62,6 +62,13 @@ static void updateFloatTexture() {
6262 }
6363 glBindTexture (GL_TEXTURE_2D, nodeTexture);
6464 glTexImage2D (GL_TEXTURE_2D, 0 , GL_RGBA32F, nbNodes, 1 , 0 , GL_RGBA, GL_FLOAT, data);
65+ #ifdef __EMSCRIPTEN__ // In GLES2 and WebGL1, we must use unsized texture internal formats.
66+ const GLenum internalFormat = GL_RGBA;
67+ #else
68+ // In desktop GL, we can also use sized internal formats.
69+ const GLenum internalFormat = GL_RGBA32F;
70+ #endif
71+ glTexImage2D (GL_TEXTURE_2D, 0 , internalFormat, nbNodes, 1 , 0 , GL_RGBA, GL_FLOAT, data);
6572 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
6673 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
6774 glBindTexture (GL_TEXTURE_2D, NULL );
@@ -122,9 +129,11 @@ static void gl_init(void) {
122129 /* Get the locations of the uniforms so we can access them */
123130 nodeSamplerLocation = glGetUniformLocation (program, " nodeInfo" );
124131 glBindAttribLocation (program, 0 , " indices" );
132+ #ifndef __EMSCRIPTEN__ // GLES2 & WebGL do not have these, only pre 3.0 desktop GL and compatibility mode GL3.0+ GL do.
125133 // Enable glPoint size in shader, always enable in Open Gl ES 2.
126134 glEnable (GL_VERTEX_PROGRAM_POINT_SIZE);
127135 glEnable (GL_POINT_SPRITE);
136+ #endif
128137}
129138int main (int argc, char *argv[]) {
130139 glutInit (&argc, argv);
0 commit comments