/* Auxiliary functions for making simple OpenGL programs */ /* Kevin Perry ICGL Sep 1995 */ #ifndef __PGL_H__ #define __PGL_H__ /*********************************************** * HERE IS AN EXAMPLE USAGE OF THIS MODULE: * (opens a 400x400 pixel window, and paints it black) * * #include * * String config[] = { "*geometry: =400x400", NULL }; * * static void draw_me(int winid, pglCallbackInfo info) * { * glClearIndex(0); * glClear(GL_COLOR_BUFFER_BIT); * } * * main(int argc, char** argv) * { * pglInitialize("Sample", config, PGL_INDEX); * pglOpenWindow(argv[0], draw_me); * pglMainLoop(); * } * ************************************************/ #include #include #include #ifdef __cplusplus extern "C" { #endif /* callback reasons: GraphicsInitialization, WindowExposure (redraw), * WindowResize, and InputEventReceived */ #define PGL_GINIT GLwCR_GINIT #define PGL_EXPOSE GLwCR_EXPOSE #define PGL_RESIZE GLwCR_RESIZE #define PGL_INPUT GLwCR_INPUT #define PGL_TIMEOUT 42 #define PGL_IDLE 43 /* idle-callbacks are not called if you use pglHandleEvents() */ /* typedefs for callback routines */ typedef struct _pglCallbackInfo { /* (looks like a GLwDrawingAreaCallbackStruct) */ int reason; XEvent* event; Dimension width; Dimension height; } *pglCallbackInfo; typedef void pglCallback(int winid, pglCallbackInfo info); /* flags for pglOpenWindow() */ #define PGL_DOUBLE 0x01 #define PGL_RGBA 0x02 /* flags meaning "not"-something-from-above... */ #define PGL_SINGLE 0x00 #define PGL_INDEX 0x00 /**********************************/ /* EXTERNAL FUNCTION DECLARATIONS */ /**********************************/ /* window creation */ Widget pglInitialize(char* appClassName, char** resources); int pglOpenWindow(char* title, pglCallback initFunc, int flags); int pglOpenSubwindow(Widget parent, char* name, pglCallback initRoutine, int flags); /* program control routines */ void pglMainLoop(void); void pglHandleEvents(void); /* misc. window operations */ void pglSetCallback(int winid, int reason, pglCallback func); void pglSetCurrentWindow(int winid); void pglSwapBuffers(int winid); void pglSetColors(int winid, int num, float*rgb); void pglSetTimeout(int winid, float seconds); /* menu operations */ void pglMakeMenu(int winid, char* title); void pglAddMenuItem(int winid, char* item, int value, void (*cb)(Widget, XtPointer, XtPointer)); /* window activation */ void pglManageWindows(void); void pglManageWindow(int winid); void pglUnmanageWindow(int winid); /* "get" functions for X and GL objects (usually unneeded) */ XtAppContext pglGetAppContext(void); Widget pglGetAppWidget(void); GLXContext pglGetGLContext(int winid); Widget pglGetGLWidget(int winid); Widget pglGetShell(int winid); /* text string handling utility funcitons */ GLuint pglMakeFont(char*); void pglDrawString(char*, GLuint); #ifdef __cplusplus } #endif #endif