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/wmesa.c

    r2938 r2962  
    1 /* $Id: wmesa.c,v 1.1 2000-02-29 00:50:15 sandervl Exp $ */
     1/* $Id: wmesa.c,v 1.2 2000-03-01 18:49:40 jeroen Exp $ */
    22
    33/*
     
    2323/*
    2424 * $Log: wmesa.c,v $
    25  * Revision 1.1  2000-02-29 00:50:15  sandervl
    26  * created
     25 * Revision 1.2  2000-03-01 18:49:40  jeroen
     26 * *** empty log message ***
    2727 *
    2828 * Revision 1.1.1.1  1999/08/19 00:55:42  jtg
     
    6767#define WMESA_STEREO_C
    6868
     69#ifdef __WIN32OS2__
     70#include <os2win.h>
     71#else
    6972#include <windows.h>
     73#endif
    7074#include <stdio.h>
    7175#include <stdlib.h>
     
    7478#include "colors.h"
    7579#include "macros.h"
     80#include "types.h"
    7681#include "context.h"
    7782#include "dd.h"
     
    8489#ifndef __WIN32OS2__
    8590#pragma warning ( disable : 4133 4761 )
     91#else
     92#ifdef DIVE
     93#include <mesadive.h>
     94extern HWND Win32ToOS2Handle(HWND);
     95#endif
    8696#endif
    8797
     
    122132/* end of added code*/
    123133
    124 static PWMC Current = NULL;
     134PWMC Current = NULL;
    125135WMesaContext WC = NULL;
    126136
     
    134144    char Msg[512];
    135145    sprintf(Msg,"%s %s %d",Cond,File,Line);
     146#ifdef __WIN32OS2__
     147    dprintf((Msg,"%s %s %d",Cond,File,Line));
     148#endif
    136149    MessageBox(NULL,Msg,"Assertion failed.",MB_OK);
    137150    exit(1);
     
    214227static void wmSetPixelFormat( PWMC wc, HDC hDC)
    215228{
     229  dprintf(("OPENGL32: Setting PixelFormat\n"));
     230
     231#ifdef DIVE
     232  wc->cColorBits=DiveQueryDepth();
     233
     234  wc->pixelformat=DiveQueryNativePixelFormat();
     235#else
    216236    if(wc->rgb_flag)
    217         wc->cColorBits = GetDeviceCaps(hDC, BITSPIXEL);
     237      wc->cColorBits = GetDeviceCaps(hDC, BITSPIXEL);
    218238    else
    219         wc->cColorBits = 8;
     239      wc->cColorBits = 8;
     240
    220241    switch(wc->cColorBits){
    221242    case 8:
     
    225246            wc->pixelformat = PF_DITHER8;
    226247        break;
     248
    227249    case 16:
    228250        wc->pixelformat = PF_5R6G5B;
    229251        break;
     252
    230253    case 32:
    231254        wc->pixelformat = PF_8R8G8B;
    232255        break;
    233     default:
     256
     257    default:                                    /* This also handles 24 bpp*/
    234258        wc->pixelformat = PF_BADFORMAT;
    235     }
     259      break;
     260    }
     261#endif
     262
     263  dprintf(("OPENGL32: Color Bits: %d\n",wc->cColorBits));
    236264}
    237265
    238266//
    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*/
    241269//
    242270BOOL /*WINAPI*/ wmSetDibColors(PWMC pwc)
     
    297325    LPBITMAPINFO pbmi = &(pwc->bmi);
    298326    int     iUsage;
     327
     328    dprintf(("OPENGL32: Creating BackingStore for %08X\n",pwc));
    299329
    300330    pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
     
    341371    DWORD   dwScanWidth = (uiScanWidth * nBypp);
    342372
    343     dprintf(("OPENGL32: wmSetDIBits\n"));
    344 
    345373    //
    346374    // We need to round up to the nearest DWORD
     
    400428        }
    401429        ENDPROFILE(flush)
    402 
    403 }
    404 
    405 
     430}
    406431
    407432/*
     
    433458* or index as specified by one of the two functions above.
    434459*/
    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 proper
    439 //       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.                           */
    440465static GLbitfield clear(GLcontext* ctx, GLbitfield mask,
    441466                  GLboolean all, GLint x, GLint y, GLint width, GLint height)
     
    449474    int     lines;
    450475
    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));
    452478
    453479    STARTPROFILE
     
    458484            height=Current->height;
    459485        }
     486
     487    dprintf(("OPENGL32: clear - all %08d - x %d - y %d - width %d - height %d\n",
     488             all,x,y,width,height));
     489
    460490        if(Current->db_flag==GL_TRUE){
    461491            UINT    nBypp = Current->cColorBits / 8;
    462492            int     i = 0;
    463493            int     iSize = 0;
     494
     495            dprintf(("OPENGL32: Clearing BackBuffer\n"));
    464496
    465497            if(nBypp ==1 ){
     
    520552            while (i<lines-1);
    521553        }
    522         else { // For single buffer
     554        else
     555          {                                            /* For single buffer*/
     556            dprintf(("OPENGL32: Clearing FrontBuffer\n"));
     557
    523558            HDC DC=DD_GETDC;
     559
     560            dprintf(("OPENGL32: Clearing FrontBuffer DC is %08X\n",DC));
     561
    524562            HPEN Pen=CreatePen(PS_SOLID,1,Current->clearpixel);
    525563            HBRUSH Brush=CreateSolidBrush(Current->clearpixel);
    526564            HPEN Old_Pen=SelectObject(DC,Pen);
    527565            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
    529569            SelectObject(DC,Old_Pen);
    530570            SelectObject(DC,Old_Brush);
    531571            DeleteObject(Pen);
    532572            DeleteObject(Brush);
     573
    533574            DD_RELEASEDC;
    534         }
    535 
    536 
     575          }
    537576
    538577        ENDPROFILE(clear)
    539578
    540                 return mask;    // TODO: I doubt this is correct. dd.h doesn't explain what this should
    541                                 //       be...
     579                return mask;/* TODO: I doubt this is correct. dd.h doesn't explain what this should*/
     580                                       /* be...                            */
    542581}
    543582
     
    640679
    641680   STARTPROFILE
     681
    642682   GetClientRect(Current->Window,&CR);
    643683
     
    651691      Current->height=*height;
    652692      Current->ScanWidth=Current->width;
     693
    653694      if ((Current->ScanWidth%sizeof(long))!=0)
    654695         Current->ScanWidth+=(sizeof(long)-(Current->ScanWidth%sizeof(long)));
    655696
    656697      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
    657705#ifdef DDRAW
    658706         DDDeleteOffScreen(Current);
     
    663711            wmCreateBackingStore(Current, Current->width, Current->height);
    664712         }
     713#endif
    665714#endif
    666715      }
     
    719768            }
    720769        }
    721         //   DD_RELEASEDC;
     770
     771                                       /* DD_RELEASEDC;                    */
    722772        ENDPROFILE(fast_rgb_points)
    723773}
     
    753803
    754804    if (0 /*Current->gl_ctx->VB->MonoColor*/) {
    755         pixel = Current->pixel;  /* use current color */
     805        pixel = Current->pixel;                        /* use current color*/
    756806    }
    757807    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));
    761820    }
    762821
     
    769828    BEGINGDICALL
    770829
    771     Pen=CreatePen(PS_SOLID,1,pixel);
     830    Pen=CreatePen(PS_SOLID,1,(COLORREF)pixel);
    772831    Old_Pen=SelectObject(DC,Pen);
    773832    MoveToEx(DC,x0,y0,NULL);
     
    902961        }
    903962    }
     963
    904964    ENDPROFILE(write_rgba_span)
    905965
     
    9451005        }
    9461006    }
     1007
    9471008    ENDPROFILE(write_rgb_span)
    9481009
     
    9631024    assert(Current->rgb_flag==GL_TRUE);
    9641025    y=FLIP(y);
     1026
    9651027    if(Current->rgb_flag==GL_TRUE){
    9661028        for (i=0; i<n; i++)
    9671029            if (mask[i])
    968                 // Trying
     1030                                       /* Trying                           */
    9691031                wmSetPixel(pwc,y,x+i,GetRValue(Current->pixel), GetGValue(Current->pixel), GetBValue(Current->pixel));
    9701032    }
     
    9751037    }
    9761038    DD_RELEASEDC;
     1039
    9771040    ENDPROFILE(write_mono_rgba_span)
    9781041}
     
    10331096{
    10341097    STARTPROFILE
     1098
    10351099        GLuint i;
    10361100    PWMC    pwc = Current;
    10371101    HDC DC=DD_GETDC;
    10381102    assert(Current->rgb_flag==GL_TRUE);
     1103
    10391104    for (i=0; i<n; i++)
    10401105       if (mask[i])
    10411106          wmSetPixel(pwc, FLIP(y[i]),x[i],rgba[i][RCOMP],rgba[i][GCOMP],rgba[i][BCOMP]);
     1107
    10421108    DD_RELEASEDC;
    10431109    ENDPROFILE(write_rgba_pixels)
     
    10601126    HDC DC=DD_GETDC;
    10611127    assert(Current->rgb_flag==GL_TRUE);
     1128
    10621129    for (i=0; i<n; i++)
    10631130        if (mask[i])
    10641131            wmSetPixel(pwc, FLIP(y[i]),x[i],GetRValue(Current->pixel),
    10651132                       GetGValue(Current->pixel), GetBValue(Current->pixel));
     1133
    10661134    DD_RELEASEDC;
    10671135    ENDPROFILE(write_mono_rgba_pixels)
     
    12851353}
    12861354
    1287 
    1288 WMesaContext WMesaCreateContext( HWND hWnd, HPALETTE* Pal,
     1355void 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
     1375WMesaContext WIN32API WMesaCreateContext( HWND hWnd, HPALETTE* Pal,
    12891376                                GLboolean rgb_flag,
    12901377                                GLboolean db_flag )
     
    12941381    GLboolean true_color_flag;
    12951382    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
    12961387    if (!c)
    12971388        return NULL;
     
    13001391    c->hDC = GetDC(hWnd);
    13011392    true_color_flag = GetDeviceCaps(c->hDC, BITSPIXEL) > 8;
    1302 #ifdef DDRAW
     1393
     1394#if defined(DDRAW) || defined(DIVE)
    13031395    if(true_color_flag) c->rgb_flag = rgb_flag = GL_TRUE;
    13041396#endif
     
    13161408#endif
    13171409
     1410    dprintf(("OPENGL32: WMesaCreateContext - db_flag is %d\n",db_flag));
    13181411
    13191412    if (rgb_flag==GL_FALSE)
    13201413    {
    13211414        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
    13251420    }
    13261421    else
    13271422    {
    13281423        c->rgb_flag = GL_TRUE;
    1329         //    c->pixel = 0;
    1330     }
     1424                                       /* c->pixel = 0;                    */
     1425    }
     1426
    13311427    GetClientRect(c->Window,&CR);
     1428
    13321429    c->width=CR.right;
    13331430    c->height=CR.bottom;
     1431
    13341432    if (db_flag)
    13351433    {
    13361434        c->db_flag = 1;
    13371435        /* Double buffered */
    1338 #ifndef DDRAW
    1339         //  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 )*/
    13401438        {
    13411439            wmCreateBackingStore(c, c->width, c->height);
    13421440
    13431441        }
     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
    13441448#endif
    13451449    }
     
    13501454            c->db_flag = 0;
    13511455    }
     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
    13521477#ifdef DDRAW
    13531478    if (DDInit(c,hWnd) == GL_FALSE) {
    13541479        free( (void *) c );
     1480        dprintf(("OPENGL32: DIVEINIT failed - exiting!\n"));
    13551481        exit(1);
    13561482    }
    13571483#endif
    1358 
     1484#endif
     1485
     1486/* JvdH - Enable software Alpha! (was FALSE!!) */
    13591487
    13601488    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*/
    13691497
    13701498    if (!c->gl_visual) {
     
    13821510
    13831511    c->gl_buffer = gl_create_framebuffer( c->gl_visual );
     1512
    13841513    if (!c->gl_buffer) {
    13851514        gl_destroy_visual( c->gl_visual );
     
    13891518    }
    13901519
    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"));
    13941525
    13951526    return c;
    13961527}
    13971528
    1398 void WMesaDestroyContext( void )
     1529void WIN32API WMesaDestroyContext( void )
    13991530{
    14001531    WMesaContext c = Current;
     1532
    14011533    ReleaseDC(c->Window,c->hDC);
     1534
    14021535    WC = c;
     1536
    14031537    if(c->hPalHalfTone != NULL)
    14041538        DeleteObject(c->hPalHalfTone);
     1539
    14051540    gl_destroy_visual( c->gl_visual );
    14061541    gl_destroy_framebuffer( c->gl_buffer );
     
    14081543
    14091544    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
    14101556#ifdef DDRAW
     1557      {
    14111558        DDFree(c);
     1559      }
    14121560#else
    14131561    wmDeleteBackingStore(c);
    14141562#endif
     1563#endif
    14151564    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*/
    14181570#if !defined(NO_PARALLEL)
    14191571    if(parallelMachine)
    14201572        PRDestroyRenderBuffer();
    14211573#endif
    1422     // End modification
    1423 }
    1424 
    1425 
     1574                                       /* End modification                 */
     1575}
    14261576
    14271577void WIN32API WMesaMakeCurrent( WMesaContext c )
    14281578{
     1579  dprintf(("OPENGL32: WMesaMakeCurrent %08X\n",c));
     1580
    14291581    if(!c){
    14301582        Current = c;
     
    14591611{
    14601612    HDC DC = Current->hDC;
     1613
     1614    dprintf(("OPENGL32: WMesaSwapBuffers() - Current %08X (%s)\n",
     1615             Current,Current->db_flag?"DOUBLE":"SINGLE"));
     1616
    14611617    if (Current->db_flag)
    14621618        wmFlush(Current);
     
    14691625    int vRet;
    14701626    LPPALETTEENTRY pPal;
     1627    ULONG rc;
     1628
     1629    dprintf(("OPENGL32: WMesaPaletteChange - Pal %08X",Pal));
     1630
    14711631    if (Current && (Current->rgb_flag==GL_FALSE || Current->dither_flag == GL_TRUE))
    14721632    {
    14731633        pPal = (PALETTEENTRY *)malloc( 256 * sizeof(PALETTEENTRY));
    14741634        Current->hPal=Pal;
    1475         //  GetPaletteEntries( Pal, 0, 256, pPal );
     1635                                 /* GetPaletteEntries( Pal, 0, 256, pPal );*/
    14761636        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
    14771645#ifdef DDRAW
    14781646        Current->lpDD->lpVtbl->CreatePalette(Current->lpDD,DDPCAPS_8BIT,
     
    14811649            Current->lpDDSPrimary->lpVtbl->SetPalette(Current->lpDDSPrimary,Current->lpDDPal);
    14821650#else
    1483         vRet = SetDIBColorTable(Current->dib.hDC,0,256,(RGBQUAD *)pPal);
     1651        vRet = SetDIBColorTable(Current->dib.hDC,0,256, (RGBQUAD *)pPal);
     1652#endif
    14841653#endif
    14851654        free( pPal );
     
    15771746}
    15781747
     1748void 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
    15791790void /*WINAPI*/ wmSetPixel(PWMC pwc, int iScanLine, int iPixel, BYTE r, BYTE g, BYTE b)
    15801791{
    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);
    16051799        }
    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);
    16101805        }
    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
    16181812}
    16191813
    16201814void /*WINAPI*/ wmCreateDIBSection(
    16211815                                   HDC   hDC,
    1622                                    PWMC pwc,    // handle of device context
    1623                                    CONST BITMAPINFO *pbmi,  // address of structure containing bitmap size, format, and color data
    1624                                    UINT iUsage  // color data type indicator: RGB values or palette indices
     1816                                   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*/
    16251819                                   )
    16261820{
     
    16411835    dwSize = sizeof(BITMAPINFO) + (dwScanWidth * pwc->height);
    16421836
     1837#ifdef __WIN32OS2__
     1838    pwc->dib.hFileMap = CreateFileMappingA((HANDLE)PAGE_FILE,
     1839#else
    16431840    pwc->dib.hFileMap = CreateFileMapping((HANDLE)PAGE_FILE,
     1841#endif
    16441842        NULL,
    16451843        PAGE_READWRITE | SEC_COMMIT,
     
    16681866    memcpy(pwc->dib.base, pbmi, sizeof(BITMAPINFO));
    16691867
     1868#ifdef __WIN32OS2__
     1869    hic = CreateICA("display", NULL, NULL, NULL);
     1870#else
    16701871    hic = CreateIC("display", NULL, NULL, NULL);
     1872#endif
    16711873    pwc->dib.hDC = CreateCompatibleDC(hic);
    16721874
     
    16931895        0);
    16941896    */
    1695     dprintf(("CreateDIBSection set pix %08X\n",pwc->pbPixels));
    16961897
    16971898    pwc->ScreenMem = pwc->addrOffScreen = pwc->pbPixels;
     
    17111912    BOOL    bRet = 0;
    17121913    DWORD   dwErr = 0;
     1914#ifdef DIVE
     1915    ULONG rc;
     1916#endif
    17131917#ifdef DDRAW
    17141918    HRESULT             ddrval;
    17151919#endif
    17161920
    1717     // Now search through the torus frames and mark used colors
    17181921    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
    17191929#ifdef DDRAW
    17201930        if (pwc->lpDDSOffScreen == NULL)
     
    17561966                pwc->dib.hDC, 0, 0, SRCCOPY);
    17571967#endif
     1968#endif
    17581969    }
    17591970
     
    19562167{
    19572168    DDFree(wc);
     2169#ifdef __WIN32OS2__
     2170    MessageBoxA( hwnd, "DirectDraw Init FAILED", "", MB_OK );
     2171#else
    19582172    MessageBox( hwnd, "DirectDraw Init FAILED", "", MB_OK );
     2173#endif
    19592174    return FALSE;
    19602175
     
    21242339
    21252340   return 0; /* Eliminate compiler warning */
    2126 } /* DDInit */
     2341}                                                                 /* DDInit*/
    21272342
    21282343static void DDFree( WMesaContext wc)
     
    21352350        wc->lpDD = NULL;
    21362351    }
    2137     // Clean up the screen on exit
     2352                                       /* Clean up the screen on exit      */
    21382353    RedrawWindow( NULL, NULL, NULL, RDW_INVALIDATE | RDW_ERASE |
    21392354        RDW_ALLCHILDREN );
     
    21532368    }
    21542369}
    2155 
    2156 
    21572370
    21582371/*
Note: See TracChangeset for help on using the changeset viewer.