@Override public void draw(GameTime gameTime) { GL11.glClearColor(0, 0, 0, 0); GL11.glClearDepth(1.0); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); RasterizerState.CULL_CLOCKWISE.set(); BlendState.OPAQUE.set(); DepthState.DEFAULT.set(); program.use(); texture.use(TextureUnit.Texture0, program.getUniform("Texture")); vb.useAsAttrib(fxsi); ib.bind(); GL11.glDrawElements(PrimitiveType.Triangles, 6, GLType.UnsignedInt, 0); ib.unbind(); texture.unuse(); GLProgram.unuse(); if (!savedImage) { int sw = game.getWidth(); int sh = game.getHeight(); ByteBuffer pb = NativeMem.createByteBuffer(sw * sh * 4); GL11.glReadPixels(0, 0, sw, sh, PixelFormat.Rgba, GLType.UnsignedByte, pb); pb.position(0); pb.limit(sw * sh * 4); byte[] cb = new byte[4]; BufferedImage im = new BufferedImage(sw, sh, BufferedImage.TYPE_INT_ARGB); for (int y = sh - 1; y >= 0; y--) { for (int x = 0; x < sw; x++) { pb.get(cb); im.setRGB( x, y, (cb[2] & 0xFF) | ((cb[1] & 0xFF) << 8) | ((cb[0] & 0xFF) << 16) | 0xFF000000); } } try { ImageIO.write(im, "png", new File("Diag.png")); System.out.println("Image Has Been Saved"); } catch (IOException e) { System.out.println(e.getMessage()); } savedImage = true; } }
public void draw(RenderCamera camera) { if (currentObject == null) return; DepthState.NONE.set(); BlendState.ALPHA_BLEND.set(); RasterizerState.CULL_CLOCKWISE.set(); for (Manipulator manip : currentManips) { Matrix4 mTransform = getTransformation(manip, camera, currentObject); manipRenderer.render(mTransform, camera.mViewProjection, manip.type, manip.axis); } DepthState.DEFAULT.set(); BlendState.OPAQUE.set(); RasterizerState.CULL_CLOCKWISE.set(); for (Manipulator manip : currentManips) { Matrix4 mTransform = getTransformation(manip, camera, currentObject); manipRenderer.render(mTransform, camera.mViewProjection, manip.type, manip.axis); } }
public void checkPicking(Renderer renderer, RenderCamera camera, int mx, int my) { if (camera == null) return; // Pick An Object renderer.beginPickingPass(camera); renderer.drawPassesPick(); if (currentObject != null) { // Draw Object Manipulators GL11.glClearDepth(1.0); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); DepthState.DEFAULT.set(); BlendState.OPAQUE.set(); RasterizerState.CULL_NONE.set(); drawPick(camera, currentObject, renderer.pickProgram); } int id = renderer.getPickID(Mouse.getX(), Mouse.getY()); selectedManipulator = manips.get(id); if (selectedManipulator != null) { // Begin Manipulator Operations System.out.println( "Selected Manip: " + selectedManipulator.type + " " + selectedManipulator.axis); return; } SceneObject o = scene.objects.get(id); if (o != null) { System.out.println("Picked An Object: " + o.getID().name); if (scenePanel != null) { scenePanel.select(o.getID().name); propWindow.tabToForefront("Object"); } currentObject = rEnv.findObject(o); } else if (currentObject != null) { currentObject = null; } }