Changeset 25383 in vbox for trunk/src/VBox/Additions/common/crOpenGL
- Timestamp:
- Dec 15, 2009 7:26:20 AM (15 years ago)
- Location:
- trunk/src/VBox/Additions/common/crOpenGL
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/crOpenGL/glx.c
r24817 r25383 1333 1333 VBOXGLXTAG(glXCreatePixmap)(Display *dpy, GLXFBConfig config, Pixmap pixmap, const ATTRIB_TYPE *attrib_list) 1334 1334 { 1335 ATTRIB_TYPE *attrib; 1336 XVisualInfo *pVis; 1337 GLX_Pixmap_t *pGlxPixmap; 1335 1338 (void) dpy; 1336 1339 (void) config; 1337 (void) attrib_list; 1338 1340 1341 pGlxPixmap = crCalloc(sizeof(GLX_Pixmap_t)); 1342 if (!pGlxPixmap) 1343 { 1344 crWarning("glXCreatePixmap failed to allocate memory"); 1345 return 0; 1346 } 1347 1348 pVis = VBOXGLXTAG(glXGetVisualFromFBConfig)(dpy, config); 1349 if (!pVis) 1350 { 1351 crWarning("Unknown config 0x%x in glXCreatePixmap", (unsigned int) config); 1352 return 0; 1353 } 1354 1355 pGlxPixmap->format = pVis->depth==24 ? GL_RGB:GL_RGBA; 1356 pGlxPixmap->target = GL_TEXTURE_2D; 1357 1358 if (attrib_list) 1359 { 1360 for (attrib = attrib_list; *attrib != None; attrib++) 1361 { 1362 switch (*attrib) 1363 { 1364 case GLX_TEXTURE_FORMAT_EXT: 1365 attrib++; 1366 switch (*attrib) 1367 { 1368 case GLX_TEXTURE_FORMAT_RGBA_EXT: 1369 pGlxPixmap->format = GL_RGBA; 1370 break; 1371 case GLX_TEXTURE_FORMAT_RGB_EXT: 1372 pGlxPixmap->format = GL_RGB; 1373 break; 1374 default: 1375 crDebug("Unexpected GLX_TEXTURE_FORMAT_EXT 0x%x", (unsigned int) *attrib); 1376 } 1377 break; 1378 case GLX_TEXTURE_TARGET_EXT: 1379 attrib++; 1380 switch (*attrib) 1381 { 1382 case GLX_TEXTURE_2D_EXT: 1383 pGlxPixmap->target = GL_TEXTURE_2D; 1384 break; 1385 case GLX_TEXTURE_RECTANGLE_EXT: 1386 pGlxPixmap->target = GL_TEXTURE_RECTANGLE_NV; 1387 break; 1388 default: 1389 crDebug("Unexpected GLX_TEXTURE_TARGET_EXT 0x%x", (unsigned int) *attrib); 1390 } 1391 break; 1392 default: attrib++; 1393 } 1394 } 1395 } 1396 1397 crHashtableAdd(stub.pGLXPixmapsHash, (unsigned int) pixmap, pGlxPixmap); 1339 1398 return (GLXPixmap) pixmap; 1340 1399 } … … 1438 1497 { 1439 1498 XVisualInfo * pVisual; 1440 1441 pVisual = glXGetVisualFromFBConfig(dpy, config); 1499 const char * pExt; 1500 1501 pVisual = VBOXGLXTAG(glXGetVisualFromFBConfig)(dpy, config); 1442 1502 if (!pVisual) 1443 1503 { … … 1455 1515 case GLX_BIND_TO_TEXTURE_TARGETS_EXT: 1456 1516 *value = GLX_TEXTURE_2D_BIT_EXT; 1517 pExt = (const char *) stub.spu->dispatch_table.GetString(GL_EXTENSIONS); 1518 if (crStrstr(pExt, "GL_NV_texture_rectangle") 1519 || crStrstr(pExt, "GL_ARB_texture_rectangle") 1520 || crStrstr(pExt, "GL_EXT_texture_rectangle")) 1521 { 1522 *value |= GLX_TEXTURE_RECTANGLE_BIT_EXT; 1523 } 1457 1524 break; 1458 1525 case GLX_BIND_TO_TEXTURE_RGBA_EXT: 1459 //crDebug("attribute=GLX_BIND_TO_TEXTURE_RGBA_EXT"); 1460 *value = True; 1526 *value = pVisual->depth==32; 1461 1527 break; 1462 1528 case GLX_BIND_TO_TEXTURE_RGB_EXT: … … 1838 1904 } 1839 1905 1840 static GLX_Pixmap_t* stubInitGlxPixmap( Display *dpy, GLXDrawable draw, ContextInfo *pContext)1906 static GLX_Pixmap_t* stubInitGlxPixmap(GLX_Pixmap_t* pCreateInfoPixmap, Display *dpy, GLXDrawable draw, ContextInfo *pContext) 1841 1907 { 1842 1908 int x, y; … … 1847 1913 GLX_Pixmap_t *pGlxPixmap; 1848 1914 1849 CRASSERT(pContext );1915 CRASSERT(pContext && pCreateInfoPixmap); 1850 1916 1851 1917 if (!XGetGeometry(dpy, (Pixmap)draw, &root, &x, &y, &w, &h, &border, &depth)) … … 1873 1939 pGlxPixmap->depth = depth; 1874 1940 pGlxPixmap->root = root; 1875 pGlxPixmap->format = pGlxPixmap->depth==24 ? GL_RGB : GL_RGBA; 1941 pGlxPixmap->format = pCreateInfoPixmap->format; 1942 pGlxPixmap->target = pCreateInfoPixmap->target; 1876 1943 1877 1944 /* Try to allocate shared memory … … 1910 1977 if (!pGlxPixmap->pDamageRegion) 1911 1978 { 1912 crWarning("stubInitGlxPixmap failed to create emp y damage region for drawable 0x%x", (unsigned int) draw);1979 crWarning("stubInitGlxPixmap failed to create empty damage region for drawable 0x%x", (unsigned int) draw); 1913 1980 } 1914 1981 … … 1927 1994 if (CR_MAX_TRANSFER_SIZE < 4*pGlxPixmap->w*pGlxPixmap->h) 1928 1995 { 1929 stub.spu->dispatch_table.TexImage2D( GL_TEXTURE_2D, 0, pGlxPixmap->format, pGlxPixmap->w, pGlxPixmap->h, 0,1996 stub.spu->dispatch_table.TexImage2D(pGlxPixmap->target, 0, pGlxPixmap->format, pGlxPixmap->w, pGlxPixmap->h, 0, 1930 1997 GL_BGRA, GL_UNSIGNED_BYTE, NULL); 1931 1998 } 1932 1999 1933 2000 crHashtableAdd(pContext->pGLXPixmapsHash, (unsigned int) draw, pGlxPixmap); 2001 crHashtableDelete(stub.pGLXPixmapsHash, (unsigned int) draw, crFree); 1934 2002 1935 2003 return pGlxPixmap; … … 1972 2040 /* Have to make sure XCopyArea is processed */ 1973 2041 XSync(dpy, False); 1974 stub.spu->dispatch_table.TexImage2D( GL_TEXTURE_2D, 0, pGlxPixmap->format, pGlxPixmap->w, pGlxPixmap->h, 0,2042 stub.spu->dispatch_table.TexImage2D(pGlxPixmap->target, 0, pGlxPixmap->format, pGlxPixmap->w, pGlxPixmap->h, 0, 1975 2043 GL_BGRA, GL_UNSIGNED_BYTE, stub.xshmSI.shmaddr); 1976 2044 /*crDebug("Sync texture for drawable 0x%x(dmg handle 0x%x) [%i,%i,%i,%i]", … … 2021 2089 stub.spu->dispatch_table.PixelStorei(GL_UNPACK_ROW_LENGTH, pGlxPixmap->w); 2022 2090 } 2023 stub.spu->dispatch_table.TexSubImage2D( GL_TEXTURE_2D, 0, pRect->x, pRect->y, pRect->width, pRect->height,2091 stub.spu->dispatch_table.TexSubImage2D(pGlxPixmap->target, 0, pRect->x, pRect->y, pRect->width, pRect->height, 2024 2092 GL_BGRA, GL_UNSIGNED_BYTE, stub.xshmSI.shmaddr); 2025 2093 if (pRect->width!=pGlxPixmap->w) … … 2063 2131 GLX_Pixmap_t *pGlxPixmap; 2064 2132 2065 crDebug("->glXBindTexImageEXT");2066 2067 2133 if (!stub.currentContext) 2068 2134 { … … 2074 2140 if (!pGlxPixmap) 2075 2141 { 2076 /*Not a fault, just setup the desired information, see comment for glXCreatePixmap function*/ 2077 pGlxPixmap = stubInitGlxPixmap(dpy, draw, stub.currentContext); 2078 2079 if (!pGlxPixmap) return; 2142 pGlxPixmap = (GLX_Pixmap_t *) crHashtableSearch(stub.pGLXPixmapsHash, (unsigned int) draw); 2143 if (!pGlxPixmap) 2144 { 2145 crDebug("Unknown drawable 0x%x in glXBindTexImageEXT!", (unsigned int) draw); 2146 return; 2147 } 2148 pGlxPixmap = stubInitGlxPixmap(pGlxPixmap, dpy, draw, stub.currentContext); 2149 if (!pGlxPixmap) 2150 { 2151 crDebug("glXBindTexImageEXT failed to get pGlxPixmap"); 2152 return; 2153 } 2080 2154 } 2081 2155 … … 2131 2205 } 2132 2206 2133 stub.spu->dispatch_table.TexImage2D( GL_TEXTURE_2D, 0, pGlxPixmap->format, pxim->width, pxim->height, 0,2207 stub.spu->dispatch_table.TexImage2D(pGlxPixmap->target, 0, pGlxPixmap->format, pxim->width, pxim->height, 0, 2134 2208 GL_BGRA, GL_UNSIGNED_BYTE, (void*)(&(pxim->data[0]))); 2135 2209 XDestroyImage(pxim); -
trunk/src/VBox/Additions/common/crOpenGL/load.c
r22591 r25383 257 257 shmdt(stub.xshmSI.shmaddr); 258 258 } 259 #endif 259 crFreeHashtable(stub.pGLXPixmapsHash, crFree); 260 #endif 261 262 crFreeHashtable(stub.windowTable, crFree); 263 crFreeHashtable(stub.contextTable, NULL); 260 264 261 265 crMemset(&stub, 0, sizeof(stub) ); … … 644 648 stub.xshmSI.shmid = -1; 645 649 stub.bShmInitFailed = GL_FALSE; 650 stub.pGLXPixmapsHash = crAllocHashtable(); 646 651 #endif 647 652 -
trunk/src/VBox/Additions/common/crOpenGL/stub.h
r24816 r25383 75 75 GLenum format; 76 76 Window root; 77 GLenum target; 77 78 GC gc; 78 79 Pixmap hShmPixmap; /* Shared memory pixmap object, if it's supported*/ … … 207 208 XShmSegmentInfo xshmSI; 208 209 GLboolean bShmInitFailed; 210 211 CRHashTable *pGLXPixmapsHash; 209 212 #endif 210 213
Note:
See TracChangeset
for help on using the changeset viewer.