-/* $Id: osmesa.c,v 1.93 2002/10/24 23:57:23 brianp Exp $ */
+/* $Id: osmesa.c,v 1.94 2002/10/25 21:06:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
{
int i;
for (i = 0; functions[i].Name; i++) {
- if (strcmp(functions[i].Name, funcName) == 0)
+ if (_mesa_strcmp(functions[i].Name, funcName) == 0)
return (void *) functions[i].Address;
}
return (void *) _glapi_get_proc_address(funcName);
-/* $Id: fakeglx.c,v 1.70 2002/10/24 23:57:23 brianp Exp $ */
+/* $Id: fakeglx.c,v 1.71 2002/10/25 21:06:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
if (dbFlag) {
/* Check if the MESA_BACK_BUFFER env var is set */
- char *backbuffer = getenv("MESA_BACK_BUFFER");
+ char *backbuffer = _mesa_getenv("MESA_BACK_BUFFER");
if (backbuffer) {
if (backbuffer[0]=='p' || backbuffer[0]=='P') {
ximageFlag = GL_FALSE;
/* Comparing IDs uses less memory but sometimes fails. */
/* XXX revisit this after 3.0 is finished. */
- if (getenv("MESA_GLX_VISUAL_HACK"))
+ if (_mesa_getenv("MESA_GLX_VISUAL_HACK"))
comparePointers = GL_TRUE;
else
comparePointers = GL_FALSE;
);
}
else if (is_usable_visual( visinfo )) {
- if (getenv("MESA_GLX_FORCE_CI")) {
+ if (_mesa_getenv("MESA_GLX_FORCE_CI")) {
/* Configure this visual as a COLOR INDEX visual. */
return save_glx_visual( dpy, visinfo,
GL_FALSE, /* rgb */
int depth, xclass = -1;
XVisualInfo *vis;
- if (!getenv( varname )) {
+ if (!_mesa_getenv( varname )) {
return NULL;
}
- strncpy( value, getenv(varname), 100 );
+ _mesa_strncpy( value, _mesa_getenv(varname), 100 );
value[99] = 0;
sscanf( value, "%s %d", type, &depth );
- if (strcmp(type,"TrueColor")==0) xclass = TrueColor;
- else if (strcmp(type,"DirectColor")==0) xclass = DirectColor;
- else if (strcmp(type,"PseudoColor")==0) xclass = PseudoColor;
- else if (strcmp(type,"StaticColor")==0) xclass = StaticColor;
- else if (strcmp(type,"GrayScale")==0) xclass = GrayScale;
- else if (strcmp(type,"StaticGray")==0) xclass = StaticGray;
+ if (_mesa_strcmp(type,"TrueColor")==0) xclass = TrueColor;
+ else if (_mesa_strcmp(type,"DirectColor")==0) xclass = DirectColor;
+ else if (_mesa_strcmp(type,"PseudoColor")==0) xclass = PseudoColor;
+ else if (_mesa_strcmp(type,"StaticColor")==0) xclass = StaticColor;
+ else if (_mesa_strcmp(type,"GrayScale")==0) xclass = GrayScale;
+ else if (_mesa_strcmp(type,"StaticGray")==0) xclass = StaticGray;
if (xclass>-1 && depth>0) {
vis = get_visual( dpy, scr, depth, xclass );
if (b) {
XMesaDestroyBuffer(b);
}
- else if (getenv("MESA_DEBUG")) {
+ else if (_mesa_getenv("MESA_DEBUG")) {
_mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
}
}
if (buffer) {
XMesaSwapBuffers(buffer);
}
- else if (getenv("MESA_DEBUG")) {
+ else if (_mesa_getenv("MESA_DEBUG")) {
_mesa_warning(NULL, "Mesa: glXSwapBuffers: invalid drawable\n");
}
}
if (buffer) {
XMesaCopySubBuffer(buffer, x, y, width, height);
}
- else if (getenv("MESA_DEBUG")) {
+ else if (_mesa_getenv("MESA_DEBUG")) {
_mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
}
}
get_extensions( void )
{
#ifdef FX
- const char *fx = getenv("MESA_GLX_FX");
+ const char *fx = _mesa_getenv("MESA_GLX_FX");
if (fx && fx[0] != 'd') {
return EXTENSIONS;
}
-/* $Id: xm_api.c,v 1.46 2002/10/24 23:57:23 brianp Exp $ */
+/* $Id: xm_api.c,v 1.47 2002/10/25 21:06:34 brianp Exp $ */
/*
* Mesa 3-D graphics library
{
(void)DitherValues; /* Muffle compiler */
- if (getenv("MESA_DEBUG"))
+ if (_mesa_getenv("MESA_DEBUG"))
fprintf( stderr, "X/Mesa error: %s\n", msg );
}
}
else {
double x = (double) value / (double) max;
- return IROUND_POS((GLfloat) max * pow(x, 1.0F/gamma));
+ return IROUND_POS((GLfloat) max * _mesa_pow(x, 1.0F/gamma));
}
}
b->shminfo.shmid = shmget( IPC_PRIVATE, b->backimage->bytes_per_line
* b->backimage->height, IPC_CREAT|0777 );
if (b->shminfo.shmid < 0) {
- if (getenv("MESA_DEBUG"))
+ if (_mesa_getenv("MESA_DEBUG"))
perror("alloc_back_buffer");
XDestroyImage( b->backimage );
b->backimage = NULL;
b->shminfo.shmaddr = b->backimage->data
= (char*)shmat( b->shminfo.shmid, 0, 0 );
if (b->shminfo.shmaddr == (char *) -1) {
- if (getenv("MESA_DEBUG"))
+ if (_mesa_getenv("MESA_DEBUG"))
perror("alloc_back_buffer");
XDestroyImage( b->backimage );
shmctl( b->shminfo.shmid, IPC_RMID, 0 );
buffer->pixel_to_b[xcol.pixel] = gray;
}
- if (colorsfailed && getenv("MESA_DEBUG")) {
+ if (colorsfailed && _mesa_getenv("MESA_DEBUG")) {
fprintf( stderr,
"Note: %d out of 256 needed colors do not match exactly.\n",
colorsfailed );
}
}
- if (colorsfailed && getenv("MESA_DEBUG")) {
+ if (colorsfailed && _mesa_getenv("MESA_DEBUG")) {
fprintf( stderr,
"Note: %d out of %d needed colors do not match exactly.\n",
colorsfailed, _R*_G*_B );
g = 1.0 / v->RedGamma;
for (i=0; i<256; i++) {
- GLint red = IROUND_POS(255.0 * pow( hpcr_rgbTbl[0][i]/255.0, g ));
+ GLint red = IROUND_POS(255.0 * _mesa_pow( hpcr_rgbTbl[0][i]/255.0, g ));
v->hpcr_rgbTbl[0][i] = CLAMP( red, 16, 239 );
}
g = 1.0 / v->GreenGamma;
for (i=0; i<256; i++) {
- GLint green = IROUND_POS(255.0 * pow( hpcr_rgbTbl[1][i]/255.0, g ));
+ GLint green = IROUND_POS(255.0 * _mesa_pow( hpcr_rgbTbl[1][i]/255.0, g ));
v->hpcr_rgbTbl[1][i] = CLAMP( green, 16, 239 );
}
g = 1.0 / v->BlueGamma;
for (i=0; i<256; i++) {
- GLint blue = IROUND_POS(255.0 * pow( hpcr_rgbTbl[2][i]/255.0, g ));
+ GLint blue = IROUND_POS(255.0 * _mesa_pow( hpcr_rgbTbl[2][i]/255.0, g ));
v->hpcr_rgbTbl[2][i] = CLAMP( blue, 32, 223 );
}
v->undithered_pf = PF_HPCR; /* can't really disable dithering for now */
/* which method should I use to clear */
/* GL_FALSE: keep the ordinary method */
/* GL_TRUE : clear with dither pattern */
- v->hpcr_clear_flag = getenv("MESA_HPCR_CLEAR") ? GL_TRUE : GL_FALSE;
+ v->hpcr_clear_flag = _mesa_getenv("MESA_HPCR_CLEAR") ? GL_TRUE : GL_FALSE;
if (v->hpcr_clear_flag) {
v->hpcr_clear_pixmap = XMesaCreatePixmap(v->display,
}
v->index_bits = 0;
- if (getenv("MESA_NO_DITHER")) {
+ if (_mesa_getenv("MESA_NO_DITHER")) {
v->dithered_pf = v->undithered_pf;
}
}
* which can help Brian figure out what's going on when a user
* reports bugs.
*/
- if (getenv("MESA_INFO")) {
+ if (_mesa_getenv("MESA_INFO")) {
fprintf(stderr, "X/Mesa visual = %p\n", (void *) v);
fprintf(stderr, "X/Mesa dithered pf = %u\n", v->dithered_pf);
fprintf(stderr, "X/Mesa undithered pf = %u\n", v->undithered_pf);
GLint red_bits, green_bits, blue_bits, alpha_bits;
/* For debugging only */
- if (getenv("MESA_XSYNC")) {
+ if (_mesa_getenv("MESA_XSYNC")) {
/* This makes debugging X easier.
* In your debugger, set a breakpoint on _XError to stop when an
* X protocol error is generated.
#endif
/* check for MESA_GAMMA environment variable */
- gamma = getenv("MESA_GAMMA");
+ gamma = _mesa_getenv("MESA_GAMMA");
if (gamma) {
v->RedGamma = v->GreenGamma = v->BlueGamma = 0.0;
sscanf( gamma, "%f %f %f", &v->RedGamma, &v->GreenGamma, &v->BlueGamma );
if (GET_VISUAL_DEPTH(v) != attr.depth) {
#endif
- if (getenv("MESA_DEBUG")) {
+ if (_mesa_getenv("MESA_DEBUG")) {
fprintf(stderr, "XMesaCreateWindowBuffer: depth mismatch between visual and window!\n");
}
return NULL;
b->cmap = attr.colormap;
}
else {
- if (getenv("MESA_DEBUG")) {
+ if (_mesa_getenv("MESA_DEBUG")) {
fprintf(stderr, "Window %u has no colormap!\n", (unsigned int) w);
}
/* this is weird, a window w/out a colormap!? */
}
#ifdef FX
- fxEnvVar = getenv("MESA_GLX_FX");
+ fxEnvVar = _mesa_getenv("MESA_GLX_FX");
if (fxEnvVar) {
if (fxEnvVar[0]!='d') {
int attribs[100];
GLboolean XMesaSetFXmode( GLint mode )
{
#ifdef FX
- const char *fx = getenv("MESA_GLX_FX");
+ const char *fx = _mesa_getenv("MESA_GLX_FX");
if (fx && fx[0] != 'd') {
GET_CURRENT_CONTEXT(ctx);
GrHwConfiguration hw;
-/* $Id: enums.c,v 1.22 2002/10/24 23:57:20 brianp Exp $ */
+/* $Id: enums.c,v 1.23 2002/10/25 21:06:26 brianp Exp $ */
/*
* Mesa 3-D graphics library
static int compar_name( const enum_elt *a, const enum_elt *b )
{
- return strcmp(a->c, b->c);
+ return _mesa_strcmp(a->c, b->c);
}
-/* $Id: extensions.c,v 1.84 2002/10/24 23:57:20 brianp Exp $ */
+/* $Id: extensions.c,v 1.85 2002/10/25 21:06:27 brianp Exp $ */
/*
* Mesa 3-D graphics library
{
struct extension *t = MALLOC_STRUCT(extension);
t->enabled = enabled;
- strncpy(t->name, name, MAX_EXT_NAMELEN);
+ _mesa_strncpy(t->name, name, MAX_EXT_NAMELEN);
t->name[MAX_EXT_NAMELEN] = 0;
t->flag = flag_ptr;
if (t->flag)
*/
struct extension *i;
foreach( i, ctx->Extensions.ext_list )
- if (strncmp(i->name, name, MAX_EXT_NAMELEN) == 0)
+ if (_mesa_strncmp(i->name, name, MAX_EXT_NAMELEN) == 0)
break;
if (i == ctx->Extensions.ext_list) {
{
struct extension *i;
foreach( i, ctx->Extensions.ext_list )
- if (strncmp(i->name, name, MAX_EXT_NAMELEN) == 0) {
+ if (_mesa_strncmp(i->name, name, MAX_EXT_NAMELEN) == 0) {
if (i->enabled)
return GL_TRUE;
else
GLuint len = 0;
foreach (i, ctx->Extensions.ext_list)
if (i->enabled)
- len += strlen(i->name) + 1;
+ len += _mesa_strlen(i->name) + 1;
if (len == 0)
return "";
- str = (char *)MALLOC(len * sizeof(char));
+ str = (char *) _mesa_malloc(len * sizeof(char));
ctx->Extensions.ext_string = str;
foreach (i, ctx->Extensions.ext_list)
if (i->enabled) {
- strcpy(str, i->name);
- str += strlen(str);
+ _mesa_strcpy(str, i->name);
+ str += _mesa_strlen(str);
*str++ = ' ';
}
-/* $Id: imports.c,v 1.21 2002/10/24 23:57:21 brianp Exp $ */
+/* $Id: imports.c,v 1.22 2002/10/25 21:06:28 brianp Exp $ */
/*
* Mesa 3-D graphics library
}
+double
+_mesa_sin(double a)
+{
+#ifdef XFree86LOADER
+ return xf86sin(a);
+#else
+ return sin(a);
+#endif
+}
+
+
+double
+_mesa_cos(double a)
+{
+#ifdef XFree86LOADER
+ return xf86cos(a);
+#else
+ return cos(a);
+#endif
+}
+
+
+double
+_mesa_sqrt(double x)
+{
+#ifdef XFree86LOADER
+ return xf86sqrt(x);
+#else
+ return sqrt(x);
+#endif
+}
+
+
+double
+_mesa_pow(double x, double y)
+{
+#ifdef XFree86LOADER
+ return xf86pow(x, y);
+#else
+ return pow(x, y);
+#endif
+}
+
+
char *
_mesa_getenv( const char *var )
{
}
+char *
+_mesa_strncat( char *dest, const char *src, size_t n )
+{
+#ifdef XFree86LOADER
+ return xf86strncat(dest, src, n);
+#else
+ return strncat(dest, src, n);
+#endif
+}
+
+
+char *
+_mesa_strcpy( char *dest, const char *src )
+{
+#ifdef XFree86LOADER
+ return xf86strcpy(dest, src);
+#else
+ return strcpy(dest, src);
+#endif
+}
+
+
+char *
+_mesa_strncpy( char *dest, const char *src, size_t n )
+{
+#ifdef XFree86LOADER
+ return xf86strncpy(dest, src, n);
+#else
+ return strncpy(dest, src, n);
+#endif
+}
+
+
+size_t
+_mesa_strlen( const char *s )
+{
+#ifdef XFree86LOADER
+ return xf86strlen(s);
+#else
+ return strlen(s);
+#endif
+}
+
+
+int
+_mesa_strcmp( const char *s1, const char *s2 )
+{
+#ifdef XFree86LOADER
+ return xf86strcmp(s1, s2);
+#else
+ return strcmp(s1, s2);
+#endif
+}
+
+
+int
+_mesa_strncmp( const char *s1, const char *s2, size_t n )
+{
+#ifdef XFree86LOADER
+ return xf86strncmp(s1, s2, n);
+#else
+ return strncmp(s1, s2, n);
+#endif
+}
+
+
int
_mesa_atoi(const char *s)
{
-/* $Id: imports.h,v 1.6 2002/10/24 23:57:21 brianp Exp $ */
+/* $Id: imports.h,v 1.7 2002/10/25 21:06:29 brianp Exp $ */
/*
* Mesa 3-D graphics library
_mesa_bzero( void *dst, size_t n );
+extern double
+_mesa_sin(double a);
+
+extern double
+_mesa_cos(double a);
+
+extern double
+_mesa_sqrt(double x);
+
+extern double
+_mesa_pow(double x, double y);
+
+
extern char *
_mesa_getenv( const char *var );
extern char *
_mesa_strstr( const char *haystack, const char *needle );
+extern char *
+_mesa_strncat( char *dest, const char *src, size_t n );
+
+extern char *
+_mesa_strcpy( char *dest, const char *src );
+
+extern char *
+_mesa_strncpy( char *dest, const char *src, size_t n );
+
+extern size_t
+_mesa_strlen( const char *s );
+
+extern int
+_mesa_strcmp( const char *s1, const char *s2 );
+
+extern int
+_mesa_strncmp( const char *s1, const char *s2, size_t n );
+
extern int
_mesa_atoi( const char *s );
-/* $Id: light.c,v 1.53 2002/10/24 23:57:21 brianp Exp $ */
+/* $Id: light.c,v 1.54 2002/10/25 21:06:29 brianp Exp $ */
/*
* Mesa 3-D graphics library
return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
l->SpotCutoff = params[0];
- l->_CosCutoff = (GLfloat) cos(params[0]*DEG2RAD);
+ l->_CosCutoff = (GLfloat) _mesa_cos(params[0]*DEG2RAD);
if (l->_CosCutoff < 0)
l->_CosCutoff = 0;
if (l->SpotCutoff != 180.0F)
for (i = EXP_TABLE_SIZE - 1; i > 0 ;i--) {
if (clamp == 0) {
- tmp = pow(i / (GLdouble) (EXP_TABLE_SIZE - 1), exponent);
+ tmp = _mesa_pow(i / (GLdouble) (EXP_TABLE_SIZE - 1), exponent);
if (tmp < FLT_MIN * 100.0) {
tmp = 0.0;
clamp = 1;
GLdouble t, x = j / (GLfloat) (SHINE_TABLE_SIZE - 1);
if (x < 0.005) /* underflow check */
x = 0.005;
- t = pow(x, shininess);
+ t = _mesa_pow(x, shininess);
if (t > 1e-20)
m[j] = (GLfloat) t;
else
-/* $Id: light.h,v 1.14 2001/09/14 21:36:43 brianp Exp $ */
+/* $Id: light.h,v 1.15 2002/10/25 21:06:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
float f = (dp * (SHINE_TABLE_SIZE-1)); \
int k = (int) f; \
if (k > SHINE_TABLE_SIZE-2) \
- result = (GLfloat) pow( dp, _tab->shininess ); \
+ result = (GLfloat) _mesa_pow( dp, _tab->shininess ); \
else \
result = _tab->tab[k] + (f-k)*(_tab->tab[k+1]-_tab->tab[k]); \
} while (0)