/** * Set up a 2D orthographic projection matrix * * @param gl * @param left * @param right * @param bottom * @param top */ public static void gluOrtho2D(GL10 gl, double left, double right, double bottom, double top) { gl.glOrthof((float) left, (float) right, (float) bottom, (float) top, -1.0f, 1.0f); }
@Override public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) { mGL.glOrthof(left, right, bottom, top, zNear, zFar); }
/** * Set up a 2D orthographic projection matrix * * @param gl * @param left * @param right * @param bottom * @param top */ public static void gluOrtho2D(GL10 gl, double left, double right, double bottom, double top) { gl.glOrthof((float) left, (float) right, (float) bottom, (float) top, -1.0f, 1.0f); }
public void glOrthof(float left, float right, float bottom, float top, float near, float far) { mCurrent.glOrthof(left, right, bottom, top, near, far); mgl.glOrthof(left, right, bottom, top, near, far); if ( _check) check(); }
public void glOrthof(float left, float right, float bottom, float top, float near, float far) { mCurrent.glOrthof(left, right, bottom, top, near, far); mgl.glOrthof(left, right, bottom, top, near, far); if ( _check) check(); }
public void glOrthof(float left, float right, float bottom, float top, float near, float far) { mCurrent.glOrthof(left, right, bottom, top, near, far); mgl.glOrthof(left, right, bottom, top, near, far); if ( _check) check(); }
@Override public void onSurfaceChanged(GL10 gl, int width, int height) { gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrthof(0, width, 0, height, -10f, 10f); gl.glViewport(0, 0, width, height); // ... }
public void onSurfaceChanged(GL10 gl, int w, int h) { n_width = w; n_height = h; gl.glViewport(0, 0, n_width, n_height); gl.glMatrixMode( GL_PROJECTION ); gl.glLoadIdentity(); gl.glOrthof(0.f, (float)m_width, (float)m_height, 0.f, -1.f, 1.0f); }
public void onSurfaceChanged(GL10 gl, int width, int height) { gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); //make sure to reset before glOrthof gl.glOrthof(0, 320f, 480f, 0, 0, 1); }
public void onSurfaceChanged(GL10 gl, int width, int height) { gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrthof(0f, 320, 0f, 320*aspect, -1f, 1f); }
@Override public void onSurfaceChanged(GL10 gl, int width, int height) { // prevent 0 divide if(height == 0) { height=1; } screenWidth = width; screenHeight = height; ratio = (float) width/height; gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrthof(0, width, 0, height, -10f, 10f); gl.glViewport(0, 0, screenWidth, screenHeight);
public void onSurfaceChanged(GL10 gl, int width, int height) { _Width = width; _Height = height; gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrthof(0.0f, width, height, 0.0f, 0.0f, 1.0f); gl.glMatrixMode(GL10.GL_MODELVIEW); }
public void on initState { GL10 gl = glGraphics.getGL(); gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrthof(x1, x2, y1, y2, 1, -1); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); }
//e.g call this from MainActivity's onCreate. Note this will not be within the openGL // thread, so you can't do opengl calls! (try it!) public void my_non_openGL_stuff_initialization(){ world = new World(new Vec2(0.0f, -9.8f), false); r = new Rect(); createObject(300, 500, 0.75f, 0.75f, BodyType.STATIC); createObject(360, 1200, 0.75f, 0.75f, BodyType.DYNAMIC); } //Note this runs on the opengl thread. You should always recreate all your opengl related //things here. This gets called at the begining, and when coming back from a pause @Override public void onSurfaceCreated(GL10 gl, EGLConfig eglConfig) { gl.glViewport(0, 0, 600, 1024); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrthof(0, 600, 0, 1024, 1, -1); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); }
public void onDrawFrame(GL10 gl) { gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); /* SET NEW PROJECTION HERE: ortho or perspective */ gl.glOrthof(0, _width, 0, _height, 0.001f, 100); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); /* SET NEW MODELVIEW MATRIX( space transformation ) HERE and DRAW YOUR STUFF */ //change zvalues if(locZ >= 99.0f){ speedZ *= -1.0f; locZ = 99.0f; } else if(locZ <= 1.0){ speedZ *= -1.0f; locZ = 1.0f; } }
@Override public void onDrawFrame(GL10 gl) { gl.glClear(GL10.GL_COLOR_BUFFER_BIT); gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrthof(0.0f, width, 0.0f, height, -1.0f, 1.0f); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); gl.glEnable(GL10.GL_BLEND); gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); gl.glEnable(GL10.GL_TEXTURE_2D); manObjects.draw(gl, 0, 0); }
/** * Begin drawing labels. Sets the OpenGL state for rapid drawing. * * @param gl * @param viewWidth * @param viewHeight */ public void beginDrawing(GL10 gl, float viewWidth, float viewHeight) { checkState(STATE_INITIALIZED, STATE_DRAWING); gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID); gl.glShadeModel(GL10.GL_FLAT); gl.glEnable(GL10.GL_BLEND); gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); gl.glColor4x(0x10000, 0x10000, 0x10000, 0x10000); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glOrthof(0.0f, viewWidth, 0.0f, viewHeight, 0.0f, 1.0f); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); // Magic offsets to promote consistent rasterization. gl.glTranslatef(0.375f, 0.375f, 0.0f); }
/** * Begin drawing labels. Sets the OpenGL state for rapid drawing. * * @param gl * @param viewWidth * @param viewHeight */ public void beginDrawing(GL10 gl, float viewWidth, float viewHeight) { checkState(STATE_INITIALIZED, STATE_DRAWING); gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID); gl.glShadeModel(GL10.GL_FLAT); gl.glEnable(GL10.GL_BLEND); gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); gl.glColor4x(0x10000, 0x10000, 0x10000, 0x10000); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glOrthof(0.0f, viewWidth, 0.0f, viewHeight, 0.0f, 1.0f); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); // Magic offsets to promote consistent rasterization. gl.glTranslatef(0.375f, 0.375f, 0.0f); }