void print_externtype(const wasm_externtype_t* type) { switch (wasm_externtype_kind(type)) { case WASM_EXTERN_FUNC: { const wasm_functype_t* functype = wasm_externtype_as_functype_const(type); printf("func "); print_valtypes(wasm_functype_params(functype)); printf(" -> "); print_valtypes(wasm_functype_results(functype)); } break; case WASM_EXTERN_GLOBAL: { const wasm_globaltype_t* globaltype = wasm_externtype_as_globaltype_const(type); printf("global "); print_mutability(wasm_globaltype_mutability(globaltype)); printf(" "); print_valtype(wasm_globaltype_content(globaltype)); } break; case WASM_EXTERN_TABLE: { const wasm_tabletype_t* tabletype = wasm_externtype_as_tabletype_const(type); printf("table "); print_limits(wasm_tabletype_limits(tabletype)); printf(" "); print_valtype(wasm_tabletype_element(tabletype)); } break; case WASM_EXTERN_MEMORY: { const wasm_memorytype_t* memorytype = wasm_externtype_as_memorytype_const(type); printf("memory "); print_limits(wasm_memorytype_limits(memorytype)); } break; } }
static void print_chip_curr(const sensors_chip_name *name, const sensors_feature *feature, int label_size) { const sensors_subfeature *sf; double val; char *label; struct sensor_subfeature_data sensors[NUM_CURR_SENSORS]; struct sensor_subfeature_data alarms[NUM_CURR_ALARMS]; int sensor_count, alarm_count; if (!(label = sensors_get_label(name, feature))) { fprintf(stderr, "ERROR: Can't get label of feature %s!\n", feature->name); return; } print_label(label, label_size); free(label); sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_CURR_INPUT); if (sf && get_input_value(name, sf, &val) == 0) printf("%+6.2f A ", val); else printf(" N/A "); sensor_count = alarm_count = 0; get_sensor_limit_data(name, feature, current_sensors, sensors, &sensor_count, alarms, &alarm_count); print_limits(sensors, sensor_count, alarms, alarm_count, label_size, "%s = %+6.2f A"); printf("\n"); }
static void print_chip_power(const sensors_chip_name *name, const sensors_feature *feature, int label_size) { double val; const sensors_subfeature *sf; struct sensor_subfeature_data sensors[6]; struct sensor_subfeature_data alarms[3]; int sensor_count, alarm_count; char *label; const char *unit; int i; if (!(label = sensors_get_label(name, feature))) { fprintf(stderr, "ERROR: Can't get label of feature %s!\n", feature->name); return; } print_label(label, label_size); free(label); sensor_count = alarm_count = 0; /* Power sensors come in 2 flavors: instantaneous and averaged. To keep things simple, we assume that each sensor only implements one flavor. */ sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_POWER_INPUT); get_sensor_limit_data(name, feature, sf ? power_inst_sensors : power_avg_sensors, sensors, ARRAY_SIZE(sensors), &sensor_count, alarms, ARRAY_SIZE(alarms), &alarm_count); /* Add sensors common to both flavors. */ get_sensor_limit_data(name, feature, power_common_sensors, sensors, ARRAY_SIZE(sensors), &sensor_count, alarms, ARRAY_SIZE(alarms), &alarm_count); if (!sf) sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_POWER_AVERAGE); if (sf && get_input_value(name, sf, &val) == 0) { scale_value(&val, &unit); printf("%6.2f %sW ", val, unit); } else printf(" N/A "); for (i = 0; i < sensor_count; i++) scale_value(&sensors[i].value, &sensors[i].unit); print_limits(sensors, sensor_count, alarms, alarm_count, label_size, "%s = %6.2f %sW"); printf("\n"); }
int main (int argc, char *argv[]) { struct rlimit rlim; pid_t pid = 0; int status = 0, nchildren = 3, i; /* Print out all limits */ printf ("Printing out all limits for pid=%d:\n", getpid ()); print_limits (); /* change and printout the limit for core file size */ printf ("\nBefore Modification, this is RLIMIT_CORE:\n"); do_limit (RLIMIT_CORE, "RLIMIT_CORE", &rlim); rlim.rlim_cur = 8 * 1024 * 1024; printf ("I forked off a child with pid = %d\n", (int)pid); setrlimit (RLIMIT_CORE, &rlim); printf ("\nAfter Modification, this is RLIMIT_CORE:\n"); do_limit (RLIMIT_CORE, "RLIMIT_CORE", &rlim); /* fork off the nchildren */ fflush (stdout); for (i = 0; i < nchildren; i++) { pid = fork (); if (pid < 0) DEATH ("Failed in fork"); if (pid == 0) { /* any child */ printf ("\nIn child pid= %d this is RLIMIT_CORE:\n", (int)getpid ()); do_limit (RLIMIT_CORE, "RLIMIT_CORE", &rlim); fflush (stdout); sleep (3); exit (0); } } while (pid > 0) { /* parent */ pid = wait (&status); printf ("Parent got return on pid=%dn\n", (int)pid); } printf (" **************************************************** \n"); print_rusage (RUSAGE_SELF); print_rusage (RUSAGE_CHILDREN); exit (0); }
static Q3ListViewItem *print_screen_info(Q3ListViewItem *l1, Q3ListViewItem *after) { Q3ListViewItem *l2 = NULL, *l3 = NULL; if (after) l1= new Q3ListViewItem(l1,after,IsDirect ? i18n("Direct Rendering") : i18n("Indirect Rendering")); else l1= new Q3ListViewItem(l1,IsDirect ? i18n("Direct Rendering") : i18n("Indirect Rendering")); if (IsDirect) if (get_dri_device()) { l2 = new Q3ListViewItem(l1, i18n("3D Accelerator")); l2->setOpen(true); l3 = new Q3ListViewItem(l2, l3, i18n("Vendor"), dri_info.vendor); l3 = new Q3ListViewItem(l2, l3, i18n("Device"), dri_info.device); l3 = new Q3ListViewItem(l2, l3, i18n("Subvendor"), dri_info.subvendor); l3 = new Q3ListViewItem(l2, l3, i18n("Revision"), dri_info.rev); } else l2=new Q3ListViewItem(l1, l2, i18n("3D Accelerator"),i18n("unknown")); if (l2) l2 = new Q3ListViewItem(l1, l2, i18n("Driver")); else l2 = new Q3ListViewItem(l1, i18n("Driver")); l2->setOpen(true); l3 = new Q3ListViewItem(l2, i18n("Vendor"),gli.glVendor); l3 = new Q3ListViewItem(l2, l3, i18n("Renderer"), gli.glRenderer); l3 = new Q3ListViewItem(l2, l3, i18n("OpenGL version"), gli.glVersion); if (IsDirect) { if (dri_info.module.isEmpty()) dri_info.module = i18n("unknown"); l3 = new Q3ListViewItem(l2, l3, i18n("Kernel module"), dri_info.module); } l3 = new Q3ListViewItem(l2, l3, i18n("OpenGL extensions")); print_extension_list(gli.glExtensions,l3); l3 = new Q3ListViewItem(l2, l3, i18n("Implementation specific")); print_limits(l3, gli.glExtensions, strstr(gli.clientExtensions, "GLX_ARB_get_proc_address") != NULL); return l1; }
//-------------------------------------------------------------- void ofApp::keyPressed(int key){ if (key == ' '){ // todo: rewrite this with ofLog: FILE *fp; if((fp=freopen(ofToDataPath("openglReport.txt").c_str(), "w" ,stdout))==NULL) { cout << "Cannot open file.\n"; return; } cout << "-------------------------------------------------\n"; cout << "opengl info\n"; cout << "-------------------------------------------------\n"; printGLInfo(); cout << "-------------------------------------------------\n"; cout << "opengl limits\n"; cout << "-------------------------------------------------\n"; print_limits(); cout << "-------------------------------------------------\n"; cout << "shader limits\n"; cout << "-------------------------------------------------\n"; printShaderLimits(); cout << "-------------------------------------------------\n"; cout << "available extensions\n"; cout << "-------------------------------------------------\n"; const GLubyte * strExt; strExt = glGetString (GL_EXTENSIONS); //cout << "extensions: " << strExt << endl; print_extension_list((char *)strExt); //isShade = gluCheckExtension ((const GLubyte*)"GL_ARB_shading_language_100", strExt); cout << "-------------------------------------------------\n"; cout << "opengl calls available\n"; cout << "-------------------------------------------------\n"; printGlewInfo(); fclose(fp); #ifdef TARGET_WIN32 string command = "start " + ofToString(ofToDataPath("openglReport.txt").c_str()); #elif defined(TARGET_LINUX) string command = "xdg-open " + ofToString(ofToDataPath("openglReport.txt").c_str()); #else string command = "open " + ofToString(ofToDataPath("openglReport.txt").c_str()); #endif if (0 != system(command.c_str())){ ofLogWarning() << "Command " << command.c_str() << " did not return 0. Something may have gone wrong."; } } }
static void print_chip_power(const sensors_chip_name *name, const sensors_feature *feature, int label_size) { double val; const sensors_subfeature *sf; struct sensor_subfeature_data sensors[NUM_POWER_SENSORS]; struct sensor_subfeature_data alarms[NUM_POWER_ALARMS]; int sensor_count, alarm_count; char *label; const char *unit; int i; if (!(label = sensors_get_label(name, feature))) { fprintf(stderr, "ERROR: Can't get label of feature %s!\n", feature->name); return; } print_label(label, label_size); free(label); sensor_count = alarm_count = 0; /* * Power sensors come in 2 flavors: instantaneous and averaged. * Most devices only support one flavor, so we try to display the * average power if the instantaneous power attribute does not exist. * If both instantaneous power and average power are supported, * average power is displayed as limit. */ sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_POWER_INPUT); get_sensor_limit_data(name, feature, sf ? power_inst_sensors : power_avg_sensors, sensors, &sensor_count, alarms, &alarm_count); /* Add sensors common to both flavors. */ get_sensor_limit_data(name, feature, power_common_sensors, sensors, &sensor_count, alarms, &alarm_count); if (!sf) sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_POWER_AVERAGE); if (sf && get_input_value(name, sf, &val) == 0) { scale_value(&val, &unit); printf("%6.2f %sW%*s", val, unit, 2 - (int)strlen(unit), ""); } else printf(" N/A "); for (i = 0; i < sensor_count; i++) { /* * Unit is W and needs to be scaled for all attributes except * interval, which does not need to be scaled and is reported in * seconds. */ if (strcmp(sensors[i].name, "interval")) { char *tmpstr; tmpstr = alloca(4); scale_value(&sensors[i].value, &unit); snprintf(tmpstr, 4, "%sW", unit); sensors[i].unit = tmpstr; } else { sensors[i].unit = "s"; } } print_limits(sensors, sensor_count, alarms, alarm_count, label_size, "%s = %6.2f %s"); printf("\n"); }
static void print_chip_temp(const sensors_chip_name *name, const sensors_feature *feature, int label_size) { struct sensor_subfeature_data sensors[NUM_TEMP_SENSORS]; struct sensor_subfeature_data alarms[NUM_TEMP_ALARMS]; int sensor_count, alarm_count; const sensors_subfeature *sf; double val; char *label; int i; if (!(label = sensors_get_label(name, feature))) { fprintf(stderr, "ERROR: Can't get label of feature %s!\n", feature->name); return; } print_label(label, label_size); free(label); sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_TEMP_FAULT); if (sf && get_value(name, sf)) { printf(" FAULT "); } else { sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_TEMP_INPUT); if (sf && get_input_value(name, sf, &val) == 0) { get_input_value(name, sf, &val); if (fahrenheit) val = deg_ctof(val); printf("%+6.1f%s ", val, degstr); } else printf(" N/A "); } sensor_count = alarm_count = 0; get_sensor_limit_data(name, feature, temp_sensors, sensors, &sensor_count, alarms, &alarm_count); for (i = 0; i < sensor_count; i++) { if (fahrenheit) sensors[i].value = deg_ctof(sensors[i].value); sensors[i].unit = degstr; } print_limits(sensors, sensor_count, alarms, alarm_count, label_size, "%-4s = %+5.1f%s"); /* print out temperature sensor info */ sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_TEMP_TYPE); if (sf) { int sens = (int)get_value(name, sf); /* older kernels / drivers sometimes report a beta value for thermistors */ if (sens > 1000) sens = 4; printf(" sensor = %s", sens == 0 ? "disabled" : sens == 1 ? "CPU diode" : sens == 2 ? "transistor" : sens == 3 ? "thermal diode" : sens == 4 ? "thermistor" : sens == 5 ? "AMD AMDSI" : sens == 6 ? "Intel PECI" : "unknown"); } printf("\n"); }
static void print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits) { Window win; int attribSingle[] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None }; int attribDouble[] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, None }; XSetWindowAttributes attr; unsigned long mask; Window root; GLXContext ctx; XVisualInfo *visinfo; int width = 100, height = 100; root = RootWindow(dpy, scrnum); visinfo = glXChooseVisual(dpy, scrnum, attribSingle); if (!visinfo) { visinfo = glXChooseVisual(dpy, scrnum, attribDouble); if (!visinfo) { fprintf(stderr, "Error: couldn't find RGB GLX visual\n"); return; } } attr.background_pixel = 0; attr.border_pixel = 0; attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone); attr.event_mask = StructureNotifyMask | ExposureMask; mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; win = XCreateWindow(dpy, root, 0, 0, width, height, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr); ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect ); if (!ctx) { fprintf(stderr, "Error: glXCreateContext failed\n"); XDestroyWindow(dpy, win); return; } if (glXMakeCurrent(dpy, win, ctx)) { const char *serverVendor = glXQueryServerString(dpy, scrnum, GLX_VENDOR); const char *serverVersion = glXQueryServerString(dpy, scrnum, GLX_VERSION); const char *serverExtensions = glXQueryServerString(dpy, scrnum, GLX_EXTENSIONS); const char *clientVendor = glXGetClientString(dpy, GLX_VENDOR); const char *clientVersion = glXGetClientString(dpy, GLX_VERSION); const char *clientExtensions = glXGetClientString(dpy, GLX_EXTENSIONS); const char *glxExtensions = glXQueryExtensionsString(dpy, scrnum); const char *glVendor = (const char *) glGetString(GL_VENDOR); const char *glRenderer = (const char *) glGetString(GL_RENDERER); const char *glVersion = (const char *) glGetString(GL_VERSION); const char *glExtensions = (const char *) glGetString(GL_EXTENSIONS); int glxVersionMajor; int glxVersionMinor; char *displayName = NULL; char *colon = NULL, *period = NULL; #ifdef DO_GLU const char *gluVersion = (const char *) gluGetString(GLU_VERSION); const char *gluExtensions = (const char *) gluGetString(GLU_EXTENSIONS); #endif if (! glXQueryVersion( dpy, & glxVersionMajor, & glxVersionMinor )) { fprintf(stderr, "Error: glXQueryVersion failed\n"); exit(1); } /* Strip the screen number from the display name, if present. */ if (!(displayName = (char *) malloc(strlen(DisplayString(dpy)) + 1))) { fprintf(stderr, "Error: malloc() failed\n"); exit(1); } strcpy(displayName, DisplayString(dpy)); colon = strrchr(displayName, ':'); if (colon) { period = strchr(colon, '.'); if (period) *period = '\0'; } printf("display: %s screen: %d\n", displayName, scrnum); free(displayName); printf("direct rendering: %s\n", glXIsDirect(dpy, ctx) ? "Yes" : "No"); printf("server glx vendor string: %s\n", serverVendor); printf("server glx version string: %s\n", serverVersion); printf("server glx extensions:\n"); print_extension_list(serverExtensions); printf("client glx vendor string: %s\n", clientVendor); printf("client glx version string: %s\n", clientVersion); printf("client glx extensions:\n"); print_extension_list(clientExtensions); printf("GLX version: %u.%u\n", glxVersionMajor, glxVersionMinor); printf("GLX extensions:\n"); print_extension_list(glxExtensions); printf("OpenGL vendor string: %s\n", glVendor); printf("OpenGL renderer string: %s\n", glRenderer); printf("OpenGL version string: %s\n", glVersion); printf("OpenGL extensions:\n"); print_extension_list(glExtensions); if (limits) print_limits(); #ifdef DO_GLU printf("glu version: %s\n", gluVersion); printf("glu extensions:\n"); print_extension_list(gluExtensions); #endif } else { fprintf(stderr, "Error: glXMakeCurrent failed\n"); } glXDestroyContext(dpy, ctx); XDestroyWindow(dpy, win); }
//-------------------------------------------------------------- void testApp::keyPressed(int key){ if (key == ' '){ // todo: rewrite this with ofLog: FILE *fp; if((fp=freopen(ofToDataPath("openglReport.txt").c_str(), "w" ,stdout))==NULL) { printf("Cannot open file.\n"); return; } printf("-------------------------------------------------\n"); printf("opengl info\n"); printf("-------------------------------------------------\n"); printGLInfo(); printf("-------------------------------------------------\n"); printf("opengl limits\n"); printf("-------------------------------------------------\n"); print_limits(); printf("-------------------------------------------------\n"); printf("shader limits\n"); printf("-------------------------------------------------\n"); printShaderLimits(); printf("-------------------------------------------------\n"); printf("available extensions\n"); printf("-------------------------------------------------\n"); const GLubyte * strExt; strExt = glGetString (GL_EXTENSIONS); //cout << "extensions: " << strExt << endl; print_extension_list((char *)strExt); //isShade = gluCheckExtension ((const GLubyte*)"GL_ARB_shading_language_100", strExt); printf("-------------------------------------------------\n"); printf("opengl calls available\n"); printf("-------------------------------------------------\n"); printGlewInfo(); fclose(fp); string command = "open " + ofToString(ofToDataPath("openglReport.txt").c_str()); system(command.c_str()); } }
static void print_screen_info(HDC _hdc, GLboolean limits, GLboolean singleLine) { WNDCLASS wc; HWND win; HGLRC ctx; int visinfo; HDC hdc; PIXELFORMATDESCRIPTOR pfd; int version; const char *oglString = "OpenGL"; memset(&wc, 0, sizeof wc); wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.lpfnWndProc = WndProc; wc.lpszClassName = "wglinfo"; wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; RegisterClass(&wc); win = CreateWindowEx(0, wc.lpszClassName, "wglinfo", WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, wc.hInstance, NULL); if (!win) { fprintf(stderr, "Couldn't create window\n"); return; } hdc = GetDC(win); if (!hdc) { fprintf(stderr, "Couldn't obtain HDC\n"); return; } pfd.cColorBits = 3; pfd.cRedBits = 1; pfd.cGreenBits = 1; pfd.cBlueBits = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; pfd.iLayerType = PFD_MAIN_PLANE; pfd.iPixelType = PFD_TYPE_RGBA; pfd.nSize = sizeof(pfd); pfd.nVersion = 1; visinfo = ChoosePixelFormat(hdc, &pfd); if (!visinfo) { pfd.dwFlags |= PFD_DOUBLEBUFFER; visinfo = ChoosePixelFormat(hdc, &pfd); } if (!visinfo) { fprintf(stderr, "Error: couldn't find RGB WGL visual\n"); return; } SetPixelFormat(hdc, visinfo, &pfd); ctx = wglCreateContext(hdc); if (!ctx) { fprintf(stderr, "Error: wglCreateContext failed\n"); return; } if (wglMakeCurrent(hdc, ctx)) { #if defined(WGL_ARB_extensions_string) PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB_func = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB"); #endif const char *glVendor = (const char *) glGetString(GL_VENDOR); const char *glRenderer = (const char *) glGetString(GL_RENDERER); const char *glVersion = (const char *) glGetString(GL_VERSION); const char *glExtensions = (const char *) glGetString(GL_EXTENSIONS); struct ext_functions extfuncs; #if defined(WGL_ARB_extensions_string) if (wglGetExtensionsStringARB_func) { const char *wglExtensions = wglGetExtensionsStringARB_func(hdc); if(wglExtensions) { printf("WGL extensions:\n"); print_extension_list(wglExtensions, singleLine); } } #endif printf("OpenGL vendor string: %s\n", glVendor); printf("OpenGL renderer string: %s\n", glRenderer); printf("OpenGL version string: %s\n", glVersion); #ifdef GL_VERSION_2_0 if (glVersion[0] >= '2' && glVersion[1] == '.') { char *v = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION); printf("OpenGL shading language version string: %s\n", v); } #endif extfuncs.GetProgramivARB = (PFNGLGETPROGRAMIVARBPROC) wglGetProcAddress("glGetProgramivARB"); extfuncs.GetStringi = (PFNGLGETSTRINGIPROC) wglGetProcAddress("glGetStringi"); extfuncs.GetConvolutionParameteriv = (GETCONVOLUTIONPARAMETERIVPROC) wglGetProcAddress("glGetConvolutionParameteriv"); version = (glVersion[0] - '0') * 10 + (glVersion[2] - '0'); printf("OpenGL extensions:\n"); print_extension_list(glExtensions, singleLine); if (limits) { print_limits(glExtensions, oglString, version, &extfuncs); } } else { fprintf(stderr, "Error: wglMakeCurrent failed\n"); } DestroyWindow(win); }
static void print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits) { Window win; int attribSingle[] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None }; int attribDouble[] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, None }; XSetWindowAttributes attr; unsigned long mask; Window root; GLXContext ctx = NULL; XVisualInfo *visinfo; int width = 100, height = 100; root = RootWindow(dpy, scrnum); /* * Find a basic GLX visual. We'll then create a rendering context and * query various info strings. */ visinfo = glXChooseVisual(dpy, scrnum, attribSingle); if (!visinfo) visinfo = glXChooseVisual(dpy, scrnum, attribDouble); if (visinfo) ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect ); #ifdef GLX_VERSION_1_3 /* Try glXChooseFBConfig() if glXChooseVisual didn't work. * XXX when would that happen? */ if (!visinfo) { int fbAttribSingle[] = { GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, GL_FALSE, None }; int fbAttribDouble[] = { GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, GL_TRUE, None }; GLXFBConfig *configs = NULL; int nConfigs; configs = glXChooseFBConfig(dpy, scrnum, fbAttribSingle, &nConfigs); if (!configs) configs = glXChooseFBConfig(dpy, scrnum, fbAttribDouble, &nConfigs); if (configs) { visinfo = glXGetVisualFromFBConfig(dpy, configs[0]); ctx = glXCreateNewContext(dpy, configs[0], GLX_RGBA_TYPE, NULL, allowDirect); XFree(configs); } } #endif if (!visinfo) { fprintf(stderr, "Error: couldn't find RGB GLX visual or fbconfig\n"); return; } if (!ctx) { fprintf(stderr, "Error: glXCreateContext failed\n"); XFree(visinfo); return; } attr.background_pixel = 0; attr.border_pixel = 0; attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone); attr.event_mask = StructureNotifyMask | ExposureMask; mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; win = XCreateWindow(dpy, root, 0, 0, width, height, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr); if (glXMakeCurrent(dpy, win, ctx)) { const char *serverVendor = glXQueryServerString(dpy, scrnum, GLX_VENDOR); const char *serverVersion = glXQueryServerString(dpy, scrnum, GLX_VERSION); const char *serverExtensions = glXQueryServerString(dpy, scrnum, GLX_EXTENSIONS); const char *clientVendor = glXGetClientString(dpy, GLX_VENDOR); const char *clientVersion = glXGetClientString(dpy, GLX_VERSION); const char *clientExtensions = glXGetClientString(dpy, GLX_EXTENSIONS); const char *glxExtensions = glXQueryExtensionsString(dpy, scrnum); const char *glVendor = (const char *) glGetString(GL_VENDOR); const char *glRenderer = (const char *) glGetString(GL_RENDERER); const char *glVersion = (const char *) glGetString(GL_VERSION); const char *glExtensions = (const char *) glGetString(GL_EXTENSIONS); int glxVersionMajor; int glxVersionMinor; char *displayName = NULL; char *colon = NULL, *period = NULL; if (! glXQueryVersion( dpy, & glxVersionMajor, & glxVersionMinor )) { fprintf(stderr, "Error: glXQueryVersion failed\n"); exit(1); } /* Strip the screen number from the display name, if present. */ if (!(displayName = (char *) malloc(strlen(DisplayString(dpy)) + 1))) { fprintf(stderr, "Error: malloc() failed\n"); exit(1); } strcpy(displayName, DisplayString(dpy)); colon = strrchr(displayName, ':'); if (colon) { period = strchr(colon, '.'); if (period) *period = '\0'; } printf("display: %s screen: %d\n", displayName, scrnum); free(displayName); printf("direct rendering: "); if (glXIsDirect(dpy, ctx)) { printf("Yes\n"); } else { if (!allowDirect) { printf("No (-i specified)\n"); } else if (getenv("LIBGL_ALWAYS_INDIRECT")) { printf("No (LIBGL_ALWAYS_INDIRECT set)\n"); } else { printf("No (If you want to find out why, try setting " "LIBGL_DEBUG=verbose)\n"); } } printf("server glx vendor string: %s\n", serverVendor); printf("server glx version string: %s\n", serverVersion); printf("server glx extensions:\n"); print_extension_list(serverExtensions); printf("client glx vendor string: %s\n", clientVendor); printf("client glx version string: %s\n", clientVersion); printf("client glx extensions:\n"); print_extension_list(clientExtensions); printf("GLX version: %u.%u\n", glxVersionMajor, glxVersionMinor); printf("GLX extensions:\n"); print_extension_list(glxExtensions); printf("OpenGL vendor string: %s\n", glVendor); printf("OpenGL renderer string: %s\n", glRenderer); printf("OpenGL version string: %s\n", glVersion); #ifdef GL_VERSION_2_0 if (glVersion[0] >= '2' && glVersion[1] == '.') { char *v = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION); printf("OpenGL shading language version string: %s\n", v); } #endif printf("OpenGL extensions:\n"); print_extension_list(glExtensions); if (limits) print_limits(glExtensions); } else { fprintf(stderr, "Error: glXMakeCurrent failed\n"); } glXDestroyContext(dpy, ctx); XFree(visinfo); XDestroyWindow(dpy, win); }
int main() { // // Start by printing the values of the macros from float.h // std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" "Macros from <math.h>" << std::endl; #ifdef __BORLANDC__ // Turn off hardware exceptions so we don't just abort // when calling numeric_limits members. _control87(MCW_EM,MCW_EM); #endif PRINT_EXPRESSION(HUGE_VAL); #ifdef HUGE_VALF PRINT_EXPRESSION(HUGE_VALF); #endif #ifdef HUGE_VALL PRINT_EXPRESSION(HUGE_VALL); #endif #ifdef INFINITY PRINT_EXPRESSION(INFINITY); #endif PRINT_MACRO(NAN); PRINT_MACRO(FP_INFINITE); PRINT_MACRO(FP_NAN); PRINT_MACRO(FP_NORMAL); PRINT_MACRO(FP_SUBNORMAL); PRINT_MACRO(FP_ZERO); PRINT_MACRO(FP_FAST_FMA); PRINT_MACRO(FP_FAST_FMAF); PRINT_MACRO(FP_FAST_FMAL); PRINT_MACRO(FP_ILOGB0); PRINT_MACRO(FP_ILOGBNAN); PRINT_MACRO(MATH_ERRNO); PRINT_MACRO(MATH_ERREXCEPT); PRINT_EXPRESSION(FLT_MIN_10_EXP); PRINT_EXPRESSION(FLT_DIG); PRINT_EXPRESSION(FLT_MIN_EXP); PRINT_EXPRESSION(FLT_EPSILON); PRINT_EXPRESSION(FLT_RADIX); PRINT_EXPRESSION(FLT_MANT_DIG); PRINT_EXPRESSION(FLT_ROUNDS); PRINT_EXPRESSION(FLT_MAX); PRINT_EXPRESSION(FLT_MAX_10_EXP); PRINT_EXPRESSION(FLT_MAX_EXP); PRINT_EXPRESSION(FLT_MIN); PRINT_EXPRESSION(DBL_DIG); PRINT_EXPRESSION(DBL_MIN_EXP); PRINT_EXPRESSION(DBL_EPSILON); PRINT_EXPRESSION(DBL_MANT_DIG); PRINT_EXPRESSION(DBL_MAX); PRINT_EXPRESSION(DBL_MIN); PRINT_EXPRESSION(DBL_MAX_10_EXP); PRINT_EXPRESSION(DBL_MAX_EXP); PRINT_EXPRESSION(DBL_MIN_10_EXP); PRINT_EXPRESSION(LDBL_MAX_10_EXP); PRINT_EXPRESSION(LDBL_MAX_EXP); PRINT_EXPRESSION(LDBL_MIN); PRINT_EXPRESSION(LDBL_MIN_10_EXP); PRINT_EXPRESSION(LDBL_DIG); PRINT_EXPRESSION(LDBL_MIN_EXP); PRINT_EXPRESSION(LDBL_EPSILON); PRINT_EXPRESSION(LDBL_MANT_DIG); PRINT_EXPRESSION(LDBL_MAX); std::cout << std::endl; // // print out numeric_limits info: // print_limits(float(0), "float"); print_limits(double(0), "double"); print_limits((long double)(0), "long double"); // // print out function overload information: // test_overloads(float(0), "float"); test_overloads(double(0), "double"); test_overloads((long double)(0), "long double"); return 0; }
static Bool print_screen_info(Display *dpy, int scrnum, Bool allowDirect, Bool coreProfile, Bool es2Profile, Bool limits, Bool singleLine, Bool coreWorked) { Window win; XSetWindowAttributes attr; unsigned long mask; Window root; GLXContext ctx = NULL; XVisualInfo *visinfo; int width = 100, height = 100; GLXFBConfig *fbconfigs; const char *oglstring = coreProfile ? "OpenGL core profile" : es2Profile ? "OpenGL ES profile" : "OpenGL"; root = RootWindow(dpy, scrnum); /* * Choose FBConfig or XVisualInfo and create a context. */ fbconfigs = choose_fb_config(dpy, scrnum); if (fbconfigs) { ctx = create_context_with_config(dpy, fbconfigs[0], coreProfile, es2Profile, allowDirect); if (!ctx && allowDirect && !coreProfile) { /* try indirect */ ctx = create_context_with_config(dpy, fbconfigs[0], coreProfile, es2Profile, False); } visinfo = glXGetVisualFromFBConfig(dpy, fbconfigs[0]); XFree(fbconfigs); } else if (!coreProfile && !es2Profile) { visinfo = choose_xvisinfo(dpy, scrnum); if (visinfo) ctx = glXCreateContext(dpy, visinfo, NULL, allowDirect); } else visinfo = NULL; if (!visinfo && !coreProfile && !es2Profile) { fprintf(stderr, "Error: couldn't find RGB GLX visual or fbconfig\n"); return False; } if (!ctx) { if (!coreProfile && !es2Profile) fprintf(stderr, "Error: glXCreateContext failed\n"); XFree(visinfo); return False; } /* * Create a window so that we can just bind the context. */ attr.background_pixel = 0; attr.border_pixel = 0; attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone); attr.event_mask = StructureNotifyMask | ExposureMask; mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; win = XCreateWindow(dpy, root, 0, 0, width, height, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr); if (glXMakeCurrent(dpy, win, ctx)) { const char *serverVendor = glXQueryServerString(dpy, scrnum, GLX_VENDOR); const char *serverVersion = glXQueryServerString(dpy, scrnum, GLX_VERSION); const char *serverExtensions = glXQueryServerString(dpy, scrnum, GLX_EXTENSIONS); const char *clientVendor = glXGetClientString(dpy, GLX_VENDOR); const char *clientVersion = glXGetClientString(dpy, GLX_VERSION); const char *clientExtensions = glXGetClientString(dpy, GLX_EXTENSIONS); const char *glxExtensions = glXQueryExtensionsString(dpy, scrnum); const char *glVendor = (const char *) glGetString(GL_VENDOR); const char *glRenderer = (const char *) glGetString(GL_RENDERER); const char *glVersion = (const char *) glGetString(GL_VERSION); char *glExtensions; int glxVersionMajor; int glxVersionMinor; char *displayName = NULL; char *colon = NULL, *period = NULL; struct ext_functions extfuncs; CheckError(__LINE__); /* Get some ext functions */ extfuncs.GetProgramivARB = (GETPROGRAMIVARBPROC) glXGetProcAddressARB((GLubyte *) "glGetProgramivARB"); extfuncs.GetStringi = (GETSTRINGIPROC) glXGetProcAddressARB((GLubyte *) "glGetStringi"); extfuncs.GetConvolutionParameteriv = (GETCONVOLUTIONPARAMETERIVPROC) glXGetProcAddressARB((GLubyte *) "glGetConvolutionParameteriv"); /* Get list of GL extensions */ if (coreProfile) { glExtensions = build_core_profile_extension_list(&extfuncs); } else { glExtensions = (char *) glGetString(GL_EXTENSIONS); } CheckError(__LINE__); if (! glXQueryVersion( dpy, & glxVersionMajor, & glxVersionMinor )) { fprintf(stderr, "Error: glXQueryVersion failed\n"); exit(1); } if (!coreWorked) { /* Strip the screen number from the display name, if present. */ if (!(displayName = (char *) malloc(strlen(DisplayString(dpy)) + 1))) { fprintf(stderr, "Error: malloc() failed\n"); exit(1); } strcpy(displayName, DisplayString(dpy)); colon = strrchr(displayName, ':'); if (colon) { period = strchr(colon, '.'); if (period) *period = '\0'; } printf("display: %s screen: %d\n", displayName, scrnum); free(displayName); printf("direct rendering: "); if (glXIsDirect(dpy, ctx)) { printf("Yes\n"); } else { if (!allowDirect) { printf("No (-i specified)\n"); } else if (getenv("LIBGL_ALWAYS_INDIRECT")) { printf("No (LIBGL_ALWAYS_INDIRECT set)\n"); } else { printf("No (If you want to find out why, try setting " "LIBGL_DEBUG=verbose)\n"); } } printf("server glx vendor string: %s\n", serverVendor); printf("server glx version string: %s\n", serverVersion); printf("server glx extensions:\n"); print_extension_list(serverExtensions, singleLine); printf("client glx vendor string: %s\n", clientVendor); printf("client glx version string: %s\n", clientVersion); printf("client glx extensions:\n"); print_extension_list(clientExtensions, singleLine); printf("GLX version: %u.%u\n", glxVersionMajor, glxVersionMinor); printf("GLX extensions:\n"); print_extension_list(glxExtensions, singleLine); printf("OpenGL vendor string: %s\n", glVendor); printf("OpenGL renderer string: %s\n", glRenderer); } else printf("\n"); printf("%s version string: %s\n", oglstring, glVersion); version = (glVersion[0] - '0') * 10 + (glVersion[2] - '0'); CheckError(__LINE__); #ifdef GL_VERSION_2_0 if (version >= 20) { char *v = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION); printf("%s shading language version string: %s\n", oglstring, v); } #endif CheckError(__LINE__); #ifdef GL_VERSION_3_0 if (version >= 30 && !es2Profile) { GLint flags; glGetIntegerv(GL_CONTEXT_FLAGS, &flags); printf("%s context flags: %s\n", oglstring, context_flags_string(flags)); } #endif CheckError(__LINE__); #ifdef GL_VERSION_3_2 if (version >= 32 && !es2Profile) { GLint mask; glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask); printf("%s profile mask: %s\n", oglstring, profile_mask_string(mask)); } #endif CheckError(__LINE__); printf("%s extensions:\n", oglstring); print_extension_list(glExtensions, singleLine); CheckError(__LINE__); if (limits) { print_limits(glExtensions, oglstring, version, &extfuncs); } if (coreProfile) free(glExtensions); } else { fprintf(stderr, "Error: glXMakeCurrent failed\n"); } glXDestroyContext(dpy, ctx); XFree(visinfo); XDestroyWindow(dpy, win); XSync(dpy, 1); return True; }