Jump to content

Detecting change of texture pack


Recommended Posts

Hrm, could be.

I've discovered that OpenGL has a rather curious omission: You are not able to bind a portion of a texture file as a texture. This is an issue when trying to apply (for example) textures out of terrain.png onto arbitrary surfaces, because tiling becomes a major issue while trying to keep the texture orientation and resolution consistent. The built-in tiling mechanism in OpenGL (where you simply specify texture coordinates beyond the actual texture and it wraps around) works brilliantly...but only on full textures, not subtextures. The two real ways to handle this end up both having rather glaring flaws to consider.

One way is to split the geometry at tile boundaries, which at first seems a reasonable way, but since Minecraft already is an inefficiently-written program, increasing the scene's complexity unnecessarily really isn't a very good idea. Additionally, sometimes there would be generated very long, thin triangles, and these can cause severe visual oddities and glitches.

The other way is to copy the image data of a subtexture at runtime and bind it as a new texture. Minecraft already has the mechanisms to do this easily: You can (using RenderEngine) get the OpenGL index of the already-loaded texture, use that to access Minecraft's BufferedImage version of it, use getSubimage to get a new BufferedImage of the subtexture, and pass that right back to allocateAndSetupTexture. There are three major flaws with this, though: It uses more texture memory (which is often the weakest part of mid- and low-end graphics cards), the data go stale if the texture pack changes, and the animation of lava/water/fire textures are lost.

There is the option of, for every submodel of every block of every render frame, to rebind and then dispose of the texture to keep everything fresh, but I wouldn't be surprised if the massive overhead of all that would end up bringing Minecraft to its knees.

The only other option I can think of is to go with the copy option, somehow account for animated textures, and upon texture-pack change, require the user to either restart the program or use an in-game item or menu option to trigger a flush of copied textures. Maybe the mod could cache some identifying information about the current texture pack and validate it once per second or so, and auto-flush upon a change...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...