Changeset 2962 for trunk/src/opengl/mesa/context.c
- Timestamp:
- Mar 1, 2000, 7:50:02 PM (25 years ago)
- 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 sandervlExp $ */1 /* $Id: context.c,v 1.2 2000-03-01 18:49:25 jeroen Exp $ */ 2 2 3 3 /* … … 35 35 * the address space. 36 36 */ 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 37 46 38 47 #ifdef PC_HEADER … … 138 147 #ifdef THREADS 139 148 140 #include "mthreads.h" /* Mesa platform independent threads interface*/149 #include "mthreads.h" /* Mesa platform independent threads interface*/ 141 150 142 151 static MesaTSD mesa_ctx_tsd; … … 333 342 { 334 343 static GLboolean alreadyCalled = GL_FALSE; 344 335 345 if (!alreadyCalled) { 336 346 gl_init_clip(); … … 346 356 gl_init_vbxform(); 347 357 gl_init_vertices(); 358 #ifdef THREADS 359 mesa_ctx_thread_init(); 360 #endif 348 361 alreadyCalled = GL_TRUE; 349 362 } … … 1262 1275 1263 1276 ctx->VB = gl_vb_create_for_immediate( ctx ); 1277 1264 1278 if (!ctx->VB) { 1265 1279 FREE( ctx ); … … 1269 1283 1270 1284 ctx->PB = gl_alloc_pb(); 1285 1271 1286 if (!ctx->PB) { 1272 1287 FREE( ctx->VB ); … … 1382 1397 gl_matrix_dtr( &ctx->ModelView ); 1383 1398 for (i = 0 ; i < MAX_MODELVIEW_STACK_DEPTH ; i++) { 1384 1399 gl_matrix_dtr( &ctx->ModelViewStack[i] ); 1385 1400 } 1386 1401 gl_matrix_dtr( &ctx->ProjectionMatrix ); 1387 1402 for (i = 0 ; i < MAX_PROJECTION_STACK_DEPTH ; i++) { 1388 1403 gl_matrix_dtr( &ctx->ProjectionStack[i] ); 1389 1404 } 1390 1405 … … 1399 1414 assert(ctx->Shared->RefCount>=0); 1400 1415 if (ctx->Shared->RefCount==0) { 1401 1402 1416 /* free shared state */ 1417 free_shared_state( ctx, ctx->Shared ); 1403 1418 } 1404 1419 1405 1420 foreach_s( s, tmps, ctx->ShineTabList ) { 1406 1421 FREE( s ); 1407 1422 } 1408 1423 FREE( ctx->ShineTabList ); … … 1465 1480 if (ctx==CC) { 1466 1481 CC = NULL; 1467 1482 CURRENT_INPUT = NULL; 1468 1483 } 1469 1484 #endif … … 1540 1555 */ 1541 1556 if (CC) { 1542 1557 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(CC, "gl_make_current"); 1543 1558 } 1544 1559 … … 1551 1566 CC->Buffer = NULL; 1552 1567 } 1568 1553 1569 CC = ctx; 1554 1570 if (ctx) { 1555 1571 SET_IMMEDIATE(ctx, ctx->input); 1556 1572 } 1557 1573 #endif 1558 1559 if (MESA_VERBOSE) fprintf(stderr, "gl_make_current()\n");1560 1574 1561 1575 if (ctx && buffer) { 1562 1576 /* 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*/ 1565 1579 gl_update_state( ctx ); 1566 1580 } … … 1571 1585 * information. 1572 1586 */ 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 } 1582 1596 } 1583 1597 … … 1649 1663 } 1650 1664 if (mask & GL_POLYGON_STIPPLE_BIT) { 1665 #ifdef __WIN32OS2__ 1666 MEMCPY( &dst->PolygonStipple, &src->PolygonStipple, 32*sizeof(GLint) ); 1667 #else 1651 1668 /* Use loop instead of MEMCPY due to problem with Portland Group's 1652 1669 * C compiler. Reported by John Stone. … … 1656 1673 dst->PolygonStipple[i] = src->PolygonStipple[i]; 1657 1674 } 1675 #endif 1658 1676 } 1659 1677 if (mask & GL_SCISSOR_BIT) { … … 1707 1725 void gl_problem( const GLcontext *ctx, const char *s ) 1708 1726 { 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 1709 1731 fprintf( stderr, "Mesa implementation error: %s\n", s ); 1710 1732 fprintf( stderr, "Report to mesa-bugs@mesa3d.org\n" ); 1711 1733 (void) ctx; 1734 #endif 1712 1735 } 1713 1736 … … 1732 1755 } 1733 1756 #endif 1757 #ifdef __WIN32OS2__ 1758 dprintf(("OPENGL32: Mesa warning: %s\n", s )); 1759 #else 1734 1760 if (debug) { 1735 1761 fprintf( stderr, "Mesa warning: %s\n", s ); 1736 1762 } 1763 #endif 1737 1764 (void) ctx; 1738 1765 } … … 1772 1799 } 1773 1800 #endif 1774 1801 #ifdef __WIN32OS2__ 1802 { 1803 #else 1775 1804 if (debug) { 1805 #endif 1776 1806 char errstr[1000]; 1777 1807 1778 1808 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 1804 1837 fprintf( stderr, "Mesa user error: %s in %s\n", errstr, s ); 1838 #endif 1805 1839 } 1806 1840 … … 1844 1878 /* ask device driver for size of output buffer */ 1845 1879 (*ctx->Driver.GetBufferSize)( ctx, &buf_width, &buf_height ); 1880 1881 dprintf(("OPENGL32: gl_ResizeBuffersMESA - new w/h %d/%d\n",buf_width,buf_height)); 1846 1882 1847 1883 /* see if size of device driver's color buffer (window) has changed */ … … 1850 1886 return; 1851 1887 1852 ctx->NewState |= NEW_RASTER_OPS; /* to update scissor / window bounds*/1888 ctx->NewState |= NEW_RASTER_OPS; /* to update scissor / window bounds*/ 1853 1889 1854 1890 /* save buffer size */ … … 1872 1908 gl_alloc_alpha_buffers( ctx ); 1873 1909 } 1910 1911 #ifdef DIVE 1912 DiveResizeBuffers(ctx->Buffer->Width,ctx->Buffer->Height); 1913 #endif 1874 1914 } 1875 1915 … … 1892 1932 /* RGBA mode blending w/ Logic Op */ 1893 1933 if (ctx->Color.ColorLogicOpEnabled) { 1894 1934 if (ctx->Driver.LogicOp 1895 1935 && (*ctx->Driver.LogicOp)( ctx, ctx->Color.LogicOp )) { 1896 1897 1898 1899 1900 1901 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 } 1903 1943 } 1904 1944 else { 1905 1906 1945 /* no logic op */ 1946 if (ctx->Driver.LogicOp) { 1907 1947 (void) (*ctx->Driver.LogicOp)( ctx, GL_COPY ); 1908 1948 } 1909 1949 ctx->Color.SWLogicOpEnabled = GL_FALSE; 1910 1950 } 1911 1951 } … … 1913 1953 /* CI mode Logic Op */ 1914 1954 if (ctx->Color.IndexLogicOpEnabled) { 1915 1955 if (ctx->Driver.LogicOp 1916 1956 && (*ctx->Driver.LogicOp)( ctx, ctx->Color.LogicOp )) { 1917 1918 1919 1920 1921 1922 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 } 1924 1964 } 1925 1965 else { 1926 1927 1966 /* no logic op */ 1967 if (ctx->Driver.LogicOp) { 1928 1968 (void) (*ctx->Driver.LogicOp)( ctx, GL_COPY ); 1929 1969 } 1930 1970 ctx->Color.SWLogicOpEnabled = GL_FALSE; 1931 1971 } 1932 1972 } … … 1999 2039 2000 2040 if (ctx->Texture.Enabled || ctx->Hint.Fog == GL_NICEST) 2001 2041 ctx->FogMode = FOG_FRAGMENT; 2002 2042 2003 2043 if ( ctx->Driver.GetParameteri && 2004 2005 2044 ctx->Driver.GetParameteri( ctx, DD_HAVE_HARDWARE_FOG ) ) 2045 ctx->FogMode = FOG_FRAGMENT; 2006 2046 } 2007 2047 … … 2019 2059 ctx->RasterMask = 0; 2020 2060 2021 if (ctx->Color.AlphaEnabled) 2022 if (ctx->Color.BlendEnabled) 2023 if (ctx->Depth.Test) 2024 if (ctx->FogMode==FOG_FRAGMENT) 2025 if (ctx->Color.SWLogicOpEnabled) 2026 if (ctx->Scissor.Enabled) 2027 if (ctx->Stencil.Enabled) 2028 if (ctx->Color.SWmasking) 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; 2029 2069 2030 2070 if (ctx->Visual->SoftwareAlpha && ctx->Color.ColorMask[ACOMP] … … 2072 2112 { 2073 2113 fprintf(stderr, 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 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, " : ""); 2095 2135 } 2096 2136 … … 2098 2138 { 2099 2139 fprintf(stderr, 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 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, " : ""); 2114 2154 } 2115 2155 … … 2136 2176 if (ctx->NewState & NEW_TEXTURE_ENV) { 2137 2177 if (ctx->Texture.Unit[0].EnvMode == ctx->Texture.Unit[0].LastEnvMode && 2138 2139 2178 ctx->Texture.Unit[1].EnvMode == ctx->Texture.Unit[1].LastEnvMode) 2179 ctx->NewState &= ~NEW_TEXTURE_ENV; 2140 2180 ctx->Texture.Unit[0].LastEnvMode = ctx->Texture.Unit[0].EnvMode; 2141 2181 ctx->Texture.Unit[1].LastEnvMode = ctx->Texture.Unit[1].EnvMode; … … 2146 2186 2147 2187 for (i=0; i < MAX_TEXTURE_UNITS; i++) { 2148 2149 2150 2151 2152 2153 2154 2155 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 } 2157 2197 } 2158 2198 } … … 2165 2205 2166 2206 for (i=0; i < MAX_TEXTURE_UNITS; i++) { 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 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 } 2188 2228 } 2189 2229 … … 2196 2236 2197 2237 if (ctx->NewState & NEW_RASTER_OPS) { 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 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 } 2263 2303 } 2264 2304 2265 2305 if (ctx->NewState & NEW_LIGHTING) { 2266 2267 2268 2269 2270 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 } 2272 2312 } 2273 2313 } … … 2278 2318 2279 2319 if (ctx->NewState & NEW_POLYGON) { 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 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; 2319 2359 } 2320 2360 } 2321 2361 2322 2362 if (ctx->NewState & ~(NEW_CLIENT_STATE| 2323 2324 2363 NEW_DRIVER_STATE|NEW_USER_CLIP| 2364 NEW_POLYGON)) 2325 2365 gl_update_clipmask(ctx); 2326 2366 2327 2367 if (ctx->NewState & (NEW_LIGHTING| 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 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)) 2338 2378 { 2339 2379 ctx->IndirectTriangles = ctx->TriangleCaps & ~ctx->Driver.TriangleCaps; … … 2341 2381 2342 2382 if (MESA_VERBOSE&VERBOSE_CULL) 2343 2383 gl_print_tri_caps("initial indirect tris", ctx->IndirectTriangles); 2344 2384 2345 2385 ctx->Driver.PointsFunc = NULL; … … 2359 2399 2360 2400 if (MESA_VERBOSE&VERBOSE_CULL) 2361 2401 gl_print_tri_caps("indirect tris", ctx->IndirectTriangles); 2362 2402 2363 2403 /* … … 2367 2407 */ 2368 2408 if (ctx->IndirectTriangles & DD_SW_RASTERIZE) { 2369 2370 2371 2372 2373 2374 2375 2376 2377 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; 2378 2418 } 2379 2419 2380 2420 if (MESA_VERBOSE&VERBOSE_CULL) 2381 2421 gl_print_tri_caps("indirect tris 2", ctx->IndirectTriangles); 2382 2422 2383 2423 gl_set_render_vb_function(ctx); … … 2388 2428 if (ctx->NewState & (NEW_MODELVIEW|NEW_PROJECTION)) { 2389 2429 if (ctx->NewState & NEW_MODELVIEW) { 2390 2391 2430 gl_matrix_analyze( &ctx->ModelView ); 2431 ctx->ProjectionMatrix.flags &= ~MAT_DIRTY_DEPENDENTS; 2392 2432 } 2393 2433 2394 2434 if (ctx->NewState & NEW_PROJECTION) { 2395 2396 2397 2398 2399 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 } 2401 2441 } 2402 2442 … … 2409 2449 */ 2410 2450 if ((ctx->Enabled & (ENABLE_POINT_ATTEN | ENABLE_LIGHT | ENABLE_FOG | 2411 2451 ENABLE_TEXGEN0 | ENABLE_TEXGEN1)) && 2412 2452 (ctx->NewState & (NEW_LIGHTING | 2413 2453 NEW_FOG | 2414 2415 2416 2417 2418 2454 NEW_MODELVIEW | 2455 NEW_PROJECTION | 2456 NEW_TEXTURING | 2457 NEW_RASTER_OPS | 2458 NEW_USER_CLIP))) 2419 2459 { 2420 2460 GLboolean oldcoord, oldnorm; … … 2425 2465 ctx->NeedNormals = (ctx->Light.Enabled || ctx->Texture.NeedNormals); 2426 2466 ctx->NeedEyeCoords = (ctx->FogMode == FOG_VERTEX || 2427 2467 ctx->Point.Attenuated); 2428 2468 ctx->NeedEyeNormals = GL_FALSE; 2429 2469 2430 2470 if (ctx->Light.Enabled) { 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 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; 2441 2481 } 2442 2482 if (ctx->Texture.Enabled || ctx->RenderMode==GL_FEEDBACK) { 2443 2444 2445 2483 if (ctx->Texture.NeedEyeCoords) ctx->NeedEyeCoords = GL_TRUE; 2484 if (ctx->Texture.NeedNormals) 2485 ctx->NeedNormals = ctx->NeedEyeNormals = GL_TRUE; 2446 2486 } 2447 2487 … … 2449 2489 2450 2490 if (ctx->NeedEyeCoords) 2451 2491 ctx->vb_proj_matrix = &ctx->ProjectionMatrix; 2452 2492 2453 2493 if (ctx->Light.Enabled) { 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 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 } 2477 2517 } 2478 2518
Note:
See TracChangeset
for help on using the changeset viewer.