Allocates the opengl texture object.
()
| 1133 | * Allocates the opengl texture object. |
| 1134 | */ |
| 1135 | protected void allocate() { |
| 1136 | dispose(); // Just in the case this object is being re-allocated. |
| 1137 | |
| 1138 | boolean enabledTex = false; |
| 1139 | if (!pgl.texturingIsEnabled(glTarget)) { |
| 1140 | pgl.enableTexturing(glTarget); |
| 1141 | enabledTex = true; |
| 1142 | } |
| 1143 | |
| 1144 | context = pgl.getCurrentContext(); |
| 1145 | glres = new GLResourceTexture(this); |
| 1146 | |
| 1147 | pgl.bindTexture(glTarget, glName); |
| 1148 | pgl.texParameteri(glTarget, PGL.TEXTURE_MIN_FILTER, glMinFilter); |
| 1149 | pgl.texParameteri(glTarget, PGL.TEXTURE_MAG_FILTER, glMagFilter); |
| 1150 | pgl.texParameteri(glTarget, PGL.TEXTURE_WRAP_S, glWrapS); |
| 1151 | pgl.texParameteri(glTarget, PGL.TEXTURE_WRAP_T, glWrapT); |
| 1152 | if (PGraphicsOpenGL.anisoSamplingSupported) { |
| 1153 | pgl.texParameterf(glTarget, PGL.TEXTURE_MAX_ANISOTROPY, |
| 1154 | PGraphicsOpenGL.maxAnisoAmount); |
| 1155 | } |
| 1156 | |
| 1157 | // First, we use glTexImage2D to set the full size of the texture (glW/glH |
| 1158 | // might be diff from w/h in the case that the GPU doesn't support NPOT |
| 1159 | // textures) |
| 1160 | pgl.texImage2D(glTarget, 0, glFormat, glWidth, glHeight, 0, |
| 1161 | PGL.RGBA, PGL.UNSIGNED_BYTE, null); |
| 1162 | |
| 1163 | // Makes sure that the texture buffer in video memory doesn't contain |
| 1164 | // any garbage. |
| 1165 | pgl.initTexture(glTarget, PGL.RGBA, width, height); |
| 1166 | |
| 1167 | pgl.bindTexture(glTarget, 0); |
| 1168 | if (enabledTex) { |
| 1169 | pgl.disableTexturing(glTarget); |
| 1170 | } |
| 1171 | bound = false; |
| 1172 | } |
| 1173 | |
| 1174 | |
| 1175 | /** |
no test coverage detected