Java Code Examples for android.opengl.GLES30#glViewport()

The following examples show how to use android.opengl.GLES30#glViewport() . 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: EGLBase14.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * Viewportを設定
 * ここで設定した値は次回以降makeCurrentを呼んだときに復帰される
 * @param x
 * @param y
 * @param width
 * @param height
 */
@Override
public void setViewPort(final int x, final int y, final int width, final int height) {
	viewPortX = x;
	viewPortY = y;
	viewPortWidth = width;
	viewPortHeight = height;

	final int glVersion = mEglBase.getGlVersion();
	if (glVersion >= 3) {
		GLES30.glViewport(x, y, width, height);
	} else if (mEglBase.getGlVersion() >= 2) {
		GLES20.glViewport(x, y, width, height);
	} else {
		GLES10.glViewport(x, y, width, height);
	}
}
 
Example 2
Source File: EGLBase10.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * Viewportを設定
 * ここで設定した値は次回以降makeCurrentを呼んだときに復帰される
 * @param x
 * @param y
 * @param width
 * @param height
 */
@Override
public void setViewPort(final int x, final int y, final int width, final int height) {
	viewPortX = x;
	viewPortY = y;
	viewPortWidth = width;
	viewPortHeight = height;

	final int glVersion = mEglBase.getGlVersion();
	if (glVersion >= 3) {
		GLES30.glViewport(x, y, width, height);
	} else if (mEglBase.getGlVersion() >= 2) {
		GLES20.glViewport(x, y, width, height);
	} else {
		GLES10.glViewport(x, y, width, height);
	}
}
 
Example 3
Source File: LessonOneRenderer.java    From opengl with Apache License 2.0 6 votes vote down vote up
@Override
public void onSurfaceChanged(GL10 glUnused, int width, int height) 
{
	// Set the OpenGL viewport to the same size as the surface.
	GLES30.glViewport(0, 0, width, height);

	// Create a new perspective projection matrix. The height will stay the same
	// while the width will vary as per aspect ratio.
	final float ratio = (float) width / height;
	final float left = -ratio;
	final float right = ratio;
	final float bottom = -1.0f;
	final float top = 1.0f;
	final float near = 1.0f;
	final float far = 10.0f;
	
	Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
}
 
Example 4
Source File: HelloTriangleRenderer.java    From opengl with Apache License 2.0 6 votes vote down vote up
public void onDrawFrame(GL10 glUnused) {
    // Set the viewport
    GLES30.glViewport(0, 0, mWidth, mHeight);

    // Clear the color buffer, which was set above in glClearColor
    GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT);

    // Use the program object
    GLES30.glUseProgram(mProgramObject);

    // Load the vertex data
    GLES30.glVertexAttribPointer(0, 3, GLES30.GL_FLOAT, false, 0, mVertices);
    //set the starting vertex at 0.
    GLES30.glEnableVertexAttribArray(0);

    //actually draw the traingle here
    GLES30.glDrawArrays(GLES30.GL_TRIANGLES, 0, 3);
}
 
Example 5
Source File: LessonOneRenderer.java    From opengl with Apache License 2.0 6 votes vote down vote up
@Override
public void onSurfaceChanged(GL10 glUnused, int width, int height) 
{
	// Set the OpenGL viewport to the same size as the surface.
	GLES30.glViewport(0, 0, width, height);

	// Create a new perspective projection matrix. The height will stay the same
	// while the width will vary as per aspect ratio.
	final float ratio = (float) width / height;
	final float left = -ratio;
	final float right = ratio;
	final float bottom = -1.0f;
	final float top = 1.0f;
	final float near = 1.0f;
	final float far = 10.0f;
	
	Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
}
 
Example 6
Source File: GLTexture.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * Viewportを設定
 * ここで設定した値は次回以降makeCurrentを呼んだときに復帰される
 * @param x
 * @param y
 * @param width
 * @param height
 */
@Override
public void setViewPort(final int x, final int y, final int width, final int height) {
	viewPortX = x;
	viewPortY = y;
	viewPortWidth = width;
	viewPortHeight = height;

	GLES30.glViewport(x, y, width, height);
}
 
Example 7
Source File: GLSurface.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * Viewportを設定
 * ここで設定した値は次回以降makeCurrentを呼んだときに復帰される
 * @param x
 * @param y
 * @param width
 * @param height
 */
@Override
public void setViewPort(final int x, final int y, final int width, final int height) {
	viewPortX = x;
	viewPortY = y;
	viewPortWidth = width;
	viewPortHeight = height;

	GLES30.glViewport(x, y, width, height);
}
 
Example 8
Source File: myRenderer.java    From opengl with Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceChanged(GL10 glUnused, int width, int height) {
    mWidth = width;
    mHeight = height;
    // Set the viewport
    GLES30.glViewport(0, 0, mWidth, mHeight);
    float aspect = (float) width / height;

    // this projection matrix is applied to object coordinates
    //no idea why 53.13f, it was used in another example and it worked.
    Matrix.perspectiveM(mProjectionMatrix, 0, 53.13f, aspect, Z_NEAR, Z_FAR);
}
 
Example 9
Source File: myRenderer.java    From opengl with Apache License 2.0 5 votes vote down vote up
public void onSurfaceChanged(GL10 glUnused, int width, int height) {
    mWidth = width;
    mHeight = height;
    // Set the viewport
    GLES30.glViewport(0, 0, mWidth, mHeight);
    float aspect = (float) width / height;

    // this projection matrix is applied to object coordinates
    //no idea why 53.13f, it was used in another example and it worked.
    Matrix.perspectiveM(mProjectionMatrix, 0, 53.13f, aspect, Z_NEAR, Z_FAR);
}
 
Example 10
Source File: MyGLRenderer.java    From opengl with Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceChanged(GL10 unused, int width, int height) {
    // Adjust the viewport based on geometry changes,
    // such as screen rotation
    GLES30.glViewport(0, 0, width, height);

    float ratio = (float) width / height;

    // this projection matrix is applied to object coordinates
    // in the onDrawFrame() method
    Matrix.frustumM(mProjectionMatrix, 0, -ratio, ratio, -1, 1, 3, 7);

}
 
Example 11
Source File: myRenderer.java    From opengl with Apache License 2.0 5 votes vote down vote up
public void onSurfaceChanged(GL10 glUnused, int width, int height) {
    mWidth = width;
    mHeight = height;
    // Set the viewport
    GLES30.glViewport(0, 0, mWidth, mHeight);
    float aspect = (float) width / height;

    // this projection matrix is applied to object coordinates
    //no idea why 53.13f, it was used in another example and it worked.
    Matrix.perspectiveM(mProjectionMatrix, 0, 53.13f, aspect, Z_NEAR, Z_FAR);
}
 
Example 12
Source File: GLES30WallpaperRenderer.java    From alynx-live-wallpaper with Apache License 2.0 4 votes vote down vote up
@Override
public void onSurfaceChanged(GL10 gl10, int width, int height) {
    GLES30.glViewport(0, 0, width, height);
}