*/
#if STENCIL_BITS==8
typedef GLubyte GLstencil;
-# define STENCIL_MAX 0xff
#elif STENCIL_BITS==16
typedef GLushort GLstencil;
-# define STENCIL_MAX 0xffff
#else
# error "illegal number of stencil bits"
#endif
const GLstencil ref = ctx->Stencil.Ref[face];
const GLstencil wrtmask = ctx->Stencil.WriteMask[face];
const GLstencil invmask = (GLstencil) (~wrtmask);
+ const GLstencil stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1;
GLuint i;
switch (oper) {
for (i=0;i<n;i++) {
if (mask[i]) {
GLstencil s = stencil[i];
- if (s < STENCIL_MAX) {
+ if (s < stencilMax) {
stencil[i] = (GLstencil) (s+1);
}
}
if (mask[i]) {
/* VERIFY logic of adding 1 to a write-masked value */
GLstencil s = stencil[i];
- if (s < STENCIL_MAX) {
+ if (s < stencilMax) {
stencil[i] = (GLstencil) ((invmask & s) | (wrtmask & (s+1)));
}
}
{
struct gl_framebuffer *fb = ctx->DrawBuffer;
struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+ const GLstencil stencilMax = (1 << fb->Visual.stencilBits) - 1;
const GLstencil ref = ctx->Stencil.Ref[face];
const GLstencil wrtmask = ctx->Stencil.WriteMask[face];
const GLstencil invmask = (GLstencil) (~wrtmask);
for (i=0;i<n;i++) {
if (mask[i]) {
GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
- if (*sptr < STENCIL_MAX) {
+ if (*sptr < stencilMax) {
*sptr = (GLstencil) (*sptr + 1);
}
}
for (i=0;i<n;i++) {
if (mask[i]) {
GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
- if (*sptr < STENCIL_MAX) {
+ if (*sptr < stencilMax) {
*sptr = (GLstencil) ((invmask & *sptr) | (wrtmask & (*sptr+1)));
}
}