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 |
|
---|
24 | #define VBOX_OGL_WITH_EXTENSION_ARRAY
|
---|
25 | #include "vboxgl.h"
|
---|
26 | #include <VBox/HostServices/wglext.h>
|
---|
27 |
|
---|
28 | #define LOG_GROUP LOG_GROUP_SHARED_OPENGL
|
---|
29 | #include <VBox/log.h>
|
---|
30 | #include <iprt/string.h>
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Initialize OpenGL extensions
|
---|
34 | *
|
---|
35 | * @returns VBox error code
|
---|
36 | */
|
---|
37 | int vboxInitOpenGLExtensions()
|
---|
38 | {
|
---|
39 | const GLubyte *pszExtensions = glGetString(GL_EXTENSIONS);
|
---|
40 | static bool fInitialized = false;
|
---|
41 |
|
---|
42 | if (fInitialized)
|
---|
43 | return VINF_SUCCESS;
|
---|
44 |
|
---|
45 | for (unsigned int i=0;i<RT_ELEMENTS(OpenGLExtensions);i++)
|
---|
46 | {
|
---|
47 | if (strstr((char *)pszExtensions, OpenGLExtensions[i].pszExtName))
|
---|
48 | {
|
---|
49 | *OpenGLExtensions[i].ppfnFunction = vboxDrvIsExtensionAvailable((char *)OpenGLExtensions[i].pszExtFunctionName);
|
---|
50 | OpenGLExtensions[i].fAvailable = !!*OpenGLExtensions[i].ppfnFunction;
|
---|
51 | }
|
---|
52 | }
|
---|
53 | fInitialized = true;
|
---|
54 | return VINF_SUCCESS;
|
---|
55 | }
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Check if an opengl extension function is available
|
---|
59 | *
|
---|
60 | * @returns VBox error code
|
---|
61 | * @param pszFunctionName OpenGL extension function name
|
---|
62 | */
|
---|
63 | bool vboxwglGetProcAddress(char *pszFunctionName)
|
---|
64 | {
|
---|
65 | for (unsigned int i=0;i<RT_ELEMENTS(OpenGLExtensions);i++)
|
---|
66 | {
|
---|
67 | if ( OpenGLExtensions[i].fAvailable
|
---|
68 | && !strcmp(OpenGLExtensions[i].pszExtFunctionName, pszFunctionName))
|
---|
69 | {
|
---|
70 | Log(("vboxwglGetProcAddress: found %s\n", pszFunctionName));
|
---|
71 | return true;
|
---|
72 | }
|
---|
73 | }
|
---|
74 | Log(("vboxwglGetProcAddress: didn't find %s\n", pszFunctionName));
|
---|
75 | return false;
|
---|
76 | }
|
---|
77 |
|
---|
78 | #ifdef RT_OS_WINDOWS
|
---|
79 | void vboxwglSwapIntervalEXT (VBOXOGLCTX *pClient, uint8_t *pCmdBuffer)
|
---|
80 | {
|
---|
81 | Assert(pfnwglSwapIntervalEXT);
|
---|
82 |
|
---|
83 | OGL_CMD(wglSwapIntervalEXT, 1);
|
---|
84 | OGL_PARAM(int, interval);
|
---|
85 | pClient->lastretval = pfnwglSwapIntervalEXT(interval);
|
---|
86 | if (!pClient->lastretval)
|
---|
87 | Log(("wglSwapIntervalEXT failed with %d\n", GetLastError()));
|
---|
88 |
|
---|
89 | pClient->fHasLastError = true;
|
---|
90 | pClient->ulLastError = GetLastError();
|
---|
91 | }
|
---|
92 |
|
---|
93 | void vboxwglGetSwapIntervalEXT (VBOXOGLCTX *pClient, uint8_t *pCmdBuffer)
|
---|
94 | {
|
---|
95 | Assert(pfnwglGetSwapIntervalEXT);
|
---|
96 |
|
---|
97 | OGL_CMD(wglGetSwapIntervalEXT, 0);
|
---|
98 | pClient->lastretval = pfnwglGetSwapIntervalEXT();
|
---|
99 | if (!pClient->lastretval)
|
---|
100 | Log(("wglGetSwapIntervalEXT failed with %d\n", GetLastError()));
|
---|
101 |
|
---|
102 | pClient->fHasLastError = true;
|
---|
103 | pClient->ulLastError = GetLastError();
|
---|
104 | }
|
---|
105 | #endif /* RT_OS_WINDOWS */
|
---|