0
  InitTexture (  ) {
int size = 600 * 600 * 4;
float text[ 600 * 600 * 4 ];
glGenTextures ( 1, &texture_ );

glBindTexture ( GL_TEXTURE_2D, texture_ );
for ( int i = 0 ; i < size ;  ) {
    text[ i ] = 0.5f;
    text[ i + 1 ] = 0.0f;
    text[ i + 2 ] = 0.0f;
    text[ i + 3 ] = 1.0f;
    i += 4;
}
glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGBA, 600, 600, 0, GL_RGBA, GL_FLOAT, text
    );
glBindTexture ( GL_TEXTURE_2D, 0 );
Renderable::IsGLError ( "InitTexture: GL Error occured ..... " );
 }

このテクスチャ初期化を使用したアプリケーションは失敗します。

 int size = 600 * 600 * 4;     // global
 float text[ 600 * 600 * 4 ];  // global

 InitTexture (  ) {
glGenTextures ( 1, &texture_ );

glBindTexture ( GL_TEXTURE_2D, texture_ );
for ( int i = 0 ; i < size ;  ) {
    text[ i ] = 0.5f;
    text[ i + 1 ] = 0.0f;
    text[ i + 2 ] = 0.0f;
    text[ i + 3 ] = 1.0f;
    i += 4;
}
glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGBA, 600, 600, 0, GL_RGBA, GL_FLOAT, text
    );
glBindTexture ( GL_TEXTURE_2D, 0 );
 Renderable::IsGLError ( "InitTexture: GL Error occured ..... " );
 }

ただし、テキスト配列がグローバルポインタの場合は、正常に機能します。どういう意味ですか?glTexImage2Dはデータをコピーしませんか?

4

1 に答える 1

2

glTexImage2D は常にデータのコピーを作成します。エラーが発生した場合は、ソース データ バッファーの所在以外に別の理由があります。

于 2012-09-16T08:10:52.293 に答える