x = (GLfloat) op->u.text.x + op->u.text.width;
fontSize(view->fontset->fonts[view->fontset->activefont],view->FontSize);
if (param == 0)
- fontColor(view->fontset->fonts[view->fontset->activefont],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,1);
if (param == 1) //selected
fontColor(view->fontset->fonts[view->fontset->activefont],view->selectedNodeColor.R, view->selectedNodeColor.G,
- view->selectedNodeColor.B);
+ view->selectedNodeColor.B,1);
fontDrawString(view->fontset->fonts[view->fontset->activefont], (x - dx), (GLfloat)op->u.text.y - dy,
(GLfloat)op->u.text.width, op->u.text.text);
}
draw_selection_box(view);
drawBorders(view);
drawRotatingTools();
+
// drawtestpoly();
/*DEBUG*/
/* if (view->mouse.mouse_mode == MM_PAN)
drawtopologicalfisheye(view->Topview);
}
glCompSetDraw(view->Topview->topviewmenu);
+// OtkUpdateCheck();
+ // OtkDisplayFunct();
+
}
else
drawGraph(view->g[view->activeGraph]); //xdot based drawing functions
#else
smyrna_font = smyrnaPath("arial.tga");
#endif
-// g_print("loading font....%i\n", fontLoad(smyrna_font));
add_font(view->fontset,"Times 14");//wired in default font
/*** OpenGL BEGIN ***/
void mShowToolBoxSlot(GtkWidget * widget, gpointer user_data)
{
- gtk_widget_hide(glade_xml_get_widget(xml, "frmToolBox"));
- gtk_widget_show(glade_xml_get_widget(xml, "frmToolBox"));
+ gtk_widget_hide(glade_xml_get_widget(xml, "gtkglwindow"));
+ gtk_widget_show(glade_xml_get_widget(xml, "gtkglwindow"));
gtk_window_set_keep_above((GtkWindow *)
- glade_xml_get_widget(xml, "frmToolBox"), 1);
+ glade_xml_get_widget(xml, "gtkglwindow"), 1);
+
+if(!gtk_widget_set_gl_capability (glade_xml_get_widget(xml, "glfixed"), configure_gl(),gtk_widget_get_gl_context(view->drawing_area),0,0))
+ printf("glwidget creation failed \n");
+
+
}
#if defined(_WIN32) && !defined(__CYGWIN__)
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
+#include <windowsx.h>
#endif
+#include "otk_lib.h"
#include <gtk/gtk.h>
#include <gtk/gtkgl.h>
#include <glade/glade.h>
GdkGLConfig *glconfig;
char* initFileName;
- smyrnaDir = getenv ("SMYRNA_PATH");
+ smyrnaDir = getenv ("SMYRNA_PATH");
#ifndef _WIN32
if (!smyrnaDir)
smyrnaDir = SMYRNA_PATH;
Name="VCCLCompilerTool"
AdditionalOptions="/D "_CRT_SECURE_NO_DEPRECATE""
Optimization="0"
- AdditionalIncludeDirectories=""$(SolutionDir)/lib/gvc";"C:\gtk\include\libglade-2.0";"$(SolutionDir)/lib/neatogen";"$(SolutionDir)/lib/sparse";"$(SolutionDir)/lib/topfish";"C:\gtk\lib\gtkglext-1.0\include";"C:\gtk\include\gtkglext-1.0\";C:\gtk\include\cairo;"C:\gtk\include\atk-1.0";"C:\gtk\lib\gtk-2.0\include\cairo";"C:\gtk\lib\gtk-2.0\include";"C:\gtk\include\gtk-2.0\";"$(SolutionDir)/cmd/smyrna/gui";"$(SolutionDir)/cmd/smyrna";"$(SolutionDir)";"$(SolutionDir)/lib/glcomp";"C:\gtk\lib\glib-2.0\include";"C:\gtk\include\glib-2.0";"C:\gtk\include\pango-1.0\";C:\gtk\include;"$(SolutionDir)/lib/common";"$(SolutionDir)/lib/cdt";"$(SolutionDir)/lib/cgraph";"$(SolutionDir)/windows\lib\ingraphs";"$(SolutionDir)/lib/xdot""
+ AdditionalIncludeDirectories=""C:\graphviz-ms\graphviz2\lib\windirent";"$(SolutionDir)/lib/gvc";"C:\gtk\include\libglade-2.0";"$(SolutionDir)/lib/neatogen";"$(SolutionDir)/lib/sparse";"$(SolutionDir)/lib/topfish";"C:\gtk\lib\gtkglext-1.0\include";"C:\gtk\include\gtkglext-1.0\";C:\gtk\include\cairo;"C:\gtk\include\atk-1.0";"C:\gtk\lib\gtk-2.0\include\cairo";"C:\gtk\lib\gtk-2.0\include";"C:\gtk\include\gtk-2.0\";"$(SolutionDir)/cmd/smyrna/gui";"$(SolutionDir)/cmd/smyrna";"$(SolutionDir)";"$(SolutionDir)/lib/glcomp";"C:\gtk\lib\glib-2.0\include";"C:\gtk\include\glib-2.0";"C:\gtk\include\pango-1.0\";C:\gtk\include;"$(SolutionDir)/lib/common";"$(SolutionDir)/lib/cdt";"$(SolutionDir)/lib/cgraph";"$(SolutionDir)/windows\lib\ingraphs";"$(SolutionDir)/lib/xdot";"$(SolutionDir)/lib/otk_lib""
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_TRIANGLE;HAVE_CONFIG_H;HAVE_GTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="0"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4995;4996"
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="mspng.lib gtk-win32-2.0.lib asprintf.lib atk-1.0.lib bz2.lib cairo.lib charset.lib croco-0.6.lib expat.lib expatw.lib glade-2.0.lib fontconfig.lib freetype.lib gdk_pixbuf-2.0.lib gdkglext-win32-1.0.lib gdk-win32-2.0.lib glib-2.0.lib gmodule-2.0.lib gobject-2.0.lib gsf-1.lib gsf-win32-1.lib gthread-2.0.lib gtkglext-win32-1.0.lib iconv.lib intl.lib jpeg.lib libexpat.lib libexpatw.lib pango-1.0.lib pangocairo-1.0.lib pangoft2-1.0.lib pangowin32-1.0.lib popt.lib rsvg-2.lib tiff.lib xml2.lib libgdkglext-win32-1.0.dll.a libgtkglext-win32-1.0.dll.a glu32.lib opengl32.lib ltdl.lib hs_regex.lib zdll.lib gladeui-1.lib glcomp.lib cgraph.lib gvc.lib xdot.lib topfish.lib ingraphs.lib neatogen.lib gts.lib $(NOINHERIT)"
+ AdditionalDependencies="mspng.lib gtk-win32-2.0.lib asprintf.lib atk-1.0.lib bz2.lib cairo.lib charset.lib croco-0.6.lib expat.lib expatw.lib glade-2.0.lib fontconfig.lib freetype.lib gdk_pixbuf-2.0.lib gdkglext-win32-1.0.lib gdk-win32-2.0.lib glib-2.0.lib gmodule-2.0.lib gobject-2.0.lib gsf-1.lib gsf-win32-1.lib gthread-2.0.lib gtkglext-win32-1.0.lib iconv.lib intl.lib jpeg.lib libexpat.lib libexpatw.lib pango-1.0.lib pangocairo-1.0.lib pangoft2-1.0.lib pangowin32-1.0.lib popt.lib rsvg-2.lib tiff.lib xml2.lib libgdkglext-win32-1.0.dll.a libgtkglext-win32-1.0.dll.a glu32.lib opengl32.lib ltdl.lib hs_regex.lib zdll.lib gladeui-1.lib glcomp.lib cgraph.lib gvc.lib xdot.lib topfish.lib ingraphs.lib neatogen.lib gts.lib User32.lib Gdi32.lib shlwapi.lib $(NOINHERIT)"
OutputFile="c:/graphviz-ms/bin/$(ProjectName).exe"
LinkIncremental="2"
AdditionalLibraryDirectories="C:\glade_setup\lib;"C:\graphviz-ms\bin";C:\gtk\lib;C:\GnuWin32\lib;"C:\Projects\graphviz2\lib\zlib-1.2.3\lib";C:\Projects\cairo_build\lib;C:\Projects\ATT\GTK\GTKTest2\lib;C:\GtkGLExt\1.0\lib;C:\GTK\2.0\bin;C:\GTK\2.0\lib"
#ifdef WIN32
#include "windows.h"
-#include "gltexfont.h"
+//#include "gltexfont.h"
//#define SMYRNA_GLADE "C:/Projects/graphviz2/share/gui/smyrna.glade"
#define SMYRNA_ATTRS "c:/graphviz-ms/share/gui/attrs.txt"
#endif
topviewdata *TopviewData;
void *customptr;
Hierarchy *h;
+ glCompColor srcColor; //fine node colors of topfisheye
+ glCompColor tarColor; //supernode colors of fisheye
int is_top_fisheye; //1 draw hierarchy 0 draw regular topview
focus_t* fs;
struct {
#include "topfisheyeview.h"
#include "glTexFont.h"
-#include "glTexFontTGA.h"
-#include "glTexFontDefs.h"
-#include "glTexFontInclude.h"
+#include "glcomptextpng.h"
#include "math.h"
#include "memory.h"
#include "viewport.h"
#include "hier.h"
#include "topfisheyeview.h"
#include <string.h>
+#include "color.h"
+
static int get_temp_coords(topview* t,int level,int v,double* coord_x,double* coord_y);
static int get_temp_coords2(topview* t,int level,int v,double* coord_x,double* coord_y,float *R,float *G,float *B);
static int FLUSH=0;
+
+static void color_interpolation(glCompColor srcColor,glCompColor tarColor,glCompColor* color,int levelcount,int level)
+{
+ if (levelcount <=0)
+ return;
+
+
+ color->R=((float)level*tarColor.R-(float)level*srcColor.R+(float)levelcount*srcColor.R) /
+ (float)levelcount;
+ color->G=((float)level*tarColor.G-(float)level*srcColor.G+(float)levelcount*srcColor.G) /
+ (float)levelcount;
+ color->B=((float)level*tarColor.B-(float)level*srcColor.B+(float)levelcount*srcColor.B) /
+ (float)levelcount;
+}
+
static double dist(double x1, double y1, double x2, double y2)
{
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
1) * x / (view->fmg.fisheye_distortion_fac * x + 1);
}
+
void fisheye_polar(double x_focus, double y_focus, topview * t)
{
int i;
Hierarchy *hp;
ex_vtx_data *gg;
topview_node *np;
+ gvcolor_t cl;
v_data *graph = makeGraph(t, &ne);
view->Topview->parms.repos.height =(int) (view->bdyTop-view->bdyBottom);
view->Topview->parms.repos.rescale=Polar;
+ //topological fisheye
+
+ colorxlate(get_attribute_value("topologicalfisheyefinestcolor", view, view->g[view->activeGraph]), &cl,
+ RGBA_DOUBLE);
+ view->Topview->srcColor.R = (float) cl.u.RGBA[0];
+ view->Topview->srcColor.G = (float) cl.u.RGBA[1];
+ view->Topview->srcColor.B = (float) cl.u.RGBA[2];
+ colorxlate(get_attribute_value("topologicalfisheyecoarsestcolor", view, view->g[view->activeGraph]), &cl,
+ RGBA_DOUBLE);
+ view->Topview->tarColor.R = (float) cl.u.RGBA[0];
+ view->Topview->tarColor.G = (float) cl.u.RGBA[1];
+ view->Topview->tarColor.B = (float) cl.u.RGBA[2];
+
+
sscanf(agget(view->g[0],"topologicalfisheyedistortionfactor"),"%lf",&view->Topview->parms.repos.distortion);
sscanf(agget(view->g[0],"topologicalfisheyefinenodes"),"%d",&view->Topview->parms.level.num_fine_nodes);
sscanf(agget(view->g[0],"topologicalfisheyecoarseningfactor"),"%lf",&view->Topview->parms.level.coarsening_rate);
void drawtopfishnodes(topview * t)
{
- int level, v;
+ glCompColor srcColor;
+ glCompColor tarColor;
+ glCompColor color;
+ int level, v;
Hierarchy *hp = t->h;
-
+ static max_visible_level=0;
+ srcColor.R=view->Topview->srcColor.R;
+ srcColor.G=view->Topview->srcColor.G;
+ srcColor.B=view->Topview->srcColor.B;
+ tarColor.R=view->Topview->tarColor.R;
+ tarColor.G=view->Topview->tarColor.G;
+ tarColor.B=view->Topview->tarColor.B;
+
glEnable(GL_POINT_SMOOTH); /*turn this off to make points look square*/
//draw focused node little bigger than others
&& (-y0 / view->zoom < view->clipY2))))
continue;
- if (level !=0)
- glColor4f((GLfloat) (hp->nlevels - level)*(GLfloat)0.5 / (GLfloat) hp->nlevels,
- (GLfloat) level / (GLfloat) hp->nlevels, (GLfloat)0,(GLfloat)view->defaultnodealpha);
- else
- glColor4f((GLfloat) 1,
- (GLfloat) level / (GLfloat) hp->nlevels*2, 0,view->defaultnodealpha);
+// if (level !=0)
+// glColor4f((GLfloat) (hp->nlevels - level)*(GLfloat)0.5 / (GLfloat) hp->nlevels,
+// (GLfloat) level / (GLfloat) hp->nlevels, (GLfloat)0,(GLfloat)view->defaultnodealpha);
+ // else
+// glColor4f((GLfloat) 1,
+// (GLfloat) level / (GLfloat) hp->nlevels*2, 0,view->defaultnodealpha);
+
+ if (max_visible_level < level)
+ max_visible_level=level;
+ color_interpolation(srcColor,tarColor,&color,max_visible_level,level);
+ glColor4f(color.R,color.G,color.B,(GLfloat)view->defaultnodealpha);
/* glColor3f((GLfloat) (hp->nlevels - level)*0.5 / (GLfloat) hp->nlevels,
(GLfloat) level / (GLfloat) hp->nlevels, 0);*/
if((v==t->fs->foci_nodes[0]) &&(focusnodes))
{
fs=view->FontSizeConst*(float)1.4;
- fontColorA(view->fontset->fonts[view->fontset->activefont],(float)0, (float)0, (float)1, (float)1);
+ fontColor(view->fontset->fonts[view->fontset->activefont],(float)0, (float)0, (float)1, (float)1);
fontSize(view->fontset->fonts[view->fontset->activefont],fs);
fontDrawString(view->fontset->fonts[view->fontset->activefont],gg[v].physical_x_coord,gg[v].physical_y_coord, (fs*strlen(buf)*(GLfloat)0.4),buf);
}
else if (finenodes)
{
- fs=view->FontSizeConst;
- fontColorA(view->fontset->fonts[view->fontset->activefont],0, 0, 0, 1);
+ fs=view->FontSizeConst*1.2;
+ fontColor(view->fontset->fonts[view->fontset->activefont],0, 0, 0, 1);
fontSize(view->fontset->fonts[view->fontset->activefont],fs);
fontDrawString(view->fontset->fonts[view->fontset->activefont],gg[v].physical_x_coord,gg[v].physical_y_coord, (fs*strlen(buf)*(GLfloat)0.4),buf);
}
}
void drawtopfishedges(topview * t)
{
- int level, v, i, n;
+ glCompColor srcColor;
+ glCompColor tarColor;
+ glCompColor color;
+
+ int level, v, i, n;
Hierarchy *hp = t->h;
+ static max_visible_level=0;
+ srcColor.R=view->Topview->srcColor.R;
+ srcColor.G=view->Topview->srcColor.G;
+ srcColor.B=view->Topview->srcColor.B;
+ tarColor.R=view->Topview->tarColor.R;
+ tarColor.G=view->Topview->tarColor.G;
+ tarColor.B=view->Topview->tarColor.B;
+
//and edges
glBegin(GL_LINES);
for (level = 0; level < hp->nlevels; level++)
{
double x, y;
n = g[v].edges[i];
- if (level !=0)
- glColor4f((GLfloat) (hp->nlevels - level)*(GLfloat)0.5 / (GLfloat) hp->nlevels,
- (GLfloat) level / (GLfloat) hp->nlevels, 0,view->defaultedgealpha);
- else
- glColor4f((GLfloat) 1,
- (GLfloat) level / (GLfloat) hp->nlevels*2, 0,view->defaultedgealpha);
+
+
+ if (max_visible_level < level)
+ max_visible_level=level;
+ color_interpolation(srcColor,tarColor,&color,max_visible_level,level);
+ glColor4f(color.R,color.G,color.B,(GLfloat)view->defaultnodealpha);
+
+
if (get_temp_coords(t,level,n,&x,&y))
{
glVertex3f((GLfloat) x0, (GLfloat) y0,(GLfloat) 0);
float *z, int num_foci)
{
+ gvcolor_t cl;
focus_t *fs = t->fs;
int i;
int closest_fine_node;
view->Topview->parms.repos.width =(int) (view->bdxRight-view->bdxLeft);
view->Topview->parms.repos.height =(int) (view->bdyTop-view->bdyBottom);
+ colorxlate(get_attribute_value("topologicalfisheyefinestcolor", view, view->g[view->activeGraph]), &cl,
+ RGBA_DOUBLE);
+ view->Topview->srcColor.R = (float) cl.u.RGBA[0];
+ view->Topview->srcColor.G = (float) cl.u.RGBA[1];
+ view->Topview->srcColor.B = (float) cl.u.RGBA[2];
+ colorxlate(get_attribute_value("topologicalfisheyecoarsestcolor", view, view->g[view->activeGraph]), &cl,
+ RGBA_DOUBLE);
+ view->Topview->tarColor.R = (float) cl.u.RGBA[0];
+ view->Topview->tarColor.G = (float) cl.u.RGBA[1];
+ view->Topview->tarColor.B = (float) cl.u.RGBA[2];
+
+
+
sscanf(agget(view->g[0],"topologicalfisheyedistortionfactor"),"%lf",&view->Topview->parms.repos.distortion);
sscanf(agget(view->g[0],"topologicalfisheyefinenodes"),"%d",&view->Topview->parms.level.num_fine_nodes);
sscanf(agget(view->g[0],"topologicalfisheyecoarseningfactor"),"%lf",&view->Topview->parms.level.coarsening_rate);
+
set_active_levels(hp, fs->foci_nodes, fs->num_foci, &(t->parms.level));
glEnd();*/
}
-
* AT&T Research, Florham Park NJ *
**********************************************************/
#include "glTexFont.h"
-#include "glTexFontTGA.h"
-#include "glTexFontDefs.h"
-#include "glTexFontInclude.h"
+#include "glcomptextpng.h"
#include "glcompbutton.h"
#include "glcomppanel.h"
#include "glcomplabel.h"
#else
#include "regex.h"
#endif
+#include "otk_lib.h"
+
+
static float dx = 0.0;
static float dy = 0.0;
static int draw_node_hint_boxes(void);
static int pick_node(topview_node * n);
+
void cleartopview(topview * t)
{
/*clear nodes */
int maxlabelsize=0;
float maxedgelen,minedgelen,len,edgelength;
+
+// OtkInitWindow( 700, 500, NULL, NULL );
+// OtkMakeButton( OtkOuterWindow, 10.0, 10.0, 80.0, 80.0, "Hello World !", 0, 0 );
+// OtkMainLoop();
+
+
+
maxedgelen=0;
minedgelen=(float)99999999.00000; //FIX ME if you have a giant graph or fix your graph
edgelength=0;
)
;
fontSize(view->fontset->fonts[view->fontset->activefont],fs);
- fontColorA(view->fontset->fonts[view->fontset->activefont],0, 0, 1, 1);
+ fontColor(view->fontset->fonts[view->fontset->activefont],0, 0, 1, 1);
fontDrawString(
&& (v->distorted_y / view->zoom * -1 < view->clipY2))
{
fs=calculate_font_size(v);
-
+ if (v->degree==0)
+ printf("haha\n");
/* fs = (v->degree ==1) ?
:
(float) (log((double) v->degree +(double) 0.5) *(double) 3)*14;*/
- fs =(float) (log((double) v->degree +(double) 0.5) *(double) 3)*14;
+ fs =(float) (log((double) v->degree +(double) 0.7) *(double) 3)*14;
// fs=view->FontSize;
fs = fs * v->zoom_factor;
+ if (v->degree < 3)
+ fs=fs*2;
if (OD_Selected(v->Node) == 1) {
ddx = dx;
ddy = dy;
return 0;
// fs= 10;
- fs= fs * (float)0.2;
+ fs= fs * (float)0.182;
fontSize(view->fontset->fonts[view->fontset->activefont],fs);
if ((log((float) v->degree) * -0.6 * view->zoom) > 0)
- fontColorA(view->fontset->fonts[view->fontset->activefont],(float) log((double) v->degree + (double) 1),
+ fontColor(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.4 * (float) view->zoom);
else
- fontColorA(view->fontset->fonts[view->fontset->activefont],(float) log((double) v->degree + (double) 1),
+ fontColor(view->fontset->fonts[view->fontset->activefont],(float) log((double) v->degree + (double) 1),
view->penColor.G, view->penColor.B, (float)0.7);
-// fontColorA(0,0,0,1);
+ fontColor(view->fontset->fonts[view->fontset->activefont],0,0,0,view->penColor.A / (float) log((double) v->degree) *
+ (float) -0.4 * (float) view->zoom);
fontDrawString(view->fontset->fonts[view->fontset->activefont],(v->distorted_x - ddx),
(v->distorted_y - ddy), (fs * strlen(v->Label)*(float)0.6),v->Label );
free(view);
}
-static char *get_attribute_value(char *attr, ViewInfo * view, Agraph_t * g)
+char *get_attribute_value(char *attr, ViewInfo * view, Agraph_t * g)
{
char *buf;
buf = agget(g, attr);
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gvplugin_gdiplus", "plugin\gdiplus\gvplugin_gdiplus.vcproj", "{0F4D5D8F-F4D6-4A5D-97E0-9B482257F493}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "otk", "lib\otk_lib\otk.vcproj", "{343EB043-1F93-4F40-989D-FA309E4668AF}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
{0F4D5D8F-F4D6-4A5D-97E0-9B482257F493}.Debug|Win32.Build.0 = Debug|Win32
{0F4D5D8F-F4D6-4A5D-97E0-9B482257F493}.Release|Win32.ActiveCfg = Release|Win32
{0F4D5D8F-F4D6-4A5D-97E0-9B482257F493}.Release|Win32.Build.0 = Release|Win32
- {343EB043-1F93-4F40-989D-FA309E4668AF}.Debug|Win32.ActiveCfg = Debug|Win32
- {343EB043-1F93-4F40-989D-FA309E4668AF}.Debug|Win32.Build.0 = Debug|Win32
- {343EB043-1F93-4F40-989D-FA309E4668AF}.Release|Win32.ActiveCfg = Release|Win32
- {343EB043-1F93-4F40-989D-FA309E4668AF}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
-/* vim:set shiftwidth=4 ts=8: */
-/*
- glTexFont Library R6
-
- Copyright (c) 1999 Nate Miller
-
- Notice: Usage of any code in this file is subject to the rules
- described in the LICENSE.TXT file included in this directory.
- Reading, compiling, or otherwise using this code constitutes
- automatic acceptance of the rules in said text file.
-
- File -- glTexFont.c
- Date -- 5/30/99
- Author -- Nate 'm|d' Miller
- Contact -- vandals1@home.com
- Web -- http://members.home.com/vandals1
-*/
-//#define FONT_LIB_DEBUG /* un-comment for debug regions */
#include "glTexFont.h"
-#include "glTexFontTGA.h"
-#include "glTexFontDefs.h"
-#include "glTexFontInclude.h"
#include "glpangofont.h"
#include "memory.h"
-/* just a global for our default colors */
-float white[] = {1.0, 1.0, 1.0, 1.0};
-float gray[] = {0.5, 0.5, 0.5, 1.0};
-
-
-/*
- tPoints contains our map for the font image. After fontMakeMap this array
- will contain all the information to get the proper key from the font map.
-*/
vec2_t tPoints[257];
-/*
-=============
-fontLoad
-
-Load the passed image name and use it for the font.
-=============
-*/
-int fontLoad (texFont_t* font,char *name)
-{
- glGenTextures (1, &(font->texId));
-
- font->blockRow = FONT_BLOCK_ROW;
- font->blockCol = FONT_BLOCK_COL;
-
- fontMakeMap (font);
-
-// return fontLoadTGA (name, font.texId);
- return fontLoadPNG ("c:\\pango_test.png", font->texId);
-}
-/*
-=============
-fontLoadEx
-
-Loads the passed image which has 'col' characters per column and 'row'
-characters per row.
-=============
-*/
-int fontLoadEx (texFont_t* font,char *name, int row, int col)
+int glCompLoadFont (glCompText* font,char *name)
{
- /* make sure we have valid dimensions */
-/* if (row * col != 256)
- return 0;*/
-
glGenTextures (1, &(font->texId));
-
- font->blockRow = row;
- font->blockCol = col;
-
fontMakeMap (font);
+ return glCompLoadFontPNG ("c:\\pango_test.png", font->texId);
- return fontLoadTGA (name, font->texId);
}
-/*
-=============
-fontDrawChar
-
-Draws a character that is 'size' pixels in w and h.
-=============
-*/
-void fontDrawChar (texFont_t* font,char c, GLfloat x, GLfloat y, GLfloat size, int shadow)
-{
- if (!font->gradient && !shadow)
- glColor4fv (font->fgColor);
- else if (!font->gradient && shadow)
- glColor4fv (font->bgColor);
- else if (font->gradient && !shadow)
- glColor4fv (font->gdColor);
-
- glBegin (GL_QUADS);
- glTexCoord2f (tPoints[(int)c][0], tPoints[(int)c][1]);
- glVertex3f (x, y,0);
- glTexCoord2f (tPoints[(int)c][0] + font->tIncX, tPoints[(int)c][1]);
- glVertex3f (x + size, y,0);
-
- if (!shadow)
- glColor4fv (font->fgColor);
- else glColor4fv (font->bgColor);
-
- glTexCoord2f (tPoints[(int)c][0] + font->tIncX, tPoints[(int)c][1] + font->tIncY);
- glVertex3f (x + size + font->italic, y + size,0);
- glTexCoord2f (tPoints[(int)c][0], tPoints[(int)c][1] + font->tIncY);
- glVertex3f (x + font->italic, y + size,0);
- glEnd ();
-}
-/*
-=============
-fontScissorNormal
-
-Normal scissor region for text rendering.
-=============
-*/
-void fontScissorNormal (texFont_t* font,int xpos, int ypos, int tabs, int carrage, int size, int len)
+void fontForeColorReset (glCompText* font)
{
- int sy;
- int ex;
- int ey;
-
- ex = len * size * tabs;
-
- if (carrage)
- {
- sy = ypos - (size * carrage);
- ey = size * (carrage + 1);
- } else {
- sy = ypos;
- ey = size;
- }
- glScissor (xpos, sy, ex, ey);
-}
-/*
-=============
-=============
-fontFgColorReset
-
-Resets the font color.
-=============
-*/
-void fontForeColorReset (texFont_t* font)
-{
- fontColorCopy (white, font->fgColor);
-}
-/*
-=============
-fontBgColorReset
+ font->color.R=1.00;
+ font->color.G=1.00;
+ font->color.B=1.00;
+ font->color.A=1.00;
-Resets the shadow color.
-=============
-*/
-void fontShadowColorReset (texFont_t* font)
-{
- fontColorCopy (gray, font->bgColor);
-}
-/*
-=============
-fontGdColorReset
-Resets the gradient color.
-=============
-*/
-void fontGradientColorReset (texFont_t* font)
-{
- fontColorCopy (gray, font->gdColor);
}
-/*
-=============
-fontReset
-
-Resets the font. Only resets variables that could possible change.
-=============
-*/
-void fontReset (texFont_t* font)
+void fontReset (glCompText* font)
{
- font->size = 12;
- font->shadow = 0;
- font->region = 0;
- font->gradient = 0;
- font->italic = 0;
- font->bold = 0;
- font->regionX = 0;
- font->regionY = 0;
- font->regionW = 0;
- font->regionH = 0;
+ font->fontheight = 12;
fontForeColorReset (font);
- fontShadowColorReset (font);
- fontGradientColorReset (font);
-}
-/*
-=============
-fontRegion
-
-Sets up a font region. Only good for one fontDrawString.
-=============
-*/
-void fontRegion (texFont_t* font,float x, float y, float w, float h)
-{
- font->region = 1;
- font->regionX = x;
- font->regionY = y - h;
- font->regionW = w;
- font->regionH = h;
}
-/*
-=============
-fontSize
-
-Sets the font size.
-=============
-*/
-void fontSize (texFont_t* font,GLfloat size)
+void fontSize (glCompText* font,GLfloat size)
{
- font->size = size;
+ font->fontheight = size;
}
-void fontzdepth(texFont_t* font,GLfloat zdepth)
+void fontzdepth(glCompText* font,GLfloat zdepth)
{
font->zdepth=zdepth;
}
-/*
-=============
-fontShadow
-
-Draws a shadow if called.
-=============
-*/
-void fontShadow (texFont_t* font)
-{
- font->shadow = 1;
-}
-/*
-=============
-fontGradient
-
-Draws gradient text if called.
-=============
-*/
-void fontGradient (texFont_t* font)
-{
- font->gradient = 1;
-}
-/*
-=============
-fontRenderChar
-
-Draws a character to the screen
-Bold is just a hack, nothing special
-=============
-*/
-void fontRenderChar (texFont_t* font,char c, GLfloat x, GLfloat y, GLfloat size)
-{
- if (font->shadow)
- {
- if (!font->bold)
- fontDrawChar (font,c, x + (GLfloat)1.0, y + (GLfloat)1.0, size, 1);
- else fontDrawChar (font,c, x + (GLfloat)2.0, y + (GLfloat)1.0, size, 1);
- }
-
-
-
- fontDrawChar (font,c, x, y, size, 0);
-
- if (font->bold)
- fontDrawChar (font,c, x + (GLfloat)1.0, y, size, 0);
-}
-/*
-=============
-fontSlashParser
-
-Handles all the fun that comes with a \\, returns amount to advance string.
-After this funtion *buffptr ++ will be the next character to draw or parse.
-=============
-*/
-int fontSlashParser (texFont_t* font,char *buffPtr, GLfloat *x, GLfloat *y)
-{
- int ret = 0;
-
- *buffPtr ++;
-
- if (!*buffPtr)
- return ret;
-
- switch (*buffPtr)
- {
- case 'a':
- case 'c':
- *x -= font->size;
- return fontSetColorFromToken (font,buffPtr);
- break;
- case 'i':
- *x -= font->size;
- return fontItalicsMode (font,buffPtr);
- break;
- case 'b':
- *x -= font->size;
- return fontBoldMode (font,buffPtr);
- break;
- default:
- *buffPtr --;
- fontRenderChar (font,*buffPtr, *x, *y, font->size);
- return ret;
- break;
- }
-}
-/*
-=============
-fontWalkString
-
-Does the actual rendering of our string.
-=============
-*/
-void fontWalkString (texFont_t* font,char *buffPtr, GLfloat xpos, GLfloat ypos, int *vPort,float width)
+void fontWalkString (glCompText* font,char *bf, GLfloat xpos, GLfloat ypos, int *vPort,float width)
{
- GLfloat size = font->size;
+ GLfloat size = font->fontheight;
GLfloat x = xpos;
GLfloat y = ypos;
GLfloat carrage = 0;
GLfloat charGap;
xMax = vPort[0] + vPort[2];
- carrage = (GLfloat) fontGetCharHits (buffPtr, '\n');
- tabs = (GLfloat) fontGetCharHits (buffPtr, '\t');
+ carrage = (GLfloat) fontGetCharHits (bf, '\n');
+ tabs = (GLfloat) fontGetCharHits (bf, '\t');
if (!tabs)
tabs = 1;
else tabs *= FONT_TAB_SPACE;
-
-/* if (font.region)
- {
- fontScissorTextRegion ();
- x = font.regionX;
- y = (font.regionY + font.regionH) - font.size;
- } else
- fontScissorNormal (xpos, ypos, tabs, carrage, font.size, len); */
-
-#ifdef FONT_LIB_DEBUG
- glClearColor (1,0,1,1);
- glClear (GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
-#endif
-
/* lets draw! */
//width for each char should be calculated , we need the max line length of the paragraph
- tempC=buffPtr;
+ tempC=bf;
charCount=0;
maxcharCount=0;
charGap=(width / (float)maxcharCount);
- for ( ; *buffPtr; *buffPtr ++, x += charGap) //size*0.7 is the distance between2 characters
+ for ( ; *bf; *bf ++, x += charGap) //size*0.7 is the distance between2 characters
{
- // if (x > xMax)
- // break;
- /* if (font.region)
- {
- if (x + size > (font.regionX + font.regionW))
- {
- y -= size;
- x = font.regionX;
- }
- if (y < font.regionY)
- break;
- }*/
+ glBegin (GL_QUADS);
+ glTexCoord2f (tPoints[(int)(*bf)][0], tPoints[(int)(*bf)][1]);
+ glVertex3f (x, y,0);
+ glTexCoord2f (tPoints[(int)(*bf)][0] + font->tIncX, tPoints[(int)(*bf)][1]);
+ glVertex3f (x + size, y,0);
-/*
- if(*buffPtr==' ') //SPACE
- x = x + size;*/
+ glColor4f (font->color.R,font->color.G,font->color.B,font->color.A);
- switch (*buffPtr)
- {
+ glTexCoord2f (tPoints[(int)(*bf)][0] + font->tIncX, tPoints[(int)(*bf)][1] + font->tIncY);
+ glVertex3f (x + size, y + size,0);
-
- case '\n':
- y -= size;
- x = xpos - size;
- continue;
- break;
- case '\t':
- x += (size * FONT_TAB_SPACE);
- continue;
- break;
- case '\\':
- buffPtr += fontSlashParser (font,buffPtr, &x, &y);
- if (*buffPtr == '\n' || *buffPtr == '\t')
- {
- buffPtr -= 1;
- continue;
- }
- break;
- default :
- fontRenderChar (font,*buffPtr, x, y, size);
- break;
- }
+ glTexCoord2f (tPoints[(int)(*bf)][0], tPoints[(int)(*bf)][1] + font->tIncY);
+ glVertex3f (x , y + size,0);
+ glEnd ();
}
}
/*
=============
*/
void
-fontDrawString (texFont_t* font, GLfloat xpos, GLfloat ypos,
- GLfloat width, char *s, ...)
+fontDrawString (glCompText* font, GLfloat xpos, GLfloat ypos,
+ GLfloat width, char *s)
{
- va_list msg;
- char buffer[FONT_MAX_LEN] = {'\0'};
int vPort[4];
-
- va_start (msg, s);
-#ifdef _WIN32
- _vsntprintf (buffer, FONT_MAX_LEN - 1, s, msg);
-#else /* not Windows */
- vsnprintf (buffer, FONT_MAX_LEN - 1, s, msg);
-#endif
- va_end (msg);
-
/* get current viewport */
glGetIntegerv (GL_VIEWPORT, vPort);
/* setup various opengl things that we need */
/* draw the string */
- fontWalkString (font,buffer, xpos, ypos, vPort,(float)width);
+ fontWalkString (font,s, xpos, ypos, vPort,(float)width);
/* glMatrixMode (GL_PROJECTION);
glPopMatrix ();
}
/*
=============
-fontSetColorFromToken
-
-Grabs a color token from a buffer and sets color.
-=============
-*/
-int fontSetColorFromToken (texFont_t* font,char *s)
-{
- int clr[4];
- int ret = 1;
-
- if (*s == 'c')
- {
- s += 1;
- if (sscanf (s, "(%d %d %d)", &clr[0], &clr[1], &clr[2]) != 3)
- return -1;
- fontColor (font,clr[0] * FONT_ITOF, clr[1] * FONT_ITOF, clr[2] * FONT_ITOF);
- } else if (*s == 'a')
- {
- s += 1;
- if (sscanf (s, "(%d %d %d %d)", &clr[0], &clr[1], &clr[2], &clr[3]) != 4)
- return -1;
- fontColorA (font,clr[0] * FONT_ITOF, clr[1] * FONT_ITOF, clr[2] * FONT_ITOF, clr[3] * FONT_ITOF);
- }
-
- while (*s != ')' && ret ++)
- s += 1;
-
- return ret + 1;
-}
-/*
-=============
-fontItalicsMode
-
-Either turns on or off italics.
-=============
-*/
-int fontItalicsMode (texFont_t* font,char *s)
-{
- s += 1;
-
- if (*s == '+')
- font->italic = FONT_ITALIC;
- else if (*s == '-')
- font->italic = 0;
- else return -1;
-
- return 2;
-}
-/*
-=============
-fontBoldMode
-
-Either turns on or off bold.
-=============
-*/
-int fontBoldMode (texFont_t* font,char *s)
-{
- s += 1;
-
- if (*s == '+')
- font->bold = 1;
- else if (*s == '-')
- font->bold = 0;
- else return -1;
-
- return 2;
-}
-/*
-=============
fontGetCharHits
Returns number of times a character is found in a buffer.
Makes the font map which allows the correct characters to be drawn.
=============
*/
-void fontMakeMap (texFont_t* font)
+void fontMakeMap (glCompText* font)
{
#define VCOPY(d,x,y) {d[0] = x; d[1] = y;}
int i = 0;
float x, y;
- font->tIncX = (float)pow (font->blockCol, -1);
- font->tIncY = (float)pow (font->blockRow, -1);
+ font->tIncX = (float)pow (C_DPI, -1);
+ font->tIncY = (float)pow (R_DPI, -1);
for (y = 1 - font->tIncY; y >= 0; y -= font->tIncY)
}
return -1;
}
-/*
- load font via font description
- returns the id,
- if font already exists no malloc just returns the id
-*/
-texFont_t* font_init()
+
+glCompText* font_init()
{
- texFont_t* font = NEW(texFont_t);
-
- font->fgColor[0]=1.0;font->fgColor[1]=1.0;font->fgColor[2]=1.0;font->fgColor[3]=1.0;
- font->gdColor[0]=0.5;font->gdColor[1]=0.5;font->gdColor[2]=0.5;font->gdColor[3]=1.0;
- font->bgColor[0]=0.5;font->bgColor[1]=0.5;font->bgColor[2]=0.5;font->bgColor[3]=1.0;
- font->size=12;
- font->shadow=0;
- font->gradient=0;
- font->italic=0;
- font->bold=0;
- font->region=0;
- font->regionX=0;
- font->regionY=0;
- font->regionW=0;
- font->regionH=0;
+ glCompText* font = NEW(glCompText);
+
+ font->color.R=1.00;
+ font->color.G=1.00;
+ font->color.B=1.00;
+ font->color.A=1.00;
+
+
+ font->fontheight=12;
font->tIncX=0.0;
font->tIncY=0.0;
- font->blockRow=FONT_BLOCK_ROW;
- font->blockCol=FONT_BLOCK_COL;
font->texId=-1;
font->fontdesc=(char*)0;
return font;
}
-void copy_font(texFont_t* targetfont,const texFont_t* sourcefont)
+void copy_font(glCompText* targetfont,const glCompText* 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->color.R=sourcefont->color.R;
+ targetfont->color.G=sourcefont->color.G;
+ targetfont->color.B=sourcefont->color.B;
+ targetfont->color.A=sourcefont->color.A;
+
+
+
+ targetfont->fontheight=sourcefont->fontheight;
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);
{
int id;
size_t sz;
- texFont_t* tf;
+ glCompText* tf;
id=fontId(fontset,fontdesc);
}
sprintf(fontpath,"%s/%s.png",fontset->font_directory,fontdesc);
if(create_font_file(fontdesc,fontpath,(float)32,(float)32)==0) {
- fontset->fonts = ALLOC(fontset->count+1,fontset->fonts,texFont_t*);
+ fontset->fonts = ALLOC(fontset->count+1,fontset->fonts,glCompText*);
fontset->fonts[fontset->count] = tf = font_init ();
tf->fontdesc = strdup(fontdesc);
glGenTextures (1, &(tf->texId)); //get opengl texture name
- if ((tf->texId >= 0) && fontLoadPNG (fontpath, tf->texId)) {
+ if ((tf->texId >= 0) && glCompLoadFontPNG (fontpath, tf->texId)) {
fontset->activefont=fontset->count;
fontset->count++;
return fontset->count;
free(fontset);
}
+void fontColor (glCompText* font,float r, float g, float b,float a)
+{
+
+
+ font->color.R=r;
+ font->color.G=g;
+ font->color.B=b;
+ font->color.A=a;
+}
-/*
- Copyright (c) 1999 Nate Miller
-
- Notice: Usage of any code in this file is subject to the rules
- described in the LICENSE.TXT file included in this directory.
- Reading, compiling, or otherwise using this code constitutes
- automatic acceptance of the rules in said text file.
-
- File -- glTexFont.h
- Date -- 5/30/99
- Author -- Nate 'm|d' Miller
- Contact -- vandals1@home.com
- Web -- http://members.home.com/vandals1
-*/
-#ifndef __GLTEXFONTH__
-#define __GLTEXFONTH__
+#ifndef GLCOMPTEXT_H
+#define GLTEXFONTH_H
#include <stdlib.h>
#include <string.h>
#endif
#include "glcompdefs.h"
-/* Error Codes */
-#define FONT_FILE_NOT_FOUND -13 /* file was not found */
-#define FONT_BAD_IMAGE_TYPE -14 /* color mapped image or image is not uncompressed */
-#define FONT_BAD_DIMENSION -15 /* dimension is not a power of 2 */
-#define FONT_BAD_BITS -16 /* image bits is not 8, 24 or 32 */
-#define FONT_BAD_DATA -17 /* image data could not be loaded */
-#define GL_TEX_FONT_VERSION 6
#ifndef vec2_t
typedef float vec2_t[2];
#ifdef __cplusplus
extern "C" {
#endif
-/*
- check if font is already loaded
- if loaded returns the id
- else returns -1
-*/
-/* int fontId(fontset_t* fontset,char* fontdesc); */
-
-/*
- Initialize fontset as an empty set
-*/
-
extern fontset_t* fontset_init(void);
-
void free_font_set(fontset_t* fontset);
-void copy_font(texFont_t* targetfont,const texFont_t* sourcefont);
-/*
- load font via font description
- returns the id,
- if font already exists no malloc just returns the id
-*/
+void copy_font(glCompText* targetfont,const glCompText* sourcefont);
int add_font(fontset_t* fontset,char* fontdesc);
-
-/*
-=============
-fontLoad
-
-Loads up out font from the passed image file name.
-=============
-*/
-int fontLoad (texFont_t* font,char *name);
-/*
-=============
-fontLoadEx
-
-Same as above but it loads a custom font map with row chars per row and col
-chars per column.
-=============
-*/
-int fontLoadEx (texFont_t* font,char *name, int row, int col);
-/*
-=============
-fontDrawString
-
-Draws a string at (xpos, ypos) in the applications window.
-=============
-*/
-void fontDrawString (texFont_t*, GLfloat , GLfloat , GLfloat, char*, ...);
-/*
-=============
-fontRegion
-
-Sets up a font region. Upper left corner is described by (xpos, ypos).
-The region is w units wide and h units tall.
-=============
-*/
-void fontRegion (texFont_t* font,float xpos, float ypos, float w, float h);
-/*
-=============
-fontSize
-
-Sets the font size.
-=============
-*/
-void fontSize (texFont_t* font,GLfloat size);
-
-
-void fontzdepth(texFont_t* font,float zdepth);
-
-/*
-=============
-fontShadow
-
-Draws shadowed text.
-=============
-*/
-void fontShadow (texFont_t* font);
-/*
-=============
-fontGradient
-
-Draws gradient text.
-=============
-*/
-void fontGradient (texFont_t* font);
-/*
-=============
-fontColor*, fontShadowColor*, fonrGradientColor*
-
-
-Sets color for various operations.
-=============
-*/
-
-texFont_t* font_init(void);
-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);
-void fontColorAp (texFont_t* font,float *clr);
-void fontShadowColor (texFont_t* font,float r, float g, float b);
-void fontShadowColorA (texFont_t* font,float r, float g, float b, float a);
-void fontShadowColorp (texFont_t* font,float *clr);
-void fontShadowColorAp (texFont_t* font,float *clr);
-void fontGradientColor (texFont_t* font,float r, float g, float b);
-void fontGradientColorA (texFont_t* font,float r, float g, float b, float a);
-void fontGradientColorp (texFont_t* font,float *clr);
-void fontGradientColorAp (texFont_t* font,float *clr);
+int glCompLoadFont (glCompText* font,char *name);
+void fontDrawString (glCompText*, GLfloat , GLfloat , GLfloat, char*);
+void fontSize (glCompText* font,GLfloat size);
+void fontzdepth(glCompText* font,float zdepth);
+glCompText* font_init(void);
+void fontColor (glCompText* font,float r, float g, float b,float a);
+
+void fontDrawChar (glCompText*,char, GLfloat, GLfloat, GLfloat);
+void fontScissorNormal (glCompText* font,int xpos, int ypos, int tabs, int carrage, int size, int len);
+int fontSetColorFromToken (glCompText* font,char *s);
+int fontGetCharHits (char *s, char f);
+void fontMakeMap (glCompText* font);
+void fontSetModes (int state);
+void fontReset (glCompText* font);
+int fontItalicsMode (glCompText* font,char *s);
+int fontBoldMode (glCompText* font,char *s);
+void fontRenderChar (glCompText* font,char c, GLfloat x, GLfloat y, GLfloat size);
#ifdef __cplusplus
}
#endif
RelativePath=".\glTexFont.h"
>
</File>
- <File
- RelativePath=".\glTexFontDefs.h"
- >
- </File>
- <File
- RelativePath=".\glTexFontInclude.h"
- >
- </File>
- <File
- RelativePath=".\glTexFontTGA.h"
- >
- </File>
<File
RelativePath=".\glutils.h"
>
RelativePath=".\glcompset.c"
>
</File>
+ <File
+ RelativePath=".\glcomptextpng.c"
+ >
+ </File>
<File
RelativePath=".\glcomptexture.c"
>
RelativePath=".\glTexFont.c"
>
</File>
- <File
- RelativePath=".\glTexFontColor.c"
- >
- </File>
- <File
- RelativePath=".\glTexFontTGA.c"
- >
- </File>
<File
RelativePath=".\glutils.c"
>
p->fontsize) / (GLfloat) 2.0 + p->pos.y + p->thickness;
fontSize(p->font,p->fontsize);
// fontColorA (p->fontcolor.R,p->fontcolor.B,p->fontcolor.G,p->fontcolor.A);
- fontColorA(p->font,0, 0, 0, 1);
+ fontColor(p->font,0, 0, 0, 1);
fontDrawString(p->font,(GLfloat) fontx, (GLfloat) fonty,
(p->fontsize *(GLfloat) strlen(p->caption) *
GLCOMPSET_FONT_SIZE_FACTOR), p->caption);
#ifndef GLCOMPDEFS_H
#define GLCOMPDEFS_H
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <math.h>
#ifdef _WIN32
-#include "windows.h"
+#include <windows.h>
+#include <winuser.h>
+#include <tchar.h>
#endif
+#include <GL/gl.h>
#include <stdlib.h>
#include <stdio.h>
#include <GL/gl.h>
#define GLCOMPSET_BEVEL_DIFF (GLfloat)0.001
#define GLCOMPSET_DEFAULT_PAD (GLfloat)3
+#define FONT_GET_MODES 1
+#define FONT_RESTORE_MODES 2
+#define FONT_MAX_LEN 1024 /* maximum chars to draw to the screen, used for buffers also */
+#define FONT_TAB_SPACE 4 /* spaces to draw for a tab, make option? */
+#define FONT_ITOF (float) pow (255, -1)
+#define FONT_ITALIC 8 /* italic amount in pixels */
+#define fontColorCopy(a,b) {b[0]= a[0]; b[1]= a[1]; b[2]= a[2]; b[3]= a[3];} /* copys colors */
+
+#define C_DPI 16
+#define R_DPI 16
+
+
typedef void (*callbackfunc_t) (void *component);
typedef enum { inverted_y,scientific_y} glCompOrientation;
} glCompTexture;
typedef struct
{
- float fgColor[4]; /* foreground color, default white */
- float gdColor[4]; /* gradient color, default gray */
- float bgColor[4]; /* background color, default gray */
- float size; /* size of text, default 12 */
- int shadow; /* shadow text? default 0 */
- int gradient; /* gradient? default 0 */
- int italic; /* italic amount, defaul 0 */
- int bold; /* bold text? */
- int region; /* do we have a text region */
- float regionX; /* lower left x */
- float regionY; /* lower left y */
- float regionW; /* text region w */
- float regionH; /* text region h */
+ char* fontdesc; //font description
+ glCompColor color;
+ float fontheight; /* size of text, default 12 */
float tIncX; /* used for texture coords, x axis amount to move */
float tIncY; /* used for texture coords, y axis amount to move */
int blockRow; /* characters per row */
int blockCol; /* characters per col */
- unsigned int texId; /* texture id */
+ int texId; /* texture id */
float zdepth; //third dimension , depth of fonts
- char* fontdesc; //font description
-} texFont_t;
+} glCompText;
typedef struct
{
- texFont_t** fonts;
+ glCompText** fonts;
int count;
int activefont;
char* font_directory; //location where the glfont files are stored
int visible;
void *parentset; //parent compset
int data;
- texFont_t* font; //pointer to font to use
+ glCompText* font; //pointer to font to use
glCompOrientation orientation;
} glCompPanel;
int visible;
void *parentset; //parent compset
int data;
- texFont_t* font; //pointer to font to use
+ glCompText* font; //pointer to font to use
glCompOrientation orientation;
}glCompTrackBar;
char *text;
GLfloat fontsizefactor;
glCompPanel *panel; //container panel
- texFont_t* font; //pointer to font to use
+ glCompText* font; //pointer to font to use
glCompOrientation orientation;
} 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
+ glCompText* font; //pointer to font to use
glCompOrientation orientation;
} 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
+ glCompText* font; //pointer to font to use
} glCompSet;
#endif
}
fontSize(p->font, p->size);
- fontColorA(p->font,p->color.R, p->color.G, p->color.B, p->color.A);
+ fontColor(p->font,p->color.R, p->color.G, p->color.B, p->color.A);
fontDrawString(p->font, p->pos.x, p->pos.y,
(p->size * p->fontsizefactor *
#define GLCOMPSET_H
#include "glTexFont.h"
-#include "glTexFontTGA.h"
-#include "glTexFontDefs.h"
-#include "glTexFontInclude.h"
+#include "glcomptextpng.h"
#include "glcomptexture.h"
static const int BYTES_PER_PIXEL = 4; /* bytes per pixel */
+#define ADD_ATTR(a) \
+ if (a) { \
+ strcat(buf, comma ? " " : ", "); \
+ comma = 1; \
+ strcat(buf, a); \
+ }
+
extern void SaveBitmapToStream(Gdiplus::Bitmap &bitmap, IStream *stream, int format);
#endif
using namespace std;
using namespace Gdiplus;
+
+
+static char* gdiplus_psfontResolve (PostscriptAlias* pa)
+{
+ static char buf[1024];
+ int comma=0;
+ strcpy(buf, pa->family);
+
+ ADD_ATTR(pa->weight);
+ ADD_ATTR(pa->stretch);
+ ADD_ATTR(pa->style);
+
+ return buf;
+}
+
+
/* Graphics for internal use, so that we can record image etc. for subsequent retrieval off the job struct */
struct ImageGraphics: public Graphics
{
return auto_ptr<Font>(new Font(reference.hdc, &found_font));
}
else
- return auto_ptr<Font>(new Font(FontFamily::GenericSerif(), fontsize));
+ {
+ strncpy(font_to_find.lfFaceName,"Times New Roman", sizeof(font_to_find.lfFaceName) - 1);
+ font_to_find.lfFaceName[sizeof(font_to_find.lfFaceName) - 1] = '\0';
+ font_to_find.lfPitchAndFamily = 0;
+ if(EnumFontFamiliesExA(reference.hdc,
+ &font_to_find,
+ fetch_first_font,
+ (LPARAM)&found_font,
+ 0) == 0)
+ {
+ found_font.lfHeight = (LONG)-fontsize;
+ found_font.lfWidth = 0;
+ return auto_ptr<Font>(new Font(reference.hdc, &found_font));
+ }
+
+ }
+// "gdiplus cannot find the default font Times New Roman."
+ return NULL;
}
static void gdiplusgen_textpara(GVJ_t *job, pointf p, textpara_t *para)
{
/* convert incoming UTF8 string to wide chars */
/* NOTE: conversion is 1 or more UTF8 chars to 1 wide char */
+ char* fontname;
int wide_count = MultiByteToWideChar(CP_UTF8, 0, para->str, -1, NULL, 0);
if (wide_count > 1) {
vector<WCHAR> wide_str(wide_count);
Gdiplus::Font* a=find_font(para->fontname, para->fontsize).get();
/* draw the text */
SolidBrush brush(Color(job->obj->pencolor.u.rgba [3], job->obj->pencolor.u.rgba [0], job->obj->pencolor.u.rgba [1], job->obj->pencolor.u.rgba [2]));
- context->DrawString(&wide_str.front(), wide_count - 1, find_font(para->fontname, para->fontsize).get(), PointF(0, -center), &brush);
+
+
+#ifdef HAVE_GD_FONTCONFIG
+ if (para->postscript_alias)
+ fontname = para->postscript_alias->family;
+ else
+#endif
+ fontname = para->fontname;
+ context->DrawString(&wide_str.front(), wide_count - 1, find_font(fontname, para->fontsize).get(), PointF(0, -center), &brush);
context->Restore(saved);
}
}