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_transform.c

    r78263 r78375  
    1919 */
    2020static INLINE void
    21 LOADMATRIX( const CRmatrix *a )
     21LOADMATRIX(PCRStateTracker pState, const CRmatrix *a )
    2222{
    2323    if (a->m00 == 1.0F && a->m01 == 0.0F && a->m02 == 0.0F && a->m03 == 0.0F &&
     
    2525            a->m20 == 0.0F && a->m21 == 0.0F && a->m22 == 1.0F && a->m23 == 0.0F &&
    2626            a->m30 == 0.0F && a->m31 == 0.0F && a->m32 == 0.0F && a->m33 == 1.0F) {
    27         diff_api.LoadIdentity();
     27        pState->diff_api.LoadIdentity();
    2828    }
    2929    else {
     
    3333        f[8] = a->m20;  f[9] = a->m21;  f[10] = a->m22; f[11] = a->m23;
    3434        f[12] = a->m30; f[13] = a->m31; f[14] = a->m32; f[15] = a->m33;
    35         diff_api.LoadMatrixf(f);
     35        pState->diff_api.LoadMatrixf(f);
    3636    }
    3737}
     
    116116    CRLimitsState *limits = &ctx->limits;
    117117    CRTransformState *t = &ctx->transform;
    118     CRStateBits *sb = GetCurrentBits();
     118    CRStateBits *sb = GetCurrentBits(ctx->pStateTracker);
    119119    CRTransformBits *tb = &(sb->transform);
    120120    unsigned int i;
     
    215215}
    216216
    217 void STATE_APIENTRY crStateClipPlane (GLenum plane, const GLdouble *equation)
    218 {
    219     CRContext *g = GetCurrentContext();
     217void STATE_APIENTRY crStateClipPlane (PCRStateTracker pState, GLenum plane, const GLdouble *equation)
     218{
     219    CRContext *g = GetCurrentContext(pState);
    220220    CRTransformState *t = &g->transform;
    221     CRStateBits *sb = GetCurrentBits();
     221    CRStateBits *sb = GetCurrentBits(pState);
    222222    CRTransformBits *tb = &(sb->transform);
    223223    GLvectord e;
     
    232232    if (g->current.inBeginEnd)
    233233    {
    234         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     234        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    235235                     "ClipPlane called in begin/end");
    236236        return;
     
    242242    if (i >= g->limits.maxClipPlanes)
    243243    {
    244         crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
     244        crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
    245245                     "ClipPlane called with bad enumerant: %d", plane);
    246246        return;
     
    254254}
    255255
    256 void STATE_APIENTRY crStateMatrixMode(GLenum e)
    257 {
    258     CRContext *g = GetCurrentContext();
     256void STATE_APIENTRY crStateMatrixMode(PCRStateTracker pState, GLenum e)
     257{
     258    CRContext *g = GetCurrentContext(pState);
    259259    CRTransformState *t = &(g->transform);
    260260    CRTextureState *tex = &(g->texture);
    261     CRStateBits *sb = GetCurrentBits();
    262     CRTransformBits *tb = &(sb->transform);
    263 
    264     if (g->current.inBeginEnd)
    265     {
    266         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "MatrixMode called in begin/end");
     261    CRStateBits *sb = GetCurrentBits(pState);
     262    CRTransformBits *tb = &(sb->transform);
     263
     264    if (g->current.inBeginEnd)
     265    {
     266        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "MatrixMode called in begin/end");
    267267        return;
    268268    }
     
    307307            }
    308308            else {
    309                 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid matrix mode: %d", e);
     309                crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "Invalid matrix mode: %d", e);
    310310                return;
    311311            }
     
    329329            }
    330330            else {
    331                  crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid matrix mode: %d", e);
     331                 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "Invalid matrix mode: %d", e);
    332332                 return;
    333333            }
    334334            break;
    335335        default:
    336             crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid matrix mode: %d", e);
     336            crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "Invalid matrix mode: %d", e);
    337337            return;
    338338    }
     
    343343}
    344344
    345 void STATE_APIENTRY crStateLoadIdentity(void)
    346 {
    347     CRContext *g = GetCurrentContext();
    348     CRTransformState *t = &(g->transform);
    349     CRStateBits *sb = GetCurrentBits();
    350     CRTransformBits *tb = &(sb->transform);
    351 
    352     if (g->current.inBeginEnd)
    353     {
    354         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     345void STATE_APIENTRY crStateLoadIdentity(PCRStateTracker pState)
     346{
     347    CRContext *g = GetCurrentContext(pState);
     348    CRTransformState *t = &(g->transform);
     349    CRStateBits *sb = GetCurrentBits(pState);
     350    CRTransformBits *tb = &(sb->transform);
     351
     352    if (g->current.inBeginEnd)
     353    {
     354        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    355355                                 "LoadIdentity called in begin/end");
    356356        return;
     
    366366}
    367367
    368 void STATE_APIENTRY crStatePopMatrix(void)
    369 {
    370     CRContext *g = GetCurrentContext();
     368void STATE_APIENTRY crStatePopMatrix(PCRStateTracker pState)
     369{
     370    CRContext *g = GetCurrentContext(pState);
    371371    CRTransformState *t = &g->transform;
    372     CRStateBits *sb = GetCurrentBits();
    373     CRTransformBits *tb = &(sb->transform);
    374 
    375     if (g->current.inBeginEnd)
    376     {
    377         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "PopMatrix called in begin/end");
     372    CRStateBits *sb = GetCurrentBits(pState);
     373    CRTransformBits *tb = &(sb->transform);
     374
     375    if (g->current.inBeginEnd)
     376    {
     377        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "PopMatrix called in begin/end");
    378378        return;
    379379    }
     
    383383    if (t->currentStack->depth == 0)
    384384    {
    385         crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "PopMatrix of empty stack.");
     385        crStateError(pState, __LINE__, __FILE__, GL_STACK_UNDERFLOW, "PopMatrix of empty stack.");
    386386        return;
    387387    }
     
    398398}
    399399
    400 void STATE_APIENTRY crStatePushMatrix(void)
    401 {
    402     CRContext *g = GetCurrentContext();
     400void STATE_APIENTRY crStatePushMatrix(PCRStateTracker pState)
     401{
     402    CRContext *g = GetCurrentContext(pState);
    403403    CRTransformState *t = &g->transform;
    404     CRStateBits *sb = GetCurrentBits();
    405     CRTransformBits *tb = &(sb->transform);
    406 
    407     if (g->current.inBeginEnd)
    408     {
    409         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "PushMatrix called in begin/end");
     404    CRStateBits *sb = GetCurrentBits(pState);
     405    CRTransformBits *tb = &(sb->transform);
     406
     407    if (g->current.inBeginEnd)
     408    {
     409        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "PushMatrix called in begin/end");
    410410        return;
    411411    }
     
    415415    if (t->currentStack->depth + 1 >= t->currentStack->maxDepth)
    416416    {
    417         crStateError(__LINE__, __FILE__, GL_STACK_OVERFLOW, "PushMatrix pass the end of allocated stack");
     417        crStateError(pState, __LINE__, __FILE__, GL_STACK_OVERFLOW, "PushMatrix pass the end of allocated stack");
    418418        return;
    419419    }
     
    433433
    434434/* Load a CRMatrix */
    435 void crStateLoadMatrix(const CRmatrix *m)
    436 {
    437     CRContext *g = GetCurrentContext();
    438     CRTransformState *t = &(g->transform);
    439     CRStateBits *sb = GetCurrentBits();
    440     CRTransformBits *tb = &(sb->transform);
    441 
    442     if (g->current.inBeginEnd)
    443     {
    444         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     435void crStateLoadMatrix(PCRStateTracker pState, const CRmatrix *m)
     436{
     437    CRContext *g = GetCurrentContext(pState);
     438    CRTransformState *t = &(g->transform);
     439    CRStateBits *sb = GetCurrentBits(pState);
     440    CRTransformBits *tb = &(sb->transform);
     441
     442    if (g->current.inBeginEnd)
     443    {
     444        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    445445                                 "LoadMatrix called in begin/end");
    446446        return;
     
    458458
    459459
    460 void STATE_APIENTRY crStateLoadMatrixf(const GLfloat *m1)
    461 {
    462     CRContext *g = GetCurrentContext();
    463     CRTransformState *t = &(g->transform);
    464     CRStateBits *sb = GetCurrentBits();
    465     CRTransformBits *tb = &(sb->transform);
    466 
    467     if (g->current.inBeginEnd)
    468     {
    469         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     460void STATE_APIENTRY crStateLoadMatrixf(PCRStateTracker pState, const GLfloat *m1)
     461{
     462    CRContext *g = GetCurrentContext(pState);
     463    CRTransformState *t = &(g->transform);
     464    CRStateBits *sb = GetCurrentBits(pState);
     465    CRTransformBits *tb = &(sb->transform);
     466
     467    if (g->current.inBeginEnd)
     468    {
     469        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    470470                                 "LoadMatrixf called in begin/end");
    471471        return;
     
    481481
    482482
    483 void STATE_APIENTRY crStateLoadMatrixd(const GLdouble *m1)
    484 {
    485     CRContext *g = GetCurrentContext();
    486     CRTransformState *t = &(g->transform);
    487     CRStateBits *sb = GetCurrentBits();
    488     CRTransformBits *tb = &(sb->transform);
    489 
    490     if (g->current.inBeginEnd)
    491     {
    492         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     483void STATE_APIENTRY crStateLoadMatrixd(PCRStateTracker pState, const GLdouble *m1)
     484{
     485    CRContext *g = GetCurrentContext(pState);
     486    CRTransformState *t = &(g->transform);
     487    CRStateBits *sb = GetCurrentBits(pState);
     488    CRTransformBits *tb = &(sb->transform);
     489
     490    if (g->current.inBeginEnd)
     491    {
     492        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    493493                                 "LoadMatrixd called in begin/end");
    494494        return;
     
    504504
    505505
    506 void STATE_APIENTRY crStateLoadTransposeMatrixfARB(const GLfloat *m1)
     506void STATE_APIENTRY crStateLoadTransposeMatrixfARB(PCRStateTracker pState, const GLfloat *m1)
    507507{
    508508   GLfloat tm[16];
    509509   if (!m1) return;
    510510   _math_transposef(tm, m1);
    511    crStateLoadMatrixf(tm);
    512 }
    513 
    514 void STATE_APIENTRY crStateLoadTransposeMatrixdARB(const GLdouble *m1)
     511   crStateLoadMatrixf(pState, tm);
     512}
     513
     514void STATE_APIENTRY crStateLoadTransposeMatrixdARB(PCRStateTracker pState, const GLdouble *m1)
    515515{
    516516   GLdouble tm[16];
    517517   if (!m1) return;
    518518   _math_transposed(tm, m1);
    519    crStateLoadMatrixd(tm);
     519   crStateLoadMatrixd(pState, tm);
    520520}
    521521
     
    527527 ** that this really helps.
    528528 */
    529 void STATE_APIENTRY crStateMultMatrixf(const GLfloat *m1)
    530 {
    531     CRContext *g = GetCurrentContext();
    532     CRTransformState *t = &(g->transform);
    533     CRStateBits *sb = GetCurrentBits();
     529void STATE_APIENTRY crStateMultMatrixf(PCRStateTracker pState, const GLfloat *m1)
     530{
     531    CRContext *g = GetCurrentContext(pState);
     532    CRTransformState *t = &(g->transform);
     533    CRStateBits *sb = GetCurrentBits(pState);
    534534    CRTransformBits *tb = &(sb->transform);
    535535    CRmatrix *m = t->currentStack->top;
     
    570570    if (g->current.inBeginEnd)
    571571    {
    572         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "MultMatrixf called in begin/end");
     572        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "MultMatrixf called in begin/end");
    573573        return;
    574574    }
     
    599599}
    600600
    601 void STATE_APIENTRY crStateMultMatrixd(const GLdouble *m1)
    602 {
    603     CRContext *g = GetCurrentContext();
    604     CRTransformState *t = &(g->transform);
    605     CRStateBits *sb = GetCurrentBits();
     601void STATE_APIENTRY crStateMultMatrixd(PCRStateTracker pState, const GLdouble *m1)
     602{
     603    CRContext *g = GetCurrentContext(pState);
     604    CRTransformState *t = &(g->transform);
     605    CRStateBits *sb = GetCurrentBits(pState);
    606606    CRTransformBits *tb = &(sb->transform);
    607607    CRmatrix *m = t->currentStack->top;
     
    641641    if (g->current.inBeginEnd)
    642642    {
    643         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "MultMatrixd called in begin/end");
     643        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "MultMatrixd called in begin/end");
    644644        return;
    645645    }
     
    670670}
    671671
    672 void STATE_APIENTRY crStateMultTransposeMatrixfARB(const GLfloat *m1)
     672void STATE_APIENTRY crStateMultTransposeMatrixfARB(PCRStateTracker pState, const GLfloat *m1)
    673673{
    674674   GLfloat tm[16];
    675675   if (!m1) return;
    676676   _math_transposef(tm, m1);
    677    crStateMultMatrixf(tm);
    678 }
    679 
    680 void STATE_APIENTRY crStateMultTransposeMatrixdARB(const GLdouble *m1)
     677   crStateMultMatrixf(pState, tm);
     678}
     679
     680void STATE_APIENTRY crStateMultTransposeMatrixdARB(PCRStateTracker pState, const GLdouble *m1)
    681681{
    682682   GLdouble tm[16];
    683683   if (!m1) return;
    684684   _math_transposed(tm, m1);
    685    crStateMultMatrixd(tm);
    686 }
    687 
    688 void STATE_APIENTRY crStateTranslatef(GLfloat x_arg, GLfloat y_arg, GLfloat z_arg)
    689 {
    690     CRContext *g = GetCurrentContext();
    691     CRTransformState *t = &(g->transform);
    692     CRStateBits *sb = GetCurrentBits();
    693     CRTransformBits *tb = &(sb->transform);
    694 
    695     if (g->current.inBeginEnd)
    696     {
    697         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     685   crStateMultMatrixd(pState, tm);
     686}
     687
     688void STATE_APIENTRY crStateTranslatef(PCRStateTracker pState, GLfloat x_arg, GLfloat y_arg, GLfloat z_arg)
     689{
     690    CRContext *g = GetCurrentContext(pState);
     691    CRTransformState *t = &(g->transform);
     692    CRStateBits *sb = GetCurrentBits(pState);
     693    CRTransformBits *tb = &(sb->transform);
     694
     695    if (g->current.inBeginEnd)
     696    {
     697        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    698698                                 "Translatef called in begin/end");
    699699        return;
     
    709709
    710710
    711 void STATE_APIENTRY crStateTranslated(GLdouble x_arg, GLdouble y_arg, GLdouble z_arg)
    712 {
    713     CRContext *g = GetCurrentContext();
    714     CRTransformState *t = &(g->transform);
    715     CRStateBits *sb = GetCurrentBits();
    716     CRTransformBits *tb = &(sb->transform);
    717 
    718     if (g->current.inBeginEnd)
    719     {
    720         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     711void STATE_APIENTRY crStateTranslated(PCRStateTracker pState, GLdouble x_arg, GLdouble y_arg, GLdouble z_arg)
     712{
     713    CRContext *g = GetCurrentContext(pState);
     714    CRTransformState *t = &(g->transform);
     715    CRStateBits *sb = GetCurrentBits(pState);
     716    CRTransformBits *tb = &(sb->transform);
     717
     718    if (g->current.inBeginEnd)
     719    {
     720        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    721721                                 "Translated called in begin/end");
    722722        return;
     
    732732
    733733
    734 void STATE_APIENTRY crStateRotatef(GLfloat ang, GLfloat x, GLfloat y, GLfloat z)
    735 {
    736     CRContext *g = GetCurrentContext();
    737     CRTransformState *t = &(g->transform);
    738     CRStateBits *sb = GetCurrentBits();
    739     CRTransformBits *tb = &(sb->transform);
    740 
    741     if (g->current.inBeginEnd)
    742     {
    743         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     734void STATE_APIENTRY crStateRotatef(PCRStateTracker pState, GLfloat ang, GLfloat x, GLfloat y, GLfloat z)
     735{
     736    CRContext *g = GetCurrentContext(pState);
     737    CRTransformState *t = &(g->transform);
     738    CRStateBits *sb = GetCurrentBits(pState);
     739    CRTransformBits *tb = &(sb->transform);
     740
     741    if (g->current.inBeginEnd)
     742    {
     743        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    744744                                 "Rotatef called in begin/end");
    745745        return;
     
    754754}
    755755
    756 void STATE_APIENTRY crStateRotated(GLdouble ang, GLdouble x, GLdouble y, GLdouble z)
    757 {
    758     CRContext *g = GetCurrentContext();
    759     CRTransformState *t = &(g->transform);
    760     CRStateBits *sb = GetCurrentBits();
    761     CRTransformBits *tb = &(sb->transform);
    762 
    763     if (g->current.inBeginEnd)
    764     {
    765         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     756void STATE_APIENTRY crStateRotated(PCRStateTracker pState, GLdouble ang, GLdouble x, GLdouble y, GLdouble z)
     757{
     758    CRContext *g = GetCurrentContext(pState);
     759    CRTransformState *t = &(g->transform);
     760    CRStateBits *sb = GetCurrentBits(pState);
     761    CRTransformBits *tb = &(sb->transform);
     762
     763    if (g->current.inBeginEnd)
     764    {
     765        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    766766                                 "Rotated called in begin/end");
    767767        return;
     
    776776}   
    777777
    778 void STATE_APIENTRY crStateScalef (GLfloat x_arg, GLfloat y_arg, GLfloat z_arg)
    779 {
    780     CRContext *g = GetCurrentContext();
    781     CRTransformState *t = &(g->transform);
    782     CRStateBits *sb = GetCurrentBits();
    783     CRTransformBits *tb = &(sb->transform);
    784 
    785     if (g->current.inBeginEnd)
    786     {
    787         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     778void STATE_APIENTRY crStateScalef (PCRStateTracker pState, GLfloat x_arg, GLfloat y_arg, GLfloat z_arg)
     779{
     780    CRContext *g = GetCurrentContext(pState);
     781    CRTransformState *t = &(g->transform);
     782    CRStateBits *sb = GetCurrentBits(pState);
     783    CRTransformBits *tb = &(sb->transform);
     784
     785    if (g->current.inBeginEnd)
     786    {
     787        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    788788                                 "Scalef called in begin/end");
    789789        return;
     
    798798}
    799799
    800 void STATE_APIENTRY crStateScaled (GLdouble x_arg, GLdouble y_arg, GLdouble z_arg)
    801 {
    802     CRContext *g = GetCurrentContext();
    803     CRTransformState *t = &(g->transform);
    804     CRStateBits *sb = GetCurrentBits();
    805     CRTransformBits *tb = &(sb->transform);
    806 
    807     if (g->current.inBeginEnd)
    808     {
    809         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     800void STATE_APIENTRY crStateScaled (PCRStateTracker pState, GLdouble x_arg, GLdouble y_arg, GLdouble z_arg)
     801{
     802    CRContext *g = GetCurrentContext(pState);
     803    CRTransformState *t = &(g->transform);
     804    CRStateBits *sb = GetCurrentBits(pState);
     805    CRTransformBits *tb = &(sb->transform);
     806
     807    if (g->current.inBeginEnd)
     808    {
     809        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    810810                                 "Scaled called in begin/end");
    811811        return;
     
    820820}
    821821
    822 void STATE_APIENTRY crStateFrustum(GLdouble left, GLdouble right,
     822void STATE_APIENTRY crStateFrustum(PCRStateTracker pState, GLdouble left, GLdouble right,
    823823                                                                     GLdouble bottom, GLdouble top,
    824824                                                                     GLdouble zNear, GLdouble zFar)
    825825{
    826     CRContext *g = GetCurrentContext();
    827     CRTransformState *t = &(g->transform);
    828     CRStateBits *sb = GetCurrentBits();
    829     CRTransformBits *tb = &(sb->transform);
    830 
    831     if (g->current.inBeginEnd)
    832     {
    833         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     826    CRContext *g = GetCurrentContext(pState);
     827    CRTransformState *t = &(g->transform);
     828    CRStateBits *sb = GetCurrentBits(pState);
     829    CRTransformBits *tb = &(sb->transform);
     830
     831    if (g->current.inBeginEnd)
     832    {
     833        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    834834                                 "Frustum called in begin/end");
    835835        return;
     
    844844}
    845845
    846 void STATE_APIENTRY crStateOrtho(GLdouble left, GLdouble right,
     846void STATE_APIENTRY crStateOrtho(PCRStateTracker pState, GLdouble left, GLdouble right,
    847847                                                                 GLdouble bottom, GLdouble top,
    848848                                                                 GLdouble zNear, GLdouble zFar)
    849849{
    850     CRContext *g = GetCurrentContext();
    851     CRTransformState *t = &(g->transform);
    852     CRStateBits *sb = GetCurrentBits();
    853     CRTransformBits *tb = &(sb->transform);
    854 
    855     if (g->current.inBeginEnd)
    856     {
    857         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     850    CRContext *g = GetCurrentContext(pState);
     851    CRTransformState *t = &(g->transform);
     852    CRStateBits *sb = GetCurrentBits(pState);
     853    CRTransformBits *tb = &(sb->transform);
     854
     855    if (g->current.inBeginEnd)
     856    {
     857        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    858858                                 "Ortho called in begin/end");
    859859        return;
     
    868868}
    869869
    870 void STATE_APIENTRY crStateGetClipPlane(GLenum plane, GLdouble *equation)
    871 {
    872     CRContext *g = GetCurrentContext();
     870void STATE_APIENTRY crStateGetClipPlane(PCRStateTracker pState, GLenum plane, GLdouble *equation)
     871{
     872    CRContext *g = GetCurrentContext(pState);
    873873    CRTransformState *t = &g->transform;
    874874    unsigned int i;
     
    876876    if (g->current.inBeginEnd)
    877877    {
    878         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     878        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    879879            "glGetClipPlane called in begin/end");
    880880        return;
     
    884884    if (i >= g->limits.maxClipPlanes)
    885885    {
    886         crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
     886        crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
    887887            "GetClipPlane called with bad enumerant: %d", plane);
    888888        return;
     
    898898                                                         CRContext *fromCtx, CRContext *toCtx )
    899899{
     900    PCRStateTracker pState = fromCtx->pStateTracker;
    900901    const GLuint maxTextureUnits = toCtx->limits.maxTextureUnits;
    901902    CRTransformState *from = &(fromCtx->transform);
     
    905906    CRbitvalue nbitID[CR_MAX_BITARRAY];
    906907
     908    CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker);
     909
    907910    for (j=0;j<CR_MAX_BITARRAY;j++)
    908911        nbitID[j] = ~bitID[j];
     
    911914    {
    912915        glAble able[2];
    913         able[0] = diff_api.Disable;
    914         able[1] = diff_api.Enable;
     916        able[0] = pState->diff_api.Disable;
     917        able[1] = pState->diff_api.Enable;
    915918        if (from->normalize != to->normalize) {
    916919            if (to->normalize == GL_TRUE)
    917                 diff_api.Enable(GL_NORMALIZE);
     920                pState->diff_api.Enable(GL_NORMALIZE);
    918921            else
    919                 diff_api.Disable(GL_NORMALIZE);
     922                pState->diff_api.Disable(GL_NORMALIZE);
    920923            FILLDIRTY(t->enable);
    921924            FILLDIRTY(t->dirty);
     
    943946
    944947    if (CHECKDIRTY(t->clipPlane, bitID)) {
    945         diff_api.MatrixMode(GL_MODELVIEW);
    946         diff_api.PushMatrix();
    947         diff_api.LoadIdentity();
     948        pState->diff_api.MatrixMode(GL_MODELVIEW);
     949        pState->diff_api.PushMatrix();
     950        pState->diff_api.LoadIdentity();
    948951        for (i=0; i<CR_MAX_CLIP_PLANES; i++) {
    949952            if (from->clipPlane[i].x != to->clipPlane[i].x ||
     
    958961                cp[3] = to->clipPlane[i].w;
    959962
    960                 diff_api.ClipPlane(GL_CLIP_PLANE0 + i, (const GLdouble *)(cp));
     963                pState->diff_api.ClipPlane(GL_CLIP_PLANE0 + i, (const GLdouble *)(cp));
    961964
    962965                FILLDIRTY(t->clipPlane);
     
    964967            }
    965968        }
    966         diff_api.PopMatrix();
     969        pState->diff_api.PopMatrix();
    967970        CLEARDIRTY(t->clipPlane, nbitID);
    968971    }
     
    986989                !crMatrixIsEqual(to->modelViewStack.top, from->modelViewStack.top))
    987990        {
    988             diff_api.MatrixMode(GL_MODELVIEW);
     991            pState->diff_api.MatrixMode(GL_MODELVIEW);
    989992
    990993            if (fd > td)
     
    992995                for (i = td; i < fd; i++)
    993996                {
    994                     diff_api.PopMatrix();
     997                    pState->diff_api.PopMatrix();
    995998                }
    996999                fd = td;
     
    9991002            for (i = fd; i <= td; i++)
    10001003            {
    1001                 LOADMATRIX(to->modelViewStack.stack + i);
     1004                LOADMATRIX(pState, to->modelViewStack.stack + i);
    10021005                FILLDIRTY(t->modelviewMatrix);
    10031006                FILLDIRTY(t->dirty);
     
    10051008                /* Don't want to push on the current matrix */
    10061009                if (i != to->modelViewStack.depth)
    1007                     diff_api.PushMatrix();
     1010                    pState->diff_api.PushMatrix();
    10081011            }
    10091012        }
     
    10211024                !crMatrixIsEqual(to->projectionStack.top, from->projectionStack.top)) {
    10221025
    1023             diff_api.MatrixMode(GL_PROJECTION);
     1026            pState->diff_api.MatrixMode(GL_PROJECTION);
    10241027
    10251028            if (fd > td)
     
    10271030                for (i = td; i < fd; i++)
    10281031                {
    1029                     diff_api.PopMatrix();
     1032                    pState->diff_api.PopMatrix();
    10301033                }
    10311034                fd = td;
     
    10341037            for (i = fd; i <= td; i++)
    10351038            {
    1036                 LOADMATRIX(to->projectionStack.stack + i);
     1039                LOADMATRIX(pState, to->projectionStack.stack + i);
    10371040                FILLDIRTY(t->projectionMatrix);
    10381041                FILLDIRTY(t->dirty);
     
    10401043                /* Don't want to push on the current matrix */
    10411044                if (i != to->projectionStack.depth)
    1042                     diff_api.PushMatrix();
     1045                    pState->diff_api.PushMatrix();
    10431046            }
    10441047        }
     
    10611064                    !crMatrixIsEqual(to->textureStack[j].top, from->textureStack[j].top))
    10621065            {
    1063                 diff_api.MatrixMode(GL_TEXTURE);
     1066                pState->diff_api.MatrixMode(GL_TEXTURE);
    10641067
    10651068                if (fd > td)
     
    10671070                    for (i = td; i < fd; i++)
    10681071                    {
    1069                         diff_api.PopMatrix();
     1072                        pState->diff_api.PopMatrix();
    10701073                    }
    10711074                    fd = td;
    10721075                }
    10731076
    1074                 diff_api.ActiveTextureARB( j + GL_TEXTURE0_ARB );
     1077                pState->diff_api.ActiveTextureARB( j + GL_TEXTURE0_ARB );
    10751078                for (i = fd; i <= td; i++)
    10761079                {
    1077                     LOADMATRIX(to->textureStack[j].stack + i);
     1080                    LOADMATRIX(pState, to->textureStack[j].stack + i);
    10781081                    FILLDIRTY(t->textureMatrix);
    10791082                    FILLDIRTY(t->dirty);
     
    10811084                    /* Don't want to push on the current matrix */
    10821085                    if (i != to->textureStack[j].depth)
    1083                         diff_api.PushMatrix();
     1086                        pState->diff_api.PushMatrix();
    10841087                }
    10851088            }
     
    10881091         * proper value now. 
    10891092         */
    1090         diff_api.ActiveTextureARB(GL_TEXTURE0_ARB + toCtx->texture.curTextureUnit);
     1093        pState->diff_api.ActiveTextureARB(GL_TEXTURE0_ARB + toCtx->texture.curTextureUnit);
    10911094        CLEARDIRTY(t->textureMatrix, nbitID);
    10921095    }
     
    11001103        if (td != fd || !crMatrixIsEqual(to->colorStack.top, from->colorStack.top))
    11011104        {
    1102             diff_api.MatrixMode(GL_COLOR);
     1105            pState->diff_api.MatrixMode(GL_COLOR);
    11031106
    11041107            if (fd > td)
     
    11061109                for (i = td; i < fd; i++)
    11071110                {
    1108                     diff_api.PopMatrix();
     1111                    pState->diff_api.PopMatrix();
    11091112                }
    11101113                fd = td;
     
    11131116            for (i = fd; i <= td; i++)
    11141117            {
    1115                 LOADMATRIX(to->colorStack.stack + i);
     1118                LOADMATRIX(pState, to->colorStack.stack + i);
    11161119                FILLDIRTY(t->colorMatrix);
    11171120                FILLDIRTY(t->dirty);
     
    11191122                /* Don't want to push on the current matrix */
    11201123                if (i != to->colorStack.depth)
    1121                     diff_api.PushMatrix();
     1124                    pState->diff_api.PushMatrix();
    11221125            }
    11231126        }
     
    11311134     * set it to the proper value now. 
    11321135     */
    1133     diff_api.MatrixMode(to->matrixMode);
     1136    pState->diff_api.MatrixMode(to->matrixMode);
    11341137
    11351138    /* sanity tests */
     
    11431146                                            CRContext *fromCtx, CRContext *toCtx )
    11441147{
     1148    PCRStateTracker pState = fromCtx->pStateTracker;
    11451149    const GLuint maxTextureUnits = toCtx->limits.maxTextureUnits;
    11461150    CRTransformState *from = &(fromCtx->transform);
     
    11511155    CRbitvalue nbitID[CR_MAX_BITARRAY];
    11521156
     1157    CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker);
     1158
    11531159    for (j=0;j<CR_MAX_BITARRAY;j++)
    11541160        nbitID[j] = ~bitID[j];
     
    11561162    if (CHECKDIRTY(t->enable, bitID)) {
    11571163        glAble able[2];
    1158         able[0] = diff_api.Disable;
    1159         able[1] = diff_api.Enable;
     1164        able[0] = pState->diff_api.Disable;
     1165        able[1] = pState->diff_api.Enable;
    11601166        for (i=0; i<CR_MAX_CLIP_PLANES; i++) {
    11611167            if (from->clip[i] != to->clip[i]) {
    11621168                if (to->clip[i] == GL_TRUE)
    1163                     diff_api.Enable(GL_CLIP_PLANE0 + i);
     1169                    pState->diff_api.Enable(GL_CLIP_PLANE0 + i);
    11641170                else
    1165                     diff_api.Disable(GL_CLIP_PLANE0 + i);
     1171                    pState->diff_api.Disable(GL_CLIP_PLANE0 + i);
    11661172                from->clip[i] = to->clip[i];
    11671173            }
     
    11691175        if (from->normalize != to->normalize) {
    11701176            if (to->normalize == GL_TRUE)
    1171                 diff_api.Enable(GL_NORMALIZE);
     1177                pState->diff_api.Enable(GL_NORMALIZE);
    11721178            else
    1173                 diff_api.Disable(GL_NORMALIZE);
     1179                pState->diff_api.Disable(GL_NORMALIZE);
    11741180            from->normalize = to->normalize;
    11751181        }
     
    11941200    if (CHECKDIRTY(t->clipPlane, bitID)) {
    11951201        if (from->matrixMode != GL_MODELVIEW) {
    1196             diff_api.MatrixMode(GL_MODELVIEW);
     1202            pState->diff_api.MatrixMode(GL_MODELVIEW);
    11971203            from->matrixMode = GL_MODELVIEW;
    11981204        }
    1199         diff_api.PushMatrix();
    1200         diff_api.LoadIdentity();
     1205        pState->diff_api.PushMatrix();
     1206        pState->diff_api.LoadIdentity();
    12011207        for (i=0; i<CR_MAX_CLIP_PLANES; i++) {
    12021208            if (from->clipPlane[i].x != to->clipPlane[i].x ||
     
    12111217                cp[3] = to->clipPlane[i].w;
    12121218
    1213                 diff_api.ClipPlane(GL_CLIP_PLANE0 + i, (const GLdouble *)(cp));
     1219                pState->diff_api.ClipPlane(GL_CLIP_PLANE0 + i, (const GLdouble *)(cp));
    12141220                from->clipPlane[i] = to->clipPlane[i];
    12151221            }
    12161222        }
    1217         diff_api.PopMatrix();
     1223        pState->diff_api.PopMatrix();
    12181224        CLEARDIRTY(t->clipPlane, nbitID);
    12191225    }
     
    12321238    {
    12331239        if (from->matrixMode != GL_MODELVIEW) {
    1234             diff_api.MatrixMode(GL_MODELVIEW);
     1240            pState->diff_api.MatrixMode(GL_MODELVIEW);
    12351241            from->matrixMode = GL_MODELVIEW;
    12361242        }
     
    12401246            for (i = to->modelViewStack.depth; i < from->modelViewStack.depth; i++)
    12411247            {
    1242                 diff_api.PopMatrix();
     1248                pState->diff_api.PopMatrix();
    12431249            }
    12441250
     
    12481254        for (i = from->modelViewStack.depth; i <= to->modelViewStack.depth; i++)
    12491255        {
    1250             LOADMATRIX(to->modelViewStack.stack + i);
     1256            LOADMATRIX(pState, to->modelViewStack.stack + i);
    12511257            from->modelViewStack.stack[i] = to->modelViewStack.stack[i];
    12521258
    12531259            /* Don't want to push on the current matrix */
    12541260            if (i != to->modelViewStack.depth)
    1255                 diff_api.PushMatrix();
     1261                pState->diff_api.PushMatrix();
    12561262        }
    12571263        from->modelViewStack.depth = to->modelViewStack.depth;
     
    12661272    {
    12671273        if (from->matrixMode != GL_PROJECTION) {
    1268             diff_api.MatrixMode(GL_PROJECTION);
     1274            pState->diff_api.MatrixMode(GL_PROJECTION);
    12691275            from->matrixMode = GL_PROJECTION;
    12701276        }
     
    12741280            for (i = to->projectionStack.depth; i < from->projectionStack.depth; i++)
    12751281            {
    1276                 diff_api.PopMatrix();
     1282                pState->diff_api.PopMatrix();
    12771283            }
    12781284
     
    12821288        for (i = from->projectionStack.depth; i <= to->projectionStack.depth; i++)
    12831289        {
    1284             LOADMATRIX(to->projectionStack.stack + i);
     1290            LOADMATRIX(pState, to->projectionStack.stack + i);
    12851291            from->projectionStack.stack[i] = to->projectionStack.stack[i];
    12861292
    12871293            /* Don't want to push on the current matrix */
    12881294            if (i != to->projectionStack.depth)
    1289                 diff_api.PushMatrix();
     1295                pState->diff_api.PushMatrix();
    12901296        }
    12911297        from->projectionStack.depth = to->projectionStack.depth;
     
    13031309    {
    13041310        if (from->matrixMode != GL_TEXTURE) {
    1305             diff_api.MatrixMode(GL_TEXTURE);
     1311            pState->diff_api.MatrixMode(GL_TEXTURE);
    13061312            from->matrixMode = GL_TEXTURE;
    13071313        }
     
    13111317            {
    13121318                if (textureFrom->curTextureUnit != j) {
    1313                     diff_api.ActiveTextureARB( j + GL_TEXTURE0_ARB );
     1319                    pState->diff_api.ActiveTextureARB( j + GL_TEXTURE0_ARB );
    13141320                    textureFrom->curTextureUnit = j;
    13151321                }
    13161322                for (i = to->textureStack[j].depth; i < from->textureStack[j].depth; i++)
    13171323                {
    1318                     diff_api.PopMatrix();
     1324                    pState->diff_api.PopMatrix();
    13191325                }
    13201326   
     
    13251331            {
    13261332                if (textureFrom->curTextureUnit != j) {
    1327                     diff_api.ActiveTextureARB( j + GL_TEXTURE0_ARB );
     1333                    pState->diff_api.ActiveTextureARB( j + GL_TEXTURE0_ARB );
    13281334                    textureFrom->curTextureUnit = j;
    13291335                }
    1330                 LOADMATRIX(to->textureStack[j].stack + i);
     1336                LOADMATRIX(pState, to->textureStack[j].stack + i);
    13311337                from->textureStack[j].stack[i] = to->textureStack[j].stack[i];
    13321338
    13331339                /* Don't want to push on the current matrix */
    13341340                if (i != to->textureStack[j].depth)
    1335                     diff_api.PushMatrix();
     1341                    pState->diff_api.PushMatrix();
    13361342            }
    13371343            from->textureStack[j].depth = to->textureStack[j].depth;
     
    13411347
    13421348        /* Restore proper active texture unit */
    1343         diff_api.ActiveTextureARB(GL_TEXTURE0_ARB + toCtx->texture.curTextureUnit);
     1349        pState->diff_api.ActiveTextureARB(GL_TEXTURE0_ARB + toCtx->texture.curTextureUnit);
    13441350    }
    13451351
     
    13491355    {
    13501356        if (from->matrixMode != GL_COLOR) {
    1351             diff_api.MatrixMode(GL_COLOR);
     1357            pState->diff_api.MatrixMode(GL_COLOR);
    13521358            from->matrixMode = GL_COLOR;
    13531359        }
     
    13571363            for (i = to->colorStack.depth; i < from->colorStack.depth; i++)
    13581364            {
    1359                 diff_api.PopMatrix();
     1365                pState->diff_api.PopMatrix();
    13601366            }
    13611367
     
    13651371        for (i = to->colorStack.depth; i <= to->colorStack.depth; i++)
    13661372        {
    1367             LOADMATRIX(to->colorStack.stack + i);
     1373            LOADMATRIX(pState, to->colorStack.stack + i);
    13681374            from->colorStack.stack[i] = to->colorStack.stack[i];
    13691375
    13701376            /* Don't want to push on the current matrix */
    13711377            if (i != to->colorStack.depth)
    1372                 diff_api.PushMatrix();
     1378                pState->diff_api.PushMatrix();
    13731379        }
    13741380        from->colorStack.depth = to->colorStack.depth;
     
    13831389    /* update MatrixMode now */
    13841390    if (from->matrixMode != to->matrixMode) {
    1385         diff_api.MatrixMode(to->matrixMode);
     1391        pState->diff_api.MatrixMode(to->matrixMode);
    13861392        from->matrixMode = to->matrixMode;
    13871393    }
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