📄 glwin.h
字号:
/*% $Id: glwin.h,v 2.33 2000/05/09 14:24:21 schmelze Exp $\section{glwin - A System Interface for OpenGL Applications}$Revision: 2.33 $\\$Date: 2000/05/09 14:24:21 $\\Author: J\"urgen Fuhrmann\\\bigskip%--------------------------------------------------------------------This module provides access to basic facilities as X windowmanagement, event handling, off screen rendering etc. It has beenderived from the OpenGL sample {\em tk} code by putting all globalvariables into a structure called {\tt glWindow}. Not everything hasbeen checked, especially not the color index stuff. I is theintention of the author to keep track of changes in the {\em libtk}toolkit. There are three main difference to the {\em libtk} kit: \begin{itemize} \item {\em glwin} is able to to manage more than one window at one time. This has been achieved by wrapping all global variables of {\em libtk} into a (hidden) data type {\tt glWindow} and letting the user provide data to all callback routines via a {\tt void*} parameter. \item The event loop (called by {\tt glwProcess()}) knows an application-controlled and an event-controlled (user-controlled) mode. In application-controlled mode it is possible to attach a GL window, let it process any pending events, render user data and exit without destroying the window contents. This enables the usage of {\em glwin} under the control of the application during transient simulations etc. In event-controlled mode, the event loop needs some user itervention (e.g. key press) to exit. \item {\tt glwGrab()} grabs the actual window contents and dumps it into a ppm file. \begin{comment} \item {\tt glwDump()} calls the user redraw function within an off-screen rendering context attached to a pixmap of user definable size. The rendered data are read into a buffer and dumped into a tiff file. To enable this feature, TIFF support (using libtiff.a) has to be compiled in. \end{comment} \item {\tt glwStartRecording()/glwStopRecording} record an MPEG stream using mpeg\_encode version 1.5 or higher.\end{itemize} %--------------------------------------------------------------------\subsection{Acknowledgements}The kernel of the code has been derived from various versions of the''tk nano window toolkit'' which comes along as OpenGL demo software.Namely, code comes from versions on SGI and Digital machines, and fromthe MESA distribution. If that code wouldn't have been available in source form, gltools would not exist.%--------------------------------------------------------------------\subsection{Installation}\label{glwin:subsect:Installation}The installation should be fairly simple. You need an ANSI C compiler,the headers and libraries of X11 and GL and.Sorry for not providing Imakefiles and/or configure scripts - to me, theseare a mess, and I try not to use anyting non-portable in my code.\subsubsection{Installation with vendor installed OpenGL}Everything should be smooth, you don't need to define any preprocessor options. Link with ''{\tt -lGL -lXext -lX11}''.\subsubsection{Installation with MESA}Obtain MESA from {\tt http://www.ssec.wisc.edu/~brianp/Mesa.html}and install it - the best way would be in {\tt /usr/local/{*}}.Then compile {\tt glwin.c} with ''{\tt -I/usr/local/include}''and link with\\ ''{\tt -L/usr/local/lib -lMesaGL -lXext -lX11}''(or whatever you have called the MESA libraries).*//*%--------------------------------------------------------------------\subsection{Imported packages}*/#ifndef GLW_HEADER#define GLW_HEADER#include <GL/gl.h>#include <stdio.h>/*%--------------------------------------------------------------------\subsection{Data Types}*//*\func{glWindow}*/typedef struct glWindowStruct *glWindow; /* This is the basic handlestructure, all data in it are hidden from the user. *//*%--------------------------------------------------------------------\subsection{Constructors and Destructors}*//*\func{glwInitDisplayMode}*/void glwInitDisplayMode( GLenum mode );/*Set the display mode for next window to create.The default value is\\ \verb-GLW_RGB|GLW_DOUBLE|GLW_DIRECT|GLW_DEPTH-.Possible values are combinations of the following bitmasks:*/#define GLW_RGB 0 /* RGB mode */#define GLW_INDEX 1 /* Color index mode */#define GLW_SINGLE 0 /* Single buffer mode */#define GLW_DOUBLE 2 /* Double buffer mode */#define GLW_DIRECT 0 /* Direct rendering */#define GLW_INDIRECT 4 /* Indirect rendering */#define GLW_ACCUM 8 /* Enable accumulation buffer */#define GLW_ALPHA 16 /* Enable alpha calculations */ #define GLW_DEPTH 32 /* Enable depth buffer */#define GLW_OVERLAY 64 /* Create Window with overlay */#define GLW_UNDERLAY 128#define GLW_STENCIL 512 #define GLW_PIXMAP 1024/*At startup and after creating a window, all values are reset tothe defaults. The values set are used only for the next windowcreated. %-----------------------------------------------------------------*//*\func{glwInitPos}*/void glwInitPos( int x, int y );/*Set the initial position of the upper left corner of thewindow on the screen.Default: $(0,0)$ (Upper left corner of the screen). %-----------------------------------------------------------------*//*\func{glwInitSize}*/void glwInitPos( int x, int y );#define GLW_SIZE_MPEG1_PAL 352,288 #define GLW_SIZE_MPEG2_PAL 704,576#define GLW_SIZE_MPEG1_NTSC 352,240 #define GLW_SIZE_MPEG2_NTSC 704,480#define GLW_SIZE_1 1024,768#define GLW_SIZE_2 1280,1024#define GLW_SIZE_3 1600,1200/*Set the size of the window on the screen.Default: GLW\_PAL\_HALF.The sizes are not mandatory.The MPEG-1 standard does not demand any frame size, the MPEG-2 standarddemans a multiple of 16 in the frame size.However it is useful to stick to the MPEG sizes given here if onewants to use MPEG in connection with hardware. %-----------------------------------------------------------------*//*\func{glwInitTitle}*/void glwInitTitle( char * title );/* Set the title of the window to be created.Default: ''gltools-1.0'' At startup and after creating a window, all values are reset to thedefaults. The values set are used only for the next window created. The maximum length of a name is defined here:*/#define GLW_NAMELEN 128/*\func{ glwInitDisplayModePolicy}*/void glwInitDisplayModePolicy( GLenum type );/* Set visual match mode. Default: \verb|GLW_MINIMUM_CRITERIA|. Possible values:*/enum { GLW_USE_ID = 1, GLW_EXACT_MATCH, GLW_MINIMUM_CRITERIA};/*At startup and after creating a window, all values are reset to thedefaults. The values set are used only for the next window created. *//*\func{glwInitOffscreen}*/void glwInitOffscreen(void);/* Declare window to be created to be an offscreen window. This couldbe used for e.g. for creating frames in batch mode. The correspondingcode is in beta status.At startup and after creating a window, all values are reset to thedefaults. The values set are used only for the next window created. */void glwInitToplevel(void *toplevel);/* Declare the toplevel window of the system window to be created.Under X11, it is used as the target for the "transient_for" property.*//*\func{glwInitAspectKeeping}*/void glwInitAspectKeeping( int yesno );/* Keep aspect ratio of window when resizing. Default: 1 (yes).At startup and after creating a window, all values are reset to thedefaults. The values set are used only for the next window created. \func{glwGetDefault}*/char * glwGetDefault(glWindow w, char * resource, char *dflt);/*Read resource from resource database, e.g. readsgltools*printerCommand from your .Xdefaults.Returns default if resource has not been found in database.\func{glwCreate}*/glWindow glwCreate( void );/* Create a window. Multiple windows may be created. OpenGL renders into the window freshly created or the window defined by \xref{glwAttach}.\func{glwDestroy}*/void glwDestroy( glWindow win );/* Destroy the window. *//*%--------------------------------------------------------\subsection{Control}*//*\func{glwAttach}*/int glwAttach( glWindow win );/* ''Attach'' the window, i.e. make the corresponding OpenGL contextcurrent.%-----------------------------------------------------------------*//*\func{glwFlush}*/void glwFlush( glWindow win );/* Flush the window. %-----------------------------------------------------------------*//*\func{glwProcess}*/void glwProcess( glWindow win, void *user_data );/* Process event loop. User data are rendered by calling the redraw function set by \xref{glwSetRedrawFunc}. The event loop is exited \begin{itemize} \item after {\tt glwQuit()} call (user intervention) in event driven mode \item after processing pending events, {\em one} redraw and {\tt glwQuit()} in application driven mode. \end{itemize} The parameter {\tt info} is used to pass user data to the callback routines. Thus, gltools can be used for rendering under control of the user code.%-----------------------------------------------------------------*//*\func{glwSetControlMode} */void glwSetControlMode( glWindow w, int mode );/* Set control mode. Possible values:*/#define GLW_EVENT_DRIVEN 1 /* default */#define GLW_APPLICATION_DRIVEN 2/*%-----------------------------------------------------------------*//*\func{glwGrabPPM}*/void glwGrabPPM( glWindow win, FILE *f
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -