x = (GLfloat) op->u.text.x;
if (op->u.text.align == -1)
x = (GLfloat) op->u.text.x + op->u.text.width;
- fontSize(view->fontset
- view->FontSize);
+ fontSize(view->fontset->fonts[view->fontset->activefont],view->FontSize);
if (param == 0)
- fontColor(view->penColor.R, view->penColor.G, view->penColor.B);
+ fontColor(view->fontset->fonts[view->fontset->activefont],view->penColor.R, view->penColor.G, view->penColor.B);
if (param == 1) //selected
- fontColor(view->selectedNodeColor.R, view->selectedNodeColor.G,
+ fontColor(view->fontset->fonts[view->fontset->activefont],view->selectedNodeColor.R, view->selectedNodeColor.G,
view->selectedNodeColor.B);
- fontDrawString((int) (x - dx), op->u.text.y - (int) dy,
+ fontDrawString(view->fontset->fonts[view->fontset->activefont],(int) (x - dx), op->u.text.y - (int) dy,
op->u.text.text, op->u.text.width);
}
#include "topfisheyeview.h"
#include "glTexFont.h"
-extern texFont_t font;
-
/*
glEnable(GL_TEXTURE_2D);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE , GL_DECAL);
- glBindTexture(GL_TEXTURE_2D,font.texId);
+ glBindTexture(GL_TEXTURE_2D,view->fontset->fonts[view->fontset->activefont]->texId);
glColor3f(1,0,0);
glBegin(GL_POLYGON);
glTexCoord2f(0.0,0.0);glVertex3f(0.0,0.0,0.0);
#else
smyrna_font = smyrnaPath("arial.tga");
#endif
- g_print("loading font....%i\n", fontLoad(smyrna_font));
+// g_print("loading font....%i\n", fontLoad(smyrna_font));
- /*** OpenGL BEGIN ***/
+ add_font(view->fontset,"Vladimir script bold 16");//wired default font
+ /*** OpenGL BEGIN ***/
if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
return;
smyrnaDir = SMYRNA_PATH;
#endif
- create_font_file("c:\\pango_test.png",(float)64.0,(float)64.0);
load_attributes();
#ifdef G_OS_WIN32
set_boundaries(t);
set_update_required(t);
t->topviewmenu = glcreate_gl_topview_menu();
+ //set componenet set's font with already loaded default font.This will be inherited by all components added to this set as default
attach_camera_widget(view);
load_host_buttons(t, g, t->topviewmenu);
t->h = '\0';
(GLfloat) fs,agnameof(view->Topview->picked_nodes[ind]->Node)
)
;
- fontSize(fs);
- fontColorA(0, 0, 1, 1);
+ fontSize(view->fontset->fonts[view->fontset->activefont],fs);
+ fontColorA(view->fontset->fonts[view->fontset->activefont],0, 0, 1, 1);
- fontDrawString(
+ fontDrawString(view->fontset->fonts[view->fontset->activefont],
(view->Topview->picked_nodes[ind]->distorted_x),
(view->Topview->picked_nodes[ind]->
distorted_y+fs+fs/5.0 ),
fs= 10;
- fontSize((int) fs);
+ fontSize(view->fontset->fonts[view->fontset->activefont],(int) fs);
if ((log((float) v->degree) * -0.6 * view->zoom) > 0)
- fontColorA((float) log((double) v->degree + (double) 1),
+ fontColorA(view->fontset->fonts[view->fontset->activefont],(float) log((double) v->degree + (double) 1),
view->penColor.G, view->penColor.B,
view->penColor.A / (float) log((double) v->degree) *
(float) -0.6 * (float) view->zoom);
else
- fontColorA((float) log((double) v->degree + (double) 1),
+ fontColorA(view->fontset->fonts[view->fontset->activefont],(float) log((double) v->degree + (double) 1),
view->penColor.G, view->penColor.B, 1);
// fontColorA(0,0,0,1);
- fontDrawString((int) (v->distorted_x - ddx),
+ fontDrawString(view->fontset->fonts[view->fontset->activefont],(int) (v->distorted_x - ddx),
(int) (v->distorted_y - ddy), v->Label,
(int) (fs * strlen(v->Label)*0.7));
{
glCompSet *s = NEW(glCompSet);
- glCompPanel *p;
+
+ glCompPanel *p;
glCompButton *b;
glCompLabel *l;
- /* GtkRequisition requisition; */
+ copy_font(&(s->font),view->fontset->fonts[view->fontset->activefont]);
+ /* GtkRequisition requisition; *//* What??*/
if (!smyrna_icon_pan) {
#ifdef _WIN32
smyrna_icon_pan = "c:/pan.raw";
atoi(get_attribute_value ("drawlabels", view, g));
view->FontSizeConst=0; //this will be calculated later in topview.c while calculating optimum font size
+
//FIXME: I don't think an openGL function can be called before it
// is initialized.
#ifdef _WIN32
set_viewport_settings_from_template(view, view->default_attributes);
view->dfltViewType = VT_NONE;
view->dfltEngine = GVK_NONE;
+ //create fontset
+ view->fontset=(fontset_t*)malloc(sizeof(fontset_t));
+ fontset_init(view->fontset);
}
font->tIncY=0.0;
font->blockRow=FONT_BLOCK_ROW;
font->blockCol=FONT_BLOCK_COL;
- font->texId=0;
+ font->texId=-1;
font->fontdesc=(char*)0;
- glGenTextures (1, &(font->texId));
fontMakeMap (font);
}
+void copy_font(texFont_t* targetfont,const texFont_t* sourcefont)
+{
+ targetfont->fgColor[0]=sourcefont->fgColor[0];
+ targetfont->fgColor[1]=sourcefont->fgColor[1];
+ targetfont->fgColor[2]=sourcefont->fgColor[2];
+ targetfont->fgColor[3]=sourcefont->fgColor[3];
+ targetfont->gdColor[0]=sourcefont->gdColor[0];
+ targetfont->gdColor[1]=sourcefont->gdColor[1];
+ targetfont->gdColor[2]=sourcefont->gdColor[2];
+ targetfont->gdColor[3]=sourcefont->gdColor[3];
+ targetfont->bgColor[0]=sourcefont->bgColor[0];
+ targetfont->bgColor[1]=sourcefont->bgColor[1];
+ targetfont->bgColor[2]=sourcefont->bgColor[2];
+ targetfont->bgColor[3]=sourcefont->bgColor[3];
+ targetfont->size=sourcefont->size;
+ targetfont->shadow=sourcefont->shadow;
+ targetfont->gradient=sourcefont->gradient;
+ targetfont->italic=sourcefont->italic;
+ targetfont->bold=sourcefont->bold;
+ targetfont->region=sourcefont->region;
+ targetfont->regionX=sourcefont->regionX;
+ targetfont->regionY=sourcefont->regionY;
+ targetfont->regionW=sourcefont->regionW;
+ targetfont->regionH=sourcefont->regionH;
+ targetfont->tIncX=sourcefont->tIncX;
+ targetfont->tIncY=sourcefont->tIncY;
+ targetfont->blockRow=sourcefont->blockRow;
+ targetfont->blockCol=sourcefont->blockCol;
+ targetfont->texId=sourcefont->texId;
+ if (targetfont->fontdesc)
+ free(targetfont->fontdesc);
+ if(sourcefont->fontdesc!=(char*)0)
+ targetfont->fontdesc=strdup(sourcefont->fontdesc);
+ else
+ targetfont->fontdesc=(char*)0;
+ fontMakeMap (targetfont);
+}
+void fontset_init(fontset_t* fs)
+{
+ fs->activefont=-1;
+ fs->count=0;
+ fs->font_directory=NULL; //FIX ME
+ fs->fonts=0;
+}
int add_font(fontset_t* fontset,char* fontdesc)
id=fontId(fontset,fontdesc);
if (id==-1)
{
- sprintf(buf,"%s//%s.png","c://fontfiles//",fontdesc);
- if(create_font_file(fontdesc,buf,(float)256,(float)256)==0)
+ sprintf(buf,"%s/%s.png","c:/fontfiles",fontdesc);
+ if(create_font_file(fontdesc,buf,(float)32,(float)32)==0)
{
fontset->fonts=realloc(fontset->fonts,sizeof(texFont_t*)*(fontset->count+1));
fontset->fonts[fontset->count]=(texFont_t*)malloc(sizeof(texFont_t));
font_init(fontset->fonts[fontset->count]);
- if(!fontLoadPNG (buf, fontset->fonts[fontset->count]->texId))
+ glGenTextures (1, &(fontset->fonts[fontset->count]->texId)); //get opengl texture name
+ if (fontset->fonts[fontset->count]->texId >= 0)
+ {
+ if(!fontLoadPNG (buf, fontset->fonts[fontset->count]->texId))
+ return -1;
+ fontset->activefont=fontset->count;
+ fontset->count++;
+ return fontset->count;
+ }
+ else
return -1;
-
- fontset->count++;
- return fontset->count;
}
else
return -1;
free(fontset->fonts[ind]);
}
free(fontset->fonts);
- free(fontset->font_directory)
+ free(fontset->font_directory);
free(fontset);
}
*/
int fontId(fontset_t* fontset,char* fontdesc);
+/*
+ Initialize fontset as an empty set
+*/
+
+void fontset_init(fontset_t* fs);
+void copy_font(texFont_t* targetfont,const texFont_t* sourcefont);
/*
load font via font description
returns the id,
=============
fontColor*, fontShadowColor*, fonrGradientColor*
+
Sets color for various operations.
=============
*/
+
void fontColor (texFont_t* font,float r, float g, float b);
void fontColorA (texFont_t* font,float r, float g, float b, float a);
void fontColorp (texFont_t* font,float *clr);
{
unsigned char *imageData = NULL;
unsigned char header[8];
- int rowbytes,i,ii,c,pixeloffset;
-
+ int rowbytes,i,ii,b0,b1,b2,b3,pixeloffset;
+ long int c;
png_structp png_ptr;
png_infop info_ptr;
png_infop end_info;
//decide what pixel offset to use, ro
pixeloffset = png_get_rowbytes(png_ptr, info_ptr)/info_ptr->width;
+ b0=-1;b1=-1;b2=-1;b3=-1;
+
for (i=0; i < info_ptr->height; i++)
{
- for (ii=0;ii < 1024; ii=ii+pixeloffset)
+ printf ("Column:%i\n",i);
+ for (ii=0;ii < png_get_rowbytes(png_ptr, info_ptr); ii=ii+pixeloffset)
{
- imageData[c]=row_pointers[255-i][ii];
+ imageData[c]=row_pointers[info_ptr->height-i-1][ii];
+
+ if(
+ (b0!=row_pointers[info_ptr->height-i-1][ii])
+ ||
+ (b1!=row_pointers[info_ptr->height-i-1][ii+1])
+ ||
+ (b2!=row_pointers[info_ptr->height-i-1][ii+2])
+ ||
+ (b3!=row_pointers[info_ptr->height-i-1][ii+3])
+ )
+ {
+ b0=row_pointers[info_ptr->height-i-1][ii];
+ b1=row_pointers[info_ptr->height-i-1][ii+1];
+ b2=row_pointers[info_ptr->height-i-1][ii+2];
+ b3=row_pointers[info_ptr->height-i-1][ii+3];
+ printf ("(%i,%i,%i,%i)",b0,b1,b2,b3);
+
+ }
+
+
c++;
}
+ printf ("\n");
}
+ printf ("embedded bytes:%i\n",c);
+
//cleaning libpng mess
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
png_free(png_ptr, row_pointers);
p->pos.y = y;
p->width = w;
p->height = h;
+ font_init(&p->font);
return p;
}
s->panels = realloc(s->panels, sizeof(glCompPanel *) * s->panelcount);
s->panels[s->panelcount - 1] = p;
p->parentset = s;
- return 1;
+ if (p->font.texId==-1) //no font has been set yet
+ copy_font(&(p->font),&(s->font));
+
+ return 1;
}
int glCompSetAddLabel(glCompSet * s, glCompLabel * p)
s->labelcount++;
s->labels = realloc(s->labels, sizeof(glCompLabel *) * s->labelcount);
s->labels[s->labelcount - 1] = p;
+ if (p->font.texId==-1) //no font has been set yet
+ copy_font(&(p->font),&(s->font));
return 1;
}
p->pos.y = p->pos.y + p->panel->pos.y;
}
- fontSize((int) p->size);
- fontColorA(p->color.R, p->color.G, p->color.B, p->color.A);
+ fontSize(&p->font,(int) p->size);
+ fontColorA(&p->font,p->color.R, p->color.G, p->color.B, p->color.A);
- fontDrawString((int) p->pos.x, (int) p->pos.y, p->text,
+ fontDrawString(&p->font,(int) p->pos.x, (int) p->pos.y, p->text,
(int) (p->size * p->fontsizefactor *
strlen(p->text)));
if (p->panel) {
p->callbackfunc = '\0';
p->panel = '\0';
p->customptr = '\0';
+ font_init(&p->font);
return p;
}
realloc(s->buttons, sizeof(glCompButton *) * s->buttoncount);
s->buttons[s->buttoncount - 1] = p;
p->parentset = s;
-
+ if (p->font.texId==-1) //no font has been set yet
+ copy_font(&(p->font),&(s->font));
return 1;
}
fonty =
(p->height - p->thickness * (GLfloat) 2 -
p->fontsize) / (GLfloat) 2.0 + p->pos.y + p->thickness;
- fontSize((int) p->fontsize);
+ fontSize(&p->font,(int) p->fontsize);
// fontColorA (p->fontcolor.R,p->fontcolor.B,p->fontcolor.G,p->fontcolor.A);
- fontColorA(0, 0, 0, 1);
- fontDrawString((int) fontx, (int) fonty, p->caption,
+ fontColorA(&p->font,0, 0, 0, 1);
+ fontDrawString(&p->font,(int) fontx, (int) fonty, p->caption,
(int) (p->fontsize * strlen(p->caption) *
GLCOMPSET_FONT_SIZE_FACTOR));
}
p->visible = 1;
p->fontsizefactor = GLCOMPSET_FONT_SIZE_FACTOR;
p->panel = '\0';
+ font_init(&p->font);
return p;
}
free(s->panels);
free(s);
}
+
+void change_fonts(glCompSet * s,const texFont_t* sourcefont)
+{
+ int ind = 0;
+ for (ind = 0; ind < s->buttoncount; ind++)
+ {
+ copy_font(&(s->buttons[ind]->font),sourcefont);
+ }
+ for (ind = 0; ind < s->labelcount; ind++)
+ {
+ copy_font(&(s->labels[ind]->font),sourcefont);
+
+ }
+ for (ind = 0; ind < s->panelcount; ind++)
+ {
+ copy_font(&(s->panels[ind]->font),sourcefont);
+ }
+}
\ No newline at end of file
int visible;
void *parentset; //parent compset
int data;
-
+ texFont_t font; //pointer to font to use
} glCompPanel;
typedef struct _glCompLabel {
char *text;
GLfloat fontsizefactor;
glCompPanel *panel; //container panel
+ texFont_t font; //pointer to font to use
} glCompLabel;
callbackfunc_t callbackfunc; //call back for button click
void *customptr; //general purpose void pointer to pass to call back
int data;
+ texFont_t font; //pointer to font to use
} glCompButton;
int active; //0 dont draw, 1 draw
int enabled; //0 disabled 1 enabled(allow mouse interaction)
GLfloat clickedX, clickedY;
+ texFont_t font; //pointer to font to use
} glCompSet;
glCompPanel *glCompPanelNew(GLfloat x, GLfloat y, GLfloat w, GLfloat h);
int glCompPanelShow(glCompPanel * p);
int glCompSetDrawPanels(glCompSet * s);
+/*
+ change all components's fonts in s
+ to sourcefont
+*/
+void change_fonts(glCompSet * s,const texFont_t* sourcefont);
+
+
#endif