better handling of minimized mode
This commit is contained in:
parent
035068e776
commit
f0dcde5310
|
@ -40,6 +40,9 @@ public class PositionTest extends BasicTest {
|
||||||
/** Whether the demo is done */
|
/** Whether the demo is done */
|
||||||
private boolean finished = false;
|
private boolean finished = false;
|
||||||
|
|
||||||
|
/** Whether in pause mode */
|
||||||
|
private boolean pauseMode = false;
|
||||||
|
|
||||||
// OpenAL stuff
|
// OpenAL stuff
|
||||||
// ===================================================
|
// ===================================================
|
||||||
|
|
||||||
|
@ -244,30 +247,62 @@ public class PositionTest extends BasicTest {
|
||||||
// handle any input
|
// handle any input
|
||||||
handleInput();
|
handleInput();
|
||||||
|
|
||||||
// render the scene
|
// render and paint if !minimized and not dirty
|
||||||
render();
|
if(!Window.isMinimized() || Window.isDirty()) {
|
||||||
|
render();
|
||||||
|
Window.paint();
|
||||||
|
} else {
|
||||||
|
// sleeeeeep
|
||||||
|
pause(100);
|
||||||
|
}
|
||||||
|
|
||||||
// allow window to process internal messages
|
// allow window to process internal messages
|
||||||
Window.update();
|
Window.update();
|
||||||
|
|
||||||
// paint the content and flip buffer
|
// act on pause mode
|
||||||
Window.paint();
|
paused(Window.isMinimized());
|
||||||
|
|
||||||
// start sound after first paint, since we don't want
|
// start sound after first paint, since we don't want
|
||||||
// the delay before something is painted on the screen
|
// the delay before something is painted on the screen
|
||||||
if (firstRun) {
|
if (firstRun && !pauseMode) {
|
||||||
firstRun = false;
|
firstRun = false;
|
||||||
|
|
||||||
// start sounds with delays
|
// start sounds with delays
|
||||||
AL.alSourcePlay(soundSources.get(LEFT));
|
startSounds();
|
||||||
pause(300);
|
|
||||||
AL.alSourcePlay(soundSources.get(CENTER));
|
|
||||||
pause(500);
|
|
||||||
AL.alSourcePlay(soundSources.get(RIGHT));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts playing the sounds at different times
|
||||||
|
*/
|
||||||
|
private void startSounds() {
|
||||||
|
AL.alSourcePlay(soundSources.get(LEFT));
|
||||||
|
pause(300);
|
||||||
|
AL.alSourcePlay(soundSources.get(CENTER));
|
||||||
|
pause(500);
|
||||||
|
AL.alSourcePlay(soundSources.get(RIGHT));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles any changes in pause mode
|
||||||
|
*
|
||||||
|
* @param paused Which pause mode to enter
|
||||||
|
*/
|
||||||
|
private void paused(boolean paused) {
|
||||||
|
// if requesting pause, and not paused - pause and stop sound
|
||||||
|
if(paused && !pauseMode) {
|
||||||
|
pauseMode = true;
|
||||||
|
AL.alSourcePause(soundSources);
|
||||||
|
}
|
||||||
|
|
||||||
|
// else go out of pause mode and start sounds
|
||||||
|
else if(!paused && pauseMode) {
|
||||||
|
pauseMode = false;
|
||||||
|
startSounds();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles any input
|
* Handles any input
|
||||||
*/
|
*/
|
||||||
|
@ -374,6 +409,7 @@ public class PositionTest extends BasicTest {
|
||||||
{
|
{
|
||||||
GL.glRotatef(20.0f, 1.0f, 1.0f, 0.0f);
|
GL.glRotatef(20.0f, 1.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
|
// left
|
||||||
GL.glPushMatrix();
|
GL.glPushMatrix();
|
||||||
{
|
{
|
||||||
GL.glTranslatef(leftPosition.get(0), leftPosition.get(1), leftPosition.get(2));
|
GL.glTranslatef(leftPosition.get(0), leftPosition.get(1), leftPosition.get(2));
|
||||||
|
@ -382,6 +418,7 @@ public class PositionTest extends BasicTest {
|
||||||
}
|
}
|
||||||
GL.glPopMatrix();
|
GL.glPopMatrix();
|
||||||
|
|
||||||
|
// center
|
||||||
GL.glPushMatrix();
|
GL.glPushMatrix();
|
||||||
{
|
{
|
||||||
GL.glTranslatef(centerPosition.get(0), centerPosition.get(1), centerPosition.get(2));
|
GL.glTranslatef(centerPosition.get(0), centerPosition.get(1), centerPosition.get(2));
|
||||||
|
@ -390,6 +427,7 @@ public class PositionTest extends BasicTest {
|
||||||
}
|
}
|
||||||
GL.glPopMatrix();
|
GL.glPopMatrix();
|
||||||
|
|
||||||
|
// right
|
||||||
GL.glPushMatrix();
|
GL.glPushMatrix();
|
||||||
{
|
{
|
||||||
GL.glTranslatef(rightPosition.get(0), rightPosition.get(1), rightPosition.get(2));
|
GL.glTranslatef(rightPosition.get(0), rightPosition.get(1), rightPosition.get(2));
|
||||||
|
@ -398,7 +436,7 @@ public class PositionTest extends BasicTest {
|
||||||
}
|
}
|
||||||
GL.glPopMatrix();
|
GL.glPopMatrix();
|
||||||
|
|
||||||
//the listener
|
// listener
|
||||||
GL.glPushMatrix();
|
GL.glPushMatrix();
|
||||||
{
|
{
|
||||||
GL.glTranslatef(listenerPosition.get(0), listenerPosition.get(1), listenerPosition.get(2));
|
GL.glTranslatef(listenerPosition.get(0), listenerPosition.get(1), listenerPosition.get(2));
|
||||||
|
|
Loading…
Reference in New Issue