1 /* $Id: winpos.c,v 1.3 2000/12/24 22:53:54 pesco Exp $ */
4 * Example of how to use the GL_MESA_window_pos extension.
5 * Brian Paul This file is in the public domain.
11 * Revision 1.3 2000/12/24 22:53:54 pesco
12 * * demos/Makefile.am (INCLUDES): Added -I$(top_srcdir)/util.
13 * * demos/Makefile.X11, demos/Makefile.BeOS-R4, demos/Makefile.cygnus:
14 * Essentially the same.
15 * Program files updated to include "readtex.c", not "../util/readtex.c".
16 * * demos/reflect.c: Likewise for "showbuffer.c".
19 * * Makefile.am (EXTRA_DIST): Added top-level regular files.
21 * * include/GL/Makefile.am (INC_X11): Added glxext.h.
24 * * src/GGI/include/ggi/mesa/Makefile.am (EXTRA_HEADERS): Include
25 * Mesa GGI headers in dist even if HAVE_GGI is not given.
27 * * configure.in: Look for GLUT and demo source dirs in $srcdir.
29 * * src/swrast/Makefile.am (libMesaSwrast_la_SOURCES): Set to *.[ch].
30 * More source list updates in various Makefile.am's.
32 * * Makefile.am (dist-hook): Remove CVS directory from distribution.
33 * (DIST_SUBDIRS): List all possible subdirs here.
34 * (SUBDIRS): Only list subdirs selected for build again.
35 * The above two applied to all subdir Makefile.am's also.
37 * Revision 1.2 2000/06/27 17:04:43 brianp
38 * fixed compiler warnings
40 * Revision 1.1.1.1 1999/08/19 00:55:40 jtg
43 * Revision 3.3 1999/03/28 18:24:37 brianp
46 * Revision 3.2 1998/11/05 04:34:04 brianp
47 * moved image files to ../images/ directory
49 * Revision 3.1 1998/02/22 16:36:10 brianp
50 * changed image file and set unpack alignment to 1
52 * Revision 3.0 1998/02/14 18:42:29 brianp
62 #define GL_GLEXT_LEGACY
65 #include "readtex.c" /* a hack, I know */
67 #define IMAGE_FILE "../images/girl.rgb"
71 # define M_PI 3.14159265
76 static GLubyte
*Image
;
77 static int ImgWidth
, ImgHeight
;
78 static GLenum ImgFormat
;
82 static void draw( void )
87 extensions
= (char *) glGetString( GL_EXTENSIONS
);
88 if (strstr( extensions
, "GL_MESA_window_pos")==NULL
) {
89 printf("Sorry, GL_MESA_window_pos extension not available.\n");
93 glClear( GL_COLOR_BUFFER_BIT
);
95 for (angle
= -45.0; angle
<= 135.0; angle
+= 10.0) {
96 GLfloat x
= 50.0 + 200.0 * cos( angle
* M_PI
/ 180.0 );
97 GLfloat y
= 50.0 + 200.0 * sin( angle
* M_PI
/ 180.0 );
99 /* Don't need to worry about the modelview or projection matrices!!! */
100 #ifdef GL_MESA_window_pos
101 glWindowPos2fMESA( x
, y
);
103 glDrawPixels( ImgWidth
, ImgHeight
, ImgFormat
, GL_UNSIGNED_BYTE
, Image
);
110 static void key( unsigned char key
, int x
, int y
)
122 /* new window size or exposure */
123 static void reshape( int width
, int height
)
125 glViewport(0, 0, (GLint
)width
, (GLint
)height
);
129 static void init( void )
131 Image
= LoadRGBImage( IMAGE_FILE
, &ImgWidth
, &ImgHeight
, &ImgFormat
);
133 printf("Couldn't read %s\n", IMAGE_FILE
);
136 glPixelStorei(GL_UNPACK_ALIGNMENT
, 1);
141 int main( int argc
, char *argv
[] )
143 glutInitWindowPosition(0, 0);
144 glutInitWindowSize(500, 500);
145 glutInitDisplayMode( GLUT_RGB
);
147 if (glutCreateWindow("winpos") <= 0) {
153 glutReshapeFunc( reshape
);
154 glutKeyboardFunc( key
);
155 glutDisplayFunc( draw
);