0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PyOpenGLを使ってglGet系の値の定数名を文字で表示する

Posted at

glGetInternalformativglGetTexParameteriv などのglGet系関数で得た値の意味は,一般人にはすぐには分かりにくいですが,PyOpenGLであればその定数名を文字列にするのがカンタンです.
やり方は,OpenGL.GLの中から対応する数値の変数名を線形探索するだけです.
Cでも数値の意味をヘッダから探したりコンパイルが入ったりと面倒なので,対応しているOpenGLの機能などの表示をサクッとしたいときに良いと思います.

※下記はフロントエンド(GLコンテキスト生成)にPySDL2を選択していますが,glfwでもfreeglutでもeglでも,GLコンテキストが作れればなんでもいいです.

from sdl2 import *
from OpenGL.GL import *

SDL_Init(SDL_INIT_VIDEO)
window=SDL_CreateWindow(b"test",0,0,480,480,SDL_WINDOW_HIDDEN|SDL_WINDOW_OPENGL)
context=SDL_GL_CreateContext(window)

pf=glGetInternalformativ(GL_TEXTURE_2D, GL_RGBA8, GL_INTERNALFORMAT_PREFERRED, 1)

print([i for i in dir(OpenGL.GL) if
    i in globals() and
    type(globals()[i])==OpenGL.constant.IntConstant and
    int(globals()[i])==pf
    ])
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?