Java Code Examples for javax.microedition.khronos.opengles.GL10#glFrontFace()
The following examples show how to use
javax.microedition.khronos.opengles.GL10#glFrontFace() .
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: CubeSmallGLUT.java From opengl with Apache License 2.0 | 6 votes |
void draw(GL10 gl) { // need for correct culling gl.glFrontFace(GL10.GL_CW); // make sure our state is correct gl.glEnableClientState(GL10.GL_NORMAL_ARRAY); // set our vertexes gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer); // set our normals for correct lighting gl.glNormalPointer(GL10.GL_FLOAT, 0, mNormalBuffer); // draw the elements gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_BYTE, mIndexBuffer); // GLUT disables the client state -- we don't. Why does it? .. // TODO: consider a preDraw, draw, postDraw ... }
Example 2
Source File: Square.java From opengl with Apache License 2.0 | 6 votes |
public void draw(GL10 gl) { //tell openGL how the vertices are ordering their faces //this is both for efficiently so openGL can ignore the "backside" and not attempt to draw it. gl.glFrontFace(GL11.GL_CCW); //counter clockwise, so any counter triangles are ignored. //send the buffers to the renderer //specific the number of elements per vertex, which there are 2. gl.glVertexPointer(2, GL11.GL_FLOAT, 0, mFVertexBuffer); //8 //color buffer is added, with the size of the 4 elements gl.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, mColorBuffer); //9 //finally draw the element, we the connectivity array, using triangles //could also be triangle lists, points or lines gl.glDrawElements(GL11.GL_TRIANGLES, 6, GL11.GL_UNSIGNED_BYTE, mIndexBuffer); //return the openGL back to the default value. gl.glFrontFace(GL11.GL_CCW); //11 }
Example 3
Source File: Square.java From opengl with Apache License 2.0 | 6 votes |
public void draw(GL10 gl) { //tell openGL how the vertices are ordering their faces //this is both for efficiently so openGL can ignore the "backside" and not attempt to draw it. gl.glFrontFace(GL11.GL_CCW); //counter clockwise, so any counter triangles are ignored. //send the buffers to the renderer //specific the number of elements per vertex, which there are 2. gl.glVertexPointer(2, GL11.GL_FLOAT, 0, mFVertexBuffer); //8 //color buffer is added, with the size of the 4 elements gl.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, mColorBuffer); //9 //finally draw the element, we the connectivity array, using triangles //could also be triangle lists, points or lines gl.glDrawElements(GL11.GL_TRIANGLES, 6, GL11.GL_UNSIGNED_BYTE, mIndexBuffer); //return the openGL back to the default value. gl.glFrontFace(GL11.GL_CCW); //11 }
Example 4
Source File: CubeSmallGLUT.java From opengl with Apache License 2.0 | 6 votes |
void draw(GL10 gl) { // need for correct culling gl.glFrontFace(GL10.GL_CW); // make sure our state is correct gl.glEnableClientState(GL10.GL_NORMAL_ARRAY); // set our vertexes gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer); // set our normals for correct lighting gl.glNormalPointer(GL10.GL_FLOAT, 0, mNormalBuffer); // draw the elements gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_BYTE, mIndexBuffer); // GLUT disables the client state -- we don't. Why does it? .. // TODO: consider a preDraw, draw, postDraw ... }
Example 5
Source File: GLBitmap.java From TikTok with Apache License 2.0 | 6 votes |
public void draw(GL10 gl) { // bind the previously generated texture gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]); // Point to our buffers gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); // Set the face rotation gl.glFrontFace(GL10.GL_CW); // Point to our vertex buffer gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer); // Draw the vertices as triangle strip gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3); // Disable the client state before leaving gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); }
Example 6
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 7
Source File: Cube.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public void draw(GL10 gl) { gl.glFrontFace(GL10.GL_CW); gl.glVertexPointer(3, GL10.GL_FIXED, 0, mVertexBuffer); gl.glColorPointer(4, GL10.GL_FIXED, 0, mColorBuffer); gl.glDrawElements(GL10.GL_TRIANGLES, 36, GL10.GL_UNSIGNED_BYTE, mIndexBuffer); }
Example 8
Source File: TriangleRenderer.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public void draw(GL10 gl) { gl.glFrontFace(GL10.GL_CCW); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mFVertexBuffer); gl.glEnable(GL10.GL_TEXTURE_2D); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTexBuffer); gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, VERTS, GL10.GL_UNSIGNED_SHORT, mIndexBuffer); }
Example 9
Source File: GLWorld.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public void draw(GL10 gl) { mColorBuffer.position(0); mVertexBuffer.position(0); mIndexBuffer.position(0); gl.glFrontFace(GL10.GL_CW); gl.glShadeModel(GL10.GL_FLAT); gl.glVertexPointer(3, GL10.GL_FIXED, 0, mVertexBuffer); gl.glColorPointer(4, GL10.GL_FIXED, 0, mColorBuffer); gl.glDrawElements(GL10.GL_TRIANGLES, mIndexCount, GL10.GL_UNSIGNED_SHORT, mIndexBuffer); count++; }
Example 10
Source File: SpriteTextRenderer.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public void draw(GL10 gl) { gl.glFrontFace(GL10.GL_CCW); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mFVertexBuffer); gl.glEnable(GL10.GL_TEXTURE_2D); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTexBuffer); gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, VERTS, GL10.GL_UNSIGNED_SHORT, mIndexBuffer); }
Example 11
Source File: RotationVectorDemo.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public void draw(GL10 gl) { gl.glEnable(GL10.GL_CULL_FACE); gl.glFrontFace(GL10.GL_CW); gl.glShadeModel(GL10.GL_SMOOTH); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer); gl.glColorPointer(4, GL10.GL_FLOAT, 0, mColorBuffer); gl.glDrawElements(GL10.GL_TRIANGLES, 36, GL10.GL_UNSIGNED_BYTE, mIndexBuffer); }
Example 12
Source File: TriangleSmallGLUT.java From opengl with Apache License 2.0 | 5 votes |
void draw(GL10 gl) { gl.glFrontFace(GL10.GL_CW); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer); gl.glNormal3f(0f, 0f, 1f); gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3); }
Example 13
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 14
Source File: TriangleSmallGLUT.java From opengl with Apache License 2.0 | 5 votes |
void draw(GL10 gl) { gl.glFrontFace(GL10.GL_CW); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer); gl.glNormal3f(0f, 0f, 1f); gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3); }
Example 15
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 16
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 17
Source File: Cube.java From tilt-game-android with MIT License | 5 votes |
/** * Draws this cube of the given GL-Surface * * @param gl The GL-Surface this cube should be drawn upon. */ public void draw(GL10 gl) { gl.glEnable(GL10.GL_CULL_FACE); gl.glFrontFace(GL10.GL_CW); gl.glShadeModel(GL10.GL_SMOOTH); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer); gl.glColorPointer(4, GL10.GL_FLOAT, 0, mColorBuffer); gl.glDrawElements(GL10.GL_TRIANGLES, 36, GL10.GL_UNSIGNED_BYTE, mIndexBuffer); }
Example 18
Source File: Page.java From PlayLikeCurl with MIT License | 4 votes |
public void draw(GL10 gl,Context context) { if(needtextureupdate) { needtextureupdate=false; loadGLTexture(gl, context); } calculateVerticesCoords(); gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glFrontFace(GL10.GL_CCW); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer); gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_SHORT, indexBuffer); gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); }
Example 19
Source File: Planet.java From opengl with Apache License 2.0 | 3 votes |
public void draw(GL10 gl) { gl.glFrontFace(GL10.GL_CW); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, m_VertexData); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glColorPointer(4, GL10.GL_FLOAT, 0, m_ColorData); gl.glEnableClientState(GL10.GL_COLOR_ARRAY); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, (m_Slices+1)*2*(m_Stacks-1)+2); }
Example 20
Source File: Planet.java From opengl with Apache License 2.0 | 3 votes |
public void draw(GL10 gl) { gl.glFrontFace(GL10.GL_CW); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, m_VertexData); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glColorPointer(4, GL10.GL_FLOAT, 0, m_ColorData); gl.glEnableClientState(GL10.GL_COLOR_ARRAY); gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, (m_Slices+1)*2*(m_Stacks-1)+2); }