I am on Windows XP.
All i am doing is makeing a BufferedImage, then Drawing some grafics onto it g.drawString(“hello”, 50, 50). and seeing if that BufferedImage will load into your texture fella.
thought it should without a problem.
I am on Windows XP.
All i am doing is makeing a BufferedImage, then Drawing some grafics onto it g.drawString(“hello”, 50, 50). and seeing if that BufferedImage will load into your texture fella.
thought it should without a problem.
Depends on the format of the BufferedImage that you’re creating. The code that I sent out only deals with 2 particular formats. If your BufferedImage isn’t in one of those 2 formats, the memory buffer will be misaligned.
Ok thanks.
Basically the following flip image routine would work, too, however the colour components are wrong ordered:
BufferedImage loadImage(filename)
{
BufferedImage org = // loaded from PNG
int width = bild.getWidth();
int height = bild.getHeight();
BufferedImage new = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
Graphics2D graph = new.createGraphics();
graph.drawImage(org, 0, height, width, -height, null);
return new
}
I wonder why there isn’t a TYPE_3BYTE_RGB which would ideally fit…
Is there a way to correct the wrong colour order?
I ask this because next I’d like to load two PNG files, one holds the 24 bpp picture in RGB format and the other holds the 8 bpp Alphamask. Then with Graphics2D or so I’d like to drawImage(…) them both into one TYPE_4BYTE_RGBA BufferedImage (I know, there’s just TYPE_4BYTE_ABGR). Then this I feed to OpenGL, like in Greg’s tutorial.
…
textureManager.createManagedTexture(“foo”, bi, GL.GL_TEXTURE_2D, GL.GL_BGR, GL.GL_RGBA16_EXT, GL.GL_LINEAR, GL.GL_LINEAR, true, false);
i have got all QuickTime image formats and even all QuickTime media formats rendering in JOGL sweet as a nut… Not live video input mind (thats a different area, not so hard mind- i just left my iSight camera in the office today).
if anyone wants the code i can post it here np
one thing mind. coss i wanted it to work on MacOSX 10.3. i have used the new QTJava - it has a set of new calls that dont work on older versions of QTJava. Apple duss it again :)… But the code with a comments around the MovieControler added back- gets it all running on the old QTJava… Apple just moved some stuff around, and changed the MovieControler.But QTJava now works on MacOSX Java1.4.x so thats cool with me.
The new QTJava is under NDA so i cant say much about it… its free to download from there ADC site:
i just wanted it to work on Mac and Windows JOGL
QuickTime Streaming onto a 3d object is cool… sorry to all u Luinx lot… i just make stuff…
I bet it can be done alot faster- but this is only my first crack at it. i teefed the texture loader from ‘gregorypierce’ with some simple editing.
Post it man post it Will save me the trouble of doing it myself this weekend. The more code we share with other the better ;D
ok here it is ;D
import net.java.games.jogl.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class MainFrame extends Frame {
public MainFrame() {
try {
setSize(512, 384);
GLCapabilities glCaps = new GLCapabilities();
glCaps.setRedBits(8);
glCaps.setBlueBits(8);
glCaps.setGreenBits(8);
glCaps.setAlphaBits(8);
GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(glCaps);
add(canvas);
canvas.addGLEventListener(new RenderCanvas());
final Animator animator = new Animator(canvas);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
animator.stop();
System.exit(0);
}
});
show();
animator.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
import java.awt.image.*;
import net.java.games.jogl.GLEventListener;
import net.java.games.jogl.GL;
import net.java.games.jogl.GLU;
import net.java.games.jogl.GLDrawable;
import net.java.games.jogl.DebugGL;
public class RenderCanvas
implements GLEventListener {
// private static Logger logger = Logger.getLogger(“TestRenderer”);
private GL gl;
private GLU glu;
private GLDrawable glDrawable;
private TextureManager textureManager;
private QTTexture qtt;
private CubeModel cm;
float lightPos[] = {100.0f, 500.0f, 200.0f, 1.0f}; // Light Position
float lightAmb[] = {0.1f, 0.1f, 0.1f, 0.2f}; // Ambient Light Values00
float lightDif[] = {1f, 1f, 1f, 1.0f}; // Diffuse Light Value
float lightSpc[] = {0.2f, 0.2f, 0.2f, 0.3f}; // Specular Light Values
float specref[] = {1f, 1f, 1f, 1f}; // Matrial spectacula.
public void init(GLDrawable drawable) {
this.gl = drawable.getGL();
this.glu = drawable.getGLU();
this.glDrawable = drawable;
//This Will Clear The Background Color To Black
gl.glClearColor(0f, 0f, 0f, 0.0f);
//Enables Clearing Of The Depth Buffer
gl.glClearDepth(1.0);
//The Type Of Depth Test To Do
gl.glDepthFunc(gl.GL_LESS);
//Enables Depth Testing
gl.glEnable(gl.GL_DEPTH_TEST);
//Enables Smooth Color Shading
gl.glShadeModel(gl.GL_SMOOTH);
//Select The Projection Matrix
gl.glMatrixMode(gl.GL_PROJECTION);
//Reset The Projection Matrix
gl.glLoadIdentity();
// Stencil Buffer Setup
gl.glClearStencil(0);
// Really Nice Perspective Calculations
gl.glHint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST);
//Select The Modelview Matrix
gl.glMatrixMode(gl.GL_MODELVIEW);
// lighting settings
gl.glLightfv(gl.GL_LIGHT1, gl.GL_POSITION, lightPos); // Set Light1 Position
gl.glLightfv(gl.GL_LIGHT1, gl.GL_AMBIENT, lightAmb); // Set Light1 Ambience
gl.glLightfv(gl.GL_LIGHT1, gl.GL_DIFFUSE, lightDif); // Set Light1 Diffuse
gl.glLightfv(gl.GL_LIGHT1, gl.GL_SPECULAR, lightSpc); // Set Light1 Specular
gl.glEnable(gl.GL_LIGHT1); // Enable Light1
gl.glEnable(gl.GL_LIGHTING); // Enable Lighting
// turns material lighting on,
gl.glEnable(gl.GL_COLOR_MATERIAL);
gl.glColorMaterial(gl.GL_FRONT, gl.GL_AMBIENT_AND_DIFFUSE);
gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, specref);
gl.glMateriali(gl.GL_FRONT, gl.GL_SHININESS, 128);
// turn on blending.
gl.glEnable(gl.GL_BLEND);
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA);
/* turns on fog.
float fogColor[] = {0.0f, 0.0f, 0.0f, 1.0f};
int fogMode = gl.GL_LINEAR;
gl.glFogi(gl.GL_FOG_MODE, fogMode);
gl.glFogfv(gl.GL_FOG_COLOR, fogColor);
gl.glFogf(gl.GL_FOG_DENSITY, 0.5f);
gl.glHint(gl.GL_FOG_HINT, gl.GL_DONT_CARE);
gl.glFogf(gl.GL_FOG_START, 15.0f);
gl.glFogf(gl.GL_FOG_END, 27.0f);
*/
this.glDrawable.setGL(new DebugGL(drawable.getGL()));
this.textureManager = TextureManager.getInstance(gl, glu);
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glShadeModel(GL.GL_SMOOTH);
try {
// NEW!
System.out.println("QTTexture start."); int ra = 128;
qtt = new QTTexture("textures/testm2.mov", ra, ra);
System.out.println("QTTexture loaded done");
cm = new CubeModel(gl);
}
catch (Exception e) {
// logger.error("Unable to load texture", e );
System.out.println("Cant load texture");
}
try {
BufferedImage bi = qtt.getQT2BufferedImage();
System.out.println("kick it awake!!!!"); // NEW
textureManager.createManagedTexture("foo", bi,
GL.GL_TEXTURE_2D, GL.GL_BGR,
GL.GL_RGBA16_EXT, GL.GL_LINEAR,
GL.GL_LINEAR, true, false);
}
catch (Exception ex) {
System.out.println("off: " + ex.toString());
ex.printStackTrace();
}
System.out.println("Init GL is " + gl.getClass().getName());
}
private void animateTexture() {
try {
BufferedImage bi = qtt.getQT2BufferedImage();
textureManager.updateTexture(“foo”, bi);
}
catch (Exception ex) {
System.out.println("off: " + ex.toString());
ex.printStackTrace();
}
}
private float rot = 0f;
public void display(GLDrawable drawable) {
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glPushMatrix();
gl.glTranslatef(0f, 0f, -6f);
gl.glRotatef(rot, 0.5f, 0.8f, 0.6f);
rot = (rot + 3f);
animateTexture();
gl.glColor4f(1f, 1f, 1f, 0.4f);
textureManager.bindTexture("foo");
gl.glPushMatrix();
cm.draw(gl);
gl.glTranslatef(0f, 0f, 0.2f);
cm.draw(gl);
gl.glPopMatrix();
gl.glPopMatrix();
}
public void reshape(GLDrawable drawable, int x, int y, int width, int height) {
float h = (float) height / (float) width;
gl.glMatrixMode(GL.GL_PROJECTION);
System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
System.err.println();
System.err.println("glLoadTransposeMatrixfARB() supported: " +
gl.isFunctionAvailable("glLoadTransposeMatrixfARB"));
if (!gl.isFunctionAvailable("glLoadTransposeMatrixfARB")) {
// --- not using extensions
gl.glLoadIdentity();
}
else {
// --- using extensions
final float[] identityTranspose = new float[] {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};
gl.glLoadTransposeMatrixfARB(identityTranspose);
}
glu.gluPerspective(45.0f, h, 1f, 1000.0f);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
}
public void displayChanged(GLDrawable drawable, boolean modeChanged,
boolean deviceChanged) {
}
}
import net.java.games.jogl.GL;
import net.java.games.jogl.GLU;
// import org.apache.log4j.Logger;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.nio.ByteBuffer;
public class TextureManager {
// private static Logger logger = Logger.getLogger(“TextureManager”);
private GL gl;
private GLU glu;
private Map textures = new HashMap();
private TextureFactory textureFactory;
private static TextureManager instance;
protected TextureManager(GL gl, GLU glu) {
this.gl = gl;
this.glu = glu;
textureFactory = TextureFactory.getFactory(gl, glu);
}
public static synchronized TextureManager getInstance(GL gl, GLU glu) {
if (instance == null) {
instance = new TextureManager(gl, glu);
}
return instance;
}
public void bindTexture(String name) {
( (Texture) textures.get(name)).bind(gl);
}
public void updateTexture(String name, BufferedImage image) throws
TextureFormatException {
textureFactory.updateTexture((Texture)textures.get(name), image);
}
public void manageTexture(Texture texture) {
// logger.debug(“Managing texture [” + texture.getName() + “]”);
textures.put(texture.getName(), texture);
}
public Texture createTexture(String name,
String resourceName,
int target,
int srcPixelFormat,
int dstPixelFormat,
int minFilter,
int magFilter,
boolean wrap,
boolean mipmapped) throws IOException,
TextureFormatException {
return textureFactory.createTexture(name, resourceName, target,
srcPixelFormat,
dstPixelFormat, minFilter, magFilter,
wrap, mipmapped);
}
public Texture createManagedTexture(String name,
String resourceName,
int target,
int srcPixelFormat,
int dstPixelFormat,
int minFilter,
int magFilter,
boolean wrap,
boolean mipmapped) throws IOException,
TextureFormatException {
Texture texture = textureFactory.createTexture(name, resourceName, target,
srcPixelFormat,
dstPixelFormat, minFilter, magFilter, wrap, mipmapped);
manageTexture(texture);
return texture;
}
public Texture createManagedTexture(String name,
BufferedImage resourceName,
int target,
int srcPixelFormat,
int dstPixelFormat,
int minFilter,
int magFilter,
boolean wrap,
boolean mipmapped) throws IOException,
TextureFormatException {
Texture texture = textureFactory.createTexture(name, resourceName, target,
srcPixelFormat,
dstPixelFormat, minFilter, magFilter, wrap, mipmapped);
manageTexture(texture);
return texture;
}
}
import net.java.games.jogl.GL;
import net.java.games.jogl.GLU;
// import org.apache.log4j.Logger;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.awt.image.DataBufferInt;
import java.awt.image.AffineTransformOp;
import java.awt.geom.AffineTransform;
import java.io.File;
import java.io.IOException;
import java.nio.;
import java.awt.;
public class TextureFactory {
// private static Logger logger = Logger.getLogger(“TextureFactory”);
private static TextureFactory instance;
private GLU glu;
private GL gl;
protected TextureFactory(GL gl, GLU glu) {
this.gl = gl;
this.glu = glu;
}
public static synchronized TextureFactory getFactory(GL gl, GLU glu) {
if (instance == null) {
instance = new TextureFactory(gl, glu);
}
return instance;
}
protected BufferedImage loadImage(String resourceName) throws IOException {
// logger.debug(“Loading resource [” + resourceName + “]”);
BufferedImage bufferedImage = ImageIO.read(new File(resourceName));
// Flip Image
//
AffineTransform tx = AffineTransform.getScaleInstance(1, -1);
tx.translate(0, -bufferedImage.getHeight(null));
AffineTransformOp op = new AffineTransformOp(tx,
AffineTransformOp.
TYPE_NEAREST_NEIGHBOR);
bufferedImage = op.filter(bufferedImage, null);
return bufferedImage;
//return ImageIO.read( getClass().getClassLoader().getResourceAsStream( resourceName ));
}
protected ByteBuffer convertImageData(BufferedImage bufferedImage) throws
TextureFormatException {
ByteBuffer imageBuffer = null;
switch (bufferedImage.getType()) {
case BufferedImage.TYPE_CUSTOM: {
byte[] data = ( (DataBufferByte) bufferedImage.getRaster().
getDataBuffer()).getData();
imageBuffer = ByteBuffer.allocateDirect(data.length);
imageBuffer.order(ByteOrder.nativeOrder());
imageBuffer.put(data, 0, data.length);
break;
}
case BufferedImage.TYPE_3BYTE_BGR: {
byte[] data = ( (DataBufferByte) bufferedImage.getRaster().getDataBuffer()).
getData();
imageBuffer = ByteBuffer.allocateDirect(data.length);
imageBuffer.order(ByteOrder.nativeOrder());
imageBuffer.put(data, 0, data.length);
break;
}
default:
throw new TextureFormatException("Unsupported image type " +
bufferedImage.getType());
}
return imageBuffer;
}
protected int createTextureID() {
int[] tmp = new int[1];
gl.glGenTextures(1, tmp);
return tmp[0];
}
public Texture createTexture(String name,
BufferedImage bufferedImage,
int target,
int srcPixelFormat,
int dstPixelFormat,
int minFilter,
int magFilter,
boolean wrap,
boolean mipmapped) throws IOException,
TextureFormatException {
// logger.debug(“Creating texture [” + name + “],[” + resourceName + “]”);
return (buildTexture(name,
bufferedImage,
target,
srcPixelFormat,
dstPixelFormat,
minFilter,
magFilter,
wrap,
mipmapped));
}
public Texture createTexture(String name,
String resourceName,
int target,
int srcPixelFormat,
int dstPixelFormat,
int minFilter,
int magFilter,
boolean wrap,
boolean mipmapped) throws IOException,
TextureFormatException {
// logger.debug(“Creating texture [” + name + “],[” + resourceName + “]”);
BufferedImage bufferedImage = loadImage(resourceName);
return (buildTexture(name,
bufferedImage,
target,
srcPixelFormat,
dstPixelFormat,
minFilter,
magFilter,
wrap,
mipmapped));
}
public Texture buildTexture(String name,
BufferedImage bufferedImage,
int target,
int srcPixelFormat,
int dstPixelFormat,
int minFilter,
int magFilter,
boolean wrap,
boolean mipmapped) throws IOException,
TextureFormatException {
Texture texture = new Texture(name, target, srcPixelFormat, dstPixelFormat,
minFilter, magFilter, wrap, mipmapped);
// create the texture ID for this texture
//
int textureID = createTextureID();
texture.setTextureID(textureID);
// bind this texture
//
gl.glBindTexture(GL.GL_TEXTURE_2D, textureID);
// load the buffered image for this resource - save a copy to we can draw into it later
//
texture.setBufferedImage(bufferedImage);
// convert that image into a byte buffer of texture data
//
ByteBuffer textureBuffer = convertImageData(bufferedImage);
// set up the texture wrapping mode depending on whether or not
// this texture is specified for wrapping or not
//
int wrapMode = wrap ? GL.GL_REPEAT : GL.GL_CLAMP;
if (target == GL.GL_TEXTURE_2D) {
gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_S, wrapMode);
gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_T, wrapMode);
gl.glTexParameteri(target, GL.GL_TEXTURE_MIN_FILTER, minFilter);
gl.glTexParameteri(target, GL.GL_TEXTURE_MAG_FILTER, magFilter);
}
// create either a series of mipmaps of a single texture image based on what's loaded
//
if (mipmapped) {
glu.gluBuild2DMipmaps(target,
dstPixelFormat,
bufferedImage.getWidth(),
bufferedImage.getHeight(),
srcPixelFormat,
GL.GL_UNSIGNED_BYTE,
textureBuffer);
}
else {
gl.glTexImage2D(target,
0,
dstPixelFormat,
bufferedImage.getWidth(),
bufferedImage.getHeight(),
0,
srcPixelFormat,
GL.GL_UNSIGNED_BYTE,
textureBuffer);
}
return texture;
}
public void updateTexture(Texture texture, BufferedImage bufferedImage) throws
TextureFormatException {
// logger.debug(“Updating texture [” + texture.getName() + “]”);
// bind this texture
//
gl.glBindTexture(GL.GL_TEXTURE_2D, texture.getTextureID());
ByteBuffer textureBuffer = convertImageData(bufferedImage);
// create either a series of mipmaps of a single texture image based on what's loaded
//
if (texture.isMipmapped()) {
glu.gluBuild2DMipmaps(texture.getTarget(),
texture.getDstPixelFormat(),
bufferedImage.getWidth(),
bufferedImage.getHeight(),
texture.getSrcPixelFormat(),
GL.GL_UNSIGNED_BYTE,
textureBuffer);
}
else {
gl.glTexImage2D(texture.getTarget(),
0,
texture.getDstPixelFormat(),
bufferedImage.getWidth(),
bufferedImage.getHeight(),
0,
texture.getSrcPixelFormat(),
GL.GL_UNSIGNED_BYTE,
textureBuffer);
}
}
}
I still can’t get this to work, my textures just don’t show up. XP, ATI graphics card.
However, I noticed above that Ant? couldn’t get the INT format to work even once you’ve added the creation of the buffer.
You need to multiply the size of the buffer (data.length) by the size of an int, in the JOGL demo this is :
BufferUtils.SIZEOF_INT
However, I’d appreciate any suggestions…
Kev
package ant.games.texture;
import java.awt.;
import java.awt.image.;
import quicktime.;
import quicktime.app.view.; // New QTJava
import quicktime.io.;
import quicktime.qd.;
import quicktime.std.;
import quicktime.std.movies.;
import quicktime.std.movies.media.*;
public class QTTexture {
private boolean mov_loaded;
private DataRef qdr;
private Movie mov;
private MoviePlayer mp;
private int kwidth = 32;
private int kheight = 32;
public QTTexture(String file, int width, int height) {
this.mov_loaded = false;
this.kwidth = width;
this.kheight = height;
try {
QTSession.open();
}
catch (Exception ex) {
System.out.println("cant open quicktime");
}
try {
qdr = new DataRef(new QTFile(file));
mov = Movie.fromDataRef(qdr, StdQTConstants.newMovieActive);
mov.getTimeBase().setFlags(StdQTConstants.loopTimeBase); // QTJava new version.
// MovieController mc = new MovieController(mov); // Use for old QTJava
// mc.setLooping(true); // Use for old QTJava
mp = new MoviePlayer(mov);
mp.setRate(1f);
mov_loaded = true;
}
catch (Exception ex) {
System.out.println("cant play quicktime: " + ex.toString());
}
}
public BufferedImage getQT2BufferedImage() {
try {
if (mov_loaded) {
QDRect r = new QDRect(kwidth, kheight);
Dimension imageSize = new Dimension(r.getWidth(), r.getHeight());
QTImageProducer qtProducer = new QTImageProducer(mp, imageSize);
Image javaImage = Toolkit.getDefaultToolkit().createImage(qtProducer);
BufferedImage bi = new BufferedImage(r.getWidth(), r.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
Graphics bg = bi.getGraphics();
bg.drawImage(javaImage, 0, kheight, kwidth, -kheight, null);
bg.dispose();
return (bi);
} else {
System.out.println("cant find texture: " + qdr.toString());
}
return (null);
}
catch (Exception ex) {
System.out.println("cant get texture: " + ex.toString());
return (null);
}
}
}
and thats it… a fully working QTTexture loader for JOGL works cool on MacOSX and WindowsXP here…
hope it helps - oh and the Texture.java etc is from the java alreay here. i didnt have to change that at all
top result
Very nice. Thank you. No Linux QT is disappointing but I’ll still take it.
Got it all working, wahay!
Even got it handling ALPHA channels in PNG images.
Wahey!
Kev
Hey Ken you know the deal, post up your changes for dealing with your Alpha types. I have it working but not with all .png files and I’m trying to solve that problem before I post up the latest version. I’m also adding the QuickTime code to the core code and finishing up for the multitexture demo - also gives a demo on fonts ‘for free’.
That’d be Kev…
I’ll post source as soon as I can get my hands on it (I’m at work now, source is at home).
However, essentially the problem to me seems to be driving srcPixelFormat from the user’s request. The srcPixelFormat should be based on the image.
All I did was add a bufferedImage.getColorModel().hasAlpha() check and change the src pixel format to GL.GL_RGBA. Of course, you had to pass in a destPixelFormat of GL.GL_RGBA, otherwise the alpha gets stripped straight out.
I had this idea on the way in this morning, for coping with all images types. How about creating a buffered image of type INT_ARGB or INT_RGB depending on what you want to use. Then load the texture image and draw it into your precreated image using getGraphics().drawImage(). Then process the buffer into a texture. All oddities of image format should be handled then since the original draw will convert the image to the right type. Would this work?
Kev
That’s nice. Didn’t find the GL_BGR source pixel format in my OpenGL 1.1 Redbook but it’s handy for a newly created BufferedImage.
So now I can feed an own BufferedImage of TYPE_3BYTE-BGR to Jogl.
img = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
img.createGraphics().drawYourStuffHere(...)
int srcPixelformat = GL.GL_BGR;
int dstPixelformat = GL.GL_RGB;
byte[] array = ((DataBufferByte) img.getRaster().getDataBuffer()).getData();
gl.gluBuild2DMipmaps(o.GL_TEXTURE_2D,
dstPixelformat,
img.getWidth(), img.getHeight(),
srcPixelformat,
o.GL_UNSIGNED_BYTE,
array);
Works great.
However I still fail with a BufferedImage of TYPE_4BYTE-ABGR which I create manually.
img = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
img.createGraphics().drawYourStuffHere(...)
int srcPixelformat = GL.GL_ABGR_EXT;
int dstPixelformat = GL.GL_RGBA;
There’s no GL_ABGR_EXT in my OpenGL driver (newest Detonator driver), and the result of the above code gives me a white texture.
If I do
gl.isExtensionAvailable("GL_ABGR_EXT")
this returns false.
So, how can I feed this weird BufferedImage.TYPE_4BYTE_ABGR to OpenGL please?
Ok, there’s a brute force approach by swaping the pixel’s samples in the BufferedImage’s raster so that they fit to OpenGL’s GL_RBGA or GL_BGRA source pixel format. While this works I’m sure there must be an easier way.
If you use PNG, you get a CUSTOM image returned. This is formatted RGBA in bytes, which fits GL nicely
Kev
TYPE_4BYTE_ABGR reads from the lowest byte up…
So when packed into a byte, it would be RGBA. Which order does OpenGL specify its components in, e.g.
Isn’t GL.GL_RGBA equivilent to TYPE_4BYTE_ABGR?
Kev