/** * Method gluOrtho2D. * * @param left * @param right * @param bottom * @param top */ public void gluOrtho2D(final GL2 gl, final double left, final double right, final double bottom, final double top) { gl.glOrtho(left, right, bottom, top, -1, 1); }
@Override public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) { gl.glOrtho(left, right, bottom, top, zNear, zFar); }
gl.glLoadIdentity(); gl.glOrtho(-0.51*this.aspectRatio,0.51*this.aspectRatio,-0.51,0.51,-10,10); gl.glMatrixMode(GL_MODELVIEW); gl.glLoadIdentity();
/** Applies orthogonal projection only if parameters are valid (i.e. not zero) */ public void apply(GL gl){ if(left!=0 && right!=0 && bottom!=0 && top!=0 && near != 0 && far !=0){ gl.getGL2().glOrtho(left, right, bottom, top, near, far); } }
final GL2 gl = drawable.getGL().getGL2(); gl.glOrtho(left, right, bottom, top, near_val, far_val); gl.glEnable(cap);
public static void glOrtho( double left, double right, double bottom, double top, double near_val, double far_val) { gl().glOrtho( left, right, bottom, top, near_val, far_val); }
public void reshape( GLAutoDrawable drawable, int x, int y, int width, int height) { System.out.println(what+": reshape"); GL2 gl = drawable.getGL().getGL2(); gl.glViewport(0,0,width,height); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0); } public void display(GLAutoDrawable drawable) {
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL2 gl = drawable.getGL().getGL2(); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0, DIMENSION.getWidth(), DIMENSION.getHeight(), 0, 1.0, -1.0); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); }
glcanvas.addGLEventListener(new GLEventListener() { @Override public void reshape(GLAutoDrawable glautodrawable, int x, int y, int width, int height) { GL2 gl = glautodrawable.getGL().getGL2(); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); // Resets any previous projection matrices gl.glOrtho(0, width, 0, height, 1, -1); gl.glMatrixMode(GL2.GL_MODELVIEW); } ... Other methods }
protected void setupGLView() { int[] viewportDimensions = new int[4]; gl.glGetIntegerv(GL.GL_VIEWPORT, viewportDimensions, 0); int width = viewportDimensions[2]; int height = viewportDimensions[3]; // setup projection gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0, width, 0, height, -1, 1); // the MODELVIEW matrix will get adjusted later gl.glMatrixMode(GL.GL_TEXTURE); gl.glLoadIdentity(); }
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL2 gl; System.out.println("reshape "+x+","+y+" "+width+","+height); gl = drawable.getGL().getGL2(); newosdwidth=width; newosdheight=height; gl.glViewport(0, 0, newosdwidth, newosdheight); gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0,newosdwidth,newosdheight,0,-1.0,1.0); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glLoadIdentity(); gl.glClearColor( 0.0f, 0.0f, 0.0f, 0.0f); gl.glClear( gl.GL_COLOR_BUFFER_BIT); synchronized(newpbufferlock) { newpbuffer=true; } myConn.postResizeEvent(new java.awt.Dimension(c.getWidth(), c.getHeight())); }
/** * Switch to 2D viewing (an orthographic projection). * * @param gl * gl * @param panelWidth * width * @param panelHeight * height */ public static void begin2D(GL2 gl, double panelWidth, double panelHeight) { gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); // save projection settings gl.glPushMatrix(); gl.glLoadIdentity(); gl.glOrtho(0.0f, panelWidth, panelHeight, 0.0f, -1.0f, 1.0f); // left, right, bottom, top, near, far /* * In an orthographic projection, the y-axis runs from the bottom-left, * upwards. This is reversed back to the more familiar top-left, * downwards, by switching the the top and bottom values in glOrtho(). */ gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); // save model view settings gl.glPushMatrix(); gl.glLoadIdentity(); // gl.glDisable(GL.GL_DEPTH_TEST); }
protected void setupGLView() { int[] viewportDimensions = new int[4]; gl.glGetIntegerv(GL.GL_VIEWPORT, viewportDimensions, 0); int width = viewportDimensions[2]; int height = viewportDimensions[3]; // setup projection gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0, width, 0, height, -1, 1); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glLoadIdentity(); // do the transform from Graphics2D coords to openGL coords gl.glTranslatef(0, height, 0); gl.glScalef(1, -1, 1); gl.glMatrixMode(GL.GL_TEXTURE); gl.glLoadIdentity(); }
void drawString(String text, int x, int y, java.awt.Color color, GL2 gl, com.jogamp.opengl.util.awt.TextRenderer tr) { //System.out.println("drawString "+ text + " x: "+x+" y: "+y); gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); //System.out.println("glOrtho(0,"+ c.getWidth() + ","+c.getHeight()+",0,-1.0,1.0)"); gl.glOrtho(0,c.getWidth(),0,c.getHeight(),-1.0,1.0); tr.begin3DRendering(); tr.setColor(color); tr.draw3D(text, x, c.getHeight()-y, 0, 1); tr.end3DRendering(); gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); }
gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0,osdwidth,0,osdheight,-1.0,1.0); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glLoadIdentity();
@Override public void afterDisplay(GL2 gl, GLU glu) { if (vizConfig.isSelectionEnable() && currentSelectionArea != null) { gl.glMatrixMode(GL2.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glOrtho(0, graphDrawable.getViewportWidth(), 0, graphDrawable.getViewportHeight(), -1, 1); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); currentSelectionArea.drawArea(gl, glu); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPopMatrix(); } graphIO.trigger(); }
@Override public void render(GL gl, GLU glu) { // gl.glDisable(GL2.GL_LIGHTING); if (gl.isGL2()) { // Set viewport and projection gl.getGL2().glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.getGL2().glPushMatrix(); gl.getGL2().glLoadIdentity(); applyViewport(gl, glu); gl.getGL2().glOrtho(0, screenWidth, 0, screenHeight, -1, 1); // Zoom and layout gl.getGL2().glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.getGL2().glPushMatrix(); gl.getGL2().glLoadIdentity(); ImageRenderer.renderImage(gl, imageData, imageWidth, imageHeight, screenWidth, screenHeight, -0.75f); // Restore matrices state gl.getGL2().glPopMatrix(); gl.getGL2().glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.getGL2().glPopMatrix(); } }
gl.glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity();
gl.glPushMatrix(); gl.glLoadIdentity(); gl.glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0);
gl.getGL2().glOrtho(AREA_LEFT, AREA_RIGHT, AREA_DOWN, AREA_TOP, -1, 1);