VirtualBox

Ignore:
Timestamp:
May 3, 2019 9:51:02 PM (6 years ago)
Author:
vboxsync
Message:

Additions/common/crOpengl,GuestHost/OpenGL,HostServices/SharedOpenGL: Eliminate all global variables from the state tracker library (state_tracker) in preparation of the SPU DLL merging, bugref:9435

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_stencil.c

    r69392 r78375  
    1111
    1212
    13 static GLint crStateStencilBufferGetIdxAndCount(CRStencilState *s, GLenum face, GLint *pIdx, GLint *pBitsIdx)
     13static GLint crStateStencilBufferGetIdxAndCount(PCRStateTracker pState, CRStencilState *s, GLenum face, GLint *pIdx, GLint *pBitsIdx)
    1414{
    1515    switch (face)
     
    3939            return 1;
    4040        default:
    41             crStateError(__LINE__,__FILE__,GL_INVALID_ENUM, "crStateStencilBufferGetIdxAndCount");
     41            crStateError(pState, __LINE__,__FILE__,GL_INVALID_ENUM, "crStateStencilBufferGetIdxAndCount");
    4242            return 0;
    4343    }
     
    6868{
    6969        CRStencilState *s = &ctx->stencil;
    70         CRStateBits *stateb = GetCurrentBits();
     70        CRStateBits *stateb = GetCurrentBits(ctx->pStateTracker);
    7171        CRStencilBits *sb = &(stateb->stencil);
    7272        int i;
     
    108108}
    109109
    110 static void crStateStencilFuncPerform(GLenum face, GLenum func, GLint ref, GLuint mask)
    111 {
    112     CRContext *g = GetCurrentContext();
     110static void crStateStencilFuncPerform(PCRStateTracker pState, GLenum face, GLenum func, GLint ref, GLuint mask)
     111{
     112    CRContext *g = GetCurrentContext(pState);
    113113    CRStencilState *s = &(g->stencil);
    114     CRStateBits *stateb = GetCurrentBits();
     114    CRStateBits *stateb = GetCurrentBits(pState);
    115115    CRStencilBits *sb = &(stateb->stencil);
    116116    GLint idx, bitsIdx, count, i;
     
    119119    if (g->current.inBeginEnd)
    120120    {
    121         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     121        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    122122            "glStencilFunc called in begin/end");
    123123        return;
     
    135135        func != GL_ALWAYS)
    136136    {
    137         crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
     137        crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
    138138            "glStencilFunc called with bogu func: %d", func);
    139139        return;
    140140    }
    141141
    142     count = crStateStencilBufferGetIdxAndCount(s, face, &idx, &bitsIdx);
     142    count = crStateStencilBufferGetIdxAndCount(pState, s, face, &idx, &bitsIdx);
    143143    if (count)
    144144    {
     
    153153}
    154154
    155 void STATE_APIENTRY crStateStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
     155void STATE_APIENTRY crStateStencilFuncSeparate(PCRStateTracker pState, GLenum face, GLenum func, GLint ref, GLuint mask)
    156156{
    157157    if (!face)
     
    159159        /* crStateStencilFuncPerform accepts 0 value, while glStencilFuncSeparate does not,
    160160         * filter it out here */
    161         crStateError(__LINE__,__FILE__,GL_INVALID_ENUM, "crStateStencilFuncSeparate");
     161        crStateError(pState, __LINE__,__FILE__,GL_INVALID_ENUM, "crStateStencilFuncSeparate");
    162162        return;
    163163    }
    164     crStateStencilFuncPerform(face, func, ref, mask);
    165 }
    166 
    167 void STATE_APIENTRY crStateStencilFunc(GLenum func, GLint ref, GLuint mask)
    168 {
    169     crStateStencilFuncPerform(0, func, ref, mask);
     164    crStateStencilFuncPerform(pState, face, func, ref, mask);
     165}
     166
     167void STATE_APIENTRY crStateStencilFunc(PCRStateTracker pState, GLenum func, GLint ref, GLuint mask)
     168{
     169    crStateStencilFuncPerform(pState, 0, func, ref, mask);
    170170}
    171171
     
    178178}
    179179
    180 static void crStateStencilOpPerform (GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
    181 {
    182         CRContext *g = GetCurrentContext();
     180static void crStateStencilOpPerform (PCRStateTracker pState, GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
     181{
     182        CRContext *g = GetCurrentContext(pState);
    183183        CRStencilState *s = &(g->stencil);
    184         CRStateBits *stateb = GetCurrentBits();
     184        CRStateBits *stateb = GetCurrentBits(pState);
    185185        CRStencilBits *sb = &(stateb->stencil);
    186186    GLint idx, bitsIdx, count, i;
     
    188188        if (g->current.inBeginEnd)
    189189        {
    190                 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     190                crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    191191                        "glStencilOp called in begin/end");
    192192                return;
     
    208208                break;
    209209        default:
    210                 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
     210                crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
    211211                        "glStencilOp called with bogus fail: %d", fail);
    212212                return;
     
    226226                break;
    227227        default:
    228                 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
     228                crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
    229229                        "glStencilOp called with bogus zfail: %d", zfail);
    230230                return;
     
    244244                break;
    245245        default:
    246                 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
     246                crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
    247247                        "glStencilOp called with bogus zpass: %d", zpass);
    248248                return;
    249249        }
    250250
    251     count = crStateStencilBufferGetIdxAndCount(s, face, &idx, &bitsIdx);
     251    count = crStateStencilBufferGetIdxAndCount(pState, s, face, &idx, &bitsIdx);
    252252    if (count)
    253253    {
     
    263263}
    264264
    265 void STATE_APIENTRY crStateStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
     265void STATE_APIENTRY crStateStencilOpSeparate (PCRStateTracker pState, GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
    266266{
    267267    if (!face)
     
    269269        /* crStateStencilOpPerform accepts 0 value, while glStencilOpSeparate does not,
    270270         * filter it out here */
    271         crStateError(__LINE__,__FILE__,GL_INVALID_ENUM, "crStateStencilOpSeparate");
     271        crStateError(pState, __LINE__,__FILE__,GL_INVALID_ENUM, "crStateStencilOpSeparate");
    272272        return;
    273273    }
    274     crStateStencilOpPerform (0, fail, zfail, zpass);
    275 }
    276 
    277 void STATE_APIENTRY crStateStencilOp (GLenum fail, GLenum zfail, GLenum zpass)
    278 {
    279     crStateStencilOpPerform (0, fail, zfail, zpass);
    280 }
    281 
    282 void STATE_APIENTRY crStateClearStencil (GLint c)
    283 {
    284         CRContext *g = GetCurrentContext();
     274    crStateStencilOpPerform (pState, 0, fail, zfail, zpass);
     275}
     276
     277void STATE_APIENTRY crStateStencilOp (PCRStateTracker pState, GLenum fail, GLenum zfail, GLenum zpass)
     278{
     279    crStateStencilOpPerform (pState, 0, fail, zfail, zpass);
     280}
     281
     282void STATE_APIENTRY crStateClearStencil (PCRStateTracker pState, GLint c)
     283{
     284        CRContext *g = GetCurrentContext(pState);
    285285        CRStencilState *s = &(g->stencil);
    286         CRStateBits *stateb = GetCurrentBits();
     286        CRStateBits *stateb = GetCurrentBits(pState);
    287287        CRStencilBits *sb = &(stateb->stencil);
    288288
    289289        if (g->current.inBeginEnd)
    290290        {
    291                 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     291                crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    292292                        "glClearStencil called in begin/end");
    293293                return;
     
    302302}
    303303
    304 void STATE_APIENTRY crStateStencilMask (GLuint mask)
    305 {
    306         CRContext *g = GetCurrentContext();
     304void STATE_APIENTRY crStateStencilMask (PCRStateTracker pState, GLuint mask)
     305{
     306        CRContext *g = GetCurrentContext(pState);
    307307        CRStencilState *s = &(g->stencil);
    308         CRStateBits *stateb = GetCurrentBits();
     308        CRStateBits *stateb = GetCurrentBits(pState);
    309309        CRStencilBits *sb = &(stateb->stencil);
    310310
    311311        if (g->current.inBeginEnd)
    312312        {
    313                 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     313                crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    314314                        "glStencilMask called in begin/end");
    315315                return;
     
    324324}
    325325
    326 void STATE_APIENTRY crStateActiveStencilFaceEXT (GLenum face)
    327 {
    328     CRContext *g = GetCurrentContext();
     326void STATE_APIENTRY crStateActiveStencilFaceEXT (PCRStateTracker pState, GLenum face)
     327{
     328    CRContext *g = GetCurrentContext(pState);
    329329    CRStencilState *s = &(g->stencil);
    330     CRStateBits *stateb = GetCurrentBits();
     330    CRStateBits *stateb = GetCurrentBits(pState);
    331331    CRStencilBits *sb = &(stateb->stencil);
    332332
     
    338338        break;
    339339    default:
    340         crStateError(__LINE__,__FILE__,GL_INVALID_ENUM, "crStateActiveStencilFaceEXT");
     340        crStateError(pState, __LINE__,__FILE__,GL_INVALID_ENUM, "crStateActiveStencilFaceEXT");
    341341        return;
    342342    }
     
    348348#ifdef CRSTATE_DEBUG_STENCIL_ERR
    349349#define CRSTATE_CLEARERR() do { \
    350             while (diff_api.GetError() != GL_NO_ERROR) {} \
     350            while (pState->diff_api.GetError() != GL_NO_ERROR) {} \
    351351        } while (0)
    352352
     
    355355            CRSTATE_CLEARERR(); \
    356356            _op; \
    357             while ((_glErr = diff_api.GetError()) != GL_NO_ERROR) { Assert(0);} \
     357            while ((_glErr = pState->diff_api.GetError()) != GL_NO_ERROR) { Assert(0);} \
    358358        }while (0)
    359359#else
     
    388388        CRContext *fromCtx, CRContext *toCtx)
    389389{
     390    PCRStateTracker pState = fromCtx->pStateTracker;
    390391    CRStencilState *from = &(fromCtx->stencil);
    391392    CRStencilState *to = &(toCtx->stencil);
     
    395396    GLchar frontMatch = -1, backMatch = -1, toFrontBackMatch = -1;
    396397    CRbitvalue nbitID[CR_MAX_BITARRAY];
     398
     399    CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker);
     400
    397401    for (j=0;j<CR_MAX_BITARRAY;j++)
    398402        nbitID[j] = ~bitID[j];
     
    402406    {
    403407        glAble able[2];
    404         able[0] = diff_api.Disable;
    405         able[1] = diff_api.Enable;
     408        able[0] = pState->diff_api.Disable;
     409        able[1] = pState->diff_api.Enable;
    406410        if (from->stencilTest != to->stencilTest)
    407411        {
     
    415419    {
    416420        glAble able[2];
    417         able[0] = diff_api.Disable;
    418         able[1] = diff_api.Enable;
     421        able[0] = pState->diff_api.Disable;
     422        able[1] = pState->diff_api.Enable;
    419423        if (from->stencilTwoSideEXT != to->stencilTwoSideEXT)
    420424        {
     
    429433        if (from->clearValue != to->clearValue)
    430434        {
    431             diff_api.ClearStencil (to->clearValue);
     435            pState->diff_api.ClearStencil (to->clearValue);
    432436            from->clearValue = to->clearValue;
    433437        }
     
    466470                if (activeFace == GL_BACK)
    467471                {
    468                     diff_api.ActiveStencilFaceEXT(GL_FRONT);
     472                    pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
    469473                    activeFace = GL_FRONT;
    470474                }
    471475
    472                 diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
     476                pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
    473477                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
    474478                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask);
     
    483487                if (activeFace == GL_BACK)
    484488                {
    485                     diff_api.ActiveStencilFaceEXT(GL_FRONT);
     489                    pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
    486490                    activeFace = GL_FRONT;
    487491                }
    488492
    489                 diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
     493                pState->diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
    490494                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
    491495                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask);
     
    498502                if (activeFace == GL_BACK)
    499503                {
    500                     diff_api.ActiveStencilFaceEXT(GL_FRONT);
     504                    pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
    501505                    activeFace = GL_FRONT;
    502506                }
    503507
    504                 diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
     508                pState->diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
    505509                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref,
    506510                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask);
     
    525529                    if (activeFace == GL_BACK)
    526530                    {
    527                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    528                         activeFace = GL_FRONT;
    529                     }
    530 
    531                     diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
     531                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     532                        activeFace = GL_FRONT;
     533                    }
     534
     535                    pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
    532536                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
    533537                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask);
     
    546550                    if (activeFace == GL_BACK)
    547551                    {
    548                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    549                         activeFace = GL_FRONT;
    550                     }
    551 
    552                     diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
     552                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     553                        activeFace = GL_FRONT;
     554                    }
     555
     556                    pState->diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
    553557                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
    554558                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask);
     
    564568                    if (activeFace == GL_BACK)
    565569                    {
    566                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    567                         activeFace = GL_FRONT;
    568                     }
    569 
    570                     diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
     570                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     571                        activeFace = GL_FRONT;
     572                    }
     573
     574                    pState->diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
    571575                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref,
    572576                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask);
     
    590594                    if (activeFace == GL_BACK)
    591595                    {
    592                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    593                         activeFace = GL_FRONT;
    594                     }
    595 
    596                     diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
     596                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     597                        activeFace = GL_FRONT;
     598                    }
     599
     600                    pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
    597601                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
    598602                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask);
     
    611615                    if (activeFace == GL_BACK)
    612616                    {
    613                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    614                         activeFace = GL_FRONT;
    615                     }
    616 
    617                     diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
     617                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     618                        activeFace = GL_FRONT;
     619                    }
     620
     621                    pState->diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
    618622                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
    619623                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask);
     
    629633                    if (activeFace == GL_BACK)
    630634                    {
    631                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    632                         activeFace = GL_FRONT;
    633                     }
    634 
    635                     diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
     635                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     636                        activeFace = GL_FRONT;
     637                    }
     638
     639                    pState->diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
    636640                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref,
    637641                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask);
     
    650654            if (activeFace == GL_FRONT)
    651655            {
    652                 diff_api.ActiveStencilFaceEXT(GL_BACK);
     656                pState->diff_api.ActiveStencilFaceEXT(GL_BACK);
    653657                activeFace = GL_BACK;
    654658            }
    655659
    656             diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].func,
     660            pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].func,
    657661                to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].ref,
    658662                to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].mask);
     
    697701                if (activeFace == GL_BACK)
    698702                {
    699                     diff_api.ActiveStencilFaceEXT(GL_FRONT);
     703                    pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
    700704                    activeFace = GL_FRONT;
    701705                }
    702706
    703                 diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
     707                pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
    704708                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
    705709                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass);
     
    715719                if (activeFace == GL_BACK)
    716720                {
    717                     diff_api.ActiveStencilFaceEXT(GL_FRONT);
     721                    pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
    718722                    activeFace = GL_FRONT;
    719723                }
    720724
    721                 diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
     725                pState->diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
    722726                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
    723727                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass);
     
    729733                if (activeFace == GL_BACK)
    730734                {
    731                     diff_api.ActiveStencilFaceEXT(GL_FRONT);
     735                    pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
    732736                    activeFace = GL_FRONT;
    733737                }
    734738
    735                 diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
     739                pState->diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
    736740                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail,
    737741                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass);
     
    754758                    if (activeFace == GL_BACK)
    755759                    {
    756                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    757                         activeFace = GL_FRONT;
    758                     }
    759 
    760                     diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
     760                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     761                        activeFace = GL_FRONT;
     762                    }
     763
     764                    pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
    761765                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
    762766                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass);
     
    775779                    if (activeFace == GL_BACK)
    776780                    {
    777                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    778                         activeFace = GL_FRONT;
    779                     }
    780 
    781                     diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
     781                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     782                        activeFace = GL_FRONT;
     783                    }
     784
     785                    pState->diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
    782786                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
    783787                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass);
     
    794798                    if (activeFace == GL_BACK)
    795799                    {
    796                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    797                         activeFace = GL_FRONT;
    798                     }
    799 
    800                     diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
     800                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     801                        activeFace = GL_FRONT;
     802                    }
     803
     804                    pState->diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
    801805                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail,
    802806                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass);
     
    820824                    if (activeFace == GL_BACK)
    821825                    {
    822                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    823                         activeFace = GL_FRONT;
    824                     }
    825 
    826                     diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
     826                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     827                        activeFace = GL_FRONT;
     828                    }
     829
     830                    pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
    827831                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
    828832                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass);
     
    841845                    if (activeFace == GL_BACK)
    842846                    {
    843                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    844                         activeFace = GL_FRONT;
    845                     }
    846 
    847                     diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
     847                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     848                        activeFace = GL_FRONT;
     849                    }
     850
     851                    pState->diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
    848852                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
    849853                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass);
     
    860864                    if (activeFace == GL_BACK)
    861865                    {
    862                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    863                         activeFace = GL_FRONT;
    864                     }
    865 
    866                     diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
     866                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     867                        activeFace = GL_FRONT;
     868                    }
     869
     870                    pState->diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
    867871                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail,
    868872                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass);
     
    881885            if (activeFace == GL_FRONT)
    882886            {
    883                 diff_api.ActiveStencilFaceEXT(GL_BACK);
     887                pState->diff_api.ActiveStencilFaceEXT(GL_BACK);
    884888                activeFace = GL_BACK;
    885889            }
    886890
    887             diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].fail,
     891            pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].fail,
    888892                                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthFail,
    889893                                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthPass);
     
    900904    if (activeFace != to->activeStencilFace)
    901905    {
    902         diff_api.ActiveStencilFaceEXT(activeFace);
     906        pState->diff_api.ActiveStencilFaceEXT(activeFace);
    903907    }
    904908
     
    918922        if (from->writeMask != to->writeMask)
    919923        {
    920             diff_api.StencilMask (to->writeMask);
     924            pState->diff_api.StencilMask (to->writeMask);
    921925            from->writeMask = to->writeMask;
    922926        }
     
    929933        CRContext *fromCtx, CRContext *toCtx)
    930934{
     935    PCRStateTracker pState = fromCtx->pStateTracker;
    931936    CRStencilState *from = &(fromCtx->stencil);
    932937    CRStencilState *to = &(toCtx->stencil);
     
    936941    GLchar frontMatch = -1, backMatch = -1, toFrontBackMatch = -1;
    937942    CRbitvalue nbitID[CR_MAX_BITARRAY];
     943
     944    CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker);
     945
    938946    for (j=0;j<CR_MAX_BITARRAY;j++)
    939947        nbitID[j] = ~bitID[j];
     
    943951    {
    944952        glAble able[2];
    945         able[0] = diff_api.Disable;
    946         able[1] = diff_api.Enable;
     953        able[0] = pState->diff_api.Disable;
     954        able[1] = pState->diff_api.Enable;
    947955        if (from->stencilTest != to->stencilTest)
    948956        {
     
    956964    {
    957965        glAble able[2];
    958         able[0] = diff_api.Disable;
    959         able[1] = diff_api.Enable;
     966        able[0] = pState->diff_api.Disable;
     967        able[1] = pState->diff_api.Enable;
    960968        if (from->stencilTwoSideEXT != to->stencilTwoSideEXT)
    961969        {
     
    970978        if (from->clearValue != to->clearValue)
    971979        {
    972             CRSTATE_CHECKGLERR(diff_api.ClearStencil (to->clearValue));
     980            CRSTATE_CHECKGLERR(pState->diff_api.ClearStencil (to->clearValue));
    973981            FILLDIRTY(b->clearValue);
    974982            FILLDIRTY(b->dirty);
     
    10071015                if (activeFace == GL_BACK)
    10081016                {
    1009                     diff_api.ActiveStencilFaceEXT(GL_FRONT);
     1017                    pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
    10101018                    activeFace = GL_FRONT;
    10111019                }
    10121020
    1013                 CRSTATE_CHECKGLERR(diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
     1021                CRSTATE_CHECKGLERR(pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
    10141022                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
    10151023                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask));
     
    10221030                if (activeFace == GL_BACK)
    10231031                {
    1024                     diff_api.ActiveStencilFaceEXT(GL_FRONT);
     1032                    pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
    10251033                    activeFace = GL_FRONT;
    10261034                }
    10271035
    1028                 CRSTATE_CHECKGLERR(diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
     1036                CRSTATE_CHECKGLERR(pState->diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
    10291037                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
    10301038                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask));
     
    10351043                if (activeFace == GL_BACK)
    10361044                {
    1037                     diff_api.ActiveStencilFaceEXT(GL_FRONT);
     1045                    pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
    10381046                    activeFace = GL_FRONT;
    10391047                }
    10401048
    1041                 CRSTATE_CHECKGLERR(diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
     1049                CRSTATE_CHECKGLERR(pState->diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
    10421050                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref,
    10431051                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask));
     
    10611069                    if (activeFace == GL_BACK)
    10621070                    {
    1063                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    1064                         activeFace = GL_FRONT;
    1065                     }
    1066 
    1067                     CRSTATE_CHECKGLERR(diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
     1071                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     1072                        activeFace = GL_FRONT;
     1073                    }
     1074
     1075                    CRSTATE_CHECKGLERR(pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
    10681076                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
    10691077                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask));
     
    10791087                    if (activeFace == GL_BACK)
    10801088                    {
    1081                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    1082                         activeFace = GL_FRONT;
    1083                     }
    1084 
    1085                     CRSTATE_CHECKGLERR(diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
     1089                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     1090                        activeFace = GL_FRONT;
     1091                    }
     1092
     1093                    CRSTATE_CHECKGLERR(pState->diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
    10861094                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
    10871095                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask));
     
    10951103                    if (activeFace == GL_BACK)
    10961104                    {
    1097                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    1098                         activeFace = GL_FRONT;
    1099                     }
    1100 
    1101                     CRSTATE_CHECKGLERR(diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
     1105                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     1106                        activeFace = GL_FRONT;
     1107                    }
     1108
     1109                    CRSTATE_CHECKGLERR(pState->diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
    11021110                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref,
    11031111                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask));
     
    11221130                    if (activeFace == GL_BACK)
    11231131                    {
    1124                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    1125                         activeFace = GL_FRONT;
    1126                     }
    1127 
    1128                     CRSTATE_CHECKGLERR(diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
     1132                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     1133                        activeFace = GL_FRONT;
     1134                    }
     1135
     1136                    CRSTATE_CHECKGLERR(pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
    11291137                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
    11301138                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask));
     
    11401148                    if (activeFace == GL_BACK)
    11411149                    {
    1142                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    1143                         activeFace = GL_FRONT;
    1144                     }
    1145 
    1146                     CRSTATE_CHECKGLERR(diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
     1150                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     1151                        activeFace = GL_FRONT;
     1152                    }
     1153
     1154                    CRSTATE_CHECKGLERR(pState->diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
    11471155                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
    11481156                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask));
     
    11561164                    if (activeFace == GL_BACK)
    11571165                    {
    1158                         diff_api.ActiveStencilFaceEXT(GL_FRONT);
    1159                         activeFace = GL_FRONT;
    1160                     }
    1161 
    1162                     CRSTATE_CHECKGLERR(diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
     1166                        pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
     1167                        activeFace = GL_FRONT;
     1168                    }
     1169
     1170                    CRSTATE_CHECKGLERR(pState->diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
    11631171                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref,
    11641172                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask));
     
    11781186            if (activeFace == GL_FRONT)
    11791187            {
    1180                 CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_BACK));
     1188                CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_BACK));
    11811189                activeFace = GL_BACK;
    11821190            }
    11831191
    1184             CRSTATE_CHECKGLERR(diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].func,
     1192            CRSTATE_CHECKGLERR(pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].func,
    11851193                to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].ref,
    11861194                to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].mask));
     
    12271235                if (activeFace == GL_BACK)
    12281236                {
    1229                     CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT));
     1237                    CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
    12301238                    activeFace = GL_FRONT;
    12311239                }
    12321240
    1233                 CRSTATE_CHECKGLERR(diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
     1241                CRSTATE_CHECKGLERR(pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
    12341242                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
    12351243                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass));
     
    12421250                if (activeFace == GL_BACK)
    12431251                {
    1244                     CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT));
     1252                    CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
    12451253                    activeFace = GL_FRONT;
    12461254                }
    12471255
    1248                 CRSTATE_CHECKGLERR(diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
     1256                CRSTATE_CHECKGLERR(pState->diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
    12491257                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
    12501258                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass));
     
    12551263                if (activeFace == GL_BACK)
    12561264                {
    1257                     CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT));
     1265                    CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
    12581266                    activeFace = GL_FRONT;
    12591267                }
    12601268
    1261                 CRSTATE_CHECKGLERR(diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
     1269                CRSTATE_CHECKGLERR(pState->diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
    12621270                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail,
    12631271                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass));
     
    12811289                    if (activeFace == GL_BACK)
    12821290                    {
    1283                         CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT));
    1284                         activeFace = GL_FRONT;
    1285                     }
    1286 
    1287                     CRSTATE_CHECKGLERR(diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
     1291                        CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
     1292                        activeFace = GL_FRONT;
     1293                    }
     1294
     1295                    CRSTATE_CHECKGLERR(pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
    12881296                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
    12891297                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass));
     
    12991307                    if (activeFace == GL_BACK)
    13001308                    {
    1301                         CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT));
    1302                         activeFace = GL_FRONT;
    1303                     }
    1304 
    1305                     CRSTATE_CHECKGLERR(diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
     1309                        CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
     1310                        activeFace = GL_FRONT;
     1311                    }
     1312
     1313                    CRSTATE_CHECKGLERR(pState->diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
    13061314                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
    13071315                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass));
     
    13151323                    if (activeFace == GL_BACK)
    13161324                    {
    1317                         CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT));
    1318                         activeFace = GL_FRONT;
    1319                     }
    1320 
    1321                     CRSTATE_CHECKGLERR(diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
     1325                        CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
     1326                        activeFace = GL_FRONT;
     1327                    }
     1328
     1329                    CRSTATE_CHECKGLERR(pState->diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
    13221330                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail,
    13231331                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass));
     
    13431351                    if (activeFace == GL_BACK)
    13441352                    {
    1345                         CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT));
    1346                         activeFace = GL_FRONT;
    1347                     }
    1348 
    1349                     CRSTATE_CHECKGLERR(diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
     1353                        CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
     1354                        activeFace = GL_FRONT;
     1355                    }
     1356
     1357                    CRSTATE_CHECKGLERR(pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
    13501358                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
    13511359                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass));
     
    13611369                    if (activeFace == GL_BACK)
    13621370                    {
    1363                         CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT));
    1364                         activeFace = GL_FRONT;
    1365                     }
    1366 
    1367                     CRSTATE_CHECKGLERR(diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
     1371                        CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
     1372                        activeFace = GL_FRONT;
     1373                    }
     1374
     1375                    CRSTATE_CHECKGLERR(pState->diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
    13681376                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
    13691377                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass));
     
    13771385                    if (activeFace == GL_BACK)
    13781386                    {
    1379                         CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT));
    1380                         activeFace = GL_FRONT;
    1381                     }
    1382 
    1383                     CRSTATE_CHECKGLERR(diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
     1387                        CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
     1388                        activeFace = GL_FRONT;
     1389                    }
     1390
     1391                    CRSTATE_CHECKGLERR(pState->diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
    13841392                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail,
    13851393                        to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass));
     
    14001408            if (activeFace == GL_FRONT)
    14011409            {
    1402                 CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_BACK));
     1410                CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_BACK));
    14031411                activeFace = GL_BACK;
    14041412            }
    14051413
    1406             CRSTATE_CHECKGLERR(diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].fail,
     1414            CRSTATE_CHECKGLERR(pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].fail,
    14071415                                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthFail,
    14081416                                    to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthPass));
     
    14201428    if (activeFace != to->activeStencilFace)
    14211429    {
    1422         CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(activeFace));
     1430        CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(activeFace));
    14231431    }
    14241432
     
    14391447        if (from->writeMask != to->writeMask)
    14401448        {
    1441             CRSTATE_CHECKGLERR(diff_api.StencilMask (to->writeMask));
     1449            CRSTATE_CHECKGLERR(pState->diff_api.StencilMask (to->writeMask));
    14421450            FILLDIRTY(b->writeMask);
    14431451            FILLDIRTY(b->dirty);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette