The first 16 component types are now reserved for the library. This
leaves room for adding standard generic attributes, such as TBN vectors.
To make further room, texcoords were limited to four indices.
Generic attributes are limited to 24. Current implementations seem to
only support 16 (the minimum allowed by the spec), so this is not a huge
problem. There's also exactly enough room for another set of 24 generic
integer attributes.
bool has_gen_attrs = false;
for(const unsigned char *c=format.begin(); c!=format.end(); ++c)
{
bool has_gen_attrs = false;
for(const unsigned char *c=format.begin(); c!=format.end(); ++c)
{
- if(*c>=TEXCOORD1+4 && *c<ATTRIB1)
+ if(*c>=TEXCOORD1+4 && *c<=TEXCOORD4+12)
has_multitex = true;
if(*c>=ATTRIB1)
has_gen_attrs = true;
has_multitex = true;
if(*c>=ATTRIB1)
has_gen_attrs = true;
if(!en)
glEnableClientState(GL_COLOR_ARRAY);
}
if(!en)
glEnableClientState(GL_COLOR_ARRAY);
}
- else if(*c>=TEXCOORD1 && *c<=TEXCOORD4+28)
+ else if(*c>=TEXCOORD1 && *c<=TEXCOORD4+12)
{
t -= get_component_type(TEXCOORD1);
if(t>0 || active_tex)
{
t -= get_component_type(TEXCOORD1);
if(t>0 || active_tex)
- t -= get_component_type(ATTRIB1);
+ if(t>=get_component_type(ATTRIB1))
+ t -= get_component_type(ATTRIB1);
glVertexAttribPointer(t, sz, GL_FLOAT, false, bpv, base+offset);
if(!en)
glEnableVertexAttribArray(t);
glVertexAttribPointer(t, sz, GL_FLOAT, false, bpv, base+offset);
if(!en)
glEnableVertexAttribArray(t);
glDisableClientState(GL_NORMAL_ARRAY);
else if(i==get_component_type(COLOR4_FLOAT))
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
else if(i==get_component_type(COLOR4_FLOAT))
glDisableClientState(GL_COLOR_ARRAY);
- else if(i>=get_component_type(TEXCOORD1) && i<=get_component_type(TEXCOORD1)+7)
+ else if(i>=get_component_type(TEXCOORD1) && i<=get_component_type(TEXCOORD1)+3)
{
unsigned j = i-get_component_type(TEXCOORD1);
if(j>0 || active_tex)
{
unsigned j = i-get_component_type(TEXCOORD1);
if(j>0 || active_tex)
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
active_tex = j;
}
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
active_tex = j;
}
+ else if(i<get_component_type(ATTRIB1))
+ glDisableVertexAttribArray(i);
else
glDisableVertexAttribArray(i-get_component_type(ATTRIB1));
}
else
glDisableVertexAttribArray(i-get_component_type(ATTRIB1));
}
const Vector4 *v = 0;
if(t==get_component_type(VERTEX3))
v = &ver;
const Vector4 *v = 0;
if(t==get_component_type(VERTEX3))
v = &ver;
- else if(*c>=TEXCOORD1 && *c<=TEXCOORD4+28)
+ else if(*c>=TEXCOORD1 && *c<=TEXCOORD4+12)
v = &texc[t-get_component_type(TEXCOORD1)];
else if(*c>=ATTRIB1)
v = &attr[t-get_component_type(ATTRIB1)];
v = &texc[t-get_component_type(TEXCOORD1)];
else if(*c>=ATTRIB1)
v = &attr[t-get_component_type(ATTRIB1)];
*ptr++ = v->x;
if(sz>=2) *ptr++ = v->y;
if(sz>=3) *ptr++ = v->z;
*ptr++ = v->x;
if(sz>=2) *ptr++ = v->y;
if(sz>=3) *ptr++ = v->z;
}
else if(comp>=ATTRIB1 && comp<=ATTRIB4)
{
}
else if(comp>=ATTRIB1 && comp<=ATTRIB4)
{
throw out_of_range("make_indexed_component");
}
else
throw out_of_range("make_indexed_component");
}
else
namespace Msp {
namespace GL {
namespace Msp {
namespace GL {
+/** A single vertex component. Nvidia drivers have aliasing between the
+fixed-functions and generic vertex attributes, despite the standard not
+allowing it. We use the same attribute indices here to avoid problems. */
enum VertexComponent
{
VERTEX2 = 1,
VERTEX3,
VERTEX4,
enum VertexComponent
{
VERTEX2 = 1,
VERTEX3,
VERTEX4,
- NORMAL3 = 6,
- COLOR4_UBYTE = 8,
- COLOR3_FLOAT = 10,
+ NORMAL3 = 10,
+ COLOR4_UBYTE = 12,
+ COLOR3_FLOAT = 14,
TEXCOORD2,
TEXCOORD3,
TEXCOORD4,
TEXCOORD2,
TEXCOORD3,
TEXCOORD4,
ATTRIB2,
ATTRIB3,
ATTRIB4
ATTRIB2,
ATTRIB3,
ATTRIB4