Java Code Examples for javax.microedition.khronos.opengles.GL10#glCullFace()
The following examples show how to use
javax.microedition.khronos.opengles.GL10#glCullFace() .
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: SolarSystemRenderer.java From opengl with Apache License 2.0 | 6 votes |
public void onSurfaceCreated(GL10 gl, EGLConfig config) { /* * By default, OpenGL enables features that improve quality * but reduce performance. One might want to tweak that * especially on software renderer. */ gl.glDisable(GL10.GL_DITHER); /* * Some one-time OpenGL initialization can be made here * probably based on features of this particular context */ gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST); gl.glEnable(GL10.GL_CULL_FACE); gl.glCullFace(GL10.GL_BACK); gl.glShadeModel(GL10.GL_SMOOTH); gl.glEnable(GL10.GL_DEPTH_TEST); }
Example 2
Source File: SolarSystemRenderer.java From opengl with Apache License 2.0 | 6 votes |
public void onSurfaceCreated(GL10 gl, EGLConfig config) { /* * By default, OpenGL enables features that improve quality * but reduce performance. One might want to tweak that * especially on software renderer. */ gl.glDisable(GL10.GL_DITHER); /* * Some one-time OpenGL initialization can be made here * probably based on features of this particular context */ gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST); gl.glEnable(GL10.GL_CULL_FACE); gl.glCullFace(GL10.GL_BACK); gl.glShadeModel(GL10.GL_SMOOTH); gl.glEnable(GL10.GL_DEPTH_TEST); }
Example 3
Source File: PLHotspot.java From PanoramaGL with Apache License 2.0 | 5 votes |
/**render methods*/ @Override protected void internalRender(GL10 gl, PLIRenderer renderer) { this.calculateCoords(gl); List<PLITexture> textures = this.getTextures(); int textureId = (textures.size() > 0 ? textures.get(0).getTextureId(gl) : 0); if(textureId == 0 || mVertexsBuffer == null || mTextureCoordsBuffer == null) return; gl.glEnable(GL10.GL_TEXTURE_2D); PLIView view = renderer.getInternalView(); gl.glColor4f(1.0f, 1.0f, 1.0f, (view != null && view.isValidForTransition()) || this.getTouchStatus() == PLSceneElementTouchStatus.PLSceneElementTouchStatusOut ? this.getAlpha() : mOverAlpha); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexsBuffer); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTextureCoordsBuffer); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glEnable(GL10.GL_CULL_FACE); gl.glCullFace(GL10.GL_FRONT); gl.glShadeModel(GL10.GL_SMOOTH); gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4); gl.glDisable(GL10.GL_TEXTURE_2D); gl.glDisable(GL10.GL_BLEND); gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); }
Example 4
Source File: OpenGLRenderer.java From smartGL with Apache License 2.0 | 5 votes |
private void checkDoubleSided(GL10 gl) { if (mDoubleSided != null) { if (mDoubleSided.booleanValue()) { gl.glDisable(GL10.GL_CULL_FACE); } else { gl.glEnable(GL10.GL_CULL_FACE); gl.glCullFace(GL10.GL_FRONT); } mDoubleSided = null; // applied } }
Example 5
Source File: PLHotspot.java From panoramagl with Apache License 2.0 | 5 votes |
/** * render methods */ @Override protected void internalRender(GL10 gl, PLIRenderer renderer) { this.calculateCoords(gl); List<PLITexture> textures = this.getTextures(); int textureId = (textures.size() > 0 ? textures.get(0).getTextureId(gl) : 0); if (textureId == 0 || mVertexsBuffer == null || mTextureCoordsBuffer == null) return; gl.glEnable(GL10.GL_TEXTURE_2D); PLIView view = renderer.getInternalView(); gl.glColor4f(1.0f, 1.0f, 1.0f, (view != null && view.isValidForTransition()) || this.getTouchStatus() == PLSceneElementTouchStatus.PLSceneElementTouchStatusOut ? this.getAlpha() : mOverAlpha); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexsBuffer); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTextureCoordsBuffer); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glEnable(GL10.GL_CULL_FACE); gl.glCullFace(GL10.GL_FRONT); gl.glShadeModel(GL10.GL_SMOOTH); gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4); gl.glDisable(GL10.GL_TEXTURE_2D); gl.glDisable(GL10.GL_BLEND); gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); }
Example 6
Source File: Square.java From opengl with Apache License 2.0 | 5 votes |
/** * This function draws our square on screen. * @param gl */ public void draw(GL10 gl) { //set a color other then white, which is blue/purple gl.glColor4f(0.5f, 0.5f, 1.0f, 1.0f); // 0x8080FFFF // Counter-clockwise winding. gl.glFrontFace(GL10.GL_CCW); // OpenGL docs // Enable face culling. gl.glEnable(GL10.GL_CULL_FACE); // OpenGL docs // What faces to remove with the face culling. gl.glCullFace(GL10.GL_BACK); // OpenGL docs // Enabled the vertices buffer for writing and to be used during // rendering. gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);// OpenGL docs. // Specifies the location and data format of an array of vertex // coordinates to use when rendering. gl.glVertexPointer(3, GL10.GL_FLOAT, 0, // OpenGL docs vertexBuffer); gl.glDrawElements(GL10.GL_TRIANGLES, indices.length,// OpenGL docs GL10.GL_UNSIGNED_SHORT, indexBuffer); // Disable the vertices buffer. gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); // OpenGL docs // Disable face culling. gl.glDisable(GL10.GL_CULL_FACE); // OpenGL docs }
Example 7
Source File: VortexRenderer.java From opengl with Apache License 2.0 | 5 votes |
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { // preparation Log.i(LOG_TAG, "onSurfaceCreated()"); gl.glMatrixMode(GL10.GL_PROJECTION); float size = .01f * (float) Math.tan(Math.toRadians(45.0) / 2); float ratio = _width / _height; // perspective: gl.glFrustumf(-size, size, -size / ratio, size / ratio, 0.01f, 100.0f); // orthographic: //gl.glOrthof(-1, 1, -1 / ratio, 1 / ratio, 0.01f, 100.0f); gl.glViewport(0, 0, (int) _width, (int) _height); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glEnable(GL10.GL_DEPTH_TEST); // define the color we want to be displayed as the "clipping wall" gl.glClearColor(0f, 0f, 0f, 1.0f); // enable the differentiation of which side may be visible gl.glEnable(GL10.GL_CULL_FACE); // which is the front? the one which is drawn counter clockwise gl.glFrontFace(GL10.GL_CCW); // which one should NOT be drawn gl.glCullFace(GL10.GL_BACK); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_COLOR_ARRAY); initTriangle(); }
Example 8
Source File: Square.java From opengl with Apache License 2.0 | 5 votes |
/** * This function draws our square on screen. * @param gl */ public void draw(GL10 gl) { //set a color other then white, which is blue/purple gl.glColor4f(0.5f, 0.5f, 1.0f, 1.0f); // 0x8080FFFF // Counter-clockwise winding. gl.glFrontFace(GL10.GL_CCW); // OpenGL docs // Enable face culling. gl.glEnable(GL10.GL_CULL_FACE); // OpenGL docs // What faces to remove with the face culling. gl.glCullFace(GL10.GL_BACK); // OpenGL docs // Enabled the vertices buffer for writing and to be used during // rendering. gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);// OpenGL docs. // Specifies the location and data format of an array of vertex // coordinates to use when rendering. gl.glVertexPointer(3, GL10.GL_FLOAT, 0, // OpenGL docs vertexBuffer); gl.glDrawElements(GL10.GL_TRIANGLES, indices.length,// OpenGL docs GL10.GL_UNSIGNED_SHORT, indexBuffer); // Disable the vertices buffer. gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); // OpenGL docs // Disable face culling. gl.glDisable(GL10.GL_CULL_FACE); // OpenGL docs }
Example 9
Source File: VortexRenderer.java From opengl with Apache License 2.0 | 5 votes |
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { // preparation Log.i(LOG_TAG, "onSurfaceCreated()"); gl.glMatrixMode(GL10.GL_PROJECTION); float size = .01f * (float) Math.tan(Math.toRadians(45.0) / 2); float ratio = _width / _height; // perspective: gl.glFrustumf(-size, size, -size / ratio, size / ratio, 0.01f, 100.0f); // orthographic: //gl.glOrthof(-1, 1, -1 / ratio, 1 / ratio, 0.01f, 100.0f); gl.glViewport(0, 0, (int) _width, (int) _height); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glEnable(GL10.GL_DEPTH_TEST); // define the color we want to be displayed as the "clipping wall" gl.glClearColor(0f, 0f, 0f, 1.0f); // enable the differentiation of which side may be visible gl.glEnable(GL10.GL_CULL_FACE); // which is the front? the one which is drawn counter clockwise gl.glFrontFace(GL10.GL_CCW); // which one should NOT be drawn gl.glCullFace(GL10.GL_BACK); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_COLOR_ARRAY); initTriangle(); }
Example 10
Source File: TGAGLSurfaceView.java From TGAReader with MIT License | 5 votes |
@Override public void onDrawFrame(GL10 gl) { gl.glClearColor(0.5f, 0.5f, 0.5f, 1); gl.glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, positionBuffer); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texcoordBuffer); gl.glEnable(GL_CULL_FACE); gl.glCullFace(GL_BACK); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); GLU.gluLookAt(gl, 3, 3, 3, 0, 0, 0, 0, 1, 0); // draw front and back draw(gl, tgaTextures[0]); // draw left and right gl.glPushMatrix(); gl.glRotatef(90, 0, 1, 0); draw(gl, tgaTextures[1]); gl.glPopMatrix(); // draw top and bottom gl.glPushMatrix(); gl.glRotatef(-90, 1, 0, 0); draw(gl, tgaTextures[2]); gl.glPopMatrix(); }
Example 11
Source File: PLCubicPanorama.java From PanoramaGL with Apache License 2.0 | 4 votes |
/**render methods*/ @Override protected void internalRender(GL10 gl, PLIRenderer renderer) { gl.glEnable(GL10.GL_TEXTURE_2D); gl.glEnable(GL10.GL_CULL_FACE); gl.glCullFace(GL10.GL_FRONT); gl.glShadeModel(GL10.GL_SMOOTH); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, sCubeBuffer); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, sTextureCoordsBuffer); // Front Face if(this.bindTextureByIndex(gl, PLConstants.kCubeFrontFaceIndex)) { gl.glNormal3f(0.0f, 0.0f, 1.0f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4); } // Back Face if(this.bindTextureByIndex(gl, PLConstants.kCubeBackFaceIndex)) { gl.glNormal3f(0.0f, 0.0f, -1.0f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 4, 4); } // Left Face if(this.bindTextureByIndex(gl, PLConstants.kCubeLeftFaceIndex)) { gl.glNormal3f(1.0f, 0.0f, 0.0f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 8, 4); } // Right Face if(this.bindTextureByIndex(gl, PLConstants.kCubeRightFaceIndex)) { gl.glNormal3f(-1.0f, 0.0f, 0.0f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 12, 4); } // Up Face if(this.bindTextureByIndex(gl, PLConstants.kCubeUpFaceIndex)) { gl.glNormal3f(0.0f, 1.0f, 0.0f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 16, 4); } // Down Face if(this.bindTextureByIndex(gl, PLConstants.kCubeDownFaceIndex)) { gl.glNormal3f(0.0f, -1.0f, 0.0f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 20, 4); } gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glDisable(GL10.GL_CULL_FACE); gl.glDisable(GL10.GL_TEXTURE_2D); }
Example 12
Source File: PLCubicPanorama.java From panoramagl with Apache License 2.0 | 4 votes |
/** * render methods */ @Override protected void internalRender(GL10 gl, PLIRenderer renderer) { gl.glEnable(GL10.GL_TEXTURE_2D); gl.glEnable(GL10.GL_CULL_FACE); gl.glCullFace(GL10.GL_FRONT); gl.glShadeModel(GL10.GL_SMOOTH); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, sCubeBuffer); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, sTextureCoordsBuffer); // Front Face if (this.bindTextureByIndex(gl, PLConstants.kCubeFrontFaceIndex)) { gl.glNormal3f(0.0f, 0.0f, 1.0f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4); } // Back Face if (this.bindTextureByIndex(gl, PLConstants.kCubeBackFaceIndex)) { gl.glNormal3f(0.0f, 0.0f, -1.0f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 4, 4); } // Left Face if (this.bindTextureByIndex(gl, PLConstants.kCubeLeftFaceIndex)) { gl.glNormal3f(1.0f, 0.0f, 0.0f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 8, 4); } // Right Face if (this.bindTextureByIndex(gl, PLConstants.kCubeRightFaceIndex)) { gl.glNormal3f(-1.0f, 0.0f, 0.0f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 12, 4); } // Up Face if (this.bindTextureByIndex(gl, PLConstants.kCubeUpFaceIndex)) { gl.glNormal3f(0.0f, 1.0f, 0.0f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 16, 4); } // Down Face if (this.bindTextureByIndex(gl, PLConstants.kCubeDownFaceIndex)) { gl.glNormal3f(0.0f, -1.0f, 0.0f); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 20, 4); } gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glDisable(GL10.GL_CULL_FACE); gl.glDisable(GL10.GL_TEXTURE_2D); }