Display

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

Submitted by Anonymous on Thu, 12/27/2001 - 15:39. Developers
The below program always gives a message ,"Can`t find visual".I have glx extensions installed and is supported.Now I want to know How can I find If the visual asked by glxchoosevisual is supported by X.I even want to know what visuals,colormaps ..., are supported by my machine.
#include
#include
#include
#include
#include

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

#include "transparent.h"

#include
#include
#include

/* Global Declarations */

XtAppContext app_context = (XtAppContext) 0 ;
Display *display = (Display *) 0 ;

/*
** START Hand edited code
*/

XVisualInfo *visual_info = (XVisualInfo *) 0 ;
Boolean gl_extension = False ;
Pixel transparent_pixel = (Pixel) 0 ;
Colormap transparent_colormap = (Colormap) 0 ;

static GLboolean GlQueryExtension(Display *display, int screen, char *name)
{
char *cptr ;
char *eptr ;
int length ;
int index ;

cptr = (char *) glXQueryExtensionsString(display, screen) ;

if (cptr == (char *) 0) {
return GL_FALSE ;
}

length = strlen(name) ;
eptr = cptr + strlen(cptr) ;

while (cptr < eptr) {
index = strcspn(cptr, " ") ;

if ((length == index) && (strncmp(name, cptr, index) == 0)) {
return GL_TRUE ;
}

cptr += (index + 1) ;
}

return GL_FALSE ;
}

static int rgba_config[] =
{
GLX_RGBA,
GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_TRANSPARENT_TYPE_EXT, GLX_TRANSPARENT_RGB_EXT,
None,
} ;

static int non_rgba_config[] =
{
GLX_BUFFER_SIZE, 2,
GLX_LEVEL, 1,
GLX_TRANSPARENT_TYPE_EXT, GLX_TRANSPARENT_INDEX_EXT,
None
} ;

/*
** END Hand edited code
*/

int main(int argc, char **argv)
{
/* Enable Localisation of the Application */

XtSetLanguageProc((XtAppContext) 0, (XtLanguageProc) 0, (XtPointer) 0) ;

/* Initialise the X Toolkit */

XtToolkitInitialize ();

/* Create a Global Application Context */

app_context = XtCreateApplicationContext ();

/* Open the Display */

display = XtOpenDisplay(app_context, (String) 0, argv[0], "XApplication",
(XrmOptionDescRec *) 0, 0,
&argc, argv);
if (display == (Display *) 0) {
printf("%s can`t open display, exiting...
", argv[0]);
exit (-1);
}

/*
** START Hand edited code
*/

if (GlQueryExtension(display, DefaultScreen(display), "GLX_EXT_visual_info") == GL_TRUE) {
gl_extension = True ;
}
else {
printf("%s can`t find X visual info extension, exiting...
", argv[0]);
exit(-1) ;
}

if (gl_extension == GL_TRUE) {
visual_info = glXChooseVisual(display, DefaultScreen(display), rgba_config) ;

if (visual_info == (XVisualInfo *) 0) {
visual_info = glXChooseVisual(display, DefaultScreen(display), non_rgba_config) ;

if (visual_info == (XVisualInfo *) 0) {
printf("%s can`t find visual, exiting...
", argv[0]);
exit(-1) ;
}
else {
printf("%s using non-RGBA visual...
", argv[0]);
}
}
else {
printf("%s using RGBA visual...
", argv[0]);
}
}

transparent_colormap = XCreateColormap(display,
RootWindow(display, visual_info->screen),
visual_info->visual,
AllocNone) ;

if (transparent_colormap == (Colormap) 0) {
printf("%s can`t create transparent colormap, exiting...
", argv[0]);
exit(-1) ;
}

transparent_pixel = 0 ;

/*
** END Hand edited code
*/

/* This converter is not registered internally by Motif */

XmRepTypeInstallTearOffModelConverter();

/* Call the Create Procedures for the Dialogs in the Application */

create_app_shell ( display, argv[0], argc, argv );
create_dialog_shell ( app_shell );

/* Display the Primary Application Shell */

XtRealizeWidget (app_shell);

/* Entering X Main Loop... */

XtAppMainLoop (app_context);

/* NOTREACHED */

exit (0);
}

Tue, 07/03/2012 - 15:00
#1
2 posts / 0 new
Last post
-10
Tue, 07/03/2012 - 15:01