+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+* This software is part of the graphviz package *
+* http://www.graphviz.org/ *
+* *
+* Copyright (c) 1994-2007 AT&T Corp. *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Corp. *
+* *
+* Information and Software Systems Research *
+* AT&T Research, Florham Park NJ *
+**********************************************************/
+
/*Open GL basic component set
includes glPanel,glCompButton,glCompCustomButton,clCompLabel,glCompStyle
*/
#define GLCOMPSET_PANEL_BEVEL (GLfloat)0.1
#define GLCOMPSET_BEVEL_DIFF (GLfloat)0.001
-typedef void (*callbackfunc_t)(void* component);
-
-typedef struct _glCompPoint
-{
- GLfloat x,y;
-}glCompPoint;
-typedef struct{
- GLfloat R;
- GLfloat G;
- GLfloat B;
- GLfloat A; //Alpha
+typedef void (*callbackfunc_t) (void *component);
+
+typedef struct _glCompPoint {
+ GLfloat x, y;
+} glCompPoint;
+typedef struct {
+ GLfloat R;
+ GLfloat G;
+ GLfloat B;
+ GLfloat A; //Alpha
} glCompColor;
-typedef struct _glCompPanel
-{
- glCompPoint pos;
- GLfloat width,height;
- GLfloat shadowwidth;
- GLfloat bevel;
- glCompColor color;
- glCompColor shadowcolor;
- int enabled;
- int visible;
- void* parentset; //parent compset
- int data;
-
-
-}glCompPanel;
-typedef struct _glCompLabel
-{
- glCompPoint pos;
- GLfloat size;
- GLfloat bevel;
- glCompColor color;
- int visible;
- char* text;
- GLfloat fontsizefactor;
- glCompPanel* panel; //container panel
-}glCompLabel;
-
-
-typedef struct _glCompButton{
- glCompPoint pos;
- GLfloat width,height;
- GLfloat bevel;
- GLfloat thickness;
- glCompColor color;
- glCompColor fontcolor;
- char* caption;
- int enabled;
- int visible;
- int status; //0 not pressed 1 pressed;
- int groupid;
- void* parentset; //parent compset
- GLfloat fontsize;
- int hasglyph;
- glCompTexture* glyph;
- int glyphwidth,glyphheight;
- glCompPanel* panel; //container panel
- callbackfunc_t callbackfunc; //call back for button click
- void* customptr; //general purpose void pointer to pass to call back
- int data;
-}glCompButton;
-
-
-
-typedef struct
-{
- glCompPanel** panels;
- glCompButton** buttons;
- glCompLabel** labels;
-
- int panelcount;
- int buttoncount;
- int labelcount;
- int active; //0 dont draw, 1 draw
- int enabled; //0 disabled 1 enabled(allow mouse interaction)
- GLfloat clickedX,clickedY;
-}glCompSet;
-
-glCompPanel* glCompPanelNew(GLfloat x,GLfloat y,GLfloat w,GLfloat h);
-void glCompSetClear(glCompSet* s);
-int glCompSetAddPanel(glCompSet* s,glCompPanel* p);
-int glCompSetRemovePanel(glCompSet* s,glCompPanel* p);
-int glCompSetDraw(glCompSet* s);
-
-glCompButton* glCompButtonNew(GLfloat x,GLfloat y,GLfloat w,GLfloat h,char* caption,char* glyphfile,int glyphwidth,int glyphheight);
-int glCompSetAddButton(glCompSet* s,glCompButton* p);
-int glCompSetRemoveButton(glCompSet* s,glCompButton* p);
-int glCompDrawButton(glCompButton* p);
-
-
-int glCompSetDraw(glCompSet* s);
-int glCompSetHide(glCompSet* s);
-int glCompSetShow(glCompSet* s);
-void glCompDrawBegin(); //pushes a gl stack
-void glCompDrawEnd(); //pops the gl stack
-int glCompDrawPanel(glCompPanel* p);
-int glCompSetClick(glCompSet* s,int x,int y);
-int glCompSetRelease(glCompSet* s, int x, int y);
-void glCompSetGetPos(int x, int y,float* X,float* Y,float* Z);
-int glCompPointInButton(glCompButton* p,float x,float y);
-void glCompButtonClick(glCompButton* p);
-
-glCompLabel* glCompLabelNew(GLfloat x,GLfloat y,GLfloat size,char* text);
-int glCompSetAddLabel(glCompSet* s,glCompLabel* p);
-int glCompSetRemoveLabel(glCompSet* s,glCompLabel* p);
-int glCompDrawLabel(glCompLabel* p);
-int glCompLabelSetText(glCompLabel* p,char* text);
-int glCompPanelHide(glCompPanel* p);
-int glCompPanelShow(glCompPanel* p);
-int glCompSetDrawPanels(glCompSet* s);
+typedef struct _glCompPanel {
+ glCompPoint pos;
+ GLfloat width, height;
+ GLfloat shadowwidth;
+ GLfloat bevel;
+ glCompColor color;
+ glCompColor shadowcolor;
+ int enabled;
+ int visible;
+ void *parentset; //parent compset
+ int data;
+
+
+} glCompPanel;
+typedef struct _glCompLabel {
+ glCompPoint pos;
+ GLfloat size;
+ GLfloat bevel;
+ glCompColor color;
+ int visible;
+ char *text;
+ GLfloat fontsizefactor;
+ glCompPanel *panel; //container panel
+} glCompLabel;
+
+
+typedef struct _glCompButton {
+ glCompPoint pos;
+ GLfloat width, height;
+ GLfloat bevel;
+ GLfloat thickness;
+ glCompColor color;
+ glCompColor fontcolor;
+ char *caption;
+ int enabled;
+ int visible;
+ int status; //0 not pressed 1 pressed;
+ int groupid;
+ void *parentset; //parent compset
+ GLfloat fontsize;
+ int hasglyph;
+ glCompTexture *glyph;
+ int glyphwidth, glyphheight;
+ glCompPanel *panel; //container panel
+ callbackfunc_t callbackfunc; //call back for button click
+ void *customptr; //general purpose void pointer to pass to call back
+ int data;
+} glCompButton;
+
+
+
+typedef struct {
+ glCompPanel **panels;
+ glCompButton **buttons;
+ glCompLabel **labels;
+
+ int panelcount;
+ int buttoncount;
+ int labelcount;
+ int active; //0 dont draw, 1 draw
+ int enabled; //0 disabled 1 enabled(allow mouse interaction)
+ GLfloat clickedX, clickedY;
+} glCompSet;
+
+glCompPanel *glCompPanelNew(GLfloat x, GLfloat y, GLfloat w, GLfloat h);
+void glCompSetClear(glCompSet * s);
+int glCompSetAddPanel(glCompSet * s, glCompPanel * p);
+int glCompSetRemovePanel(glCompSet * s, glCompPanel * p);
+int glCompSetDraw(glCompSet * s);
+
+glCompButton *glCompButtonNew(GLfloat x, GLfloat y, GLfloat w, GLfloat h,
+ char *caption, char *glyphfile,
+ int glyphwidth, int glyphheight);
+int glCompSetAddButton(glCompSet * s, glCompButton * p);
+int glCompSetRemoveButton(glCompSet * s, glCompButton * p);
+int glCompDrawButton(glCompButton * p);
+
+
+int glCompSetDraw(glCompSet * s);
+int glCompSetHide(glCompSet * s);
+int glCompSetShow(glCompSet * s);
+void glCompDrawBegin(); //pushes a gl stack
+void glCompDrawEnd(); //pops the gl stack
+int glCompDrawPanel(glCompPanel * p);
+int glCompSetClick(glCompSet * s, int x, int y);
+int glCompSetRelease(glCompSet * s, int x, int y);
+void glCompSetGetPos(int x, int y, float *X, float *Y, float *Z);
+int glCompPointInButton(glCompButton * p, float x, float y);
+void glCompButtonClick(glCompButton * p);
+
+glCompLabel *glCompLabelNew(GLfloat x, GLfloat y, GLfloat size,
+ char *text);
+int glCompSetAddLabel(glCompSet * s, glCompLabel * p);
+int glCompSetRemoveLabel(glCompSet * s, glCompLabel * p);
+int glCompDrawLabel(glCompLabel * p);
+int glCompLabelSetText(glCompLabel * p, char *text);
+int glCompPanelHide(glCompPanel * p);
+int glCompPanelShow(glCompPanel * p);
+int glCompSetDrawPanels(glCompSet * s);
#endif
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+* This software is part of the graphviz package *
+* http://www.graphviz.org/ *
+* *
+* Copyright (c) 1994-2007 AT&T Corp. *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Corp. *
+* *
+* Information and Software Systems Research *
+* AT&T Research, Florham Park NJ *
+**********************************************************/
+
#include "glcomptexture.h"
-glCompTexture* glCompCreateTextureFromRaw(char* filename,int width,int height,int wrap)
+glCompTexture *glCompCreateTextureFromRaw(char *filename, int width,
+ int height, int wrap)
{
- glCompTexture* t;
+ glCompTexture *t;
#ifdef _WIN32
- BYTE * data;
+ BYTE *data;
#else
- unsigned char *data;
+ unsigned char *data;
#endif
- FILE * file;
- t=malloc(sizeof(glCompTexture));
- glGenTextures( 1, &t->id );
+ FILE *file;
+ t = malloc(sizeof(glCompTexture));
+ glGenTextures(1, &t->id);
- // allocate buffer
- data = malloc( width * height * 3 );
- // open and read texture data
- file = fopen( filename, "rb" );
- fread( data, width * height * 3, 1, file );
- fclose( file );
+ // allocate buffer
+ data = malloc(width * height * 3);
+ // open and read texture data
+ file = fopen(filename, "rb");
+ fread(data, width * height * 3, 1, file);
+ fclose(file);
// select our current texture
- glBindTexture( GL_TEXTURE_2D, t->id);
+ glBindTexture(GL_TEXTURE_2D, t->id);
// select modulate to mix texture with color for shading
- glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// when texture area is small, bilinear filter the closest mipmap
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
- GL_LINEAR_MIPMAP_NEAREST );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR_MIPMAP_NEAREST);
// when texture area is large, bilinear filter the first mipmap
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// if wrap is true, the texture wraps over at the edges (repeat)
// ... false, the texture ends at the edges (clamp)
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
- (GLfloat)wrap ? (GLfloat)GL_REPEAT : GL_CLAMP );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
- (GLfloat)wrap ? (GLfloat)GL_REPEAT : GL_CLAMP );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
+ (GLfloat) wrap ? (GLfloat) GL_REPEAT : GL_CLAMP);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
+ (GLfloat) wrap ? (GLfloat) GL_REPEAT : GL_CLAMP);
/* glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_REPEAT );
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
// build our texture mipmaps
glTexImage2D(GL_TEXTURE_2D, 0, 4, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE,data);*/
- gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, width, height,
- GL_RGB, GL_UNSIGNED_BYTE, data );
+ gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, width, height,
+ GL_RGB, GL_UNSIGNED_BYTE, data);
// free buffer
- free( data );
- t->w=(float)width;
- t->h=(float)height;
- return t;
+ free(data);
+ t->w = (float) width;
+ t->h = (float) height;
+ return t;
}
-int glCompDeleteTexture(glCompTexture* t)
+
+int glCompDeleteTexture(glCompTexture * t)
{
- return 0;
+ return 0;
}