您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ DefaultScreen函数代码示例

51自学网 2021-06-01 20:26:07
  C++
这篇教程C++ DefaultScreen函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中DefaultScreen函数的典型用法代码示例。如果您正苦于以下问题:C++ DefaultScreen函数的具体用法?C++ DefaultScreen怎么用?C++ DefaultScreen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了DefaultScreen函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: xDrawLegendBox

voidxDrawLegendBox (Display *dpy, Window win,	int x, int y, int width, int height,	float bclip, float wclip, char *units, char *legendfont,	char *labelfont, char *title, char *titlefont,	char *axescolor, char *titlecolor, char *gridcolor,	int style)/*****************************************************************************draw a labeled axes box******************************************************************************Input:dpy		display pointerwin		windowx		x coordinate of upper left corner of boxy		y coordinate of upper left corner of boxwidth		width of boxheight		height of boxunits		label for legendlegendfont	name of font to use for legend labelslabelfont	name of font to use for axes labelstitle		axes box titletitlefont	name of font to use for titleaxescolor	name of color to use for axestitlecolor	name of color to use for titlegridcolor	name of color to use for gridint style	NORMAL (axis 1 on bottom, axis 2 on left)		SEISMIC (axis 1 on left, axis 2 on top)******************************************************************************Notes:xDrawLegendBox will determine the numbered tic incremenet and firstnumbered tic automatically, if the specified increment is zero.Pad values must be specified in the same units as the correspondingaxes values.  These pads are useful when the contents of the axes boxrequires more space than implied by the axes values.  For example,the first and last seismic wiggle traces plotted inside an axes boxwill typically extend beyond the axes values corresponding to thefirst and last traces.  However, all tics will lie within the limitsspecified in the axes values (x1beg, x1end, x2beg, x2end).******************************************************************************Author:		Dave Hale, Colorado School of Mines, 01/27/90Author:		Berend Scheffers , TNO Delft, 06/11/92*****************************************************************************/{	GC gca,gct,gcg;	XGCValues *values=NULL;	XColor scolor,ecolor;	XFontStruct *fa,*ft;	XWindowAttributes wa;	Colormap cmap;	int labelca,labelcd,labelch,labelcw,titleca,titlecd,titlech,titlecw,		xa,ya,tw,ticsize,ticb,numb,lstr,scr;	float dnum=EPS,amin,amax,base,anum,azero;	char str[256];	/* get screen */	scr = DefaultScreen(dpy);	/* create graphics contexts */	gca = XCreateGC(dpy,win,0,values);	gct = XCreateGC(dpy,win,0,values);	gcg = XCreateGC(dpy,win,0,values);	/* get and set fonts and determine character dimensions */	fa = XLoadQueryFont(dpy,legendfont);	if (fa==NULL) fa = XLoadQueryFont(dpy,"fixed");	if (fa==NULL) {		fprintf(stderr,"Cannot load/query legendfont=%s/n",legendfont);		exit(-1);	}	XSetFont(dpy,gca,fa->fid);	labelca = fa->max_bounds.ascent;	labelcd = fa->max_bounds.descent;	labelch = fa->max_bounds.ascent+fa->max_bounds.descent;	labelcw = fa->max_bounds.lbearing+fa->max_bounds.rbearing;	ft = XLoadQueryFont(dpy,titlefont);	if (ft==NULL) ft = XLoadQueryFont(dpy,"fixed");	if (ft==NULL) {		fprintf(stderr,"Cannot load/query titlefont=%s/n",titlefont);		exit(-1);	}	XSetFont(dpy,gct,ft->fid);	titleca = ft->max_bounds.ascent;	titlecd = ft->max_bounds.descent;	titlech = ft->max_bounds.ascent+ft->max_bounds.descent;	titlecw = ft->max_bounds.lbearing+ft->max_bounds.rbearing;	/* determine window's current colormap */	XGetWindowAttributes(dpy,win,&wa);	cmap = wa.colormap;	/* get and set colors */	if (XAllocNamedColor(dpy,cmap,axescolor,&scolor,&ecolor))		XSetForeground(dpy,gca,ecolor.pixel);	else		XSetForeground(dpy,gca,1L);	if (XAllocNamedColor(dpy,cmap,titlecolor,&scolor,&ecolor))		XSetForeground(dpy,gct,ecolor.pixel);	else		XSetForeground(dpy,gct,1L);//.........这里部分代码省略.........
开发者ID:JOravetz,项目名称:SeisUnix,代码行数:101,


示例2: assert

WidgetXtNativePopupMenu::traverseBuild(  Widget parent,  MenuRecord * menu,  int indent){  assert(indent < 24);  int i;#if SOXT_POPUPMENU_DEBUG  char pre[24];  for (i = 0; i < indent; i++) pre[i] = ' ';  pre[i] = '/0';#endif // SOXT_POPUPMENU_DEBUG  int j = 0;  MenuRecord * sub;  ItemRecord * item;  do {    sub = (MenuRecord *) NULL;    item = (ItemRecord *) NULL;    const int numMenus = this->menus->getLength();    for (i = 0; i < numMenus; i++) {      sub = (MenuRecord *) (*this->menus)[i];      if ((sub->pos == j) && (sub->parent == menu)) {#if SOXT_POPUPMENU_DEBUG        fprintf(stderr, "%s%s {/n", pre, sub->name);#endif // SOXT_POPUPMENU_DEBUG        Display * dpy = SoXt::getDisplay();        const int screen = DefaultScreen(dpy);        Visual * visual = DefaultVisual(dpy, screen);        Colormap colormap = DefaultColormap(dpy, screen);        int depth = DefaultDepth(dpy, screen);        Arg args[10];        int argc = 0;        XtSetArg(args[argc], XmNvisual, visual); argc++;        XtSetArg(args[argc], XmNdepth, depth); argc++;        XtSetArg(args[argc], XmNcolormap, colormap); argc++;        Widget submenu = XmCreatePulldownMenu(parent, sub->name, args, argc);        sub->menu = XtVaCreateManagedWidget(sub->name,          xmCascadeButtonGadgetClass, parent,          XmNsubMenuId, submenu,          XtVaTypedArg,            XmNlabelString, XmRString,            sub->title, strlen(sub->title) + 1,          NULL);        this->traverseBuild(submenu, sub, indent + 2);#if SOXT_POPUPMENU_DEBUG        fprintf(stderr, "%s}/n", pre);#endif // SOXT_POPUPMENU_DEBUG        break;      } else {        sub = (MenuRecord *) NULL;      }    }    if (sub == NULL) {      const int numItems = this->items->getLength();      for (i = 0; i < numItems; i++) {        item = (ItemRecord *) (*this->items)[i];        if ((item->pos == j) && (item->parent == menu)) {#if SOXT_POPUPMENU_DEBUG          fprintf(stderr, "%s%s/n", pre, item->name);#endif // SOXT_POPUPMENU_DEBUG          if (item->flags & ITEM_SEPARATOR) {            item->item = XtVaCreateManagedWidget(item->title,              xmSeparatorGadgetClass, parent, NULL);          } else {            item->item = XtVaCreateManagedWidget(item->title,              xmToggleButtonGadgetClass, parent,              XmNsensitive, (item->flags & ITEM_ENABLED) ? True : False,              XtVaTypedArg,                XmNlabelString, XmRString,                item->title, strlen(item->title)+1,              NULL);            XtAddCallback(item->item, XmNvalueChangedCallback,                XtNativePopupMenu::itemSelectionCallback, this);            XmToggleButtonSetState(item->item,              (item->flags & ITEM_MARKED) ? True : False,              False);          }          break;        } else {          item = (ItemRecord *) NULL;        }      }    }    j++;  } while ((sub != NULL) || (item != NULL));  return parent;} // traverseBuild()
开发者ID:ALLPix,项目名称:SoXt,代码行数:88,


示例3: XScreenCount

void CWinSystemX11::UpdateResolutions(){  CWinSystemBase::UpdateResolutions();  int numScreens = XScreenCount(m_dpy);  g_xrandr.SetNumScreens(numScreens);  bool switchOnOff = CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOSCREEN_BLANKDISPLAYS);  m_userOutput = CSettings::GetInstance().GetString(CSettings::SETTING_VIDEOSCREEN_MONITOR);  if (m_userOutput.compare("Default") == 0)    switchOnOff = false;  if(g_xrandr.Query(true, !switchOnOff))  {    XOutput *out = NULL;    if (m_userOutput.compare("Default") != 0)    {      out = g_xrandr.GetOutput(m_userOutput);      if (out)      {        XMode mode = g_xrandr.GetCurrentMode(m_userOutput);        if (!mode.isCurrent && !switchOnOff)        {          out = NULL;        }      }    }    if (!out)    {      m_userOutput = g_xrandr.GetModes()[0].name;      out = g_xrandr.GetOutput(m_userOutput);    }    if (switchOnOff)    {      // switch on output      g_xrandr.TurnOnOutput(m_userOutput);      // switch off other outputs      std::vector<XOutput> outputs = g_xrandr.GetModes();      for (size_t i=0; i<outputs.size(); i++)      {        if (StringUtils::EqualsNoCase(outputs[i].name, m_userOutput))          continue;        g_xrandr.TurnOffOutput(outputs[i].name);      }    }    XMode mode = g_xrandr.GetCurrentMode(m_userOutput);    if (mode.id.empty())      mode = g_xrandr.GetPreferredMode(m_userOutput);    m_bIsRotated = out->isRotated;    if (!m_bIsRotated)      UpdateDesktopResolution(CDisplaySettings::GetInstance().GetResolutionInfo(RES_DESKTOP), 0, mode.w, mode.h, mode.hz);    else      UpdateDesktopResolution(CDisplaySettings::GetInstance().GetResolutionInfo(RES_DESKTOP), 0, mode.h, mode.w, mode.hz);    CDisplaySettings::GetInstance().GetResolutionInfo(RES_DESKTOP).strId     = mode.id;    CDisplaySettings::GetInstance().GetResolutionInfo(RES_DESKTOP).strOutput = m_userOutput;  }  else  {    m_userOutput = "No Output";    m_nScreen = DefaultScreen(m_dpy);    int w = DisplayWidth(m_dpy, m_nScreen);    int h = DisplayHeight(m_dpy, m_nScreen);    UpdateDesktopResolution(CDisplaySettings::GetInstance().GetResolutionInfo(RES_DESKTOP), 0, w, h, 0.0);  }  // erase previous stored modes  CDisplaySettings::GetInstance().ClearCustomResolutions();  CLog::Log(LOGINFO, "Available videomodes (xrandr):");  XOutput *out = g_xrandr.GetOutput(m_userOutput);  if (out != NULL)  {    std::vector<XMode>::iterator modeiter;    CLog::Log(LOGINFO, "Output '%s' has %" PRIdS" modes", out->name.c_str(), out->modes.size());    for (modeiter = out->modes.begin() ; modeiter!=out->modes.end() ; modeiter++)    {      XMode mode = *modeiter;      CLog::Log(LOGINFO, "ID:%s Name:%s Refresh:%f Width:%d Height:%d",                mode.id.c_str(), mode.name.c_str(), mode.hz, mode.w, mode.h);      RESOLUTION_INFO res;      res.iScreen = 0; // not used by X11      res.dwFlags = 0;      res.iWidth  = mode.w;      res.iHeight = mode.h;      res.iScreenWidth  = mode.w;      res.iScreenHeight = mode.h;      if (mode.IsInterlaced())        res.dwFlags |= D3DPRESENTFLAG_INTERLACED;      if (!m_bIsRotated)      {        res.iWidth  = mode.w;        res.iHeight = mode.h;      }      else//.........这里部分代码省略.........
开发者ID:krattai,项目名称:sht_tv,代码行数:101,


示例4: lockscreen

static Lock *lockscreen(Display *dpy, int screen) {#if !TRANSPARENT	char curs[] = {0, 0, 0, 0, 0, 0, 0, 0};#endif	unsigned int len;	Lock *lock;#if !TRANSPARENT	XColor color, dummy;#endif	XSetWindowAttributes wa;#if !TRANSPARENT	Cursor invisible;#endif#if TRANSPARENT	XVisualInfo vi;#endif	if(dpy == NULL || screen < 0)		return NULL;	lock = malloc(sizeof(Lock));	if(lock == NULL)		return NULL;	lock->screen = screen;	lock->root = RootWindow(dpy, lock->screen);#if TRANSPARENT	XMatchVisualInfo(dpy, DefaultScreen(dpy), 32, TrueColor, &vi);	wa.colormap = XCreateColormap(dpy, DefaultRootWindow(dpy), vi.visual, AllocNone);#endif	/* init */	wa.override_redirect = 1;#if !TRANSPARENT	wa.background_pixel = BlackPixel(dpy, lock->screen);#else	wa.border_pixel = 0;	wa.background_pixel = 0xaa000000;#endif	lock->win = XCreateWindow(dpy, lock->root, 0, 0, DisplayWidth(dpy, lock->screen), DisplayHeight(dpy, lock->screen),#if !TRANSPARENT			0, DefaultDepth(dpy, lock->screen), CopyFromParent,			DefaultVisual(dpy, lock->screen), CWOverrideRedirect | CWBackPixel, &wa);#else			0, vi.depth, CopyFromParent,			vi.visual, CWOverrideRedirect | CWBackPixel | CWColormap | CWBorderPixel, &wa);#endif	Atom name_atom = XA_WM_NAME;	XTextProperty name_prop = { "slock", name_atom, 8, 5 };	XSetWMName(dpy, lock->win, &name_prop);	// Atom name_ewmh_atom = XInternAtom(dpy, "_NET_WM_NAME", False);	// XTextProperty name_ewmh_prop = { "slock", name_ewmh_atom, 8, 5 };	// XSetTextProperty(dpy, lock->win, &name_ewmh_prop, name_ewmh_atom);	// XSetWMName(dpy, lock->win, &name_ewmh_prop);	XClassHint *hint = XAllocClassHint();	if (hint) {		hint->res_name = "slock";		hint->res_class = "slock";		XSetClassHint(dpy, lock->win, hint);		XFree(hint);	}#if !TRANSPARENT	XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), COLOR2, &color, &dummy);	lock->colors[1] = color.pixel;	XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), COLOR1, &color, &dummy);	lock->colors[0] = color.pixel;	lock->pmap = XCreateBitmapFromData(dpy, lock->win, curs, 8, 8);	invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap, &color, &color, 0, 0);	XDefineCursor(dpy, lock->win, invisible);#endif	XMapRaised(dpy, lock->win);	for(len = 1000; len; len--) {		if(XGrabPointer(dpy, lock->root, False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,#if !TRANSPARENT			GrabModeAsync, GrabModeAsync, None, invisible, CurrentTime) == GrabSuccess)#else			GrabModeAsync, GrabModeAsync, None, None, CurrentTime) == GrabSuccess)#endif			break;		usleep(1000);	}	if(running && (len > 0)) {		for(len = 1000; len; len--) {			if(XGrabKeyboard(dpy, lock->root, True, GrabModeAsync, GrabModeAsync, CurrentTime)				== GrabSuccess)				break;			usleep(1000);		}	}	running &= (len > 0);	if(!running) {		unlockscreen(dpy, lock);//.........这里部分代码省略.........
开发者ID:coloradomountain,项目名称:slock,代码行数:101,


示例5: main

main (int argc, char *argv[])#endif{	XEvent ev;	fd_set fd;	int xfd;	dd = XOpenDisplay (NULL);	if (!dd)		return 0;	scr_screen = DefaultScreen (dd);	scr_depth = DefaultDepth (dd, scr_screen);	scr_height = DisplayHeight (dd, scr_screen);	scr_width = DisplayWidth (dd, scr_screen);	root_win = RootWindow (dd, scr_screen);	/* helps us catch windows closing/opening */	XSelectInput (dd, root_win, PropertyChangeMask);	XSetErrorHandler ((XErrorHandler) handle_error);	XInternAtoms (dd, atom_names, ATOM_COUNT, False, atoms);	gui_init ();	bzero (&tb, sizeof (struct taskbar));	tb.win = gui_create_taskbar ();	xfd = ConnectionNumber (dd);	gui_sync ();	while (1)	{		FD_ZERO (&fd);		FD_SET (xfd, &fd);		select (xfd + 1, &fd, 0, 0, 0);		while (XPending (dd))		{			XNextEvent (dd, &ev);			switch (ev.type)			{			case ButtonPress:				handle_press (ev.xbutton.x, ev.xbutton.y, ev.xbutton.button);				break;			case DestroyNotify:				del_task (ev.xdestroywindow.window);				/* fall through */			case Expose:				gui_draw_taskbar ();				break;			case PropertyNotify:				handle_propertynotify (ev.xproperty.window, ev.xproperty.atom);				break;			case FocusIn:				handle_focusin (ev.xfocus.window);				break;			/*default:				   printf ("unknown evt type: %d/n", ev.type);*/			}		}	}	/*XCloseDisplay (dd);   return 0;*/}
开发者ID:hoverisk,项目名称:fspanel-black,代码行数:65,


示例6: createWindow

static Window createWindow(Window parent, Visual *visual, gulong mask, XSetWindowAttributes *attrib){	return XCreateWindow(t_display, parent, 0, 0, 1, 1, 0, (visual ? 32 : DefaultDepth(t_display, DefaultScreen(t_display))), InputOutput,		(visual ? visual : DefaultVisual(t_display, DefaultScreen(t_display))), mask, attrib);}
开发者ID:sylware,项目名称:lboxwm,代码行数:5,


示例7: winopen

void winopen(void){	XWMHints *hints;	xdpy = XOpenDisplay(nil);	if (!xdpy)		winerror(&gapp, "could not open display.");	XA_TARGETS = XInternAtom(xdpy, "TARGETS", False);	XA_TIMESTAMP = XInternAtom(xdpy, "TIMESTAMP", False);	XA_UTF8_STRING = XInternAtom(xdpy, "UTF8_STRING", False);	xscr = DefaultScreen(xdpy);	ximage_init(xdpy, xscr, DefaultVisual(xdpy, xscr));	xcarrow = XCreateFontCursor(xdpy, XC_left_ptr);	xchand = XCreateFontCursor(xdpy, XC_hand2);	xcwait = XCreateFontCursor(xdpy, XC_watch);	xbgcolor.red = 0x7000;	xbgcolor.green = 0x7000;	xbgcolor.blue = 0x7000;	xshcolor.red = 0x4000;	xshcolor.green = 0x4000;	xshcolor.blue = 0x4000;	XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xbgcolor);	XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xshcolor);	xwin = XCreateWindow(xdpy, DefaultRootWindow(xdpy),			10, 10, 200, 100, 1,			ximage_get_depth(),			InputOutput,			ximage_get_visual(),			0,			nil);	XSetWindowColormap(xdpy, xwin, ximage_get_colormap());	XSelectInput(xdpy, xwin,			StructureNotifyMask | ExposureMask | KeyPressMask |			PointerMotionMask | ButtonPressMask | ButtonReleaseMask);	mapped = 0;	xgc = XCreateGC(xdpy, xwin, 0, nil);	XDefineCursor(xdpy, xwin, xcarrow);	hints = XAllocWMHints();	if (hints)	{		hints->flags = IconPixmapHint;		hints->icon_pixmap = XCreateBitmapFromData(xdpy, xwin,				gs_l_xbm_bits, gs_l_xbm_width, gs_l_xbm_height);		if (hints->icon_pixmap)		{			XSetWMHints(xdpy, xwin, hints);		}		XFree(hints);	}}
开发者ID:wzhsunn,项目名称:SumatraPDF_0.6_Source,代码行数:63,


示例8: main

int main(int argc, char* argv[]) {  int number_of_stars = 200;  int iterations = 1000;  prec time_unit = gdt;  if(argc == 3)    {      number_of_stars = atoi(argv[1]);      iterations = atoi(argv[2]);    }  struct star* star_array = malloc(sizeof(struct star) * number_of_stars);  generate_init_values(number_of_stars, star_array);          #ifdef ANIMATE  XPoint* points = malloc(sizeof(XPoint)*number_of_stars);  Display* disp;  Window window, rootwin;  int screen;  disp = XOpenDisplay(NULL);  screen = DefaultScreen(disp);  rootwin = RootWindow(disp,screen);  window = XCreateSimpleWindow(disp,rootwin,                               0,0,X_SIZE,Y_SIZE,1,0,0);  GC gc = XCreateGC(disp, window, 0, 0);  XSetForeground(disp, gc, WhitePixel(disp, screen));  XSetBackground(disp, gc, BlackPixel(disp, screen));  XMapWindow(disp,window);  XClearWindow(disp,window);		  copyToXBuffer(star_array, points, number_of_stars);  XDrawPoints(disp, window, gc, points, number_of_stars, 0);  XFlush(disp);#endif  clock_t start = clock();  for(int i = 0; i < iterations; i++)    {#ifndef ANIMATE            resetForces(number_of_stars, star_array);      updateForces(number_of_stars, number_of_stars - 1, star_array);      for(int j = 0; j < number_of_stars; ++j){        update_position(&star_array[j], time_unit);      }#endif     #ifdef ANIMATE      resetForces(number_of_stars, star_array);      updateForces(number_of_stars, number_of_stars - 1, star_array);      for(int j = 0; j < number_of_stars; ++j){        update_position(&star_array[j], time_unit);        copyToXBuffer(star_array, points,number_of_stars );        XDrawPoints(disp, window, gc, points, number_of_stars, CoordModeOrigin);	      }      XClearWindow(disp,window);    #endif     }  clock_t stop = clock();  float diff = (float)(stop - start)/CLOCKS_PER_SEC;  printf("Total: %lf seconds/n",diff);  printf("Bodies: %d/n",number_of_stars);  printf("Iterations: %d/n", iterations);#ifdef ANIMATE  free(points);  XCloseDisplay(disp);#endif  free(star_array);  return 0;}
开发者ID:albohl,项目名称:nbody,代码行数:89,


示例9: glXChooseVisual

bool GLWindow::CreateContextGL(int major, int minor){	if (!NativeDisplay) return false;	// Get visual information	int attrListDbl[] =	{		// GLX_X_RENDERABLE: If True is specified, then only frame buffer configurations that have associated X		// visuals (and can be used to render to Windows and/or GLX pixmaps) will be considered. The default value is GLX_DONT_CARE.		GLX_X_RENDERABLE    , True,		GLX_RED_SIZE        , 8,		GLX_GREEN_SIZE      , 8,		GLX_BLUE_SIZE       , 8,		GLX_DEPTH_SIZE      , 24,		GLX_DOUBLEBUFFER    , True,		None	};	// Attribute are very sensible to the various implementation (intel, nvidia, amd)	// Nvidia and Intel doesn't support previous attributes for opengl2.0	int attrListDbl_2_0[] =	{		GLX_RGBA,		GLX_DOUBLEBUFFER,		GLX_RED_SIZE, 8,		GLX_GREEN_SIZE, 8,		GLX_BLUE_SIZE, 8,		GLX_DEPTH_SIZE, 24,		None	};	// Only keep for older card but NVIDIA and AMD both drop the support of those cards	if (major <= 2) {		XVisualInfo *vi = glXChooseVisual(NativeDisplay, DefaultScreen(NativeDisplay), attrListDbl_2_0);		if (vi == NULL) return NULL;		glxContext = glXCreateContext(NativeDisplay, vi, NULL, GL_TRUE);        XFree(vi);		if (!glxContext) return false;		glXMakeCurrent(NativeDisplay, NativeWindow, glxContext);		return true;	}	PFNGLXCHOOSEFBCONFIGPROC glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)GetProcAddress("glXChooseFBConfig");	int fbcount = 0;	GLXFBConfig *fbc = glXChooseFBConfig(NativeDisplay, DefaultScreen(NativeDisplay), attrListDbl, &fbcount);	if (!fbc || fbcount < 1) {		ZZLog::Error_Log("GLX: failed to find a framebuffer");		return false;	}	PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)GetProcAddress("glXCreateContextAttribsARB");	if (!glXCreateContextAttribsARB) return false;	// Create a context	int context_attribs[] =	{		GLX_CONTEXT_MAJOR_VERSION_ARB, major,		GLX_CONTEXT_MINOR_VERSION_ARB, minor,		// Keep compatibility for old cruft		GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,		//GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,		// FIXME : Request a debug context to ease opengl development#if (defined(ZEROGS_DEVBUILD) || defined(_DEBUG)) && defined(OGL4_LOG)		GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,#endif		None	};	glxContext = glXCreateContextAttribsARB(NativeDisplay, fbc[0], 0, true, context_attribs);	if (!glxContext) {		ZZLog::Error_Log("GLX: failed to create an opengl context");		return false;	}	XSync( NativeDisplay, false);	if (!glXMakeCurrent(NativeDisplay, NativeWindow, glxContext)) {		ZZLog::Error_Log("GLX: failed to attach the opengl context");		return false;	}	return true;}
开发者ID:ACanadianKernel,项目名称:pcsx2,代码行数:86,


示例10: main

int main(int argc, char**argv){	char **missing_charset_list;	int missing_charset_count;	XGCValues xgcv;	unsigned long mask;	Display* dpy;	int scr;	Window w, root;	XSetWindowAttributes set_attr;	int i;	XIMStyle *style;        static char buf[128];        KeySym keysym = 0;        Status status;	XWMHints wm_hints;    	XClassHint class_hints;	XIMStyle input_style = 0;	char **font_name_list;	char *def_string;	XFontStruct **font_struct_list;	char **font_encoding_list;	int nb_font;	int len = 0;	int no_xim = 0;	printf ("A -> %c /n", XUtf8Tolower('A'));    	if (!setlocale(LC_ALL, ""))        	puts("locale not supported by C library, locale unchanged");    	if (!XSetLocaleModifiers(""))        	puts("X locale modifiers not supported, using default");		dpy = XOpenDisplay(0);	if (!dpy) { puts("cannot open display./n"); exit(-1); }	scr = DefaultScreen(dpy);	root = RootWindow(dpy, scr);	set_attr.event_mask = KeyPressMask|FocusChangeMask;	set_attr.background_pixel = WhitePixel(dpy, DefaultScreen(dpy));	set_attr.border_pixel = BlackPixel(dpy, DefaultScreen(dpy));	w = XCreateWindow(dpy, root, 10,10,200,100,0, 		DefaultDepth(dpy, DefaultScreen(dpy)),		InputOutput, DefaultVisual(dpy, DefaultScreen(dpy)),		CWEventMask | CWBackPixel | CWBorderPixel, &set_attr);	if (!w) { puts("cannot creat window./n"); exit(-1); }	class_hints.res_name = "test";    	class_hints.res_class = "Test";	wm_hints.input = True;    	wm_hints.flags = InputHint;    	XmbSetWMProperties(dpy, w, "test", "test", NULL, 0,                       NULL, &wm_hints, &class_hints);	XMapWindow(dpy, w);	xim_im = XOpenIM(dpy, NULL, "test", "Test");	if (!xim_im) { 		puts("cannot Open Input Manager: Try default./n"); 		XSetLocaleModifiers("@im=");		xim_im = XOpenIM(dpy, NULL, "test", "Test");		if (!xim_im) { puts("Failed exiting./n"); exit(-1); }	}	XGetIMValues (xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL);    	for (i = 0, style = xim_styles->supported_styles;         	i < xim_styles->count_styles; i++, style++)	{		if (i == 0 && *style == (XIMStatusNone|XIMPreeditNone)) {			printf("this is not a XIM server !!!/n");			no_xim = 1;		}        	printf("input style : 0x%X/n", *style);	}	xim_ic = XCreateIC(xim_im,                        XNInputStyle, 			(XIMPreeditNothing | XIMStatusNothing),                        XNClientWindow, w,			XNFocusWindow, w,                        NULL);	if (!xim_ic) { puts("cannot create Input Context./n"); exit(-1);}    	XFree(xim_styles);	XSetICFocus(xim_ic);	/***************************************************************/	/** I don't recommand to use a font base name list similar 	 *  to the following one in a real application ;-) 	 *  You should use an iso8859-1 font, plus a single font for 	 *  your language. */	/***************************************************************/        fontset = XCreateUtf8FontStruct(dpy, 		"-*-*-*-*-*-*-*-*-*-*-*-*-iso8858-3," /* not valid */		"-*-*-medium-r-*-*-*-*-*-*-*-*-iso8859-1,"		"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-6,"		"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-8,"		"-*-*-*-*-*-*-*-*-*-*-*-*-ksc5601.1987-0,"		"-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific," 		"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-2,"		"-*-*-*-*-*-*-*-*-*-*-*-*-koi8-1,"		"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0208.1983-0,"		"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0212.1990-0,"//.........这里部分代码省略.........
开发者ID:vovan888,项目名称:linux-on-sx1,代码行数:101,


示例11: DRI2FallbackPRESENTPixmap

BOOLDRI2FallbackPRESENTPixmap(PRESENTpriv *present_priv, struct DRI2priv *dri2_priv,                          int fd, int width, int height, int stride, int depth,                          int bpp, PRESENTPixmapPriv **present_pixmap_priv){    Window root = RootWindow(dri2_priv->dpy, DefaultScreen(dri2_priv->dpy));    Pixmap pixmap;    EGLImageKHR image;    GLuint texture_read, texture_write, fbo_read, fbo_write;    EGLint attribs[] = {        EGL_WIDTH, 0,        EGL_HEIGHT, 0,        EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ARGB8888,        EGL_DMA_BUF_PLANE0_FD_EXT, 0,        EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,        EGL_DMA_BUF_PLANE0_PITCH_EXT, 0,        EGL_NONE    };    EGLenum current_api = 0;    int status;    pthread_mutex_lock(&present_priv->mutex_present);    pixmap = XCreatePixmap(dri2_priv->dpy, root, width, height, 24);    if (!pixmap)        goto fail;    attribs[1] = width;    attribs[3] = height;    attribs[7] = fd;    attribs[11] = stride;    current_api = eglQueryAPI();    eglBindAPI(EGL_OPENGL_API);    /* We bind the dma-buf to a EGLImage, then to a texture, and then to a fbo.     * Note that we can delete the EGLImage, but we shouldn't delete the texture,     * else the fbo is invalid */    image = dri2_priv->eglCreateImageKHR_func(dri2_priv->display,                              EGL_NO_CONTEXT,                              EGL_LINUX_DMA_BUF_EXT,                              NULL, attribs);    if (image == EGL_NO_IMAGE_KHR)        goto fail;    close(fd);    if(eglMakeCurrent(dri2_priv->display, EGL_NO_SURFACE, EGL_NO_SURFACE, dri2_priv->context)) {        glGenTextures(1, &texture_read);        glBindTexture(GL_TEXTURE_2D, texture_read);        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);        dri2_priv->glEGLImageTargetTexture2DOES_func(GL_TEXTURE_2D, image);        glGenFramebuffers(1, &fbo_read);        glBindFramebuffer(GL_FRAMEBUFFER, fbo_read);        glFramebufferTexture2D(GL_FRAMEBUFFER,                               GL_COLOR_ATTACHMENT0,                               GL_TEXTURE_2D, texture_read,                               0);        status = glCheckFramebufferStatus(GL_FRAMEBUFFER);        if (status != GL_FRAMEBUFFER_COMPLETE)            goto fail;        glBindTexture(GL_TEXTURE_2D, 0);        dri2_priv->eglDestroyImageKHR_func(dri2_priv->display, image);        /* We bind a newly created pixmap (to which we want to copy the content)         * to an EGLImage, then to a texture, then to a fbo. */        image = dri2_priv->eglCreateImageKHR_func(dri2_priv->display,                                                  dri2_priv->context,                                                  EGL_NATIVE_PIXMAP_KHR,                                                  (void *)pixmap, NULL);        if (image == EGL_NO_IMAGE_KHR)            goto fail;        glGenTextures(1, &texture_write);        glBindTexture(GL_TEXTURE_2D, texture_write);        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);        dri2_priv->glEGLImageTargetTexture2DOES_func(GL_TEXTURE_2D, image);        glGenFramebuffers(1, &fbo_write);        glBindFramebuffer(GL_FRAMEBUFFER, fbo_write);        glFramebufferTexture2D(GL_FRAMEBUFFER,                               GL_COLOR_ATTACHMENT0,                               GL_TEXTURE_2D, texture_write,                               0);        status = glCheckFramebufferStatus(GL_FRAMEBUFFER);        if (status != GL_FRAMEBUFFER_COMPLETE)            goto fail;        glBindTexture(GL_TEXTURE_2D, 0);        dri2_priv->eglDestroyImageKHR_func(dri2_priv->display, image);    } else {        ERR("eglMakeCurrent failed with 0x%0X/n", eglGetError());    }    eglMakeCurrent(dri2_priv->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);    *present_pixmap_priv = (PRESENTPixmapPriv *) calloc(1, sizeof(PRESENTPixmapPriv));    if (!*present_pixmap_priv) {        goto fail;    }//.........这里部分代码省略.........
开发者ID:sarnex,项目名称:wine,代码行数:101,


示例12: DefaultRootWindow

	//-------------------------------------------------------------------------------------------------//	void GLXWindow::create(const String& name, uint width, uint height,			   bool fullScreen, const NameValuePairList *miscParams)	{		Display *xDisplay = mGLSupport->getXDisplay();		String title = name;		uint samples = 0;		short frequency = 0;		bool vsync = false;		bool hidden = false;		unsigned int vsyncInterval = 1;		int gamma = 0;		::GLXContext glxContext = 0;		::GLXDrawable glxDrawable = 0;		Window externalWindow = 0;		Window parentWindow = DefaultRootWindow(xDisplay);		int left = DisplayWidth(xDisplay, DefaultScreen(xDisplay))/2 - width/2;		int top  = DisplayHeight(xDisplay, DefaultScreen(xDisplay))/2 - height/2;				mIsFullScreen = fullScreen;				if(miscParams)		{			NameValuePairList::const_iterator opt;			NameValuePairList::const_iterator end = miscParams->end();						// NB: Do not try to implement the externalGLContext option.			//			//	 Accepting a non-current context would expose us to the 			//	 risk of segfaults when we made it current. Since the			//	 application programmers would be responsible for these			//	 segfaults, they are better discovering them in their code.					if ((opt = miscParams->find("currentGLContext")) != end &&				StringConverter::parseBool(opt->second))			{				if (! glXGetCurrentContext())				{					OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "currentGLContext was specified with no current GL context", "GLXWindow::create");				}								glxContext = glXGetCurrentContext();				glxDrawable = glXGetCurrentDrawable();			}						// Note: Some platforms support AA inside ordinary windows			if((opt = miscParams->find("FSAA")) != end) 				samples = StringConverter::parseUnsignedInt(opt->second);						if((opt = miscParams->find("displayFrequency")) != end) 				frequency = (short)StringConverter::parseInt(opt->second);						if((opt = miscParams->find("vsync")) != end) 				vsync = StringConverter::parseBool(opt->second);			if((opt = miscParams->find("hidden")) != end)				hidden = StringConverter::parseBool(opt->second);			if((opt = miscParams->find("vsyncInterval")) != end) 				vsyncInterval = StringConverter::parseUnsignedInt(opt->second);			if ((opt = miscParams->find("gamma")) != end)				gamma = StringConverter::parseBool(opt->second);			if((opt = miscParams->find("left")) != end) 				left = StringConverter::parseInt(opt->second);						if((opt = miscParams->find("top")) != end) 				top = StringConverter::parseInt(opt->second);						if((opt = miscParams->find("title")) != end) 				title = opt->second;						if ((opt = miscParams->find("externalGLControl")) != end)				mIsExternalGLControl = StringConverter::parseBool(opt->second);						if((opt = miscParams->find("parentWindowHandle")) != end) 			{				vector<String>::type tokens = StringUtil::split(opt->second, " :");								if (tokens.size() == 3)				{					// deprecated display:screen:xid format					parentWindow = StringConverter::parseUnsignedLong(tokens[2]);				}				else				{					// xid format					parentWindow = StringConverter::parseUnsignedLong(tokens[0]);				}			}			else if((opt = miscParams->find("externalWindowHandle")) != end) 			{				vector<String>::type tokens = StringUtil::split(opt->second, " :");								LogManager::getSingleton().logMessage(													  "GLXWindow::create: The externalWindowHandle parameter is deprecated./n"													  "Use the parentWindowHandle or currentGLContext parameter instead.");								if (tokens.size() == 3)//.........这里部分代码省略.........
开发者ID:JoeyZh,项目名称:ogre-android,代码行数:101,


示例13: OSWindow

X11Window::X11Window( intf_thread_t *pIntf, GenericWindow &rWindow,                      X11Display &rDisplay, bool dragDrop, bool playOnDrop,                      X11Window *pParentWindow, GenericWindow::WindowType_t type ):    OSWindow( pIntf ), m_rDisplay( rDisplay ), m_pParent( pParentWindow ),    m_dragDrop( dragDrop ), m_pDropTarget( NULL ), m_type ( type ){    XSetWindowAttributes attr;    unsigned long valuemask;    std::string name_type;    if( type == GenericWindow::FullscreenWindow )    {        m_wnd_parent = DefaultRootWindow( XDISPLAY );        int i_screen = DefaultScreen( XDISPLAY );        attr.event_mask = ExposureMask | StructureNotifyMask;        attr.background_pixel = BlackPixel( XDISPLAY, i_screen );        attr.backing_store = Always;        valuemask = CWBackingStore | CWBackPixel | CWEventMask;        if( NET_WM_STATE_FULLSCREEN == None )        {            attr.override_redirect = True;            valuemask = valuemask | CWOverrideRedirect;        }        name_type = "Fullscreen";    }    else if( type == GenericWindow::VoutWindow )    {        m_wnd_parent = pParentWindow->m_wnd;        int i_screen = DefaultScreen( XDISPLAY );        attr.event_mask = ExposureMask | StructureNotifyMask;        attr.backing_store = Always;        attr.background_pixel = BlackPixel( XDISPLAY, i_screen );        valuemask = CWBackingStore | CWBackPixel | CWEventMask;        name_type = "VoutWindow";    }    else if( type == GenericWindow::FscWindow )    {        m_wnd_parent = DefaultRootWindow( XDISPLAY );        attr.event_mask = ExposureMask | StructureNotifyMask;        valuemask = CWEventMask;        name_type = "FscWindow";    }    else    {        m_wnd_parent = DefaultRootWindow( XDISPLAY );        attr.event_mask = ExposureMask | StructureNotifyMask;        valuemask = CWEventMask;        name_type = "TopWindow";    }    // Create the window    m_wnd = XCreateWindow( XDISPLAY, m_wnd_parent, -10, 0, 10, 10, 0, 0,                           InputOutput, CopyFromParent, valuemask, &attr );    // wait for X server to process the previous commands    XSync( XDISPLAY, false );    // Set the colormap for 8bpp mode    if( XPIXELSIZE == 1 )    {        XSetWindowColormap( XDISPLAY, m_wnd, m_rDisplay.getColormap() );    }    // Select events received by the window    long event_mask;    if( type == GenericWindow::VoutWindow )    {        event_mask =  ExposureMask|KeyPressMask|                      LeaveWindowMask|FocusChangeMask;    }    else    {        event_mask =  ExposureMask|KeyPressMask|                      PointerMotionMask|ButtonPressMask|ButtonReleaseMask|                      LeaveWindowMask|FocusChangeMask;    }    XSelectInput( XDISPLAY, m_wnd, event_mask );    // Store a pointer on the generic window in a map    X11Factory *pFactory = (X11Factory*)X11Factory::instance( getIntf() );    pFactory->m_windowMap[m_wnd] = &rWindow;    // Changing decorations    struct {        unsigned long flags;        unsigned long functions;        unsigned long decorations;        signed   long input_mode;        unsigned long status;//.........这里部分代码省略.........
开发者ID:RamboLouis,项目名称:vlc,代码行数:101,


示例14: DefaultScreen

const QRect XfitMan::availableGeometry(int screen) const{    QDesktopWidget *d = QApplication::desktop();    if (screen < 0 || screen >= d->screenCount())        screen = d->primaryScreen();    QRect available = d->screenGeometry(screen);    // Iterate over all the client windows and subtract from the available    // area the space they reserved on the edges (struts).    // Note: _NET_WORKAREA is not reliable as it exposes only one    // rectangular area spanning all screens.    Display *display = QX11Info::display();    int x11Screen = d->isVirtualDesktop() ? DefaultScreen(display) : screen;    Atom ret;    int format, status;    uchar* data = 0;    ulong nitems, after;    status = XGetWindowProperty(display, QX11Info::appRootWindow(x11Screen),                                atom("_NET_CLIENT_LIST"), 0L, ~0L, False, XA_WINDOW,                                &ret, &format, &nitems, &after, &data);    if (status == Success && ret == XA_WINDOW && format == 32 && nitems)    {        const QRect desktopGeometry = d->rect();        Window* xids = (Window*) data;        for (quint32 i = 0; i < nitems; ++i)        {            ulong nitems2;            uchar* data2 = 0;            status = XGetWindowProperty(display, xids[i],                                        atom("_NET_WM_STRUT_PARTIAL"), 0, 12, False, XA_CARDINAL,                                        &ret, &format, &nitems2, &after, &data2);            if (status == Success && ret == XA_CARDINAL && format == 32 && nitems2 == 12)            {                ulong* struts = (ulong*) data2;                QRect left(desktopGeometry.x(),                           desktopGeometry.y() + struts[4],                           struts[0],                           struts[5] - struts[4]);                if (available.intersects(left))                    available.setX(left.width());                QRect right(desktopGeometry.x() + desktopGeometry.width() - struts[1],                            desktopGeometry.y() + struts[6],                            struts[1],                            struts[7] - struts[6]);                if (available.intersects(right))                    available.setWidth(right.x() - available.x());                QRect top(desktopGeometry.x() + struts[8],                          desktopGeometry.y(),                          struts[9] - struts[8],                          struts[2]);                if (available.intersects(top))                    available.setY(top.height());                QRect bottom(desktopGeometry.x() + struts[10],                             desktopGeometry.y() + desktopGeometry.height() - struts[3],                             struts[11] - struts[10],                             struts[3]);                if (available.intersects(bottom))                    available.setHeight(bottom.y() - available.y());            }            if (data2)                XFree(data2);        }    }    if (data)        XFree(data);    return available;}
开发者ID:Icenowy,项目名称:libsubway,代码行数:79,


示例15: main

int main(int argc, char **argv){	Display *dpy;	Window w, quit, clearButton, drawButton;	Window root;    struct timespec wait;	int    screen;	unsigned long black, white;	GC       gc;	XEvent   e;    float t;    int isDraw;    int pointNum;    int i;    XPoint usrPoints[20];    XPoint bufPoints[20];    XPoint selectedPoints[20];    //*************************************init****    	dpy = XOpenDisplay("");    	root = DefaultRootWindow (dpy);	screen = DefaultScreen (dpy);	white = WhitePixel (dpy, screen);	black = BlackPixel (dpy, screen);    	w = XCreateSimpleWindow(dpy, root, 100, 100, WIDTH, HEIGHT, BORDER, black, white);        /* Make Buttons */	quit = XCreateSimpleWindow(dpy, w, 10, 3, 30, 12, BORDER, black, white);    clearButton = XCreateSimpleWindow(dpy, w, 52, 3, 37, 12, BORDER, black, white);    drawButton = XCreateSimpleWindow(dpy, w, 100, 3, 35, 12, BORDER, black, white);	gc = XCreateGC(dpy, w, 0, NULL);        pointNum = 0;    isDraw = 0;    t = 0;    wait.tv_sec = 0;    wait.tv_nsec = NANOTIME;        for (i = 0; i < 20; i++) {        usrPoints[i].x = 0;        usrPoints[i].y = 0;        bufPoints[i].x = 0;        bufPoints[i].y = 0;    }        //*********************************************    	XSelectInput(dpy, w, ButtonPressMask | ExposureMask);    XSelectInput(dpy, quit, ButtonPressMask);    XSelectInput(dpy, clearButton, ButtonPressMask);    XSelectInput(dpy, drawButton, ButtonPressMask);    	XMapWindow(dpy, w);	XMapSubwindows(dpy, w);    XSetForeground(dpy, gc, white);	XSetForeground(dpy, gc, black);    //*************************************loop****	while(1){        if(XEventsQueued(dpy, QueuedAfterReading)){            XDrawString(dpy, quit, gc, 4, 10, "Exit", 4);            XDrawString(dpy, clearButton, gc, 4, 10, "Clear", 5);            XDrawString(dpy, drawButton, gc, 4, 10, "Draw", 4);            //***********************************event****            XNextEvent(dpy, &e);            switch(e.type){                case ButtonPress :                     if (e.xany.window == quit) {                        return 0;                    } else if (e.xany.window == clearButton) {                        XClearWindow(dpy, w);                        t = 0;                        isDraw = 0;                        pointNum = 0;                    } else if (e.xany.window == drawButton) {                        if (!pointNum) break;                        isDraw = 1;                    } else {                        if (0 < t && t < 1) XClearWindow(dpy, w);                        selectedPoints[pointNum].x = e.xbutton.x;                        selectedPoints[pointNum].y = e.xbutton.y;                        bufPoints[pointNum] = selectedPoints[pointNum];                        pointNum++;                        drawPointDetail(dpy, w, gc, bufPoints, pointNum);                        isDraw = 0;                        t = 0;                    }                    break;                case Expose:                    drawPointDetail(dpy, w, gc, bufPoints, pointNum);                    isDraw = 0;                    t = 0;            }        } else {            //********************************animation****            if (t < 1 && isDraw) {//.........这里部分代码省略.........
开发者ID:mactkg,项目名称:xbeizer,代码行数:101,


示例16: glXQueryExtensionsString

void X11OpenGLWindow::enableOpenGL(){    if (forceOpenGL3)    { // Get the default screen's GLX extension list  const char *glxExts = glXQueryExtensionsString( m_data->m_dpy,                                                  DefaultScreen( m_data->m_dpy ) );  // NOTE: It is not necessary to create or make current to a context before  // calling glXGetProcAddressARB, unless we dynamically load OpenGL/GLX/X11  glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0;  glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)           glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB" );  GLXContext ctx = 0;  // Install an X error handler so the application won't exit if GL 3.0  // context allocation fails.  //  // Note this error handler is global.  All display connections in all threads  // of a process use the same error handler, so be sure to guard against other  // threads issuing X commands while this code is running.  ctxErrorOccurred = false;  int (*oldHandler)(Display*, XErrorEvent*) =         MyXSetErrorHandler(&ctxErrorHandler);  // Check for the GLX_ARB_create_context extension string and the function.  // If either is not present, use GLX 1.3 context creation method.  if ( !isExtensionSupported( glxExts, "GLX_ARB_create_context" ) ||       !glXCreateContextAttribsARB )  {    printf( "glXCreateContextAttribsARB() not found"            " ... using old-style GLX context/n" );    ctx = glXCreateNewContext( m_data->m_dpy, m_data->m_bestFbc, GLX_RGBA_TYPE, 0, True );  }  // If it does, try to get a GL 3.0 context!  else  {	 int context_attribs[] = {          GLX_CONTEXT_MAJOR_VERSION_ARB ,3,          GLX_CONTEXT_MINOR_VERSION_ARB, 2,          GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,          GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,None     };/*    int context_attribs[] =      {        GLX_CONTEXT_MAJOR_VERSION_ARB, 3,        GLX_CONTEXT_MINOR_VERSION_ARB, 2,        //GLX_CONTEXT_FLAGS_ARB        , GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,        None      };*/    printf( "Creating context/n" );    ctx = glXCreateContextAttribsARB( m_data->m_dpy, m_data->m_bestFbc, 0,                                      True, context_attribs );    // Sync to ensure any errors generated are processed.    MyXSync( m_data->m_dpy, False );    if ( !ctxErrorOccurred && ctx )      printf( "Created GL 3.0 context/n" );    else    {      // Couldn't create GL 3.0 context.  Fall back to old-style 2.x context.      // When a context version below 3.0 is requested, implementations will      // return the newest context version compatible with OpenGL versions less      // than version 3.0.      // GLX_CONTEXT_MAJOR_VERSION_ARB = 1      context_attribs[1] = 1;      // GLX_CONTEXT_MINOR_VERSION_ARB = 0      context_attribs[3] = 0;      ctxErrorOccurred = false;      printf( "Failed to create GL 3.0 context"              " ... using old-style GLX context/n" );      ctx = glXCreateContextAttribsARB( m_data->m_dpy, m_data->m_bestFbc, 0,                                        True, context_attribs );    }  }  // Sync to ensure any errors generated are processed.  MyXSync( m_data->m_dpy, False );  // Restore the original error handler  MyXSetErrorHandler( oldHandler );  if ( ctxErrorOccurred || !ctx )  {    printf( "Failed to create an OpenGL context/n" );    exit(1);  }  // Verifying that context is a direct context  if ( ! glXIsDirect ( m_data->m_dpy, ctx ) )//.........这里部分代码省略.........
开发者ID:Leboudin,项目名称:bullet3,代码行数:101,


示例17: GLW_SetMode

/*** GLW_SetMode*/int GLW_SetMode( const char *drivername, int mode, qboolean fullscreen ){  int attrib[] = {    GLX_RGBA,         // 0    GLX_RED_SIZE, 4,      // 1, 2    GLX_GREEN_SIZE, 4,      // 3, 4    GLX_BLUE_SIZE, 4,     // 5, 6    GLX_DOUBLEBUFFER,     // 7    GLX_DEPTH_SIZE, 1,      // 8, 9    GLX_STENCIL_SIZE, 1,    // 10, 11    None  };  // these match in the array#define ATTR_RED_IDX 2#define ATTR_GREEN_IDX 4#define ATTR_BLUE_IDX 6#define ATTR_DEPTH_IDX 9#define ATTR_STENCIL_IDX 11  Window root;  XVisualInfo *visinfo;  XSetWindowAttributes attr;  XSizeHints sizehints;  unsigned long mask;  int colorbits, depthbits, stencilbits;  int tcolorbits, tdepthbits, tstencilbits;  int dga_MajorVersion, dga_MinorVersion;  int actualWidth, actualHeight;  int i;  const char*   glstring; // bk001130 - from cvs1.17 (mkv)  ri.Printf( PRINT_ALL, "Initializing OpenGL display/n");  ri.Printf (PRINT_ALL, "...setting mode %d:", mode );  if ( !R_GetModeInfo( &glConfig.vidWidth, &glConfig.vidHeight, &glConfig.windowAspect, mode ) )  {    ri.Printf( PRINT_ALL, " invalid mode/n" );    return RSERR_INVALID_MODE;  }  ri.Printf( PRINT_ALL, " %d %d/n", glConfig.vidWidth, glConfig.vidHeight);  if (!(dpy = XOpenDisplay(NULL)))  {    fprintf(stderr, "Error couldn't open the X display/n");    return RSERR_INVALID_MODE;  }    scrnum = DefaultScreen(dpy);  root = RootWindow(dpy, scrnum);  actualWidth = glConfig.vidWidth;  actualHeight = glConfig.vidHeight;  // Get video mode list#ifdef HAVE_XF86DGA  if (!XF86VidModeQueryVersion(dpy, &vidmode_MajorVersion, &vidmode_MinorVersion))  {#endif /* HAVE_XF86DGA */    vidmode_ext = qfalse;#ifdef HAVE_XF86DGA  } else  {    ri.Printf(PRINT_ALL, "Using XFree86-VidModeExtension Version %d.%d/n",              vidmode_MajorVersion, vidmode_MinorVersion);    vidmode_ext = qtrue;  }#endif /* HAVE_XF86DGA */  // Check for DGA	  dga_MajorVersion = 0, dga_MinorVersion = 0;#ifdef HAVE_XF86DGA  if (in_dgamouse->value)  {    if (!XF86DGAQueryVersion(dpy, &dga_MajorVersion, &dga_MinorVersion))    {      // unable to query, probably not supported      ri.Printf( PRINT_ALL, "Failed to detect XF86DGA Mouse/n" );      ri.Cvar_Set( "in_dgamouse", "0" );    } else    {      ri.Printf( PRINT_ALL, "XF86DGA Mouse (Version %d.%d) initialized/n",                 dga_MajorVersion, dga_MinorVersion);    }  }#endif /* HAVE_XF86DGA */#ifdef HAVE_XF86DGA  if (vidmode_ext)  {    int best_fit, best_dist, dist, x, y;    XF86VidModeGetAllModeLines(dpy, scrnum, &num_vidmodes, &vidmodes);    // Are we going fullscreen?  If so, let's change video mode    if (fullscreen)    {      best_dist = 9999999;//.........这里部分代码省略.........
开发者ID:AlienHoboken,项目名称:Tremulous-W-Server,代码行数:101,


示例18: MyXOpenDisplay

void    X11OpenGLWindow::createWindow(const b3gWindowConstructionInfo& ci){    m_data->m_dpy = MyXOpenDisplay(NULL);    if(m_data->m_dpy == NULL) {        printf("/n/tcannot connect to X server/n/n");            exit(0);     }    m_data->m_root = DefaultRootWindow(m_data->m_dpy);#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONSGLboolean res = glewXInit();if (res==0){	printf("glewXInit OK/n");} else{	printf("glewXInit failed, exit/n");	exit(0);}#endif //GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS    if (ci.m_openglVersion < 3)    {        forceOpenGL3 = false;    }    if (forceOpenGL3)    {        int glxMinor, glxMajor;        if (!glXQueryVersion(m_data->m_dpy,&glxMajor,&glxMinor) || (((glxMajor==1)&&(glxMinor<3)) || (glxMajor<1)))        {            printf("Invalid GLX version: major %d, minor %d/n",glxMajor,glxMinor);            exit(0);        }        static int visual_attribs[] =            {              GLX_X_RENDERABLE    , True,              GLX_DRAWABLE_TYPE   , GLX_WINDOW_BIT,              GLX_RENDER_TYPE     , GLX_RGBA_BIT,              GLX_X_VISUAL_TYPE   , GLX_TRUE_COLOR,              GLX_RED_SIZE        , 8,              GLX_GREEN_SIZE      , 8,              GLX_BLUE_SIZE       , 8,              GLX_ALPHA_SIZE      , 8,              GLX_DEPTH_SIZE      , 24,              GLX_STENCIL_SIZE    , 8,              GLX_DOUBLEBUFFER    , True,              None            };            int fbcount;            GLXFBConfig* fbc = glXChooseFBConfig(m_data->m_dpy, DefaultScreen(m_data->m_dpy), visual_attribs, &fbcount);            if (!fbc)            {                printf( "Failed to retrieve a framebuffer config/n" );                exit(1);            }///don't use highest samples, it is really slow on some NVIDIA Quadro cards#ifdef USE_HIGHEST_SAMPLES            int best_fbc = -1, worst_fbc = -1, best_num_samp = -1, worst_num_samp = 999;            int i;            for (i=0; i<fbcount; ++i)            {	            XVisualInfo *vi = glXGetVisualFromFBConfig( m_data->m_dpy, fbc[i] );	            if ( vi )	            {	              int samp_buf, samples;	              glXGetFBConfigAttrib( m_data->m_dpy, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf );	              glXGetFBConfigAttrib( m_data->m_dpy, fbc[i], GLX_SAMPLES       , &samples  );	              //printf( "  Matching fbconfig %d, visual ID 0x%2x: SAMPLE_BUFFERS = %d,"	               //       " SAMPLES = %d/n",	                //      i, vi -> visualid, samp_buf, samples );	              if ( best_fbc < 0 || (samp_buf && (samples > best_num_samp)) )	                best_fbc = i, best_num_samp = samples;	              if ( worst_fbc < 0 || (!samp_buf || (samples < worst_num_samp)) )	                worst_fbc = i, worst_num_samp = samples;	            }	            MyXFree( vi );            }            m_data->m_bestFbc = fbc[ best_fbc ];#else	    m_data->m_bestFbc = *fbc;#endif            // Be sure to free the FBConfig list allocated by glXChooseFBConfig()            MyXFree( fbc );            m_data->m_vi = glXGetVisualFromFBConfig( m_data->m_dpy, m_data->m_bestFbc );            m_data->m_swa.colormap = m_data->m_cmap = MyXCreateColormap( m_data->m_dpy,                                                 RootWindow( m_data->m_dpy, m_data->m_vi->screen ),//.........这里部分代码省略.........
开发者ID:Leboudin,项目名称:bullet3,代码行数:101,


示例19: main

int main() {	XTextProperty title;	XEvent event; 	XSizeHints *hints;	XWMHints *wm_hints;	KeySym key;	Pixmap pix;	pthread_t thread;		/* grepare toPlot function */	spline_init();	/* visual routines */	int pressed_1[3] = {0, 0, 0};	// pressed state of button1: condition and coordinates	char *caption = "Interpolation";	char *dpy_str = getenv("DISPLAY");	fprintf(stderr, "Connecting to %s/t ", dpy_str);	dpy = XOpenDisplay(dpy_str);	if( !dpy ) {		fprintf(stderr, "Unable to connect/n");		exit(EXIT_FAILURE);	} else {		fprintf(stderr, "OK/n");	}	scr = DefaultScreen(dpy);	getColors();	width = 2 * DisplayWidth(dpy, scr) / 3;	height = 2 * DisplayHeight(dpy, scr) / 3;	win = XCreateSimpleWindow(dpy,			RootWindow(dpy, scr),			0, 0,			width, height,			0,			black, white			);	XStringListToTextProperty(&caption, 1, &title);	XSetWMName(dpy, win, &title);	XSetWMIconName(dpy, win, &title);	cont = XCreateGC(dpy, win, 0, NULL);	if( cont<0 ) {		fprintf(stderr, "XCReateGC: unable to set GC");		exit(EXIT_FAILURE);	}	/* making window unresizeable */	hints = XAllocSizeHints();	if( !hints ) {		fprintf(stderr, "XAllocSizeHints: out of memory");		exit(EXIT_FAILURE);	}	hints->flags = PMaxSize | PMinSize;	hints->min_width = width;	hints->min_height = height;	hints->max_width = width;	hints->max_height = height;	XSetWMNormalHints(dpy, win, hints);	XFree(hints);	/* setting icon */	pix = XCreateBitmapFromData(dpy, win, icon_bits, icon_width, icon_height);	if( !pix ) {		fprintf(stderr, "XCreateBitmapFromData: cannot create icon");		exit(EXIT_FAILURE);	}	wm_hints = XAllocWMHints(); 	if( !wm_hints ) {		fprintf(stderr, "XAllocWMHints: out of memory");		exit(EXIT_FAILURE);	}	wm_hints->flags = IconPixmapHint | StateHint | IconPositionHint;	wm_hints->icon_pixmap = pix;	wm_hints->initial_state = IconicState;	wm_hints->icon_x = 0;	wm_hints->icon_y = 0;	XSetWMHints(dpy, win, wm_hints);	XFree(wm_hints);		/* making window visible */	XMapWindow(dpy, win);	draw(2,1);	XSelectInput(dpy, win, ExposureMask | KeyPressMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask);	while( 1 ) {		XNextEvent(dpy, &event);		switch( event.type ) {//.........这里部分代码省略.........
开发者ID:andy722,项目名称:spline-xlib,代码行数:101,


示例20: defined

//.........这里部分代码省略.........  }    // Select an EGL configuration that matches the native window  m_config = configList[0];  EGLint* attribList = NULL;#ifdef EMPOWER  EGLint windowAttrs[3];  int windowIndex = 0;  windowAttrs[windowIndex++] = EGL_RENDER_BUFFER;  windowAttrs[windowIndex++] = EGL_BACK_BUFFER;  windowAttrs[windowIndex++] = EGL_NONE;  attribList = windowAttrs;#endif#ifdef HAS_OPENKODE  //CLog::Log(LOGDEBUG, "KD: kdCreateWindow");  m_kdWindow = kdCreateWindow(m_display, m_config, KD_NULL);  if (!m_kdWindow)  {    CLog::Log(LOGERROR, "Error creating native window");    return false;  }  //CLog::Log(LOGDEBUG, "KD: kdRealizeWindow");  if (kdRealizeWindow(m_kdWindow, &m_nativeWindow))  {    CLog::Log(LOGERROR, "Could not realize native window");    return false;  }#elif defined HAS_X11  int screen = DefaultScreen(m_x11Display);  XSetWindowAttributes windowAttributes;  windowAttributes.colormap     = DefaultColormap(m_x11Display, screen);  windowAttributes.border_pixel = 0;  windowAttributes.event_mask   = ExposureMask           |                                  VisibilityChangeMask   |                                  KeyPressMask           |                                  KeyReleaseMask         |                                  ButtonPressMask        |                                  ButtonReleaseMask      |                                  PointerMotionMask      |                                  StructureNotifyMask    |                                  SubstructureNotifyMask |                                  FocusChangeMask;  m_nativeWindow = (NativeWindowType) XCreateWindow( m_x11Display,                              RootWindow(m_x11Display, screen),                              0, 0,     // x/y position of top-left outside corner of the window                              res.iWidth, res.iHeight, // Width and height of window                              0,        // Border width                              DefaultDepth(m_x11Display, screen),                              InputOutput,                              DefaultVisual(m_x11Display, screen),                              CWBorderPixel | CWColormap | CWEventMask,                              &windowAttributes );  XSetStandardProperties(m_x11Display, (Window) m_nativeWindow, name, name, None, NULL, 0, NULL);  Atom wmDeleteMessage = XInternAtom(m_x11Display, "WM_DELETE_WINDOW", False);  XSetWMProtocols(m_x11Display, (Window) m_nativeWindow, &wmDeleteMessage, 1);  if (fullScreen && !SetFullScreen(fullScreen, res, false))
开发者ID:Kr0nZ,项目名称:boxee,代码行数:67,


示例21: _cogl_winsys_egl_onscreen_init

static CoglBool_cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,                                EGLConfig egl_config,                                CoglError **error){  CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);  CoglContext *context = framebuffer->context;  CoglDisplay *display = context->display;  CoglRenderer *renderer = display->renderer;  CoglRendererEGL *egl_renderer = renderer->winsys;  CoglXlibRenderer *xlib_renderer =    _cogl_xlib_renderer_get_data (renderer);  CoglOnscreenXlib *xlib_onscreen;  CoglOnscreenEGL *egl_onscreen = onscreen->winsys;  Window xwin;  /* FIXME: We need to explicitly Select for ConfigureNotify events.   * For foreign windows we need to be careful not to mess up any   * existing event mask.   * We need to document that for windows we create then toolkits   * must be careful not to clear event mask bits that we select.   */  /* XXX: Note we ignore the user's original width/height when   * given a foreign X window. */  if (onscreen->foreign_xid)    {      Status status;      CoglXlibTrapState state;      XWindowAttributes attr;      int xerror;      xwin = onscreen->foreign_xid;      _cogl_xlib_renderer_trap_errors (display->renderer, &state);      status = XGetWindowAttributes (xlib_renderer->xdpy, xwin, &attr);      xerror = _cogl_xlib_renderer_untrap_errors (display->renderer,                                                  &state);      if (status == 0 || xerror)        {          char message[1000];          XGetErrorText (xlib_renderer->xdpy, xerror,                         message, sizeof (message));          _cogl_set_error (error, COGL_WINSYS_ERROR,                       COGL_WINSYS_ERROR_CREATE_ONSCREEN,                       "Unable to query geometry of foreign "                       "xid 0x%08lX: %s",                       xwin, message);          return FALSE;        }      _cogl_framebuffer_winsys_update_size (framebuffer,                                            attr.width, attr.height);      /* Make sure the app selects for the events we require... */      onscreen->foreign_update_mask_callback (onscreen,                                              COGL_ONSCREEN_X11_EVENT_MASK,                                              onscreen->                                              foreign_update_mask_data);    }  else    {      int width;      int height;      CoglXlibTrapState state;      XVisualInfo *xvisinfo;      XSetWindowAttributes xattr;      unsigned long mask;      int xerror;      width = cogl_framebuffer_get_width (framebuffer);      height = cogl_framebuffer_get_height (framebuffer);      _cogl_xlib_renderer_trap_errors (display->renderer, &state);      xvisinfo = get_visual_info (display, egl_config);      if (xvisinfo == NULL)        {          _cogl_set_error (error, COGL_WINSYS_ERROR,                       COGL_WINSYS_ERROR_CREATE_ONSCREEN,                       "Unable to retrieve the X11 visual of context's "                       "fbconfig");          return FALSE;        }      /* window attributes */      xattr.background_pixel =        WhitePixel (xlib_renderer->xdpy,                    DefaultScreen (xlib_renderer->xdpy));      xattr.border_pixel = 0;      /* XXX: is this an X resource that we are leaking
C++ DefaultVisual函数代码示例
C++ DefaultRootWindow函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。