Merge pull request #574 from wolsen/issue-573
Use AWTTextureIO for creating textures from jpegs
This commit is contained in:
commit
d9a3cbb39c
@ -1,22 +1,22 @@
|
|||||||
package net.sf.openrocket.gui.figure3d;
|
package net.sf.openrocket.gui.figure3d;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.jogamp.opengl.GL;
|
import javax.imageio.ImageIO;
|
||||||
import com.jogamp.opengl.GLAutoDrawable;
|
|
||||||
import com.jogamp.opengl.GLProfile;
|
|
||||||
|
|
||||||
import net.sf.openrocket.appearance.Decal;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.jogamp.opengl.GLAutoDrawable;
|
||||||
|
import com.jogamp.opengl.GLProfile;
|
||||||
import com.jogamp.opengl.util.texture.Texture;
|
import com.jogamp.opengl.util.texture.Texture;
|
||||||
import com.jogamp.opengl.util.texture.TextureData;
|
import com.jogamp.opengl.util.texture.awt.AWTTextureIO;
|
||||||
import com.jogamp.opengl.util.texture.TextureIO;
|
|
||||||
|
import net.sf.openrocket.appearance.Decal;
|
||||||
|
|
||||||
public class TextureCache {
|
public class TextureCache {
|
||||||
private static final Logger log = LoggerFactory.getLogger(TextureCache.class);
|
private static final Logger log = LoggerFactory.getLogger(TextureCache.class);
|
||||||
@ -83,8 +83,8 @@ public class TextureCache {
|
|||||||
try {
|
try {
|
||||||
log.debug("Loading texture " + uri);
|
log.debug("Loading texture " + uri);
|
||||||
InputStream is = uri.openStream();
|
InputStream is = uri.openStream();
|
||||||
TextureData data = TextureIO.newTextureData(GLProfile.getDefault(), is, GL.GL_RGBA, GL.GL_RGBA, true, null);
|
BufferedImage img = ImageIO.read(is);
|
||||||
tex = TextureIO.newTexture(data);
|
tex = AWTTextureIO.newTexture(GLProfile.getDefault(), img, true);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error("Error loading Texture", e);
|
log.error("Error loading Texture", e);
|
||||||
}
|
}
|
||||||
@ -118,8 +118,8 @@ public class TextureCache {
|
|||||||
try {
|
try {
|
||||||
log.debug("Loading texture " + decal);
|
log.debug("Loading texture " + decal);
|
||||||
InputStream is = decal.getImage().getBytes();
|
InputStream is = decal.getImage().getBytes();
|
||||||
TextureData data = TextureIO.newTextureData(GLProfile.getDefault(), is, GL.GL_RGBA, GL.GL_RGBA, true, null);
|
BufferedImage img = ImageIO.read(is);
|
||||||
tex = TextureIO.newTexture(data);
|
tex = AWTTextureIO.newTexture(GLProfile.getDefault(), img, true);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error("Error loading Texture", e);
|
log.error("Error loading Texture", e);
|
||||||
}
|
}
|
||||||
|
@ -114,30 +114,31 @@
|
|||||||
*/
|
*/
|
||||||
package net.sf.openrocket.gui.figure3d.photo.exhaust;
|
package net.sf.openrocket.gui.figure3d.photo.exhaust;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.jogamp.common.nio.Buffers;
|
||||||
import com.jogamp.opengl.GL;
|
import com.jogamp.opengl.GL;
|
||||||
import com.jogamp.opengl.GL2;
|
import com.jogamp.opengl.GL2;
|
||||||
import com.jogamp.opengl.GLProfile;
|
import com.jogamp.opengl.GLProfile;
|
||||||
import com.jogamp.opengl.fixedfunc.GLLightingFunc;
|
import com.jogamp.opengl.fixedfunc.GLLightingFunc;
|
||||||
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
|
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
|
||||||
import com.jogamp.opengl.glu.GLU;
|
import com.jogamp.opengl.glu.GLU;
|
||||||
|
import com.jogamp.opengl.util.texture.Texture;
|
||||||
|
import com.jogamp.opengl.util.texture.awt.AWTTextureIO;
|
||||||
|
|
||||||
import net.sf.openrocket.motor.Motor;
|
import net.sf.openrocket.motor.Motor;
|
||||||
import net.sf.openrocket.util.Color;
|
import net.sf.openrocket.util.Color;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.jogamp.common.nio.Buffers;
|
|
||||||
import com.jogamp.opengl.util.texture.Texture;
|
|
||||||
import com.jogamp.opengl.util.texture.TextureData;
|
|
||||||
import com.jogamp.opengl.util.texture.TextureIO;
|
|
||||||
|
|
||||||
public final class FlameRenderer {
|
public final class FlameRenderer {
|
||||||
|
|
||||||
public interface FlameSettings {
|
public interface FlameSettings {
|
||||||
@ -308,18 +309,14 @@ public final class FlameRenderer {
|
|||||||
public static void init(GL2 gl) {
|
public static void init(GL2 gl) {
|
||||||
try {
|
try {
|
||||||
log.debug("Loading Textures");
|
log.debug("Loading Textures");
|
||||||
TextureData data = TextureIO.newTextureData(GLProfile.getDefault(),
|
BufferedImage img = ImageIO.read(FlameRenderer.class.getResourceAsStream("/datafiles/flame/c-color.png"));
|
||||||
FlameRenderer.class.getResourceAsStream("/datafiles/flame/c-color.png"), GL.GL_RGBA, GL.GL_RGBA,
|
smokeT = AWTTextureIO.newTexture(GLProfile.getDefault(), img, true);
|
||||||
true, null);
|
|
||||||
smokeT = TextureIO.newTexture(data);
|
img = ImageIO.read(FlameRenderer.class.getResourceAsStream("/datafiles/flame/c-normal.png"));
|
||||||
data = TextureIO.newTextureData(GLProfile.getDefault(),
|
smokeN = AWTTextureIO.newTexture(GLProfile.getDefault(), img, true);
|
||||||
FlameRenderer.class.getResourceAsStream("/datafiles/flame/c-normal.png"), GL.GL_RGBA, GL.GL_RGBA,
|
|
||||||
true, null);
|
img = ImageIO.read(FlameRenderer.class.getResourceAsStream("/datafiles/flame/smoke2.png"));
|
||||||
smokeN = TextureIO.newTexture(data);
|
flameT = AWTTextureIO.newTexture(GLProfile.getDefault(), img, true);
|
||||||
data = TextureIO.newTextureData(GLProfile.getDefault(),
|
|
||||||
FlameRenderer.class.getResourceAsStream("/datafiles/flame/smoke2.png"), GL.GL_RGBA, GL.GL_RGBA,
|
|
||||||
true, null);
|
|
||||||
flameT = TextureIO.newTexture(data);
|
|
||||||
|
|
||||||
log.debug("Loading Shader");
|
log.debug("Loading Shader");
|
||||||
String line;
|
String line;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user