emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.75k stars 3.3k forks source link

OpenGL legacy emulation, weird WebGL error: GL_INVALID_VALUE: Index must be less than MAX_VERTEX_ATTRIBS #13011

Open GeorgRottensteiner opened 3 years ago

GeorgRottensteiner commented 3 years ago

I've whittled the issue down to a simple quad rendering. I receive a error message from WebGL stating "GL_INVALID_VALUE: Index must be less than MAX_VERTEX_ATTRIBS"

However I don't see where I'm going wrong. Find attached the sample code and build file.

This is some issue that's plagueing my porting of a bigger game where all quads run onto errors. The same code works nicely on desktop though.

gltest.zip

In the file, run gltest.html in your browser to see the problem in the console. I'm doing one glBegin/glEnd call once, and the message appears during checking the error state after glEnd.

Any help is greatly appreciated

Tested on Windows 10 with Edge Chromium.

Here's the relevant snippet:

glBegin( GL_QUADS );
  glColor4ub( (GLubyte)( ( Color1 & 0xff0000 ) >> 16 ), (GLubyte)( ( Color1 & 0x00ff00 ) >> 8 ), (GLubyte)( Color1 & 0xff ), ( Color1 & 0xff000000 ) >> 24 );
  glTexCoord2f( TU1, TV1 );
  glVertex3i( X, Y, (int)Z );

  glColor4ub( (GLubyte)( ( Color2 & 0xff0000 ) >> 16 ), (GLubyte)( ( Color2 & 0x00ff00 ) >> 8 ), (GLubyte)( Color2 & 0xff ), ( Color2 & 0xff000000 ) >> 24 );
  glTexCoord2f( TU2, TV2 );
  glVertex3i( X + Width, Y, (int)Z );
  CheckError( "RenderQuad2d 2" );

  glColor4ub( (GLubyte)( ( Color4 & 0xff0000 ) >> 16 ), (GLubyte)( ( Color4 & 0x00ff00 ) >> 8 ), (GLubyte)( Color4 & 0xff ), ( Color4 & 0xff000000 ) >> 24 );
  glTexCoord2f( TU4, TV4 );
  glVertex3i( X + Width, Y + Height, (int)Z );
  CheckError( "RenderQuad2d 3" );

  glColor4ub( (GLubyte)( ( Color3 & 0xff0000 ) >> 16 ), (GLubyte)( ( Color3 & 0x00ff00 ) >> 8 ), (GLubyte)( Color3 & 0xff ), ( Color3 & 0xff000000 ) >> 24 );
  glTexCoord2f( TU3, TV3 );
  glVertex3i( X, Y + Height, (int)Z );
  CheckError( "RenderQuad2d 4" );

  glEnd();
  CheckError( "RenderQuad2d x" );
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.