Java Code Examples for javax.microedition.khronos.opengles.GL10#glOrthof()

The following examples show how to use javax.microedition.khronos.opengles.GL10#glOrthof() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WaveformVisualizerSurfaceView.java    From android-openslmediaplayer with Apache License 2.0 6 votes vote down vote up
private static void drawWaveForm(
        GL10 gl, int width, int height,
        FloatBuffer vertices, int n, float ymin, float ymax, FloatColor color) {

    gl.glPushMatrix();

    // viewport
    gl.glViewport(0, 0, width, height);

    // X: [0:1], Y: [ymin:ymax]
    gl.glOrthof(0.0f, 1.0f, ymin, ymax, -1.0f, 1.0f);

    gl.glColor4f(color.red, color.green, color.blue, color.alpha);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glVertexPointer(2, GL10.GL_FLOAT, (2 * Float.SIZE / 8), vertices);
    gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, n);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

    gl.glPopMatrix();
}
 
Example 2
Source File: HQFftVisualizerSurfaceView.java    From android-openslmediaplayer with Apache License 2.0 6 votes vote down vote up
private static void drawFFT(
        GL10 gl, int width, int height,
        FloatBuffer vertices, int n,
        int vposition, float yrange, FloatColor color) {

    gl.glPushMatrix();

    // viewport
    gl.glViewport(0, (height / 2) * (1 - vposition), width, (height / 2));

    // X: [0:1], Y: [0:1]
    gl.glOrthof(0.0f, 1.0f, 0.0f, yrange, -1.0f, 1.0f);

    gl.glColor4f(color.red, color.green, color.blue, color.alpha);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glVertexPointer(2, GL10.GL_FLOAT, (2 * Float.SIZE / 8), vertices);
    gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, n);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

    gl.glPopMatrix();
}
 
Example 3
Source File: HQWaveformVisualizerSurfaceView.java    From android-openslmediaplayer with Apache License 2.0 6 votes vote down vote up
private static void drawWaveForm(
        GL10 gl, int width, int height,
        FloatBuffer vertices, int n, int vposition, float yrange, FloatColor color) {

    gl.glPushMatrix();

    // viewport
    gl.glViewport(0, (height / 2) * (1 - vposition), width, (height / 2));

    // X: [0:1], Y: [-1:+1] (scaled)
    gl.glOrthof(0.0f, 1.0f, -yrange, yrange, -1.0f, 1.0f);

    gl.glColor4f(color.red, color.green, color.blue, color.alpha);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glVertexPointer(2, GL10.GL_FLOAT, (2 * Float.SIZE / 8), vertices);
    gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, n);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

    gl.glPopMatrix();
}
 
Example 4
Source File: FftVisualizerSurfaceView.java    From android-openslmediaplayer with Apache License 2.0 6 votes vote down vote up
private static void drawFFT(
        GL10 gl, int width, int height,
        FloatBuffer vertices, int n,
        float yrange, FloatColor color) {

    gl.glPushMatrix();

    // viewport
    gl.glViewport(0, 0, width, height);

    // X: [0:1], Y: [0:yrange]
    gl.glOrthof(0.0f, 1.0f, 0.0f, yrange, -1.0f, 1.0f);

    gl.glColor4f(color.red, color.green, color.blue, color.alpha);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glVertexPointer(2, GL10.GL_FLOAT, (2 * Float.SIZE / 8), vertices);
    gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, n);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

    gl.glPopMatrix();
}
 
Example 5
Source File: Room.java    From BobEngine with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Gathers the vertex, texture, and index data for each GameObject in this
 * room and passes that information to openGL. Can be called from another
 * room's draw method to draw both rooms at once. If overridden, call
 * super.draw(gl).
 *
 * @param gl OpenGL ES 1.0 object to do pass drawing information to.
 */
public void draw(GL10 gl) {
	// Update camera
	gl.glMatrixMode(GLES10.GL_PROJECTION);
	gl.glLoadIdentity();
	gl.glOrthof(camLeft, camRight, camBottom, camTop, -1, 1);

	// Draw graphics
	gl.glMatrixMode(GLES10.GL_MODELVIEW);
	gl.glLoadIdentity();

	for (int l = 0; l < layers; l++) {
		for (int i = 0; i < renderables.size(); i++) {
			Renderable r = renderables.get(i);

			if (r.getGraphic() != null && r.getGraphic().shouldLoad()) {     // Load the graphic if needed
				getView().getGraphicsHelper().addGraphic(r.getGraphic());
			}

			r.render(gl, l);
		}
	}
}
 
Example 6
Source File: TouchSurfaceView.java    From retrobreaker with MIT License 6 votes vote down vote up
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
	mScreenWidth = width;
	mScreenHeight = height;
	
	float ratio = (float) width / height;
	State.setScreenMeasures((2.0f * Config.SCREEN_RATIO) - Config.WALL, 2.0f - Config.WALL);

	// Define a fixed game screen ratio independently of the screen resolution
	if(ratio >= Config.SCREEN_RATIO) {
		int newWidth = Math.round(height * Config.SCREEN_RATIO);
		gl.glViewport((width - newWidth)/2, 0, newWidth, height);
	} else {
		int newHeight = Math.round(width/Config.SCREEN_RATIO);
		gl.glViewport(0, (height - newHeight)/2, width, newHeight);
	}
	gl.glMatrixMode(GL10.GL_PROJECTION);
	gl.glLoadIdentity();
	gl.glOrthof(-Config.SCREEN_RATIO, Config.SCREEN_RATIO, -1.0f, 1.0f, -1.0f, 1.0f);

	Matrix.orthoM(mUnprojectProjMatrix, 0, -Config.SCREEN_RATIO, Config.SCREEN_RATIO, -1.0f, 1.0f, -1.0f, 1.0f);
	Matrix.setIdentityM(mUnprojectViewMatrix, 0);
}
 
Example 7
Source File: LabelMaker.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 8
Source File: GLDrawerES1.java    From Building-Android-UIs-with-Custom-Views with MIT License 5 votes vote down vote up
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
    if (height == 0) height = 1;
    float aspect = (float) width / height;

    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();
    gl.glOrthof(-10.f, 10.f, 10.f / aspect, -10.f / aspect, 0.1f, 100.f);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();

}