List of usage examples for org.lwjgl.opengl GL11 glClearDepth
public static void glClearDepth(@NativeType("GLdouble") double depth)
From source file:com.opengrave.og.MainThread.java
License:Open Source License
protected void initGL() { if (glfwInit() != GLFW_TRUE) { System.exit(1);//from w w w .ja v a 2s . c om } glfwDefaultWindowHints(); glfwWindowHint(GLFW_VISIBLE, GLFW_TRUE); glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); window = glfwCreateWindow(800, 600, "HiddenGrave", NULL, NULL); if (window == NULL) { System.exit(1); } glfwMakeContextCurrent(window); glfwSwapInterval(1); // TODO condig of vsync. Enable vsync GL.createCapabilities(); glfwSetFramebufferSizeCallback(window, (framebufferSizeCallback = new GLFWFramebufferSizeCallback() { @Override public void invoke(long window, int width, int height) { onResize(width, height); } })); onResize(800, 600); // TODO Check all extensions. TEX 2D ARRAY, GLSL 130 createConfig(); Util.initMatrices(); Renderable.init(); GUIXML.init(); // Prepare Lighting initLighting(); // Default Values GL11.glClearColor(0.5f, 0.5f, 0.5f, 1.0f); // sets background to grey Util.checkErr(); GL11.glClearDepth(1.0f); // clear depth buffer Util.checkErr(); GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables depth testing Util.checkErr(); GL11.glDepthFunc(GL11.GL_LEQUAL); // sets the type of test to use for // depth testing GL11.glEnable(GL11.GL_BLEND); Resources.loadTextures(); // Reconsider positioning. Other than GUI // texture we could offset these in another // thread... Possibly? Resources.loadModels(); Resources.loadFonts(); }
From source file:com.runescape.client.revised.editor.modelviewer.Main.java
License:Open Source License
public static void initialize(final Canvas modelCanvas) { try {/*from ww w . j a va 2s.com*/ 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.rvantwisk.cnctools.controls.opengl.OpenGLRenderer.java
License:Open Source License
protected void init() { GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearDepth(1.0); GL11.glDepthFunc(GL11.GL_LEQUAL);/*from w ww. j av a2 s . co m*/ GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
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 w ww.ja va 2s. 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:com.telinc1.rpjg.Game.java
License:Apache License
public void start() { // Start logging. Configurator.defaultConfig().writer(new ConsoleWriter()) .formatPattern("[{date:yyyy-MM-dd HH:mm:ss}] [{level}] [{class_name}] {message}").activate(); Logger.info("Creating and initializing game."); // Create the display. try {// ww w . j ava 2 s. co m Display.setTitle(GameOptions.GAME_NAME); Display.setResizable(false); Display.setDisplayMode(new DisplayMode(640, 360)); Display.setVSyncEnabled(true); Display.setFullscreen(false); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); System.exit(ExitCodes.INIT_DISPLAY); } finally { this.isRunning = true; Logger.info("Finished display creation."); } // Initialize OpenGL. GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0f, 0f, 0f, 0f); GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight()); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); // Load all textures. TextureLoader.initialize(); // Initialize the game. this.initialize(); // Load the default map. this.loadMap("dungeon"); ModuleManager.getInstance().openModule(new ModuleMap()); // Main game loop while (this.isRunning() && !Display.isCloseRequested()) { // Clear the screen from the previous frame. GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); this.loop(); this.draw(); this.collectInput(); // Sync and update the display. Display.update(); Display.sync(GameOptions.FRAME_RATE); } // Free up all resources and exit. Logger.info("Close requested!"); TextureLoader.destroy(); Display.destroy(); Logger.info("Resources destroyed - exiting."); System.exit(ExitCodes.CLOSE_REQUESTED); }
From source file:edu.csun.ecs.cs.multitouchj.ui.graphic.WindowManager.java
License:Apache License
protected void initializeOpenGl() { DisplayMode displayMode = displayManager.getCurrentDisplayMode(); GL11.glEnable(GL11.GL_DEPTH_TEST);//from ww w . j a v a 2 s .c o m GL11.glClearDepth(1.0f); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glViewport(0, 0, displayMode.getWidth(), displayMode.getHeight()); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); //GLU.gluPerspective(45.0f, (float)SCREEN_WIDTH/(float)SCREEN_HEIGHT, 4.0f, 4000.0f); GLU.gluPerspective(45.0f, (float) displayMode.getWidth() / (float) displayMode.getHeight(), 1.0f, 100.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //GL11.glClearDepth(1.0f); //GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); //GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); }
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:eu.over9000.veya.gui.Gui.java
License:Open Source License
private static void setUpStates(final int width, final int height) { try {/* w w w .j a v a 2 s. c om*/ Display.setDisplayMode(new DisplayMode(width, height)); Display.create(); //Display.create(new PixelFormat().withSamples(4).withDepthBits(24), new ContextAttribs(3, 3)); Display.setVSyncEnabled(true); } catch (final LWJGLException e) { e.printStackTrace(); System.exit(0); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0.0f, 0.3f, 0.0f, 0.0f); GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, width, height, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
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);/*from ww w . jav a 2s . 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); }
From source file:fr.def.iss.vd2.lib_v3d.V3DCanvas.java
License:Open Source License
/** * Sets up the screen./*ww w . j a v a 2 s . c o m*/ * * @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(); }