VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/glext.cpp@ 3476

Last change on this file since 3476 was 3476, checked in by vboxsync, 18 years ago

use iprt

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

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