public static void orthoMode(Size size) { GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glOrtho(0, size.getWidth(), 0, size.getHeight(), -10, 10); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); }
private void loadImages() throws Exception { // background backgroundControl = new FramedControl(); backgroundControl.setColor(Color.BLACK); backgroundControl.setOpacity(0.5f); backgroundControl.setSize(new Size(displayMode.getWidth(), displayMode.getHeight())); backgroundControl.setTopLeftPosition(new Point(0, 0)); WindowManager.getInstance().setBackgroundControl(backgroundControl); // middle dot middleDotControl = new VisualControl(); middleDotControl.setTexture(getClass().getResource(URL_IMAGE_MIDDLE_DOT)); Size middleDotControlSize = middleDotControl.getSize(); middleDotControl.setSize(new Size(middleDotControlSize.getWidth(), displayMode.getHeight())); middleDotControl.setTopLeftPosition( new Point(((displayMode.getWidth() / 2.0f) - (middleDotControlSize.getWidth() / 2.0f)), 0)); // top bar BounceableControl topBar = new BounceableControl(); topBar.setTexture(getClass().getResource(URL_IMAGE_WHITE_RECTANGLE)); topBar.setSize(new Size(displayMode.getWidth(), BAR_SIZE)); topBar.setTopLeftPosition(new Point(0, 0)); bounceableControls.add(topBar); // bottom bar BounceableControl bottomBar = new BounceableControl(); bottomBar.setTexture(getClass().getResource(URL_IMAGE_WHITE_RECTANGLE)); bottomBar.setSize(new Size(displayMode.getWidth(), BAR_SIZE)); bottomBar.setTopLeftPosition(new Point(0, (displayMode.getHeight() - BAR_SIZE))); bounceableControls.add(bottomBar); // win/lose wonControl = new VisualControl(); // wonControl.setColor(Color.BLACK); wonControl.setTexture(getClass().getResource(URL_IMAGE_WON)); wonControl.setVisible(false); lostControl = new VisualControl(); // lostControl.setColor(Color.BLACK); lostControl.setTexture(getClass().getResource(URL_IMAGE_LOST)); lostControl.setVisible(false); // paddles for (int i = 0; i < NUMBER_OF_PADDLES; i++) { BounceableControl paddle = new BounceableControl(); paddle.setTexture(getClass().getResource(URL_IMAGE_WHITE_RECTANGLE)); paddle.setVisible(false); paddles.put(i, paddle); } // ball shadows for (int i = 0; i < NUMBER_OF_BALL_SHADOWS; i++) { float opacity = (1.0f - ((1.0f / (float) (NUMBER_OF_BALL_SHADOWS + 1)) * (i + 1))); float size = (BALL_SIZE * (NUMBER_OF_BALL_SHADOWS / (float) (NUMBER_OF_BALL_SHADOWS + (i + 1)))); log.debug("opacity: " + opacity + ", size: " + size); VisualControl visualControl = new VisualControl(); visualControl.setTexture(getClass().getResource(URL_IMAGE_WHITE_RECTANGLE)); visualControl.setSize(new Size(size, size)); visualControl.setOpacity(opacity); visualControl.setVisible(false); ballShadows.addLast(visualControl); } // ball ball = new VisualControl(); // ball.setColor(Color.BLACK); ball.setTexture(getClass().getResource(URL_IMAGE_WHITE_RECTANGLE)); ball.setSize(new Size(BALL_SIZE, BALL_SIZE)); // ball.setMargin(1.0f); ball.setVisible(false); // listeners backgroundControl.addTouchListener(this); }