メニュー

pygame.display

ウィンドウ画面やスクリーンの制御を行うpygameモジュール

このモジュールではpygameのディプレイ部分を制御することができます。 Pygameで使用されるdisplay Surfaceは、ウィンドウ内に描写されるものかフルスクリーンで動作するもののどちらか一つになります。displayを作成すると、それがメインで画面に表示されるものとして扱われます。描写処理を行ってもそれはすぐに画面に反映されるわけではなく、画面の更新を行うための二つの命令のうちどちらかを実行する必要があります。

ディスプレイの原点はスクリーンの左上となり、そこのx座標が0、y座標が0となります。各座標の数値が増えるほど座標位置はスクリーンの右下へ移動します。

この pygameのdisplayは複数のモードの中から一つを選んで初期化することができます。既定ではdisplayはソフト側のメモリー上で制御されます。 この他にもハード側での高速描写処理やOpenGLを使うような特別なモードを設定することができます。これらのモードはpygame.display.set_mode で特定の引数を設定することで切り替えます。

Pygameでは、いかなる状況でも一つのdisplayしかアクティブ状態にすることができません。pygame.display.set_mode 命令で新しいdisplayを作成すると、これまで使用していたdisplayは終了して閉じられます。ピクセル形式や画面解像度に関する精密な制御操作が必要な場合は、pygame.display.mode_ok命令や pygame.display.list_modes命令、pygame.display.Info命令を使用することでdisplayの情報を参照することができます。

display Surfaceが作成されると、このpygame.displayモジュールに含まれている命令を使って作成されたdisplayの操作を行います。pygame.displayモジュールの初期化に失敗してしまうと、display Surfaceでの画面描写を行うことができません。ディスプレイモードの切り替えを行うと、作成済みdisplay Surfaceは自動的に新しいディスプレイモードでの処理ができるように切り替えが行われます。

ディスプレイモードの切り替えが行われると、いくつかのイベント処理がpygameのイベント登録リストに設定されます。 pygame.QUITは、ユーザーがプログラムの終了処理を実行した時に発生するイベントです。ディスプレイが選択された状態になったり選択解除状態になった時は、 pygame.ACTIVEEVENTイベントが発生します。displayにpygame.RESIZABLEフラグが設定されていた時は、 ユーザーがウィンドウのサイズを変更するとpygame.VIDEORESIZEイベントが発生します。スクリーンに直接描写を行うハードウェアディスプレイモードでは、ウィンドウの再描写が必要な時にpygame.VIDEOEXPOSEイベントが発生します。

pygame module to control the display window and screen

This module offers control over the pygame display. Pygame has a single display Surface that is either contained in a window or runs full screen. Once you create the display you treat it as a regular Surface. Changes are not immediately visible onscreen, you must choose one of the two flipping functions to update the actual display.

The origin of the display, where x = 0, and y = 0 is the top left of the screen. Both axis increase positively towards the botom right of the screen.

The pygame display can actually be initialized in one of several modes. By default the display is a basic software driven framebuffer. You can request special modules like hardware acceleration and OpenGL support. These are controlled by flags passed to pygame.display.set_mode - initialize a window or screen for display.

Pygame can only have a single display active at any time. Creating a new one with pygame.display.set_mode - initialize a window or screen for display will close the previous display. If precise control is needed over the pixel format or display resolutions, use the functions pygame.display.mode_ok - pick the best color depth for a display mode, pygame.display.list_modes - get list of available fullscreen modes, and pygame.display.Info - Create a video display information object to query information about the display.

Once the display Surface is created, the functions from this module effect the single existing display. The Surface becomes invalid if the module is uninitialized. If a new display mode is set, the existing Surface will automatically switch to operate on the new display.

Then the display mode is set, several events are placed on the pygame event queue. pygame.QUIT is sent when the user has requested the program to shutdown. The window will receive pygame.ACTIVEEVENT events as the display gains and loses input focus. If the display is set with the pygame.RESIZABLE flag, pygame.VIDEORESIZE events will be sent when the user adjusts the window dimensions. Hardware displays that draw direct to the screen will get pygame.VIDEOEXPOSE events when portions of the window must be redrawn.


pygame.display.init

pygame.displayモジュールを初期化します。
pygame.display.init(): return None

pygame.displayモジュールを初期化します。このdisplayモジュールは初期化しなければ一切使用することができません。この初期化処理は、通常は上位に位置するpygame.init処理を実行した時に自動的に実行されます。

Pygameはpygame.displayモジュールが初期化された時に、バックエンドにある内部displayの中から描写処理に使用するものを一つ選択します。 ここで選択されるdisplayのモードは、ユーザーのパソコン環境やユーザ権限によって変わってきます。displayモジュールが初期化された後は、バックエンドの制御に使用される環境変数SDL_VIDEODRIVERを設定することができます。初期化の時に複数のdisplayモードを選択できる環境は下記の通りになります。

   Windows : windib, directx
   Unix    : x11, dga, fbcon, directfb, ggi, vgl, svgalib, aalib

いくつかのプラットフォームでは、作成済みウィンドウにpygameのディスプレイを埋め込むことが可能です。その処理を行うには、 環境変数 SDL_WINDOWIDをウィンドウIDかウィンドウハンドルに設定しなければいけません。この環境変数は、 pygame displayの初期化時に設定されているかどうかチェックされます。この埋め込みdisplayでプログラムを実行している時は、予期せぬ多くの副作用が発生することがあるので注意してください。

この初期化処理は二回以上実行しても特に問題はありません。複数回初期化をしても全く意味がないのです。

initialize the display module
pygame.display.init(): return None

Initializes the pygame display module. The display module cannot do anything until it is initialized. This is usually handled for you automatically when you call the higher level pygame.init - initialize all imported pygame modules.

Pygame will select from one of several internal display backends when it is initialized. The display mode will be chosen depending on the platform and permissions of current user. Before the display module is initialized the environment variable SDL_VIDEODRIVER can be set to control which backend is used. The systems with multiple choices are listed here.

   Windows : windib, directx
   Unix    : x11, dga, fbcon, directfb, ggi, vgl, svgalib, aalib

On some platforms it is possible to embed the pygame display into an already existing window. To do this, the environment variable SDL_WINDOWID must be set to a string containing the window id or handle. The environment variable is checked when the pygame display is initialized. Be aware that there can be many strange side effects when running in an embedded display.

It is harmless to call this more than once, repeated calls have no effect.


pygame.display.quit

pygame.display モジュールの初期化を解除します。
pygame.display.quit(): return None

この処理はpygame.displayモジュールを全て終了させます。これはアクティブなウィンドウが閉じられるということです。この処理はプログラムが終了した時に自動的に実行されます。

この初期化処理は二回以上実行しても特に問題はありません。複数回初期化の解除をしても全く意味がないのです。

uninitialize the display module
pygame.display.quit(): return None

This will shut down the entire display module. This means any active displays will be closed. This will also be handled automatically when the program exits.

It is harmless to call this more than once, repeated calls have no effect.


pygame.display.get_init

pygame.displayモジュールが初期化されていた場合はTrueを戻り値として返します。
pygame.display.get_init(): return bool

pygame.displayモジュールが初期化されていた場合はTrueを戻り値として返します。

true if the display module is initialized
pygame.display.get_init(): return bool

Returns True if the pygame.display module is currently initialized.


pygame.display.set_mode

display描写用のウィンドウやスクリーンを初期化します。
pygame.display.set_mode(resolution=(0,0), flags=0, depth=0): return Surface

この命令ではdisplay Surfaceを作成します。設定する引数によってディスプレイの種類が決められます。ここで作成されたディスプレイは、ユーザーの使用環境に最も最適化された状態のものとなります。

resolution引数は、displayの幅と高さを表す二組の数字です。flags引数は、追加で指定できるものです。depth 引数は色を描写するのに使用されるビット数を表します。

作成されたSurfaceは通常のSurfaceと同じように描写処理を行うことができ、編集した結果はパソコンのモニターに表示されます。

resolution引数を設定しなかったり(0, 0)を設定した場合に、pygameが SDLのバージョン1.2.10以降を使用していると、作成されたSurfaceはパソコンのモニターと同じ大きさとなります。displayの幅か高さのどちらか一方に0を設定していた場合には、Surfaceの設定されなかった値についてはパソコンのモニターと同じ幅や高さが設定されます。使用してるSDLのバージョンが1.2.10より古い場合は例外が発生してしまいます。

depth 引数は通常は設定しないほうがよいでしょう。使用しているパソコン環境に最も最適化されて処理速度の速いdepth値が既定値として設定されています。ゲーム制作時に特別なカラーフォーマットを使う必要がある場合には、depth引数を設定してビット深度を制御できます。処理が遅くなりすぎて使用できないカラービット深度が設定された場合、 Pygameそのカラービット深度に近い値を使って処理を実行します

フルスクリーンディスプレイモードが設定された時、場合によってはこちらで想定していたフルスクリーン状態にならない場合もあります。こうした状況において、pygameは要求に最も近いディスプレイモードを選び出して実行します。 作成されたsurfaceのサイズは、設定されたresolution引数と常に同じ値になります。

flags 引数を設定することで、ディスプレイの種類を任意のものに切り替えることができます。ディスプレイの種類は複数ものから選んで設定することができ、またビット単位のor演算子を使用することでそれら複数ものを組み合わせて設定することができます。( pygame.RESIZABLE | pygame.NOFRAME)というように指定します。flags引数に0を設定したり、flags引数の設定をしなかった場合は、規定値のソフトウェア側で起動するウィンドウとなります。以下のflags引数から任意の値を選んでディスプレイの種類を決定します。:

   pygame.FULLSCREEN    フルスクリーンのディスプレイを作成します。
   pygame.DOUBLEBUF     ハードウェア側での高速描写処理やOpenGLを使用する時にはこの値設定した方が良いでしょう。
   pygame.HWSURFACE     ハードウェア側での高速描写処理を使用します。フルスクリーンモードでしか使用できません。
   pygame.OPENGL        OpenGLでの描写処理を行うディスプレイを作成します。
   pygame.RESIZABLE     ウィンドウのサイズ変更ができるようになります。
   pygame.NOFRAME       ウィンドウの外枠やGUI部品が表示されなくなります。
initialize a window or screen for display
pygame.display.set_mode(resolution=(0,0), flags=0, depth=0): return Surface

This function will create a display Surface. The arguments passed in are requests for a display type. The actual created display will be the best possible match supported by the system.

The resolution argument is a pair of numbers representing the width and height. The flags argument is a collection of additional options. The depth argument represents the number of bits to use for color.

The Surface that gets returned can be drawn to like a regular Surface but changes will eventually be seen on the monitor.

If no resolution is passed or is set to (0, 0) and pygame uses SDL version 1.2.10 or above, the created Surface will have the same size as the current screen resolution. If only the width or height are set to 0, the Surface will have the same width or height as the screen resolution. Using a SDL version prior to 1.2.10 will raise an exception.

It is usually best to not pass the depth argument. It will default to the best and fastest color depth for the system. If your game requires a specific color format you can control the depth with this argument. Pygame will emulate an unavailable color depth which can be slow.

When requesting fullscreen display modes, sometimes an exact match for the requested resolution cannot be made. In these situations pygame will select the closest compatable match. The returned surface will still always match the requested resolution.

The flags argument controls which type of display you want. There are several to choose from, and you can even combine multiple types using the bitwise or operator, (the pipe "|" character). If you pass 0 or no flags argument it will default to a software driven window. Here are the display flags you will want to choose from:

   pygame.FULLSCREEN    create a fullscreen display
   pygame.DOUBLEBUF     recommended for HWSURFACE or OPENGL
   pygame.HWSURFACE     hardware accelerated, only in FULLSCREEN
   pygame.OPENGL        create an opengl renderable display
   pygame.RESIZABLE     display window should be sizeable
   pygame.NOFRAME       display window will have no border or controls

pygame.display.get_surface

作成済みのdisplay surfaceの情報を取得します。
pygame.display.get_surface(): return Surface

作成済みのdisplay surfaceの情報を戻り値として返します。display surfaceが作成されていなかった場合は、Noneが戻り値として返されます。

get a reference to the currently set display surface
pygame.display.get_surface(): return Surface

Return a reference to the currently set display Surface. If no display mode has been set this will return None.


pygame.display.flip

display Surface全体を更新して画面に描写します。
pygame.display.flip(): return None

この命令では、display全体の内容を更新します。ディスプレイモードに pygame.HWSURFACEpygame.DOUBLEBUFを使用してる場合は、この命令は現在行われている一連の描写処理が完了するのを待ったうえでsurfacesの更新を行います。他のディスプレイモードを使用している場合には、単純にsurfaceの内容全体の更新が行われます。

pygame.OPENGL対応のディスプレイモードを使用している場合は、この命令はOpenGLのバッファスワップ機能を実行して画面の更新を行います。

update the full display Surface to the screen
pygame.display.flip(): return None

This will update the contents of the entire display. If your display mode is using the flags pygame.HWSURFACE and pygame.DOUBLEBUF, this will wait for a vertical retrace and swap the surfaces. If you are using a different type of display mode, it will simply update the entire contents of the surface.

When using an pygame.OPENGL display mode this will perform a gl buffer swap.


pygame.display.update

スクリーンの一部分のみを更新します。この命令はソフトウェア側での表示処理に最適化されています。
pygame.display.update(rectangle=None): return Nonepygame.display.update(rectangle_list): return None

この命令はpygame.display.flip命令をソフトウェア側での表示処理に最適化したようなものです。画面全体ではなく画面の一部の更新しかできません。引数を何にも設定しなければpygame.display.flipと同じようにSurface全体が更新されます。

この命令ではrect型の値やそのリストを引数として設定することができます。更新する範囲一つ一つ設定して何回もupdate命令を呼び出すよりは、範囲のリストをまとめて設定して一度のupdate命令で完了させる方が効率が良いでしょう。更新する範囲のリストを引数に設定した場合、リストの中にNone値が入っていても特に問題はありません。そのNone値は無視されて処理が行われます。

この命令はpygame.OPENGL対応のディスプレイモードでは使用することができず、例外が発生してしまいます。

update portions of the screen for software displays
pygame.display.update(rectangle=None): return Nonepygame.display.update(rectangle_list): return None

This function is like an optimized version of pygame.display.flip - update the full display Surface to the screen for software displays. It allows only a portion of the screen to updated, instead of the entire area. If no argument is passed it updates the entire Surface area like pygame.display.flip - update the full display Surface to the screen.

You can pass the function a single rectangle, or a sequence of rectangles. It is more efficient to pass many rectangles at once than to call update multiple times with single or a partial list of rectangles. If passing a sequence of rectangles it is safe to include None values in the list, which will be skipped.

This call cannot be used on pygame.OPENGL displays and will generate an exception.


pygame.display.get_driver

pygameで使用するディスプレイドライバー名を取得します。
pygame.display.get_driver(): return name

Pygameは初期化される時に、使用できるいくつかのディスプレイドライバーの中から一つを選びます。この命令ではpygameで使用されるディスプレイドライバーの、プログラム内部で使われている名前を戻り値として返します。This can be used to provide limited information about what display capabilities might be accelerated. pygame.display.set_modeでは指定可能ないくつかのオプションが見られますので、詳しくはそのSDL_VIDEODRIVERフラグを参照してください。

get the name of the pygame display backend
pygame.display.get_driver(): return name

Pygame chooses one of many available display backends when it is initialized. This returns the internal name used for the display backend. This can be used to provide limited information about what display capabilities might be accelerated. See the SDL_VIDEODRIVER flags in pygame.display.set_mode - initialize a window or screen for display to see some of the common options.


pygame.display.Info

ビデオディスプレイの情報を保持したクラスを作成します。
pygame.display.Info(): return VideoInfo

ディスプレイ情報のクラスを作成します。このクラスからは現在のグラフィック環境の詳細が記されたいくつかの属性を参照できます。この命令がpygame.display.set_modeを実行する前に呼び出された場合は、使用環境によっては既定ディスプレイモードを設定した状態の情報が作成されます。あなたがディスプレイモードを設定した後、ちゃんと意図したモードに設定されているかを確認するためにこの命令を使用することができます。この命令で作成されたビデオ情報クラスでは、下記の項目を参照することができます。:

  hw:         ディスプレイがハードウェア側での高速描写モードならTrueとなる
  wm:          ディスプレイがウィンドウを使用する描写モードならTrueとなる
  video_mem:  ディスプレイで使用されるビデオメモリーのメガバイト数。不明の場合は0となる
  bitsize:    ピクセル1つを保存するのに使用されるビット数
  bytesize:   ピクセル1つを保存するのに使用されるバイト数
  masks:      RGBA形式の色情報をピクセルへ適用するために使用する、4つの数値を保持するタプル型の値
  shifts:     RGBA形式の色情報をピクセルへ適用するために使用する、4つの数値を保持するタプル型の値
  losses:     RGBA形式の色情報をピクセルへ適用するために使用する、4つの数値を保持するタプル型の値
  blit_hw:    ハードウェア側Surfaceでの高速コピー描写が使用可能な場合はTrueとなる。
  blit_hw_CC: ハードウェア側Surfaceでの透明色を適用した高速コピー描写が使用可能な場合はTrueとなる。
  blit_hw_A:  ハードウェア側Surfaceでのピクセル単位の透過を適用した高速コピー描写が使用可能な場合はTrueとなる。
  blit_sw:    ソフトウェア側Surfaceでの高速コピー描写が使用可能な場合はTrueとなる。
  blit_sw_CC: ソフトウェア側Surfaceでの透明色を適用した高速コピー描写が使用可能な場合はTrueとなる。
  blit_sw_A:  ソフトウェア側Surfaceでのピクセル単位の透過を適用した高速コピー描写が使用可能な場合はTrueとなる。
  current_h, current_w:  現在のビデオモードでのウィンドウの幅と高さの値です。
  display.set_modeを実行する前にこの値を取得すると、パソコンのモニターの幅と高さの値が得られます。
    (current_hと current_wはSDL のver1.2.10、pygameのver 1.8.0から使用できるようになりました。)
    ver1.2.10以前のSDLでcurrent_hと current_wを参照すると、-1のエラー値となります。

※原文には current_h, current_hと記載されていますが、誤記の可能性があるため current_h, current_wと読み替えて訳しています。

Create a video display information object
pygame.display.Info(): return VideoInfo

Creates a simple object containing several attributes to describe the current graphics environment. If this is called before pygame.display.set_mode - initialize a window or screen for display some platforms can provide information about the default display mode. This can also be called after setting the display mode to verify specific display options were satisfied. The VidInfo object has several attributes:

  hw:         True if the display is hardware accelerated
  wm:         True if windowed display modes can be used
  video_mem:  The megabytes of video memory on the display. This is 0 if unknown
  bitsize:    Number of bits used to store each pixel
  bytesize:   Number of bytes used to store each pixel
  masks:      Four values used to pack RGBA values into pixels
  shifts:     Four values used to pack RGBA values into pixels
  losses:     Four values used to pack RGBA values into pixels
  blit_hw:    True if hardware Surface blitting is accelerated
  blit_hw_CC: True if hardware Surface colorkey blitting is accelerated
  blit_hw_A:  True if hardware Surface pixel alpha blitting is accelerated
  blit_sw:    True if software Surface blitting is accelerated
  blit_sw_CC: True if software Surface colorkey blitting is accelerated
  blit_sw_A:  True if software Surface pixel alpha blitting is acclerated
  current_h, current_h:  Width and height of the current video mode, or of the
    desktop mode if called before the display.set_mode is called.
    (current_h, current_w are available since SDL 1.2.10, and pygame 1.8.0)
    They are -1 on error, or if an old SDL is being used.

pygame.display.get_wm_info

現在のウィンドウシステムの情報を取得します。
pygame.display.get_wm_info(): return dict

文字列をキーとしたdictionary型のリストを作成します。ここで得られる文字列と数値は、システムによって任意の値が設定されます。使用環境によっては、システム情報を持たないために空のdictionary型リストが戻り値として返される場合もあります。殆どの環境では "window"キーと現在のディスプレイに合わせたシステムIDを表す数値が戻り値として返されます。

この機能はpygameのver 1.7.1から実装されました。

Get information about the current windowing system
pygame.display.get_wm_info(): return dict

Creates a dictionary filled with string keys. The strings and values are arbitrarily created by the system. Some systems may have no information and an empty dictionary will be returned. Most platforms will return a "window" key with the value set to the system id for the current display.

New with pygame 1.7.1


pygame.display.list_modes

使用できるフルスクリーンモードのリストを取得します。
pygame.display.list_modes(depth=0, flags=pygame.FULLSCREEN): return list

この命令では指定したカラー深度で作成可能なウィンドウの大きさのリストと戻り値として返します。設定した引数で作成できるディスプレイモードがない場合、空のリストが戻り値として返されます。戻り値の値が-1の場合でも要求した解像度で問題なく動作するでしょう。 (これはウィンドモードで実行した時によく起こる現象です。).戻り値のサイズの並び順については、大きいものから順に並んでいます。

depth引数に0を設定した場合、 SDLは現在のディスプレイ環境最適なカラー深度を選んで処理を実行します。flags引数は既定ではpygame.FULLSCREENとなっていますが、特定のフルスクリーンモードのリストを取得するには他にも追加でflags引数を設定する必要があります。

get list of available fullscreen modes
pygame.display.list_modes(depth=0, flags=pygame.FULLSCREEN): return list

This function returns a list of possible dimensions for a specified color depth. The return value will be an empty list if no display modes are available with the given arguments. A return value of -1 means that any requested resolution should work (this is likely the case for windowed modes). Mode sizes are sorted from biggest to smallest.

If depth is 0, SDL will choose the current/best color depth for the display. The flags defaults to pygame.FULLSCREEN, but you may need to add additional flags for specific fullscreen modes.


pygame.display.mode_ok

ディスプレイモードに最適なカラー深度を取得します。
pygame.display.mode_ok(size, flags=0, depth=0): return depth

この命令ではpygame.display.set_mode命令と同じ引数を使用します。この命令は要求されたディスプレイモードが使用できるかどうかを確認するために使用します。設定したディスプレイモードが使用できない環境の場合は0が戻り値として返されます。それ以外の場合はディスプレイの要件に最適のピクセル深度が戻り値として返されます。

通常depth引数を設定する必要はありませんが、使用環境によっては複数のディスプレイ深度をサポートしている場合もあります。depth引数を設定してみることによって、使用環境に最も適した深度を調べられるかもしれません。

大抵の場合、flags引数にはpygame.HWSURFACEpygame.DOUBLEBUF、そしておそらくpygame.FULLSCREENがよく使用されるでしょう。設定したディスプレイflagsが使用できない環境の場合は0が戻り値として返されます。

※原文ではIt is used to 「depermine」 if a requested display mode is available.となっていますが、誤記の可能性があるためIt is used to 「determine」 if a requested display mode is available.と読み替えて訳しています。

pick the best color depth for a display mode
pygame.display.mode_ok(size, flags=0, depth=0): return depth

This function uses the same arguments as pygame.display.set_mode - initialize a window or screen for display. It is used to depermine if a requested display mode is available. It will return 0 if the display mode cannot be set. Otherwise it will return a pixel depth that best matches the display asked for.

Usually the depth argument is not passed, but some platforms can support multiple display depths. If passed it will hint to which depth is a better match.

The most useful flags to pass will be pygame.HWSURFACE, pygame.DOUBLEBUF, and maybe pygame.FULLSCREEN. The function will return 0 if these display flags cannot be set.


pygame.display.gl_get_attribute

現在のディスプレイ環境に合わせたOpenGLフラグの値を取得します。
pygame.display.gl_get_attribute(flag): return value

pygame.display.set_mode命令で pygame.OPENGLフラグを設定した場合は、実行後にこの命令が呼び出して設定したOpenGLの値に問題がないかチェックすると良いかもしれません。設定できるflags引数一覧についてはpygame.display.gl_set_attributeを参照してください。

get the value for an opengl flag for the current display
pygame.display.gl_get_attribute(flag): return value

After calling pygame.display.set_mode - initialize a window or screen for display with the pygame.OPENGL flag, it is a good idea to check the value of any requested OpenGL attributes. See pygame.display.gl_set_attribute - request an opengl display attribute for the display mode for a list of valid flags.


pygame.display.gl_set_attribute

ディスプレイモードに合わせたOpenGLの属性を設定します。
pygame.display.gl_set_attribute(flag, value): return None

pygame.display.set_mode命令でpygame.OPENGLフラグを設定した場合は、Pygameは色やダブルバッファリングといったOpenGLの属性を自動的に設定します。 OpenGLでは任意に設定して制御することができる属性がいくつかあります。これらの属性の中の一つのflagを、正しい値と共に設定します。この命令はpygame.display.set_mode命令よりも前に実行しなければなりません。

設定できるOPENGL flags は下記のものがあります;

  GL_ALPHA_SIZE, GL_DEPTH_SIZE, GL_STENCIL_SIZE, GL_ACCUM_RED_SIZE,
  GL_ACCUM_GREEN_SIZE,  GL_ACCUM_BLUE_SIZE, GL_ACCUM_ALPHA_SIZE,
  GL_MULTISAMPLEBUFFERS, GL_MULTISAMPLESAMPLES, GL_STEREO
request an opengl display attribute for the display mode
pygame.display.gl_set_attribute(flag, value): return None

When calling pygame.display.set_mode - initialize a window or screen for display with the pygame.OPENGL flag, Pygame automatically handles setting the OpenGL attributes like color and doublebuffering. OpenGL offers several other attributes you may want control over. Pass one of these attributes as the flag, and its appropriate value. This must be called before pygame.display.set_mode - initialize a window or screen for display

The OPENGL flags are;

  GL_ALPHA_SIZE, GL_DEPTH_SIZE, GL_STENCIL_SIZE, GL_ACCUM_RED_SIZE,
  GL_ACCUM_GREEN_SIZE,  GL_ACCUM_BLUE_SIZE, GL_ACCUM_ALPHA_SIZE,
  GL_MULTISAMPLEBUFFERS, GL_MULTISAMPLESAMPLES, GL_STEREO

pygame.display.get_active

ディスプレイがアクティブ状態ならTrueとなります。
pygame.display.get_active(): return bool

pygame.display.set_mode命令が呼び出された後、ディスプレイSurfaceはスクリーン上で見えるようになります。大抵のウィンドウはユーザーによって隠すことができます。ディスプレイSurfaceが隠されたりアイコン化された場合、この命令はFalseを戻り値として返します。

true when the display is active on the display
pygame.display.get_active(): return bool

After pygame.display.set_mode - initialize a window or screen for display is called the display Surface will be visible on the screen. Most windowed displays can be hidden by the user. If the display Surface is hidden or iconified this will return False.


pygame.display.iconify

ディスプレイsurfaceを最小化します。
pygame.display.iconify(): return bool

ディスプレイsurfaceが描写されるウィンドウを最小化したり隠したりします。全ての環境においてディスプレイの最小化がサポートされている訳ではありません。最小化に成功した場合はTrueが戻り値として返されます。

ディスプレイがアイコン化された時、pygame.display.get_active命令はFalseを戻り値として返します。ウィンドウが最小化されるとイベントキューがACTIVEEVENTイベントを受け取ります。

iconify the display surface
pygame.display.iconify(): return bool

Request the window for the display surface be iconified or hidden. Not all systems and displays support an iconified display. The function will return True if successfull.

When the display is iconified pygame.display.get_active - true when the display is active on the display will return False. The event queue should receive a ACTIVEEVENT event when the window has been iconified.


pygame.display.toggle_fullscreen

フルスクリーンモードとウィンドウモードの切り替えを行います。
pygame.display.toggle_fullscreen(): return bool

ウィンドウモードとフルスクリーンモードの切り替えを行います。この命令はunix x11ビデオドライバー上でのみしか機能しません。大抵の場合、pygame.display.set_mode命令でフルスクリーンモードのフラグを設定して実行する方が良いでしょう。

switch between fullscreen and windowed displays
pygame.display.toggle_fullscreen(): return bool

Switches the display window between windowed and fullscreen modes. This function only works under the unix x11 video driver. For most situations it is better to call pygame.display.set_mode - initialize a window or screen for display with new display flags.


pygame.display.set_gamma

ハードウェアのガンマランプを変更します。
pygame.display.set_gamma(red, green=None, blue=None): return bool

ハードウェアディスプレイの赤、緑、青のガンマ値を設定します。green引数とblue引数が設定されなかった場合は、それらは両方ともred引数と同じ値になります。全ての環境においてガンマランプがサポートされている訳ではありません。この処理に成功した場合はTrueが戻り値として返されます。

ガンマ値が1.0だとディスプレイ表示は色に比例した明るさとなります。1.0も小さい値だとディスプレイ表示は暗くなり、大きい値だと明るくなります。

change the hardware gamma ramps
pygame.display.set_gamma(red, green=None, blue=None): return bool

Set the red, green, and blue gamma values on the display hardware. If the green and blue arguments are not passed, they will both be the same as red. Not all systems and hardware support gamma ramps, if the function succeeds it will return True.

A gamma value of 1.0 creates a linear color table. Lower values will darken the display and higher values will brighten.


pygame.display.set_gamma_ramp

ルックアップテーブルを使用してハードウェアのガンマランプを変更します。
pygame.display.set_gamma_ramp(red, green, blue): return bool

詳細なルックアップテーブルを使用して、赤、緑、青のガンマランプを設定します。各引数には256個の要素を持ったシーケンス型の値を設定する必要があります。要素には0から0xffff(65536)まで範囲内の数字が使用できます。全ての環境においてガンマランプがサポートされている訳ではありません。この処理に成功した場合はTrueが戻り値として返されます。

※原文では簡易説明文と公式が逆になっている可能性があるため、修正して訳しています。

set_gamma_ramp(red, green, blue): return bool
change the hardware gamma ramps with a custom lookuppygame.display.set_gamma_ramp(red, green, blue): return bool

Set the red, green, and blue gamma ramps with an explicit lookup table. Each argument should be sequence of 256 integers. The integers should range between 0 and 0xffff. Not all systems and hardware support gamma ramps, if the function succeeds it will return True.


pygame.display.set_icon

ウィンドウに表示されるシステムアイコンを変更します。
pygame.display.set_icon(Surface): return None

ウィンドウに表示されるシステムアイコンを設定します。全てのウィンドウにおいて、既定ではシンプルなpygameのロゴマークがタイトルバーに表示されます。

任意のsurfaceを引数として設定することできますが、大抵のシステム環境では幅32x高さ32以下の画像を求められます。設定した画像は透明色を持つことができ、設定時にはその色もシステムへと伝えられます。

環境によってはウィンドウが表示された後だとウィンドウアイコンが変更できないこともあります。ディスプレイモードが設定される前にウィンドウのアイコンを作成するには、pygame.display.set_mode命令よりも前にこの命令を実行します。

change the system image for the display window
pygame.display.set_icon(Surface): return None

Sets the runtime icon the system will use to represent the display window. All windows default to a simple pygame logo for the window icon.

You can pass any surface, but most systems want a smaller image around 32x32. The image can have colorkey transparency which will be passed to the system.

Some systems do not allow the window icon to change after it has been shown. This function can be called before pygame.display.set_mode - initialize a window or screen for display to create the icon before the display mode is set.


pygame.display.set_caption

ウィンドウのタイトルを設定します。
pygame.display.set_caption(title, icontitle=None): return None

ディスプレイがウィンドウタイトルを持っていた場合、この命令でウィンドウのタイトル名前を変更できます。環境によっては最小化されたディスプレイに合わせた短いタイトルをサポートしています。

set the current window caption
pygame.display.set_caption(title, icontitle=None): return None

If the display has a window title, this function will change the name on the window. Some systems support an alternate shorter title to be used for minimized displays.


pygame.display.get_caption

ウィンドウのタイトルを取得します。
pygame.display.get_caption(): return (title, icontitle)

ディスプレイSurfaceの、タイトルとアイコンタイトルを戻り値として返します。大抵はタイトルとアイコンタイトルは同じ値になります。

get the current window caption
pygame.display.get_caption(): return (title, icontitle)

Returns the title and icontitle for the display Surface. These will often be the same value.


pygame.display.set_palette

インデックス化されたディスプレイのカラーパレットを設定します。
pygame.display.set_palette(palette=None): return None

8bitディスプレイのビデオディスプレイカラーパレットを変更します。This does not change the palette for the actual display Surface, only the palette that is used to display the Surface.palette 引数を設定しなかった場合は、システムの既定パレットに設定し直されます。palette引数にはRGB形式の三つの色情報を保持したタプル型の値を、シーケンス型としてつないだものを設定します。

set the display color palette for indexed displays
pygame.display.set_palette(palette=None): return None

This will change the video display color palette for 8bit displays. This does not change the palette for the actual display Surface, only the palette that is used to display the Surface. If no palette argument is passed, the system default palette will be restored. The palette is a sequence of RGB triplets.