GL_TEXTURE_RECTANGLE_ARBを使用してデータの生のテクスチャを使用しようとしています:
void Display::tex(){
GLubyte Texture[16] =
{
0,0,0,0, 0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF, 0,0,0,0
};
GLuint Nom;
glLoadIdentity();//load identity matrix
glTranslatef(0.0f,0.0f,-4.0f);//move forward 4 units
glEnable(GL_DEPTH_TEST); //Active le depth test
glDisable( GL_CULL_FACE );
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 2);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &Nom);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, Nom);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,
GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, 2, 2,
0, GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, Texture);
angle = 0.01 * glutGet ( GLUT_ELAPSED_TIME );
glRotatef(angle,0,1,1);
glBegin(GL_QUADS); //Et c'est parti pour le cube !
glTexCoord2i(0,0);glVertex3i(-1,-1,-1);
glTexCoord2i(1,0);glVertex3i(+1,-1,-1);
glTexCoord2i(1,1);glVertex3i(+1,+1,-1);
glTexCoord2i(0,1);glVertex3i(-1,+1,-1);
//1 face
glTexCoord2i(0,0);glVertex3i(-1,-1,+1);
glTexCoord2i(1,0);glVertex3i(+1,-1,+1);
glTexCoord2i(1,1);glVertex3i(+1,+1,+1);
glTexCoord2i(0,1);glVertex3i(-1,+1,+1);
//2 faces
glTexCoord2i(0,0);glVertex3i(+1,-1,-1);
glTexCoord2i(1,0);glVertex3i(+1,-1,+1);
glTexCoord2i(1,1);glVertex3i(+1,+1,+1);
glTexCoord2i(0,1);glVertex3i(+1,+1,-1);
//3 faces
glTexCoord2i(0,0);glVertex3i(-1,-1,-1);
glTexCoord2i(1,0);glVertex3i(-1,-1,+1);
glTexCoord2i(1,1);glVertex3i(-1,+1,+1);
glTexCoord2i(0,1);glVertex3i(-1,+1,-1);
//4 faces
glTexCoord2i(1,0);glVertex3i(-1,+1,-1);
glTexCoord2i(1,1);glVertex3i(+1,+1,-1);
glTexCoord2i(0,1);glVertex3i(+1,+1,+1);
glTexCoord2i(0,0);glVertex3i(-1,+1,+1);
//5 faces
glTexCoord2i(1,0);glVertex3i(-1,-1,+1);
glTexCoord2i(1,1);glVertex3i(+1,-1,+1);
glTexCoord2i(0,1);glVertex3i(+1,-1,-1);
glTexCoord2i(0,0);glVertex3i(-1,-1,-1);
//6 faces
glEnd();
glFlush();
}
結果はあまり良くありません:
http://shareimage.ro/images/xdkyd12oty44c0qpuo1b.png
立方体は、テクスチャが4つの正方形(2つの黒と2つの白)のすべての面を持っている必要があります。
エラーがどこにあるのかわかりません...