1 /* $Id: winpos.c,v 1.1 1999/08/19 00:55:40 jtg 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.1 1999/08/19 00:55:40 jtg
14 * Revision 3.3 1999/03/28 18:24:37 brianp
17 * Revision 3.2 1998/11/05 04:34:04 brianp
18 * moved image files to ../images/ directory
20 * Revision 3.1 1998/02/22 16:36:10 brianp
21 * changed image file and set unpack alignment to 1
23 * Revision 3.0 1998/02/14 18:42:29 brianp
35 #include "../util/readtex.c" /* a hack, I know */
37 #define IMAGE_FILE "../images/girl.rgb"
41 # define M_PI 3.14159265
46 static GLubyte
*Image
;
47 static int ImgWidth
, ImgHeight
;
48 static GLenum ImgFormat
;
52 static void draw( void )
57 extensions
= (char *) glGetString( GL_EXTENSIONS
);
58 if (strstr( extensions
, "GL_MESA_window_pos")==NULL
) {
59 printf("Sorry, GL_MESA_window_pos extension not available.\n");
63 glClear( GL_COLOR_BUFFER_BIT
);
65 for (angle
= -45.0; angle
<= 135.0; angle
+= 10.0) {
66 GLfloat x
= 50.0 + 200.0 * cos( angle
* M_PI
/ 180.0 );
67 GLfloat y
= 50.0 + 200.0 * sin( angle
* M_PI
/ 180.0 );
69 /* Don't need to worry about the modelview or projection matrices!!! */
70 #ifdef GL_MESA_window_pos
71 glWindowPos2fMESA( x
, y
);
73 glDrawPixels( ImgWidth
, ImgHeight
, ImgFormat
, GL_UNSIGNED_BYTE
, Image
);
80 static void key( unsigned char key
, int x
, int y
)
92 /* new window size or exposure */
93 static void reshape( int width
, int height
)
95 glViewport(0, 0, (GLint
)width
, (GLint
)height
);
99 static void init( void )
101 Image
= LoadRGBImage( IMAGE_FILE
, &ImgWidth
, &ImgHeight
, &ImgFormat
);
103 printf("Couldn't read %s\n", IMAGE_FILE
);
106 glPixelStorei(GL_UNPACK_ALIGNMENT
, 1);
111 int main( int argc
, char *argv
[] )
113 glutInitWindowPosition(0, 0);
114 glutInitWindowSize(500, 500);
115 glutInitDisplayMode( GLUT_RGB
);
117 if (glutCreateWindow("winpos") <= 0) {
123 glutReshapeFunc( reshape
);
124 glutKeyboardFunc( key
);
125 glutDisplayFunc( draw
);