static unsigned num_extensions;
static GLboolean use_ztrick = GL_FALSE;
-static GLfloat aspect;
+static GLfloat aspectX = 1.0f, aspectY = 1.0f;
/*
*
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glFrustum(-1.0, 1.0, -aspect, aspect, 5.0, 60.0);
+ glFrustum(-aspectX, aspectX, -aspectY, aspectY, 5.0, 60.0);
glEnable(GL_LIGHTING);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- glTranslatef(0.0, 0.0, -40.0);
+ glTranslatef(0.0, 0.0, -45.0);
}
else {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
static void
reshape(int width, int height)
{
- aspect = (GLfloat) height / (GLfloat) width;
+ if (width > height) {
+ aspectX = (GLfloat) width / (GLfloat) height;
+ aspectY = 1.0;
+ }
+ else {
+ aspectX = 1.0;
+ aspectY = (GLfloat) height / (GLfloat) width;
+ }
-
glViewport(0, 0, (GLint) width, (GLint) height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glFrustum(-1.0, 1.0, -aspect, aspect, 5.0, 60.0);
+ glFrustum(-aspectX, aspectX, -aspectY, aspectY, 5.0, 60.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- glTranslatef(0.0, 0.0, -40.0);
+ glTranslatef(0.0, 0.0, -45.0);
}
}
+/**
+ * Remove window border/decorations.
+ */
+static void
+no_border( Display *dpy, Window w)
+{
+ static const unsigned MWM_HINTS_DECORATIONS = (1 << 1);
+ static const int PROP_MOTIF_WM_HINTS_ELEMENTS = 5;
+
+ typedef struct
+ {
+ unsigned long flags;
+ unsigned long functions;
+ unsigned long decorations;
+ long inputMode;
+ unsigned long status;
+ } PropMotifWmHints;
+
+ PropMotifWmHints motif_hints;
+ Atom prop, proptype;
+ unsigned long flags = 0;
+
+ /* setup the property */
+ motif_hints.flags = MWM_HINTS_DECORATIONS;
+ motif_hints.decorations = flags;
+
+ /* get the atom for the property */
+ prop = XInternAtom( dpy, "_MOTIF_WM_HINTS", True );
+ if (!prop) {
+ /* something went wrong! */
+ return;
+ }
+
+ /* not sure this is correct, seems to work, XA_WM_HINTS didn't work */
+ proptype = prop;
+
+ XChangeProperty( dpy, w, /* display, window */
+ prop, proptype, /* property, type */
+ 32, /* format: 32-bit datums */
+ PropModeReplace, /* mode */
+ (unsigned char *) &motif_hints, /* data */
+ PROP_MOTIF_WM_HINTS_ELEMENTS /* nelements */
+ );
+}
+
+
/*
* Create an RGB, double-buffered window.
* Return the window and context handles.
*/
static void
make_window( Display *dpy, const char *name,
- int x, int y, int width, int height,
+ int x, int y, int width, int height, GLboolean fullscreen,
Window *winRet, GLXContext *ctxRet)
{
int attrib[] = { GLX_RGBA,
scrnum = DefaultScreen( dpy );
root = RootWindow( dpy, scrnum );
+ if (fullscreen) {
+ x = y = 0;
+ width = DisplayWidth( dpy, scrnum );
+ height = DisplayHeight( dpy, scrnum );
+ }
+
visinfo = glXChooseVisual( dpy, scrnum, attrib );
if (!visinfo) {
printf("Error: couldn't get an RGB, Double-buffered visual\n");
None, (char **)NULL, 0, &sizehints);
}
+ if (fullscreen)
+ no_border(dpy, win);
+
ctx = glXCreateContext( dpy, visinfo, NULL, True );
if (!ctx) {
printf("Error: glXCreateContext failed\n");
* Display the refresh rate of the display using the GLX_OML_sync_control
* extension.
*/
-
static void
show_refresh_rate( Display * dpy )
{
* \param string String of GLX extensions.
* \sa is_extension_supported
*/
-
static void
make_extension_table( const char * string )
{
* \return GL_TRUE of the extension is supported, GL_FALSE otherwise.
* \sa make_extension_table
*/
-
static GLboolean
is_extension_supported( const char * ext )
{
int swap_interval = 1;
GLboolean do_swap_interval = GL_FALSE;
GLboolean force_get_rate = GL_FALSE;
+ GLboolean fullscreen = GL_FALSE;
GLboolean printInfo = GL_FALSE;
int i;
PFNGLXSWAPINTERVALMESAPROC set_swap_interval = NULL;
PFNGLXGETSWAPINTERVALMESAPROC get_swap_interval = NULL;
-
+ int width = 300, height = 300;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-display") == 0 && i + 1 < argc) {
*/
force_get_rate = GL_TRUE;
}
+ else if (strcmp(argv[i], "-fullscreen") == 0) {
+ fullscreen = GL_TRUE;
+ }
else if (strcmp(argv[i], "-ztrick") == 0) {
use_ztrick = GL_TRUE;
}
printf(" -info Display GL information\n");
printf(" -swap N Swap no more than once per N vertical refreshes\n");
printf(" -forcegetrate Try to use glXGetMscRateOML function\n");
+ printf(" -fullscreen Full-screen window\n");
return 0;
}
}
return -1;
}
- make_window(dpy, "glxgears", 0, 0, 300, 300, &win, &ctx);
+ make_window(dpy, "glxgears", 0, 0, width, height, fullscreen, &win, &ctx);
XMapWindow(dpy, win);
glXMakeCurrent(dpy, win, ctx);
/* Set initial projection/viewing transformation.
* same as glxgears.c
*/
- reshape(300, 300);
+ reshape(width, height);
event_loop(dpy, win);