#include "core_glxopengl.h" CoreOpenGL::CoreOpenGL(char *title,unsigned int width,unsigned int height,int colorsize,int depthsize,int flags): Core(title,width,height,colorsize,depthsize,flags) { dpy=XOpenDisplay(0); screen=DefaultScreen(dpy); } CoreOpenGL::~CoreOpenGL() { XCloseDisplay(dpy); } static int attribs_16bit[]= { GLX_DOUBLEBUFFER, GLX_RGBA, GLX_RED_SIZE,4, GLX_GREEN_SIZE,4, GLX_BLUE_SIZE,4, GLX_ALPHA_SIZE,4, GLX_DEPTH_SIZE,16, None }; static int attribs_32bit[]= { GLX_DOUBLEBUFFER, GLX_RGBA, GLX_RED_SIZE,8, GLX_GREEN_SIZE,8, GLX_BLUE_SIZE,8, GLX_ALPHA_SIZE,8, GLX_DEPTH_SIZE,24, None }; bool CoreOpenGL::Start() { XVisualInfo *vi; XF86VidModeModeInfo **modes; if (flags&RAVEN_FULLSCREEN) { int modeNum; XF86VidModeGetAllModeLines(dpy,screen,&modeNum,&modes); deskMode=*modes[0]; best_mode=0; for (register int i=0; ihdisplay==width)&&(modes[i]->vdisplay==height)) best_mode=i; } } modedepth=colorsize>depthsize?colorsize:depthsize; switch (modedepth) { case 16: case 24: vi=glXChooseVisual(dpy,screen,attribs_16bit); if (vi==NULL) return 0; break; case 32: vi=glXChooseVisual(dpy,screen,attribs_32bit); if (vi==NULL) return 0; break; default: return false; } int glxMajorVersion,glxMinorVersion; int vidModeMajorVersion,vidModeMinorVersion; glXQueryVersion(dpy,&glxMajorVersion,&glxMinorVersion); cout<<"GLX Version: "<screen),vi->visual,AllocNone); attr.colormap=cmap; attr.border_pixel=0; if (flags&RAVEN_FULLSCREEN) { XF86VidModeSwitchToMode(dpy, screen, modes[best_mode]); XF86VidModeSetViewPort(dpy, screen, 0, 0); int dpyWidth = modes[best_mode]->hdisplay; int dpyHeight = modes[best_mode]->vdisplay; cout<<"Size: "<screen), 0, 0, dpyWidth, dpyHeight, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &attr); XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0); XMapRaised(dpy, win); XGrabKeyboard(dpy, win, True, GrabModeAsync, GrabModeAsync, CurrentTime); XGrabPointer(dpy, win, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, win, None, CurrentTime); } else { /* create a window in window mode*/ attr.override_redirect=1; attr.event_mask=ExposureMask|VisibilityChangeMask|KeyPressMask| KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask| StructureNotifyMask|SubstructureNotifyMask|FocusChangeMask; win = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, width,height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &attr); /* only set window title and handle wm_delete_events if in windowed mode */ Atom wmDelete=XInternAtom(dpy, "WM_DELETE_WINDOW", True); XSetWMProtocols(dpy, win, &wmDelete, 1); XSetStandardProperties(dpy, win, title,title, None, NULL, 0, NULL); XMapRaised(dpy, win); } /* connect the glx-context to the window */ Window winDummy; unsigned int borderDummy,cs_temp; int dummy_x,dummy_y; glXMakeCurrent(dpy, win, ctx); XGetGeometry(dpy, win, &winDummy, &dummy_x, &dummy_y, &width, &height, &borderDummy, &cs_temp); colorsize=cs_temp; cout<<"Depth: "<0) { XNextEvent(dpy,&event); switch (event.type) { case Expose: if (event.xexpose.count!=0) break; break; case ConfigureNotify: if ((event.xconfigure.width!=(int)width) || (event.xconfigure.height!=(int)height)) { width=event.xconfigure.width; height=event.xconfigure.height; isresized=true; } break; case ClientMessage: if (*XGetAtomName(dpy, event.xclient.message_type) == *"WM_PROTOCOLS") { cout<<"Terminate WM signal...\n"<