aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/render/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jake2/render/opengl')
-rw-r--r--src/jake2/render/opengl/GLDriver.java4
-rw-r--r--src/jake2/render/opengl/JoglDummyDriver.java22
-rw-r--r--src/jake2/render/opengl/JoglES1Driver.java24
-rw-r--r--src/jake2/render/opengl/JoglES2Driver.java28
-rw-r--r--src/jake2/render/opengl/JoglGL2Driver.java21
-rw-r--r--src/jake2/render/opengl/JoglGL2ES1.java8
-rw-r--r--src/jake2/render/opengl/NEWTWin.java162
7 files changed, 121 insertions, 148 deletions
diff --git a/src/jake2/render/opengl/GLDriver.java b/src/jake2/render/opengl/GLDriver.java
index 6fda8cf..0967576 100644
--- a/src/jake2/render/opengl/GLDriver.java
+++ b/src/jake2/render/opengl/GLDriver.java
@@ -1,5 +1,7 @@
package jake2.render.opengl;
+import java.util.List;
+
import javax.media.nativewindow.util.Dimension;
import jake2.qcommon.xcommand_t;
@@ -24,7 +26,7 @@ public interface GLDriver {
void logNewFrame();
- ScreenMode[] getModeList();
+ List<ScreenMode> getModeList();
void updateScreen(xcommand_t callback);
diff --git a/src/jake2/render/opengl/JoglDummyDriver.java b/src/jake2/render/opengl/JoglDummyDriver.java
index fb41bf7..3316f2a 100644
--- a/src/jake2/render/opengl/JoglDummyDriver.java
+++ b/src/jake2/render/opengl/JoglDummyDriver.java
@@ -25,6 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package jake2.render.opengl;
+import java.util.List;
+
import jake2.qcommon.xcommand_t;
import jake2.render.Base;
@@ -49,7 +51,7 @@ public abstract class JoglDummyDriver extends DummyGL implements GLDriver {
public abstract String getName();
- public ScreenMode[] getModeList() {
+ public List<ScreenMode> getModeList() {
if(null == newtWin) {
throw new RuntimeException("NEWTWin not yet initialized.");
}
@@ -62,7 +64,6 @@ public abstract class JoglDummyDriver extends DummyGL implements GLDriver {
}
int res = newtWin.setMode(glp, dim, mode, fullscreen, getName());
if( Base.rserr_ok == res ) {
- activate();
init(0, 0);
return Base.rserr_ok;
@@ -71,7 +72,6 @@ public abstract class JoglDummyDriver extends DummyGL implements GLDriver {
}
public void shutdown() {
- deactivate();
if(null != newtWin) {
newtWin.shutdown();
}
@@ -98,7 +98,7 @@ public abstract class JoglDummyDriver extends DummyGL implements GLDriver {
}
public void beginFrame(float camera_separation) {
- activate();
+ activateGLContext();
}
public void endFrame() {
@@ -126,18 +126,12 @@ public abstract class JoglDummyDriver extends DummyGL implements GLDriver {
callback.execute();
}
- protected void activate() {
- final GLContext ctx = newtWin.window.getContext();
- if ( null != ctx && GLContext.getCurrent() != ctx ) {
- ctx.makeCurrent();
- }
+ protected final void activateGLContext() {
+ newtWin.activateGLContext();
}
- protected void deactivate() {
- final GLContext ctx = newtWin.window.getContext();
- if ( null != ctx && GLContext.getCurrent() == ctx) {
- ctx.release();
- }
+ protected final void deactivateGLContext() {
+ newtWin.activateGLContext();
}
// --------------------------------------------------------------------------
diff --git a/src/jake2/render/opengl/JoglES1Driver.java b/src/jake2/render/opengl/JoglES1Driver.java
index 64d3790..790b2d8 100644
--- a/src/jake2/render/opengl/JoglES1Driver.java
+++ b/src/jake2/render/opengl/JoglES1Driver.java
@@ -25,6 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package jake2.render.opengl;
+import java.util.List;
+
import jake2.game.cvar_t;
import jake2.qcommon.Cvar;
import jake2.qcommon.xcommand_t;
@@ -59,7 +61,7 @@ public abstract class JoglES1Driver extends JoglGL2ES1 implements GLDriver {
public abstract String getName();
- public ScreenMode[] getModeList() {
+ public List<ScreenMode> getModeList() {
if(null == newtWin) {
throw new RuntimeException("NEWTWin not yet initialized.");
}
@@ -72,7 +74,6 @@ public abstract class JoglES1Driver extends JoglGL2ES1 implements GLDriver {
}
int res = newtWin.setMode(glp, dim, mode, fullscreen, getName());
if( Base.rserr_ok == res ) {
- activate();
setGL(newtWin.window.getGL().getGL2ES1());
init(0, 0);
@@ -82,7 +83,6 @@ public abstract class JoglES1Driver extends JoglGL2ES1 implements GLDriver {
}
public void shutdown() {
- deactivate();
if(null != newtWin) {
newtWin.shutdown();
}
@@ -109,7 +109,7 @@ public abstract class JoglES1Driver extends JoglGL2ES1 implements GLDriver {
}
public void beginFrame(float camera_separation) {
- activate();
+ newtWin.activateGLContext();
}
public void endFrame() {
@@ -137,18 +137,12 @@ public abstract class JoglES1Driver extends JoglGL2ES1 implements GLDriver {
callback.execute();
}
- protected void activate() {
- final GLContext ctx = newtWin.window.getContext();
- if ( null != ctx && GLContext.getCurrent() != ctx ) {
- ctx.makeCurrent();
- }
+ protected final void activateGLContext() {
+ newtWin.activateGLContext();
}
-
- protected void deactivate() {
- final GLContext ctx = newtWin.window.getContext();
- if ( null != ctx && GLContext.getCurrent() == ctx) {
- ctx.release();
- }
+
+ protected final void deactivateGLContext() {
+ newtWin.activateGLContext();
}
// --------------------------------------------------------------------------
diff --git a/src/jake2/render/opengl/JoglES2Driver.java b/src/jake2/render/opengl/JoglES2Driver.java
index b6a0a62..f4b0519 100644
--- a/src/jake2/render/opengl/JoglES2Driver.java
+++ b/src/jake2/render/opengl/JoglES2Driver.java
@@ -25,6 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package jake2.render.opengl;
+import java.util.List;
+
import jake2.game.cvar_t;
import jake2.qcommon.Cvar;
import jake2.qcommon.xcommand_t;
@@ -57,14 +59,14 @@ public abstract class JoglES2Driver extends JoglGL2ES1 implements GLDriver {
protected static final ShaderSelectionMode shaderSelectionMode = ShaderSelectionMode.COLOR_TEXTURE2;
protected JoglES2Driver() {
- super(false);
+ super(true);
}
private NEWTWin newtWin = null;
public abstract String getName();
- public ScreenMode[] getModeList() {
+ public List<ScreenMode> getModeList() {
if(null == newtWin) {
throw new RuntimeException("NEWTWin not yet initialized.");
}
@@ -77,7 +79,6 @@ public abstract class JoglES2Driver extends JoglGL2ES1 implements GLDriver {
}
int res = newtWin.setMode(glp, dim, mode, fullscreen, getName());
if( Base.rserr_ok == res ) {
- activate();
setGL( FixedFuncUtil.wrapFixedFuncEmul(newtWin.window.getGL(), shaderSelectionMode, null, true, false) );
init(0, 0);
@@ -87,7 +88,6 @@ public abstract class JoglES2Driver extends JoglGL2ES1 implements GLDriver {
}
public void shutdown() {
- deactivate();
if(null != newtWin) {
newtWin.shutdown();
}
@@ -114,7 +114,7 @@ public abstract class JoglES2Driver extends JoglGL2ES1 implements GLDriver {
}
public void beginFrame(float camera_separation) {
- activate();
+ activateGLContext();
}
public void endFrame() {
@@ -141,20 +141,14 @@ public abstract class JoglES2Driver extends JoglGL2ES1 implements GLDriver {
public void updateScreen(xcommand_t callback) {
callback.execute();
}
-
- protected void activate() {
- final GLContext ctx = newtWin.window.getContext();
- if ( null != ctx && GLContext.getCurrent() != ctx ) {
- ctx.makeCurrent();
- }
- }
- protected void deactivate() {
- final GLContext ctx = newtWin.window.getContext();
- if ( null != ctx && GLContext.getCurrent() == ctx) {
- ctx.release();
- }
+ protected final void activateGLContext() {
+ newtWin.activateGLContext();
}
+ protected final void deactivateGLContext() {
+ newtWin.activateGLContext();
+ }
+
// --------------------------------------------------------------------------
}
diff --git a/src/jake2/render/opengl/JoglGL2Driver.java b/src/jake2/render/opengl/JoglGL2Driver.java
index c2ca450..6fa7af7 100644
--- a/src/jake2/render/opengl/JoglGL2Driver.java
+++ b/src/jake2/render/opengl/JoglGL2Driver.java
@@ -25,6 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package jake2.render.opengl;
+import java.util.List;
+
import jake2.game.cvar_t;
import jake2.qcommon.Cvar;
import jake2.qcommon.xcommand_t;
@@ -59,7 +61,7 @@ public abstract class JoglGL2Driver extends JoglGL2ES1 implements GLDriver {
public abstract String getName();
- public ScreenMode[] getModeList() {
+ public List<ScreenMode> getModeList() {
if(null == newtWin) {
throw new RuntimeException("NEWTWin not yet initialized.");
}
@@ -82,7 +84,6 @@ public abstract class JoglGL2Driver extends JoglGL2ES1 implements GLDriver {
}
public void shutdown() {
- deactivate();
if(null != newtWin) {
newtWin.shutdown();
}
@@ -109,7 +110,7 @@ public abstract class JoglGL2Driver extends JoglGL2ES1 implements GLDriver {
}
public void beginFrame(float camera_separation) {
- activate();
+ activateGLContext();
}
public void endFrame() {
@@ -137,18 +138,12 @@ public abstract class JoglGL2Driver extends JoglGL2ES1 implements GLDriver {
callback.execute();
}
- protected void activate() {
- final GLContext ctx = newtWin.window.getContext();
- if ( null != ctx && GLContext.getCurrent() != ctx ) {
- ctx.makeCurrent();
- }
+ protected final void activateGLContext() {
+ newtWin.activateGLContext();
}
- protected void deactivate() {
- final GLContext ctx = newtWin.window.getContext();
- if ( null != ctx && GLContext.getCurrent() == ctx) {
- ctx.release();
- }
+ protected final void deactivateGLContext() {
+ newtWin.activateGLContext();
}
// --------------------------------------------------------------------------
diff --git a/src/jake2/render/opengl/JoglGL2ES1.java b/src/jake2/render/opengl/JoglGL2ES1.java
index e560bac..524fdaf 100644
--- a/src/jake2/render/opengl/JoglGL2ES1.java
+++ b/src/jake2/render/opengl/JoglGL2ES1.java
@@ -306,10 +306,6 @@ public class JoglGL2ES1 implements QGL {
gl.glPixelStorei(pname, param);
}
- public void glPointSize(float size) {
- gl.glPointSize(size);
- }
-
public void glPolygonMode(int face, int mode) {
if( GL_FRONT_AND_BACK != face || GL_FILL != mode ) { // if !default
System.err.println("IGNORED: glPolygonMode(0x"+Integer.toHexString(face)+", 0x"+Integer.toHexString(mode)+")");
@@ -408,6 +404,10 @@ public class JoglGL2ES1 implements QGL {
gl.glClientActiveTexture(texture);
}
+ public void glPointSize(float size) {
+ gl.glPointSize(size);
+ }
+
public void glPointParameterEXT(int pname, FloatBuffer pfParams) {
gl.glPointParameterfv(pname, pfParams);
}
diff --git a/src/jake2/render/opengl/NEWTWin.java b/src/jake2/render/opengl/NEWTWin.java
index d9164dd..fe62060 100644
--- a/src/jake2/render/opengl/NEWTWin.java
+++ b/src/jake2/render/opengl/NEWTWin.java
@@ -22,6 +22,7 @@ import javax.media.nativewindow.util.Dimension;
import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.nativewindow.util.SurfaceSize;
import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLContext;
import javax.media.opengl.GLProfile;
import jogamp.opengl.FPSCounterImpl;
@@ -43,16 +44,13 @@ public class NEWTWin {
volatile GLWindow window = null;
final FPSCounterImpl fpsCounter = new FPSCounterImpl();
- public ScreenMode[] getModeList() {
- final List<ScreenMode> sml = screen.getScreenModes();
- ScreenMode[] sma = new ScreenMode[sml.size()];
- sml.toArray(sma);
- return sma;
+ public List<ScreenMode> getModeList() {
+ return screen.getScreenModes();
}
public ScreenMode findDisplayMode(DimensionImmutable dim) {
final List<ScreenMode> sml = ScreenModeUtil.filterByResolution(screen.getScreenModes(), dim);
- if(null == sml || sml.size() == 0) {
+ if(sml.size() == 0) {
return oldDisplayMode;
}
return sml.get(0);
@@ -86,25 +84,13 @@ public class NEWTWin {
final Dimension newDim = new Dimension();
- VID.Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n");
+ VID.Printf(Defines.PRINT_ALL, "Initializing OpenGL display for profile "+glp+"\n");
- VID.Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":");
-
- /**
- if (Globals.appletMode && container == null) {
- container = (Container) Globals.applet;
- } */
-
- final boolean screenRemRef;
if(null == screen) {
screen = NewtFactory.createScreen(NewtFactory.createDisplay(null), 0);
screen.addReference(); // trigger native creation
- screenRemRef = true;
} else if( !screen.isNativeValid() ) {
screen.addReference(); // trigger native creation
- screenRemRef = true;
- } else {
- screenRemRef = false;
}
if (!VID.GetModeInfo(newDim, mode)) {
@@ -112,34 +98,27 @@ public class NEWTWin {
return Base.rserr_invalid_mode;
}
- VID.Printf(Defines.PRINT_ALL, " " + newDim.getWidth() + " " + newDim.getHeight() + '\n');
+ VID.Printf(Defines.PRINT_ALL, "...setting mode " + mode + ", " + newDim.getWidth() + " x " + newDim.getHeight() + ", fs " + fullscreen + ", driver " + driverName + "\n");
- if (!Globals.appletMode) {
- // destroy the existing window
- if (window != null) shutdown();
- }
+ // destroy the existing window, not screen
+ shutdownImpl(false);
- if(null == window) {
- final GLCapabilities caps = new GLCapabilities(glp);
- CapabilitiesChooser chooser = null; // default
- {
- final cvar_t v = Cvar.Get("jogl_rgb565", "0", 0);
- if( v.value != 0f ) {
- caps.setRedBits(5);
- caps.setGreenBits(6);
- caps.setBlueBits(5);
- chooser = new GenericGLCapabilitiesChooser(); // don't trust native GL-TK chooser
- }
- }
- window = GLWindow.create(screen, caps);
- window.setCapabilitiesChooser(chooser);
- window.setTitle("Jake2 ("+driverName+"-newt-"+glp.getName().toLowerCase()+")");
+ if(null != window) {
+ throw new InternalError("XXX");
}
-
- if (oldDisplayMode == null) {
- oldDisplayMode = window.getScreen().getCurrentScreenMode();
+ final GLCapabilities caps = new GLCapabilities(glp);
+ CapabilitiesChooser chooser = null; // default
+ {
+ final cvar_t v = Cvar.Get("jogl_rgb565", "0", 0);
+ if( v.value != 0f ) {
+ caps.setRedBits(5);
+ caps.setGreenBits(6);
+ caps.setBlueBits(5);
+ chooser = new GenericGLCapabilitiesChooser(); // don't trust native GL-TK chooser
+ }
}
-
+ window = GLWindow.create(screen, caps);
+ window.setCapabilitiesChooser(chooser);
window.addWindowListener(new WindowAdapter() {
public void windowDestroyNotify(WindowEvent e) {
if (!Globals.appletMode) {
@@ -148,55 +127,32 @@ public class NEWTWin {
}
public void windowResized(WindowEvent e) {
- int width = window.getWidth();
- int height = window.getHeight();
- final int mask = ~0x03;
- if ((width & 0x03) != 0) {
- width &= mask;
- width += 4;
- }
-
- Base.setVid(width, height);
- // let the sound and input subsystems know about the new window
- VID.NewWindow(width, height);
+ propagateNewSize();
}
});
+ window.setTitle("Jake2 ("+driverName+"-newt-"+glp.getName().toLowerCase()+")");
- if (Globals.appletMode) {
- // Destroy the previous display if there is one
- shutdown();
-
- // We don't support full-screen mode
- fullscreen = false;
+ if (oldDisplayMode == null) {
+ oldDisplayMode = window.getScreen().getCurrentScreenMode();
}
// We need to feed the NEWT Window to the NEWTKBD
NEWTKBD.Init(window);
- window.setSize(newDim.getWidth(), newDim.getHeight());
-
- // D I F F E R E N T J A K E 2 E V E N T P R O C E S S I N G
window.addWindowListener(NEWTKBD.listener);
window.addKeyListener(NEWTKBD.listener);
window.addMouseListener(NEWTKBD.listener);
if (fullscreen) {
- window.setFullscreen(true);
-
ScreenMode sm = findDisplayMode(newDim);
final DimensionImmutable smDim = sm.getMonitorMode().getSurfaceSize().getResolution();
newDim.setWidth( smDim.getWidth() );
newDim.setHeight( smDim.getHeight() );
window.getScreen().setCurrentScreenMode(sm);
window.setFullscreen(true);
- window.setVisible(true);
-
- VID.Printf(Defines.PRINT_ALL, "...setting fullscreen " + sm.toString() + '\n');
-
} else {
- if (!Globals.appletMode) {
- window.setVisible(true);
- } else {
+ window.setSize(newDim.getWidth(), newDim.getHeight());
+ if (Globals.appletMode) {
// Notify the size listener about the change
final SizeChangeListener listener = Globals.sizeChangeListener;
if (listener != null) {
@@ -204,6 +160,7 @@ public class NEWTWin {
}
}
}
+ window.setVisible(true);
if (!Globals.appletMode) {
while ( !window.isNativeValid()|| !window.isRealized() ) {
@@ -214,30 +171,67 @@ public class NEWTWin {
}
window.requestFocus();
window.display(); // force GL resource validation
-
+
VID.Printf(Defines.PRINT_ALL, "...reques GLCaps "+window.getRequestedCapabilities()+'\n');
VID.Printf(Defines.PRINT_ALL, "...chosen GLCaps "+window.getChosenGLCapabilities()+'\n');
-
- if(screenRemRef) {
- screen.removeReference();
- }
-
+ VID.Printf(Defines.PRINT_ALL, "...size "+window.getWidth()+" x "+window.getHeight()+'\n');
fpsCounter.setUpdateFPSFrames(isARM ? 60 : 4*60, System.err);
+ // propagateNewSize("init");
+ activateGLContext();
+
return Base.rserr_ok;
}
+
+ private void propagateNewSize() {
+ final int width = window.getWidth();
+ final int height = window.getHeight();
+ final int _width;
+ final int mask = ~0x03;
+ if ((width & 0x03) != 0) {
+ _width = ( width & mask ) + 4;
+ } else {
+ _width = width;
+ }
+ VID.Printf(Defines.PRINT_ALL, "Resize: " + width + " x " + height + ", masked " + _width + "x" + height + "\n");
+ Base.setVid(_width, height);
+ // let the sound and input subsystems know about the new window
+ VID.NewWindow(_width, height);
+ }
+
+ protected final void activateGLContext() {
+ final GLContext ctx = window.getContext();
+ if ( null != ctx && GLContext.getCurrent() != ctx ) {
+ ctx.makeCurrent();
+ }
+ }
+
+ protected final void deactivateGLContext() {
+ final GLContext ctx = window.getContext();
+ if ( null != ctx && GLContext.getCurrent() == ctx) {
+ ctx.release();
+ }
+ }
+
void shutdown() {
- if (!Globals.appletMode) {
- if ( null != window ) {
+ shutdownImpl(true);
+ }
+
+ private void shutdownImpl(boolean withScreen) {
+ if ( null != window ) {
+ deactivateGLContext();
+ if (!Globals.appletMode) {
window.destroy();
- }
- } else {
- if ( null != window ) {
+ } else {
window.destroy(); // same thing
}
+ window = null;
+ }
+ if( withScreen && null != screen ) {
+ screen.destroy();
+ screen = null;
}
- window = null;
}
}