Ignore:
Timestamp:
Mar 1, 2000, 7:50:02 PM (25 years ago)
Author:
jeroen
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/opengl/mesa/context.c

    r2938 r2962  
    1 /* $Id: context.c,v 1.1 2000-02-29 00:50:00 sandervl Exp $ */
     1/* $Id: context.c,v 1.2 2000-03-01 18:49:25 jeroen Exp $ */
    22
    33/*
     
    3535 * the address space.
    3636 */
     37
     38#ifdef __WIN32OS2__
     39#include <os2win.h>
     40#ifdef DIVE
     41#include "types.h"
     42#include "wmesadef.h"
     43#include "mesadive.h"
     44#endif
     45#endif
    3746
    3847#ifdef PC_HEADER
     
    138147#ifdef THREADS
    139148
    140 #include "mthreads.h" /* Mesa platform independent threads interface */
     149#include "mthreads.h"        /* Mesa platform independent threads interface*/
    141150
    142151static MesaTSD mesa_ctx_tsd;
     
    333342{
    334343   static GLboolean alreadyCalled = GL_FALSE;
     344
    335345   if (!alreadyCalled) {
    336346      gl_init_clip();
     
    346356      gl_init_vbxform();
    347357      gl_init_vertices();
     358#ifdef THREADS
     359      mesa_ctx_thread_init();
     360#endif
    348361      alreadyCalled = GL_TRUE;
    349362   }
     
    12621275
    12631276   ctx->VB = gl_vb_create_for_immediate( ctx );
     1277
    12641278   if (!ctx->VB) {
    12651279      FREE( ctx );
     
    12691283
    12701284   ctx->PB = gl_alloc_pb();
     1285
    12711286   if (!ctx->PB) {
    12721287      FREE( ctx->VB );
     
    13821397      gl_matrix_dtr( &ctx->ModelView );
    13831398      for (i = 0 ; i < MAX_MODELVIEW_STACK_DEPTH ; i++) {
    1384         gl_matrix_dtr( &ctx->ModelViewStack[i] );
     1399        gl_matrix_dtr( &ctx->ModelViewStack[i] );
    13851400      }
    13861401      gl_matrix_dtr( &ctx->ProjectionMatrix );
    13871402      for (i = 0 ; i < MAX_PROJECTION_STACK_DEPTH ; i++) {
    1388         gl_matrix_dtr( &ctx->ProjectionStack[i] );
     1403        gl_matrix_dtr( &ctx->ProjectionStack[i] );
    13891404      }
    13901405
     
    13991414      assert(ctx->Shared->RefCount>=0);
    14001415      if (ctx->Shared->RefCount==0) {
    1401         /* free shared state */
    1402         free_shared_state( ctx, ctx->Shared );
     1416        /* free shared state */
     1417        free_shared_state( ctx, ctx->Shared );
    14031418      }
    14041419
    14051420      foreach_s( s, tmps, ctx->ShineTabList ) {
    1406         FREE( s );
     1421        FREE( s );
    14071422      }
    14081423      FREE( ctx->ShineTabList );
     
    14651480      if (ctx==CC) {
    14661481         CC = NULL;
    1467         CURRENT_INPUT = NULL;
     1482        CURRENT_INPUT = NULL;
    14681483      }
    14691484#endif
     
    15401555    */
    15411556   if (CC) {
    1542       ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(CC, "gl_make_current");
     1557     ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(CC, "gl_make_current");
    15431558   }
    15441559
     
    15511566      CC->Buffer = NULL;
    15521567   }
     1568
    15531569   CC = ctx;
    15541570   if (ctx) {
    1555       SET_IMMEDIATE(ctx, ctx->input);
     1571   SET_IMMEDIATE(ctx, ctx->input);
    15561572   }
    15571573#endif
    1558 
    1559    if (MESA_VERBOSE) fprintf(stderr, "gl_make_current()\n");
    15601574
    15611575   if (ctx && buffer) {
    15621576      /* TODO: check if ctx and buffer's visual match??? */
    1563       ctx->Buffer = buffer;      /* Bind the frame buffer to the context */
    1564       ctx->NewState = NEW_ALL;   /* just to be safe */
     1577      ctx->Buffer = buffer;         /* Bind the frame buffer to the context*/
     1578      ctx->NewState = NEW_ALL;                           /* just to be safe*/
    15651579      gl_update_state( ctx );
    15661580   }
     
    15711585    * information.
    15721586    */
    1573    if (ctx && ctx->FirstTimeCurrent) {
    1574       if (getenv("MESA_INFO")) {
    1575          fprintf(stderr, "Mesa GL_VERSION = %s\n", (char *) gl_GetString(ctx, GL_VERSION));
    1576          fprintf(stderr, "Mesa GL_RENDERER = %s\n", (char *) gl_GetString(ctx, GL_RENDERER));
    1577          fprintf(stderr, "Mesa GL_VENDOR = %s\n", (char *) gl_GetString(ctx, GL_VENDOR));
    1578          fprintf(stderr, "Mesa GL_EXTENSIONS = %s\n", (char *) gl_GetString(ctx, GL_EXTENSIONS));
    1579       }
    1580       ctx->FirstTimeCurrent = GL_FALSE;
    1581    }
     1587   if (ctx && ctx->FirstTimeCurrent)
     1588     {
     1589        dprintf(("Mesa GL_VERSION = %s\n", (char *) gl_GetString(ctx, GL_VERSION)));
     1590        dprintf(("Mesa GL_RENDERER = %s\n", (char *) gl_GetString(ctx, GL_RENDERER)));
     1591        dprintf(("Mesa GL_VENDOR = %s\n", (char *) gl_GetString(ctx, GL_VENDOR)));
     1592        dprintf(("Mesa GL_EXTENSIONS = %s\n", (char *) gl_GetString(ctx, GL_EXTENSIONS)));
     1593
     1594        ctx->FirstTimeCurrent = GL_FALSE;
     1595     }
    15821596}
    15831597
     
    16491663   }
    16501664   if (mask & GL_POLYGON_STIPPLE_BIT) {
     1665#ifdef __WIN32OS2__
     1666      MEMCPY( &dst->PolygonStipple, &src->PolygonStipple, 32*sizeof(GLint) );
     1667#else
    16511668      /* Use loop instead of MEMCPY due to problem with Portland Group's
    16521669       * C compiler.  Reported by John Stone.
     
    16561673         dst->PolygonStipple[i] = src->PolygonStipple[i];
    16571674      }
     1675#endif
    16581676   }
    16591677   if (mask & GL_SCISSOR_BIT) {
     
    17071725void gl_problem( const GLcontext *ctx, const char *s )
    17081726{
     1727#ifdef __WIN32OS2__
     1728   dprintf(("OPENGL32: Mesa implementation error: %s\n", s) );
     1729   dprintf(("OPENGL32: Report to J.vandenHorn@fibre.a2000.nl\n" ));
     1730#else
    17091731   fprintf( stderr, "Mesa implementation error: %s\n", s );
    17101732   fprintf( stderr, "Report to mesa-bugs@mesa3d.org\n" );
    17111733   (void) ctx;
     1734#endif
    17121735}
    17131736
     
    17321755   }
    17331756#endif
     1757#ifdef __WIN32OS2__
     1758   dprintf(("OPENGL32: Mesa warning: %s\n", s ));
     1759#else
    17341760   if (debug) {
    17351761      fprintf( stderr, "Mesa warning: %s\n", s );
    17361762   }
     1763#endif
    17371764   (void) ctx;
    17381765}
     
    17721799   }
    17731800#endif
    1774 
     1801#ifdef __WIN32OS2__
     1802              {
     1803#else
    17751804   if (debug) {
     1805#endif
    17761806      char errstr[1000];
    17771807
    17781808      switch (error) {
    1779          case GL_NO_ERROR:
    1780             strcpy( errstr, "GL_NO_ERROR" );
    1781             break;
    1782          case GL_INVALID_VALUE:
    1783             strcpy( errstr, "GL_INVALID_VALUE" );
    1784             break;
    1785          case GL_INVALID_ENUM:
    1786             strcpy( errstr, "GL_INVALID_ENUM" );
    1787             break;
    1788          case GL_INVALID_OPERATION:
    1789             strcpy( errstr, "GL_INVALID_OPERATION" );
    1790             break;
    1791          case GL_STACK_OVERFLOW:
    1792             strcpy( errstr, "GL_STACK_OVERFLOW" );
    1793             break;
    1794          case GL_STACK_UNDERFLOW:
    1795             strcpy( errstr, "GL_STACK_UNDERFLOW" );
    1796             break;
    1797          case GL_OUT_OF_MEMORY:
    1798             strcpy( errstr, "GL_OUT_OF_MEMORY" );
    1799             break;
    1800          default:
    1801             strcpy( errstr, "unknown" );
    1802             break;
    1803       }
     1809         case GL_NO_ERROR:
     1810            strcpy( errstr, "GL_NO_ERROR" );
     1811            break;
     1812         case GL_INVALID_VALUE:
     1813            strcpy( errstr, "GL_INVALID_VALUE" );
     1814            break;
     1815         case GL_INVALID_ENUM:
     1816            strcpy( errstr, "GL_INVALID_ENUM" );
     1817            break;
     1818         case GL_INVALID_OPERATION:
     1819            strcpy( errstr, "GL_INVALID_OPERATION" );
     1820            break;
     1821         case GL_STACK_OVERFLOW:
     1822            strcpy( errstr, "GL_STACK_OVERFLOW" );
     1823            break;
     1824         case GL_STACK_UNDERFLOW:
     1825            strcpy( errstr, "GL_STACK_UNDERFLOW" );
     1826            break;
     1827         case GL_OUT_OF_MEMORY:
     1828            strcpy( errstr, "GL_OUT_OF_MEMORY" );
     1829            break;
     1830         default:
     1831            strcpy( errstr, "unknown" );
     1832            break;
     1833      }
     1834#ifdef __WIN32OS2__
     1835      dprintf( ("OPENGL32: Mesa user error: %s in %s\n", errstr, s ));
     1836#else
    18041837      fprintf( stderr, "Mesa user error: %s in %s\n", errstr, s );
     1838#endif
    18051839   }
    18061840
     
    18441878   /* ask device driver for size of output buffer */
    18451879   (*ctx->Driver.GetBufferSize)( ctx, &buf_width, &buf_height );
     1880
     1881   dprintf(("OPENGL32: gl_ResizeBuffersMESA - new w/h %d/%d\n",buf_width,buf_height));
    18461882
    18471883   /* see if size of device driver's color buffer (window) has changed */
     
    18501886      return;
    18511887
    1852    ctx->NewState |= NEW_RASTER_OPS;  /* to update scissor / window bounds */
     1888   ctx->NewState |= NEW_RASTER_OPS;    /* to update scissor / window bounds*/
    18531889
    18541890   /* save buffer size */
     
    18721908      gl_alloc_alpha_buffers( ctx );
    18731909   }
     1910
     1911#ifdef DIVE
     1912   DiveResizeBuffers(ctx->Buffer->Width,ctx->Buffer->Height);
     1913#endif
    18741914}
    18751915
     
    18921932      /* RGBA mode blending w/ Logic Op */
    18931933      if (ctx->Color.ColorLogicOpEnabled) {
    1894         if (ctx->Driver.LogicOp
     1934        if (ctx->Driver.LogicOp
    18951935             && (*ctx->Driver.LogicOp)( ctx, ctx->Color.LogicOp )) {
    1896             /* Device driver can do logic, don't have to do it in software */
    1897             ctx->Color.SWLogicOpEnabled = GL_FALSE;
    1898         }
    1899         else {
    1900             /* Device driver can't do logic op so we do it in software */
    1901             ctx->Color.SWLogicOpEnabled = GL_TRUE;
    1902         }
     1936            /* Device driver can do logic, don't have to do it in software */
     1937            ctx->Color.SWLogicOpEnabled = GL_FALSE;
     1938        }
     1939        else {
     1940            /* Device driver can't do logic op so we do it in software */
     1941            ctx->Color.SWLogicOpEnabled = GL_TRUE;
     1942        }
    19031943      }
    19041944      else {
    1905         /* no logic op */
    1906         if (ctx->Driver.LogicOp) {
     1945        /* no logic op */
     1946        if (ctx->Driver.LogicOp) {
    19071947            (void) (*ctx->Driver.LogicOp)( ctx, GL_COPY );
    19081948         }
    1909         ctx->Color.SWLogicOpEnabled = GL_FALSE;
     1949        ctx->Color.SWLogicOpEnabled = GL_FALSE;
    19101950      }
    19111951   }
     
    19131953      /* CI mode Logic Op */
    19141954      if (ctx->Color.IndexLogicOpEnabled) {
    1915         if (ctx->Driver.LogicOp
     1955        if (ctx->Driver.LogicOp
    19161956             && (*ctx->Driver.LogicOp)( ctx, ctx->Color.LogicOp )) {
    1917             /* Device driver can do logic, don't have to do it in software */
    1918             ctx->Color.SWLogicOpEnabled = GL_FALSE;
    1919         }
    1920         else {
    1921             /* Device driver can't do logic op so we do it in software */
    1922             ctx->Color.SWLogicOpEnabled = GL_TRUE;
    1923         }
     1957            /* Device driver can do logic, don't have to do it in software */
     1958            ctx->Color.SWLogicOpEnabled = GL_FALSE;
     1959        }
     1960        else {
     1961            /* Device driver can't do logic op so we do it in software */
     1962            ctx->Color.SWLogicOpEnabled = GL_TRUE;
     1963        }
    19241964      }
    19251965      else {
    1926         /* no logic op */
    1927         if (ctx->Driver.LogicOp) {
     1966        /* no logic op */
     1967        if (ctx->Driver.LogicOp) {
    19281968            (void) (*ctx->Driver.LogicOp)( ctx, GL_COPY );
    19291969         }
    1930         ctx->Color.SWLogicOpEnabled = GL_FALSE;
     1970        ctx->Color.SWLogicOpEnabled = GL_FALSE;
    19311971      }
    19321972   }
     
    19992039
    20002040      if (ctx->Texture.Enabled || ctx->Hint.Fog == GL_NICEST)
    2001         ctx->FogMode = FOG_FRAGMENT;
     2041        ctx->FogMode = FOG_FRAGMENT;
    20022042
    20032043      if ( ctx->Driver.GetParameteri &&
    2004            ctx->Driver.GetParameteri( ctx, DD_HAVE_HARDWARE_FOG ) )
    2005         ctx->FogMode = FOG_FRAGMENT;
     2044           ctx->Driver.GetParameteri( ctx, DD_HAVE_HARDWARE_FOG ) )
     2045        ctx->FogMode = FOG_FRAGMENT;
    20062046   }
    20072047
     
    20192059   ctx->RasterMask = 0;
    20202060
    2021    if (ctx->Color.AlphaEnabled)         ctx->RasterMask |= ALPHATEST_BIT;
    2022    if (ctx->Color.BlendEnabled)         ctx->RasterMask |= BLEND_BIT;
    2023    if (ctx->Depth.Test)                 ctx->RasterMask |= DEPTH_BIT;
    2024    if (ctx->FogMode==FOG_FRAGMENT)      ctx->RasterMask |= FOG_BIT;
    2025    if (ctx->Color.SWLogicOpEnabled)     ctx->RasterMask |= LOGIC_OP_BIT;
    2026    if (ctx->Scissor.Enabled)            ctx->RasterMask |= SCISSOR_BIT;
    2027    if (ctx->Stencil.Enabled)            ctx->RasterMask |= STENCIL_BIT;
    2028    if (ctx->Color.SWmasking)            ctx->RasterMask |= MASKING_BIT;
     2061   if (ctx->Color.AlphaEnabled)         ctx->RasterMask |= ALPHATEST_BIT;
     2062   if (ctx->Color.BlendEnabled)         ctx->RasterMask |= BLEND_BIT;
     2063   if (ctx->Depth.Test)                 ctx->RasterMask |= DEPTH_BIT;
     2064   if (ctx->FogMode==FOG_FRAGMENT)      ctx->RasterMask |= FOG_BIT;
     2065   if (ctx->Color.SWLogicOpEnabled)     ctx->RasterMask |= LOGIC_OP_BIT;
     2066   if (ctx->Scissor.Enabled)            ctx->RasterMask |= SCISSOR_BIT;
     2067   if (ctx->Stencil.Enabled)            ctx->RasterMask |= STENCIL_BIT;
     2068   if (ctx->Color.SWmasking)            ctx->RasterMask |= MASKING_BIT;
    20292069
    20302070   if (ctx->Visual->SoftwareAlpha && ctx->Color.ColorMask[ACOMP]
     
    20722112{
    20732113   fprintf(stderr,
    2074            "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
    2075            msg,
    2076            state,
    2077            (state & NEW_LIGHTING)         ? "lighting, " : "",
    2078            (state & NEW_RASTER_OPS)       ? "raster-ops, " : "",
    2079            (state & NEW_TEXTURING)        ? "texturing, " : "",
    2080            (state & NEW_POLYGON)          ? "polygon, " : "",
    2081            (state & NEW_DRVSTATE0)        ? "driver-0, " : "",
    2082            (state & NEW_DRVSTATE1)        ? "driver-1, " : "",
    2083            (state & NEW_DRVSTATE2)        ? "driver-2, " : "",
    2084            (state & NEW_DRVSTATE3)        ? "driver-3, " : "",
    2085            (state & NEW_MODELVIEW)        ? "modelview, " : "",
    2086            (state & NEW_PROJECTION)       ? "projection, " : "",
    2087            (state & NEW_TEXTURE_MATRIX)   ? "texture-matrix, " : "",
    2088            (state & NEW_USER_CLIP)        ? "user-clip, " : "",
    2089            (state & NEW_TEXTURE_ENV)      ? "texture-env, " : "",
    2090            (state & NEW_CLIENT_STATE)     ? "client-state, " : "",
    2091            (state & NEW_FOG)              ? "fog, " : "",
    2092            (state & NEW_NORMAL_TRANSFORM) ? "normal-transform, " : "",
    2093            (state & NEW_VIEWPORT)         ? "viewport, " : "",
    2094            (state & NEW_TEXTURE_ENABLE)   ? "texture-enable, " : "");
     2114           "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
     2115           msg,
     2116           state,
     2117           (state & NEW_LIGHTING)         ? "lighting, " : "",
     2118           (state & NEW_RASTER_OPS)       ? "raster-ops, " : "",
     2119           (state & NEW_TEXTURING)        ? "texturing, " : "",
     2120           (state & NEW_POLYGON)          ? "polygon, " : "",
     2121           (state & NEW_DRVSTATE0)        ? "driver-0, " : "",
     2122           (state & NEW_DRVSTATE1)        ? "driver-1, " : "",
     2123           (state & NEW_DRVSTATE2)        ? "driver-2, " : "",
     2124           (state & NEW_DRVSTATE3)        ? "driver-3, " : "",
     2125           (state & NEW_MODELVIEW)        ? "modelview, " : "",
     2126           (state & NEW_PROJECTION)       ? "projection, " : "",
     2127           (state & NEW_TEXTURE_MATRIX)   ? "texture-matrix, " : "",
     2128           (state & NEW_USER_CLIP)        ? "user-clip, " : "",
     2129           (state & NEW_TEXTURE_ENV)      ? "texture-env, " : "",
     2130           (state & NEW_CLIENT_STATE)     ? "client-state, " : "",
     2131           (state & NEW_FOG)              ? "fog, " : "",
     2132           (state & NEW_NORMAL_TRANSFORM) ? "normal-transform, " : "",
     2133           (state & NEW_VIEWPORT)         ? "viewport, " : "",
     2134           (state & NEW_TEXTURE_ENABLE)   ? "texture-enable, " : "");
    20952135}
    20962136
     
    20982138{
    20992139   fprintf(stderr,
    2100            "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s\n",
    2101            msg,
    2102            flags,
    2103            (flags & ENABLE_TEX0)       ? "tex-0, " : "",
    2104            (flags & ENABLE_TEX1)       ? "tex-1, " : "",
    2105            (flags & ENABLE_LIGHT)      ? "light, " : "",
    2106            (flags & ENABLE_FOG)        ? "fog, " : "",
    2107            (flags & ENABLE_USERCLIP)   ? "userclip, " : "",
    2108            (flags & ENABLE_TEXGEN0)    ? "tex-gen-0, " : "",
    2109            (flags & ENABLE_TEXGEN1)    ? "tex-gen-1, " : "",
    2110            (flags & ENABLE_TEXMAT0)    ? "tex-mat-0, " : "",
    2111            (flags & ENABLE_TEXMAT1)    ? "tex-mat-1, " : "",
    2112            (flags & ENABLE_NORMALIZE)  ? "normalize, " : "",
    2113            (flags & ENABLE_RESCALE)    ? "rescale, " : "");
     2140           "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s\n",
     2141           msg,
     2142           flags,
     2143           (flags & ENABLE_TEX0)       ? "tex-0, " : "",
     2144           (flags & ENABLE_TEX1)       ? "tex-1, " : "",
     2145           (flags & ENABLE_LIGHT)      ? "light, " : "",
     2146           (flags & ENABLE_FOG)        ? "fog, " : "",
     2147           (flags & ENABLE_USERCLIP)   ? "userclip, " : "",
     2148           (flags & ENABLE_TEXGEN0)    ? "tex-gen-0, " : "",
     2149           (flags & ENABLE_TEXGEN1)    ? "tex-gen-1, " : "",
     2150           (flags & ENABLE_TEXMAT0)    ? "tex-mat-0, " : "",
     2151           (flags & ENABLE_TEXMAT1)    ? "tex-mat-1, " : "",
     2152           (flags & ENABLE_NORMALIZE)  ? "normalize, " : "",
     2153           (flags & ENABLE_RESCALE)    ? "rescale, " : "");
    21142154}
    21152155
     
    21362176   if (ctx->NewState & NEW_TEXTURE_ENV) {
    21372177      if (ctx->Texture.Unit[0].EnvMode == ctx->Texture.Unit[0].LastEnvMode &&
    2138           ctx->Texture.Unit[1].EnvMode == ctx->Texture.Unit[1].LastEnvMode)
    2139         ctx->NewState &= ~NEW_TEXTURE_ENV;
     2178          ctx->Texture.Unit[1].EnvMode == ctx->Texture.Unit[1].LastEnvMode)
     2179        ctx->NewState &= ~NEW_TEXTURE_ENV;
    21402180      ctx->Texture.Unit[0].LastEnvMode = ctx->Texture.Unit[0].EnvMode;
    21412181      ctx->Texture.Unit[1].LastEnvMode = ctx->Texture.Unit[1].EnvMode;
     
    21462186
    21472187      for (i=0; i < MAX_TEXTURE_UNITS; i++) {
    2148         if (ctx->TextureMatrix[i].flags & MAT_DIRTY_ALL_OVER)
    2149         {
    2150             gl_matrix_analyze( &ctx->TextureMatrix[i] );
    2151             ctx->TextureMatrix[i].flags &= ~MAT_DIRTY_DEPENDENTS;
    2152 
    2153             if (ctx->Texture.Unit[i].Enabled &&
    2154                 ctx->TextureMatrix[i].type != MATRIX_IDENTITY)
    2155                ctx->Enabled |= ENABLE_TEXMAT0 << i;
    2156         }
     2188        if (ctx->TextureMatrix[i].flags & MAT_DIRTY_ALL_OVER)
     2189        {
     2190            gl_matrix_analyze( &ctx->TextureMatrix[i] );
     2191            ctx->TextureMatrix[i].flags &= ~MAT_DIRTY_DEPENDENTS;
     2192
     2193            if (ctx->Texture.Unit[i].Enabled &&
     2194                ctx->TextureMatrix[i].type != MATRIX_IDENTITY)
     2195               ctx->Enabled |= ENABLE_TEXMAT0 << i;
     2196        }
    21572197      }
    21582198   }
     
    21652205
    21662206      for (i=0; i < MAX_TEXTURE_UNITS; i++) {
    2167         if (ctx->Texture.Unit[i].Enabled) {
    2168             gl_update_texture_unit( ctx, &ctx->Texture.Unit[i] );
    2169 
    2170             ctx->Texture.ReallyEnabled |=
    2171                ctx->Texture.Unit[i].ReallyEnabled<<(i*4);
    2172 
    2173             if (ctx->Texture.Unit[i].GenFlags != 0) {
    2174                ctx->Enabled |= ENABLE_TEXGEN0 << i;
    2175 
    2176                if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_NORMALS)
    2177                {
    2178                   ctx->Texture.NeedNormals = GL_TRUE;
    2179                   ctx->Texture.NeedEyeCoords = GL_TRUE;
    2180                }
    2181 
    2182                if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_EYE_COORD)
    2183                {
    2184                   ctx->Texture.NeedEyeCoords = GL_TRUE;
    2185                }
    2186             }
    2187         }
     2207        if (ctx->Texture.Unit[i].Enabled) {
     2208            gl_update_texture_unit( ctx, &ctx->Texture.Unit[i] );
     2209
     2210            ctx->Texture.ReallyEnabled |=
     2211               ctx->Texture.Unit[i].ReallyEnabled<<(i*4);
     2212
     2213            if (ctx->Texture.Unit[i].GenFlags != 0) {
     2214               ctx->Enabled |= ENABLE_TEXGEN0 << i;
     2215
     2216               if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_NORMALS)
     2217               {
     2218                  ctx->Texture.NeedNormals = GL_TRUE;
     2219                  ctx->Texture.NeedEyeCoords = GL_TRUE;
     2220               }
     2221
     2222               if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_EYE_COORD)
     2223               {
     2224                  ctx->Texture.NeedEyeCoords = GL_TRUE;
     2225               }
     2226            }
     2227        }
    21882228      }
    21892229
     
    21962236
    21972237      if (ctx->NewState & NEW_RASTER_OPS) {
    2198         update_pixel_logic(ctx);
    2199         update_pixel_masking(ctx);
    2200         update_fog_mode(ctx);
    2201         update_rasterflags(ctx);
    2202         if (ctx->Driver.Dither) {
    2203             (*ctx->Driver.Dither)( ctx, ctx->Color.DitherFlag );
    2204         }
    2205 
    2206         /* Check if incoming colors can be modified during rasterization */
    2207         if (ctx->Fog.Enabled ||
    2208              ctx->Texture.Enabled ||
    2209              ctx->Color.BlendEnabled ||
    2210              ctx->Color.SWmasking ||
    2211              ctx->Color.SWLogicOpEnabled) {
    2212             ctx->MutablePixels = GL_TRUE;
    2213         }
    2214         else {
    2215             ctx->MutablePixels = GL_FALSE;
    2216         }
    2217 
    2218         /* update scissor region */
    2219 
    2220         ctx->Buffer->Xmin = 0;
    2221         ctx->Buffer->Ymin = 0;
    2222         ctx->Buffer->Xmax = ctx->Buffer->Width-1;
    2223         ctx->Buffer->Ymax = ctx->Buffer->Height-1;
    2224         if (ctx->Scissor.Enabled) {
    2225             if (ctx->Scissor.X > ctx->Buffer->Xmin) {
    2226                ctx->Buffer->Xmin = ctx->Scissor.X;
    2227             }
    2228             if (ctx->Scissor.Y > ctx->Buffer->Ymin) {
    2229                ctx->Buffer->Ymin = ctx->Scissor.Y;
    2230             }
    2231             if (ctx->Scissor.X + ctx->Scissor.Width - 1 < ctx->Buffer->Xmax) {
    2232                ctx->Buffer->Xmax = ctx->Scissor.X + ctx->Scissor.Width - 1;
    2233             }
    2234             if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < ctx->Buffer->Ymax) {
    2235                ctx->Buffer->Ymax = ctx->Scissor.Y + ctx->Scissor.Height - 1;
    2236             }
    2237         }
    2238 
    2239         /* The driver isn't managing the depth buffer.
    2240           */
    2241         if (ctx->Driver.AllocDepthBuffer == gl_alloc_depth_buffer)
    2242         {
    2243             if (ctx->Depth.Mask) {
    2244                switch (ctx->Depth.Func) {
    2245                case GL_LESS:
    2246                   ctx->Driver.DepthTestSpan = gl_depth_test_span_less;
    2247                   ctx->Driver.DepthTestPixels = gl_depth_test_pixels_less;
    2248                   break;
    2249                case GL_GREATER:
    2250                   ctx->Driver.DepthTestSpan = gl_depth_test_span_greater;
    2251                   ctx->Driver.DepthTestPixels = gl_depth_test_pixels_greater;
    2252                   break;
    2253                default:
    2254                   ctx->Driver.DepthTestSpan = gl_depth_test_span_generic;
    2255                   ctx->Driver.DepthTestPixels = gl_depth_test_pixels_generic;
    2256                }
    2257             }
    2258             else {
    2259                ctx->Driver.DepthTestSpan = gl_depth_test_span_generic;
    2260                ctx->Driver.DepthTestPixels = gl_depth_test_pixels_generic;
    2261             }
    2262         }
     2238        update_pixel_logic(ctx);
     2239        update_pixel_masking(ctx);
     2240        update_fog_mode(ctx);
     2241        update_rasterflags(ctx);
     2242        if (ctx->Driver.Dither) {
     2243            (*ctx->Driver.Dither)( ctx, ctx->Color.DitherFlag );
     2244        }
     2245
     2246        /* Check if incoming colors can be modified during rasterization */
     2247        if (ctx->Fog.Enabled ||
     2248             ctx->Texture.Enabled ||
     2249             ctx->Color.BlendEnabled ||
     2250             ctx->Color.SWmasking ||
     2251             ctx->Color.SWLogicOpEnabled) {
     2252            ctx->MutablePixels = GL_TRUE;
     2253        }
     2254        else {
     2255            ctx->MutablePixels = GL_FALSE;
     2256        }
     2257
     2258        /* update scissor region */
     2259
     2260        ctx->Buffer->Xmin = 0;
     2261        ctx->Buffer->Ymin = 0;
     2262        ctx->Buffer->Xmax = ctx->Buffer->Width-1;
     2263        ctx->Buffer->Ymax = ctx->Buffer->Height-1;
     2264        if (ctx->Scissor.Enabled) {
     2265            if (ctx->Scissor.X > ctx->Buffer->Xmin) {
     2266               ctx->Buffer->Xmin = ctx->Scissor.X;
     2267            }
     2268            if (ctx->Scissor.Y > ctx->Buffer->Ymin) {
     2269               ctx->Buffer->Ymin = ctx->Scissor.Y;
     2270            }
     2271            if (ctx->Scissor.X + ctx->Scissor.Width - 1 < ctx->Buffer->Xmax) {
     2272               ctx->Buffer->Xmax = ctx->Scissor.X + ctx->Scissor.Width - 1;
     2273            }
     2274            if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < ctx->Buffer->Ymax) {
     2275               ctx->Buffer->Ymax = ctx->Scissor.Y + ctx->Scissor.Height - 1;
     2276            }
     2277        }
     2278
     2279        /* The driver isn't managing the depth buffer.
     2280          */
     2281        if (ctx->Driver.AllocDepthBuffer == gl_alloc_depth_buffer)
     2282        {
     2283            if (ctx->Depth.Mask) {
     2284               switch (ctx->Depth.Func) {
     2285               case GL_LESS:
     2286                  ctx->Driver.DepthTestSpan = gl_depth_test_span_less;
     2287                  ctx->Driver.DepthTestPixels = gl_depth_test_pixels_less;
     2288                  break;
     2289               case GL_GREATER:
     2290                  ctx->Driver.DepthTestSpan = gl_depth_test_span_greater;
     2291                  ctx->Driver.DepthTestPixels = gl_depth_test_pixels_greater;
     2292                  break;
     2293               default:
     2294                  ctx->Driver.DepthTestSpan = gl_depth_test_span_generic;
     2295                  ctx->Driver.DepthTestPixels = gl_depth_test_pixels_generic;
     2296               }
     2297            }
     2298            else {
     2299               ctx->Driver.DepthTestSpan = gl_depth_test_span_generic;
     2300               ctx->Driver.DepthTestPixels = gl_depth_test_pixels_generic;
     2301            }
     2302        }
    22632303      }
    22642304
    22652305      if (ctx->NewState & NEW_LIGHTING) {
    2266         ctx->TriangleCaps &= ~(DD_TRI_LIGHT_TWOSIDE|DD_LIGHTING_CULL);
    2267         if (ctx->Light.Enabled) {
    2268             if (ctx->Light.Model.TwoSide)
    2269                ctx->TriangleCaps |= (DD_TRI_LIGHT_TWOSIDE|DD_LIGHTING_CULL);
    2270             gl_update_lighting(ctx);
    2271         }
     2306        ctx->TriangleCaps &= ~(DD_TRI_LIGHT_TWOSIDE|DD_LIGHTING_CULL);
     2307        if (ctx->Light.Enabled) {
     2308            if (ctx->Light.Model.TwoSide)
     2309               ctx->TriangleCaps |= (DD_TRI_LIGHT_TWOSIDE|DD_LIGHTING_CULL);
     2310            gl_update_lighting(ctx);
     2311        }
    22722312      }
    22732313   }
     
    22782318
    22792319      if (ctx->NewState & NEW_POLYGON) {
    2280         /* Setup CullBits bitmask */
    2281         if (ctx->Polygon.CullFlag) {
    2282             ctx->backface_sign = 1;
    2283             switch(ctx->Polygon.CullFaceMode) {
    2284             case GL_BACK:
    2285                if(ctx->Polygon.FrontFace==GL_CCW)
    2286                   ctx->backface_sign = -1;
    2287                ctx->Polygon.CullBits = 1;
    2288                break;
    2289             case GL_FRONT:
    2290                if(ctx->Polygon.FrontFace!=GL_CCW)
    2291                   ctx->backface_sign = -1;
    2292                ctx->Polygon.CullBits = 2;
    2293                break;
    2294             default:
    2295             case GL_FRONT_AND_BACK:
    2296                ctx->backface_sign = 0;
    2297                ctx->Polygon.CullBits = 0;
    2298                ctx->TriangleCaps |= DD_TRI_CULL_FRONT_BACK;
    2299                break;
    2300             }
    2301         }
    2302         else {
    2303             ctx->Polygon.CullBits = 3;
    2304             ctx->backface_sign = 0;
    2305         }
    2306 
    2307         /* Any Polygon offsets enabled? */
    2308         ctx->TriangleCaps &= ~DD_TRI_OFFSET;
    2309 
    2310         if (ctx->Polygon.OffsetPoint ||
    2311              ctx->Polygon.OffsetLine ||
    2312              ctx->Polygon.OffsetFill)
    2313             ctx->TriangleCaps |= DD_TRI_OFFSET;
    2314 
    2315         /* reset Z offsets now */
    2316         ctx->PointZoffset   = 0.0;
    2317         ctx->LineZoffset    = 0.0;
    2318         ctx->PolygonZoffset = 0.0;
     2320        /* Setup CullBits bitmask */
     2321        if (ctx->Polygon.CullFlag) {
     2322            ctx->backface_sign = 1;
     2323            switch(ctx->Polygon.CullFaceMode) {
     2324            case GL_BACK:
     2325               if(ctx->Polygon.FrontFace==GL_CCW)
     2326                  ctx->backface_sign = -1;
     2327               ctx->Polygon.CullBits = 1;
     2328               break;
     2329            case GL_FRONT:
     2330               if(ctx->Polygon.FrontFace!=GL_CCW)
     2331                  ctx->backface_sign = -1;
     2332               ctx->Polygon.CullBits = 2;
     2333               break;
     2334            default:
     2335            case GL_FRONT_AND_BACK:
     2336               ctx->backface_sign = 0;
     2337               ctx->Polygon.CullBits = 0;
     2338               ctx->TriangleCaps |= DD_TRI_CULL_FRONT_BACK;
     2339               break;
     2340            }
     2341        }
     2342        else {
     2343            ctx->Polygon.CullBits = 3;
     2344            ctx->backface_sign = 0;
     2345        }
     2346
     2347        /* Any Polygon offsets enabled? */
     2348        ctx->TriangleCaps &= ~DD_TRI_OFFSET;
     2349
     2350        if (ctx->Polygon.OffsetPoint ||
     2351             ctx->Polygon.OffsetLine ||
     2352             ctx->Polygon.OffsetFill)
     2353            ctx->TriangleCaps |= DD_TRI_OFFSET;
     2354
     2355        /* reset Z offsets now */
     2356        ctx->PointZoffset   = 0.0;
     2357        ctx->LineZoffset    = 0.0;
     2358        ctx->PolygonZoffset = 0.0;
    23192359      }
    23202360   }
    23212361
    23222362   if (ctx->NewState & ~(NEW_CLIENT_STATE|
    2323                         NEW_DRIVER_STATE|NEW_USER_CLIP|
    2324                         NEW_POLYGON))
     2363                        NEW_DRIVER_STATE|NEW_USER_CLIP|
     2364                        NEW_POLYGON))
    23252365      gl_update_clipmask(ctx);
    23262366
    23272367   if (ctx->NewState & (NEW_LIGHTING|
    2328                         NEW_RASTER_OPS|
    2329                         NEW_TEXTURING|
    2330                         NEW_TEXTURE_ENABLE|
    2331                         NEW_TEXTURE_ENV|
    2332                         NEW_POLYGON|
    2333                         NEW_DRVSTATE0|
    2334                         NEW_DRVSTATE1|
    2335                         NEW_DRVSTATE2|
    2336                         NEW_DRVSTATE3|
    2337                         NEW_USER_CLIP))
     2368                        NEW_RASTER_OPS|
     2369                        NEW_TEXTURING|
     2370                        NEW_TEXTURE_ENABLE|
     2371                        NEW_TEXTURE_ENV|
     2372                        NEW_POLYGON|
     2373                        NEW_DRVSTATE0|
     2374                        NEW_DRVSTATE1|
     2375                        NEW_DRVSTATE2|
     2376                        NEW_DRVSTATE3|
     2377                        NEW_USER_CLIP))
    23382378   {
    23392379      ctx->IndirectTriangles = ctx->TriangleCaps & ~ctx->Driver.TriangleCaps;
     
    23412381
    23422382      if (MESA_VERBOSE&VERBOSE_CULL)
    2343         gl_print_tri_caps("initial indirect tris", ctx->IndirectTriangles);
     2383        gl_print_tri_caps("initial indirect tris", ctx->IndirectTriangles);
    23442384
    23452385      ctx->Driver.PointsFunc = NULL;
     
    23592399
    23602400      if (MESA_VERBOSE&VERBOSE_CULL)
    2361         gl_print_tri_caps("indirect tris", ctx->IndirectTriangles);
     2401        gl_print_tri_caps("indirect tris", ctx->IndirectTriangles);
    23622402
    23632403      /*
     
    23672407       */
    23682408      if (ctx->IndirectTriangles & DD_SW_RASTERIZE) {
    2369         gl_set_point_function(ctx);
    2370         gl_set_line_function(ctx);
    2371         gl_set_triangle_function(ctx);
    2372         gl_set_quad_function(ctx);
    2373 
    2374         if ((ctx->IndirectTriangles &
    2375               (DD_TRI_SW_RASTERIZE|DD_QUAD_SW_RASTERIZE|DD_TRI_CULL)) ==
    2376              (DD_TRI_SW_RASTERIZE|DD_QUAD_SW_RASTERIZE|DD_TRI_CULL))
    2377             ctx->IndirectTriangles &= ~DD_TRI_CULL;
     2409        gl_set_point_function(ctx);
     2410        gl_set_line_function(ctx);
     2411        gl_set_triangle_function(ctx);
     2412        gl_set_quad_function(ctx);
     2413
     2414        if ((ctx->IndirectTriangles &
     2415              (DD_TRI_SW_RASTERIZE|DD_QUAD_SW_RASTERIZE|DD_TRI_CULL)) ==
     2416             (DD_TRI_SW_RASTERIZE|DD_QUAD_SW_RASTERIZE|DD_TRI_CULL))
     2417            ctx->IndirectTriangles &= ~DD_TRI_CULL;
    23782418      }
    23792419
    23802420      if (MESA_VERBOSE&VERBOSE_CULL)
    2381         gl_print_tri_caps("indirect tris 2", ctx->IndirectTriangles);
     2421        gl_print_tri_caps("indirect tris 2", ctx->IndirectTriangles);
    23822422
    23832423      gl_set_render_vb_function(ctx);
     
    23882428   if (ctx->NewState & (NEW_MODELVIEW|NEW_PROJECTION)) {
    23892429      if (ctx->NewState & NEW_MODELVIEW) {
    2390         gl_matrix_analyze( &ctx->ModelView );
    2391         ctx->ProjectionMatrix.flags &= ~MAT_DIRTY_DEPENDENTS;
     2430        gl_matrix_analyze( &ctx->ModelView );
     2431        ctx->ProjectionMatrix.flags &= ~MAT_DIRTY_DEPENDENTS;
    23922432      }
    23932433
    23942434      if (ctx->NewState & NEW_PROJECTION) {
    2395         gl_matrix_analyze( &ctx->ProjectionMatrix );
    2396         ctx->ProjectionMatrix.flags &= ~MAT_DIRTY_DEPENDENTS;
    2397 
    2398         if (ctx->Transform.AnyClip) {
    2399             gl_update_userclip( ctx );
    2400         }
     2435        gl_matrix_analyze( &ctx->ProjectionMatrix );
     2436        ctx->ProjectionMatrix.flags &= ~MAT_DIRTY_DEPENDENTS;
     2437
     2438        if (ctx->Transform.AnyClip) {
     2439            gl_update_userclip( ctx );
     2440        }
    24012441      }
    24022442
     
    24092449    */
    24102450   if ((ctx->Enabled & (ENABLE_POINT_ATTEN | ENABLE_LIGHT | ENABLE_FOG |
    2411                         ENABLE_TEXGEN0 | ENABLE_TEXGEN1)) &&
     2451                        ENABLE_TEXGEN0 | ENABLE_TEXGEN1)) &&
    24122452       (ctx->NewState & (NEW_LIGHTING |
    24132453                         NEW_FOG |
    2414                         NEW_MODELVIEW |
    2415                         NEW_PROJECTION |
    2416                         NEW_TEXTURING |
    2417                         NEW_RASTER_OPS |
    2418                         NEW_USER_CLIP)))
     2454                        NEW_MODELVIEW |
     2455                        NEW_PROJECTION |
     2456                        NEW_TEXTURING |
     2457                        NEW_RASTER_OPS |
     2458                        NEW_USER_CLIP)))
    24192459   {
    24202460      GLboolean oldcoord, oldnorm;
     
    24252465      ctx->NeedNormals = (ctx->Light.Enabled || ctx->Texture.NeedNormals);
    24262466      ctx->NeedEyeCoords = (ctx->FogMode == FOG_VERTEX ||
    2427                             ctx->Point.Attenuated);
     2467                            ctx->Point.Attenuated);
    24282468      ctx->NeedEyeNormals = GL_FALSE;
    24292469
    24302470      if (ctx->Light.Enabled) {
    2431         if (ctx->Light.Flags & LIGHT_POSITIONAL) {
    2432             /* Need length for attenuation */
    2433             if (!TEST_MAT_FLAGS( &ctx->ModelView, MAT_FLAGS_LENGTH_PRESERVING))
    2434                ctx->NeedEyeCoords = GL_TRUE;
    2435         } else if (ctx->Light.NeedVertices) {
    2436             /* Need angle for spot calculations */
    2437             if (!TEST_MAT_FLAGS( &ctx->ModelView, MAT_FLAGS_ANGLE_PRESERVING))
    2438                ctx->NeedEyeCoords = GL_TRUE;
    2439         }
    2440         ctx->NeedEyeNormals = ctx->NeedEyeCoords;
     2471        if (ctx->Light.Flags & LIGHT_POSITIONAL) {
     2472            /* Need length for attenuation */
     2473            if (!TEST_MAT_FLAGS( &ctx->ModelView, MAT_FLAGS_LENGTH_PRESERVING))
     2474               ctx->NeedEyeCoords = GL_TRUE;
     2475        } else if (ctx->Light.NeedVertices) {
     2476            /* Need angle for spot calculations */
     2477            if (!TEST_MAT_FLAGS( &ctx->ModelView, MAT_FLAGS_ANGLE_PRESERVING))
     2478               ctx->NeedEyeCoords = GL_TRUE;
     2479        }
     2480        ctx->NeedEyeNormals = ctx->NeedEyeCoords;
    24412481      }
    24422482      if (ctx->Texture.Enabled || ctx->RenderMode==GL_FEEDBACK) {
    2443         if (ctx->Texture.NeedEyeCoords) ctx->NeedEyeCoords = GL_TRUE;
    2444         if (ctx->Texture.NeedNormals)
    2445             ctx->NeedNormals = ctx->NeedEyeNormals = GL_TRUE;
     2483        if (ctx->Texture.NeedEyeCoords) ctx->NeedEyeCoords = GL_TRUE;
     2484        if (ctx->Texture.NeedNormals)
     2485            ctx->NeedNormals = ctx->NeedEyeNormals = GL_TRUE;
    24462486      }
    24472487
     
    24492489
    24502490      if (ctx->NeedEyeCoords)
    2451         ctx->vb_proj_matrix = &ctx->ProjectionMatrix;
     2491        ctx->vb_proj_matrix = &ctx->ProjectionMatrix;
    24522492
    24532493      if (ctx->Light.Enabled) {
    2454         gl_update_lighting_function(ctx);
    2455 
    2456         if ( (ctx->NewState & NEW_LIGHTING) ||
    2457               ((ctx->NewState & (NEW_MODELVIEW| NEW_PROJECTION)) &&
    2458                !ctx->NeedEyeCoords) ||
    2459               oldcoord != ctx->NeedEyeCoords ||
    2460               oldnorm != ctx->NeedEyeNormals) {
    2461             gl_compute_light_positions(ctx);
    2462         }
    2463 
    2464         ctx->rescale_factor = 1.0F;
    2465 
    2466         if (ctx->ModelView.flags & (MAT_FLAG_UNIFORM_SCALE |
    2467                                      MAT_FLAG_GENERAL_SCALE |
    2468                                      MAT_FLAG_GENERAL_3D |
    2469                                      MAT_FLAG_GENERAL) )
    2470 
    2471         {
    2472             GLfloat *m = ctx->ModelView.inv;
    2473             GLfloat f = m[2]*m[2] + m[6]*m[6] + m[10]*m[10];
    2474             if (f > 1e-12 && (f-1)*(f-1) > 1e-12)
    2475                ctx->rescale_factor = 1.0/GL_SQRT(f);
    2476         }
     2494        gl_update_lighting_function(ctx);
     2495
     2496        if ( (ctx->NewState & NEW_LIGHTING) ||
     2497              ((ctx->NewState & (NEW_MODELVIEW| NEW_PROJECTION)) &&
     2498               !ctx->NeedEyeCoords) ||
     2499              oldcoord != ctx->NeedEyeCoords ||
     2500              oldnorm != ctx->NeedEyeNormals) {
     2501            gl_compute_light_positions(ctx);
     2502        }
     2503
     2504        ctx->rescale_factor = 1.0F;
     2505
     2506        if (ctx->ModelView.flags & (MAT_FLAG_UNIFORM_SCALE |
     2507                                     MAT_FLAG_GENERAL_SCALE |
     2508                                     MAT_FLAG_GENERAL_3D |
     2509                                     MAT_FLAG_GENERAL) )
     2510
     2511        {
     2512            GLfloat *m = ctx->ModelView.inv;
     2513            GLfloat f = m[2]*m[2] + m[6]*m[6] + m[10]*m[10];
     2514            if (f > 1e-12 && (f-1)*(f-1) > 1e-12)
     2515               ctx->rescale_factor = 1.0/GL_SQRT(f);
     2516        }
    24772517      }
    24782518
Note: See TracChangeset for help on using the changeset viewer.