2
看來我的紋理加載器在64位環境下運行時不再工作。即時通訊不知道,如果原因是64位虛擬機本身或文件位於64位文件系統。java/opengl:在64位虛擬機上加載紋理
要加載的圖像是RGBA PNG文件,它在32位Windows系統上正確顯示,但在我的64位win7上,某些顏色通道似乎翻轉了。
這裏是我的代碼:
InputStream is = Thread.currentThread().getContextClassLoader()
.getResourceAsStream(path);
BufferedImage bi = ImageIO.read(is);
is.close();
byte[] databytes = ((DataBufferByte) bi.getRaster().getDataBuffer()).getData();
ByteBuffer data = ByteBuffer.allocateDirect(databytes.length);
data.order(ByteOrder.nativeOrder());
data.put(databytes, 0, databytes.length);
data.rewind();
IntBuffer texb = IntBuffer.allocate(1);
binding.genTextures(1, texb);
binding.bindTexture(binding.TEXTURE_2D(), texb.get(0));
binding.texParameter(binding.TEXTURE_2D(), binding.TEXTURE_MIN_FILTER(),
binding.LINEAR());
binding.texParameter(binding.TEXTURE_2D(), binding.TEXTURE_MAG_FILTER(),
binding.LINEAR());
binding.texParameter(binding.TEXTURE_2D(), binding.TEXTURE_WRAP_S(),
binding.CLAMP());
binding.texParameter(binding.TEXTURE_2D(), binding.TEXTURE_WRAP_T(),
binding.CLAMP());
binding.texEnvi(binding.TEXTURE_ENV(), binding.TEXTURE_ENV_MODE(),
binding.MODULATE());
binding.texImage2D(binding.TEXTURE_2D(), 0, binding.RGBA(), bi.getWidth(),
bi.getHeight(), 0, binding.RGBA(), binding.UNSIGNED_BYTE(), data);
沒有人知道是什麼地方出錯了?謝謝!