| 1099 | |
| 1100 | |
| 1101 | protected void setSize(int w, int h) { |
| 1102 | width = w; |
| 1103 | height = h; |
| 1104 | |
| 1105 | if (PGraphicsOpenGL.npotTexSupported) { |
| 1106 | glWidth = w; |
| 1107 | glHeight = h; |
| 1108 | } else { |
| 1109 | glWidth = PGL.nextPowerOfTwo(w); |
| 1110 | glHeight = PGL.nextPowerOfTwo(h); |
| 1111 | } |
| 1112 | |
| 1113 | if (glWidth > PGraphicsOpenGL.maxTextureSize || |
| 1114 | glHeight > PGraphicsOpenGL.maxTextureSize) { |
| 1115 | glWidth = glHeight = 0; |
| 1116 | throw new RuntimeException("Image width and height cannot be" + |
| 1117 | " larger than " + |
| 1118 | PGraphicsOpenGL.maxTextureSize + |
| 1119 | " with this graphics card."); |
| 1120 | } |
| 1121 | |
| 1122 | // If non-power-of-two textures are not supported, and the specified width |
| 1123 | // or height is non-power-of-two, then glWidth (glHeight) will be greater |
| 1124 | // than w (h) because it is chosen to be the next power of two, and this |
| 1125 | // quotient will give the appropriate maximum texture coordinate value given |
| 1126 | // this situation. |
| 1127 | maxTexcoordU = (float)width / glWidth; |
| 1128 | maxTexcoordV = (float)height / glHeight; |
| 1129 | } |
| 1130 | |
| 1131 | |
| 1132 | /** |