List of usage examples for org.lwjgl.opengl GL11 glPolygonMode
public static void glPolygonMode(@NativeType("GLenum") int face, @NativeType("GLenum") int mode)
From source file:com.aelitis.azureus.plugins.view3d.ViewTest2.java
License:Open Source License
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite comp = new Composite(shell, SWT.NONE); comp.setLayout(new FillLayout()); GLData data = new GLData(); data.doubleBuffer = true;/*from w w w . j av a 2s . c o m*/ data.accumAlphaSize = 8; data.accumBlueSize = 8; data.accumGreenSize = 8; data.accumRedSize = 8; final GLCanvas canvas = new GLCanvas(comp, SWT.NONE, data); canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } canvas.addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { Rectangle bounds = canvas.getBounds(); float fAspect = (float) bounds.width / (float) bounds.height; canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } GL11.glViewport(0, 0, bounds.width, bounds.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); } }); GL11.glLineWidth(1); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glEnable(GL11.GL_BLEND); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); GL11.glColor3f(1.0f, 0.0f, 0.0f); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glClearDepth(1.0); GL11.glLineWidth(2); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glShadeModel(GL11.GL_FLAT); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearAccum(0.0f, 0.0f, 0.0f, 0.0f); shell.setText("SWT/LWJGL Example"); shell.setSize(640, 480); shell.open(); final Runnable run = new Runnable() { float rot = 0; public void run() { if (!canvas.isDisposed()) { canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } int ACSIZE = 8; int[] viewport = getViewport(); GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT); for (int jitter = 0; jitter < ACSIZE; jitter++) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); double jit_x = jits[jitter][0]; double jit_y = jits[jitter][1]; accPerspective(50.0, (double) viewport[2] / (double) viewport[3], 1.0, 15.0, jit_x, jit_y, 0.0, 0.0, 1.0); { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glClearColor(.3f, .5f, .8f, 1.0f); GL11.glLoadIdentity(); GL11.glTranslatef(0.0f, 0.0f, -10.0f); float frot = rot; GL11.glRotatef(0.15f * rot, 2.0f * frot, 10.0f * frot, 1.0f); GL11.glRotatef(0.3f * rot, 3.0f * frot, 1.0f * frot, 1.0f); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glColor3f(0.9f, 0.9f, 0.9f); drawCylinder(2, 3, 50, 0); drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15); } GL11.glAccum(GL11.GL_ACCUM, 1.0f / ACSIZE); } GL11.glAccum(GL11.GL_RETURN, 1.0f); GL11.glFlush(); rot += 0.1; canvas.swapBuffers(); display.asyncExec(this); } } }; canvas.addListener(SWT.Paint, new Listener() { public void handleEvent(Event event) { run.run(); } }); display.asyncExec(run); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:com.ardor3d.scene.state.lwjgl.LwjglWireframeStateUtil.java
License:Open Source License
private static void applyPolyMode(final int frontMode, final int backMode, final WireframeStateRecord record) { if (record.isValid()) { if (frontMode == backMode && (record.frontMode != frontMode || record.backMode != backMode)) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, frontMode); record.frontMode = frontMode; record.backMode = backMode;//from w w w . ja v a 2 s . c o m } else if (frontMode != backMode) { if (record.frontMode != frontMode) { GL11.glPolygonMode(GL11.GL_FRONT, frontMode); record.frontMode = frontMode; } if (record.backMode != backMode) { GL11.glPolygonMode(GL11.GL_BACK, backMode); record.backMode = backMode; } } } else { if (frontMode == backMode) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, frontMode); } else if (frontMode != backMode) { GL11.glPolygonMode(GL11.GL_FRONT, frontMode); GL11.glPolygonMode(GL11.GL_BACK, backMode); } record.frontMode = frontMode; record.backMode = backMode; } }
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java
License:Apache License
public void glPolygonMode(int face, int mode) { GL11.glPolygonMode(face, mode); }
From source file:com.bossletsplays.duthorix.utils.Util.java
License:Apache License
public static void enableWireframe() { GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_COLOR_MATERIAL); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); }
From source file:com.bossletsplays.duthorix.utils.Util.java
License:Apache License
public static void disableWireframe() { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_COLOR_MATERIAL); }
From source file:com.flowpowered.caustic.lwjgl.gl20.GL20VertexArray.java
License:MIT License
@Override public void draw() { checkCreated();// w ww . j av a 2s .co m if (extension.has()) { // Bind the vao extension.glBindVertexArray(id); } else { // Enable the vertex attributes for (int i = 0; i < attributeBufferIDs.length; i++) { // Bind the buffer GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, attributeBufferIDs[i]); // Define the attribute GL20.glVertexAttribPointer(i, attributeSizes[i], attributeTypes[i], attributeNormalizing[i], 0, 0); // Enable it GL20.glEnableVertexAttribArray(i); } // Unbind the last buffer GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); } // Bind the index buffer GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBufferID); // Set the polygon mode GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, polygonMode.getGLConstant()); // Draw all indices with the provided mode GL11.glDrawElements(drawingMode.getGLConstant(), indicesDrawCount, GL11.GL_UNSIGNED_INT, indicesOffset * DataType.INT.getByteSize()); // Unbind the indices buffer GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); // Check for errors LWJGLUtil.checkForGLError(); }
From source file:com.flowpowered.caustic.lwjgl.gl30.GL30VertexArray.java
License:MIT License
@Override public void draw() { checkCreated();// w w w . j a v a 2 s .co m // Bind the vao GL30.glBindVertexArray(id); // Bind the index buffer GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBufferID); // Set the polygon mode GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, polygonMode.getGLConstant()); // Draw all indices with the provided mode GL11.glDrawElements(drawingMode.getGLConstant(), indicesDrawCount, GL11.GL_UNSIGNED_INT, indicesOffset * DataType.INT.getByteSize()); // Unbind the index buffer GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); // Unbind the vao GL30.glBindVertexArray(0); // Check for errors LWJGLUtil.checkForGLError(); }
From source file:com.google.gapid.glviewer.Geometry.java
License:Apache License
public Renderable asRenderable(DisplayMode displayMode) { if (model == null) { return Renderable.NOOP; }/*from w w w. ja v a 2 s.c o m*/ final int polygonMode = displayMode.glPolygonMode; final int modelPrimitive = translatePrimitive(model.getPrimitive()); final float[] positions = model.getPositions(); final float[] normals = model.getNormals(); final int[] indices = isNonPolygonPoints(displayMode) ? null : model.getIndices(); return new Renderable() { private VertexBuffer positionBuffer; private VertexBuffer normalBuffer; private IndexBuffer indexBuffer; @Override public void init(Renderer renderer) { positionBuffer = renderer.newVertexBuffer(positions, 3); if (normals != null) { normalBuffer = renderer.newVertexBuffer(normals, 3); } if (indices != null) { indexBuffer = renderer.newIndexBuffer(indices); } } @Override public void render(Renderer renderer, State state) { state.transform.push(modelMatrix); state.transform.apply(state.shader); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, polygonMode); state.shader.setAttribute(Constants.POSITION_ATTRIBUTE, positionBuffer); if (normalBuffer != null) { state.shader.setAttribute(Constants.NORMAL_ATTRIBUTE, normalBuffer); } else { state.shader.setAttribute(Constants.NORMAL_ATTRIBUTE, 1, 0, 0); } if (indexBuffer != null) { Renderer.draw(state.shader, modelPrimitive, indexBuffer); } else { Renderer.draw(state.shader, GL11.GL_POINTS, positions.length / 3); } GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); state.transform.pop(); } @Override public void dispose(Renderer renderer) { if (positionBuffer != null) { positionBuffer.delete(); positionBuffer = null; } if (normalBuffer != null) { normalBuffer.delete(); normalBuffer = null; } if (indexBuffer != null) { indexBuffer.delete(); indexBuffer = null; } } }; }
From source file:com.grillecube.client.renderer.model.ModelRenderer.java
/** render world terrains */ public void render(CameraProjective camera, HashMap<Model, ArrayList<ModelInstance>> renderingList) { if (this.getMainRenderer().getGLFWWindow().isKeyPressed(GLFW.GLFW_KEY_F)) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); }//from w w w. ja va2 s.c om GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_DEPTH_TEST); // enable model program this.programModel.useStart(); { // load global uniforms this.programModel.loadCamera(camera); // for each entity to render for (ArrayList<ModelInstance> models : renderingList.values()) { if (models.size() > 0) { Model model = models.get(0).getModel(); model.bind(); this.programModel.loadModel(model); for (ModelInstance instance : models) { this.programModel.loadModelInstance(instance); model.draw(); } } } } this.programModel.useStop(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_BLEND); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); }
From source file:com.grillecube.client.renderer.world.TerrainRenderer.java
public void render(CameraProjective camera, WorldFlat world, ArrayList<TerrainMesh> opaqueMeshes, ArrayList<TerrainMesh> transparentMeshes) { GL11.glEnable(GL11.GL_DEPTH_TEST);/*w ww. ja va2s . com*/ if (this.getMainRenderer().getGLFWWindow().isKeyPressed(GLFW.GLFW_KEY_F)) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); } this.terrainProgram.useStart(); this.terrainProgram.loadUniforms(camera, world); if (opaqueMeshes != null && opaqueMeshes.size() > 0) { this.drawMeshes(camera, opaqueMeshes, ProgramTerrain.MESH_TYPE_OPAQUE); } if (transparentMeshes != null && transparentMeshes.size() > 0) { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // bind textures this.drawMeshes(camera, transparentMeshes, ProgramTerrain.MESH_TYPE_TRANSPARENT); GL11.glDisable(GL11.GL_BLEND); } GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); }