Re: Issue about textures and glOrtho
Posted by Daniel S. on Mar 22, 2011; 2:44pm
URL: https://forum.jogamp.org/Issue-about-textures-and-glOrtho-tp2675799p2715127.html
Hi,
thanks for your hints (statemachine ;-). I'm still not so firm with OpenGL.
I've tried gl.glDisable(GL.GL_DEPTH_TEST) and gl.glDisable(GL.GL_CULL_FACE); but nothing changed.
So I have search a lot in the internet and coded a new example. Now textures and glOrtho work fine. but I can't draw anythiong on my background image. I'm guessing that I have to load the Modelview matrix after drawing the quad with the texture. But I can't get it runnig....
Maybe you know the right instructions :-)
Here is my display Method:
public void display(GLAutoDrawable drawable) {
// TODO Auto-generated method stub
final GL gl = drawable.getGL();
// Clear screen.
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glMatrixMode(GL.GL_PROJECTION); // Select Projection
gl.glPushMatrix(); // Push The Matrix
gl.glLoadIdentity(); // Reset The Matrix
gl.glOrtho(0, 640, 480, 0, -1, 1); // Select Ortho Mode (640x480)
gl.glMatrixMode(GL.GL_MODELVIEW); // Select Modelview Matrix
gl.glPushMatrix(); // Push The Matrix
gl.glLoadIdentity(); // Reset The Matrix
// Enable two-dimensional texturing.
tex.enable ();
// Bind this texture to the current rendering context.
tex.bind ();
gl.glBegin(GL.GL_QUADS);
gl.glTexCoord2f(0, 1); // Texture Coordinate ( 0, 1 )
gl.glVertex2f(0, 0); // First Vertex ( 0, 0 )
// Texture Coordinate ( 0, 0 )
gl.glTexCoord2f(0, 0 );
gl.glVertex2f(0, 480); // Second Vertex ( 0, 480 )
// Texture Coordinate ( 1, 0 )
gl.glTexCoord2f(1 , 0 );
gl.glVertex2f(640, 480); // Third Vertex ( 640, 480 )
// Texture Coordinate ( 1, 1 )
gl.glTexCoord2f(1 , 1 );
gl.glVertex2f(640, 0); // Fourth Vertex ( 640, 0 )
gl.glEnd();
tex.disable ();
// this trinagle isn't shown
gl.glBegin(GL.GL_TRIANGLES);
gl.glColor3f(1,0,0);
gl.glVertex2d(100,100);
gl.glVertex2d(150,150);
gl.glVertex2d(300,300);
gl.glEnd();
}
Thanks in advance!
Greetings,
Daniel