From: erg Date: Fri, 16 Jul 2010 18:15:35 +0000 (+0000) Subject: ifdef out unused code; clean up interfaces; make external names more uniform X-Git-Tag: LAST_LIBGRAPH~32^2~1271 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b6699bf5373e29a7067de27ed536cd51b4fec88;p=graphviz ifdef out unused code; clean up interfaces; make external names more uniform --- diff --git a/lib/glcomp/glcompbutton.c b/lib/glcomp/glcompbutton.c index 8b39db1fc..9184e8de3 100644 --- a/lib/glcomp/glcompbutton.c +++ b/lib/glcomp/glcompbutton.c @@ -51,7 +51,7 @@ glCompButton *glCompButtonNew(glCompObj * par, GLfloat x, GLfloat y, p->customptr = '\0'; /*set event functions */ - p->common.functions.draw = glCompButtonDraw; + p->common.functions.draw = (glcompdrawfunc_t)glCompButtonDraw; p->common.functions.click = glCompButtonClick; p->common.functions.doubleclick = glCompButtonDoubleClick; @@ -62,7 +62,7 @@ glCompButton *glCompButtonNew(glCompObj * par, GLfloat x, GLfloat y, p->common.functions.mouseup = glCompButtonMouseUp; /*caption */ - p->common.font = new_font_from_parent((glCompObj *) p, NULL); + p->common.font = glNewFontFromParent ((glCompObj *) p, NULL); p->label = glCompLabelNew((glCompObj *) p, 0, 0, caption); p->label->common.font->justify.VJustify = glFontVJustifyCenter; p->label->common.font->justify.HJustify = glFontHJustifyCenter; diff --git a/lib/glcomp/glcompdefs.h b/lib/glcomp/glcompdefs.h index ce171b4d4..7f544c8d0 100644 --- a/lib/glcomp/glcompdefs.h +++ b/lib/glcomp/glcompdefs.h @@ -273,14 +273,11 @@ extern "C" { glObjType objType; /*always keep this here for each drawable object */ glCompCommon common; glCompTex *texture; - char *pngFile; + GLfloat width, height; /* width and height in world coords */ + /* char *pngFile; */ int stretch; } glCompImage; - - - - /*generic panel*/ typedef struct _glCompPanel { glObjType objType; /*always keep this here for each drawable object */ diff --git a/lib/glcomp/glcompfont.c b/lib/glcomp/glcompfont.c index ca9905e9c..7387c8832 100644 --- a/lib/glcomp/glcompfont.c +++ b/lib/glcomp/glcompfont.c @@ -22,7 +22,7 @@ #include "memory.h" #include -void print_bitmap_string(void *font, char *s) +static void print_bitmap_string(void *font, char *s) { if (s && strlen(s)) { while (*s) { @@ -33,6 +33,7 @@ void print_bitmap_string(void *font, char *s) } } +#if 0 void init_gl_vars(glCompFont * f) { @@ -84,6 +85,7 @@ void restore_gl_vars(glCompFont * f) glDisable(GL_TEXTURE_2D); glMatrixMode(f->glcache.matrix);*/ } +#endif void glprintfglut(void *font, GLfloat xpos, GLfloat ypos, GLfloat zpos, char *bf) { @@ -93,8 +95,7 @@ void glprintfglut(void *font, GLfloat xpos, GLfloat ypos, GLfloat zpos, } - - +#if 0 static void glPrintf(glCompFont * font, GLfloat xpos, GLfloat ypos, GLfloat zpos, GLfloat width, char *bf, int usez) @@ -129,8 +130,6 @@ glprintfz(glCompFont * font, GLfloat xpos, GLfloat ypos, GLfloat zpos, glPrintf(font, xpos, ypos, zpos, width, bf, 0); } - - static int fontId(fontset_t * fontset, char *fontdesc) { int ind = 0; @@ -152,7 +151,7 @@ static int glutfontId(fontset_t * fontset, void *glutfont) } -glCompFont *glut_font_init(void) +static glCompFont *glut_font_init(void) { glCompFont *font = NEW(glCompFont); font->color.R = 1.00; @@ -185,7 +184,8 @@ glCompFont *glut_font_init(void) return font; } -void delete_font(glCompFont * f) +#endif +void glDeleteFont(glCompFont * f) { if (f->fontdesc) free(f->fontdesc); @@ -195,7 +195,7 @@ void delete_font(glCompFont * f) } -glCompFont *new_font(glCompSet * s, char *text, glCompColor * c,glCompFontType type, char *fontdesc, int fs,int is2D) +glCompFont *glNewFont (glCompSet * s, char *text, glCompColor * c,glCompFontType type, char *fontdesc, int fs,int is2D) { glCompFont *font = (glCompFont*) malloc(sizeof(glCompFont)); font->reference = 0; @@ -227,7 +227,7 @@ glCompFont *new_font(glCompSet * s, char *text, glCompColor * c,glCompFontType t -glCompFont *new_font_from_parent(glCompObj * o, char *text) +glCompFont *glNewFontFromParent(glCompObj * o, char *text) { glCompCommon *parent; glCompFont *font = NEW(glCompFont); @@ -264,13 +264,13 @@ glCompFont *new_font_from_parent(glCompObj * o, char *text) c.B = GLCOMPSET_FONT_COLOR_B; c.A = GLCOMPSET_FONT_COLOR_ALPHA; font = - new_font(o->common.compset, text, &c, pangotext, + glNewFont (o->common.compset, text, &c, pangotext, GLCOMPSET_FONT_DESC, GLCOMPSET_FONT_SIZE,1); } return font; } - +#if 0 #ifndef _WIN32 #define TMPTEMP "/tmp/_sfXXXX" @@ -324,7 +324,7 @@ glCompFont *add_font(fontset_t * fontset, char *fontdesc, int fs) fontpath = ALLOC(fontpathsz, fontpath, char); } /* sprintf(fontpath, "%s/%s.png", fontset->font_directory, fontdesc); - if (create_font_file(fontdesc,fs, fontpath, (float) 32, (float) 32) == + if (glCompCreateFontFile(fontdesc,fs, fontpath, (float) 32, (float) 32) == 0) { fontset->fonts = ALLOC(fontset->count + 1, fontset->fonts, glCompFont *); @@ -377,7 +377,7 @@ void fontColor(glCompFont * font, float r, float g, float b, float a) font->color.B = b; font->color.A = a; } - +#endif /*texture base 3d text rendering*/ void glCompDrawText3D(glCompFont * f,GLfloat x,GLfloat y,GLfloat z,GLfloat w,GLfloat h) @@ -398,12 +398,13 @@ void glCompDrawText3D(glCompFont * f,GLfloat x,GLfloat y,GLfloat z,GLfloat w,GLf glEnable(GL_BLEND); } +#if 0 /*bitmap base 2D text rendering */ static void change_fontC(unsigned char* d,int w,int h,glCompColor* c) { int size=w*h*4; int ind=0; - for (ind;ind <=size; ind=ind+4) + for (;ind <=size; ind=ind+4) { if(d[ind+3] != 0) { @@ -414,7 +415,7 @@ static void change_fontC(unsigned char* d,int w,int h,glCompColor* c) } } } - +#endif void glCompDrawText(glCompFont * f,GLfloat x,GLfloat y) { @@ -467,3 +468,63 @@ void glCompRenderText(glCompFont * f, glCompObj * parentObj) glCompDrawText(f,x,y); } + +#if 0 +#define imageWidth 256 +#define imageHeight 256 +static GLubyte imageData[imageWidth][imageHeight][4]; +#endif + +#if 0 +int glCompLoadFontPNG(char *name, int id) +{ + GLubyte *imageData = NULL; + int imageWidth, imageHeight, idx2, c; + +// imageData = fontGetData (s, size, imageBits); + imageData = glCompLoadPng (name, &imageWidth, &imageHeight); + + c = 0; + idx2 = 0; +/* for (idx=0;idx < imageWidth*imageHeight+30000;idx=idx+1) + { + if (c!=imageData[idx]) + { + c=imageData[idx]; + printf ("%i) %i \n ",idx2,imageData[idx]); + } + + idx2++; + c=((((idx&0x8)==0)^((idx2&0x8))==0))*255; + imageData[idx][idx2][0] = c; + imageData[idx][idx2][1] = c; + imageData[idx][idx2][2] = c; + imageData[idx][idx2][3] = 255; + + }*/ + + + /* no image data */ + if (imageData == NULL) + return -1; + + glBindTexture(GL_TEXTURE_2D, id); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + /* glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); */ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + /* glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); */ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); +// glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE , GL_DECAL); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, imageWidth, imageHeight, 0, + GL_ALPHA, GL_UNSIGNED_BYTE, imageData); +// glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData); + + /* release data, its been uploaded */ + + return 1; +} +#endif diff --git a/lib/glcomp/glcompfont.h b/lib/glcomp/glcompfont.h index 99f588266..447ea9765 100644 --- a/lib/glcomp/glcompfont.h +++ b/lib/glcomp/glcompfont.h @@ -31,27 +31,27 @@ typedef float GLfloat; #ifdef __cplusplus extern "C" { #endif - extern fontset_t *fontset_init(void); - extern void free_font_set(fontset_t * fontset); - extern void copy_font(glCompFont * targetfont, - const glCompFont * sourcefont); - extern glCompFont *add_font(fontset_t * fontset, char *fontdesc, - int fs); - extern glCompFont *add_glut_font(fontset_t * fontset, void *glutfont); - extern void glprintf(glCompFont *, GLfloat, GLfloat, GLfloat, GLfloat, - char *); - extern void glprintfglut(void *font, GLfloat xpos, GLfloat ypos, - GLfloat zpos, char *bf); - extern glCompFont *font_init(void); - extern void fontColor(glCompFont * font, float r, float g, float b, - float a); - extern int glCompLoadFontPNG(char *name, int id); - extern glCompFont *new_font(glCompSet * s, char *text, glCompColor * c,glCompFontType type, char *fontdesc, int fs,int is2D); - extern glCompFont *new_font_from_parent(glCompObj * o, char *text); - extern void delete_font(glCompFont * f); - extern void glCompDrawText(glCompFont * f,GLfloat x,GLfloat y); - extern void glCompRenderText(glCompFont * f, glCompObj * parentObj); - extern void glCompDrawText3D(glCompFont * f,GLfloat x,GLfloat y,GLfloat z,GLfloat w,GLfloat h); +#if 0 + void copy_font(glCompFont * targetfont, const glCompFont * sourcefont); + fontset_t *fontset_init(void); + void free_font_set(fontset_t * fontset); + glCompFont *add_font(fontset_t * fontset, char *fontdesc, int fs); + glCompFont *add_glut_font(fontset_t * fontset, void *glutfont); + void fontColor(glCompFont * font, float r, float g, float b, float a); + glCompFont *font_init(void); + int glCompLoadFontPNG(char *name, int id); + void glprintf(glCompFont *, GLfloat, GLfloat, GLfloat, GLfloat, char *); +#endif + + void glprintfglut(void *font, GLfloat xpos, GLfloat ypos, GLfloat zpos, char *bf); + + glCompFont *glNewFont(glCompSet * s, char *text, glCompColor * c, + glCompFontType type, char *fontdesc, int fs,int is2D); + glCompFont *glNewFontFromParent(glCompObj * o, char *text); + void glDeleteFont(glCompFont * f); + void glCompDrawText(glCompFont * f,GLfloat x,GLfloat y); + void glCompRenderText(glCompFont * f, glCompObj * parentObj); + void glCompDrawText3D(glCompFont * f,GLfloat x,GLfloat y,GLfloat z,GLfloat w,GLfloat h); #ifdef __cplusplus } diff --git a/lib/glcomp/glcompimage.c b/lib/glcomp/glcompimage.c index c0d06df22..c13a1a0c6 100644 --- a/lib/glcomp/glcompimage.c +++ b/lib/glcomp/glcompimage.c @@ -31,23 +31,46 @@ glCompImage *glCompImageNew(glCompObj * par, GLfloat x, GLfloat y) p->objType = glImageObj; p->stretch = 0; +#if 0 p->pngFile = (char *) 0; +#endif p->texture = NULL; p->common.functions.draw = glCompImageDraw; return p; } +/* glCompImageNewFile: + * Creates image from given input file. + * At present, we assume png input. + * Return 0 on failure. + */ +glCompImage *glCompImageNewFile (glCompObj * par, GLfloat x, GLfloat y, char* imgfile, int is2D) +{ + int imageWidth, imageHeight; + unsigned char *data = glCompLoadPng (imgfile, &imageWidth, &imageHeight); + glCompImage *p; + + if (!data) return NULL; + p = glCompImageNew (par, x, y); + if (!glCompImageLoad (p, data, imageWidth, imageHeight, is2D)) { + glCompImageDelete (p); + return NULL; + } + return p; +} + void glCompImageDelete(glCompImage * p) { glCompEmptyCommon(&p->common); +#if 0 if (p->pngFile) free(p->pngFile); +#endif if (p->texture) glCompDeleteTexture(p->texture); free(p); } -extern unsigned char *load_png(char *file_name, int *imageWidth, - int *imageHeight); + int glCompImageLoad(glCompImage * i, unsigned char *data, int width, int height,int is2D) { @@ -72,24 +95,26 @@ int glCompImageLoadPng(glCompImage * i, char *pngFile,int is2D) { int imageWidth, imageHeight; unsigned char *data; - data = load_png(pngFile, &imageWidth, &imageHeight); + data = glCompLoadPng (pngFile, &imageWidth, &imageHeight); return glCompImageLoad(i, data, imageWidth, imageHeight,is2D); } + +#if 0 int glCompImageLoadRaw(glCompSet * s, glCompImage * i, char *rawFile,int is2D) { int imageWidth, imageHeight; unsigned char *data; - data = load_png(rawFile, &imageWidth, &imageHeight); + data = glCompLoadPng (rawFile, &imageWidth, &imageHeight); return glCompImageLoad(i, data, imageWidth, imageHeight,is2D); } +#endif void glCompImageDraw(void *obj) { - glCompImage *p; - static glCompCommon ref; - static GLfloat w,h,d; - p = (glCompImage *) obj; - ref = p->common; + glCompImage *p = (glCompImage *) obj; + glCompCommon ref = p->common; + GLfloat w,h,d; + glCompCalcWidget((glCompCommon *) p->common.parent, &p->common, &ref); if (!p->common.visible) return; @@ -103,9 +128,12 @@ void glCompImageDraw(void *obj) } else { - +#if 0 w=ref.width; h=ref.height; +#endif + w = p->width; + h = p->height; d=(GLfloat)p->common.layer* (GLfloat)GLCOMPSET_BEVEL_DIFF; glDisable(GL_BLEND); glEnable(GL_TEXTURE_2D); diff --git a/lib/glcomp/glcompimage.h b/lib/glcomp/glcompimage.h index 5d54d040c..f71d2651f 100644 --- a/lib/glcomp/glcompimage.h +++ b/lib/glcomp/glcompimage.h @@ -22,6 +22,8 @@ extern "C" { #endif + extern glCompImage *glCompImageNewFile(glCompObj * par, GLfloat x, + GLfloat y, char* imgfile, int is2D); extern glCompImage *glCompImageNew(glCompObj * par, GLfloat x, GLfloat y); extern void glCompImageDelete(glCompImage * p); diff --git a/lib/glcomp/glcomplabel.c b/lib/glcomp/glcomplabel.c index fa1d84012..58def751b 100644 --- a/lib/glcomp/glcomplabel.c +++ b/lib/glcomp/glcomplabel.c @@ -32,8 +32,8 @@ glCompLabel *glCompLabelNew(glCompObj * par, GLfloat x, GLfloat y, //typedef enum {glPanelObj,glbuttonObj,glLabelObj,glImageObj}glObjType; p->text = strdup(text); - p->common.font = new_font_from_parent((glCompObj*)p, text); - p->common.functions.draw = glCompLabelDraw; + p->common.font = glNewFontFromParent ((glCompObj*)p, text); + p->common.functions.draw = (glcompdrawfunc_t)glCompLabelDraw; return p; } @@ -67,9 +67,9 @@ static void update_font(glCompLabel * p,char* text,char* desc,int fs) if (strlen(text) >512) return ; - p->common.font=new_font(p->common.compset,text,&p->common.color,temp->type,desc,fs,temp->is2D); + p->common.font=glNewFont (p->common.compset,text,&p->common.color,temp->type,desc,fs,temp->is2D); if(temp) - delete_font(temp); + glDeleteFont(temp); if(p->text) free(p->text); p->text = strdup(text); diff --git a/lib/glcomp/glcomppanel.c b/lib/glcomp/glcomppanel.c index 6c485be08..144aafee2 100644 --- a/lib/glcomp/glcomppanel.c +++ b/lib/glcomp/glcomppanel.c @@ -41,9 +41,9 @@ glCompPanel *glCompPanelNew(glCompObj * parentObj, GLfloat x, GLfloat y, p->common.width = w; p->common.height = h; - p->common.font = new_font_from_parent((glCompObj *) p, NULL); + p->common.font = glNewFontFromParent((glCompObj *) p, NULL); p->text = (char *) 0; - p->common.functions.draw = glCompPanelDraw; + p->common.functions.draw = (glcompdrawfunc_t)glCompPanelDraw; p->image = (glCompImage *) 0; return p; } @@ -171,9 +171,10 @@ void glCompPanelMouseUp(glCompObj * obj, GLfloat x, GLfloat y, } - +#if 0 void glCompPanelSetText(glCompPanel * p, char *str) { // replacestr(str, &p->text); } +#endif diff --git a/lib/glcomp/glcompset.c b/lib/glcomp/glcompset.c index 6e36bf2ad..4d8fb0fdd 100644 --- a/lib/glcomp/glcompset.c +++ b/lib/glcomp/glcompset.c @@ -174,7 +174,7 @@ static void glCompSetMouseUp(void *obj, GLfloat x, GLfloat y, -extern void glCompInitCommon(glCompObj * childObj, glCompObj * parentObj, +void glCompInitCommon(glCompObj * childObj, glCompObj * parentObj, GLfloat x, GLfloat y) { glCompCommon *c; @@ -236,12 +236,12 @@ extern void glCompInitCommon(glCompObj * childObj, glCompObj * parentObj, c->layer = 0; c->pos.z = 0; } - c->font = new_font_from_parent(childObj, NULL); + c->font = glNewFontFromParent(childObj, NULL); } void glCompEmptyCommon(glCompCommon * c) { - delete_font(c->font); + glDeleteFont(c->font); } glCompSet *glCompSetNew(int w, int h) { @@ -255,11 +255,11 @@ glCompSet *glCompSetNew(int w, int h) s->obj = (glCompObj **) 0; s->textureCount = 0; s->textures = (glCompTex **) 0; - s->common.font = new_font_from_parent((glCompObj *) s, NULL); + s->common.font = glNewFontFromParent((glCompObj *) s, NULL); s->common.compset = (glCompSet *) s; - s->common.functions.mouseover = glCompMouseMove; - s->common.functions.mousedown = glCompSetMouseDown; - s->common.functions.mouseup = glCompSetMouseUp; + s->common.functions.mouseover = (glcompmouseoverfunc_t)glCompMouseMove; + s->common.functions.mousedown = (glcompmousedownfunc_t)glCompSetMouseDown; + s->common.functions.mouseup = (glcompmouseupfunc_t)glCompSetMouseUp; glCompMouseInit(&s->mouse); return s; } @@ -343,19 +343,6 @@ void glCompDrawEnd(void) //pops the gl stack } - - - - - - - - - - - - - void glCompSetClear(glCompSet * s) { /* int ind = 0; diff --git a/lib/glcomp/glcompset.h b/lib/glcomp/glcompset.h index a4ea78b20..008fff165 100644 --- a/lib/glcomp/glcompset.h +++ b/lib/glcomp/glcompset.h @@ -43,7 +43,6 @@ extern "C" { extern int glcompsetGetGroupId(glCompSet * s); extern void glCompDrawBegin(void); extern void glCompDrawEnd(void); - extern void glCompDeleteTexture(glCompTex * t); extern void glCompSetAddObj(glCompSet * s, glCompObj * obj); glCompObj *glCompGetObjByMouse(glCompSet * s, glCompMouse * m, int onlyClickable); diff --git a/lib/glcomp/glcomptextpng.c b/lib/glcomp/glcomptextpng.c index 7387ee4cd..07b125bdb 100644 --- a/lib/glcomp/glcomptextpng.c +++ b/lib/glcomp/glcomptextpng.c @@ -19,7 +19,7 @@ #include #include -unsigned char *load_png(char *filename, int *imageWidth, int *imageHeight) +unsigned char *glCompLoadPng (char *filename, int *imageWidth, int *imageHeight) { cairo_surface_t *surface; cairo_format_t format; @@ -27,12 +27,8 @@ unsigned char *load_png(char *filename, int *imageWidth, int *imageHeight) unsigned char *d; surface = NULL; -/* d=create_pango_texture("Arial",14,"hello world \ n hello mars",surface,&w,&h); - *imageWidth=w; - *imageHeight=h;*/ - - surface = cairo_image_surface_create_from_png(filename); + if (!surface) return 0; w = cairo_image_surface_get_width(surface); h = cairo_image_surface_get_height(surface); *imageWidth = w; @@ -40,12 +36,9 @@ unsigned char *load_png(char *filename, int *imageWidth, int *imageHeight) format = cairo_image_surface_get_format(surface); d = cairo_image_surface_get_data(surface); return d; - - - - } +#if 0 unsigned char *load_raw(char *filename, int width, int height) { @@ -60,8 +53,6 @@ unsigned char *load_raw(char *filename, int width, int height) return data; } - - unsigned char *load_png2(char *file_name, int *imageWidth, int *imageHeight) { @@ -156,60 +147,6 @@ unsigned char *load_png2(char *file_name, int *imageWidth, fclose (fp); return imageData; } +#endif -/*#define imageWidth 256 -#define imageHeight 256 -static GLubyte imageData[imageWidth][imageHeight][4];*/ - -int glCompLoadFontPNG(char *name, int id) -{ - GLubyte *imageData = NULL; - int imageWidth, imageHeight, idx2, c; - -// imageData = fontGetData (s, size, imageBits); - imageData = load_png(name, &imageWidth, &imageHeight); - - c = 0; - idx2 = 0; -/* for (idx=0;idx < imageWidth*imageHeight+30000;idx=idx+1) - { - if (c!=imageData[idx]) - { - c=imageData[idx]; - printf ("%i) %i \n ",idx2,imageData[idx]); - } - - idx2++; - c=((((idx&0x8)==0)^((idx2&0x8))==0))*255; - imageData[idx][idx2][0] = c; - imageData[idx][idx2][1] = c; - imageData[idx][idx2][2] = c; - imageData[idx][idx2][3] = 255; - - }*/ - - - /* no image data */ - if (imageData == NULL) - return -1; - - glBindTexture(GL_TEXTURE_2D, id); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - /* glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); */ - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - /* glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); */ - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); -// glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE , GL_DECAL); - - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, imageWidth, imageHeight, 0, - GL_ALPHA, GL_UNSIGNED_BYTE, imageData); -// glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData); - - /* release data, its been uploaded */ - - return 1; -} diff --git a/lib/glcomp/glcomptextpng.h b/lib/glcomp/glcomptextpng.h index 0085f9fc4..cb6290bf9 100644 --- a/lib/glcomp/glcomptextpng.h +++ b/lib/glcomp/glcomptextpng.h @@ -14,4 +14,4 @@ * AT&T Research, Florham Park NJ * **********************************************************/ -unsigned char *load_png(char *filename, int *imageWidth, int *imageHeight); +unsigned char *glCompLoadPng (char *filename, int *imageWidth, int *imageHeight); diff --git a/lib/glcomp/glcomptexture.c b/lib/glcomp/glcomptexture.c index cc57e2824..6b2c90894 100644 --- a/lib/glcomp/glcomptexture.c +++ b/lib/glcomp/glcomptexture.c @@ -19,10 +19,11 @@ #include "memory.h" +#if 0 void glCompSetRemoveTexLabel(glCompSet * s, glCompFont * t) { } - +#endif static glCompTex *glCompSetAddNewTexture(glCompSet * s, int width, int height, unsigned char *data, @@ -60,7 +61,7 @@ static glCompTex *glCompSetAddNewTexture(glCompSet * s, int width, } } if (is2D && !Er) { - t->data = N_NEW(4 * width * height, char); + t->data = N_NEW(4 * width * height, unsigned char); offset = 4; //RGBA mod,TO DO implement other modes /*data upside down because of pango gl coord system */ for (ind = 0; ind < height; ind++) { @@ -136,7 +137,7 @@ glCompTex *glCompSetAddNewTexLabel(glCompSet * s, char *def, int fs, } - data = create_pango_texture(def, fs, text, surface, &width, &height); + data = glCompCreatePangoTexture(def, fs, text, surface, &width, &height); if (!data) /*pango error , */ Er = 1; t = glCompSetAddNewTexture(s, width, height, data, is2D,fs); diff --git a/lib/glcomp/glcomptexture.h b/lib/glcomp/glcomptexture.h index 89058e081..dd522d479 100644 --- a/lib/glcomp/glcomptexture.h +++ b/lib/glcomp/glcomptexture.h @@ -41,6 +41,7 @@ extern "C" { int fs, char *text, int is2D); + extern void glCompDeleteTexture(glCompTex * t); #ifdef __cplusplus } #endif diff --git a/lib/glcomp/glpangofont.c b/lib/glcomp/glpangofont.c index 96ce726c7..2807c62db 100644 --- a/lib/glcomp/glpangofont.c +++ b/lib/glcomp/glpangofont.c @@ -93,7 +93,7 @@ writer(void *closure, const unsigned char *data, unsigned int length) return CAIRO_STATUS_WRITE_ERROR; } -int create_font_file(char *fontdescription, int fs, char *fontfile, +int glCompCreateFontFile(char *fontdescription, int fs, char *fontfile, float gw, float gh) { @@ -158,7 +158,7 @@ int create_font_file(char *fontdescription, int fs, char *fontfile, } -unsigned char *create_pango_texture(char *fontdescription, int fontsize, +unsigned char *glCompCreatePangoTexture(char *fontdescription, int fontsize, char *txt, cairo_surface_t * surface, int *w, int *h) { diff --git a/lib/glcomp/glpangofont.h b/lib/glcomp/glpangofont.h index 4ace42d6d..7bc7cf026 100644 --- a/lib/glcomp/glpangofont.h +++ b/lib/glcomp/glpangofont.h @@ -26,11 +26,11 @@ extern "C" { //creates a font file with given name and font description //returns non-zero if fails - unsigned char *create_pango_texture(char *fontdescription, + unsigned char *glCompCreatePangoTexture(char *fontdescription, int fontsize, char *txt, cairo_surface_t * surface, int *w, int *h); - int create_font_file(char *fontdescription, int fs, char *fontfile, + int glCompCreateFontFile(char *fontdescription, int fs, char *fontfile, float gw, float gh); #ifdef __cplusplus diff --git a/lib/glcomp/glutils.c b/lib/glcomp/glutils.c index 9a06781b1..5bd3aea02 100644 --- a/lib/glcomp/glutils.c +++ b/lib/glcomp/glutils.c @@ -244,7 +244,8 @@ int GetFixedOGLPoslocal(int x, int y, GLfloat * X, GLfloat * Y, return 1; } -void linear_interplotate(float x1, float y1, float x2, float y2, float x3, +#if 0 +void linear_interpolate(float x1, float y1, float x2, float y2, float x3, float *y3) { @@ -254,7 +255,6 @@ void linear_interplotate(float x1, float y1, float x2, float y2, float x3, *y3 = a * x3 + b; } -#if 0 int glreversecamera(ViewInfo * view) { @@ -279,6 +279,7 @@ int glreversecamera(ViewInfo * view) +#if 0 static glCompPoint add(glCompPoint p, glCompPoint q) { p.x += q.x; @@ -286,6 +287,7 @@ static glCompPoint add(glCompPoint p, glCompPoint q) p.z += q.z; return p; } +#endif static glCompPoint sub(glCompPoint p, glCompPoint q) { @@ -305,6 +307,7 @@ static double len(glCompPoint p) return sqrt(dot(p, p)); } +#if 0 static glCompPoint scale(double d, glCompPoint p) { p.x *= (float) d; @@ -312,6 +315,7 @@ static glCompPoint scale(double d, glCompPoint p) p.z *= (float) d; return p; } +#endif static glCompPoint blend(glCompPoint p, glCompPoint q, float m) { @@ -323,6 +327,12 @@ static glCompPoint blend(glCompPoint p, glCompPoint q, float m) return r; } +static double dist(glCompPoint p, glCompPoint q) +{ + return (len(sub(p, q))); +} + +#if 0 static glCompPoint normalize(glCompPoint p) { double d = len(p); @@ -330,11 +340,6 @@ static glCompPoint normalize(glCompPoint p) return scale(1 / d, p); } -static double dist(glCompPoint p, glCompPoint q) -{ - return (len(sub(p, q))); -} - static glCompPoint intersect(line l, plane J) { double t = -(J.d + dot(l.u, J.N)) / dot(l.v, J.N); @@ -361,6 +366,7 @@ double point_to_line_dist(glCompPoint p, glCompPoint a, glCompPoint b) return (dist(p, q)); } +#endif /* @@ -389,11 +395,11 @@ double point_to_lineseg_dist(glCompPoint p, glCompPoint a, glCompPoint b) } +#if 0 /* Calculates the parameters of a plane via given 3 points on it */ - void make_plane(glCompPoint a, glCompPoint b, glCompPoint c, plane * P) { P->N.x = a.y * (b.z - c.z) + b.y * (c.z - a.z) + c.y * (a.z - b.z); //+ @@ -403,6 +409,7 @@ void make_plane(glCompPoint a, glCompPoint b, glCompPoint c, plane * P) (a.x * (b.y * c.z - c.y * b.z) + b.x * (c.y * a.z - a.y * c.z) + c.x * (a.y * b.z - b.y * a.z)) * -1; } +#endif void replacestr(char *source, char **target) { @@ -411,6 +418,7 @@ void replacestr(char *source, char **target) *target = strdup(source); } +#if 0 /* move a point on the great circle of it (spherical) @@ -454,6 +462,7 @@ int rot_spherex(plane J, float tet, glCompPoint P, glCompPoint * P2) return 0; } +#endif void glCompSelectionBox(glCompSet * s) { @@ -688,8 +697,8 @@ void copy_glcomp_color(glCompColor * source, glCompColor * target) } - -double area2(glCompPoint * p1p, glCompPoint * p2p, glCompPoint * p3p) +#if 0 +static double area2(glCompPoint * p1p, glCompPoint * p2p, glCompPoint * p3p) { double d; @@ -700,7 +709,7 @@ double area2(glCompPoint * p1p, glCompPoint * p2p, glCompPoint * p3p) enum {ISCCW, ISON, ISCW}; /* counterclockwise; collinear; clockwise */ -int sideOf (glCompPoint * p1p, glCompPoint * p2p, glCompPoint * p3p) { +static int sideOf (glCompPoint * p1p, glCompPoint * p2p, glCompPoint * p3p) { double d = area2 (p1p,p2p,p3p); if (d < 0) return ISCCW; else if (d > 0) return ISCW; @@ -711,6 +720,7 @@ int lines_intersect (glCompPoint* a, glCompPoint* b, glCompPoint* c, glCompPoint { return ((sideOf(a,b,c) != sideOf(a,b,d)) && (sideOf(c,d,a) != sideOf(c,d,b))); } +#endif GLfloat distBetweenPts(glCompPoint A,glCompPoint B,float R) { GLfloat rv=0; diff --git a/lib/glcomp/glutils.h b/lib/glcomp/glutils.h index 685e4714a..87f5abf18 100644 --- a/lib/glcomp/glutils.h +++ b/lib/glcomp/glutils.h @@ -43,11 +43,14 @@ extern "C" { int GetFixedOGLPoslocal(int x, int y, GLfloat * X, GLfloat * Y, GLfloat * Z); void to3D(int x, int y, GLfloat * X, GLfloat * Y, GLfloat * Z); - void linear_interplotate(float, float, float, float, float, float *); - double point_to_line_dist(glCompPoint p, glCompPoint u, glCompPoint v); double point_to_lineseg_dist(glCompPoint p, glCompPoint a, glCompPoint b); +#if 0 + void linear_interpolate(float, float, float, float, float, float *); + double point_to_line_dist(glCompPoint p, glCompPoint u, glCompPoint v); int rot_spherex(plane J, float tet, glCompPoint P, glCompPoint * P2); void make_plane(glCompPoint a, glCompPoint b, glCompPoint c, plane * P); + int lines_intersect (glCompPoint* a, glCompPoint* b, glCompPoint* c, glCompPoint* d); +#endif void replacestr(char *source, char **target); extern void glCompCalcWidget(glCompCommon * parent, glCompCommon * child, glCompCommon * ref); @@ -60,7 +63,6 @@ extern "C" { extern void glCompSetColor(glCompColor * c); void glCompSelectionBox(glCompSet * s); - extern int lines_intersect (glCompPoint* a, glCompPoint* b, glCompPoint* c, glCompPoint* d); extern GLfloat distBetweenPts(glCompPoint A,glCompPoint B,float R); extern int is_point_in_rectangle(float X, float Y, float RX, float RY, float RW,float RH);