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:fr.def.iss.vd2.lib_v3d.V3DCanvas.java
License:Open Source License
/** * Sets up the screen.//from ww w . j av a 2s . c om * * @see javax.media.openGL11.GLEventListener#init(javax.media.openGL11.GLAutoDrawable) */ public void init() { try { frame = new JFrame("Space agencies"); //frame.setSize(width,height); //frame.setUndecorated(true); //here frame.setVisible(true); //frame.setAlwaysOnTop(true); frame.setLocation(0, 0); Canvas canvas = new Canvas(); canvas.setMinimumSize(new Dimension(800, 600)); canvas.setPreferredSize(new Dimension(width, height)); frame.add(canvas); frame.pack(); frame.addWindowListener(generateWindowListener()); frame.getContentPane().addHierarchyBoundsListener(new HierarchyBoundsListener() { @Override public void ancestorMoved(HierarchyEvent e) { } @Override public void ancestorResized(HierarchyEvent e) { width = frame.getContentPane().getWidth(); height = frame.getContentPane().getHeight(); reshape(0, 0, width, height); } }); Display.setDisplayMode(new DisplayMode(width, height)); //Display.setFullscreen(true); Display.setVSyncEnabled(false); Display.setTitle("Space agencies"); Display.setParent(canvas); Display.create(); canvas.requestFocus(); } catch (Exception e) { System.out.println("Error setting up display" + e); System.exit(0); } // Enable z- (depth) buffer for hidden surface removal. GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glEnable(GL11.GL_POINT_SMOOTH); if (polygonOffset) { GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glPolygonOffset(1.0f, 1.0f); } GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST); GL11.glClearDepth(1.0); // Enables Clearing Of The Depth Buffer GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_BLEND); // Enable smooth shading. GL11.glShadeModel(GL11.GL_SMOOTH); // Define "clear" color. GL11.glClearColor(0f, 0f, 0.4f, 0f); // We want a nice perspective. GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glFlush(); TextureManager.clearCache(); initied = true; // new LWJGLBinding(); }
From source file:hellfirepvp.astralsorcery.client.gui.journal.GuiProgressionClusterRenderer.java
License:Open Source License
private void drawConnection(double originX, double originY, double targetX, double targetY, float zLevel) { GL11.glPushMatrix();/*from www.j a v a 2 s .c o m*/ GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glLineWidth(3.5F); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); long clientTicks = ClientScheduler.getClientTick(); Vector3 origin = new Vector3(originX, originY, 0); Vector3 line = origin.vectorFromHereTo(targetX, targetY, 0); int segments = (int) Math.ceil(line.length() / 1); //1 = max line segment length int activeSegment = (int) (clientTicks % segments); Vector3 segmentIter = line.divide(segments); for (int i = segments; i >= 0; i--) { double lx = origin.getX(); double ly = origin.getY(); origin.add(segmentIter); float brightness = 0.4F; brightness += (0.6F * evaluateBrightness(i, activeSegment)); drawLinePart(lx, ly, origin.getX(), origin.getY(), zLevel, brightness); } GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(2.0F); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); GL11.glPopMatrix(); }
From source file:illarion.graphics.lwjgl.DriverSettingsLWJGL.java
License:Open Source License
/** * Setup OpenGL to render dots./*ww w . j a v a 2 s .c om*/ */ public void enableDrawDot() { if (currentMode != MODE_DRAWDOT) { disableLast(); final int quality = Graphics.getInstance().getQuality(); if (quality >= Graphics.QUALITY_NORMAL) { GL11.glEnable(GL11.GL_POINT_SMOOTH); if (quality >= Graphics.QUALITY_HIGH) { GL11.glHint(GL11.GL_POINT_SMOOTH_HINT, GL11.GL_NICEST); } else { GL11.glHint(GL11.GL_POINT_SMOOTH_HINT, GL11.GL_FASTEST); } } else { GL11.glDisable(GL11.GL_POINT_SMOOTH); } GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); currentMode = MODE_DRAWDOT; } }
From source file:illarion.graphics.lwjgl.DriverSettingsLWJGL.java
License:Open Source License
/** * Setup OpenGL to render lines./*from w ww. ja v a 2s .co m*/ */ public void enableDrawLine() { if (currentMode != MODE_DRAWLINE) { disableLast(); final int quality = Graphics.getInstance().getQuality(); if (quality >= Graphics.QUALITY_NORMAL) { GL11.glEnable(GL11.GL_LINE_SMOOTH); if (quality >= Graphics.QUALITY_HIGH) { GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); } else { GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_FASTEST); } } else { GL11.glDisable(GL11.GL_LINE_SMOOTH); } GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); currentMode = MODE_DRAWLINE; } }
From source file:illarion.graphics.lwjgl.DriverSettingsLWJGL.java
License:Open Source License
/** * Setup OpenGL to render polygons.//from w ww . ja va 2 s. co m */ public void enableDrawPoly() { if (currentMode != MODE_DRAWPOLY) { disableLast(); final int quality = Graphics.getInstance().getQuality(); if (quality == Graphics.QUALITY_MAX) { GL11.glEnable(GL11.GL_POLYGON_SMOOTH); GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST); } else { GL11.glDisable(GL11.GL_POLYGON_SMOOTH); } GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); currentMode = MODE_DRAWPOLY; } }
From source file:illarion.graphics.lwjgl.TextureAtlasLWJGL.java
License:Open Source License
/** * Activate the texture and prepare it for usage by OpenGL. * // w w w .j a v a2 s .c om * @param resizeable true in case the texture shall be loaded with advanced * rescaling methods, that are more calculation intensive but * look better then the normal ones * @param allowCompression true if the texture is compressed at default * settings, false if not. Best disallow compression for static * images such as tiles, since the effects of the compression * will be quite visible there */ @Override @SuppressWarnings("nls") public void activateTexture(final boolean resizeable, final boolean allowCompression) { if (!hasTextureData()) { throw new IllegalStateException("No texturedata loaded"); } final int quality = Graphics.getInstance().getQuality(); if (getTextureID() != 0) { removeTexture(); } // generate new texture ID final int texID = getNewTextureID(); setTextureID(texID); // bind texture ID DriverSettingsLWJGL.getInstance().enableTexture(texID); // prepare texture data if (resizeable) { // Textures will be resized -> smoothing would be good if (quality <= Graphics.QUALITY_LOW) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); } else if ((quality <= Graphics.QUALITY_NORMAL) || isNoMipMaps()) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); } else { if (GLContext.getCapabilities().OpenGL14) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_GENERATE_MIPMAP, GL11.GL_TRUE); } else { setNoMipMaps(true); } if (!isNoMipMaps()) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); } else { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); } } } else { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); } GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); if (GLContext.getCapabilities().OpenGL13) { GL11.glHint(GL13.GL_TEXTURE_COMPRESSION_HINT, GL11.GL_NICEST); } // setup texture compression final boolean activateCompression = GLContext.getCapabilities().OpenGL13 && ((allowCompression && (quality < Graphics.QUALITY_MAX)) || (quality <= Graphics.QUALITY_LOW)); if (isTextureRGBA()) { internalFormat = GL11.GL_RGBA; sourceFormat = GL11.GL_RGBA; if (activateCompression) { internalFormat = GL13.GL_COMPRESSED_RGBA; } } else if (isTextureRGB()) { internalFormat = GL11.GL_RGB; sourceFormat = GL11.GL_RGB; if (activateCompression) { internalFormat = GL13.GL_COMPRESSED_RGB; } } else if (isTextureGrey()) { internalFormat = GL11.GL_LUMINANCE; sourceFormat = GL11.GL_LUMINANCE; if (activateCompression) { internalFormat = GL13.GL_COMPRESSED_LUMINANCE; } } else if (isTextureGreyAlpha()) { internalFormat = GL11.GL_LUMINANCE_ALPHA; sourceFormat = GL11.GL_LUMINANCE_ALPHA; if (activateCompression) { internalFormat = GL13.GL_COMPRESSED_LUMINANCE_ALPHA; } } final ByteBuffer texData = getTextureData(); final int texWidth = getTextureWidth(); final int texHeight = getTextureHeight(); // produce a texture from the byte buffer GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, internalFormat, texWidth, texHeight, 0, sourceFormat, GL11.GL_UNSIGNED_BYTE, texData); if (quality < Graphics.QUALITY_MAX) { texIDBuffer.rewind(); GL11.glGetTexLevelParameter(GL11.GL_TEXTURE_2D, 0, GL13.GL_TEXTURE_COMPRESSED, texIDBuffer); texData.rewind(); if (texIDBuffer.get(0) == GL11.GL_FALSE) { int newInternalFormat = internalFormat; if (internalFormat == GL13.GL_COMPRESSED_LUMINANCE_ALPHA) { newInternalFormat = GL13.GL_COMPRESSED_RGBA; } else if (internalFormat == GL13.GL_COMPRESSED_LUMINANCE) { newInternalFormat = GL13.GL_COMPRESSED_RGB; } final int orgSize = texData.remaining(); if (newInternalFormat != internalFormat) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, newInternalFormat, texWidth, texHeight, 0, sourceFormat, GL11.GL_UNSIGNED_BYTE, texData); GL11.glGetTexLevelParameter(GL11.GL_TEXTURE_2D, 0, GL13.GL_TEXTURE_COMPRESSED_IMAGE_SIZE, texIDBuffer); final int newSize = texIDBuffer.get(0); if (newSize > orgSize) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, internalFormat, texWidth, texHeight, 0, sourceFormat, GL11.GL_UNSIGNED_BYTE, texData); } } } } texIDBuffer.rewind(); GL11.glGetTexLevelParameter(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_INTERNAL_FORMAT, texIDBuffer); internalFormat = texIDBuffer.get(); discardImageData(); }
From source file:im.bci.jnuit.lwjgl.LwjglNuitRenderer.java
License:Open Source License
@Override public void render(Root root) { GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_TRANSFORM_BIT | GL11.GL_HINT_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_SCISSOR_BIT | GL11.GL_LINE_BIT | GL11.GL_TEXTURE_BIT); GL11.glViewport(0, 0, LwjglHelper.getWidth(), LwjglHelper.getHeight()); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix();// w ww . j av a2s .c o m GL11.glLoadIdentity(); GL11.glOrtho(root.getX(), root.getWidth(), root.getHeight(), root.getY(), -1.0, 1.0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_SCISSOR_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glEnable(GL11.GL_TEXTURE_2D); drawBackgroundAndBorder(root); drawStack(root); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glPopAttrib(); }
From source file:io.flob.blackheart.Level.java
License:Open Source License
public void tick() throws Exception { if (display_list_dirty) { load_display_list();/* w ww. j a v a 2s . c om*/ } ByteBuffer temp = ByteBuffer.allocateDirect(16); temp.order(ByteOrder.nativeOrder()); float fog_colour[] = new float[] { 0f, 0f, 0f, 0f }; GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP); temp.asFloatBuffer().put(fog_colour).flip(); GL11.glFog(GL11.GL_FOG_COLOR, temp.asFloatBuffer()); GL11.glFogf(GL11.GL_FOG_DENSITY, 0.25f); GL11.glHint(GL11.GL_FOG_HINT, GL11.GL_DONT_CARE); GL11.glFogf(GL11.GL_FOG_START, 0); GL11.glFogf(GL11.GL_FOG_END, 200); _barry.tick(); try { Collections.sort(objects_dynamic, this.sort_objects); } catch (Exception ex) { Output.error(ex.getMessage()); } if (Debug.collision_boxs) { _game._core._display.flush_texture(); for (int count = 0; count < objects_static.size(); count++) { if (objects_static.get(count) instanceof ICollidable) { ICollidable objcet = (ICollidable) objects_static.get(count); objcet.collision_box().render(); } } for (int count = 0; count < objects_dynamic.size(); count++) { if (objects_dynamic.get(count) instanceof ICollidable) { ICollidable objcet = (ICollidable) objects_dynamic.get(count); objcet.collision_box().render(); } } _barry.collision_box().render(); _barry.ray_picker().collision_box().render(); } GL11.glPushMatrix(); _game._core._texture.game_atlas.bind(); if (_game.anaglyph()) { GL11.glTranslatef(1 * 0.03f, 0, 0); GL11.glColorMask(true, false, false, true); } GL11.glBegin(GL11.GL_QUADS); GL11.glCallList(display_list); for (int count = 0; count < objects_dynamic.size(); count++) { objects_dynamic.get(count).tick(); } GL11.glEnd(); if (_game.anaglyph()) { GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glColorMask(false, true, true, true); GL11.glTranslatef(-1 * 0.03f, 0, 0); GL11.glBegin(GL11.GL_QUADS); GL11.glCallList(display_list); for (int count = 0; count < objects_dynamic.size(); count++) { objects_dynamic.get(count)._render(); } GL11.glEnd(); GL11.glColorMask(true, true, true, true); } GL11.glPopMatrix(); for (int count = 0; count < objects_dynamic.size(); count++) { if (objects_dynamic.get(count).IRemove()) { objects_dynamic.remove(count); } } _hud.tick(); if (_barry.health() <= 0) { _game._core.state(_game._core._game_dead); } }
From source file:io.flob.clicker.DisplayDriver.java
License:Open Source License
private void init_GL() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();// ww w .j av a 2 s . co m GL11.glOrtho(0, width, height, 0, -1, 1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glClearColor(0.1f, 0.1f, 0.1f, 1.0f); GL11.glClearDepth(1.0f); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
From source file:io.github.SolidStudiosTeam.Flicker.engine.GameLoop.java
License:Open Source License
@Override public void initGL() { /* Enable 2D textures. */ GL11.glEnable(GL11.GL_TEXTURE_2D);/*from w ww.j av a 2s . c o m*/ /* Make all models smoothly textured. */ GL11.glShadeModel(GL11.GL_SMOOTH); /* Set the background color to that signature blue. */ GL11.glClearColor(0.9f, 1.0f, 1.0f, 0.0f); /* Set the clear depth to all-the-way */ GL11.glClearDepth(1.0); /* Enable the depth system. */ GL11.glEnable(GL11.GL_DEPTH_TEST); /* Set the function for depth to GL_LEQUAL. */ GL11.glDepthFunc(GL11.GL_LEQUAL); // GL11.glEnable(GL11.GL_BLEND); //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); /* Enable face culling, basically don't render this face relative to the camera's position. */ // GL11.glEnable(GL11.GL_CULL_FACE); /* Set OpenGL to cull the back face of our spatials. */ // GL11.glCullFace(GL11.GL_BACK); /* Set the matrix mode to projection. */ GL11.glMatrixMode(GL11.GL_PROJECTION); /* Reset the OpenGL configuration, loading our above prefrences. */ GL11.glLoadIdentity(); /* Set the perspective. */ GLU.gluPerspective(45.0f, (float) displayMode.getWidth() / (float) displayMode.getHeight(), 0.1f, 100.0f); /* Set the matrix mode to be model view. */ GL11.glMatrixMode(GL11.GL_MODELVIEW); /* Set the perspective correction hint to finest quality. */ GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); }