0
代碼:FloatBuffer拋出異常?我怎樣才能解決這個問題?
FloatBuffer buf = BufferTools.reserveData(4);
float[] fl = new float[]{0.1f, 0.1f, 0.1f, 1.0f};
buf.put(fl);
其中buf.put(fl)
是線2039的錯誤都在談論:
Exception in thread "main" java.lang.IllegalArgumentException: Number of remaining buffer elements is 0, must be at least 4. Because at most 4 elements can be returned, a buffer with at least 4 elements is required, regardless of actual returned element count
at org.lwjgl.BufferChecks.throwBufferSizeException(BufferChecks.java:162)
at org.lwjgl.BufferChecks.checkBufferSize(BufferChecks.java:189)
at org.lwjgl.BufferChecks.checkBuffer(BufferChecks.java:258)
at org.lwjgl.opengl.GL11.glLight(GL11.java:2039)
at Joehot200.TerrainDemo.setUpLighting(TerrainDemo.java:1543)
at Joehot200.TerrainDemo.enterGameLoop(TerrainDemo.java:1984)
at Joehot200.TerrainDemo.startGame(TerrainDemo.java:2109)
at Joehot200.Main.main(Main.java:56)
我在做什麼錯?我只想擁有一個帶有4個元素的FloatBuffer,這樣我就可以設置OpenGL環境照明。
什麼是TerrainDemo:2109年,1984年和1543年? – Brian
因此,您向我們展示的代碼來自'org.lwjgl.opengl.GL11',而不是您自己的代碼? –
BufferTools不是'org.lwggl' API。它從何而來? –