[Mesa-dev] [PATCH] mesa: check glBegin()/glDrawArrays()/etc mode with _mesa_valid_prim_mode()

Brian Paul brian.e.paul at gmail.com
Tue Sep 20 19:30:07 PDT 2011


On Tue, Sep 20, 2011 at 7:54 PM, Yuanhan Liu
<yuanhan.liu at linux.intel.com> wrote:
> On Tue, Sep 20, 2011 at 08:51:45AM -0600, Brian Paul wrote:
>> From: Brian Paul <brianp at vmware.com>
>>
>> We now raise an GL_INVALID_ENUM in glBegin() if mode is illegal, as was
>> done in Yuanhan Liu's original patch.
>>
>> Take geometry shaders support into account too.

>> +
>>  /**
>>   * Called via glBegin.
>>   */
>> @@ -563,6 +565,11 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode )
>>        struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
>>        int i;
>>
>> +      if (!_mesa_valid_prim_mode(ctx, mode)) {
>> +         _mesa_error(ctx, GL_INVALID_ENUM, "glBegin");
>> +         return;
>> +      }
>> +
>
> Sorry, shouldn't we add the mode validation after the if(ctx->NewState)
> code block to make sure the previous states are updated?

It really doesn't matter.  If there's dirty state it'll get checked in
the next GL call.
We typically put the error checking code before everything else in the
GL functions.

-Brian


More information about the mesa-dev mailing list