use of jake2.qcommon.qfiles in project narchy by automenta.
the class NEWTWin method setMode.
/**
* @param dim
* @param mode
* @param fullscreen
* @param driverName
* @return enum Base.rserr_t
*/
public int setMode(GLProfile glp, Dimension dim, int mode, boolean fullscreen, String driverName) {
final Dimension newDim = new Dimension();
VID.Printf(Defines.PRINT_ALL, "Initializing OpenGL display for profile " + glp + '\n');
if (null == screen) {
screen = NewtFactory.createScreen(NewtFactory.createDisplay(null), 0);
// trigger native creation
screen.addReference();
} else if (!screen.isNativeValid()) {
// trigger native creation
screen.addReference();
}
if (!VID.GetModeInfo(newDim, mode)) {
VID.Printf(Defines.PRINT_ALL, " invalid mode\n");
return Base.rserr_invalid_mode;
}
VID.Printf(Defines.PRINT_ALL, "...setting mode " + mode + ", " + newDim.getWidth() + " x " + newDim.getHeight() + ", fs " + fullscreen + ", driver " + driverName + '\n');
// destroy the existing window, not screen
shutdownImpl(false);
if (null != window) {
throw new InternalError("XXX");
}
final GLCapabilities caps = new GLCapabilities(glp);
// default
CapabilitiesChooser chooser = null;
final cvar_t v = Cvar.Get("jogl_rgb565", "0", 0);
if (v.value != 0f) {
caps.setRedBits(5);
caps.setGreenBits(6);
caps.setBlueBits(5);
// don't trust native GL-TK chooser
chooser = new GenericGLCapabilitiesChooser();
}
window = GLWindow.create(screen, caps);
window.setAutoSwapBufferMode(false);
// we do handle QUIT on our own, no GLWindow.display() called.
window.setDefaultCloseOperation(WindowClosingProtocol.WindowClosingMode.DO_NOTHING_ON_CLOSE);
window.setCapabilitiesChooser(chooser);
window.addWindowListener(new WindowAdapter() {
@Override
public void windowDestroyNotify(WindowEvent e) {
// not applet and not already in shutdown ?
shouldQuit = null != window;
}
@Override
public void windowResized(WindowEvent e) {
propagateNewSize();
}
});
window.setTitle("Jake2 (" + driverName + "-newt-" + glp.getName().toLowerCase() + ')');
animCtrl = new GameAnimatorControl();
window.setAnimator(animCtrl);
final MonitorDevice mainMonitor = window.getMainMonitor();
if (oldDisplayMode == null) {
oldDisplayMode = mainMonitor.getCurrentMode();
}
// We need to feed the NEWT Window to the NEWTKBD
NEWTKBD.Init(window);
window.addWindowListener(NEWTKBD.listener);
window.addKeyListener(NEWTKBD.listener);
window.addMouseListener(NEWTKBD.listener);
window.setSize(newDim.getWidth(), newDim.getHeight());
// no display() invocation on other thread!
isAnimating = true;
// if( !fullscreen && Globals.appletMode ) {
// forceReleaseCtx = FORCE_RELEASE_CTX_VAL;
//
// // Notify the size listener about the change
// final SizeChangeListener listener = Globals.sizeChangeListener;
// if (listener != null) {
// listener.sizeChanged(newDim.getWidth(), newDim.getHeight());
// }
// window.addKeyListener( new ReparentKeyListener() );
//
// final NativeSurface NativeSurface = NewtFactory.createWindow(window);
// final java.applet.Applet applet = (java.applet.Applet) Globals.applet;
// final Runnable appletAddAction = () -> {
// applet.add(NativeSurface, java.awt.BorderLayout.CENTER);
// applet.validate();
// NativeSurface.setFocusable(true);
// NativeSurface.requestFocus();
// if( Platform.OSType.MACOS == Platform.getOSType() && NativeSurface.isOffscreenLayerSurfaceEnabled() ) {
// System.err.println("XXX Relayout");
// // force relayout
// final int cW = NativeSurface.getWidth();
// final int cH = NativeSurface.getHeight();
// NativeSurface.setSize(cW+1, cH+1);
// NativeSurface.setSize(cW, cH);
// }
// };
// if( java.awt.EventQueue.isDispatchThread() ) {
// System.err.println("XXX Adding on AWT EDT - same thread");
// appletAddAction.run();
// } else {
// System.err.println("XXX Adding on AWT EDT - off thread");
// try {
// java.awt.EventQueue.invokeAndWait(appletAddAction);
// } catch (Exception e) {
// throw new RuntimeException("NEWT Exception during NativeSurface on AWT-EDT", e);
// }
// }
// canvasObj = NativeSurface;
// int w=0;
// while ( w<10 && !window.isNativeValid()|| !window.isRealized() ) {
// w++;
// try {
// Thread.sleep(100);
// } catch (InterruptedException e) {}
// }
// System.err.println("XXX waited = "+w+" * 100 ms");
// } else {
forceReleaseCtx = false;
canvasObj = null;
if (fullscreen) {
MonitorMode mm = findDisplayMode(newDim);
final DimensionImmutable smDim = mm.getSurfaceSize().getResolution();
newDim.setWidth(smDim.getWidth());
newDim.setHeight(smDim.getHeight());
mainMonitor.setCurrentMode(mm);
VID.Printf(Defines.PRINT_ALL, "...MonitorMode " + mm + '\n');
window.setFullscreen(true);
}
window.setVisible(true);
window.requestFocus();
if (!window.isNativeValid() || !window.isRealized()) {
throw new RuntimeException("NEWT window didn't not realize: " + window);
}
// force GL creation
window.display();
final GLContext ctx = window.getContext();
if (!ctx.isCreated()) {
System.err.println("Warning: GL context not created: " + ctx);
}
if (ctx.isCurrent()) {
throw new RuntimeException("NEWT GL context still current: " + ctx);
}
VID.Printf(Defines.PRINT_ALL, "...reques GLCaps " + window.getRequestedCapabilities() + '\n');
VID.Printf(Defines.PRINT_ALL, "...chosen GLCaps " + window.getChosenGLCapabilities() + '\n');
VID.Printf(Defines.PRINT_ALL, "...size " + window.getWidth() + " x " + window.getHeight() + '\n');
// propagateNewSize("init");
activateGLContext(true);
return Base.rserr_ok;
}
use of jake2.qcommon.qfiles in project narchy by automenta.
the class Qcommon method Init.
/**
* This function initializes the different subsystems of
* the game engine. The setjmp/longjmp mechanism of the original
* was replaced with exceptions.
* @param args the original unmodified command line arguments
*/
public static void Init(String[] args) {
try {
// prepare enough of the subsystems to handle
// cvar and command buffer management
Com.InitArgv(args);
Cbuf.Init();
Cmd.Init();
Cvar.Init();
Key.Init();
// we need to add the early commands twice, because
// a basedir or cddir needs to be set before execing
// config files, but we want other parms to override
// the settings of the config files
Cbuf.AddEarlyCommands(false);
Cbuf.Execute();
if (Globals.dedicated.value != 1.0f) {
Jake2.q2DataTool.setStatus("initializing filesystem...");
}
FS.InitFilesystem();
if (Globals.dedicated.value != 1.0f) {
Jake2.q2DataTool.setStatus("loading config...");
}
reconfigure(false);
// use cddir from config.cfg
FS.setCDDir();
// mark the default search paths
FS.markBaseSearchPaths();
if (Globals.dedicated.value != 1.0f) {
// test for valid baseq2
Jake2.q2DataTool.testQ2Data();
}
// reload default.cfg and config.cfg
reconfigure(true);
//
// init commands and vars
//
Cmd.AddCommand("error", Com.Error_f);
Globals.host_speeds = Cvar.Get("host_speeds", "0", 0);
Globals.log_stats = Cvar.Get("log_stats", "0", 0);
Globals.developer = Cvar.Get("developer", "0", CVAR_ARCHIVE);
Globals.timescale = Cvar.Get("timescale", "0", 0);
Globals.fixedtime = Cvar.Get("fixedtime", "0", 0);
Globals.logfile_active = Cvar.Get("logfile", "0", 0);
Globals.showtrace = Cvar.Get("showtrace", "0", 0);
Globals.dedicated = Cvar.Get("dedicated", "0", CVAR_NOSET);
String s = Com.sprintf("%4.2f %s %s %s", new Vargs(4).add(Globals.VERSION).add(CPUSTRING).add(Globals.__DATE__).add(BUILDSTRING));
Cvar.Get("version", s, CVAR_SERVERINFO | CVAR_NOSET);
if (Globals.dedicated.value != 1.0f) {
Jake2.q2DataTool.setStatus("initializing network subsystem...");
}
// ok
NET.Init();
// ok
Netchan.Netchan_Init();
if (Globals.dedicated.value != 1.0f) {
Jake2.q2DataTool.setStatus("initializing server subsystem...");
}
// ok
SV_MAIN.SV_Init();
if (Globals.dedicated.value != 1.0f) {
Jake2.q2DataTool.setStatus("initializing client subsystem...");
}
CL.Init();
// add + commands from command line
if (!Cbuf.AddLateCommands()) {
// if the user didn't give any commands, run default action
if (Globals.dedicated.value == 0)
Cbuf.AddText("d1\n");
else
Cbuf.AddText("dedicated_start\n");
Cbuf.Execute();
} else {
// the user asked for something explicit
// so drop the loading plaque
SCR.EndLoadingPlaque();
}
Com.Printf("====== Quake2 Initialized ======\n\n");
// save config when configuration is completed
CL.WriteConfiguration();
if (Globals.dedicated.value != 1.0f) {
Jake2.q2DataTool.dispose();
}
} catch (longjmpException e) {
Sys.Error("Error during initialization");
}
}
use of jake2.qcommon.qfiles in project narchy by automenta.
the class JOALSoundImpl method Init.
/* (non-Javadoc)
* @see jake2.sound.SoundImpl#Init()
*/
@Override
public boolean Init() {
try {
alc = ALFactory.getALC();
alcDevice = alc.alcOpenDevice(null);
alcContext = alc.alcCreateContext(alcDevice, null);
alc.alcMakeContextCurrent(alcContext);
al = ALFactory.getAL();
checkError();
initOpenALExtensions();
} catch (ALException e) {
Com.Printf(e.getMessage() + '\n');
return false;
} catch (Throwable e) {
Com.Printf(e.toString() + '\n');
return false;
}
// set the master volume
s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE);
al.alGenBuffers(buffers.length, buffers, 0);
int count = Channel.init(al, buffers);
Com.Printf("... using " + count + " channels\n");
al.alDistanceModel(AL.AL_INVERSE_DISTANCE_CLAMPED);
Cmd.AddCommand("play", new xcommand_t() {
@Override
public void execute() {
Play();
}
});
Cmd.AddCommand("stopsound", new xcommand_t() {
@Override
public void execute() {
StopAllSounds();
}
});
Cmd.AddCommand("soundlist", new xcommand_t() {
@Override
public void execute() {
SoundList();
}
});
Cmd.AddCommand("soundinfo", new xcommand_t() {
@Override
public void execute() {
SoundInfo_f();
}
});
num_sfx = 0;
Com.Println("sound sampling rate: 44100Hz");
StopAllSounds();
Com.Println("------------------------------------");
return true;
}
Aggregations