@@ -62,6 +62,13 @@ static void updateFloatTexture() {
62
62
}
63
63
glBindTexture (GL_TEXTURE_2D, nodeTexture);
64
64
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);
65
72
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
66
73
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
67
74
glBindTexture (GL_TEXTURE_2D, NULL );
@@ -122,9 +129,11 @@ static void gl_init(void) {
122
129
/* Get the locations of the uniforms so we can access them */
123
130
nodeSamplerLocation = glGetUniformLocation (program, " nodeInfo" );
124
131
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.
125
133
// Enable glPoint size in shader, always enable in Open Gl ES 2.
126
134
glEnable (GL_VERTEX_PROGRAM_POINT_SIZE);
127
135
glEnable (GL_POINT_SPRITE);
136
+ #endif
128
137
}
129
138
int main (int argc, char *argv[]) {
130
139
glutInit (&argc, argv);
0 commit comments