VirtualBox

Changeset 3438 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
Jul 5, 2007 9:00:44 AM (18 years ago)
Author:
vboxsync
Message:

Window creation needs to be done in DrvSetPixelFormat

Location:
trunk/src/VBox/Additions/WINNT/Graphics/OpenGL
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/OpenGL/OGLComplexSync.cpp

    r3436 r3438  
    2424
    2525
    26 /* Driver functions */
    27 HGLRC APIENTRY DrvCreateContext(HDC hdc)
    28 {
    29     uint32_t cx, cy;
    30     PIXELFORMATDESCRIPTOR pfd;
    31     int rc;
    32     HWND hwnd;
    33 
    34     /** check dimensions and pixel format of hdc */
    35     hwnd = WindowFromDC(hdc);
    36     if (hwnd)
    37     {
    38         RECT rect;
    39 
    40         GetWindowRect(hwnd, &rect);
    41         cx = rect.right - rect.left;
    42         cy = rect.bottom - rect.top;
    43     }
    44     else
    45     {
    46         /** @todo get dimenions of memory dc; a bitmap should be selected in there */
    47         AssertFailed();
    48     }
    49 
    50     uint32_t iPixelFormat = GetPixelFormat(hdc);
    51     if (iPixelFormat)
    52     {
    53         rc = DescribePixelFormat(hdc, iPixelFormat, sizeof(pfd), &pfd);
    54         Assert(rc);
    55     }
    56     else
    57     {
    58         pfd.cColorBits = GetDeviceCaps(hdc, BITSPIXEL);
    59         pfd.iPixelType = PFD_TYPE_RGBA;
    60         pfd.cDepthBits = 16;
    61     }
    62     VBOX_OGL_GEN_SYNC_OP6_RET(HGLRC, DrvCreateContext, hdc, cx, cy, pfd.cColorBits, pfd.iPixelType, pfd.cDepthBits);
    63     /* Propagate error through the right channel */
    64     SetLastError(glGetError());
    65     return retval;
    66 }
    67 
    68 HGLRC APIENTRY DrvCreateLayerContext(HDC hdc, int iLayerPlane)
    69 {
    70     uint32_t cx, cy;
    71     PIXELFORMATDESCRIPTOR pfd;
    72     int rc;
    73     HWND hwnd;
    74 
    75     /** check dimensions and pixel format of hdc */
    76     hwnd = WindowFromDC(hdc);
    77     if (hwnd)
    78     {
    79         RECT rect;
    80 
    81         GetWindowRect(hwnd, &rect);
    82         cx = rect.right - rect.left;
    83         cy = rect.bottom - rect.top;
    84     }
    85     else
    86     {
    87         /** @todo get dimenions of memory dc; a bitmap should be selected in there */
    88         AssertFailed();
    89     }
    90     uint32_t iPixelFormat = GetPixelFormat(hdc);
    91     if (iPixelFormat)
    92     {
    93         rc = DescribePixelFormat(hdc, iPixelFormat, sizeof(pfd), &pfd);
    94         Assert(rc);
    95     }
    96     else
    97     {
    98         pfd.cColorBits = GetDeviceCaps(hdc, BITSPIXEL);
    99         pfd.iPixelType = PFD_TYPE_RGBA;
    100         pfd.cDepthBits = 16;
    101     }
    102 
    103     VBOX_OGL_GEN_SYNC_OP7_RET(HGLRC, DrvCreateLayerContext, hdc, iLayerPlane, cx, cy, pfd.cColorBits, pfd.iPixelType, pfd.cDepthBits);
    104     /* Propagate error through the right channel */
    105     SetLastError(glGetError());
    106     return retval;
    107 }
    108 
    109 BOOL APIENTRY DrvDescribeLayerPlane(HDC hdc,int iPixelFormat,
    110                                     int iLayerPlane, UINT nBytes,
    111                                     LPLAYERPLANEDESCRIPTOR plpd)
    112 {
    113     VBOX_OGL_GEN_SYNC_OP5_PASS_PTR_RET(BOOL, DrvDescribeLayerPlane, hdc, iPixelFormat, iLayerPlane, nBytes, nBytes, plpd);
    114     /* Propagate error through the right channel */
    115     SetLastError(glGetError());
    116     return retval;
    117 }
    118 
    119 int APIENTRY DrvGetLayerPaletteEntries(HDC hdc, int iLayerPlane,
    120                                        int iStart, int cEntries,
    121                                        COLORREF *pcr)
    122 {
    123     VBOX_OGL_GEN_SYNC_OP5_PASS_PTR_RET(int, DrvGetLayerPaletteEntries, hdc, iLayerPlane, iStart, cEntries, sizeof(COLORREF)*cEntries, pcr);
    124     /* Propagate error through the right channel */
    125     SetLastError(glGetError());
    126     return retval;
    127 }
    128 
    129 int APIENTRY DrvDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd)
    130 {
    131     /* if ppfd == NULL, then DrvDescribelayerPlane returns the maximum nr of supported pixel formats */
    132     VBOX_OGL_GEN_SYNC_OP4_PASS_PTR_RET(int, DrvDescribePixelFormat, hdc, iPixelFormat, nBytes, nBytes, ppfd);
    133     /* Propagate error through the right channel */
    134     SetLastError(glGetError());
    135     return retval;
    136 }
    137 
    138 #ifdef VBOX_WITH_WGL_EXPORTS
    139 /* Test export for directly linking with vboxogl.dll */
    140 int WINAPI wglDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd)
    141 {
    142     return DrvDescribePixelFormat(hdc, iPixelFormat, nBytes, ppfd);
    143 }
    144 
    145 BOOL WINAPI wglDescribeLayerPlane(HDC hdc,int iPixelFormat,
    146                                   int iLayerPlane, UINT nBytes,
    147                                   LPLAYERPLANEDESCRIPTOR plpd)
    148 {
    149     return DrvDescribeLayerPlane(hdc, iPixelFormat, iLayerPlane, nBytes, plpd);
    150 }
    151 
    152 int WINAPI wglGetLayerPaletteEntries(HDC hdc, int iLayerPlane,
    153                                      int iStart, int cEntries,
    154                                      COLORREF *pcr)
    155 {
    156     return DrvGetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
    157 }
    158 
    159 HGLRC WINAPI wglCreateContext(HDC hdc)
    160 {
    161     return DrvCreateContext(hdc);
    162 }
    163 
    164 #endif
    165 
    16626void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
    16727{
  • trunk/src/VBox/Additions/WINNT/Graphics/OpenGL/OGLSimpleSync.cpp

    r3436 r3438  
    2323#include "VBoxOGL.h"
    2424
    25 
    26 BOOL APIENTRY DrvDeleteContext(HGLRC hglrc)
    27 {
    28     VBOX_OGL_GEN_SYNC_OP1_RET(BOOL, DrvDeleteContext, hglrc);
    29     /* Propagate error through the right channel */
    30     SetLastError(glGetError());
    31     return retval;
    32 }
    33 
    34 BOOL APIENTRY DrvCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
    35 {
    36     VBOX_OGL_GEN_SYNC_OP3_RET(BOOL, DrvCopyContext, hglrcSrc, hglrcDst, mask);
    37     /* Propagate error through the right channel */
    38     SetLastError(glGetError());
    39     return retval;
    40 }
    41 
    42 void APIENTRY DrvReleaseContext(HGLRC hglrc)
    43 {
    44     VBOX_OGL_GEN_SYNC_OP1(DrvReleaseContext, hglrc);
    45     /* Propagate error through the right channel */
    46     SetLastError(glGetError());
    47 }
    48 
    49 BOOL APIENTRY DrvShareLists(HGLRC hglrc1, HGLRC hglrc2)
    50 {
    51     VBOX_OGL_GEN_SYNC_OP2_RET(BOOL, DrvShareLists, hglrc1, hglrc2);
    52     /* Propagate error through the right channel */
    53     SetLastError(glGetError());
    54     return retval;
    55 }
    56 
    57 int APIENTRY DrvSetLayerPaletteEntries(HDC hdc, int iLayerPlane,
    58                                        int iStart, int cEntries,
    59                                        CONST COLORREF *pcr)
    60 {
    61     VBOX_OGL_GEN_SYNC_OP5_PTR_RET(int, DrvSetLayerPaletteEntries, hdc, iLayerPlane, iStart, cEntries, sizeof(COLORREF)*cEntries, pcr);
    62     /* Propagate error through the right channel */
    63     SetLastError(glGetError());
    64     return retval;
    65 }
    66 
    67 
    68 BOOL APIENTRY DrvRealizeLayerPalette(HDC hdc, int iLayerPlane, BOOL bRealize)
    69 {
    70     VBOX_OGL_GEN_SYNC_OP3_RET(BOOL, DrvRealizeLayerPalette, hdc, iLayerPlane, bRealize);
    71     /* Propagate error through the right channel */
    72     SetLastError(glGetError());
    73     return retval;
    74 }
    75 
    76 BOOL APIENTRY DrvSwapLayerBuffers(HDC hdc, UINT fuPlanes)
    77 {
    78     VBOX_OGL_GEN_SYNC_OP2_RET(BOOL, DrvSwapLayerBuffers, hdc, fuPlanes);
    79     /* Propagate error through the right channel */
    80     SetLastError(glGetError());
    81     return retval;
    82 }
    83 
    84 BOOL APIENTRY DrvSetPixelFormat(HDC hdc, int iPixelFormat)
    85 {
    86     VBOX_OGL_GEN_SYNC_OP2_RET(BOOL, DrvSetPixelFormat, hdc, iPixelFormat);
    87     /* Propagate error through the right channel */
    88     SetLastError(glGetError());
    89     return retval;
    90 }
    91 
    92 BOOL APIENTRY DrvSwapBuffers(HDC hdc)
    93 {
    94     VBOX_OGL_GEN_SYNC_OP1_RET(BOOL, DrvSwapBuffers, hdc);
    95     /* Propagate error through the right channel */
    96     SetLastError(glGetError());
    97     return retval;
    98 }
    99 
    100 #ifdef VBOX_WITH_WGL_EXPORTS
    101 /* Test export for directly linking with vboxogl.dll */
    102 int WINAPI wglSetLayerPaletteEntries(HDC hdc, int iLayerPlane,
    103                                      int iStart, int cEntries,
    104                                      CONST COLORREF *pcr)
    105 {
    106     return DrvSetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
    107 }
    108 
    109 BOOL WINAPI wglSetPixelFormat(HDC hdc, int iPixelFormat)
    110 {
    111     return DrvSetPixelFormat(hdc, iPixelFormat);
    112 }
    113 
    114 BOOL WINAPI wglRealizeLayerPalette(HDC hdc, int iLayerPlane, BOOL bRealize)
    115 {
    116     return DrvRealizeLayerPalette(hdc, iLayerPlane, bRealize);
    117 }
    118 
    119 BOOL WINAPI wglDeleteContext(HGLRC hglrc)
    120 {
    121     return DrvDeleteContext(hglrc);
    122 }
    123 
    124 BOOL WINAPI wglSwapLayerBuffers(HDC hdc, UINT fuPlanes)
    125 {
    126     return DrvSwapLayerBuffers(hdc, fuPlanes);
    127 }
    128 
    129 BOOL WINAPI SwapBuffers(HDC hdc)
    130 {
    131     return DrvSwapBuffers(hdc);
    132 }
    133 
    134 BOOL WINAPI wglCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
    135 {
    136     return DrvCopyContext(hglrcSrc, hglrcDst, mask);
    137 }
    138 
    139 BOOL WINAPI wglShareLists(HGLRC hglrc1, HGLRC hglrc2)
    140 {
    141     return DrvShareLists(hglrc1, hglrc2);
    142 }
    143 #endif
    14425
    14526/* OpenGL functions */
  • trunk/src/VBox/Additions/WINNT/Graphics/OpenGL/drv.cpp

    r3419 r3438  
    9292}
    9393
     94/* DrvSetPixelFormat can only be called once for each window (if hdc associated with one). */
     95BOOL APIENTRY DrvSetPixelFormat(HDC hdc, int iPixelFormat)
     96{
     97    uint32_t cx, cy;
     98    HWND hwnd;
     99
     100    /** check dimensions and pixel format of hdc */
     101    hwnd = WindowFromDC(hdc);
     102    if (hwnd)
     103    {
     104        RECT rect;
     105
     106        GetClientRect(hwnd, &rect);
     107        cx = rect.right - rect.left;
     108        cy = rect.bottom - rect.top;
     109    }
     110    else
     111    {
     112        /** @todo get dimenions of memory dc; a bitmap should be selected in there */
     113        AssertFailed();
     114    }
     115
     116    VBOX_OGL_GEN_SYNC_OP4_RET(BOOL, DrvSetPixelFormat, hdc, iPixelFormat, cx, cy);
     117    /* Propagate error through the right channel */
     118    SetLastError(glGetError());
     119    return retval;
     120}
     121
     122HGLRC APIENTRY DrvCreateContext(HDC hdc)
     123{
     124    VBOX_OGL_GEN_SYNC_OP1_RET(HGLRC, DrvCreateContext, hdc);
     125    /* Propagate error through the right channel */
     126    SetLastError(glGetError());
     127    return retval;
     128}
     129
     130HGLRC APIENTRY DrvCreateLayerContext(HDC hdc, int iLayerPlane)
     131{
     132    VBOX_OGL_GEN_SYNC_OP2_RET(HGLRC, DrvCreateLayerContext, hdc, iLayerPlane);
     133    /* Propagate error through the right channel */
     134    SetLastError(glGetError());
     135    return retval;
     136}
     137
     138BOOL APIENTRY DrvDescribeLayerPlane(HDC hdc,int iPixelFormat,
     139                                    int iLayerPlane, UINT nBytes,
     140                                    LPLAYERPLANEDESCRIPTOR plpd)
     141{
     142    VBOX_OGL_GEN_SYNC_OP5_PASS_PTR_RET(BOOL, DrvDescribeLayerPlane, hdc, iPixelFormat, iLayerPlane, nBytes, nBytes, plpd);
     143    /* Propagate error through the right channel */
     144    SetLastError(glGetError());
     145    return retval;
     146}
     147
     148int APIENTRY DrvGetLayerPaletteEntries(HDC hdc, int iLayerPlane,
     149                                       int iStart, int cEntries,
     150                                       COLORREF *pcr)
     151{
     152    VBOX_OGL_GEN_SYNC_OP5_PASS_PTR_RET(int, DrvGetLayerPaletteEntries, hdc, iLayerPlane, iStart, cEntries, sizeof(COLORREF)*cEntries, pcr);
     153    /* Propagate error through the right channel */
     154    SetLastError(glGetError());
     155    return retval;
     156}
     157
     158int APIENTRY DrvDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd)
     159{
     160    /* if ppfd == NULL, then DrvDescribelayerPlane returns the maximum nr of supported pixel formats */
     161    VBOX_OGL_GEN_SYNC_OP4_PASS_PTR_RET(int, DrvDescribePixelFormat, hdc, iPixelFormat, nBytes, nBytes, ppfd);
     162    /* Propagate error through the right channel */
     163    SetLastError(glGetError());
     164    return retval;
     165}
     166
     167
     168BOOL APIENTRY DrvDeleteContext(HGLRC hglrc)
     169{
     170    VBOX_OGL_GEN_SYNC_OP1_RET(BOOL, DrvDeleteContext, hglrc);
     171    /* Propagate error through the right channel */
     172    SetLastError(glGetError());
     173    return retval;
     174}
     175
     176BOOL APIENTRY DrvCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
     177{
     178    VBOX_OGL_GEN_SYNC_OP3_RET(BOOL, DrvCopyContext, hglrcSrc, hglrcDst, mask);
     179    /* Propagate error through the right channel */
     180    SetLastError(glGetError());
     181    return retval;
     182}
     183
     184void APIENTRY DrvReleaseContext(HGLRC hglrc)
     185{
     186    VBOX_OGL_GEN_SYNC_OP1(DrvReleaseContext, hglrc);
     187    /* Propagate error through the right channel */
     188    SetLastError(glGetError());
     189}
     190
     191BOOL APIENTRY DrvShareLists(HGLRC hglrc1, HGLRC hglrc2)
     192{
     193    VBOX_OGL_GEN_SYNC_OP2_RET(BOOL, DrvShareLists, hglrc1, hglrc2);
     194    /* Propagate error through the right channel */
     195    SetLastError(glGetError());
     196    return retval;
     197}
     198
     199int APIENTRY DrvSetLayerPaletteEntries(HDC hdc, int iLayerPlane,
     200                                       int iStart, int cEntries,
     201                                       CONST COLORREF *pcr)
     202{
     203    VBOX_OGL_GEN_SYNC_OP5_PTR_RET(int, DrvSetLayerPaletteEntries, hdc, iLayerPlane, iStart, cEntries, sizeof(COLORREF)*cEntries, pcr);
     204    /* Propagate error through the right channel */
     205    SetLastError(glGetError());
     206    return retval;
     207}
     208
     209
     210BOOL APIENTRY DrvRealizeLayerPalette(HDC hdc, int iLayerPlane, BOOL bRealize)
     211{
     212    VBOX_OGL_GEN_SYNC_OP3_RET(BOOL, DrvRealizeLayerPalette, hdc, iLayerPlane, bRealize);
     213    /* Propagate error through the right channel */
     214    SetLastError(glGetError());
     215    return retval;
     216}
     217
     218BOOL APIENTRY DrvSwapLayerBuffers(HDC hdc, UINT fuPlanes)
     219{
     220    VBOX_OGL_GEN_SYNC_OP2_RET(BOOL, DrvSwapLayerBuffers, hdc, fuPlanes);
     221    /* Propagate error through the right channel */
     222    SetLastError(glGetError());
     223    return retval;
     224}
     225
     226BOOL APIENTRY DrvSwapBuffers(HDC hdc)
     227{
     228    VBOX_OGL_GEN_SYNC_OP1_RET(BOOL, DrvSwapBuffers, hdc);
     229    /* Propagate error through the right channel */
     230    SetLastError(glGetError());
     231    return retval;
     232}
     233
    94234#ifdef VBOX_WITH_WGL_EXPORTS
    95235/* Test export for directly linking with vboxogl.dll */
     236int WINAPI wglSetLayerPaletteEntries(HDC hdc, int iLayerPlane,
     237                                     int iStart, int cEntries,
     238                                     CONST COLORREF *pcr)
     239{
     240    return DrvSetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
     241}
     242
     243BOOL WINAPI wglSetPixelFormat(HDC hdc, int iPixelFormat)
     244{
     245    return DrvSetPixelFormat(hdc, iPixelFormat);
     246}
     247
     248BOOL WINAPI wglRealizeLayerPalette(HDC hdc, int iLayerPlane, BOOL bRealize)
     249{
     250    return DrvRealizeLayerPalette(hdc, iLayerPlane, bRealize);
     251}
     252
     253BOOL WINAPI wglDeleteContext(HGLRC hglrc)
     254{
     255    return DrvDeleteContext(hglrc);
     256}
     257
     258BOOL WINAPI wglSwapLayerBuffers(HDC hdc, UINT fuPlanes)
     259{
     260    return DrvSwapLayerBuffers(hdc, fuPlanes);
     261}
     262
     263BOOL WINAPI SwapBuffers(HDC hdc)
     264{
     265    return DrvSwapBuffers(hdc);
     266}
     267
     268BOOL WINAPI wglCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
     269{
     270    return DrvCopyContext(hglrcSrc, hglrcDst, mask);
     271}
     272
     273BOOL WINAPI wglShareLists(HGLRC hglrc1, HGLRC hglrc2)
     274{
     275    return DrvShareLists(hglrc1, hglrc2);
     276}
     277
    96278BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc)
    97279{
     
    104286    return DrvGetProcAddress(lpszProc);
    105287}
     288
     289int WINAPI wglDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd)
     290{
     291    return DrvDescribePixelFormat(hdc, iPixelFormat, nBytes, ppfd);
     292}
     293
     294BOOL WINAPI wglDescribeLayerPlane(HDC hdc,int iPixelFormat,
     295                                  int iLayerPlane, UINT nBytes,
     296                                  LPLAYERPLANEDESCRIPTOR plpd)
     297{
     298    return DrvDescribeLayerPlane(hdc, iPixelFormat, iLayerPlane, nBytes, plpd);
     299}
     300
     301int WINAPI wglGetLayerPaletteEntries(HDC hdc, int iLayerPlane,
     302                                     int iStart, int cEntries,
     303                                     COLORREF *pcr)
     304{
     305    return DrvGetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
     306}
     307
     308HGLRC WINAPI wglCreateContext(HDC hdc)
     309{
     310    return DrvCreateContext(hdc);
     311}
     312
    106313#endif
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette