Update texture coordinates on the fly?

Is it possible to update a quad’s texture coordinates on the fly?



[java]skyquad.getMesh().setBuffer(Type.TexCoord, 2, BufferUtils.createFloatBuffer(texCoord));[/java]



This fails with “Data has already been sent. Cannot setupData again” exception.



And can you set texture coordinates higher than 1.0? And if so, will the texture wrap around?



To make a long story short, is it possible to simulate scrolling of the texture on a quad by changing the texture coordinates? Generally it would be cool to see some examples on how to manipulate typical texture things on a quad, for example adjust tiling in width/height, etc.

Dont set a new buffer, change the existing and call something like setbufferchanged or similar.



However scrolling textures are probalby better done in shader, since that does not need the bottleneck between cpu and gpu

Ok, would this be a huge bottleneck for one quad that needs updating per frame? I mean does the whole mesh/textures and all have to be flushed and reuploaded every frame?



How about real time editing of textures on a quad. Is that possible? I saw the snippet by maxxer for making custom textures but would it be possible to change texture on a quad for every frame, flip-flopping beteween two of these? In that case I know the texture has to be re-uploaded so that would be costly. I guess its more efficient if there is a way to access the texture in GPU memory for editing on the fly.

If you change the buffer it has to be reuploaded. Thtas that way with opengl or direct x.

And all texture editing tools does it that way. If you change between two, change the used texture in the material, and leave both unchanged, that way only the shader uniform needs to be updated, instead of a texture. Real time is no problem, if its only one quad, the troughput is somewhere around several gigabytes per second from cpu to gpu. But if you change much (severl dozen to a few hundred per frame), the delay this causes might be noticeable.



Also it’s not the whole mesh, each meash has several buffers, (the vertexe, normals, texturecoordiantes, only the one changed needs to be reuploaded.



Each material(Shader)

can have several textures it uses,

Each texture itself has a buffer,

so if you change the texture the texture needs to be uploaded.

if you change the uvcoords the uvbuffer needs to be uploaded

if you change the texture used, only the uniform the shader uses is changed.



Only way around would be to access the texture from opencl directly, but don’t worry about that, since this is a bit to much for the beginning.