Changeset 3438 in vbox
- Timestamp:
- Jul 5, 2007 9:00:44 AM (18 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/OpenGL/OGLComplexSync.cpp
r3436 r3438 24 24 25 25 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 else45 {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 else57 {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 else86 {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 else97 {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_EXPORTS139 /* 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 #endif165 166 26 void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) 167 27 { -
trunk/src/VBox/Additions/WINNT/Graphics/OpenGL/OGLSimpleSync.cpp
r3436 r3438 23 23 #include "VBoxOGL.h" 24 24 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_EXPORTS101 /* 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 #endif144 25 145 26 /* OpenGL functions */ -
trunk/src/VBox/Additions/WINNT/Graphics/OpenGL/drv.cpp
r3419 r3438 92 92 } 93 93 94 /* DrvSetPixelFormat can only be called once for each window (if hdc associated with one). */ 95 BOOL 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 122 HGLRC 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 130 HGLRC 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 138 BOOL 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 148 int 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 158 int 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 168 BOOL 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 176 BOOL 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 184 void 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 191 BOOL 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 199 int 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 210 BOOL 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 218 BOOL 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 226 BOOL 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 94 234 #ifdef VBOX_WITH_WGL_EXPORTS 95 235 /* Test export for directly linking with vboxogl.dll */ 236 int 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 243 BOOL WINAPI wglSetPixelFormat(HDC hdc, int iPixelFormat) 244 { 245 return DrvSetPixelFormat(hdc, iPixelFormat); 246 } 247 248 BOOL WINAPI wglRealizeLayerPalette(HDC hdc, int iLayerPlane, BOOL bRealize) 249 { 250 return DrvRealizeLayerPalette(hdc, iLayerPlane, bRealize); 251 } 252 253 BOOL WINAPI wglDeleteContext(HGLRC hglrc) 254 { 255 return DrvDeleteContext(hglrc); 256 } 257 258 BOOL WINAPI wglSwapLayerBuffers(HDC hdc, UINT fuPlanes) 259 { 260 return DrvSwapLayerBuffers(hdc, fuPlanes); 261 } 262 263 BOOL WINAPI SwapBuffers(HDC hdc) 264 { 265 return DrvSwapBuffers(hdc); 266 } 267 268 BOOL WINAPI wglCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask) 269 { 270 return DrvCopyContext(hglrcSrc, hglrcDst, mask); 271 } 272 273 BOOL WINAPI wglShareLists(HGLRC hglrc1, HGLRC hglrc2) 274 { 275 return DrvShareLists(hglrc1, hglrc2); 276 } 277 96 278 BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc) 97 279 { … … 104 286 return DrvGetProcAddress(lpszProc); 105 287 } 288 289 int WINAPI wglDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd) 290 { 291 return DrvDescribePixelFormat(hdc, iPixelFormat, nBytes, ppfd); 292 } 293 294 BOOL 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 301 int 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 308 HGLRC WINAPI wglCreateContext(HDC hdc) 309 { 310 return DrvCreateContext(hdc); 311 } 312 106 313 #endif -
trunk/src/VBox/HostServices/SharedOpenGL/glwindrv.cpp
r3435 r3438 146 146 HGLRC glrc = 0; 147 147 148 OGL_CMD(DrvCreateContext, 6); 149 OGL_PARAM(HDC, hdc); 148 OGL_CMD(DrvCreateContext, 1); 149 OGL_PARAM(HDC, hdc); 150 151 Log(("DrvCreateContext %x\n", hdc)); 152 Assert(VBOX_OGL_GUEST_TO_HOST_HDC(hdc)); 153 glrc = wglCreateContext(pClient->hdc); 154 155 pClient->lastretval = (uint64_t)glrc; 156 pClient->fHasLastError = true; 157 pClient->ulLastError = GetLastError(); 158 } 159 160 void vboxglDrvSetContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer) 161 { 162 OGL_CMD(DrvSetContext, 2); 163 OGL_PARAM(HDC, hdc); 164 OGL_PARAM(HGLRC, hglrc); 165 166 Log(("DrvSetyContext %x %x\n", hdc, hglrc)); 167 pClient->lastretval = wglMakeCurrent(VBOX_OGL_GUEST_TO_HOST_HDC(hdc), hglrc); 168 if (!pClient->lastretval) 169 Log(("wglMakeCurrent failed with %d\n", GetLastError())); 170 171 pClient->fHasLastError = true; 172 pClient->ulLastError = GetLastError(); 173 } 174 175 void vboxglDrvCopyContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer) 176 { 177 OGL_CMD(DrvDeleteContext, 3); 178 OGL_PARAM(HGLRC, hglrcSrc); 179 OGL_PARAM(HGLRC, hglrcDst); 180 OGL_PARAM(UINT, mask); 181 Log(("DrvCopyContext %x %x %x\n", hglrcSrc, hglrcDst, mask)); 182 pClient->lastretval = wglCopyContext(hglrcSrc, hglrcDst, mask); 183 if (!pClient->lastretval) 184 Log(("wglCopyContext failed with %d\n", GetLastError())); 185 186 pClient->fHasLastError = true; 187 pClient->ulLastError = GetLastError(); 188 } 189 190 void vboxglDrvReleaseContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer) 191 { 192 OGL_CMD(DrvReleaseContext, 1); 193 OGL_PARAM(HGLRC, hglrc); 194 195 Log(("DrvReleaseContext %x\n", hglrc)); 196 /* clear current selection */ 197 pClient->lastretval = wglMakeCurrent(VBOX_OGL_GUEST_TO_HOST_HDC(hdc), NULL); 198 if (!pClient->lastretval) 199 Log(("wglMakeCurrent failed with %d\n", GetLastError())); 200 pClient->fHasLastError = true; 201 pClient->ulLastError = GetLastError(); 202 } 203 204 void vboxglDrvDeleteContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer) 205 { 206 OGL_CMD(DrvDeleteContext, 1); 207 OGL_PARAM(HGLRC, hglrc); 208 209 Log(("DrvDeleteContext %x\n", hglrc)); 210 pClient->lastretval = wglDeleteContext(hglrc); 211 if (!pClient->lastretval) 212 Log(("wglDeleteContext failed with %d\n", GetLastError())); 213 pClient->fHasLastError = true; 214 pClient->ulLastError = GetLastError(); 215 } 216 217 void vboxglDrvCreateLayerContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer) 218 { 219 HGLRC glrc = 0; 220 221 OGL_CMD(DrvCreateLayerContext, 2); 222 OGL_PARAM(HDC, hdc); 223 OGL_PARAM(int, iLayerPlane); 224 225 Log(("DrvCreateLayerContext %x %d\n", hdc, iLayerPlane)); 226 Assert(VBOX_OGL_GUEST_TO_HOST_HDC(hdc)); 227 glrc = wglCreateLayerContext(VBOX_OGL_GUEST_TO_HOST_HDC(hdc), iLayerPlane); 228 229 pClient->lastretval = (uint64_t)glrc; 230 pClient->fHasLastError = true; 231 pClient->ulLastError = GetLastError(); 232 } 233 234 void vboxglDrvShareLists(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer) 235 { 236 OGL_CMD(DrvShareLists, 3); 237 OGL_PARAM(HGLRC, hglrc1); 238 OGL_PARAM(HGLRC, hglrc2); 239 240 Log(("DrvShareLists %x %x\n", hglrc1, hglrc2)); 241 pClient->lastretval = wglShareLists(hglrc1, hglrc2); 242 pClient->fHasLastError = true; 243 pClient->ulLastError = GetLastError(); 244 } 245 246 247 void vboxglDrvRealizeLayerPalette(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer) 248 { 249 OGL_CMD(DrvRealizeLayerPalette, 3); 250 OGL_PARAM(HDC, hdc); 251 OGL_PARAM(int, iLayerPlane); 252 OGL_PARAM(BOOL, bRealize); 253 Log(("DrvRealizeLayerPalette %x %d %d\n", hdc, iLayerPlane, bRealize)); 254 pClient->lastretval = wglRealizeLayerPalette(VBOX_OGL_GUEST_TO_HOST_HDC(hdc), iLayerPlane, bRealize); 255 pClient->fHasLastError = true; 256 pClient->ulLastError = GetLastError(); 257 } 258 259 void vboxglDrvSwapLayerBuffers(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer) 260 { 261 OGL_CMD(DrvSwapLayerBuffers, 2); 262 OGL_PARAM(HDC, hdc); 263 OGL_PARAM(UINT, fuPlanes); 264 Log(("DrvSwapLayerBuffers %x %d\n", hdc, fuPlanes)); 265 pClient->lastretval = wglSwapLayerBuffers(VBOX_OGL_GUEST_TO_HOST_HDC(hdc), fuPlanes); 266 pClient->fHasLastError = true; 267 pClient->ulLastError = GetLastError(); 268 } 269 270 void vboxglDrvSetPixelFormat(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer) 271 { 272 int rc; 273 PIXELFORMATDESCRIPTOR pfd; 274 275 OGL_CMD(DrvSetPixelFormat, 4); 276 OGL_PARAM(HDC, hdc); 277 OGL_PARAM(int, iPixelFormat); 150 278 OGL_PARAM(uint32_t, cx); 151 279 OGL_PARAM(uint32_t, cy); 152 OGL_PARAM(BYTE, cColorBits); 153 OGL_PARAM(BYTE, iPixelType); 154 OGL_PARAM(BYTE, cDepthBits); 155 156 Log(("DrvCreateContext %x (%d,%d) bpp=%d type=%x depth=%d\n", hdc, cx, cy, cColorBits, iPixelType, cDepthBits)); 280 157 281 #ifdef VBOX_OGL_DEBUG_WINDOW_OUTPUT 158 282 if (!pClient->hwnd) … … 162 286 RTThreadSleep(100); 163 287 } 164 SetWindowPos(pClient->hwnd, NULL, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER); 165 166 PIXELFORMATDESCRIPTOR pfd = {0}; 167 int format; 288 RECT rect; 289 rect.bottom = 0; 290 rect.left = 0; 291 rect.right = cx; 292 rect.top = cy; 293 /* Convert client rectangel to window rectangle */ 294 AdjustWindowRect(&rect, WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE, FALSE); 295 SetWindowPos(pClient->hwnd, NULL, 0, 0, rect.right - rect.left, rect.top - rect.bottom, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER); 168 296 169 297 pClient->hdc = GetDC(pClient->hwnd); 170 298 171 pfd.nSize = sizeof(pfd);172 pfd.nVersion = 1;173 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;174 pfd.iPixelType = iPixelType;175 pfd.cColorBits = cColorBits;176 pfd.cDepthBits = cDepthBits;177 pfd.iLayerType = PFD_MAIN_PLANE;178 uint32_t lasterr = glGetError();179 format = ChoosePixelFormat(pClient->hdc, &pfd);180 SetPixelFormat(pClient->hdc, format, &pfd);181 182 glrc = wglCreateContext(pClient->hdc);183 Assert(glrc);184 #else185 AssertFailed();186 glrc = 0;187 #endif188 189 pClient->lastretval = (uint64_t)glrc;190 pClient->fHasLastError = true;191 pClient->ulLastError = GetLastError();192 }193 194 void vboxglDrvSetContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer)195 {196 OGL_CMD(DrvSetContext, 2);197 OGL_PARAM(HDC, hdc);198 OGL_PARAM(HGLRC, hglrc);199 200 Log(("DrvSetyContext %x %x\n", hdc, hglrc));201 #ifdef VBOX_OGL_DEBUG_WINDOW_OUTPUT202 pClient->lastretval = wglMakeCurrent(pClient->hdc, hglrc);203 if (!pClient->lastretval)204 Log(("wglMakeCurrent failed with %d\n", GetLastError()));205 #else206 AssertFailed();207 #endif208 pClient->fHasLastError = true;209 pClient->ulLastError = GetLastError();210 }211 212 void vboxglDrvCopyContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer)213 {214 OGL_CMD(DrvDeleteContext, 3);215 OGL_PARAM(HGLRC, hglrcSrc);216 OGL_PARAM(HGLRC, hglrcDst);217 OGL_PARAM(UINT, mask);218 Log(("DrvCopyContext %x %x %x\n", hglrcSrc, hglrcDst, mask));219 pClient->lastretval = wglCopyContext(hglrcSrc, hglrcDst, mask);220 if (!pClient->lastretval)221 Log(("wglCopyContext failed with %d\n", GetLastError()));222 223 pClient->fHasLastError = true;224 pClient->ulLastError = GetLastError();225 }226 227 void vboxglDrvReleaseContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer)228 {229 OGL_CMD(DrvReleaseContext, 1);230 OGL_PARAM(HGLRC, hglrc);231 232 Log(("DrvReleaseContext %x\n", hglrc));233 /* clear current selection */234 pClient->lastretval = wglMakeCurrent(pClient->hdc, NULL);235 if (!pClient->lastretval)236 Log(("wglMakeCurrent failed with %d\n", GetLastError()));237 pClient->fHasLastError = true;238 pClient->ulLastError = GetLastError();239 }240 241 void vboxglDrvDeleteContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer)242 {243 OGL_CMD(DrvDeleteContext, 1);244 OGL_PARAM(HGLRC, hglrc);245 246 Log(("DrvDeleteContext %x\n", hglrc));247 pClient->lastretval = wglDeleteContext(hglrc);248 if (!pClient->lastretval)249 Log(("wglDeleteContext failed with %d\n", GetLastError()));250 pClient->fHasLastError = true;251 pClient->ulLastError = GetLastError();252 }253 254 void vboxglDrvCreateLayerContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer)255 {256 HGLRC glrc = 0;257 258 OGL_CMD(DrvCreateLayerContext, 7);259 OGL_PARAM(HDC, hdc);260 OGL_PARAM(int, iLayerPlane);261 OGL_PARAM(uint32_t, cx);262 OGL_PARAM(uint32_t, cy);263 OGL_PARAM(BYTE, cColorBits);264 OGL_PARAM(BYTE, iPixelType);265 OGL_PARAM(BYTE, cDepthBits);266 267 Log(("DrvCreateLayerContext %x (%d,%d) bpp=%d type=%x depth=%d\n", hdc, cx, cy, cColorBits, iPixelType, cDepthBits));268 #ifdef VBOX_OGL_DEBUG_WINDOW_OUTPUT269 if (!pClient->hwnd)270 {271 pClient->hwnd= CreateWindow("VBoxOGL", "VirtualBox OpenGL",272 WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE,273 0, 0, cx, cy,274 NULL, NULL, 0, NULL);275 }276 else277 {278 SetWindowPos(pClient->hwnd, NULL, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER);279 }280 PIXELFORMATDESCRIPTOR pfd = {0};281 int format;282 283 pClient->hdc = GetDC(pClient->hwnd);284 285 pfd.nSize = sizeof(pfd);286 pfd.nVersion = 1;287 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;288 pfd.iPixelType = iPixelType;289 pfd.cColorBits = cColorBits;290 pfd.cDepthBits = cDepthBits;291 pfd.iLayerType = PFD_MAIN_PLANE;292 format = ChoosePixelFormat(pClient->hdc, &pfd);293 SetPixelFormat(pClient->hdc, format, &pfd);294 295 glrc = wglCreateLayerContext(pClient->hdc, iLayerPlane);296 #else297 AssertFailed();298 #endif299 300 pClient->lastretval = (uint64_t)glrc;301 pClient->fHasLastError = true;302 pClient->ulLastError = GetLastError();303 }304 305 void vboxglDrvShareLists(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer)306 {307 OGL_CMD(DrvShareLists, 3);308 OGL_PARAM(HGLRC, hglrc1);309 OGL_PARAM(HGLRC, hglrc2);310 311 Log(("DrvShareLists %x %x\n", hglrc1, hglrc2));312 pClient->lastretval = wglShareLists(hglrc1, hglrc2);313 pClient->fHasLastError = true;314 pClient->ulLastError = GetLastError();315 }316 317 318 void vboxglDrvRealizeLayerPalette(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer)319 {320 OGL_CMD(DrvRealizeLayerPalette, 3);321 OGL_PARAM(HDC, hdc);322 OGL_PARAM(int, iLayerPlane);323 OGL_PARAM(BOOL, bRealize);324 Log(("DrvRealizeLayerPalette %x %d %d\n", hdc, iLayerPlane, bRealize));325 pClient->lastretval = wglRealizeLayerPalette(VBOX_OGL_GUEST_TO_HOST_HDC(hdc), iLayerPlane, bRealize);326 pClient->fHasLastError = true;327 pClient->ulLastError = GetLastError();328 }329 330 void vboxglDrvSwapLayerBuffers(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer)331 {332 OGL_CMD(DrvSwapLayerBuffers, 2);333 OGL_PARAM(HDC, hdc);334 OGL_PARAM(UINT, fuPlanes);335 Log(("DrvSwapLayerBuffers %x %d\n", hdc, fuPlanes));336 pClient->lastretval = wglSwapLayerBuffers(VBOX_OGL_GUEST_TO_HOST_HDC(hdc), fuPlanes);337 pClient->fHasLastError = true;338 pClient->ulLastError = GetLastError();339 }340 341 void vboxglDrvSetPixelFormat(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer)342 {343 int rc;344 PIXELFORMATDESCRIPTOR pfd;345 346 OGL_CMD(DrvSetPixelFormat, 2);347 OGL_PARAM(HDC, hdc);348 OGL_PARAM(int, iPixelFormat);349 350 Log(("DrvSetPixelFormat %x %d\n", hdc, iPixelFormat));351 299 rc = DescribePixelFormat(VBOX_OGL_GUEST_TO_HOST_HDC(hdc), iPixelFormat, sizeof(pfd), &pfd); 352 300 if (rc) … … 359 307 pClient->lastretval = 0; 360 308 } 309 310 #else 311 AssertFailed(); 312 #endif 313 314 Log(("DrvSetPixelFormat %x %d (%d,%d)\n", hdc, iPixelFormat, cx, cy)); 361 315 pClient->fHasLastError = true; 362 316 pClient->ulLastError = GetLastError();
Note:
See TracChangeset
for help on using the changeset viewer.