]> granicus.if.org Git - graphviz/commitdiff
Add smyrna to main graphviz tree
authorellson <devnull@localhost>
Wed, 23 Jan 2008 20:52:43 +0000 (20:52 +0000)
committerellson <devnull@localhost>
Wed, 23 Jan 2008 20:52:43 +0000 (20:52 +0000)
lib/utilities/glTexFontColor.c [new file with mode: 0755]
lib/utilities/glTexFontDefs.h [new file with mode: 0755]
lib/utilities/glTexFontInclude.h [new file with mode: 0755]
lib/utilities/glTexFontTGA.c [new file with mode: 0755]
lib/utilities/glTexFontTGA.h [new file with mode: 0755]

diff --git a/lib/utilities/glTexFontColor.c b/lib/utilities/glTexFontColor.c
new file mode 100755 (executable)
index 0000000..45dfed3
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+    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        -- glTexFontColor.c
+    Date        -- 6/10/99
+    Author      -- Nate 'm|d' Miller
+    Contact     -- vandals1@home.com
+    Web         -- http://members.home.com/vandals1
+*/
+#include "glTexFont.h"
+
+/* color functions must be defined in texFont.h */
+
+extern texFont_t font;
+
+/*
+=============
+fontColor, fontColorA, fontColorp, fontColorAp
+   
+Sets the currect color for the text. 
+=============
+*/
+void fontColor (float r, float g, float b)
+{
+    font.fgColor[0] = r;
+    font.fgColor[1] = g;
+    font.fgColor[2] = b;
+    font.fgColor[3] = 1.0;
+}
+void fontColorA (float r, float g, float b, float a)
+{
+    font.fgColor[0] = r;
+    font.fgColor[1] = g;
+    font.fgColor[2] = b;
+    font.fgColor[3] = a;
+}
+void fontColorp (float *clr)
+{
+    font.fgColor[0] = clr[0];
+    font.fgColor[1] = clr[1];
+    font.fgColor[2] = clr[2];
+    font.fgColor[3] = 1.0;
+}
+void fontColorAp (float *clr)
+{
+    font.fgColor[0] = clr[0];
+    font.fgColor[1] = clr[1];
+    font.fgColor[2] = clr[2];
+    font.fgColor[3] = clr[3];
+}
+/*
+=============
+fontShadow, fontShadowA, fontShadowp, fontShadowAp
+   
+Sets the currect shadow color for the text. 
+=============
+*/
+void fontShadowColor (float r, float g, float b)
+{
+    font.bgColor[0] = r;
+    font.bgColor[1] = g;
+    font.bgColor[2] = b;
+    font.bgColor[3] = 1.0;
+}
+void fontShadowColorA (float r, float g, float b, float a)
+{
+    font.bgColor[0] = r;
+    font.bgColor[1] = g;
+    font.bgColor[2] = b;
+    font.bgColor[3] = a;
+}
+void fontShadowColorp (float *clr)
+{
+    font.bgColor[0] = clr[0];
+    font.bgColor[1] = clr[1];
+    font.bgColor[2] = clr[2];
+    font.bgColor[3] = 1.0;
+}
+void fontShadowColorAp (float *clr)
+{
+    font.bgColor[0] = clr[0];
+    font.bgColor[1] = clr[1];
+    font.bgColor[2] = clr[2];
+    font.bgColor[3] = clr[3];
+}
+/*
+=============
+fontGradientColor, fontGradientColorA, fontGradientColorp, fontGradientColorAp
+   
+Sets the currect gradient color for the text. 
+=============
+*/
+void fontGradientColor (float r, float g, float b)
+{
+    font.gdColor[0] = r;
+    font.gdColor[1] = g;
+    font.gdColor[2] = b;
+    font.gdColor[3] = 1.0;
+}
+void fontGradientColorA (float r, float g, float b, float a)
+{
+    font.gdColor[0] = r;
+    font.gdColor[1] = g;
+    font.gdColor[2] = b;
+    font.gdColor[3] = a;
+}
+void fontGradientColorp (float *clr)
+{
+    font.gdColor[0] = clr[0];
+    font.gdColor[1] = clr[1];
+    font.gdColor[2] = clr[2];
+    font.gdColor[3] = 1.0;
+}
+void fontGradientColorAp (float *clr)
+{
+    font.gdColor[0] = clr[0];
+    font.gdColor[1] = clr[1];
+    font.gdColor[2] = clr[2];
+    font.gdColor[3] = clr[3];
+}
diff --git a/lib/utilities/glTexFontDefs.h b/lib/utilities/glTexFontDefs.h
new file mode 100755 (executable)
index 0000000..6ba58d9
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+    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        -- glTexFontDefs.h
+    Date        -- 5/31/99
+    Author      -- Nate 'm|d' Miller
+    Contact     -- vandals1@home.com
+    Web         -- http://members.home.com/vandals1
+
+    All functions are called internally by the library, These should never be 
+    called from anywhere but INSIDE the library.  Versy messy but doesn't
+    matter all that much.
+*/
+/*
+    FONT_BLOCK_COL, FONT_BLOCK_ROW
+       
+    Number of characters per row and per col in the font map.  
+    FONT_BLOCK_COL * FONT_BLOCK_ROW must equal 256.  If it doesn't the library 
+    will fail to work properly.  Why 256?  Chars range from 0 to 255.  
+*/
+#define FONT_BLOCK_COL              16
+#define FONT_BLOCK_ROW              16
+#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 */
+
+/* various functions used by the library, see texFont.c for info */
+void fontDrawChar (char c, int x, int y, int size, int shadow);
+void fontScissorNormal (int xpos, int ypos, int tabs, int carrage, int size, int len);
+int fontSetColorFromToken (char *s);
+int fontGetCharHits (char *s, char f);
+void fontMakeMap (void);
+void fontSetModes (int state);
+void fontReset (void);
+void fontScissorTextRegion (void);
+int fontItalicsMode (char *s);
+int fontBoldMode (char *s);
+void fontRenderChar (char c, int x, int y, int size);
diff --git a/lib/utilities/glTexFontInclude.h b/lib/utilities/glTexFontInclude.h
new file mode 100755 (executable)
index 0000000..94fbfcf
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+    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        -- glTexFontInclude.h
+    Date        -- 6/12/99
+    Author      -- Nate 'm|d' Miller
+    Contact     -- vandals1@home.com
+    Web         -- http://members.home.com/vandals1
+*/
+/* just generic headers to include, nothing fancy */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <math.h>
+#ifdef _WIN32
+#include <windows.h>
+#include <winuser.h>
+#include <tchar.h>
+#endif
+#include <GL/gl.h>
diff --git a/lib/utilities/glTexFontTGA.c b/lib/utilities/glTexFontTGA.c
new file mode 100755 (executable)
index 0000000..e014e40
--- /dev/null
@@ -0,0 +1,236 @@
+/*
+    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        -- glTexFontTGA.c
+    Date        -- 5/30/99
+    Author      -- Nate 'm|d' Miller
+    Contact     -- vandals1@home.com
+    Web         -- http://members.home.com/vandals1
+
+    Change Log
+    **********
+    6/11/99 - added support for 8bit images, changed commenting
+    5/30/99 - original file
+*/
+#include "glTexFont.h"
+#include "glTexFontTGA.h"
+#include "glTexFontInclude.h"
+
+GLenum texFormat;
+
+/*
+=============
+fontCheckSize
+
+Make sure its a power of 2.
+=============
+*/
+int fontCheckSize (int x)
+{
+       if (x == 2       || x == 4 || 
+               x == 8   || x == 16 || 
+               x == 32  || x == 64 ||
+               x == 128 || x == 256 || x == 512)
+               return 1;
+       else return 0;
+}
+/*
+=============
+fontGetRGBA
+
+Reads in RGBA data for a 32bit image. 
+=============
+*/
+unsigned char *fontGetRGBA (FILE *s, int size)
+{
+       unsigned char *rgba;
+       unsigned char temp;
+       int bread;
+       int i;
+
+       rgba = malloc (size * 4); 
+
+       if (rgba == NULL)
+               return 0;
+
+       bread = fread (rgba, sizeof (unsigned char), size * 4, s); 
+       
+    /* TGA is stored in BGRA, make it RGBA */
+       if (bread != size * 4)
+       {
+               free (rgba);
+               return 0;
+       }
+
+       for (i = 0; i < size * 4; i += 4 )
+       {
+               temp = rgba[i];
+               rgba[i] = rgba[i + 2];
+               rgba[i + 2] = temp;
+       }
+
+       texFormat = GL_RGBA;
+       return rgba;
+}
+/*
+=============
+fontGetRGB
+
+Reads in RGB data for a 24bit image. 
+=============
+*/
+unsigned char *fontGetRGB (FILE *s, int size)
+{
+       unsigned char *rgb;
+       unsigned char temp;
+       int bread;
+       int i;
+
+       rgb = malloc (size * 3); 
+       
+       if (rgb == NULL)
+               return 0;
+
+       bread = fread (rgb, sizeof (unsigned char), size * 3, s);
+
+       if (bread != size * 3)
+       {
+               free (rgb);
+               return 0;
+       }
+
+    /* TGA is stored in BGR, make it RGB */
+       for (i = 0; i < size * 3; i += 3)
+       {
+               temp = rgb[i];
+               rgb[i] = rgb[i + 2];
+               rgb[i + 2] = temp;
+       }
+       
+       texFormat = GL_RGB;
+
+       return rgb;
+}
+/*
+=============
+fontGetGray
+
+Reads a gray scale image. 
+=============
+*/
+unsigned char *fontGetGray (FILE *s, int size)
+{
+       unsigned char *grayData;
+       int bread;
+
+       grayData = malloc (size);
+
+       if (grayData == NULL)
+               return 0;
+
+       bread = fread (grayData, sizeof (unsigned char), size, s);
+
+       if (bread != size)
+       {
+               free (grayData);
+               return 0;
+       }
+       
+       texFormat = GL_ALPHA;
+
+       return grayData;
+}
+/*
+=============
+fontGetData
+
+Gets the image data for the specified bit depth.
+=============
+*/
+unsigned char *fontGetData (FILE *s, int sz, int iBits)
+{
+       if (iBits == 32)
+               return fontGetRGBA (s, sz);
+       else if (iBits == 24)
+               return fontGetRGB (s, sz);      
+    else if (iBits == 8)
+        return fontGetGray (s, sz);
+    else
+        return 0;
+}
+/*
+=============
+fontLoadTGA
+
+Loads up a targa file.  Supported types are 8,24 and 32 uncompressed images.  
+=============
+*/
+int fontLoadTGA (char *name, int id)
+{
+       unsigned char type[4];
+       unsigned char info[7];
+       unsigned char *imageData = NULL;
+       int imageWidth, imageHeight;
+       int imageBits, size;
+       FILE *s;
+       
+#ifdef _WIN32
+       if (!(s = fopen (name, "r+bt")))
+#else
+// FIXME - the file exists but I still error on this fopen() call
+fprintf(stderr,"font: %s\n", name);
+       if (!(s = fopen (name, "rb")))
+#endif
+               return FONT_FILE_NOT_FOUND;
+
+       fread (&type, sizeof (char), 3, s); // read in colormap info and image type, byte 0 ignored
+       fseek (s, 12, SEEK_SET);                        // seek past the header and useless info
+       fread (&info, sizeof (char), 6, s);
+
+       if (type[1] != 0 || (type[2] != 2 && type[2] != 3))
+               return FONT_BAD_IMAGE_TYPE;
+    
+    imageWidth = info[0] + info[1] * 256; 
+       imageHeight = info[2] + info[3] * 256;
+       imageBits =     info[4]; 
+
+       size = imageWidth * imageHeight; 
+
+       /* make sure dimension is a power of 2 */
+       if (!fontCheckSize (imageWidth) || !fontCheckSize (imageHeight))
+               return FONT_BAD_DIMENSION;
+
+       /* make sure we are loading a supported type */
+       if (imageBits != 32 && imageBits != 24 && imageBits != 8)
+               return FONT_BAD_BITS;
+
+       imageData = fontGetData (s, size, imageBits);
+       
+       fclose (s);
+
+       /* no image data */
+       if (imageData == NULL)
+               return FONT_BAD_DATA;
+
+       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);
+       glTexImage2D (GL_TEXTURE_2D, 0, texFormat, imageWidth, imageHeight, 0, texFormat, GL_UNSIGNED_BYTE, imageData);
+
+       /* release data, its been uploaded */
+       free (imageData);
+
+       return 1;
+}
+
diff --git a/lib/utilities/glTexFontTGA.h b/lib/utilities/glTexFontTGA.h
new file mode 100755 (executable)
index 0000000..4797164
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+    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        -- glTexFontTGA.c
+    Date        -- 5/30/99
+    Author      -- Nate 'm|d' Miller
+    Contact     -- vandals1@home.com
+    Web         -- http://members.home.com/vandals1
+*/
+int fontLoadTGA (char *name, int id); /* id is the texture id to bind too */
+