GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


PHP Opengl texture code by iridium
1
 
      global $w32;
      $this->im = imagecreatetruecolor( 10, 10 );
      imagefilledrectangle( $this->im, -1, -1, 11, 11, 
                            imagecolorallocate( $this->im, 255, 255, 128 ) );
            
      // glGenTextures( 1, $num );
      $num = glmakenewtexture();
      $this->textureno = $num;
      
      // Fetch pointer to bitmap info for $this->im
      $gdptr = getgdptr( $this->im ) + 0x80;
      
      $w32->glBindTexture  ( GL_TEXTURE_2D, $this->textureno );
      $w32->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
      $w32->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
      $w32->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
      $w32->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
      // Generate a R = 255, G = 0, B = 255, A = 0 texture
      $test = str_repeat( "\0xff\0x00\0xff\0x00", 64 * 64 );
      // Function definition (Not entirely correct but sizes should be the same)
      // void glTexImage2D( int textype, int level, int interalformat, int w, int h, int border, int format, int type, char *pixeldata );
      $w32->glTexImage2D( GL_TEXTURE_2D, 0, 0, 64, 64, 0, GL_RGB, GL_4_BYTES, $test );