Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 1.09 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. GLenum as property in Objective-C OpenGL
  2. if (numberOfMipmaps > 0) {
  3.     if (textureData != 0)
  4.         glDeleteTextures(1, &textureData);
  5.     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  6.     glGenTextures(1, &textureData);
  7.     glBindTexture(GL_TEXTURE_2D, textureData);
  8.     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  9.     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  10.     CHECK_GL_ERROR();
  11.  
  12.     for (GLint i = 0; i < numberOfMipmaps; i++) {
  13.         unsigned char *data = mipmaps[i].address;
  14.  
  15.         glTexImage2D(GL_TEXTURE_2D, i, internalFormat, width, height, 0, format, target, data);
  16.         //glGenerateMipmapOES(GL_TEXTURE_2D);
  17.         CHECK_GL_ERROR();
  18.  
  19.         width = MAX(width >> 1, 1);
  20.         height = MAX(height >> 1, 1);
  21.     }
  22. }
  23.        
  24. @property (nonatomic, assign) GLint internalFormat;
  25. @property (nonatomic, assign) GLenum format;
  26. @property (nonatomic, assign) GLenum target;
  27.        
  28. internalFormat = GL_RGBA;
  29. format = GL_RGBA;
  30. target = GL_UNSIGNED_SHORT_5_5_5_1;
  31.        
  32. glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT_565, data);