1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox OpenGL helper functions
|
---|
4 | *
|
---|
5 | * OpenGL extensions
|
---|
6 | *
|
---|
7 | * References: http://oss.sgi.com/projects/ogl-sample/registry/
|
---|
8 | * http://icps.u-strasbg.fr/~marchesin/perso/extensions/
|
---|
9 | */
|
---|
10 |
|
---|
11 | /*
|
---|
12 | *
|
---|
13 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
14 | *
|
---|
15 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
16 | * available from http://www.virtualbox.org. This file is free software;
|
---|
17 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
18 | * General Public License as published by the Free Software Foundation,
|
---|
19 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
20 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
21 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
22 | *
|
---|
23 | * If you received this file as part of a commercial VirtualBox
|
---|
24 | * distribution, then only the terms of your commercial VirtualBox
|
---|
25 | * license agreement apply instead of the previous paragraph.
|
---|
26 | *
|
---|
27 | */
|
---|
28 |
|
---|
29 | #define VBOX_OGL_WITH_EXTENSION_ARRAY
|
---|
30 | #include "vboxgl.h"
|
---|
31 | #include <VBox/HostServices/wglext.h>
|
---|
32 |
|
---|
33 | #define LOG_GROUP LOG_GROUP_SHARED_OPENGL
|
---|
34 | #include <VBox/log.h>
|
---|
35 | #include <iprt/string.h>
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Initialize OpenGL extensions
|
---|
39 | *
|
---|
40 | * @returns VBox error code
|
---|
41 | */
|
---|
42 | int vboxInitOpenGLExtensions()
|
---|
43 | {
|
---|
44 | const GLubyte *pszExtensions = glGetString(GL_EXTENSIONS);
|
---|
45 | static bool fInitialized = false;
|
---|
46 |
|
---|
47 | if (fInitialized)
|
---|
48 | return VINF_SUCCESS;
|
---|
49 |
|
---|
50 | for (unsigned int i=0;i<RT_ELEMENTS(OpenGLExtensions);i++)
|
---|
51 | {
|
---|
52 | if (strstr((char *)pszExtensions, OpenGLExtensions[i].pszExtName))
|
---|
53 | {
|
---|
54 | *OpenGLExtensions[i].ppfnFunction = vboxDrvIsExtensionAvailable((char *)OpenGLExtensions[i].pszExtFunctionName);
|
---|
55 | OpenGLExtensions[i].fAvailable = !!*OpenGLExtensions[i].ppfnFunction;
|
---|
56 | }
|
---|
57 | }
|
---|
58 | fInitialized = true;
|
---|
59 | return VINF_SUCCESS;
|
---|
60 | }
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * Check if an opengl extension function is available
|
---|
64 | *
|
---|
65 | * @returns VBox error code
|
---|
66 | * @param pszFunctionName OpenGL extension function name
|
---|
67 | */
|
---|
68 | bool vboxwglGetProcAddress(char *pszFunctionName)
|
---|
69 | {
|
---|
70 | for (unsigned int i=0;i<RT_ELEMENTS(OpenGLExtensions);i++)
|
---|
71 | {
|
---|
72 | if ( OpenGLExtensions[i].fAvailable
|
---|
73 | && !strcmp(OpenGLExtensions[i].pszExtFunctionName, pszFunctionName))
|
---|
74 | {
|
---|
75 | Log(("vboxwglGetProcAddress: found %s\n", pszFunctionName));
|
---|
76 | return true;
|
---|
77 | }
|
---|
78 | }
|
---|
79 | Log(("vboxwglGetProcAddress: didn't find %s\n", pszFunctionName));
|
---|
80 | return false;
|
---|
81 | }
|
---|
82 |
|
---|
83 | #ifdef RT_OS_WINDOWS
|
---|
84 | void vboxwglSwapIntervalEXT (VBOXOGLCTX *pClient, uint8_t *pCmdBuffer)
|
---|
85 | {
|
---|
86 | Assert(pfnwglSwapIntervalEXT);
|
---|
87 |
|
---|
88 | OGL_CMD(wglSwapIntervalEXT, 1);
|
---|
89 | OGL_PARAM(int, interval);
|
---|
90 | pClient->lastretval = pfnwglSwapIntervalEXT(interval);
|
---|
91 | if (!pClient->lastretval)
|
---|
92 | Log(("wglSwapIntervalEXT failed with %d\n", GetLastError()));
|
---|
93 |
|
---|
94 | pClient->fHasLastError = true;
|
---|
95 | pClient->ulLastError = GetLastError();
|
---|
96 | }
|
---|
97 |
|
---|
98 | void vboxwglGetSwapIntervalEXT (VBOXOGLCTX *pClient, uint8_t *pCmdBuffer)
|
---|
99 | {
|
---|
100 | Assert(pfnwglGetSwapIntervalEXT);
|
---|
101 |
|
---|
102 | OGL_CMD(wglGetSwapIntervalEXT, 0);
|
---|
103 | pClient->lastretval = pfnwglGetSwapIntervalEXT();
|
---|
104 | if (!pClient->lastretval)
|
---|
105 | Log(("wglGetSwapIntervalEXT failed with %d\n", GetLastError()));
|
---|
106 |
|
---|
107 | pClient->fHasLastError = true;
|
---|
108 | pClient->ulLastError = GetLastError();
|
---|
109 | }
|
---|
110 | #endif /* RT_OS_WINDOWS */
|
---|