~ubuntu-branches/ubuntu/jaunty/mesa/jaunty

« back to all changes in this revision

Viewing changes to src/mesa/main/enable.c

  • Committer: Bazaar Package Importer
  • Author(s): Timo Aaltonen
  • Date: 2009-01-23 10:20:24 UTC
  • mfrom: (1.2.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20090123102024-1f3kmb3aea7wzk67
Tags: 7.3~rc3-1ubuntu1
* Merge with Debian experimental.
* Drop 102_dont_vblank.patch, since the new drm code in the kernel
  fixes the bugs that it worked around.
* Bump the build-dependency of libdrm to 2.4.4. It's the first version
  with necessary changes to build this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
201
201
   }
202
202
 
203
203
 
 
204
 
 
205
/**
 
206
 * Return pointer to current texture unit for setting/getting coordinate
 
207
 * state.
 
208
 * Note that we'll set GL_INVALID_OPERATION if the active texture unit is
 
209
 * higher than the number of supported coordinate units.  And we'll return NULL.
 
210
 */
 
211
static struct gl_texture_unit *
 
212
get_texcoord_unit(GLcontext *ctx)
 
213
{
 
214
   if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) {
 
215
      _mesa_error(ctx, GL_INVALID_OPERATION, "glEnable/Disable(texcoord unit)");
 
216
      return NULL;
 
217
   }
 
218
   else {
 
219
      return &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
 
220
   }
 
221
}
 
222
 
 
223
 
204
224
/**
205
225
 * Helper function to enable or disable a texture target.
206
226
 */
321
341
         ctx->Transform.CullVertexFlag = state;
322
342
         break;
323
343
      case GL_DEPTH_TEST:
324
 
         if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
325
 
            _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
326
 
            return;
327
 
         }
328
344
         if (ctx->Depth.Test == state)
329
345
            return;
330
346
         FLUSH_VERTICES(ctx, _NEW_DEPTH);
612
628
            return;
613
629
         }
614
630
         break;
615
 
      case GL_TEXTURE_GEN_Q: {
616
 
         GLuint unit = ctx->Texture.CurrentUnit;
617
 
         struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
618
 
         GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT;
619
 
         if (state)
620
 
            newenabled |= Q_BIT;
621
 
         if (texUnit->TexGenEnabled == newenabled)
622
 
            return;
623
 
         FLUSH_VERTICES(ctx, _NEW_TEXTURE);
624
 
         texUnit->TexGenEnabled = newenabled;
625
 
         break;
626
 
      }
627
 
      case GL_TEXTURE_GEN_R: {
628
 
         GLuint unit = ctx->Texture.CurrentUnit;
629
 
         struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
630
 
         GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT;
631
 
         if (state)
632
 
            newenabled |= R_BIT;
633
 
         if (texUnit->TexGenEnabled == newenabled)
634
 
            return;
635
 
         FLUSH_VERTICES(ctx, _NEW_TEXTURE);
636
 
         texUnit->TexGenEnabled = newenabled;
637
 
         break;
638
 
      }
639
 
      case GL_TEXTURE_GEN_S: {
640
 
         GLuint unit = ctx->Texture.CurrentUnit;
641
 
         struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
642
 
         GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT;
643
 
         if (state)
644
 
            newenabled |= S_BIT;
645
 
         if (texUnit->TexGenEnabled == newenabled)
646
 
            return;
647
 
         FLUSH_VERTICES(ctx, _NEW_TEXTURE);
648
 
         texUnit->TexGenEnabled = newenabled;
649
 
         break;
650
 
      }
651
 
      case GL_TEXTURE_GEN_T: {
652
 
         GLuint unit = ctx->Texture.CurrentUnit;
653
 
         struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
654
 
         GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT;
655
 
         if (state)
656
 
            newenabled |= T_BIT;
657
 
         if (texUnit->TexGenEnabled == newenabled)
658
 
            return;
659
 
         FLUSH_VERTICES(ctx, _NEW_TEXTURE);
660
 
         texUnit->TexGenEnabled = newenabled;
661
 
         break;
662
 
      }
 
631
      case GL_TEXTURE_GEN_Q:
 
632
         {
 
633
            struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
 
634
            if (texUnit) {
 
635
               GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT;
 
636
               if (state)
 
637
                  newenabled |= Q_BIT;
 
638
               if (texUnit->TexGenEnabled == newenabled)
 
639
                  return;
 
640
               FLUSH_VERTICES(ctx, _NEW_TEXTURE);
 
641
               texUnit->TexGenEnabled = newenabled;
 
642
            }
 
643
         }
 
644
         break;
 
645
      case GL_TEXTURE_GEN_R:
 
646
         {
 
647
            struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
 
648
            if (texUnit) {
 
649
               GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT;
 
650
               if (state)
 
651
                  newenabled |= R_BIT;
 
652
               if (texUnit->TexGenEnabled == newenabled)
 
653
                  return;
 
654
               FLUSH_VERTICES(ctx, _NEW_TEXTURE);
 
655
               texUnit->TexGenEnabled = newenabled;
 
656
            }
 
657
         }
 
658
         break;
 
659
      case GL_TEXTURE_GEN_S:
 
660
         {
 
661
            struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
 
662
            if (texUnit) {
 
663
               GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT;
 
664
               if (state)
 
665
                  newenabled |= S_BIT;
 
666
               if (texUnit->TexGenEnabled == newenabled)
 
667
                  return;
 
668
               FLUSH_VERTICES(ctx, _NEW_TEXTURE);
 
669
               texUnit->TexGenEnabled = newenabled;
 
670
            }
 
671
         }
 
672
         break;
 
673
      case GL_TEXTURE_GEN_T:
 
674
         {
 
675
            struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
 
676
            if (texUnit) {
 
677
               GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT;
 
678
               if (state)
 
679
                  newenabled |= T_BIT;
 
680
               if (texUnit->TexGenEnabled == newenabled)
 
681
                  return;
 
682
               FLUSH_VERTICES(ctx, _NEW_TEXTURE);
 
683
               texUnit->TexGenEnabled = newenabled;
 
684
            }
 
685
         }
 
686
         break;
663
687
 
664
688
      /*
665
689
       * CLIENT STATE!!!
1153
1177
         return is_texture_enabled(ctx, TEXTURE_3D_BIT);
1154
1178
      case GL_TEXTURE_GEN_Q:
1155
1179
         {
1156
 
            const struct gl_texture_unit *texUnit;
1157
 
            texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1158
 
            return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
 
1180
            const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
 
1181
            if (texUnit) {
 
1182
               return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
 
1183
            }
1159
1184
         }
 
1185
         return GL_FALSE;
1160
1186
      case GL_TEXTURE_GEN_R:
1161
1187
         {
1162
 
            const struct gl_texture_unit *texUnit;
1163
 
            texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1164
 
            return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
 
1188
            const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
 
1189
            if (texUnit) {
 
1190
               return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
 
1191
            }
1165
1192
         }
 
1193
         return GL_FALSE;
1166
1194
      case GL_TEXTURE_GEN_S:
1167
1195
         {
1168
 
            const struct gl_texture_unit *texUnit;
1169
 
            texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1170
 
            return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
 
1196
            const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
 
1197
            if (texUnit) {
 
1198
               return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
 
1199
            }
1171
1200
         }
 
1201
         return GL_FALSE;
1172
1202
      case GL_TEXTURE_GEN_T:
1173
1203
         {
1174
 
            const struct gl_texture_unit *texUnit;
1175
 
            texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1176
 
            return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
 
1204
            const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
 
1205
            if (texUnit) {
 
1206
               return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
 
1207
            }
1177
1208
         }
 
1209
         return GL_FALSE;
1178
1210
 
1179
1211
      /*
1180
1212
       * CLIENT STATE!!!