MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / offScreenTest

Function offScreenTest

server/eglxfakerut.cpp:801–996  ·  view source on GitHub ↗

Test off-screen rendering

Source from the content-addressed store, hash-verified

799
800// Test off-screen rendering
801int offScreenTest(void)
802{
803 Display *dpy = NULL; Window win = 0;
804 EGLDisplay edpy = 0;
805 EGLSurface pb = 0, winSurface = 0;
806 int dpyw, dpyh, lastFrame = 0, retval = 1;
807 int cfgAttribs[] = { EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_WINDOW_BIT,
808 EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_STENCIL_SIZE, 0,
809 EGL_NONE };
810 XVisualInfo *vis = NULL; EGLConfig config = 0;
811 EGLint nc = 0;
812 EGLContext ctx = 0;
813 XSetWindowAttributes swa;
814 GLuint fbo = 0, rbo = 0;
815 TestColor clr(0);
816
817 printf("Off-screen rendering test\n\n");
818
819 try
820 {
821 if(!(dpy = XOpenDisplay(0))) THROW("Could not open display");
822 dpyw = DisplayWidth(dpy, DefaultScreen(dpy));
823 dpyh = DisplayHeight(dpy, DefaultScreen(dpy));
824
825 if((edpy = eglGetDisplay(dpy)) == EGL_NO_DISPLAY)
826 THROW_EGL("eglGetDisplay()");
827 if(!eglInitialize(edpy, NULL, NULL))
828 THROW_EGL("eglInitialize()");
829
830 if(!eglChooseConfig(edpy, cfgAttribs, &config, 1, &nc))
831 THROW_EGL("eglChooseConfig()");
832 int cfgid = EGLConfigID(edpy, config);
833 if((vis = getVisualFromConfig(dpy, DefaultScreen(dpy), edpy,
834 config)) == NULL)
835 THROW("Could not find matching visual for config");
836
837 Window root = RootWindow(dpy, DefaultScreen(dpy));
838 swa.colormap = XCreateColormap(dpy, root, vis->visual, AllocNone);
839 swa.border_pixel = 0;
840 swa.background_pixel = 0;
841 swa.event_mask = 0;
842 if((win = XCreateWindow(dpy, root, 0, 0, dpyw / 2, dpyh / 2, 0, vis->depth,
843 InputOutput, vis->visual, CWBorderPixel | CWColormap | CWEventMask,
844 &swa)) == 0)
845 THROW("Could not create window");
846 XMapWindow(dpy, win);
847 if((winSurface = eglCreateWindowSurface(edpy, config, win, NULL)) == 0)
848 THROW_EGL("eglCreateWindowSurface()");
849 checkSurface(edpy, winSurface, dpyw / 2, dpyh / 2, -1, cfgid);
850
851 int pbAttribs[] = { EGL_WIDTH, dpyw / 2, EGL_HEIGHT, dpyh / 2, EGL_NONE };
852 if((pb = eglCreatePbufferSurface(edpy, config, pbAttribs)) == 0)
853 THROW_EGL("eglCreatePbufferSurface()");
854 checkSurface(edpy, pb, dpyw / 2, dpyh / 2, 0, cfgid);
855
856 if(!eglBindAPI(EGL_OPENGL_API))
857 THROW_EGL("eglBindAPI()");
858 if(!(ctx = eglCreateContext(edpy, config, NULL, NULL)))

Callers 1

mainFunction · 0.70

Calls 15

XOpenDisplayFunction · 0.85
eglGetDisplayFunction · 0.85
eglInitializeFunction · 0.85
eglChooseConfigFunction · 0.85
XCreateWindowFunction · 0.85
eglCreateWindowSurfaceFunction · 0.85
checkSurfaceFunction · 0.85
eglCreatePbufferSurfaceFunction · 0.85
eglCreateContextFunction · 0.85
eglMakeCurrentFunction · 0.85
eglSwapBuffersFunction · 0.85
checkReadbackStateFunction · 0.85

Tested by

no test coverage detected