VBoxOGL.cpp revision 4604ab7d38c2bd2dfc255aa1facffdf81c1c9153
/** @file
*
* VBoxDisp -- Windows Guest OpenGL ICD
*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#include "VBoxOGL.h"
#include <VBox/VBoxGuest.h>
#include <stdarg.h>
#include <stdio.h>
HINSTANCE hDllVBoxOGL = 0;
static VBOX_OGL_CTX vboxOGLCtx = {0};
/**
* Set the thread local OpenGL context
*
* @param pCtx thread local OpenGL context ptr
*/
{
}
/**
* Return the thread local OpenGL context
*
* @return thread local OpenGL context ptr or NULL if failure
*/
{
if (!pCtx)
{
/* lazy init */
}
return pCtx;
}
/**
* Initialize the OpenGL guest-host communication channel
*
* @return success or failure (boolean)
* @param hDllInst Dll instance handle
*/
{
dwOGLTlsIndex = TlsAlloc();
if (dwOGLTlsIndex == TLS_OUT_OF_INDEXES)
{
return FALSE;
}
/* open VBox guest driver */
NULL,
NULL);
{
return FALSE;
}
return TRUE;
}
/**
* Destroy the OpenGL guest-host communication channel
*
* @return success or failure (boolean)
*/
{
DbgPrintf(("VBoxOGLExit\n"));
hDllVBoxOGL = 0;
return TRUE;
}
/**
* Initialize new thread
*
* @return success or failure (boolean)
*/
{
if (!pCtx)
return FALSE;
pCtx->pCmdBuffer = (uint8_t *)VirtualAlloc(NULL, VBOX_OGL_MAX_CMD_BUFFER, MEM_COMMIT, PAGE_READWRITE);
if (!pCtx->pCmdBuffer)
return FALSE;
NULL))
{
{
}
}
else
{
return FALSE;
}
if ( VBOX_FAILURE(rc)
{
return FALSE;
}
/* Initialize OpenGL extensions */
return TRUE;
}
/**
* Clean up for terminating thread
*
* @return success or failure (boolean)
*/
{
pCtx = VBoxOGLGetThreadCtx();
{
NULL);
if (!bRet)
{
}
}
if (pCtx)
{
if (pCtx->pCmdBuffer)
}
return TRUE;
}
/**
* Send an HGCM request
*
* @return VBox status code
* @param pvData Data pointer
* @param cbData Data size
*/
{
NULL))
{
return VINF_SUCCESS;
}
return VERR_NOT_SUPPORTED;
}
#ifdef DEBUG
/**
* Log to the debug output device
*
* @param pszFormat Format string
* @param ... Variable parameters
*/
void VBoxDbgLog(char *pszFormat, ...)
{
{
// OutputDebugStringA(Buffer);
}
}
#endif
{
/** @todo if fetch error flag set -> flush buffer */
return pCtx->glLastError;
}
{
}
/**
* Query OpenGL strings
*
* @returns OpenGL string pointer
* @param name string type
*/
{
switch (name)
{
/* Note: We hide the host vendor and renderer to avoid exposing potential critical information (exploits) */
case GL_VENDOR:
return (const GLubyte *)VBOX_VENDOR;
case GL_RENDERER:
return (const GLubyte *)"VirtualBox OpenGL Renderer";
case GL_VERSION:
return (const GLubyte *)szOpenGLVersion;
case GL_EXTENSIONS:
return (const GLubyte *)szOpenGLExtensions;
default:
return NULL;
}
}
/**
* Flush the OpenGL command queue and return the return val of the last command
*
* @returns return val of last command
*/
{
/* reset command buffer */
if ( VBOX_FAILURE(rc)
{
return 0;
}
#ifdef DEBUG
#endif
}
/**
* Flush the OpenGL command queue and return the return val of the last command
* The last command's final parameter is a pointer where its result is stored
*
* @returns return val of last command
* @param pLastParam Last parameter's address
* @param cbParam Last parameter's size
*/
{
if (cbParam)
{
}
else
{
/* Placeholder as HGCM doesn't like NULL pointers */
}
/* reset command buffer */
if ( VBOX_FAILURE(rc)
{
return 0;
}
#ifdef DEBUG
#endif
}
/**
* Check if an OpenGL extension is available on the host
*
* @returns available or not
* @param pszExtFunctionName
*/
bool VBoxIsExtensionAvailable(const char *pszExtFunctionName)
{
if ( VBOX_FAILURE(rc)
{
return false;
}
return true;
}