wrapped a few more C library functions

This commit is contained in:
Brian Paul
2002-10-25 21:06:26 +00:00
parent e781aec85d
commit 367d308b82
9 changed files with 196 additions and 55 deletions

View File

@@ -1,4 +1,4 @@
/* $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 * Mesa 3-D graphics library
@@ -653,7 +653,7 @@ OSMesaGetProcAddress( const char *funcName )
{ {
int i; int i;
for (i = 0; functions[i].Name; 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 *) functions[i].Address;
} }
return (void *) _glapi_get_proc_address(funcName); return (void *) _glapi_get_proc_address(funcName);

View File

@@ -1,4 +1,4 @@
/* $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 * Mesa 3-D graphics library
@@ -271,7 +271,7 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
if (dbFlag) { if (dbFlag) {
/* Check if the MESA_BACK_BUFFER env var is set */ /* 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) {
if (backbuffer[0]=='p' || backbuffer[0]=='P') { if (backbuffer[0]=='p' || backbuffer[0]=='P') {
ximageFlag = GL_FALSE; ximageFlag = GL_FALSE;
@@ -287,7 +287,7 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
/* Comparing IDs uses less memory but sometimes fails. */ /* Comparing IDs uses less memory but sometimes fails. */
/* XXX revisit this after 3.0 is finished. */ /* XXX revisit this after 3.0 is finished. */
if (getenv("MESA_GLX_VISUAL_HACK")) if (_mesa_getenv("MESA_GLX_VISUAL_HACK"))
comparePointers = GL_TRUE; comparePointers = GL_TRUE;
else else
comparePointers = GL_FALSE; comparePointers = GL_FALSE;
@@ -366,7 +366,7 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo )
); );
} }
else if (is_usable_visual( visinfo )) { 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. */ /* Configure this visual as a COLOR INDEX visual. */
return save_glx_visual( dpy, visinfo, return save_glx_visual( dpy, visinfo,
GL_FALSE, /* rgb */ GL_FALSE, /* rgb */
@@ -565,21 +565,21 @@ static XVisualInfo *get_env_visual(Display *dpy, int scr, const char *varname)
int depth, xclass = -1; int depth, xclass = -1;
XVisualInfo *vis; XVisualInfo *vis;
if (!getenv( varname )) { if (!_mesa_getenv( varname )) {
return NULL; return NULL;
} }
strncpy( value, getenv(varname), 100 ); _mesa_strncpy( value, _mesa_getenv(varname), 100 );
value[99] = 0; value[99] = 0;
sscanf( value, "%s %d", type, &depth ); sscanf( value, "%s %d", type, &depth );
if (strcmp(type,"TrueColor")==0) xclass = TrueColor; if (_mesa_strcmp(type,"TrueColor")==0) xclass = TrueColor;
else if (strcmp(type,"DirectColor")==0) xclass = DirectColor; else if (_mesa_strcmp(type,"DirectColor")==0) xclass = DirectColor;
else if (strcmp(type,"PseudoColor")==0) xclass = PseudoColor; else if (_mesa_strcmp(type,"PseudoColor")==0) xclass = PseudoColor;
else if (strcmp(type,"StaticColor")==0) xclass = StaticColor; else if (_mesa_strcmp(type,"StaticColor")==0) xclass = StaticColor;
else if (strcmp(type,"GrayScale")==0) xclass = GrayScale; else if (_mesa_strcmp(type,"GrayScale")==0) xclass = GrayScale;
else if (strcmp(type,"StaticGray")==0) xclass = StaticGray; else if (_mesa_strcmp(type,"StaticGray")==0) xclass = StaticGray;
if (xclass>-1 && depth>0) { if (xclass>-1 && depth>0) {
vis = get_visual( dpy, scr, depth, xclass ); vis = get_visual( dpy, scr, depth, xclass );
@@ -1383,7 +1383,7 @@ Fake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap )
if (b) { if (b) {
XMesaDestroyBuffer(b); XMesaDestroyBuffer(b);
} }
else if (getenv("MESA_DEBUG")) { else if (_mesa_getenv("MESA_DEBUG")) {
_mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n"); _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
} }
} }
@@ -1457,7 +1457,7 @@ Fake_glXSwapBuffers( Display *dpy, GLXDrawable drawable )
if (buffer) { if (buffer) {
XMesaSwapBuffers(buffer); XMesaSwapBuffers(buffer);
} }
else if (getenv("MESA_DEBUG")) { else if (_mesa_getenv("MESA_DEBUG")) {
_mesa_warning(NULL, "Mesa: glXSwapBuffers: invalid drawable\n"); _mesa_warning(NULL, "Mesa: glXSwapBuffers: invalid drawable\n");
} }
} }
@@ -1474,7 +1474,7 @@ Fake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
if (buffer) { if (buffer) {
XMesaCopySubBuffer(buffer, x, y, width, height); 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"); _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
} }
} }
@@ -1742,7 +1742,7 @@ static const char *
get_extensions( void ) get_extensions( void )
{ {
#ifdef FX #ifdef FX
const char *fx = getenv("MESA_GLX_FX"); const char *fx = _mesa_getenv("MESA_GLX_FX");
if (fx && fx[0] != 'd') { if (fx && fx[0] != 'd') {
return EXTENSIONS; return EXTENSIONS;
} }

View File

@@ -1,4 +1,4 @@
/* $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 * Mesa 3-D graphics library
@@ -167,7 +167,7 @@ static void error( const char *msg )
{ {
(void)DitherValues; /* Muffle compiler */ (void)DitherValues; /* Muffle compiler */
if (getenv("MESA_DEBUG")) if (_mesa_getenv("MESA_DEBUG"))
fprintf( stderr, "X/Mesa error: %s\n", msg ); fprintf( stderr, "X/Mesa error: %s\n", msg );
} }
@@ -266,7 +266,7 @@ static GLint gamma_adjust( GLfloat gamma, GLint value, GLint max )
} }
else { else {
double x = (double) value / (double) max; 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));
} }
} }
@@ -504,7 +504,7 @@ static GLboolean alloc_shm_back_buffer( XMesaBuffer b )
b->shminfo.shmid = shmget( IPC_PRIVATE, b->backimage->bytes_per_line b->shminfo.shmid = shmget( IPC_PRIVATE, b->backimage->bytes_per_line
* b->backimage->height, IPC_CREAT|0777 ); * b->backimage->height, IPC_CREAT|0777 );
if (b->shminfo.shmid < 0) { if (b->shminfo.shmid < 0) {
if (getenv("MESA_DEBUG")) if (_mesa_getenv("MESA_DEBUG"))
perror("alloc_back_buffer"); perror("alloc_back_buffer");
XDestroyImage( b->backimage ); XDestroyImage( b->backimage );
b->backimage = NULL; b->backimage = NULL;
@@ -516,7 +516,7 @@ static GLboolean alloc_shm_back_buffer( XMesaBuffer b )
b->shminfo.shmaddr = b->backimage->data b->shminfo.shmaddr = b->backimage->data
= (char*)shmat( b->shminfo.shmid, 0, 0 ); = (char*)shmat( b->shminfo.shmid, 0, 0 );
if (b->shminfo.shmaddr == (char *) -1) { if (b->shminfo.shmaddr == (char *) -1) {
if (getenv("MESA_DEBUG")) if (_mesa_getenv("MESA_DEBUG"))
perror("alloc_back_buffer"); perror("alloc_back_buffer");
XDestroyImage( b->backimage ); XDestroyImage( b->backimage );
shmctl( b->shminfo.shmid, IPC_RMID, 0 ); shmctl( b->shminfo.shmid, IPC_RMID, 0 );
@@ -872,7 +872,7 @@ static GLboolean setup_grayscale( int client, XMesaVisual v,
buffer->pixel_to_b[xcol.pixel] = gray; buffer->pixel_to_b[xcol.pixel] = gray;
} }
if (colorsfailed && getenv("MESA_DEBUG")) { if (colorsfailed && _mesa_getenv("MESA_DEBUG")) {
fprintf( stderr, fprintf( stderr,
"Note: %d out of 256 needed colors do not match exactly.\n", "Note: %d out of 256 needed colors do not match exactly.\n",
colorsfailed ); colorsfailed );
@@ -952,7 +952,7 @@ static GLboolean setup_dithered_color( int client, XMesaVisual v,
} }
} }
if (colorsfailed && getenv("MESA_DEBUG")) { if (colorsfailed && _mesa_getenv("MESA_DEBUG")) {
fprintf( stderr, fprintf( stderr,
"Note: %d out of %d needed colors do not match exactly.\n", "Note: %d out of %d needed colors do not match exactly.\n",
colorsfailed, _R*_G*_B ); colorsfailed, _R*_G*_B );
@@ -986,19 +986,19 @@ static void setup_8bit_hpcr( XMesaVisual v )
g = 1.0 / v->RedGamma; g = 1.0 / v->RedGamma;
for (i=0; i<256; i++) { 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 ); v->hpcr_rgbTbl[0][i] = CLAMP( red, 16, 239 );
} }
g = 1.0 / v->GreenGamma; g = 1.0 / v->GreenGamma;
for (i=0; i<256; i++) { 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 ); v->hpcr_rgbTbl[1][i] = CLAMP( green, 16, 239 );
} }
g = 1.0 / v->BlueGamma; g = 1.0 / v->BlueGamma;
for (i=0; i<256; i++) { 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->hpcr_rgbTbl[2][i] = CLAMP( blue, 32, 223 );
} }
v->undithered_pf = PF_HPCR; /* can't really disable dithering for now */ v->undithered_pf = PF_HPCR; /* can't really disable dithering for now */
@@ -1007,7 +1007,7 @@ static void setup_8bit_hpcr( XMesaVisual v )
/* which method should I use to clear */ /* which method should I use to clear */
/* GL_FALSE: keep the ordinary method */ /* GL_FALSE: keep the ordinary method */
/* GL_TRUE : clear with dither pattern */ /* 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) { if (v->hpcr_clear_flag) {
v->hpcr_clear_pixmap = XMesaCreatePixmap(v->display, v->hpcr_clear_pixmap = XMesaCreatePixmap(v->display,
@@ -1242,7 +1242,7 @@ static GLboolean initialize_visual_and_buffer( int client,
} }
v->index_bits = 0; v->index_bits = 0;
if (getenv("MESA_NO_DITHER")) { if (_mesa_getenv("MESA_NO_DITHER")) {
v->dithered_pf = v->undithered_pf; v->dithered_pf = v->undithered_pf;
} }
} }
@@ -1253,7 +1253,7 @@ static GLboolean initialize_visual_and_buffer( int client,
* which can help Brian figure out what's going on when a user * which can help Brian figure out what's going on when a user
* reports bugs. * reports bugs.
*/ */
if (getenv("MESA_INFO")) { if (_mesa_getenv("MESA_INFO")) {
fprintf(stderr, "X/Mesa visual = %p\n", (void *) v); fprintf(stderr, "X/Mesa visual = %p\n", (void *) v);
fprintf(stderr, "X/Mesa dithered pf = %u\n", v->dithered_pf); fprintf(stderr, "X/Mesa dithered pf = %u\n", v->dithered_pf);
fprintf(stderr, "X/Mesa undithered pf = %u\n", v->undithered_pf); fprintf(stderr, "X/Mesa undithered pf = %u\n", v->undithered_pf);
@@ -1471,7 +1471,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
GLint red_bits, green_bits, blue_bits, alpha_bits; GLint red_bits, green_bits, blue_bits, alpha_bits;
/* For debugging only */ /* For debugging only */
if (getenv("MESA_XSYNC")) { if (_mesa_getenv("MESA_XSYNC")) {
/* This makes debugging X easier. /* This makes debugging X easier.
* In your debugger, set a breakpoint on _XError to stop when an * In your debugger, set a breakpoint on _XError to stop when an
* X protocol error is generated. * X protocol error is generated.
@@ -1529,7 +1529,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
#endif #endif
/* check for MESA_GAMMA environment variable */ /* check for MESA_GAMMA environment variable */
gamma = getenv("MESA_GAMMA"); gamma = _mesa_getenv("MESA_GAMMA");
if (gamma) { if (gamma) {
v->RedGamma = v->GreenGamma = v->BlueGamma = 0.0; v->RedGamma = v->GreenGamma = v->BlueGamma = 0.0;
sscanf( gamma, "%f %f %f", &v->RedGamma, &v->GreenGamma, &v->BlueGamma ); sscanf( gamma, "%f %f %f", &v->RedGamma, &v->GreenGamma, &v->BlueGamma );
@@ -1732,7 +1732,7 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w,
if (GET_VISUAL_DEPTH(v) != attr.depth) { if (GET_VISUAL_DEPTH(v) != attr.depth) {
#endif #endif
if (getenv("MESA_DEBUG")) { if (_mesa_getenv("MESA_DEBUG")) {
fprintf(stderr, "XMesaCreateWindowBuffer: depth mismatch between visual and window!\n"); fprintf(stderr, "XMesaCreateWindowBuffer: depth mismatch between visual and window!\n");
} }
return NULL; return NULL;
@@ -1748,7 +1748,7 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w,
b->cmap = attr.colormap; b->cmap = attr.colormap;
} }
else { else {
if (getenv("MESA_DEBUG")) { if (_mesa_getenv("MESA_DEBUG")) {
fprintf(stderr, "Window %u has no colormap!\n", (unsigned int) w); fprintf(stderr, "Window %u has no colormap!\n", (unsigned int) w);
} }
/* this is weird, a window w/out a colormap!? */ /* this is weird, a window w/out a colormap!? */
@@ -1784,7 +1784,7 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w,
} }
#ifdef FX #ifdef FX
fxEnvVar = getenv("MESA_GLX_FX"); fxEnvVar = _mesa_getenv("MESA_GLX_FX");
if (fxEnvVar) { if (fxEnvVar) {
if (fxEnvVar[0]!='d') { if (fxEnvVar[0]!='d') {
int attribs[100]; int attribs[100];
@@ -2181,7 +2181,7 @@ GLboolean XMesaLoseCurrent(XMesaContext c)
GLboolean XMesaSetFXmode( GLint mode ) GLboolean XMesaSetFXmode( GLint mode )
{ {
#ifdef FX #ifdef FX
const char *fx = getenv("MESA_GLX_FX"); const char *fx = _mesa_getenv("MESA_GLX_FX");
if (fx && fx[0] != 'd') { if (fx && fx[0] != 'd') {
GET_CURRENT_CONTEXT(ctx); GET_CURRENT_CONTEXT(ctx);
GrHwConfiguration hw; GrHwConfiguration hw;

View File

@@ -1,4 +1,4 @@
/* $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 * Mesa 3-D graphics library
@@ -853,7 +853,7 @@ static int sorted = 0;
static int compar_name( const enum_elt *a, const enum_elt *b ) 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);
} }

View File

@@ -1,4 +1,4 @@
/* $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 * Mesa 3-D graphics library
@@ -315,7 +315,7 @@ _mesa_add_extension( GLcontext *ctx,
{ {
struct extension *t = MALLOC_STRUCT(extension); struct extension *t = MALLOC_STRUCT(extension);
t->enabled = enabled; 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->name[MAX_EXT_NAMELEN] = 0;
t->flag = flag_ptr; t->flag = flag_ptr;
if (t->flag) if (t->flag)
@@ -337,7 +337,7 @@ set_extension( GLcontext *ctx, const char *name, GLint state )
*/ */
struct extension *i; struct extension *i;
foreach( i, ctx->Extensions.ext_list ) 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; break;
if (i == ctx->Extensions.ext_list) { if (i == ctx->Extensions.ext_list) {
@@ -379,7 +379,7 @@ _mesa_extension_is_enabled( GLcontext *ctx, const char *name)
{ {
struct extension *i; struct extension *i;
foreach( i, ctx->Extensions.ext_list ) 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) if (i->enabled)
return GL_TRUE; return GL_TRUE;
else else
@@ -446,18 +446,18 @@ _mesa_extensions_get_string( GLcontext *ctx )
GLuint len = 0; GLuint len = 0;
foreach (i, ctx->Extensions.ext_list) foreach (i, ctx->Extensions.ext_list)
if (i->enabled) if (i->enabled)
len += strlen(i->name) + 1; len += _mesa_strlen(i->name) + 1;
if (len == 0) if (len == 0)
return ""; return "";
str = (char *)MALLOC(len * sizeof(char)); str = (char *) _mesa_malloc(len * sizeof(char));
ctx->Extensions.ext_string = str; ctx->Extensions.ext_string = str;
foreach (i, ctx->Extensions.ext_list) foreach (i, ctx->Extensions.ext_list)
if (i->enabled) { if (i->enabled) {
strcpy(str, i->name); _mesa_strcpy(str, i->name);
str += strlen(str); str += _mesa_strlen(str);
*str++ = ' '; *str++ = ' ';
} }

View File

@@ -1,4 +1,4 @@
/* $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 * Mesa 3-D graphics library
@@ -208,6 +208,50 @@ _mesa_bzero( void *dst, size_t n )
} }
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 * char *
_mesa_getenv( const char *var ) _mesa_getenv( const char *var )
{ {
@@ -230,6 +274,72 @@ _mesa_strstr( const char *haystack, const char *needle )
} }
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 int
_mesa_atoi(const char *s) _mesa_atoi(const char *s)
{ {

View File

@@ -1,4 +1,4 @@
/* $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 3-D graphics library
@@ -127,12 +127,43 @@ extern void
_mesa_bzero( void *dst, size_t n ); _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 * extern char *
_mesa_getenv( const char *var ); _mesa_getenv( const char *var );
extern char * extern char *
_mesa_strstr( const char *haystack, const char *needle ); _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 extern int
_mesa_atoi( const char *s ); _mesa_atoi( const char *s );

View File

@@ -1,4 +1,4 @@
/* $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 * Mesa 3-D graphics library
@@ -156,7 +156,7 @@ _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
return; return;
FLUSH_VERTICES(ctx, _NEW_LIGHT); FLUSH_VERTICES(ctx, _NEW_LIGHT);
l->SpotCutoff = params[0]; l->SpotCutoff = params[0];
l->_CosCutoff = (GLfloat) cos(params[0]*DEG2RAD); l->_CosCutoff = (GLfloat) _mesa_cos(params[0]*DEG2RAD);
if (l->_CosCutoff < 0) if (l->_CosCutoff < 0)
l->_CosCutoff = 0; l->_CosCutoff = 0;
if (l->SpotCutoff != 180.0F) if (l->SpotCutoff != 180.0F)
@@ -1038,7 +1038,7 @@ static void validate_spot_exp_table( struct gl_light *l )
for (i = EXP_TABLE_SIZE - 1; i > 0 ;i--) { for (i = EXP_TABLE_SIZE - 1; i > 0 ;i--) {
if (clamp == 0) { 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) { if (tmp < FLT_MIN * 100.0) {
tmp = 0.0; tmp = 0.0;
clamp = 1; clamp = 1;
@@ -1096,7 +1096,7 @@ static void validate_shine_table( GLcontext *ctx, GLuint i, GLfloat shininess )
GLdouble t, x = j / (GLfloat) (SHINE_TABLE_SIZE - 1); GLdouble t, x = j / (GLfloat) (SHINE_TABLE_SIZE - 1);
if (x < 0.005) /* underflow check */ if (x < 0.005) /* underflow check */
x = 0.005; x = 0.005;
t = pow(x, shininess); t = _mesa_pow(x, shininess);
if (t > 1e-20) if (t > 1e-20)
m[j] = (GLfloat) t; m[j] = (GLfloat) t;
else else

View File

@@ -1,4 +1,4 @@
/* $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 * Mesa 3-D graphics library
@@ -86,7 +86,7 @@ do { \
float f = (dp * (SHINE_TABLE_SIZE-1)); \ float f = (dp * (SHINE_TABLE_SIZE-1)); \
int k = (int) f; \ int k = (int) f; \
if (k > SHINE_TABLE_SIZE-2) \ if (k > SHINE_TABLE_SIZE-2) \
result = (GLfloat) pow( dp, _tab->shininess ); \ result = (GLfloat) _mesa_pow( dp, _tab->shininess ); \
else \ else \
result = _tab->tab[k] + (f-k)*(_tab->tab[k+1]-_tab->tab[k]); \ result = _tab->tab[k] + (f-k)*(_tab->tab[k+1]-_tab->tab[k]); \
} while (0) } while (0)