pike.git / src / post_modules / GL / auto.c.in

version» Context lines:

pike.git/src/post_modules/GL/auto.c.in:13:   #include "object.h"   #include "program.h"   #include "interpret.h"   #include "builtin_functions.h"   #include "pike_error.h"   #include "module_support.h"   #include "operators.h"   #include "mapping.h"   #include "pike_types.h"    - #ifdef HAVE_WINDEF_H - #include <windows.h> - #endif /* HAVE_WINDEF_H */ + #ifdef HAVE_OPENGL_GL_H + #include <OpenGL/gl.h> + #else   #ifdef HAVE_GL_GL_H   #include <GL/gl.h>   #endif /* HAVE_GL_GL_H */ - #ifdef HAVE_OPENGL_GL_H - #include <OpenGL/gl.h> +    #endif /* HAVE_OPENGL_GL_H */         #define sp Pike_sp      #define ZT_INT 1   #define ZT_FLOAT 2   #define ZT_DOUBLE 4   #define ZT_ARRAY 8   
pike.git/src/post_modules/GL/auto.c.in:85:    }    for(i=0; i<args; i++)    if(!((tt=1<<TYPEOF(s[i]))&ty)) {    char buf[32];    int n=0;    buf[0]='\0';    for(tt=0; ty; tt++)    if(ty&(1<<tt)) {    ty&=~(1<<tt);    if(n++) -  strcat(buf, " or "); -  strcat(buf, get_name_of_type(tt)); +  strncat(buf, " or ", sizeof(buf)-strlen(buf)-1); +  strncat(buf, get_name_of_type(tt), sizeof(buf)-strlen(buf)-1);    }    Pike_error("%s: got %s, expected %s.\n", func,    get_name_of_type(TYPEOF(s[i])), buf);    } else    tr|=tt;    if(tr==(BIT_INT|BIT_FLOAT))    tt=((rty&ZT_DOUBLE)? ZT_DOUBLE:ZT_FLOAT);    else if(tr==BIT_FLOAT)    tt=((rty&ZT_FLOAT)? ZT_FLOAT:ZT_DOUBLE);    else if(tr!=BIT_INT)
pike.git/src/post_modules/GL/auto.c.in:122:    case ZT_DOUBLE:    ret->v.d[i]=(TYPEOF(s[i]) == T_INT?(double)s[i].u.integer:    s[i].u.float_number);    break;    }    return args;   }      static int img_inited=0;    - static void img_init() + static void img_init(void)   {    glPixelStorei(GL_PACK_SWAP_BYTES, 0);    glPixelStorei(GL_PACK_LSB_FIRST, 0);    glPixelStorei(GL_PACK_ROW_LENGTH, 0);    glPixelStorei(GL_PACK_SKIP_ROWS, 0);    glPixelStorei(GL_PACK_SKIP_PIXELS, 0);    glPixelStorei(GL_PACK_ALIGNMENT, 1);    glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);    glPixelStorei(GL_UNPACK_LSB_FIRST, 0);    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
pike.git/src/post_modules/GL/auto.c.in:159:    unsigned char *p;    size_t size;    } *stor_mem;    unsigned char *pp;    struct { unsigned char r, g, b; } *p1, *p2;    INT32 cnt;       static struct program *image_program=NULL;       if(image_program == NULL) { -  push_text("Image.Image"); +  push_static_text("Image.Image");    SAFE_APPLY_MASTER("resolv",1);    image_program=program_from_svalue(sp-1);    pop_stack();    if(image_program == NULL)    Pike_error("%s: Can't resolve Image.Image!\n", func);    }       img->alloc = 0;    if(TYPEOF(*a) == T_MAPPING) {    struct svalue *v;    if((v=simple_mapping_string_lookup(a->u.mapping, "rgb"))) {    if(TYPEOF(*v) == T_OBJECT && -  (rgbstor = (void *)get_storage(v->u.object, image_program)) != NULL && +  (rgbstor = get_storage(v->u.object, image_program)) != NULL &&    rgbstor->img != NULL)    ;    else    Pike_error("Bad argument %d to %s.\n", arg, func);    }    if((v=simple_mapping_string_lookup(a->u.mapping, "luminance"))) {    if(TYPEOF(*v) == T_OBJECT && -  (lumstor = (void *)get_storage(v->u.object, image_program)) != NULL && +  (lumstor = get_storage(v->u.object, image_program)) != NULL &&    lumstor->img != NULL)    ;    else    Pike_error("Bad argument %d to %s.\n", arg, func);    }    if((v=simple_mapping_string_lookup(a->u.mapping, "alpha"))) {    if(TYPEOF(*v) == T_OBJECT && -  (astor = (void *)get_storage(v->u.object, image_program)) != NULL && +  (astor = get_storage(v->u.object, image_program)) != NULL &&    astor->img != NULL)    ;    else    Pike_error("Bad argument %d to %s.\n", arg, func);    }    if( (v=simple_mapping_string_lookup(a->u.mapping, "mem" )) ) {       if(shm_program == NULL) { -  push_text("System.Memory"); +  push_static_text("System.Memory");    SAFE_APPLY_MASTER("resolv",1);    shm_program=program_from_svalue(sp-1);    pop_stack();    if(shm_program == NULL)    Pike_error("%s: Can't resolve System.Memory!\n", func);    }       if( TYPEOF(*v) == T_OBJECT && -  (stor_mem = (void *)get_storage( v->u.object, shm_program ) ) ) +  (stor_mem = get_storage( v->u.object, shm_program ) ) )    {    INT_TYPE x=0, y=0, row=0;    if( (v=simple_mapping_string_lookup(a->u.mapping, "mem_w" )) )    img->width = v->u.integer;    else    Pike_error("Need mem_w for memory texture\n");    if( (v=simple_mapping_string_lookup(a->u.mapping, "mem_h" )) )    img->height = v->u.integer;    else    Pike_error("Need mem_h for memory texture\n");
pike.git/src/post_modules/GL/auto.c.in:246:    if(x != 0 || y != 0 || row != 0) {    glPixelStorei(GL_UNPACK_ROW_LENGTH, row);    glPixelStorei(GL_UNPACK_SKIP_ROWS, y);    glPixelStorei(GL_UNPACK_SKIP_PIXELS, x);    img_inited = 0; /* Need to reset these later... */    }    return;    }    }    } else if(TYPEOF(*a) == T_OBJECT && -  (rgbstor = (void *)get_storage(a->u.object, image_program)) != +  (rgbstor = get_storage(a->u.object, image_program)) !=    NULL && rgbstor->img != NULL)    ;    else    Pike_error("Bad argument %d to %s.\n", arg, func);       if(rgbstor==NULL && lumstor==NULL && astor==NULL)    Pike_error("Too few images specified.\n");       if(rgbstor!=NULL && lumstor!=NULL)    Pike_error("Can't have both rgb and luminance data.\n");
pike.git/src/post_modules/GL/auto.c.in:341:      static void *get_mem_object( struct svalue *x )   {    struct {    unsigned char *p;    size_t size;    } *stor_mem;       if(shm_program == NULL)    { -  push_text("System.Memory"); +  push_static_text("System.Memory");    SAFE_APPLY_MASTER("resolv",1);    shm_program=program_from_svalue(sp-1);    pop_stack();    if(shm_program == NULL)    Pike_error("Can't resolve System.Memory!\n");    }    if( TYPEOF(*x) != T_OBJECT || -  !(stor_mem = (void *)get_storage( x->u.object, shm_program ) ) ) +  !(stor_mem = get_storage( x->u.object, shm_program ) ) )    Pike_error("Expected System.Memory object\n");    return stor_mem->p;   }            static void release_img(struct zimage *img)   {    if(img->alloc)    free(img->pixels);
pike.git/src/post_modules/GL/auto.c.in:515:   #define glClearAccum4v(f) glClearAccum((f)[0], (f)[1], (f)[2], (f)[3])   #define glEvalPoint1v(i) glEvalPoint1((i)[0]);   #define glEvalPoint2v(i) glEvalPoint2((i)[0], (i)[1]);      static void my_glFrustum(INT32 args);      static void my_glDeleteTextures( INT32 args );   static void my_glGenTextures( INT32 args );   static void my_glCallLists( INT32 args );    - static void pre_init() + static void pre_init(void)   {    add_function_constant("glFrustum", my_glFrustum,    "function(float,float,float,float,float,float:void)",    OPT_SIDE_EFFECT);    add_function_constant("glDeleteTextures", my_glDeleteTextures,    "function(int...:void)",    OPT_SIDE_EFFECT);    add_function_constant("glCallLists", my_glCallLists,"function(int...:void)",    OPT_SIDE_EFFECT);    add_function_constant("glGenTextures", my_glGenTextures,    "function(int:array(int))", OPT_EXTERNAL_DEPEND);   }    - static void post_init() + static void post_init(void)   {   }      @@   static void my_glGenTextures( INT32 args )   { -  GLint *res; +  GLuint *res;    struct array *a;    int ntexts;    int i;    if( args != 1 || TYPEOF(Pike_sp[-1]) != PIKE_T_INT )    Pike_error("Illegal argument to glGenTextures. Expected integer\n");    ntexts = Pike_sp[-1].u.integer;    pop_stack();    -  res = xalloc( sizeof( GLint ) * ntexts ); -  memset( res, 0, sizeof(GLint)*ntexts ); +  res = xcalloc( sizeof( GLuint ), ntexts );    glGenTextures( ntexts, res );    a = allocate_array( ntexts );    for( i = 0; i<ntexts; i++ )    a->item[i].u.integer = res[i];    push_array( a );    free( res );   }      static void my_glDeleteTextures( INT32 args )   {    /* optimize the (valid) args==0 case. */    if( args )    {    GLuint *ls = (GLuint *)xalloc( sizeof( GLint ) * args );    int i;    for( i = 0; i<args; i++ )    {    if( TYPEOF(Pike_sp[i-args]) != PIKE_T_INT ) {    free( ls ); -  SIMPLE_BAD_ARG_ERROR("glDeleteTextures", i+1, "int"); +  SIMPLE_ARG_TYPE_ERROR("glDeleteTextures", i+1, "int");    }    ls[i] = Pike_sp[i-args].u.integer;    }    pop_n_elems(args);    glDeleteTextures( args, ls );    free( ls );    }   }      static void my_glCallLists( INT32 args )   {    /* optimize the (valid) args==0 case. */    if( args )    {    GLint *ls = (GLint *)xalloc( sizeof( GLint ) * args );    int i;    for( i = 0; i<args; i++ )    {    if( TYPEOF(Pike_sp[i-args]) != PIKE_T_INT ) {    free( ls ); -  SIMPLE_BAD_ARG_ERROR("glCallLists", i+1, "int"); +  SIMPLE_ARG_TYPE_ERROR("glCallLists", i+1, "int");    }    ls[i] = Pike_sp[i-args].u.integer;    }    pop_n_elems(args);    glCallLists( args, GL_INT, ls );    free( ls );    }   }      static void my_glFrustum(INT32 args)   {    FLOAT_TYPE right,left,bottom,top,close,away;    GLdouble m[16]; -  get_all_args("glFrustum", args, "%f%f%f%f%f%f", +  get_all_args(NULL, args, "%f%f%f%f%f%f",    &left, &right, &bottom, &top, &close, &away);       if (right == left) {    SIMPLE_ARG_ERROR("glFrustum", 2,    "Arguments right and left must not be equal.");    }       if (bottom == top) {    SIMPLE_ARG_ERROR("glFrustum", 4,    "Arguments bottom and top must not be equal.");