Skip to main content

Posts

Showing posts with the label opengl

Simple Java OpenGL Textures Manager

I'm trying to make a simple textures manager for a 2D tile-based project. What I have is a class that has a hashmap of strings (texture name) and textures. If the name doesn't exist in the hashmap, it uses TextureIO.newTexture(..) to create it and store it into the hashmap. This is the error I get when I try to load a texture: Exception in thread "Timer-0" javax.media.opengl.GLException: java.lang.IllegalArgumentException: Illegally formatted version identifier: "null" at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:271) at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:410) at javax.media.opengl.GLCanvas.display(GLCanvas.java:244) at com.sun.opengl.util.Animator.display(Animator.java:144) at com.sun.opengl.util.FPSAnimator$1.run(FPSAnimator.java:95) at java.util.TimerThread.mainLoop(Unknown Source) at java.util.TimerThread.run(Unknown Source) Caused by: java.lang.IllegalArgumen

Loading an animated image to a BufferedImage array

I'm trying to implement animated textures into an OpenGL game seamlessly. I made a generic ImageDecoder class to translate any BufferedImage into a ByteBuffer. It works perfectly for now, though it doesn't load animated images. I'm not trying to load an animated image as an ImageIcon. I need the BufferedImage to get an OpenGL-compliant ByteBuffer. How can I load every frames as a BufferedImage array in an animated image ? On a similar note, how can I get the animation rate / period ? Does Java handle APNG ?