Java Code Examples for com.jogamp.opengl.GL2#glShadeModel()
The following examples show how to use
com.jogamp.opengl.GL2#glShadeModel() .
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: CubeTexture.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void init(GLAutoDrawable drawable) { final GL2 gl = drawable.getGL().getGL2(); gl.glShadeModel(GL2.GL_SMOOTH); gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); gl.glClearDepth(1.0f); gl.glEnable(GL2.GL_DEPTH_TEST); gl.glDepthFunc(GL2.GL_LEQUAL); gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST); gl.glEnable(GL2.GL_TEXTURE_2D); try { File im = new File("D:\\Temp\\image\\lenna.jpg "); //File im = new File("D:\\Temp\\Map\\GLOBALeb3colshade.jpg"); BufferedImage image = ImageIO.read(im); Texture t = AWTTextureIO.newTexture(gl.getGLProfile(), image, true); //Texture t = TextureIO.newTexture(im, true); texture = t.getTextureObject(gl); } catch (IOException e) { e.printStackTrace(); } }
Example 2
Source File: DelaunayTriangulationExample.java From delaunay-triangulator with MIT License | 6 votes |
public void init(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glDisable(GL.GL_CULL_FACE); gl.glShadeModel(GL2.GL_SMOOTH); gl.glClearColor(COLOR_BACKGROUND.getRed() / 255.0f, COLOR_BACKGROUND.getGreen() / 255.0f, COLOR_BACKGROUND.getBlue() / 255.0f, 1); gl.glClearDepth(1.0f); gl.glEnable(GL.GL_DEPTH_TEST); gl.glDepthFunc(GL.GL_LEQUAL); gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); gl.setSwapInterval(1); gl.glDisable(GL2.GL_CULL_FACE); delaunayTriangulator = new DelaunayTriangulator(pointSet); }
Example 3
Source File: MaterialEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
public void render(GL2 gl2) { gl2.glColor4d(diffuse.getR(),diffuse.getG(),diffuse.getB(),diffuse.getA()); gl2.glMaterialfv(GL2.GL_FRONT, GL2.GL_DIFFUSE, diffuse.getFloatArray(),0); gl2.glMaterialfv(GL2.GL_FRONT, GL2.GL_SPECULAR, specular.getFloatArray(),0); gl2.glMaterialfv(GL2.GL_FRONT, GL2.GL_EMISSION, emission.getFloatArray(),0); gl2.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT, ambient.getFloatArray(),0); gl2.glMaterialf(GL2.GL_FRONT, GL2.GL_SHININESS, shininess.get().floatValue()); gl2.glColorMaterial(GL2.GL_FRONT,GL2.GL_AMBIENT_AND_DIFFUSE ); boolean isColorEnabled = gl2.glIsEnabled(GL2.GL_COLOR_MATERIAL); gl2.glDisable(GL2.GL_COLOR_MATERIAL); gl2.glShadeModel(GL2.GL_SMOOTH); if(isLit()) gl2.glEnable(GL2.GL_LIGHTING); else gl2.glDisable(GL2.GL_LIGHTING); texture.render(gl2); if(isColorEnabled) gl2.glEnable(GL2.GL_COLOR_MATERIAL); }
Example 4
Source File: Tessellation.java From MeteoInfo with GNU Lesser General Public License v3.0 | 4 votes |
public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL2.GL_COLOR_BUFFER_BIT); gl.glColor3f(1.0f, 1.0f, 1.0f); /* * jogl specific addition for tessellation */ tessellCallBack tessCallback = new tessellCallBack(gl, glu); double rect[][] = new double[][]{ // [4][3] in C; reverse here {50.0, 50.0, 0.0}, {200.0, 50.0, 0.0}, {200.0, 200.0, 0.0}, {50.0, 200.0, 0.0}}; double tri[][] = new double[][]{// [3][3] {75.0, 75.0, 0.0}, {125.0, 175.0, 0.0}, {175.0, 75.0, 0.0}}; double star[][] = new double[][]{// [5][6]; 6x5 in java {250.0, 50.0, 0.0, 1.0, 0.0, 1.0}, {325.0, 200.0, 0.0, 1.0, 1.0, 0.0}, {400.0, 50.0, 0.0, 0.0, 1.0, 1.0}, {250.0, 150.0, 0.0, 1.0, 0.0, 0.0}, {400.0, 150.0, 0.0, 0.0, 1.0, 0.0}}; gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); startList = gl.glGenLists(2); GLUtessellator tobj = glu.gluNewTess(); glu.gluTessCallback(tobj, GLU.GLU_TESS_VERTEX, tessCallback);// glVertex3dv); glu.gluTessCallback(tobj, GLU.GLU_TESS_BEGIN, tessCallback);// beginCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_END, tessCallback);// endCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_ERROR, tessCallback);// errorCallback); /* rectangle with triangular hole inside */ gl.glNewList(startList, GL2.GL_COMPILE); gl.glShadeModel(GL2.GL_FLAT); glu.gluTessBeginPolygon(tobj, null); glu.gluTessBeginContour(tobj); glu.gluTessVertex(tobj, rect[0], 0, rect[0]); glu.gluTessVertex(tobj, rect[1], 0, rect[1]); glu.gluTessVertex(tobj, rect[2], 0, rect[2]); glu.gluTessVertex(tobj, rect[3], 0, rect[3]); glu.gluTessEndContour(tobj); glu.gluTessBeginContour(tobj); glu.gluTessVertex(tobj, tri[0], 0, tri[0]); glu.gluTessVertex(tobj, tri[1], 0, tri[1]); glu.gluTessVertex(tobj, tri[2], 0, tri[2]); glu.gluTessEndContour(tobj); glu.gluTessEndPolygon(tobj); gl.glEndList(); glu.gluTessCallback(tobj, GLU.GLU_TESS_VERTEX, tessCallback);// vertexCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_BEGIN, tessCallback);// beginCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_END, tessCallback);// endCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_ERROR, tessCallback);// errorCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_COMBINE, tessCallback);// combineCallback); /* smooth shaded, self-intersecting star */ gl.glNewList(startList + 1, GL2.GL_COMPILE); gl.glShadeModel(GL2.GL_SMOOTH); glu.gluTessProperty(tobj, // GLU.GLU_TESS_WINDING_RULE, // GLU.GLU_TESS_WINDING_POSITIVE); glu.gluTessBeginPolygon(tobj, null); glu.gluTessBeginContour(tobj); glu.gluTessVertex(tobj, star[0], 0, star[0]); glu.gluTessVertex(tobj, star[1], 0, star[1]); glu.gluTessVertex(tobj, star[2], 0, star[2]); glu.gluTessVertex(tobj, star[3], 0, star[3]); glu.gluTessVertex(tobj, star[4], 0, star[4]); glu.gluTessEndContour(tobj); glu.gluTessEndPolygon(tobj); gl.glEndList(); glu.gluDeleteTess(tobj); gl.glCallList(startList); gl.glCallList(startList + 1); gl.glFlush(); }