I am trying to create a graphics engine using OpenGL and PHP. I am
currently trying to create a completly white texture to test out the
texturing capabilities.
My idea is to create an array 256x256x3 of the value 255 to create a
completely white texture. When I do this in C it works fine but in PHP I
get a array of red, blue, green and black lines texturing the cube.
I have built a webpage detailing this problem:
http://www.marksblogg.com/opengl-php-texturing/
The texture creation happens in the following code. I appolgies that I
didn't clean up the code more prior to this. Any help or ideas would be
greatly appriciated.
$textpoint = null;
$p = "";
$pos = 0;
for( $x = 0; $x < 256; $x ++ )
for( $y = 0; $y < 256; $y ++ )
for( $d = 0; $d < 4; $d ++ )
{
// comes up black:
//$p[ $pos ] = sprintf( "%c", 255 );
// comes up with Red, green, blue, black stripes
//$p[ $pos ] = 0xff;
// comes up with Red, green, blue, black stripes
$p[ $pos ] = 255;
$pos ++;
}
glGenTextures(1 , &$textpoint );
glBindTexture(G L_TEXTURE_2D, $textpoint[ 0 ] );
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_ FILTER,GL_LINEA R);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_ FILTER,GL_LINEA R);
glTexImage2D(GL _TEXTURE_2D, 0, 3,
256, 256,
0, GL_RGB, GL_UNSIGNED_BYT E, $p);