/* Copyright 2010 Christian Matt
*
* This file is part of PonkOut.
*
* PonkOut is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PonkOut is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PonkOut. If not, see <http://www.gnu.org/licenses/>.
*/
package ponkOut.graphics;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.Sphere;
import org.lwjgl.util.vector.Vector2f;
import ponkOut.logic.Ball;
public class SolidBallGO extends BallGO {
private int displayList;
public SolidBallGO(Ball ball, Material material, GraphicsObjectsManager goManager) {
super(ball, material, goManager);
Sphere sphere = new Sphere();
float radius = ball.getRadius();
// use more polygons for larger balls
int res = (int) (7 + 15.0f * radius);
// create display list
displayList = GL11.glGenLists(1);
GL11.glNewList(displayList, GL11.GL_COMPILE);
sphere.draw(radius, res, res);
GL11.glEndList();
}
@Override
public void draw() {
// store current transformation matrix
GL11.glPushMatrix();
// translate to ball position
Vector2f pos = ball.getPosition();
GL11.glTranslatef(pos.x, pos.y, 0.0f);
// enable lighting
Lighting.enable(false);
// set material
appearance.use();
// draw the ball
GL11.glCallList(displayList);
// disable lighting
Lighting.disable();
// restore transformation matrix
GL11.glPopMatrix();
}
}