/* Copyright (c) Mark J. Kilgard, 1996. */
/* This program is freely distributable without licensing fees
and is provided without guarantee or warrantee expressed or
implied. This program is -not- in the public domain. */
#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>
#include <GL/glx.h>
static char *ClassOf(int c);
static char *Format(int n, int w);
void
main(int argc, char *argv[])
{
Display *dpy;
XVisualInfo match, *visualList, *vi, *visualToTry;
int errorBase, eventBase, major, minor, found;
int glxCapable, bufferSize, level, renderType, doubleBuffer, stereo,
auxBuffers, redSize, greenSize, blueSize, alphaSize, depthSize,
stencilSize, acRedSize, acGreenSize, acBlueSize, acAlphaSize;
dpy = XOpenDisplay(NULL);
if (!dpy) {
fprintf(stderr, "Could not connect to %s.\n", XDisplayName(NULL));
exit(1);
}
if (glXQueryExtension(dpy, &errorBase, &eventBase) == False) {
fprintf(stderr, "OpenGL not supported by X server.\n");
exit(1);
}
glXQueryVersion(dpy, &major, &minor);
printf("display: %s\n", XDisplayName(NULL));
printf("using GLX version: %d.%d\n\n", major, minor);
match.screen = DefaultScreen(dpy);
visualList = XGetVisualInfo(dpy, VisualScreenMask, &match, &found);
printf(" visual bf lv rg d st r g b a ax dp st accum buffs\n");
printf(" id dep cl sz l ci b ro sz sz sz sz bf th cl r g b a\n");
printf("-------------------------------------------------------------\n");
visualToTry = NULL;
for(vi = visualList; found > 0; found--, vi++) {
glXGetConfig(dpy, vi, GLX_USE_GL, &glxCapable);
if (glxCapable) {
printf("0x%x %2d %s", vi->visualid, vi->depth, ClassOf(vi->class));
glXGetConfig(dpy, vi, GLX_BUFFER_SIZE, &bufferSize);
glXGetConfig(dpy, vi, GLX_LEVEL, &level);
glXGetConfig(dpy, vi, GLX_RGBA, &renderType);
glXGetConfig(dpy, vi, GLX_DOUBLEBUFFER, &doubleBuffer);
glXGetConfig(dpy, vi, GLX_STEREO, &stereo);
glXGetConfig(dpy, vi, GLX_AUX_BUFFERS, &auxBuffers);
glXGetConfig(dpy, vi, GLX_RED_SIZE, &redSize);
glXGetConfig(dpy, vi, GLX_GREEN_SIZE, &greenSize);
glXGetConfig(dpy, vi, GLX_BLUE_SIZE, &blueSize);
glXGetConfig(dpy, vi, GLX_ALPHA_SIZE, &alphaSize);
glXGetConfig(dpy, vi, GLX_DEPTH_SIZE, &depthSize);
glXGetConfig(dpy, vi, GLX_STENCIL_SIZE, &stencilSize);
glXGetConfig(dpy, vi, GLX_ACCUM_RED_SIZE, &acRedSize);
glXGetConfig(dpy, vi, GLX_ACCUM_GREEN_SIZE, &acGreenSize);
glXGetConfig(dpy, vi, GLX_ACCUM_BLUE_SIZE, &acBlueSize);
glXGetConfig(dpy, vi, GLX_ACCUM_ALPHA_SIZE, &acAlphaSize);
printf(" %2s %2s %1s %1s %1s ",
Format(bufferSize, 2), Format(level, 2),
renderType ? "r" : "c",
doubleBuffer ? "y" : ".",
stereo ? "y" : ".");
printf("%2s %2s %2s %2s ",
Format(redSize, 2), Format(greenSize, 2),
Format(blueSize, 2), Format(alphaSize, 2));
printf("%2s %2s %2s %2s %2s %2s %2s",
Format(auxBuffers, 2), Format(depthSize, 2), Format(stencilSize, 2),
Format(acRedSize, 2), Format(acGreenSize, 2),
Format(acBlueSize, 2), Format(acAlphaSize, 2));
printf("\n");
visualToTry = vi;
}
}
if (visualToTry) {
GLXContext context;
Window window;
Colormap colormap;
XSetWindowAttributes swa;
context = glXCreateContext(dpy, visualToTry, 0, GL_TRUE);
colormap = XCreateColormap(dpy,
RootWindow(dpy, visualToTry->screen),
visualToTry->visual, AllocNone);
swa.colormap = colormap;
swa.border_pixel = 0;
window = XCreateWindow(dpy, RootWindow(dpy, visualToTry->screen), 0, 0, 100, 100,
0, visualToTry->depth, InputOutput, visualToTry->visual,
CWBorderPixel | CWColormap, &swa);
glXMakeCurrent(dpy, window, context);
printf("\n");
printf("OpenGL vendor string: %s\n", glGetString(GL_VENDOR));
printf("OpenGL renderer string: %s\n", glGetString(GL_RENDERER));
printf("OpenGL version string: %s\n", glGetString(GL_VERSION));
if (glXIsDirect(dpy, context))
printf("direct rendering: supported\n");
printf( "GL extensions: '%s'\n\n", glGetString(GL_EXTENSIONS) );
#if defined(GLX_VERSION_1_1)
printf( "GLX extensions: '%s'\n\n", glXQueryExtensionsString( dpy, visualToTry->screen ) );
#endif
} else
printf("No GLX-capable visuals!\n");
XFree(visualList);
}
static char *
ClassOf(int c)
{
switch (c) {
case StaticGray: return "sg";
case GrayScale: return "gs";
case StaticColor: return "sc";
case PseudoColor: return "pc";
case TrueColor: return "tc";
case DirectColor: return "dc";
default: return "??";
}
}
static char *
Format(int n, int w)
{
static char buffer[256];
static int bufptr;
char *buf;
if (bufptr >= sizeof(buffer) - w)
bufptr = 0;
buf = buffer + bufptr;
if (n == 0)
sprintf(buf, "%*s", w, ".");
else
sprintf(buf, "%*d", w, n);
bufptr += w + 1;
return buf;
}
没有合适的资源?快使用搜索试试~ 我知道了~
76个qt+例子.+非常适合学习qt编程%2C-76+qt+example.+Qt+very+suitable+for+lear...
共2000个文件
obj:439个
cpp:410个
png:196个
4星 · 超过85%的资源 需积分: 11 103 下载量 168 浏览量
2009-11-18
15:41:53
上传
评论
收藏 8.11MB RAR 举报
温馨提示
76个qt+例子.+非常适合学习qt编程%2C-76+qt+example.+Qt+very+suitable+for+learning+programming%2C.rar
资源推荐
资源详情
资源评论
收起资源包目录
76个qt+例子.+非常适合学习qt编程%2C-76+qt+example.+Qt+very+suitable+for+learning+programming%2C.rar (2000个子文件)
helpdemo.adp 1KB
image.any 12KB
picture.any 545B
trolltech.bmp 29KB
qtlogo.bmp 17KB
gllogo.bmp 17KB
gllogo.bmp 17KB
qtlogo.bmp 17KB
flag.bmp 2KB
glxvisuals.c 5KB
sovlayerutil.c 5KB
fbm.c 5KB
sovinfo.c 3KB
dndbase.cpp 178KB
widgetsbase.cpp 154KB
wood.cpp 64KB
maindialog.cpp 57KB
gllandscape.cpp 24KB
qfileiconview.cpp 23KB
widgets.cpp 23KB
view.cpp 21KB
showimg.cpp 20KB
canvas.cpp 19KB
textedit.cpp 16KB
chartform.cpp 16KB
glteapots.cpp 15KB
qmake_image_collection.cpp 15KB
textedit.cpp 15KB
ftpmainwindow.cpp 14KB
options.cpp 13KB
xform.cpp 13KB
metal.cpp 13KB
gtetrix.cpp 12KB
scrollview.cpp 12KB
toplevel.cpp 12KB
dirview.cpp 12KB
application.cpp 12KB
qdragapp.cpp 12KB
moc_qfileiconview.cpp 11KB
moc_widgets.cpp 11KB
tictac.cpp 11KB
graph.cpp 10KB
centralwidget.cpp 10KB
helpwindow.cpp 10KB
qmag.cpp 10KB
qdir.cpp 10KB
distributor.cpp 10KB
main.cpp 9KB
helpwindow.cpp 9KB
menu.cpp 9KB
qwerty.cpp 9KB
gllandscapeviewer.cpp 9KB
application.cpp 9KB
moc_canvas.cpp 9KB
moc_qdir.cpp 9KB
patterns.cpp 8KB
gear.cpp 8KB
application.cpp 8KB
drawdemo.cpp 8KB
progress.cpp 8KB
main.cpp 8KB
listviews.cpp 8KB
gearwidget.cpp 8KB
glgear.cpp 8KB
lineedits.cpp 8KB
trayicon_win.cpp 7KB
nntp.cpp 7KB
moc_textedit.cpp 7KB
prodcons.cpp 7KB
moc_application.cpp 7KB
moc_gllandscape.cpp 7KB
wizard.cpp 7KB
moc_server.cpp 7KB
moc_tictac.cpp 7KB
moc_textedit.cpp 7KB
moc_display.cpp 7KB
moc_main.cpp 7KB
styledbutton.cpp 7KB
qthumbwheel.cpp 7KB
chartform_canvas.cpp 7KB
glbox.cpp 6KB
moc_qtetrixb.cpp 6KB
glworkspace.cpp 6KB
aticatac.cpp 6KB
setdataform.cpp 6KB
moc_glcontrolwidget.cpp 6KB
themes.cpp 6KB
regexptester.cpp 6KB
gltexobj.cpp 6KB
globjwin.cpp 6KB
tpiece.cpp 6KB
moc_ftpmainwindow.cpp 6KB
mainwindow.cpp 6KB
moc_trayicon.cpp 6KB
moc_showimg.cpp 6KB
dnd.cpp 6KB
gltexobj.cpp 6KB
qtetrixb.cpp 6KB
moc_qtetrix.cpp 6KB
i18n.cpp 6KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- 义甬君2011-10-24一般,有些可用
zhonghuaweixu
- 粉丝: 5
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- keil2 + proteus + 8051.exe
- 1961ee27df03bd4595d28e24b00dde4e_744c805f7e4fb4d40fa3f695bfbab035_8(1).c
- mediapipe-0.9.0.1-cp37-cp37m-win-amd64.whl.zip
- windows注册表编辑工具
- mediapipe-0.9.0.1-cp37-cp37m-win-amd64.whl.zip
- 校园通行码预约管理系统20240522075502
- 车类型数据集6250张VOC+YOLO格式.zip
- The PyTorch implementation of STGCN.STGCN-main.zip
- 092300108.cpp
- 车类型数据集6000张VOC+YOLO格式.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功