Ejemplo n.º 1
0
static void free_texgen_data( struct tnl_pipeline_stage *stage )

{
   struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);

   if (store) {
	 if (store->texcoord.data)
	    _mesa_vector4f_free( &store->texcoord );


      if (store->tmp_f) FREE( store->tmp_f );
      if (store->tmp_m) FREE( store->tmp_m );
      FREE( store );
      stage->privatePtr = NULL;
   }
}
Ejemplo n.º 2
0
static void free_texgen_data( struct tnl_pipeline_stage *stage )

{
   struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
   GLuint i;

   if (store) {
      for (i = 0 ; i < MAX_TEXTURE_COORD_UNITS ; i++)
	 if (store->texcoord[i].data)
	    _mesa_vector4f_free( &store->texcoord[i] );


      free( store->tmp_f );
      free( store->tmp_m );
      free( store );
      stage->privatePtr = NULL;
   }
}
Ejemplo n.º 3
0
/* Called the first time stage->run() is invoked.
 */
static GLboolean alloc_texgen_data( struct gl_context *ctx,
				    struct tnl_pipeline_stage *stage )
{
   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
   struct texgen_stage_data *store;

   stage->privatePtr = CALLOC(sizeof(*store));
   store = TEXGEN_STAGE_DATA(stage);
   if (!store)
      return GL_FALSE;

   _mesa_vector4f_alloc( &store->texcoord, 0, VB->Size, 32 );

   store->tmp_f = (GLfloat (*)[3]) MALLOC(VB->Size * sizeof(GLfloat) * 3);
   store->tmp_m = (GLfloat *) MALLOC(VB->Size * sizeof(GLfloat));

   return GL_TRUE;
}
Ejemplo n.º 4
0
static void validate_texgen_stage( struct gl_context *ctx,
				   struct tnl_pipeline_stage *stage )
{
   struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
   GLuint i;

   if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Current) 
      return;

   for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
      struct gl_fixedfunc_texture_unit *texUnit =
         &ctx->Texture.FixedFuncUnit[i];

      if (texUnit->TexGenEnabled) {
	 GLuint sz;

	 if (texUnit->TexGenEnabled & Q_BIT)
	    sz = 4;
	 else if (texUnit->TexGenEnabled & R_BIT)
	    sz = 3;
	 else if (texUnit->TexGenEnabled & T_BIT)
	    sz = 2;
	 else
	    sz = 1;

	 store->TexgenSize[i] = sz;
	 store->TexgenFunc[i] = texgen; /* general solution */

         /* look for special texgen cases */
	 if (texUnit->TexGenEnabled == (S_BIT|T_BIT|R_BIT)) {
	    if (texUnit->_GenFlags == TEXGEN_REFLECTION_MAP_NV) {
	       store->TexgenFunc[i] = texgen_reflection_map_nv;
	    }
	    else if (texUnit->_GenFlags == TEXGEN_NORMAL_MAP_NV) {
	       store->TexgenFunc[i] = texgen_normal_map_nv;
	    }
	 }
	 else if (texUnit->TexGenEnabled == (S_BIT|T_BIT) &&
		  texUnit->_GenFlags == TEXGEN_SPHERE_MAP) {
	    store->TexgenFunc[i] = texgen_sphere_map;
	 }
      }
   }
}
Ejemplo n.º 5
0
static void validate_texgen_stage( struct gl_context *ctx,
				   struct tnl_pipeline_stage *stage )
{
   struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);

   if (!ctx->Texture._TexGenEnabled) 
      return;

   {
      struct gl_texture_unit *texUnit = &ctx->Texture.Unit;

      if (texUnit->TexGenEnabled) {
         GLuint sz;

      if (texUnit->TexGenEnabled & Q_BIT)
	     sz = 4;
	  else if (texUnit->TexGenEnabled & R_BIT)
	     sz = 3;
      else if (texUnit->TexGenEnabled & T_BIT)
         sz = 2;
      else
         sz = 1;

      store->TexgenSize = sz;
      store->TexgenFunc = texgen; /* general solution */

      /* look for special texgen cases */
      if (texUnit->TexGenEnabled == (S_BIT|T_BIT|R_BIT)) {
         if (texUnit->_GenFlags == TEXGEN_REFLECTION_MAP_NV) {
            store->TexgenFunc = texgen_reflection_map_nv;
         }
         else if (texUnit->_GenFlags == TEXGEN_NORMAL_MAP_NV) {
            store->TexgenFunc = texgen_normal_map_nv;
         }
      }
	 else if (texUnit->TexGenEnabled == (S_BIT|T_BIT) &&
		  texUnit->_GenFlags == TEXGEN_SPHERE_MAP) {
	    store->TexgenFunc = texgen_sphere_map;
	 }
      }
   }
}
Ejemplo n.º 6
0
/* Called the first time stage->run() is invoked.
 */
static GLboolean alloc_texgen_data( struct gl_context *ctx,
				    struct tnl_pipeline_stage *stage )
{
   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
   struct texgen_stage_data *store;
   GLuint i;

   stage->privatePtr = calloc(1, sizeof(*store));
   store = TEXGEN_STAGE_DATA(stage);
   if (!store)
      return GL_FALSE;

   for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
      _mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 );

   store->tmp_f = malloc(VB->Size * sizeof(GLfloat) * 3);
   store->tmp_m = malloc(VB->Size * sizeof(GLfloat));

   return GL_TRUE;
}
Ejemplo n.º 7
0
static GLboolean run_texgen_stage( struct gl_context *ctx,
				   struct tnl_pipeline_stage *stage )
{
   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
   struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);

   if (!ctx->Texture._TexGenEnabled) 
      return GL_TRUE;

   {
      struct gl_texture_unit *texUnit = &ctx->Texture.Unit;

      if (texUnit->TexGenEnabled) {

         store->TexgenFunc( ctx, store);

         VB->AttribPtr[VERT_ATTRIB_TEX] = &store->texcoord;
      }
   }

   return GL_TRUE;
}
Ejemplo n.º 8
0
static GLboolean run_texgen_stage( struct gl_context *ctx,
				   struct tnl_pipeline_stage *stage )
{
   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
   struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
   GLuint i;

   if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Current) 
      return GL_TRUE;

   for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
      struct gl_fixedfunc_texture_unit *texUnit =
         &ctx->Texture.FixedFuncUnit[i];

      if (texUnit->TexGenEnabled) {
	 store->TexgenFunc[i]( ctx, store, i );

         VB->AttribPtr[VERT_ATTRIB_TEX0 + i] = &store->texcoord[i];
      }
   }

   return GL_TRUE;
}