At first, my english is not very good, so please don’t wonder if I use false grammar.
I have the following problem:
I want to draw an 2D Image with alpha 0.5 over some 3D objects so that they can be seen a bit. I’ve tried this with the following code (JOGL) but it just don’t draw the 3D objects (except if the image is not drawn, then the objects are drawn)
gl.glDisable( GL.GL_DEPTH_TEST );
gl.glWindowPos2i(0,engine.getHeight()/2);
gl.glDrawPixels(image.getWidth() ,image.getHeight() ,gl.GL_RGBA ,gl.GL_UNSIGNED_BYTE, image.getRGBABuf());//image.getRGBABuf() returns the pixel values (R G B A=0.5);
gl.glEnable(gl.GL_DEPTH_TEST);
This code is executed after the other objects are drawn
It is drawn with the following viewing volume:
private double [] position = { 0.0, 0.0, 5.0 };
private double [] lookAt = { 0.0, 0.0, 0.0 };
private double [] up = { 0.0, 1.0, 0.0 };
private double fovy = 45.0;
private double aspect = 1/4;
private double nearClip = 0.01;
private double farClip = 20;
...
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(fovy, aspect, nearClip, farClip);
gl.glMatrixMode(GL.GL_MODELVIEW);
...
glu.gluLookAt(position[0],position[1],position[2],lookAt[0],lookAt[1],lookAt[2],up[0],up[1],up[2]);
And Blending is also enabled:
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glEnable(gl.GL_BLEND);
Do anybody know whats wrong with this code (or can definitly say the OpenGL code is ok, but maybe there’s an problem with image itself)?