.\" $XFree86: xc/doc/man/GL/glx/xintro.3gl,v 1.3 2001/03/03 22:06:33 tsi Exp $ .\" .\" Copyright (c) 1999, 2001 The X Japanese Documentation Project. .\" .\" Permission is hereby granted, free of charge, to any person obtaining a .\" copy of this software and associated documentation files (the .\" "Software"), to deal in the Software without restriction, including .\" without limitation the rights to use, copy, modify, merge, publish, dis- .\" tribute, sublicense, and/or sell copies of the Software, and to permit .\" persons to whom the Software is furnished to do so, subject to the fol- .\" lowing conditions: .\" .\" The above copyright notice and this permission notice shall be included .\" in all copies or substantial portions of the Software. .\" .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- .\" ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT .\" SHALL THE X JAPANESE DOCUMENTATION PROJECT BE LIABLE FOR ANY CLAIM, .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. .\" .\" Except as contained in this notice, the name of The X Japanese .\" Documentation Project shall not be used in advertising or otherwise to .\" promote the sale, use or other dealings in this Software without prior .\" written authorization from The X Japanese Documentation Project. .\" .\" X Window System is a trademark of The Open Group. .\" .\" Translated Sun Aug 29 15:28:11 JST 1999 .\" by FUJIWARA Teruyoshi .\" Updated Sun Oct 21 13:37:58 JST 2001 for XFree86 4.1.0 .\" by FUJIWARA Teruyoshi .\" '\"! eqn | mmdoc '\"macro stdmacro .ds Vn Version 1.2 .ds Dt 6 March 1997 .ds Re Release 1.2.0 .ds Dp Feb 16 02:56 .ds Dm Feb 10 17:2 .ds Xs 32008 15 xintro.gl .TH GLXINTRO .\"0 .SH NAME .SH 名前 .B "glXIntro .\"0 \- Introduction to OpenGL in the X window system \- X ウィンドウシステムで OpenGL を使う方法の解説 .\"0 .SH OVERVIEW .SH 概要 .\"0 OpenGL (called GL in other pages) is a high-performance 3D-oriented renderer. OpenGL(他のページでは GL と呼ぶ)は、高性能な 3 次元指向レンダラである。 .\"0 It is available in the X window system through the GLX extension. OpenGL は GLX 機能拡張を通じて X ウィンドウシステムで利用することがで きる。 .\"0 To determine whether the GLX extension is supported by an X server, .\"0 and if so, what version is supported, call \f3glXQueryExtension\fP .\"0 and \f3glXQueryVersion\fP. X サーバが GLX 機能拡張をサポートしているかどうかを確かめる場合や、 サポートしている場合にそのバージョンを確かめるには、 \f3glXQueryExtension\fP と \f3glXQueryVersion\fP を用いること。 .P .\"0 GLX extended servers make a subset of their visuals available .\"0 for OpenGL rendering. GLX 機能拡張に対応したサーバは、OpenGL のレンダリングに使うことができ るビジュアルを、全体のビジュアルのサブセットとして生成する。 .\"0 Drawables created with these visuals can also be rendered using .\"0 the core X renderer .\"0 and with the renderer of any other X extension that is compatible .\"0 with all core X visuals. このようなビジュアルを使って生成されたドロウアブルは、コアの X レンダラ を使ってレンダリングすることや、コアの X ビジュアル全てと互換である任 意の機能拡張のレンダラを使ってレンダリングすることができる。 .P .\"0 GLX extends drawables with several buffers other than .\"0 the standard color buffer. GLX は、標準のカラーバッファ以外にいくつかのバッファを追加してドロウア ブルを拡張する。 .\"0 These buffers include back and auxiliary color buffers, .\"0 a depth buffer, .\"0 a stencil buffer, .\"0 and a color accumulation buffer. これらのバッファには、背面カラーバッファや補助カラーバッファ、 デプスバッファ、 ステンシルバッファ、 カラーアキュームレーションバッファが含まれる。 .\"0 Some or all are included in each X visual that supports OpenGL. これらの一部あるいは全ては、OpenGL をサポートしているそれぞれの X ビジュ アルに含まれる。 .P .\"0 To render using OpenGL into an X drawable, .\"0 you must first choose a visual that defines the required OpenGL buffers. OpenGL を用いて X のドロウアブルをレンダリングするにはまず、必要とされ る OpenGL バッファを定義するビジュアルを選択しなければならない。 .\"0 \f3glXChooseVisual\fP can be used to simplify selecting a compatible visual. \f3glXChooseVisual\fP を使うと、条件に合うビジュアルの選択を簡単に行う ことができる。 .\"0 If more control of the selection process is required, .\"0 use \f3XGetVisualInfo\fP and \f3glXGetConfig\fP to select among .\"0 all the available visuals. 選択処理をもっと細かく制御する必要があれば、 \f3XGetVisualInfo\fP と \f3glXGetConfig\fP を用いて、利用可能な全ての ビジュアルの中から選択を行うこと。 .P .\"0 Use the selected visual to create both a GLX context and an X .\"0 drawable. GLX コンテクストと X のドロウアブルのどちらを作るにも、選択したビジュ アルを使うこと。 .\"0 GLX contexts are created with \f3glXCreateContext\fP, .\"0 and drawables are created with either \f3XCreateWindow\fP or .\"0 \f3glXCreateGLXPixmap\fP. GLX コンテクストは \f3glXCreateContext\fP を使って生成し、ドロウアブル は \f3XCreateWindow\fP か \f3glXCreateGLXPixmap\fP を使って生成する。 .\"0 Finally, .\"0 bind the context and the drawable together using \f3glXMakeCurrent\fP. 最後に、\f3glXMakeCurrent\fP を使ってコンテクストとドロウアブルを関連 付けること。 .\"0 This context/drawable pair becomes the current context and current .\"0 drawable, .\"0 and it is used by all OpenGL commands until \f3glXMakeCurrent\fP is .\"0 called with different arguments. このコンテクストとドロウアブルのペアは現在のコンテクストと現在の ドロウアブルになり、他の引き数を指定して \f3glXMakeCurrent\fP を呼び出 すまでは、全ての OpenGL のコマンドはこれを用いる。 .P .\"0 Both core X and OpenGL commands can be used to operate on the .\"0 current drawable. コアの X コマンドを使っても、OpenGL のコマンドを使っても現在のドロウアブル を操作することができる。 .\"0 The X and OpenGL command streams are not synchronized, .\"0 however, .\"0 except at explicitly created boundaries generated by calling .\"0 \f3glXWaitGL\fP, \f3glXWaitX\fP, \f3XSync\fP, and \f3glFlush\fP. しかし、X と OpenGL のコマンドストリームは同期していない( \f3glXWaitGL\fP, \f3glXWaitX\fP, \f3XSync\fP, \f3glFlush\fP を呼び出し て両者の境界を明示的に生成した場合は除く)。 .\"0 .SH EXAMPLES .SH 例 .\"0 Below is the minimum code required to create an RGBA-format, .\"0 X window that's compatible with OpenGL and to clear it to yellow. 以下に示すのは、RGBA 形式であり OpenGL と互換な X のウィンドウを生成し、 これを黄色でクリアするための最小限のコードである。 .\"0 The code is correct, .\"0 but it does not include any error checking. これは正しいコードであるが、エラーチェックは全く入っていない。 .\"0 Return values \f2dpy\fP, .\"0 \f2vi\fP, .\"0 \f2cx\fP, .\"0 \f2cmap\fP, and .\"0 \f2win\fP should all be tested. 本来は返り値の \f2dpy\fP, \f2vi\fP, \f2cx\fP, \f2cmap\fP, \f2win\fP は 全てチェックすべきである。 .P .Ex \&#include \&#include \&#include 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); } .Ee .\"0 .SH NOTES .SH 注意 .\"0 A color map must be created and passed to \f3XCreateWindow\fP. カラーマップは必ず生成し、\f3XCreateWindow\fP に渡さなければならない。 .\"0 See the preceding example code. 上記のサンプルコードを参照すること。 .P .\"0 A GLX context must be created and attached to an X drawable before .\"0 OpenGL commands can be executed. GLX コンテクストは、OpenGL のコマンドが実行される前に生成し、X の ドロウアブルに割り当てなければならない。 .\"0 OpenGL commands issued while no context/drawable pair is current .\"0 result in undefined behavior. 現在のコンテクストとドロウアブルのペアが無い状態で OpenGL のコマンドを 発行すると、その動作は未定義である。 .P .\"0 Exposure events indicate that \f2all\fP buffers associated with the .\"0 specified window may be damaged and should be repainted. 露出イベントは、指定されたウィンドウに関係がある\f2全ての\fPバッファの 内容が壊れた可能性があり、再描画しなければならないことを示す。 .\"0 Although certain buffers of some visuals on some systems .\"0 may never require repainting .\"0 (the depth buffer, for example), .\"0 it is incorrect to write a program assuming that these buffers will .\"0 not be damaged. 一部のシステムでは、一部のビジュアルの特定のバッファ(例えばデプスバッ ファ)は再描画を全く必要としないことがあるが、このようなバッファの内容 が壊れないことを前提としてプログラムを書くことは間違いである。 .P .\"0 GLX commands manipulate XVisualInfo structures rather than pointers to .\"0 visuals or visual IDs. GLX コマンドは XVisualInfo 構造体を扱い、ビジュアルへのポインタやビジュ アルの ID を扱うことはない。 .\"0 XVisualInfo structures contain \f2visual\fP, .\"0 \f2visualID\fP, .\"0 \f2screen\fP, and .\"0 \f2depth\fP elements, .\"0 as well as other X-specific information. XVisualInfo には、\f2visual\fP, \f2visualID\fP, \f2screen\fP, \f2depth\fP 要素や他の X 固有の情報が含まれる。 .\"0 .SH USING GLX EXTENSIONS .SH GLX 機能拡張の使用 .\"0 All supported GLX extensions will have a corresponding definition in glx.h .\"0 and a token in the extension string returned by \f3glXQueryExtensionsString\fP. サポートされている全ての GLX 機能拡張について、対応する定義が glx.h に ある。また、\f3glXQueryExtensionsString\fP が返す拡張内容を表す文字列 にはトークンが含まれる。 .\"0 For example, if the \f3EXT_visual_info\fP extension is supported, .\"0 then this token will be defined in glx.h and \f3EXT_visual_info\fP .\"0 will appear in the extension .\"0 string returned by \f3glXQueryExtensionsString\fP. The definitions in glx.h .\"0 can be used at compile time to determine if procedure calls corresponding .\"0 to an extension exist in the library. 例えば、\f3EXT_visual_info\fP 機能拡張がサポートされていれば、このトー クンは glx.h で定義されており、\f3glXQueryExtensionsString\fP が返す拡 張内容を表す文字列には \f3EXT_visual_info\fP が現れる。glx.h における 定義は、拡張に対応する手続きがライブラリ内に存在しているかどうかを調べ るためにコンパイル時に使われる。 .P .\"0 OpenGL itself has also been extended. Refer to \f3glIntro\fP for more .\"0 information. OpenGL そのものも今まで拡張されてきている。詳しくは \f3glIntro\fP を参 照すること。 .P .\"0 .SH GLX 1.1 and GLX 1.2 .SH GLX 1.1 と GLX 1.2 .\"0 GLX 1.2 is now supported. It is backward compatible with GLX 1.1 and .\"0 GLX 1.0. GLX 1.2 は既にサポートされている。これは GLX 1.1 と GLX 1.0 に対して後 方互換性を持つ。 .P .\"0 GLX 1.2 corresponds to OpenGL version 1.1 and introduces the following .\"0 new call: \f3glGetCurrentDisplay\fP. GLX 1.2 は OpenGL 1.1 に対応し、新しい関数として \f3glGetCurrentDisplay\fP が導入されている。 .P .\"0 GLX 1.1 corresponds to OpenGL version 1.0 and introduces the .\"0 following new calls: .\"0 \f3glXQueryExtensionsString\fP, \f3glXQueryServerString\fP, and .\"0 \f3glXGetClientString\fP. GLX 1.1 は OpenGL 1.0 に対応し、新しい関数として \f3glXQueryExtensionsString\fP, \f3glXQueryServerString\fP, \f3glXGetClientString\fP が導入されている。 .P .\"0 Call \f3glQueryVersion\fP .\"0 to determine at runtime what version of GLX is available. \f3glQueryVersion\fP .\"0 returns the version that is supported on the connection. Thus .\"0 if 1.2 is returned, both the client and server support GLX 1.2. どのバージョンの GLX が利用可能であるかを実行時に調べるには \f3glQueryVersion\fP を用いること。\f3glQueryVersion\fP はサーバとの接 続においてサポートされているバージョンを返す。つまり、1.2 が返された場 合には、サーバトクライアントの双方が GLX 1.2 をサポートしているという ことである。 .\"0 You can also check the GLX version at compile time: GLX_VERSION_1_1 .\"0 will be defined in glx.h if GLX 1.1 calls are supported and .\"0 GLX_VERSION_1_2 will be defined if GLX 1.2 calls are supported. GLX のバージョンをコンパイル時に調べることもできる。 GLX 1.1 の関数がサポートされていれば glx.h 内で GLX_VERSION_1_1 が定義 されており、GLX 1.2 の関数がサポートされていれば GLX_VERSION_1_2 が定 義されている。 .\"0 .SH SEE ALSO .SH 関連項目 \f3glIntro\fP, \f3glFinish\fP, \f3glFlush\fP, \f3glXChooseVisual\fP, \f3glXCopyContext\fP, .br \f3glXCreateContext\fP, \f3glXCreateGLXPixmap\fP, \f3glXDestroyContext\fP, .br \f3glXGetClientString\fP, \f3glXGetConfig\fP, \f3glXIsDirect\fP, \f3glXMakeCurrent\fP, .br \f3glXQueryExtension\fP, \f3glXQueryExtensionsString\fP, \f3glXQueryServerString\fP, \f3glXQueryVersion\fP, \f3glXSwapBuffers\fP, \f3glXUseXFont\fP, \f3glXWaitGL\fP, \f3glXWaitX\fP, \f3XCreateColormap\fP, \f3XCreateWindow\fP, \f3XSync\fP