emscripten-core / emscripten-core/emscripten

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

Open
#13,011 1 comment 0 reactions 0 assignees View on GitHub
wontfix
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

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](https://github.com/emscripten-core/emscripten/files/5678030/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" );
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.