Changeset 2962 for trunk/src/opengl/mesa/wmesa.c
- Timestamp:
- Mar 1, 2000, 7:50:02 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/mesa/wmesa.c
r2938 r2962 1 /* $Id: wmesa.c,v 1. 1 2000-02-29 00:50:15 sandervlExp $ */1 /* $Id: wmesa.c,v 1.2 2000-03-01 18:49:40 jeroen Exp $ */ 2 2 3 3 /* … … 23 23 /* 24 24 * $Log: wmesa.c,v $ 25 * Revision 1. 1 2000-02-29 00:50:15 sandervl26 * created25 * Revision 1.2 2000-03-01 18:49:40 jeroen 26 * *** empty log message *** 27 27 * 28 28 * Revision 1.1.1.1 1999/08/19 00:55:42 jtg … … 67 67 #define WMESA_STEREO_C 68 68 69 #ifdef __WIN32OS2__ 70 #include <os2win.h> 71 #else 69 72 #include <windows.h> 73 #endif 70 74 #include <stdio.h> 71 75 #include <stdlib.h> … … 74 78 #include "colors.h" 75 79 #include "macros.h" 80 #include "types.h" 76 81 #include "context.h" 77 82 #include "dd.h" … … 84 89 #ifndef __WIN32OS2__ 85 90 #pragma warning ( disable : 4133 4761 ) 91 #else 92 #ifdef DIVE 93 #include <mesadive.h> 94 extern HWND Win32ToOS2Handle(HWND); 95 #endif 86 96 #endif 87 97 … … 122 132 /* end of added code*/ 123 133 124 staticPWMC Current = NULL;134 PWMC Current = NULL; 125 135 WMesaContext WC = NULL; 126 136 … … 134 144 char Msg[512]; 135 145 sprintf(Msg,"%s %s %d",Cond,File,Line); 146 #ifdef __WIN32OS2__ 147 dprintf((Msg,"%s %s %d",Cond,File,Line)); 148 #endif 136 149 MessageBox(NULL,Msg,"Assertion failed.",MB_OK); 137 150 exit(1); … … 214 227 static void wmSetPixelFormat( PWMC wc, HDC hDC) 215 228 { 229 dprintf(("OPENGL32: Setting PixelFormat\n")); 230 231 #ifdef DIVE 232 wc->cColorBits=DiveQueryDepth(); 233 234 wc->pixelformat=DiveQueryNativePixelFormat(); 235 #else 216 236 if(wc->rgb_flag) 217 237 wc->cColorBits = GetDeviceCaps(hDC, BITSPIXEL); 218 238 else 219 wc->cColorBits = 8; 239 wc->cColorBits = 8; 240 220 241 switch(wc->cColorBits){ 221 242 case 8: … … 225 246 wc->pixelformat = PF_DITHER8; 226 247 break; 248 227 249 case 16: 228 250 wc->pixelformat = PF_5R6G5B; 229 251 break; 252 230 253 case 32: 231 254 wc->pixelformat = PF_8R8G8B; 232 255 break; 233 default: 256 257 default: /* This also handles 24 bpp*/ 234 258 wc->pixelformat = PF_BADFORMAT; 235 } 259 break; 260 } 261 #endif 262 263 dprintf(("OPENGL32: Color Bits: %d\n",wc->cColorBits)); 236 264 } 237 265 238 266 // 239 // This function sets the color table of a DIB section 240 // to match that of the destination DC 267 /* This function sets the color table of a DIB section*/ 268 /* to match that of the destination DC*/ 241 269 // 242 270 BOOL /*WINAPI*/ wmSetDibColors(PWMC pwc) … … 297 325 LPBITMAPINFO pbmi = &(pwc->bmi); 298 326 int iUsage; 327 328 dprintf(("OPENGL32: Creating BackingStore for %08X\n",pwc)); 299 329 300 330 pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); … … 341 371 DWORD dwScanWidth = (uiScanWidth * nBypp); 342 372 343 dprintf(("OPENGL32: wmSetDIBits\n"));344 345 373 // 346 374 // We need to round up to the nearest DWORD … … 400 428 } 401 429 ENDPROFILE(flush) 402 403 } 404 405 430 } 406 431 407 432 /* … … 433 458 * or index as specified by one of the two functions above. 434 459 */ 435 //static void clear(GLcontext* ctx, 436 // GLboolean all,GLint x, GLint y, GLint width, GLint height ) 437 / / TODO: I modified this function to match the prototype in dd.h. (swansma@geocities.com)438 / / dd.h does not explain what the return type is so I could not set this to the proper439 // value. 460 /* static void clear(GLcontext* ctx,*/ 461 /* GLboolean all,GLint x, GLint y, GLint width, GLint height )*/ 462 /* TODO: I modified this function to match the prototype in dd.h. (swansma@geocities.com)*/ 463 /* dd.h does not explain what the return type is so I could not set this to the proper*/ 464 /* value. */ 440 465 static GLbitfield clear(GLcontext* ctx, GLbitfield mask, 441 466 GLboolean all, GLint x, GLint y, GLint width, GLint height) … … 449 474 int lines; 450 475 451 dprintf(("OPENGL32: clear\n")); 476 dprintf(("OPENGL32: clear - all %08d - x %d - y %d - width %d - height %d\n", 477 all,x,y,width,height)); 452 478 453 479 STARTPROFILE … … 458 484 height=Current->height; 459 485 } 486 487 dprintf(("OPENGL32: clear - all %08d - x %d - y %d - width %d - height %d\n", 488 all,x,y,width,height)); 489 460 490 if(Current->db_flag==GL_TRUE){ 461 491 UINT nBypp = Current->cColorBits / 8; 462 492 int i = 0; 463 493 int iSize = 0; 494 495 dprintf(("OPENGL32: Clearing BackBuffer\n")); 464 496 465 497 if(nBypp ==1 ){ … … 520 552 while (i<lines-1); 521 553 } 522 else { // For single buffer 554 else 555 { /* For single buffer*/ 556 dprintf(("OPENGL32: Clearing FrontBuffer\n")); 557 523 558 HDC DC=DD_GETDC; 559 560 dprintf(("OPENGL32: Clearing FrontBuffer DC is %08X\n",DC)); 561 524 562 HPEN Pen=CreatePen(PS_SOLID,1,Current->clearpixel); 525 563 HBRUSH Brush=CreateSolidBrush(Current->clearpixel); 526 564 HPEN Old_Pen=SelectObject(DC,Pen); 527 565 HBRUSH Old_Brush=SelectObject(DC,Brush); 528 // Rectangle(DC,x,y,x+width,y+height); 566 567 Rectangle(DC,x,y,x+width,y+height); 568 529 569 SelectObject(DC,Old_Pen); 530 570 SelectObject(DC,Old_Brush); 531 571 DeleteObject(Pen); 532 572 DeleteObject(Brush); 573 533 574 DD_RELEASEDC; 534 } 535 536 575 } 537 576 538 577 ENDPROFILE(clear) 539 578 540 return mask; // TODO: I doubt this is correct. dd.h doesn't explain what this should541 // be...579 return mask;/* TODO: I doubt this is correct. dd.h doesn't explain what this should*/ 580 /* be... */ 542 581 } 543 582 … … 640 679 641 680 STARTPROFILE 681 642 682 GetClientRect(Current->Window,&CR); 643 683 … … 651 691 Current->height=*height; 652 692 Current->ScanWidth=Current->width; 693 653 694 if ((Current->ScanWidth%sizeof(long))!=0) 654 695 Current->ScanWidth+=(sizeof(long)-(Current->ScanWidth%sizeof(long))); 655 696 656 697 if (Current->db_flag){ 698 #ifdef DIVE 699 if(!DiveDirectAccess()) 700 if (Current->rgb_flag==GL_TRUE && Current->dither_flag!=GL_TRUE){ 701 wmDeleteBackingStore(Current); 702 wmCreateBackingStore(Current, Current->width, Current->height); 703 } 704 #else 657 705 #ifdef DDRAW 658 706 DDDeleteOffScreen(Current); … … 663 711 wmCreateBackingStore(Current, Current->width, Current->height); 664 712 } 713 #endif 665 714 #endif 666 715 } … … 719 768 } 720 769 } 721 // DD_RELEASEDC; 770 771 /* DD_RELEASEDC; */ 722 772 ENDPROFILE(fast_rgb_points) 723 773 } … … 753 803 754 804 if (0 /*Current->gl_ctx->VB->MonoColor*/) { 755 pixel = Current->pixel; /* use current color*/805 pixel = Current->pixel; /* use current color*/ 756 806 } 757 807 else { 758 pixel = RGB((GLubyte)(Current->gl_ctx->VB->ColorPtr->data[pv][0]), 759 (GLubyte)(Current->gl_ctx->VB->ColorPtr->data[pv][1]), 760 (GLubyte)(Current->gl_ctx->VB->ColorPtr->data[pv][2])); 808 dprintf(("OPENGL32: READADDR: %08X - pv %d - LINE R-G-B is %d,%d,%d\n", 809 Current->gl_ctx->VB->ColorPtr->data[pv], 810 pv, 811 Current->gl_ctx->VB->ColorPtr->data[pv][0], 812 Current->gl_ctx->VB->ColorPtr->data[pv][1], 813 Current->gl_ctx->VB->ColorPtr->data[pv][2])); 814 815 pixel = RGB((GLubyte)(Current->gl_ctx->VB->ColorPtr->data[pv][0]/* *255.0*/), 816 (GLubyte)(Current->gl_ctx->VB->ColorPtr->data[pv][1]/* *255.0*/), 817 (GLubyte)(Current->gl_ctx->VB->ColorPtr->data[pv][2]/* *255.0*/)); 818 819 dprintf(("OPENGL32: PIXEL set to %08X",pixel)); 761 820 } 762 821 … … 769 828 BEGINGDICALL 770 829 771 Pen=CreatePen(PS_SOLID,1, pixel);830 Pen=CreatePen(PS_SOLID,1,(COLORREF)pixel); 772 831 Old_Pen=SelectObject(DC,Pen); 773 832 MoveToEx(DC,x0,y0,NULL); … … 902 961 } 903 962 } 963 904 964 ENDPROFILE(write_rgba_span) 905 965 … … 945 1005 } 946 1006 } 1007 947 1008 ENDPROFILE(write_rgb_span) 948 1009 … … 963 1024 assert(Current->rgb_flag==GL_TRUE); 964 1025 y=FLIP(y); 1026 965 1027 if(Current->rgb_flag==GL_TRUE){ 966 1028 for (i=0; i<n; i++) 967 1029 if (mask[i]) 968 // Trying1030 /* Trying */ 969 1031 wmSetPixel(pwc,y,x+i,GetRValue(Current->pixel), GetGValue(Current->pixel), GetBValue(Current->pixel)); 970 1032 } … … 975 1037 } 976 1038 DD_RELEASEDC; 1039 977 1040 ENDPROFILE(write_mono_rgba_span) 978 1041 } … … 1033 1096 { 1034 1097 STARTPROFILE 1098 1035 1099 GLuint i; 1036 1100 PWMC pwc = Current; 1037 1101 HDC DC=DD_GETDC; 1038 1102 assert(Current->rgb_flag==GL_TRUE); 1103 1039 1104 for (i=0; i<n; i++) 1040 1105 if (mask[i]) 1041 1106 wmSetPixel(pwc, FLIP(y[i]),x[i],rgba[i][RCOMP],rgba[i][GCOMP],rgba[i][BCOMP]); 1107 1042 1108 DD_RELEASEDC; 1043 1109 ENDPROFILE(write_rgba_pixels) … … 1060 1126 HDC DC=DD_GETDC; 1061 1127 assert(Current->rgb_flag==GL_TRUE); 1128 1062 1129 for (i=0; i<n; i++) 1063 1130 if (mask[i]) 1064 1131 wmSetPixel(pwc, FLIP(y[i]),x[i],GetRValue(Current->pixel), 1065 1132 GetGValue(Current->pixel), GetBValue(Current->pixel)); 1133 1066 1134 DD_RELEASEDC; 1067 1135 ENDPROFILE(write_mono_rgba_pixels) … … 1285 1353 } 1286 1354 1287 1288 WMesaContext WMesaCreateContext( HWND hWnd, HPALETTE* Pal, 1355 void WMesaUpdateScreenPos(PWMC c,HWND hWnd) 1356 { 1357 RECT CR; 1358 1359 GetWindowRect(hWnd,&CR); 1360 1361 c->WinPos.x=CR.left+GetSystemMetrics(SM_CXFRAME); 1362 c->WinPos.y=CR.top+GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYFRAME); 1363 1364 c->width=CR.right-CR.left-2*GetSystemMetrics(SM_CXFRAME); 1365 c->height=CR.bottom-CR.top-GetSystemMetrics(SM_CYCAPTION)-2*GetSystemMetrics(SM_CYFRAME); 1366 1367 dprintf(("OPENGL32: WMesaUpdateScreenPos %08X - x/y %d/%d, w/h %d/%d\n", 1368 hWnd, 1369 c->WinPos.x, 1370 c->WinPos.y, 1371 c->width, 1372 c->height)); 1373 } 1374 1375 WMesaContext WIN32API WMesaCreateContext( HWND hWnd, HPALETTE* Pal, 1289 1376 GLboolean rgb_flag, 1290 1377 GLboolean db_flag ) … … 1294 1381 GLboolean true_color_flag; 1295 1382 c = (struct wmesa_context * ) calloc(1,sizeof(struct wmesa_context)); 1383 1384 dprintf(("OPENGL32: Creating MESA Context (%s)\n", 1385 db_flag?"DOUBLE BUFFERED":"SINGLE_BUFFERED")); 1386 1296 1387 if (!c) 1297 1388 return NULL; … … 1300 1391 c->hDC = GetDC(hWnd); 1301 1392 true_color_flag = GetDeviceCaps(c->hDC, BITSPIXEL) > 8; 1302 #ifdef DDRAW 1393 1394 #if defined(DDRAW) || defined(DIVE) 1303 1395 if(true_color_flag) c->rgb_flag = rgb_flag = GL_TRUE; 1304 1396 #endif … … 1316 1408 #endif 1317 1409 1410 dprintf(("OPENGL32: WMesaCreateContext - db_flag is %d\n",db_flag)); 1318 1411 1319 1412 if (rgb_flag==GL_FALSE) 1320 1413 { 1321 1414 c->rgb_flag = GL_FALSE; 1322 // c->pixel = 1; 1323 c->db_flag = db_flag =GL_TRUE; // WinG requires double buffering 1324 printf("Single buffer is not supported in color index mode, setting to double buffer.\n"); 1415 #ifndef DIVE 1416 c->db_flag = db_flag =GL_TRUE; /* WinG requires double buffering*/ 1417 1418 dprintf(("OPENGL32: Single buffer is not supported in color index mode, setting to double buffer.\n")); 1419 #endif 1325 1420 } 1326 1421 else 1327 1422 { 1328 1423 c->rgb_flag = GL_TRUE; 1329 // c->pixel = 0; 1330 } 1424 /* c->pixel = 0; */ 1425 } 1426 1331 1427 GetClientRect(c->Window,&CR); 1428 1332 1429 c->width=CR.right; 1333 1430 c->height=CR.bottom; 1431 1334 1432 if (db_flag) 1335 1433 { 1336 1434 c->db_flag = 1; 1337 1435 /* Double buffered */ 1338 #if ndef DDRAW1339 // if (c->rgb_flag==GL_TRUE && c->dither_flag != GL_TRUE )1436 #if !defined(DDRAW) && !defined(DIVE) 1437 /* if (c->rgb_flag==GL_TRUE && c->dither_flag != GL_TRUE )*/ 1340 1438 { 1341 1439 wmCreateBackingStore(c, c->width, c->height); 1342 1440 1343 1441 } 1442 #else 1443 #ifdef DIVE 1444 /* Dive direct access unavailable - switch to DIB mode */ 1445 if(!DiveDirectAccess()) 1446 wmCreateBackingStore(c, c->width, c->height); 1447 #endif 1344 1448 #endif 1345 1449 } … … 1350 1454 c->db_flag = 0; 1351 1455 } 1456 1457 /* Also set the correct PixelFormat now! */ 1458 wmSetPixelFormat(c, c->hDC); 1459 1460 #ifdef DIVE 1461 /* Store window position for DIVE draws - all x/y's are relative to this */ 1462 /* base position of the screen... */ 1463 dprintf(("OPENGL32: Creating context (%08X)\n",c)); 1464 1465 WMesaUpdateScreenPos(c,hWnd); 1466 1467 if(DiveDirectAccess()) 1468 if(!DiveInit(c,hWnd)) 1469 { 1470 free( (void *) c ); 1471 Current=0; 1472 dprintf(("OPENGL32: DIVEINIT failed - exiting!\n")); 1473 MessageBoxA( hWnd, "Dive Init FAILED", "", MB_OK ); 1474 exit(1); 1475 } 1476 #else 1352 1477 #ifdef DDRAW 1353 1478 if (DDInit(c,hWnd) == GL_FALSE) { 1354 1479 free( (void *) c ); 1480 dprintf(("OPENGL32: DIVEINIT failed - exiting!\n")); 1355 1481 exit(1); 1356 1482 } 1357 1483 #endif 1358 1484 #endif 1485 1486 /* JvdH - Enable software Alpha! (was FALSE!!) */ 1359 1487 1360 1488 c->gl_visual = gl_create_visual(rgb_flag, 1361 GL_ FALSE, /* software alpha*/1362 db_flag, /* db_flag*/1363 GL_FALSE, /* stereo*/1364 16, /* depth_bits*/1365 8, /* stencil_bits*/1366 8, /* accum_bits*/1367 0, /* index bits*/1368 8,8,8,8 ); /* r, g, b, a bits*/1489 GL_TRUE, /* software alpha*/ 1490 db_flag, /* db_flag*/ 1491 GL_FALSE, /* stereo*/ 1492 16, /* depth_bits*/ 1493 8, /* stencil_bits*/ 1494 8, /* accum_bits*/ 1495 0, /* index bits*/ 1496 8,8,8,8 ); /* r, g, b, a bits*/ 1369 1497 1370 1498 if (!c->gl_visual) { … … 1382 1510 1383 1511 c->gl_buffer = gl_create_framebuffer( c->gl_visual ); 1512 1384 1513 if (!c->gl_buffer) { 1385 1514 gl_destroy_visual( c->gl_visual ); … … 1389 1518 } 1390 1519 1391 c->gl_ctx->Driver.UpdateState = setup_DD_pointers; 1392 1393 // setup_DD_pointers(c->gl_ctx); 1520 c->gl_ctx->Driver.UpdateState = setup_DD_pointers; 1521 1522 /* setup_DD_pointers(c->gl_ctx); */ 1523 1524 dprintf(("OPENGL32: Created context %08X - (%s)\n",c,c->db_flag?"DOUBLE":"SINGLE")); 1394 1525 1395 1526 return c; 1396 1527 } 1397 1528 1398 void W MesaDestroyContext( void )1529 void WIN32API WMesaDestroyContext( void ) 1399 1530 { 1400 1531 WMesaContext c = Current; 1532 1401 1533 ReleaseDC(c->Window,c->hDC); 1534 1402 1535 WC = c; 1536 1403 1537 if(c->hPalHalfTone != NULL) 1404 1538 DeleteObject(c->hPalHalfTone); 1539 1405 1540 gl_destroy_visual( c->gl_visual ); 1406 1541 gl_destroy_framebuffer( c->gl_buffer ); … … 1408 1543 1409 1544 if (c->db_flag) 1545 #ifdef DIVE 1546 if(DiveDirectAccess()) 1547 { 1548 DiveFree(c); 1549 /* Clean up the screen on exit */ 1550 RedrawWindow( NULL, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | 1551 RDW_ALLCHILDREN ); 1552 } 1553 else 1554 wmDeleteBackingStore(c); 1555 #else 1410 1556 #ifdef DDRAW 1557 { 1411 1558 DDFree(c); 1559 } 1412 1560 #else 1413 1561 wmDeleteBackingStore(c); 1414 1562 #endif 1563 #endif 1415 1564 free( (void *) c ); 1416 //Following code is added to enable parallel render 1417 // Parallel render only work in double buffer mode 1565 1566 /* Set current context to 0, otherwise exitlist-routine will trap */ 1567 Current=0; 1568 /* Following code is added to enable parallel render*/ 1569 /* Parallel render only work in double buffer mode*/ 1418 1570 #if !defined(NO_PARALLEL) 1419 1571 if(parallelMachine) 1420 1572 PRDestroyRenderBuffer(); 1421 1573 #endif 1422 // End modification 1423 } 1424 1425 1574 /* End modification */ 1575 } 1426 1576 1427 1577 void WIN32API WMesaMakeCurrent( WMesaContext c ) 1428 1578 { 1579 dprintf(("OPENGL32: WMesaMakeCurrent %08X\n",c)); 1580 1429 1581 if(!c){ 1430 1582 Current = c; … … 1459 1611 { 1460 1612 HDC DC = Current->hDC; 1613 1614 dprintf(("OPENGL32: WMesaSwapBuffers() - Current %08X (%s)\n", 1615 Current,Current->db_flag?"DOUBLE":"SINGLE")); 1616 1461 1617 if (Current->db_flag) 1462 1618 wmFlush(Current); … … 1469 1625 int vRet; 1470 1626 LPPALETTEENTRY pPal; 1627 ULONG rc; 1628 1629 dprintf(("OPENGL32: WMesaPaletteChange - Pal %08X",Pal)); 1630 1471 1631 if (Current && (Current->rgb_flag==GL_FALSE || Current->dither_flag == GL_TRUE)) 1472 1632 { 1473 1633 pPal = (PALETTEENTRY *)malloc( 256 * sizeof(PALETTEENTRY)); 1474 1634 Current->hPal=Pal; 1475 // GetPaletteEntries( Pal, 0, 256, pPal );1635 /* GetPaletteEntries( Pal, 0, 256, pPal );*/ 1476 1636 GetPalette( Pal, (RGBQUAD *)pPal ); 1637 #ifdef DIVE 1638 /* rc=DiveSetSourcePalette(Current->hDiveInstance, 1639 0, 1640 256, 1641 (PBYTE)pPal); 1642 */ 1643 dprintf(("OPENGL32: DiveSetupSourcePalette rc %d\n",rc)); 1644 #else 1477 1645 #ifdef DDRAW 1478 1646 Current->lpDD->lpVtbl->CreatePalette(Current->lpDD,DDPCAPS_8BIT, … … 1481 1649 Current->lpDDSPrimary->lpVtbl->SetPalette(Current->lpDDSPrimary,Current->lpDDPal); 1482 1650 #else 1483 vRet = SetDIBColorTable(Current->dib.hDC,0,256,(RGBQUAD *)pPal); 1651 vRet = SetDIBColorTable(Current->dib.hDC,0,256, (RGBQUAD *)pPal); 1652 #endif 1484 1653 #endif 1485 1654 free( pPal ); … … 1577 1746 } 1578 1747 1748 void DibSetPixel(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b) 1749 { 1750 if (Current->db_flag) 1751 { 1752 LPBYTE lpb = pwc->pbPixels; 1753 LPDWORD lpdw; 1754 LPWORD lpw; 1755 UINT nBypp = pwc->cColorBits >> 3; 1756 UINT nOffset = iPixel % nBypp; 1757 1758 // Move the pixel buffer pointer to the scanline that we 1759 // want to access 1760 1761 // pwc->dib.fFlushed = FALSE; 1762 1763 lpb += pwc->ScanWidth * iScanLine; 1764 /* Now move to the desired pixel */ 1765 lpb += iPixel * nBypp; 1766 lpb = PIXELADDR(iPixel, iScanLine); 1767 lpdw = (LPDWORD)lpb; 1768 lpw = (LPWORD)lpb; 1769 1770 if(nBypp == 1){ 1771 if(pwc->dither_flag) 1772 *lpb = DITHER_RGB_2_8BIT(r,g,b,iScanLine,iPixel); 1773 else 1774 *lpb = BGR8(r,g,b); 1775 } 1776 else if(nBypp == 2) 1777 *lpw = BGR16(r,g,b); 1778 else if (nBypp == 3){ 1779 *lpdw = BGR24(r,g,b); 1780 } 1781 else if (nBypp == 4) 1782 *lpdw = BGR32(r,g,b); 1783 } 1784 else{ 1785 SetPixel(Current->hDC, iPixel, iScanLine, RGB(r,g,b)); 1786 DD_RELEASEDC; 1787 } 1788 } 1789 1579 1790 void /*WINAPI*/ wmSetPixel(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b) 1580 1791 { 1581 if (Current->db_flag) { 1582 LPBYTE lpb = pwc->pbPixels; 1583 LPDWORD lpdw; 1584 LPWORD lpw; 1585 UINT nBypp = pwc->cColorBits >> 3; 1586 UINT nOffset = iPixel % nBypp; 1587 1588 // Move the pixel buffer pointer to the scanline that we 1589 // want to access 1590 1591 // pwc->dib.fFlushed = FALSE; 1592 1593 lpb += pwc->ScanWidth * iScanLine; 1594 // Now move to the desired pixel 1595 lpb += iPixel * nBypp; 1596 lpb = PIXELADDR(iPixel, iScanLine); 1597 lpdw = (LPDWORD)lpb; 1598 lpw = (LPWORD)lpb; 1599 1600 if(nBypp == 1){ 1601 if(pwc->dither_flag) 1602 *lpb = DITHER_RGB_2_8BIT(r,g,b,iScanLine,iPixel); 1603 else 1604 *lpb = BGR8(r,g,b); 1792 #ifdef DIVE 1793 if(DiveDirectAccess()) 1794 { 1795 if (Current->db_flag) 1796 { 1797 /* We're using a buffered context - write to the backbuffer */ 1798 DiveWriteBackbuffer(pwc,iScanLine,iPixel,r,g,b); 1605 1799 } 1606 else if(nBypp == 2) 1607 *lpw = BGR16(r,g,b); 1608 else if (nBypp == 3){ 1609 *lpdw = BGR24(r,g,b); 1800 else 1801 { 1802 /* We're using a non-buffered context - write to the video mem! */ 1803 /* TODO: What about cards that do not support direct access?? */ 1804 DiveWriteFrontbuffer(pwc,iScanLine,iPixel,r,g,b); 1610 1805 } 1611 else if (nBypp == 4) 1612 *lpdw = BGR32(r,g,b); 1613 } 1614 else{ 1615 SetPixel(Current->hDC, iPixel, iScanLine, RGB(r,g,b)); 1616 DD_RELEASEDC; 1617 } 1806 } 1807 else 1808 DibSetPixel(pwc, iScanLine, iPixel, r, g, b); 1809 #else 1810 DibSetPixel(pwc, iScanLine, iPixel, r, g, b); 1811 #endif 1618 1812 } 1619 1813 1620 1814 void /*WINAPI*/ wmCreateDIBSection( 1621 1815 HDC hDC, 1622 PWMC pwc, // handle of device context1623 CONST BITMAPINFO *pbmi, // address of structure containing bitmap size, format, and color data1624 UINT iUsage // color data type indicator: RGB values or palette indices1816 PWMC pwc, /* handle of device context */ 1817 CONST BITMAPINFO *pbmi,/* address of structure containing bitmap size, format, and color data*/ 1818 UINT iUsage/* color data type indicator: RGB values or palette indices*/ 1625 1819 ) 1626 1820 { … … 1641 1835 dwSize = sizeof(BITMAPINFO) + (dwScanWidth * pwc->height); 1642 1836 1837 #ifdef __WIN32OS2__ 1838 pwc->dib.hFileMap = CreateFileMappingA((HANDLE)PAGE_FILE, 1839 #else 1643 1840 pwc->dib.hFileMap = CreateFileMapping((HANDLE)PAGE_FILE, 1841 #endif 1644 1842 NULL, 1645 1843 PAGE_READWRITE | SEC_COMMIT, … … 1668 1866 memcpy(pwc->dib.base, pbmi, sizeof(BITMAPINFO)); 1669 1867 1868 #ifdef __WIN32OS2__ 1869 hic = CreateICA("display", NULL, NULL, NULL); 1870 #else 1670 1871 hic = CreateIC("display", NULL, NULL, NULL); 1872 #endif 1671 1873 pwc->dib.hDC = CreateCompatibleDC(hic); 1672 1874 … … 1693 1895 0); 1694 1896 */ 1695 dprintf(("CreateDIBSection set pix %08X\n",pwc->pbPixels));1696 1897 1697 1898 pwc->ScreenMem = pwc->addrOffScreen = pwc->pbPixels; … … 1711 1912 BOOL bRet = 0; 1712 1913 DWORD dwErr = 0; 1914 #ifdef DIVE 1915 ULONG rc; 1916 #endif 1713 1917 #ifdef DDRAW 1714 1918 HRESULT ddrval; 1715 1919 #endif 1716 1920 1717 // Now search through the torus frames and mark used colors1718 1921 if(pwc->db_flag){ 1922 #ifdef DIVE 1923 if(DiveDirectAccess()) 1924 DiveFlush(pwc); 1925 else 1926 bRet = BitBlt(pwc->hDC, 0, 0, pwc->width, pwc->height, 1927 pwc->dib.hDC, 0, 0, SRCCOPY); 1928 #else 1719 1929 #ifdef DDRAW 1720 1930 if (pwc->lpDDSOffScreen == NULL) … … 1756 1966 pwc->dib.hDC, 0, 0, SRCCOPY); 1757 1967 #endif 1968 #endif 1758 1969 } 1759 1970 … … 1956 2167 { 1957 2168 DDFree(wc); 2169 #ifdef __WIN32OS2__ 2170 MessageBoxA( hwnd, "DirectDraw Init FAILED", "", MB_OK ); 2171 #else 1958 2172 MessageBox( hwnd, "DirectDraw Init FAILED", "", MB_OK ); 2173 #endif 1959 2174 return FALSE; 1960 2175 … … 2124 2339 2125 2340 return 0; /* Eliminate compiler warning */ 2126 } /* DDInit*/2341 } /* DDInit*/ 2127 2342 2128 2343 static void DDFree( WMesaContext wc) … … 2135 2350 wc->lpDD = NULL; 2136 2351 } 2137 // Clean up the screen on exit2352 /* Clean up the screen on exit */ 2138 2353 RedrawWindow( NULL, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | 2139 2354 RDW_ALLCHILDREN ); … … 2153 2368 } 2154 2369 } 2155 2156 2157 2370 2158 2371 /*
Note:
See TracChangeset
for help on using the changeset viewer.