List of usage examples for org.lwjgl.opengl GL11 glClear
public static void glClear(@NativeType("GLbitfield") int mask)
From source file:RobotDemo.java
private void loop() { GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); GL11.glColor4f(1.0f, 0.0f, 0.0f, 1.0f); while (GLFW.glfwWindowShouldClose(window) != GL11.GL_TRUE) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glPushMatrix();/*from www .j a v a 2 s . c o m*/ for (Robot r : robots) r.draw(); GL11.glPopMatrix(); GLFW.glfwSwapBuffers(window); GLFW.glfwPollEvents(); } }
From source file:$.DrawSystem.java
License:Open Source License
@Override protected void processEntities(ImmutableBag<Entity> entities) { GL11.glClearColor(0.1f, 0, 0, 1f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); List<Entity> entititesSortedByZ = new ArrayList<>(entities.size()); for (int i = 0, n = entities.size(); i < n; ++i) { final Entity e = entities.get(i); if (e.isEnabled()) { entititesSortedByZ.add(e); }//from w ww .j a va 2s.c o m } Collections.sort(entititesSortedByZ, zComparator); 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.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); updateViewPort(); GL11.glViewport(viewPort.x, viewPort.y, viewPort.width, viewPort.height); GLU.gluOrtho2D(-toolkit.getVirtualResolutionWidth() / 2.0f, toolkit.getVirtualResolutionWidth() / 2.0f, toolkit.getVirtualResolutionHeight() / 2.0f, -toolkit.getVirtualResolutionHeight() / 2.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glEnable(GL11.GL_TEXTURE_2D); 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); Game game = (Game) world; Entity hero = game.getHero(); if (null != hero) { Sprite heroSprite = spriteMapper.get(hero); Vector heroPos = spriteProjector.project(heroSprite.getPosition()); GL11.glTranslatef(-heroPos.x, -heroPos.y, 0.0f); } for (Entity e : entititesSortedByZ) { MainMenu mainMenu = mainMenuMapper.getSafe(e); if (null != mainMenu) { mainMenu.draw(); } DialogueComponent dialog = dialogMapper.getSafe(e); if (null != dialog) { dialog.draw(); } Level level = levelMapper.getSafe(e); if (null != level) { drawLevel(level); } Sprite sprite = spriteMapper.getSafe(e); if (null != sprite) { drawSprite(sprite); } } GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glPopAttrib(); }
From source file:a1.gui.GUI_Map.java
License:Open Source License
public void CreateLightMap() { //Coord screen_size = new Coord(Config.getScreenWidth(), Config.getScreenHeight()); //Coord screen_coord = new Coord(GUI.map.mc).sub(screen_size.div(2)); List<Coord> lst = new ArrayList<Coord>(); for (RenderPart p : render_parts) { Drawable d = p.owner.getattr(Drawable.class); if (d != null) { if (d.name.contains("fir")) { lst.add(p.dc);/*www.j a va 2 s. c o m*/ } if (d.name.contains("player")) { lst.add(p.dc); } } } // for (Obj o : ObjCache.objs.values()) { // Drawable d = o.getattr(Drawable.class); // if (d != null) { // if (d.name.contains("tree")) { // if (o.getpos().in_rect(screen_coord, screen_size)) // lst.add(o.getpos()); // } // } // } if (first) { first = false; boolean FBOEnabled = GLContext.getCapabilities().GL_EXT_framebuffer_object; if (!FBOEnabled) Log.info("No FBO"); myFBOId = EXTFramebufferObject.glGenFramebuffersEXT(); //LightMap = GL11.glGenTextures(); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, myFBOId); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, LightMap, 0); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0); } //ByteBuffer bb = ByteBuffer.allocate(1024 * 1024 * 4); //GL11.glReadPixels(0, 0, 1024, 768, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, bb); // ? FBO ? ? EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, myFBOId); // GL11.glPushAttrib(GL11.GL_VIEWPORT_BIT); // ? // GL11.glViewport( 0, 0, 1024, 1024 ); // // ? // ? GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glClearColor(0.3f, 0.3f, 0.4f, 1.0f); GL11.glClear(GL_COLOR_BUFFER_BIT); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); // ? ? ? for (Coord c : lst) DrawLight(c, 100, 100); /*GL11.glTranslatef(0, 0, -6f); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(0, 0, 0); GL11.glVertex3f(200, 0, 0); GL11.glVertex3f(200, 200, 0); GL11.glVertex3f(0, 200, 0); GL11.glEnd();*/ // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0); // GL11.glPopAttrib(); // GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); // // //GL11.glBindTexture(GL11.GL_TEXTURE_2D, LightMap); //Render2D.CheckError(); // ? - ? //GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, 0, 0, 1024, 1024, 0); //GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1024, 1024); //Render2D.CheckError(); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
From source file:adrianton.gloptat.plotter.Displayer.java
License:Open Source License
public void loop() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); render();//from w ww. j a v a 2s . co m Display.update(); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); render(); Display.update(); while (true) { if (needsResurface) { needsResurface = false; Surface.release(); Surface.assemble(this); } // GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); if (mouse() || needsRepaint) // needs refresh { needsRepaint = false; GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); render(); Display.update(); Display.sync(40); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); render(); } // adv(); // render(); Display.update(); Display.sync(40); if (Display.isCloseRequested()) exitProgram(); } }
From source file:akarnokd.opengl.experiment.FontExample.java
License:Apache License
/** * Start the test // w ww . j a v a2 s .c o m */ public void start() { initGL(800, 600); init(); while (true) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); render(); Display.update(); Display.sync(100); if (Display.isCloseRequested()) { Display.destroy(); System.exit(0); } } }
From source file:analog.clock.AnalogClock.java
private void init() { GLFW.glfwInit();//from ww w . ja v a 2s .c om window = GLFW.glfwCreateWindow(600, 600, "Analog Clock", 0, 0); GLFW.glfwMakeContextCurrent(window); GL.createCapabilities(); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GLFW.glfwSwapBuffers(window); }
From source file:analog.clock.AnalogClock.java
private void loop() { try {/*from w ww. j av a 2s .com*/ for (int i = 0; i < 1000; i++) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); drawCircle(0.25, 8); // draw the sun earthOrbitAngle += 1; moonOrbitAngle += 5; earthAxisAngle += 10; GL11.glPushMatrix(); GL11.glRotatef(earthOrbitAngle, 0, 0, 1); GL11.glTranslatef(0.75f, 0.0f, 0.0f); GL11.glPushMatrix(); GL11.glRotatef(earthAxisAngle, 0, 0, 1); GL11.glScalef(0.5f, 0.5f, 0.5f); drawCircle(0.25, 3); // draw the earth GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glRotatef(moonOrbitAngle, 0, 0, 1); GL11.glTranslatef(0.25f, 0.0f, 0.0f); GL11.glScalef(0.25f, 0.25f, 0.25f); drawCircle(0.25, 5); // draw the moon GL11.glPopMatrix(); GL11.glPopMatrix(); Thread.sleep(10); GLFW.glfwSwapBuffers(window); } } catch (InterruptedException ex) { Logger.getLogger(AnalogClock.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:aphelion.client.Client.java
License:Open Source License
public static void initGL() { int displayWidth = Display.getWidth(); int displayHeight = Display.getHeight(); glDisableAll();/*from w ww .ja v a 2 s .c om*/ GL11.glViewport(0, 0, displayWidth, displayHeight); GL11.glMatrixMode(GL11.GL_PROJECTION); // Apply subsequent matrix operations to the projection matrix stack. GL11.glLoadIdentity(); GL11.glOrtho(0, displayWidth, displayHeight, 0, -1, 1); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT); AsyncTexture.unbind(); // Enable alpha channels for images GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_BLEND); Graph.g.setDimensions(displayWidth, displayHeight); Graphics.setCurrent(Graph.g); Graph.g.setDrawMode(Graphics.MODE_NORMAL); }
From source file:ar.com.quark.backend.lwjgl.opengl.DesktopGLES20.java
License:Apache License
/** * {@inheritDoc} */ @Override public void glClear(int value) { GL11.glClear(value); }
From source file:arg.RenderRecipe.java
License:Open Source License
public void draw() { File dir = new File(Minecraft.getMinecraft().mcDataDir, "recipes"); if (!dir.exists() && !dir.mkdirs()) { throw new RuntimeException("The recipes directory could not be created: " + dir); }// w w w .jav a 2s. co m name = name.replace(" ", ""); File file = new File(Minecraft.getMinecraft().mcDataDir, "recipes/" + name + ".png"); if (file.exists()) return; GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glViewport(0, 0, width, height); GL11.glOrtho(0.0D, xSize, ySize, 0.0D, 1000.0D, 3000.0D); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.0F, 0.0F, -2000.0F); GL11.glLineWidth(1.0F); GL11.glEnable(GL11.GL_COLOR_MATERIAL); try { drawScreen(0, 0, 0); } catch (Exception e) { e.printStackTrace(); } int[] pixels = new int[width * height]; int bindex; ByteBuffer fb = ByteBuffer.allocateDirect(width * height * 3); GL11.glReadPixels(0, 0, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, fb); GL11.glPopMatrix(); GL11.glPopAttrib(); GL11.glPopClientAttrib(); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); try { Display.swapBuffers(); } catch (LWJGLException e1) { e1.printStackTrace(); } BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int i = (x + (width * y)) * 3; int r = fb.get(i) & 0xFF; int g = fb.get(i + 1) & 0xFF; int b = fb.get(i + 2) & 0xFF; image.setRGB(x, height - (y + 1), (0xFF << 24) | (r << 16) | (g << 8) | b); } } try { ImageIO.write(image, "png", file); } catch (Exception e) { e.printStackTrace(); } }