Top > C++ > OpenGL

OpenGL Edit

対応しているテクスチャフォーマットを調べる。 Edit

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 
-
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
!
|
-
|
!
|
|
|
|
!
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
!
 
namespace
{
  void t_formatCheck( 
      const GLenum aInternalFormat
      , const char* aInternalFormatName
      , const GLenum aFormat
      )
  {
    GLuint textureName;
 
    // 前処理
    glEnable(GL_TEXTURE_2D);
    glGenTextures(1 , &textureName);
    glBindTexture(GL_TEXTURE_2D , textureName);
 
    // テクスチャ作成
    glGetError();
    glTexImage2D(
        GL_PROXY_TEXTURE_2D , 0 , aInternalFormat , 4 , 4 ,
        0 , aFormat , GL_UNSIGNED_BYTE , 0
    );
    if ( glGetError() == GL_NO_ERROR )
    {
        GLint red = 0, green = 0, blue = 0, alpha = 0, luminance = 0, intensity = 0 ;
        glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &red) ;
        glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &green) ;
        glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &blue) ;
        glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &alpha) ;
        glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE, &luminance) ;
        glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTENSITY_SIZE, &intensity) ;
        printf( "%s: Success(%d,%d,%d,%d,%d,%d)\n" 
            , aInternalFormatName 
            , red , green , blue , alpha , luminance , intensity
            );
    }
    else
    {
        printf( "%s: Failure\n" , aInternalFormatName );
    }
 
    // 後処理
    glDeleteTextures(1 , &textureName);
    glDisable(GL_TEXTURE_2D);
  };
 
#define FormatCheck( aInternalFormat , aFormat ) t_formatCheck( aFormat , #aFormat , aInternalFormat )
 
  void t_allFormatCheck()
  {
      FormatCheck( GL_ALPHA, GL_ALPHA );
      FormatCheck( GL_ALPHA, GL_ALPHA4 );
      FormatCheck( GL_ALPHA, GL_ALPHA8 );
      FormatCheck( GL_ALPHA, GL_ALPHA12 );
      FormatCheck( GL_ALPHA, GL_ALPHA16 );
      FormatCheck( GL_LUMINANCE, GL_LUMINANCE );
      FormatCheck( GL_LUMINANCE, GL_LUMINANCE4 );
      FormatCheck( GL_LUMINANCE, GL_LUMINANCE8 );
      FormatCheck( GL_LUMINANCE, GL_LUMINANCE12 );
      FormatCheck( GL_LUMINANCE, GL_LUMINANCE16 );
      FormatCheck( GL_LUMINANCE_ALPHA, GL_LUMINANCE4_ALPHA4 );
      FormatCheck( GL_LUMINANCE_ALPHA, GL_LUMINANCE6_ALPHA2 );
      FormatCheck( GL_LUMINANCE_ALPHA, GL_LUMINANCE8_ALPHA8 );
      FormatCheck( GL_LUMINANCE_ALPHA, GL_LUMINANCE8_ALPHA8 );
      FormatCheck( GL_LUMINANCE, GL_INTENSITY );
      FormatCheck( GL_LUMINANCE, GL_INTENSITY4 );
      FormatCheck( GL_LUMINANCE, GL_INTENSITY8 );
      FormatCheck( GL_LUMINANCE, GL_INTENSITY12 );
      FormatCheck( GL_LUMINANCE, GL_INTENSITY16 );
      FormatCheck( GL_RGB, GL_R3_G3_B2 );
      FormatCheck( GL_RGB, GL_RGB4 );
      FormatCheck( GL_RGB, GL_RGB5 );
      FormatCheck( GL_RGB, GL_RGB8 );
      FormatCheck( GL_RGB, GL_RGB10 );
      FormatCheck( GL_RGB, GL_RGB12 );
      FormatCheck( GL_RGB, GL_RGB16 );
      FormatCheck( GL_RGBA, GL_RGBA2 );
      FormatCheck( GL_RGBA, GL_RGBA4 );
      FormatCheck( GL_RGBA, GL_RGB5_A1 );
      FormatCheck( GL_RGBA, GL_RGBA8 );
      FormatCheck( GL_RGBA, GL_RGB10_A2 );
      FormatCheck( GL_RGBA, GL_RGBA12 );
      FormatCheck( GL_RGBA, GL_RGBA16 );
  }
}

Reload   New Lower page making Edit Freeze Diff Upload Copy Rename   Front page List of pages Search Recent changes Backup Referer   Help   RSS of recent changes
Last-modified: (5457d)