Minor tweaks to help out at a driver level.
[mesa.git] / src / mesa / main / api_arrayelt.c
index acca5701a5332a00b1623ba7f150a35bc1632777..aefeadf228a16dde9b3ea7e9e6e0097aaa23f521 100644 (file)
@@ -1,10 +1,8 @@
-/* $Id: api_arrayelt.c,v 1.8 2002/04/19 00:23:08 brianp Exp $ */
-
 /*
  * Mesa 3-D graphics library
- * Version:  4.1
+ * Version:  5.1
  *
- * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  */
 
 /* Author:
- *    Keith Whitwell <keith_whitwell@yahoo.com>
+ *    Keith Whitwell <keith@tungstengraphics.com>
  */
 
 #include "glheader.h"
 #include "api_arrayelt.h"
 #include "context.h"
 #include "glapi.h"
-#include "mem.h"
+#include "imports.h"
 #include "macros.h"
 #include "mtypes.h"
 
@@ -53,7 +51,7 @@ typedef struct {
 } AEarray;
 
 typedef struct {
-   AEtexarray texarrays[MAX_TEXTURE_UNITS+1];
+   AEtexarray texarrays[MAX_TEXTURE_COORD_UNITS + 1];
    AEarray arrays[32];
    GLuint NewState;
 } AEcontext;
@@ -252,6 +250,9 @@ static void (*fogcoordfuncs[8])( const void * ) = {
 
 GLboolean _ae_create_context( GLcontext *ctx )
 {
+   if (ctx->aelt_context)
+      return GL_TRUE;
+
    ctx->aelt_context = MALLOC( sizeof(AEcontext) );
    if (!ctx->aelt_context)
       return GL_FALSE;
@@ -277,7 +278,7 @@ static void _ae_update_state( GLcontext *ctx )
    AEarray *aa = actx->arrays;
    GLuint i;
 
-   for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
+   for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
       if (ctx->Array.TexCoord[i].Enabled) {
         ta->unit = i;
         ta->array = &ctx->Array.TexCoord[i];
@@ -336,7 +337,7 @@ static void _ae_update_state( GLcontext *ctx )
 }
 
 
-void _ae_loopback_array_elt( GLint elt )
+void GLAPIENTRY _ae_loopback_array_elt( GLint elt )
 {
    GET_CURRENT_CONTEXT(ctx);
    AEcontext *actx = AE_CONTEXT(ctx);
@@ -347,13 +348,19 @@ void _ae_loopback_array_elt( GLint elt )
       _ae_update_state( ctx );
 
    for (ta = actx->texarrays ; ta->func ; ta++) {
-      ta->func( ta->unit, (char *)ta->array->Ptr + elt * ta->array->StrideB );
+      GLubyte *src = ta->array->BufferObj->Data
+                   + (GLuint) ta->array->Ptr
+                   + elt * ta->array->StrideB;
+      ta->func( ta->unit + GL_TEXTURE0_ARB, src);
    }
 
    /* Must be last
     */
    for (aa = actx->arrays ; aa->func ; aa++) {
-      aa->func( (char *)aa->array->Ptr + elt * aa->array->StrideB );
+      GLubyte *src = aa->array->BufferObj->Data
+                   + (GLuint) aa->array->Ptr
+                   + elt * aa->array->StrideB;
+      aa->func( src );
    }
 }