graphics
Class Renderer

java.lang.Object
  extended by graphics.Renderer
All Implemented Interfaces:
EventListener, javax.media.opengl.GLEventListener

public class Renderer
extends Object
implements javax.media.opengl.GLEventListener

The renderer class controls the flow of the rendering thread across methods and objects according to the selected game mode. The graphics that are not sepcific to game mode are implemented in the methods of this class, as well as sound effects and the general logic and state info for the flow of the graphical rendering.

Author:
Terje

Field Summary
private  float clockRot
           
private  boolean countdownRendered
           
private  int countdowntexture
           
(package private)  TextureReader.Texture countdownTexture
           
private  GameMode currentGameMode
           
(package private)  boolean displayFirst
           
(package private)  boolean displaySec
           
(package private)  boolean displayThird
           
private  GraphicsFacade facade
           
private  boolean freshResults
           
private  double gameAverage
           
private  AudioSample gameOverSound
           
private  boolean gameOverSoundPlayed
           
private  javax.media.opengl.glu.GLU glu
           
private  com.sun.opengl.util.j2d.TextRenderer hiResTextRenderer
           
(package private)  TextureReader.Texture idleTexture
           
private  boolean isLastQuestion
           
private  boolean isLastRound
           
private  com.sun.opengl.util.j2d.TextRenderer midResTextRenderer
           
private  NumberFormat numberFormat
           
(package private)  int printAverage
           
private  boolean questionInitialized
           
private  float rot
           
private  boolean roundInitialized
           
private  AudioSample secondSound
           
private  long startTime
           
private  QuestionGraphics tempQuestion
           
private  Respondent[] tempRespondendts
           
private  Respondent[] tempSumGameRespondents
           
private  Respondent[] tempSumRespondents
           
private  com.sun.opengl.util.j2d.TextRenderer textRenderer
           
private  int texture
           
private  int timeLimit
           
private  long timemark
           
private  AudioSample timesUpSound
           
 
Constructor Summary
Renderer(GraphicsFacade facade)
          initialize variables, sound clips.
 
Method Summary
 void display(javax.media.opengl.GLAutoDrawable glDrawable)
          This method is called for each frame to be displayed.
 void displayChanged(javax.media.opengl.GLAutoDrawable glDrawable, boolean b, boolean b1)
           
private  int genTexture(javax.media.opengl.GL gl)
          OpenGL helper methid for preaparation of textures.
 void init(javax.media.opengl.GLAutoDrawable glDrawable)
          OpenGL specific einitializtion.
 void initializeLoginIdle(javax.media.opengl.GLAutoDrawable glDrawable)
           
 boolean isQuestionInitialized()
           
private  void makeRGBTexture(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu, TextureReader.Texture img, int target, boolean mipmapped)
          OpenGL helper methid for preaparation of textures.
 void nextStep()
          Jumps to the next logical step as the user requests next step or the previous step was finished.
 boolean renderEndGame(javax.media.opengl.GLAutoDrawable glDrawable)
          Render the high score list to screen
(package private)  void renderLoginIdle(javax.media.opengl.GLAutoDrawable glDrawable)
           
 void renderPopQuestion(javax.media.opengl.GLAutoDrawable glDrawable)
          Render the posing of the question, with alternatives and the animated timer.
 void reshape(javax.media.opengl.GLAutoDrawable glDrawable, int x, int y, int w, int h)
          OpenGL specific reshaping.
 void returnGameResults(Respondent[] respondents)
           
 void returnResults(QuestionGraphics question, Respondent[] respondents)
           
 void returnRoundResults(Respondent[] respondents)
           
 void setLastQuestion(boolean isLastQuestion)
           
 void setLastRound(boolean b)
           
 void setMode(int mode)
          A call to this method sets the current game mode to the selectid integer.
 void setQuestionInitialized(boolean questionInitialized)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

glu

private javax.media.opengl.glu.GLU glu

numberFormat

private NumberFormat numberFormat

textRenderer

private com.sun.opengl.util.j2d.TextRenderer textRenderer

hiResTextRenderer

private com.sun.opengl.util.j2d.TextRenderer hiResTextRenderer

midResTextRenderer

private com.sun.opengl.util.j2d.TextRenderer midResTextRenderer

tempQuestion

private QuestionGraphics tempQuestion

facade

private GraphicsFacade facade

texture

private int texture

countdowntexture

private int countdowntexture

countdownRendered

private boolean countdownRendered

rot

private float rot

startTime

private long startTime

clockRot

private float clockRot

timemark

private long timemark

timeLimit

private int timeLimit

questionInitialized

private boolean questionInitialized

roundInitialized

private boolean roundInitialized

secondSound

private AudioSample secondSound

timesUpSound

private AudioSample timesUpSound

isLastQuestion

private boolean isLastQuestion

displayFirst

boolean displayFirst

displaySec

boolean displaySec

displayThird

boolean displayThird

printAverage

int printAverage

idleTexture

TextureReader.Texture idleTexture

countdownTexture

TextureReader.Texture countdownTexture

currentGameMode

private GameMode currentGameMode

freshResults

private boolean freshResults

tempRespondendts

private Respondent[] tempRespondendts

tempSumRespondents

private Respondent[] tempSumRespondents

isLastRound

private boolean isLastRound

tempSumGameRespondents

private Respondent[] tempSumGameRespondents

gameAverage

private double gameAverage

gameOverSound

private AudioSample gameOverSound

gameOverSoundPlayed

private boolean gameOverSoundPlayed
Constructor Detail

Renderer

public Renderer(GraphicsFacade facade)
initialize variables, sound clips.

Parameters:
facade -
Method Detail

initializeLoginIdle

public void initializeLoginIdle(javax.media.opengl.GLAutoDrawable glDrawable)

renderLoginIdle

void renderLoginIdle(javax.media.opengl.GLAutoDrawable glDrawable)

renderEndGame

public boolean renderEndGame(javax.media.opengl.GLAutoDrawable glDrawable)
Render the high score list to screen

Parameters:
glDrawable -
Returns:

renderPopQuestion

public void renderPopQuestion(javax.media.opengl.GLAutoDrawable glDrawable)
Render the posing of the question, with alternatives and the animated timer.

Parameters:
glDrawable -

init

public void init(javax.media.opengl.GLAutoDrawable glDrawable)
OpenGL specific einitializtion.

Specified by:
init in interface javax.media.opengl.GLEventListener

display

public void display(javax.media.opengl.GLAutoDrawable glDrawable)
This method is called for each frame to be displayed. The current state of the program decides which method performs the actual rendering.

Specified by:
display in interface javax.media.opengl.GLEventListener

reshape

public void reshape(javax.media.opengl.GLAutoDrawable glDrawable,
                    int x,
                    int y,
                    int w,
                    int h)
OpenGL specific reshaping. See nehe.gamedev.net for documentation.

Specified by:
reshape in interface javax.media.opengl.GLEventListener

displayChanged

public void displayChanged(javax.media.opengl.GLAutoDrawable glDrawable,
                           boolean b,
                           boolean b1)
Specified by:
displayChanged in interface javax.media.opengl.GLEventListener

nextStep

public void nextStep()
Jumps to the next logical step as the user requests next step or the previous step was finished.


makeRGBTexture

private void makeRGBTexture(javax.media.opengl.GL gl,
                            javax.media.opengl.glu.GLU glu,
                            TextureReader.Texture img,
                            int target,
                            boolean mipmapped)
OpenGL helper methid for preaparation of textures.

Parameters:
gl -
glu -
img -
target -
mipmapped -

genTexture

private int genTexture(javax.media.opengl.GL gl)
OpenGL helper methid for preaparation of textures.

Parameters:
gl -
Returns:

setMode

public void setMode(int mode)
A call to this method sets the current game mode to the selectid integer. The integer must be the same on the server for meaningful processing.

Parameters:
mode -

isQuestionInitialized

public boolean isQuestionInitialized()

setQuestionInitialized

public void setQuestionInitialized(boolean questionInitialized)

returnResults

public void returnResults(QuestionGraphics question,
                          Respondent[] respondents)

setLastQuestion

public void setLastQuestion(boolean isLastQuestion)

setLastRound

public void setLastRound(boolean b)

returnRoundResults

public void returnRoundResults(Respondent[] respondents)

returnGameResults

public void returnGameResults(Respondent[] respondents)