@Override public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) { GL2 gl2 = arg0.getGL().getGL2(); gl2.glMatrixMode(GL2.GL_PROJECTION); gl2.glLoadIdentity(); // coordinate system origin at lower left with width and height same as the window GLU glu = new GLU(); glu.gluOrtho2D(0.0f, getWidth(), 0.0f, getHeight()); gl2.glMatrixMode(GL2.GL_MODELVIEW); gl2.glLoadIdentity(); gl2.glViewport(0, 0, getWidth(), getHeight()); controller.updateExtents(arg3 / 2, arg4 / 2); } }
private void endRendering(final boolean ortho) { final GL2 gl = GLContext.getCurrentGL().getGL2(); final Texture texture = getTexture(); texture.disable(gl); if (ortho) { gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glPopMatrix(); gl.glMatrixMode(GL.GL_TEXTURE); gl.glPopMatrix(); } gl.glPopAttrib(); }
private void orient( final GL2 gl ) { if( this.config.getOrientation()[0] != 0 ) { gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW ); final double[] o = this.config.getOrientation(); for( int i = 0; i < o.length; i+=4 ) gl.glRotated( o[i], o[i+1], o[i+2], o[i+3] ); } }
@Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height0) { GL2 gl = drawable.getGL().getGL2(); // get the OpenGL 2 graphics context int height = height0; if (height == 0) { height = 1; // prevent divide by zero } float aspect = (float) width / height; // Set the view port (display area) to cover the entire window gl.glViewport(0, 0, width, height); // Setup perspective projection, with aspect ratio matches viewport gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); // choose projection matrix gl.glLoadIdentity(); // reset projection matrix glu.gluPerspective(45.0, aspect, 0.1, 100.0); // fovy, aspect, zNear, // zFar // Enable the model-view transform gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glLoadIdentity(); // reset }
/** * Apply the camera to a GL context. * * @param gl GL context. */ public void apply(GL2 gl) { // 3D projection gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); // Perspective. glu.gluPerspective(35, ratio, 1, 1000); glu.gluLookAt(distance * sinZ, distance * -cosZ, height, // pos 0, 0, .5, // center 0, 0, 1 // up ); // Change back to model view matrix. gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); // Store the matrixes for reference. gl.glGetIntegerv(GL.GL_VIEWPORT, viewp, 0); gl.glGetDoublev(GLMatrixFunc.GL_MODELVIEW_MATRIX, modelview, 0); gl.glGetDoublev(GLMatrixFunc.GL_PROJECTION_MATRIX, projection, 0); }
@Override public void applyInternalTransform( DrawContext dc, boolean textureIdentityActive ) { GL2 gl = GLContext.getCurrent( ).getGL( ).getGL2( ); if ( !textureIdentityActive ) { gl.glMatrixMode( GL2.GL_TEXTURE ); gl.glLoadIdentity( ); } gl.glScaled( scaleX, scaleY, 1 ); }
/** * Main render method * * @param gl GL context */ public final void render(GL2 gl) { gl.glMatrixMode(GL2.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glOrtho(0, width, 0, height, -1, +1); gl.glColor4f(0f, 0f, 0f, .5f); // Fade background: gl.glBegin(GL2.GL_QUADS); gl.glVertex2f(0f, 0f); gl.glVertex2f(width, 0f); gl.glVertex2f(width, height); gl.glVertex2f(0f, height); gl.glEnd(); renderContents(gl); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPopMatrix(); }
/** * {@inheritDoc} * * @see javax.media.opengl.GLEventListener#reshape(javax.media.opengl.GLAutoDrawable, * int, int, int, int) */ @Override public void reshape( final GLAutoDrawable drawable, final int arg1, final int arg2, final int arg3, final int arg4 ) { final GL2 gl = drawable.getGL().getGL2(); final float w = this.window.getDrawableSurface().getWidth(); final float h = this.window.getDrawableSurface().getHeight(); gl.glMatrixMode( GLMatrixFunc.GL_PROJECTION ); gl.glLoadIdentity(); this.glu.gluPerspective( 50, (w / h), 0.01, 10 ); }
@Override public void init( final GLAutoDrawable drawable ) { final GL2 gl = drawable.getGL().getGL2(); gl.setSwapInterval( 1 ); gl.glEnable( GL.GL_DEPTH_TEST ); gl.glDepthFunc( GL.GL_LEQUAL ); gl.glShadeModel( GLLightingFunc.GL_SMOOTH ); gl.glHint( GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST ); // gl.glEnable( GL.GL_BLEND ); // gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA ); gl.glEnable( GL2GL3.GL_POLYGON_SMOOTH ); final float w = this.window.getDrawableSurface().getWidth(); final float h = this.window.getDrawableSurface().getHeight(); // Set the projection matrix (only done once - just here) gl.glMatrixMode( GLMatrixFunc.GL_PROJECTION ); gl.glLoadIdentity(); this.glu.gluPerspective( 50, (w / h), 0.01, 10 ); // Set the initial model matrix gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW ); gl.glLoadIdentity(); gl.glViewport( 0, 0, (int) w, (int) h ); /* viewport size in pixels */ }
gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW );
@Override public void display(GLAutoDrawable glad) { GL2 gl = (GL2)glad.getGL(); gl.glBlendFunc(GL_SRC_ALPHA, blends[iBlend]); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); new GLU().gluOrtho2D(-width / 2 - 1, width / 2 + 1, -height/2 - 1, height/2 + 1); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[0]); if (useOpenGLContext) { queue.finish(); } else { //interleavedColorAndPositionsMem.map(queue, CLMem.MapFlags.Read); interleavedColorAndPositionsMem.read(queue, interleavedColorAndPositionsTemp, true); gl.glBufferSubData(GL_ARRAY_BUFFER, 0, (int)interleavedColorAndPositionsTemp.getValidBytes(), interleavedColorAndPositionsTemp.getByteBuffer()); //interleavedColorAndPositionsMem.unmap(queue, interleavedColorAndPositionsTemp); } gl.glClear(GL_COLOR_BUFFER_BIT); gl.glColor3f(1.0f, 1.0f, 1.0f); //gl.glEnableClientState(GL_VERTEX_ARRAY); //gl.glEnableClientState(GL_COLOR_ARRAY); //gl.glColorPointer(4, GL_UNSIGNED_BYTE, elementSize, gl.glInterleavedArrays(GL2.GL_C4UB_V2F, elementSize, 0); gl.glDrawArrays(GL_POINTS, 0, particlesCount); gl.glBindBuffer(GL_ARRAY_BUFFER, 0); if (!paused) updateKernelArgs(); }
gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); glu.gluOrtho2D(0, width, 0, height); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glMatrixMode(GL.GL_TEXTURE); gl.glPushMatrix(); gl.glLoadIdentity();
gl.glDisable(GL.GL_CULL_FACE); gl.glDisable(GL.GL_DEPTH_TEST); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0f, 1f, 0f, StyleLibrary.SCALE, -1, 1); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity();
gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW ); gl.glTranslated( p2[0], p2[1], p2[2] ); gl.glRotated( object.object.xRotation, 1, 0, 0 ); gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW ); gl.glBegin( GL.GL_POINTS ); gl.glVertex3d( p2[0], p2[1], p2[2] );
gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW ); gl.glLoadIdentity();
gl2.glMatrixMode(gl2.GL_MODELVIEW); gl2.glLoadIdentity(); gl2.glMatrixMode(gl2.GL_PROJECTION); gl2.glLoadIdentity(); gl2.glOrtho(0, 0, view_width_, view_height_, 0.1, 100.0);
gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW ); gl.glTranslated( p[0], p[1], p[2] );
gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW );