List of usage examples for org.lwjgl.opengl GL11 glHint
public static void glHint(@NativeType("GLenum") int target, @NativeType("GLenum") int hint)
From source file:com.github.begla.blockmania.game.Blockmania.java
License:Apache License
public void resetOpenGLParameters() { glEnable(GL_CULL_FACE);// ww w.j a va2s . com glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); // Update the viewing distance double minDist = VIEWING_DISTANCES[_activeViewingDistance] * 8.0f; glFogf(GL_FOG_START, (float) (minDist * 0.8)); glFogf(GL_FOG_END, (float) minDist); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); glShadeModel(GL11.GL_SMOOTH); }
From source file:com.github.begla.blockmania.main.Blockmania.java
License:Apache License
private void setupOpenGL() { glEnable(GL_CULL_FACE);/*from w w w .ja v a 2 s . c om*/ glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glFogi(GL_FOG_MODE, GL_LINEAR); // Update the viewing distance double minDist = Math.min(Configuration.getSettingNumeric("V_DIST_X") * Configuration.CHUNK_DIMENSIONS.x, Configuration.getSettingNumeric("V_DIST_Z") * Configuration.CHUNK_DIMENSIONS.z); double viewingDistance = minDist / 2f; glFogf(GL_FOG_START, (float) (viewingDistance * 0.25)); glFogf(GL_FOG_END, (float) viewingDistance); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); glShadeModel(GL11.GL_SMOOTH); }
From source file:com.kodehawa.gui.api.render.ModGuiUtils.java
License:Open Source License
/** * Half Circle/* w w w.j av a2 s.c om*/ * * Modes: 0 Left to right, bottom to top 1 Top to bottom, left to right 2 * Right to left, top to bottom 3 Bottom to top, right to left * * @param x * @param y * @param r * @param c */ public static void drawFilledHalfCircle(int x, int y, double r, int c, int mode) { float f = ((c >> 24) & 0xff) / 255F; float f1 = ((c >> 16) & 0xff) / 255F; float f2 = ((c >> 8) & 0xff) / 255F; float f3 = (c & 0xff) / 255F; GL11.glDisable(3553 /* GL_TEXTURE_2D */); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(770, 771); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glEnable(GL11.GL_POLYGON_SMOOTH); GL11.glEnable(GL11.GL_POINT_SMOOTH); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST); GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST); GL11.glColor4f(f1, f2, f3, f); GL11.glBegin(6 /* GL_TRIANGLE_FAN */); int startang = 0; int endang = 0; if (mode == 0) { startang = 90; endang = 270; } if (mode == 1) { startang = 360; endang = 540; } if (mode == 2) { startang = 270; endang = 450; } if (mode == 3) { startang = 180; endang = 360; } for (int i = startang; i <= endang; i++) { double x2 = Math.sin(((i * 3.141526D) / 180)) * r; double y2 = Math.cos(((i * 3.141526D) / 180)) * r; GL11.glVertex2d(x + x2, y + y2); } GL11.glEnd(); GL11.glDisable(GL11.GL_POLYGON_SMOOTH); GL11.glDisable(GL11.GL_POINT_SMOOTH); GL11.glDisable(2848 /* GL_LINE_SMOOTH */); GL11.glEnable(3553 /* GL_TEXTURE_2D */); GL11.glDisable(3042 /* GL_BLEND */); }
From source file:com.opengrave.og.engine.Node.java
License:Open Source License
public void renderSemiTransparent(Matrix4f matrix) { Util.checkErr();/* w w w.j av a 2s .c om*/ doRenderSemiTransparent(matrix); if (MainThread.main.input.getLastHovered() != null) { Pickable lr = MainThread.main.input.getLastHovered().getRenderable(); if (this instanceof BaseObject && lr instanceof BaseObject) { if (lr == this) { BaseObject notThis = (BaseObject) this; if (notThis.drawOutline) { // Setup for outline draw GL11.glDepthFunc(GL11.GL_LESS); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_LINE); GL11.glLineWidth(10f); GL11.glCullFace(GL11.GL_FRONT); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // Draw RenderStyle rs = notThis.getRenderStyle(); notThis.setRenderStyle(RenderStyle.HALO); doRender(matrix); notThis.setRenderStyle(rs); // Return to correct state GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_FILL); GL11.glLineWidth(1f); GL11.glCullFace(GL11.GL_BACK); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_BLEND); } } } } Util.checkErr(); for (Node node : children) { Matrix4f childMatrix = matrix.mult(node.getMatrix(), null); node.renderSemiTransparent(childMatrix); Util.checkErr(); } }
From source file:com.runescape.client.revised.editor.modelviewer.Main.java
License:Open Source License
public static void initialize(final Canvas modelCanvas) { try {/*ww w.j a v a2 s . c om*/ Display.setParent(modelCanvas); Display.create(new PixelFormat(8, 24, 8, 8)); Display.makeCurrent(); } catch (final LWJGLException lwjgle) { try { Display.create(new PixelFormat(8, 24, 8, 0)); } catch (final LWJGLException e) { e.printStackTrace(); } } Display.setVSyncEnabled(false); Display.setSwapInterval(0); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glClearDepth(1.0F); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glEnable(GL11.GL_NORMALIZE); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_POINT_SMOOTH); GL11.glEnable(GL11.GL_POLYGON_SMOOTH); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glColorMaterial(GL11.GL_FRONT, GL11.GL_DIFFUSE); GL11.glCullFace(GL11.GL_BACK); }
From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java
License:Mozilla Public License
public InspectorCanvas(Composite parent, int style, GLData data) { super(parent, style, data); setCurrent();//from www . j a v a 2 s . com // Clear the canvas. GL11.glClearColor(CLEAR_COLOR[0], CLEAR_COLOR[1], CLEAR_COLOR[2], CLEAR_COLOR[3]); GL11.glClearDepth(1.0f); GL11.glLineWidth(1.0f); GL11.glPointSize(1.0f); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glEnable(GL11.GL_POLYGON_SMOOTH); GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, 0.01f); GL11.glEnable(GL11.GL_STENCIL_TEST); GL11.glStencilFunc(GL11.GL_ALWAYS, 0x1, 0xf); GL11.glStencilOp(GL11.GL_INCR, GL11.GL_KEEP, GL11.GL_INCR); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); reset(); mTransform = new Matrix4f(); mTransform.setIdentity(); addListener(SWT.Resize, this); addListener(SWT.Paint, this); addMouseListener(this); addMouseWheelListener(this); }
From source file:espresso3d.engine.E3DEngine.java
License:Open Source License
private void initGL() { logger.writeLine(E3DEngineLogger.SEVERITY_INFO, "Initializing OpenGL"); GL11.glShadeModel(GL11.GL_SMOOTH); // Enable Smooth Shading GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background GL11.glClearDepth(1.0); // Depth Buffer Setup GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); // Set Perspective Calculations To Most Accurate }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
/*********** NEW FOR RENDER TREE **********/ public void initSmoothing() { GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); // Set Perspective Calculations To Most Accurate GL11.glHint(GL11.GL_POINT_SMOOTH_HINT, GL11.GL_NICEST); // Really Nice Point Smoothing }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
public void initSolidAndLineRendering() { GL11.glDepthMask(true);/*from w w w . ja v a2 s . co m*/ GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); // Set Perspective Calculations To Most Accurate disableAllTextureUnits(); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); }
From source file:fable.imageviewer.views.ReliefView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { thisView = this; parent.setLayout(new GridLayout(1, false)); GridUtils.removeMargins(parent);/* w w w .j ava 2 s. co m*/ createActions(); Composite comp = new Composite(parent, SWT.NONE); comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); comp.setLayout(new FillLayout()); GLData data = new GLData(); data.doubleBuffer = true; canvas = new GLCanvas(comp, SWT.NONE, data); canvas.setSize(comp.getSize()); canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException ex) { FableUtils.excMsg(ReliefView.class, "Error in createPartControl using GLContext.useContext", ex); } // context = GLDrawableFactory.getFactory().createExternalGLContext(); 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 ex) { FableUtils.excMsg(ReliefView.class, "Error in resize listener using GLContext.useContext", ex); } // context.makeCurrent(); // GL11 gl = context.getGL (); GL11.glViewport(0, 0, bounds.width, bounds.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); // GLU glu = new GLU(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); drawRelief(); canvas.swapBuffers(); // context.release(); } }); canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException ex) { FableUtils.excMsg(ReliefView.class, "Error in createPartControl using GLContext.useContext", ex); } // GL11 gl = context.getGL (); 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); // context.release(); // create the grip for users to change the orientation, translation and // zoom grip = new SceneGrip(canvas, this); canvas.addMouseListener(grip); canvas.addMouseMoveListener(grip); canvas.addListener(SWT.MouseWheel, grip); canvas.addKeyListener(grip); // apparently opengl has to be redrawn constantly (why ?) Display.getCurrent().asyncExec(new Runnable() { // int rot = 0; public void run() { if (canvas == null) return; if (!canvas.isDisposed()) { canvas.setCurrent(); Rectangle bounds = canvas.getBounds(); grip.setBounds(bounds); canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException ex) { FableUtils.excMsg(ReliefView.class, "Error in createPartControl using " + "GLContext.useContext", ex); } // GL11 gl = context.getGL (); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glClearColor(.0f, .0f, .0f, 1.0f); // black background drawRelief(); canvas.swapBuffers(); // context.release(); Display.getCurrent().timerExec(200, this); } } }); createImageInformationPanel(parent); }