示例#1
0
void REPLICATESPU_APIENTRY replicatespu_Vertex4fv( const GLfloat * v )
{
	GET_THREAD(thread);
	if (thread->currentContext->displayListMode != GL_FALSE) {
		crDLMCompileVertex4fv(v);
	}
	if (replicate_spu.swap)
	{
		crPackVertex4fvSWAP( v );
	}
	else
	{
		crPackVertex4fv( v );
	}
	RunState();
}
示例#2
0
/*
 * Expand glArrayElement into crPackVertex/Color/Normal/etc.
 */
void
crPackExpandArrayElement(GLint index, CRClientState *c)
{
    unsigned char *p;
    unsigned int unit, attr;
    const CRVertexArrays *array = &(c->array);
    const GLboolean vpEnabled = crStateGetCurrent()->program.vpEnabled;

    /*crDebug("crPackExpandArrayElement(%i)", index);*/

    if (array->n.enabled && !(vpEnabled && array->a[VERT_ATTRIB_NORMAL].enabled))
    {
        p = array->n.p + index * array->n.stride;

#ifdef CR_ARB_vertex_buffer_object
        if (array->n.buffer && array->n.buffer->data)
        {
            p = (unsigned char *)(array->n.buffer->data) + (unsigned long)p;
        }
#endif

        switch (array->n.type)
        {
            case GL_BYTE: crPackNormal3bv((GLbyte *)p); break;
            case GL_SHORT: crPackNormal3sv((GLshort *)p); break;
            case GL_INT: crPackNormal3iv((GLint *)p); break;
            case GL_FLOAT: crPackNormal3fv((GLfloat *)p); break;
            case GL_DOUBLE: crPackNormal3dv((GLdouble *)p); break;
            default:
                crWarning("Unhandled: crPackExpandArrayElement, array->n.type 0x%x", array->n.type);
        }
    }

    if (array->c.enabled && !(vpEnabled && array->a[VERT_ATTRIB_COLOR0].enabled))
    {
        p = array->c.p + index * array->c.stride;

#ifdef CR_ARB_vertex_buffer_object
        if (array->c.buffer && array->c.buffer->data)
        {
            p = (unsigned char *)(array->c.buffer->data) + (unsigned long)p;
        }
#endif

        switch (array->c.type)
        {
            case GL_BYTE:
                switch (c->array.c.size)
                {
                    case 3: crPackColor3bv((GLbyte *)p); break;
                    case 4: crPackColor4bv((GLbyte *)p); break;
                }
                break;
            case GL_UNSIGNED_BYTE:
                switch (c->array.c.size)
                {
                    case 3: crPackColor3ubv((GLubyte *)p); break;
                    case 4: crPackColor4ubv((GLubyte *)p); break;
                }
                break;
            case GL_SHORT:
                switch (c->array.c.size)
                {
                    case 3: crPackColor3sv((GLshort *)p); break;
                    case 4: crPackColor4sv((GLshort *)p); break;
                }
                break;
            case GL_UNSIGNED_SHORT:
                switch (c->array.c.size)
                {
                    case 3: crPackColor3usv((GLushort *)p); break;
                    case 4: crPackColor4usv((GLushort *)p); break;
                }
                break;
            case GL_INT:
                switch (c->array.c.size)
                {
                    case 3: crPackColor3iv((GLint *)p); break;
                    case 4: crPackColor4iv((GLint *)p); break;
                }
                break;
            case GL_UNSIGNED_INT:
                switch (c->array.c.size)
                {
                    case 3: crPackColor3uiv((GLuint *)p); break;
                    case 4: crPackColor4uiv((GLuint *)p); break;
                }
                break;
            case GL_FLOAT:
                switch (c->array.c.size)
                {
                    case 3: crPackColor3fv((GLfloat *)p); break;
                    case 4: crPackColor4fv((GLfloat *)p); break;
                }
                break;
            case GL_DOUBLE:
                switch (c->array.c.size)
                {
                    case 3: crPackColor3dv((GLdouble *)p); break;
                    case 4: crPackColor4dv((GLdouble *)p); break;
                }
                break;
            default:
                crWarning("Unhandled: crPackExpandArrayElement, array->c.type 0x%x", array->c.type);
        }
    }

#ifdef CR_EXT_secondary_color
    if (array->s.enabled && !(vpEnabled && array->a[VERT_ATTRIB_COLOR1].enabled))
    {
        p = array->s.p + index * array->s.stride;

#ifdef CR_ARB_vertex_buffer_object
        if (array->s.buffer && array->s.buffer->data)
        {
            p = (unsigned char *)(array->s.buffer->data) + (unsigned long)p;
        }
#endif

        switch (array->s.type)
        {
            case GL_BYTE:
                crPackSecondaryColor3bvEXT((GLbyte *)p); break;
            case GL_UNSIGNED_BYTE:
                crPackSecondaryColor3ubvEXT((GLubyte *)p); break;
            case GL_SHORT:
                crPackSecondaryColor3svEXT((GLshort *)p); break;
            case GL_UNSIGNED_SHORT:
                crPackSecondaryColor3usvEXT((GLushort *)p); break;
            case GL_INT:
                crPackSecondaryColor3ivEXT((GLint *)p); break;
            case GL_UNSIGNED_INT:
                crPackSecondaryColor3uivEXT((GLuint *)p); break;
            case GL_FLOAT:
                crPackSecondaryColor3fvEXT((GLfloat *)p); break;
            case GL_DOUBLE:
                crPackSecondaryColor3dvEXT((GLdouble *)p); break;
            default:
                crWarning("Unhandled: crPackExpandArrayElement, array->s.type 0x%x", array->s.type);
        }
    }
#endif // CR_EXT_secondary_color


#ifdef CR_EXT_fog_coord
    if (array->f.enabled && !(vpEnabled && array->a[VERT_ATTRIB_FOG].enabled))
    {
        p = array->f.p + index * array->f.stride;

#ifdef CR_ARB_vertex_buffer_object
        if (array->f.buffer && array->f.buffer->data)
        {
            p = (unsigned char *)(array->f.buffer->data) + (unsigned long)p;
        }
#endif
        crPackFogCoordfEXT( *((GLfloat *) p) );
    }
#endif // CR_EXT_fog_coord

    for (unit = 0 ; unit < CR_MAX_TEXTURE_UNITS ; unit++)
    {
        if (array->t[unit].enabled && !(vpEnabled && array->a[VERT_ATTRIB_TEX0+unit].enabled))
        {
            p = array->t[unit].p + index * array->t[unit].stride;

#ifdef CR_ARB_vertex_buffer_object
            if (array->t[unit].buffer && array->t[unit].buffer->data)
            {
                p = (unsigned char *)(array->t[unit].buffer->data) + (unsigned long)p;
            }
#endif

            switch (array->t[unit].type)
            {
                case GL_SHORT:
                    switch (array->t[unit].size)
                    {
                        case 1: crPackMultiTexCoord1svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
                        case 2: crPackMultiTexCoord2svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
                        case 3: crPackMultiTexCoord3svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
                        case 4: crPackMultiTexCoord4svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
                    }
                    break;
                case GL_INT:
                    switch (array->t[unit].size)
                    {
                        case 1: crPackMultiTexCoord1ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
                        case 2: crPackMultiTexCoord2ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
                        case 3: crPackMultiTexCoord3ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
                        case 4: crPackMultiTexCoord4ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
                    }
                    break;
                case GL_FLOAT:
                    switch (array->t[unit].size)
                    {
                        case 1: crPackMultiTexCoord1fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
                        case 2: crPackMultiTexCoord2fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
                        case 3: crPackMultiTexCoord3fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
                        case 4: crPackMultiTexCoord4fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
                    }
                    break;
                case GL_DOUBLE:
                    switch (array->t[unit].size)
                    {
                        case 1: crPackMultiTexCoord1dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
                        case 2: crPackMultiTexCoord2dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
                        case 3: crPackMultiTexCoord3dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
                        case 4: crPackMultiTexCoord4dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
                    }
                    break;
                default:
                    crWarning("Unhandled: crPackExpandArrayElement, array->t[%i].type 0x%x", unit, array->t[unit].type);
            }
        }
    }

    if (array->i.enabled)
    {
        p = array->i.p + index * array->i.stride;

#ifdef CR_ARB_vertex_buffer_object
        if (array->i.buffer && array->i.buffer->data)
        {
            p = (unsigned char *)(array->i.buffer->data) + (unsigned long)p;
        }
#endif

        switch (array->i.type)
        {
            case GL_SHORT: crPackIndexsv((GLshort *)p); break;
            case GL_INT: crPackIndexiv((GLint *)p); break;
            case GL_FLOAT: crPackIndexfv((GLfloat *)p); break;
            case GL_DOUBLE: crPackIndexdv((GLdouble *)p); break;
            default:
                crWarning("Unhandled: crPackExpandArrayElement, array->i.type 0x%x", array->i.type);
        }
    }

    if (array->e.enabled)
    {
        p = array->e.p + index * array->e.stride;

#ifdef CR_ARB_vertex_buffer_object
        if (array->e.buffer && array->e.buffer->data)
        {
            p = (unsigned char *)(array->e.buffer->data) + (unsigned long)p;
        }
#endif

        crPackEdgeFlagv(p);
    }

    for (attr = 1; attr < VERT_ATTRIB_MAX; attr++)
    {
        if (array->a[attr].enabled)
        {
            crPackVertexAttrib(array, attr, index);
        }
    }

    if (array->a[VERT_ATTRIB_POS].enabled)
    {
        crPackVertexAttrib(array, VERT_ATTRIB_POS, index);
    }
    else if (array->v.enabled)
    {
        p = array->v.p + index * array->v.stride;

#ifdef CR_ARB_vertex_buffer_object
        if (array->v.buffer && array->v.buffer->data)
        {
            p = (unsigned char *)(array->v.buffer->data) + (unsigned long)p;
        }
#endif
        switch (array->v.type)
        {
            case GL_SHORT:
                switch (c->array.v.size)
                {
                    case 2: crPackVertex2sv((GLshort *)p); break;
                    case 3: crPackVertex3sv((GLshort *)p); break;
                    case 4: crPackVertex4sv((GLshort *)p); break;
                }
                break;
            case GL_INT:
                switch (c->array.v.size)
                {
                    case 2: crPackVertex2iv((GLint *)p); break;
                    case 3: crPackVertex3iv((GLint *)p); break;
                    case 4: crPackVertex4iv((GLint *)p); break;
                }
                break;
            case GL_FLOAT:
                switch (c->array.v.size)
                {
                    case 2: crPackVertex2fv((GLfloat *)p); break;
                    case 3: crPackVertex3fv((GLfloat *)p); break;
                    case 4: crPackVertex4fv((GLfloat *)p); break;
                }
                break;
            case GL_DOUBLE:
                switch (c->array.v.size)
                {
                    case 2: crPackVertex2dv((GLdouble *)p); break;
                    case 3: crPackVertex3dv((GLdouble *)p); break;
                    case 4: crPackVertex4dv((GLdouble *)p); break;
                }
                break;
            default:
                crWarning("Unhandled: crPackExpandArrayElement, array->v.type 0x%x", array->v.type);
        }
    }
}