Skip to content

Commit

Permalink
Merge pull request #6382 from mgsx-dev/fix/texture-arrray
Browse files Browse the repository at this point in the history
fix TextureArray mipmap generation, fixes #6380
  • Loading branch information
Tom-Ski committed Jan 29, 2021
2 parents 9e9ecd4 + 2294394 commit 3d1f76f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public void consumeTextureArrayData () {
disposePixmap = true;
}
Gdx.gl30.glTexSubImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, 0, 0, i, pixmap.getWidth(), pixmap.getHeight(), 1, pixmap.getGLInternalFormat(), pixmap.getGLType(), pixmap.getPixels());
if (useMipMaps) {
Gdx.gl20.glGenerateMipmap(GL30.GL_TEXTURE_2D_ARRAY);
}
if (disposePixmap) pixmap.dispose();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.badlogic.gdx.Application;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Mesh;
Expand All @@ -27,13 +28,17 @@
import com.badlogic.gdx.graphics.TextureArray;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g3d.utils.FirstPersonCameraController;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.graphics.profiling.GLErrorListener;
import com.badlogic.gdx.graphics.profiling.GLProfiler;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.tests.utils.GdxTest;
import com.badlogic.gdx.tests.utils.GdxTestConfig;

/** @author Tomski **/
@GdxTestConfig(requireGL30=true)
public class TextureArrayTest extends GdxTest {

TextureArray textureArray;
Expand Down Expand Up @@ -66,8 +71,14 @@ public void create () {
cameraController = new FirstPersonCameraController(camera);
Gdx.input.setInputProcessor(cameraController);

textureArray = new TextureArray(texPaths);
FileHandle [] texFiles = new FileHandle[texPaths.length];
for(int i=0 ; i<texPaths.length ; i++){
texFiles[i] = Gdx.files.internal(texPaths[i]);
}

textureArray = new TextureArray(true, texFiles);
textureArray.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
textureArray.setFilter(TextureFilter.MipMapLinearLinear, TextureFilter.Linear);
shaderProgram = new ShaderProgram(Gdx.files.internal("data/shaders/texturearray.vert"), Gdx.files.internal("data/shaders/texturearray.frag"));
System.out.println(shaderProgram.getLog());

Expand Down

0 comments on commit 3d1f76f

Please sign in to comment.