Scroll to navigation

GLXINTRO() GLXINTRO()

̾??

glXIntro - X ???????ɥ??????ƥ??? OpenGL ???Ȥ???ˡ?β???

????

OpenGL(¾?Υڡ????Ǥ? GL ?ȸƤ?)?ϡ?????ǽ?? 3 ?????ظ??????????Ǥ??롣 OpenGL ?? GLX ??ǽ??ĥ???̤??? X ???????ɥ??????ƥ??????Ѥ??뤳?Ȥ??? ???롣 X ?????Ф? GLX ??ǽ??ĥ?򥵥ݡ??Ȥ??Ƥ??뤫?ɤ??????Τ??????????䡢 ???ݡ??Ȥ??Ƥ????????ˤ??ΥС??????????Τ??????ˤϡ? glXQueryExtension ?? glXQueryVersion ???Ѥ??뤳?ȡ?

GLX ??ǽ??ĥ???б??????????Фϡ?OpenGL ?Υ????????󥰤˻Ȥ????Ȥ??Ǥ? ???ӥ??奢?????????ΤΥӥ??奢???Υ??֥??åȤȤ??????????롣 ???Τ褦?ʥӥ??奢?????Ȥä????????줿?ɥ??????֥??ϡ??????? X ???????? ???Ȥäƥ????????󥰤??뤳?Ȥ䡢?????? X ?ӥ??奢?????Ƥȸߴ??Ǥ???Ǥ ?դε?ǽ??ĥ?Υ??????????Ȥäƥ????????󥰤??뤳?Ȥ??Ǥ??롣

GLX ?ϡ?ɸ???Υ??顼?Хåե??ʳ??ˤ????Ĥ??ΥХåե????ɲä??ƥɥ????? ?֥?????ĥ???롣 ???????ΥХåե??ˤϡ????̥??顼?Хåե??????????顼?Хåե??? ?ǥץ??Хåե??? ???ƥ󥷥??Хåե??? ???顼?????塼???졼???????Хåե????ޤޤ??롣 ???????ΰ??????뤤?????Ƥϡ?OpenGL ?򥵥ݡ??Ȥ??Ƥ??뤽?줾???? X ?ӥ??? ?????˴ޤޤ??롣

OpenGL ???Ѥ??? X ?Υɥ??????֥????????????󥰤????ˤϤޤ???ɬ?פȤ??? ?? OpenGL ?Хåե????????????ӥ??奢???????򤷤ʤ????Фʤ??ʤ??? glXChooseVisual ???Ȥ??ȡ??????˹礦?ӥ??奢????????????ñ?˹Ԥ? ???Ȥ??Ǥ??롣 ?????????????äȺ٤??????椹??ɬ?פ??????С? XGetVisualInfo ?? glXGetConfig ???Ѥ??ơ????Ѳ?ǽ?????Ƥ? ?ӥ??奢?????椫?????????Ԥ????ȡ?

GLX ?????ƥ????Ȥ? X ?Υɥ??????֥??Τɤ??????????ˤ⡢???򤷤??ӥ??? ???????Ȥ????ȡ? GLX ?????ƥ????Ȥ? glXCreateContext ???Ȥä??????????ɥ??????֥? ?? XCreateWindow ?? glXCreateGLXPixmap ???Ȥä????????롣 ?Ǹ??ˡ?glXMakeCurrent ???Ȥäƥ????ƥ????Ȥȥɥ??????֥?????Ϣ ?դ??뤳?ȡ? ???Υ????ƥ????Ȥȥɥ??????֥??Υڥ??ϸ??ߤΥ????ƥ????Ȥȸ??ߤ? ?ɥ??????֥??ˤʤꡢ¾?ΰ??????????ꤷ?? glXMakeCurrent ???Ƥӽ? ???ޤǤϡ????Ƥ? OpenGL ?Υ??ޥ??ɤϤ??????Ѥ??롣

?????? X ???ޥ??ɤ??ȤäƤ⡢OpenGL ?Υ??ޥ??ɤ??ȤäƤ⸽?ߤΥɥ??????֥? ??????뤳?Ȥ??Ǥ??롣 ????????X ?? OpenGL ?Υ??ޥ??ɥ??ȥ꡼????Ʊ?????Ƥ??ʤ?( glXWaitGL, glXWaitX, XSync, glFlush ???ƤӽФ? ??ξ?Ԥζ?????????Ū???????????????Ͻ???)??

??

?ʲ??˼????Τϡ?RGBA ?????Ǥ??? OpenGL ?ȸߴ??? X ?Υ??????ɥ??????????? ?????򲫿??ǥ??ꥢ???뤿???κǾ??¤Υ????ɤǤ??롣 ?????????????????ɤǤ??뤬?????顼?????å??????????äƤ??ʤ??? ???????֤??ͤ? dpy, vi, cx, cmap, win ?? ???ƥ????å????٤??Ǥ??롣

#include <GL/glx.h> #include <GL/gl.h> #include <unistd.h>

static int attributeListSgl[] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None };

static int attributeListDbl[] = { GLX_RGBA, GLX_DOUBLE_BUFFER, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None };

static Bool WaitForNotify(Display *d, XEvent *e, char *arg) {
return (e->type == MapNotify) && (e->xmap.window == (Window)arg); }

int main(int argc, char **argv) {
Display *dpy;
XVisualInfo *vi;
Colormap cmap;
XSetWindowAttributes swa;
Window win;
GLXContext cx;
XEvent event;
int swap_flag = FALSE;


dpy = XOpenDisplay(0);


vi = glXChooseVisual(dpy, DefaultScreen(dpy), attributeListSgl);
if (vi == NULL) {
vi = glXChooseVisual(dpy, DefaultScreen(dpy), attributeListDbl);
swap_flag = TRUE;
}


cx = glXCreateContext(dpy, vi, 0, GL_TRUE);


cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone);


swa.colormap = cmap;
swa.border_pixel = 0;
swa.event_mask = StructureNotifyMask;
win = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 100, 100,
0, vi->depth, InputOutput, vi->visual,
CWBorderPixel|CWColormap|CWEventMask, &swa);
XMapWindow(dpy, win);
XIfEvent(dpy, &event, WaitForNotify, (char*)win);


glXMakeCurrent(dpy, win, cx);


glClearColor(1,1,0,1);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
if (swap_flag) glXSwapBuffers(dpy,win);


sleep(10); }

????

???顼?ޥåפ?ɬ??????????XCreateWindow ???Ϥ??ʤ????Фʤ??ʤ??? ?嵭?Υ????ץ륳???ɤ򻲾Ȥ??뤳?ȡ?

GLX ?????ƥ????Ȥϡ?OpenGL ?Υ??ޥ??ɤ??¹Ԥ?????????????????X ?? ?ɥ??????֥??˳??????Ƥʤ????Фʤ??ʤ??? ???ߤΥ????ƥ????Ȥȥɥ??????֥??Υڥ???̵?????֤? OpenGL ?Υ??ޥ??ɤ? ȯ?Ԥ????ȡ?????ư????̤?????Ǥ??롣

Ϫ?Х??٥??Ȥϡ????ꤵ?줿???????ɥ??˴ط??????????Ƥ??Хåե??? ???Ƥ????줿??ǽ???????ꡢ?????褷?ʤ????Фʤ??ʤ????Ȥ򼨤??? ?????Υ????ƥ??Ǥϡ??????Υӥ??奢?????????ΥХåե?(?㤨?Хǥץ??Х? ?ե?)?Ϻ???????????ɬ?פȤ??ʤ????Ȥ????뤬?????Τ褦?ʥХåե??????? ???????ʤ????Ȥ??????Ȥ??ƥץ??????????񤯤??Ȥϴְ㤤?Ǥ??롣

GLX ???ޥ??ɤ? XVisualInfo ??¤?Τ򰷤????ӥ??奢???ؤΥݥ??󥿤??ӥ??? ?????? ID ?򰷤????ȤϤʤ??? XVisualInfo ?ˤϡ?visual, visualID, screen, depth ???Ǥ?¾?? X ??ͭ?ξ??󤬴ޤޤ??롣

GLX ??ǽ??ĥ?λ???

???ݡ??Ȥ????Ƥ??????Ƥ? GLX ??ǽ??ĥ?ˤĤ??ơ??б??????????? glx.h ?? ???롣?ޤ???glXQueryExtensionsString ???֤???ĥ???Ƥ?ɽ??ʸ???? ?ˤϥȡ????󤬴ޤޤ??롣 ?㤨?С?EXT_visual_info ??ǽ??ĥ?????ݡ??Ȥ????Ƥ????С????Υȡ? ?????? glx.h ???????????Ƥ??ꡢglXQueryExtensionsString ???֤??? ĥ???Ƥ?ɽ??ʸ?????ˤ? EXT_visual_info ???????롣glx.h ?ˤ????? ?????ϡ???ĥ???б???????³?????饤?֥???????¸?ߤ??Ƥ??뤫?ɤ?????Ĵ?? ?뤿???˥????ѥ??????˻Ȥ????롣

OpenGL ???Τ??Τ⺣?ޤdz?ĥ?????Ƥ??Ƥ??롣?ܤ????? glIntro ???? ?Ȥ??뤳?ȡ?

GLX 1.1 ?? GLX 1.2

GLX 1.2 ?ϴ??˥??ݡ??Ȥ????Ƥ??롣?????? GLX 1.1 ?? GLX 1.0 ???Ф??Ƹ? ???ߴ????????ġ?

GLX 1.2 ?? OpenGL 1.1 ???б????????????ؿ??Ȥ??? glGetCurrentDisplay ??Ƴ???????Ƥ??롣

GLX 1.1 ?? OpenGL 1.0 ???б????????????ؿ??Ȥ??? glXQueryExtensionsString, glXQueryServerString, glXGetClientString ??Ƴ???????Ƥ??롣

?ɤΥС????????? GLX ?????Ѳ?ǽ?Ǥ??뤫???¹Ի???Ĵ?٤??ˤ? glQueryVersion ???Ѥ??뤳?ȡ?glQueryVersion ?ϥ????ФȤ??? ³?ˤ????ƥ??ݡ??Ȥ????Ƥ????С??????????֤????Ĥޤꡢ1.2 ???֤??줿?? ???ˤϡ??????Хȥ??饤?????Ȥ??????? GLX 1.2 ?򥵥ݡ??Ȥ??Ƥ????Ȥ??? ???ȤǤ??롣 GLX ?ΥС????????򥳥??ѥ???????Ĵ?٤뤳?Ȥ??Ǥ??롣 GLX 1.1 ?δؿ??????ݡ??Ȥ????Ƥ????? glx.h ???? GLX_VERSION_1_1 ?????? ?????Ƥ??ꡢGLX 1.2 ?δؿ??????ݡ??Ȥ????Ƥ????? GLX_VERSION_1_2 ???? ???????Ƥ??롣

??Ϣ????

glIntro, glFinish, glFlush, glXChooseVisual, glXCopyContext,
glXCreateContext, glXCreateGLXPixmap, glXDestroyContext,
glXGetClientString, glXGetConfig, glXIsDirect, glXMakeCurrent,
glXQueryExtension, glXQueryExtensionsString, glXQueryServerString, glXQueryVersion, glXSwapBuffers, glXUseXFont, glXWaitGL, glXWaitX, XCreateColormap, XCreateWindow, XSync