packspu_getstring.c revision 49ad08ab15f3b96d2d5ba5134a0506dd7b27fdf1
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* Copyright (c) 2001, Stanford University
45e9809aff7304721fddb95654901b32195c9c7avboxsync * All rights reserved
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * See the file LICENSE.txt for information on redistributing this software.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "packspu.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "cr_packfunctions.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "state/cr_statefuncs.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "cr_string.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "packspu_proto.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncstatic GLubyte gpszExtensions[10000];
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifdef CR_OPENGL_VERSION_2_0
45e9809aff7304721fddb95654901b32195c9c7avboxsyncstatic GLubyte gpszShadingVersion[255]="";
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncstatic void GetString(GLenum name, GLubyte *pszStr)
45e9809aff7304721fddb95654901b32195c9c7avboxsync{
45e9809aff7304721fddb95654901b32195c9c7avboxsync GET_THREAD(thread);
45e9809aff7304721fddb95654901b32195c9c7avboxsync int writeback = 1;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (pack_spu.swap)
45e9809aff7304721fddb95654901b32195c9c7avboxsync crPackGetStringSWAP(name, pszStr, &writeback);
45e9809aff7304721fddb95654901b32195c9c7avboxsync else
45e9809aff7304721fddb95654901b32195c9c7avboxsync crPackGetString(name, pszStr, &writeback);
45e9809aff7304721fddb95654901b32195c9c7avboxsync packspuFlush( (void *) thread );
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync while (writeback)
45e9809aff7304721fddb95654901b32195c9c7avboxsync crNetRecv();
45e9809aff7304721fddb95654901b32195c9c7avboxsync}
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncstatic GLfloat
45e9809aff7304721fddb95654901b32195c9c7avboxsyncGetVersionString(void)
45e9809aff7304721fddb95654901b32195c9c7avboxsync{
45e9809aff7304721fddb95654901b32195c9c7avboxsync GLubyte return_value[100];
45e9809aff7304721fddb95654901b32195c9c7avboxsync GLfloat version;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync GetString(GL_VERSION, return_value);
CRASSERT(crStrlen((char *)return_value) < 100);
version = crStrToFloat((char *) return_value);
version = crStateComputeVersion(version);
return version;
}
static const GLubyte *
GetExtensions(void)
{
GLubyte return_value[10*1000];
const GLubyte *extensions, *ext;
GET_THREAD(thread);
int writeback = 1;
if (pack_spu.swap)
{
crPackGetStringSWAP( GL_EXTENSIONS, return_value, &writeback );
}
else
{
crPackGetString( GL_EXTENSIONS, return_value, &writeback );
}
packspuFlush( (void *) thread );
while (writeback)
crNetRecv();
CRASSERT(crStrlen((char *)return_value) < 10*1000);
/* OK, we got the result from the server. Now we have to
* intersect is with the set of extensions that Chromium understands
* and tack on the Chromium-specific extensions.
*/
extensions = return_value;
ext = crStateMergeExtensions(1, &extensions);
sprintf((char*)gpszExtensions, "%s", ext);
return gpszExtensions;
}
#ifdef WINDOWS
static bool packspuRunningUnderWine(void)
{
return NULL != GetModuleHandle("wined3d.dll");
}
#endif
const GLubyte * PACKSPU_APIENTRY packspu_GetString( GLenum name )
{
GET_CONTEXT(ctx);
switch(name)
{
case GL_EXTENSIONS:
return GetExtensions();
case GL_VERSION:
#if 0 && defined(WINDOWS)
if (packspuRunningUnderWine())
{
GetString(GL_REAL_VERSION, ctx->pszRealVersion);
return ctx->pszRealVersion;
}
else
#endif
{
float version = GetVersionString();
sprintf((char*)ctx->glVersion, "%.1f Chromium %s", version, CR_VERSION_STRING);
return ctx->glVersion;
}
case GL_VENDOR:
#ifdef WINDOWS
if (packspuRunningUnderWine())
{
GetString(GL_REAL_VENDOR, ctx->pszRealVendor);
return ctx->pszRealVendor;
}
else
#endif
{
return crStateGetString(name);
}
case GL_RENDERER:
#ifdef WINDOWS
if (packspuRunningUnderWine())
{
GetString(GL_REAL_RENDERER, ctx->pszRealRenderer);
return ctx->pszRealRenderer;
}
else
#endif
{
return crStateGetString(name);
}
#ifdef CR_OPENGL_VERSION_2_0
case GL_SHADING_LANGUAGE_VERSION:
GetString(GL_SHADING_LANGUAGE_VERSION, gpszShadingVersion);
return gpszShadingVersion;
#endif
#ifdef GL_CR_real_vendor_strings
case GL_REAL_VENDOR:
GetString(GL_REAL_VENDOR, ctx->pszRealVendor);
return ctx->pszRealVendor;
case GL_REAL_VERSION:
GetString(GL_REAL_VERSION, ctx->pszRealVersion);
return ctx->pszRealVersion;
case GL_REAL_RENDERER:
GetString(GL_REAL_RENDERER, ctx->pszRealRenderer);
return ctx->pszRealRenderer;
#endif
default:
return crStateGetString(name);
}
}