📄 displaysystem.java
字号:
* @param w
* the width/horizontal resolution of the display.
* @param h
* the height/vertical resolution of the display.
* @param bpp
* the color depth of the display.
*/
public abstract void createHeadlessWindow(int w, int h, int bpp);
/**
* <code>createCanvas</code> should create a canvas object with the
* desired settings. The width and height defined by w and h define the size
* of the canvas. Makes an AWT canvas by default.
*
* @param w
* the width/horizontal resolution of the display.
* @param h
* the height/vertical resolution of the display.
*/
public JMECanvas createCanvas(int w, int h) {
return createCanvas(w, h, "AWT", new HashMap<String, Object>());
}
/**
* <code>createCanvas</code> should create a canvas object with the desired
* settings. The width and height defined by w and h define the size of the
* canvas.
*
* @param w
* the width/horizontal resolution of the display.
* @param h
* the height/vertical resolution of the display.
* @param type
* the type of canvas to make. e.g. "AWT", "SWT".
* @param props
* the properties we want to use (if any) for constructing our
* canvas.
*/
public abstract JMECanvas createCanvas(int w, int h, String type, HashMap<String, Object> props);
public void registerCanvasConstructor(String type, Class<? extends CanvasConstructor> constructorClass) {
canvasConstructRegistry.put(type, constructorClass);
}
public CanvasConstructor makeCanvasConstructor(String type) {
Class<? extends CanvasConstructor> constructorClass = canvasConstructRegistry.get(type);
if (constructorClass == null) {
throw new JmeException("Unregistered canvas type: "+type);
}
CanvasConstructor constructor;
try {
constructor = constructorClass.newInstance();
} catch (Exception e) {
throw new JmeException("Unable to instantiate canvas constructor: "+constructorClass);
}
return constructor;
}
/**
* <code>recreateWindow</code> recreates a window with the desired
* settings.
*
* @param w
* the width/horizontal resolution of the display.
* @param h
* the height/vertical resolution of the display.
* @param bpp
* the color depth of the display.
* @param frq
* the frequency of refresh of the display.
* @param fs
* flag determining if fullscreen is to be used or not. True will
* use fullscreen, false will use windowed mode.
*/
public abstract void recreateWindow(int w, int h, int bpp, int frq,
boolean fs);
/**
* <code>getRenderer</code> returns the <code>Renderer</code>
* implementation that is compatible with the chosen
* <code>DisplaySystem</code>. For example, if
* <code>LWJGLDisplaySystem</code> is used, the returned
* <code>Renderer</code> will be</code> LWJGLRenderer</code>.
*
* @return the appropriate <code>Renderer</code> implementation that is
* compatible with the used <code>DisplaySystem</code>.
* @see com.jme.renderer.Renderer
*/
public abstract Renderer getRenderer();
/**
* <code>setRenderer</code> sets the <code>Renderer</code> object that
* is to be used by this display. The implementing class should take
* measures to insure that the given Renderer is compatible with the
* Display.
*
* @param r
* the Renderer to set for this display.
*/
public abstract void setRenderer(Renderer r);
/**
* <code>isCreated</code> returns the current status of the display
* system. If the window and renderer are created, true is returned,
* otherwise false.
*
* @return whether the display system is created.
*/
public boolean isCreated() {
return created;
}
/**
* <code>isActive</code> returns true if the display is active.
*
* @return whether the display system is active.
*/
public abstract boolean isActive();
/**
* <code>isClosing</code> notifies if the window is currently closing.
* This could be caused via the application itself or external interrupts
* such as alt-f4 etc.
*
* @return true if the window is closing, false otherwise.
*/
public abstract boolean isClosing();
/**
* <code>reset</code> cleans up the display system for closing or
* restarting.
*/
public abstract void reset();
/**
* <code>close</code> shutdowns and destroys any window contexts.
*/
public abstract void close();
/**
* Returns the minimum bits per pixel in the alpha buffer.
*
* @return the int value of alphaBits.
*/
public int getMinAlphaBits() {
return alphaBits;
}
/**
* Sets the minimum bits per pixel in the alpha buffer.
*
* @param alphaBits -
* the new value for alphaBits
*/
public void setMinAlphaBits(int alphaBits) {
this.alphaBits = alphaBits;
}
/**
* Returns the minimum bits per pixel in the depth buffer.
*
* @return the int value of depthBits.
*/
public int getMinDepthBits() {
return depthBits;
}
/**
* Sets the minimum bits per pixel in the depth buffer.
*
* @param depthBits -
* the new value for depthBits
*/
public void setMinDepthBits(int depthBits) {
this.depthBits = depthBits;
}
/**
* Returns the minimum bits per pixel in the stencil buffer.
*
* @return the int value of stencilBits.
*/
public int getMinStencilBits() {
return stencilBits;
}
/**
* Sets the minimum bits per pixel in the stencil buffer.
*
* @param stencilBits -
* the new value for stencilBits
*/
public void setMinStencilBits(int stencilBits) {
this.stencilBits = stencilBits;
}
/**
* Returns the minimum samples in multisample buffer.
*
* @return the int value of samples.
*/
public int getMinSamples() {
return samples;
}
/**
* Sets the minimum samples in the multisample buffer.
*
* @param samples -
* the new value for samples
*/
public void setMinSamples(int samples) {
this.samples = samples;
}
/**
* Returns the brightness last requested by this display.
*
* @return brightness - should be between -1 and 1.
*/
public float getBrightness() {
return brightness;
}
/**
* Note: This affects the whole screen, not just the game window.
*
* @param brightness
* The brightness to set (set -1 to 1) default is 0
*/
public void setBrightness(float brightness) {
this.brightness = brightness;
updateDisplayBGC();
}
/**
* @return Returns the contrast.
*/
public float getContrast() {
return contrast;
}
/**
* Note: This affects the whole screen, not just the game window.
*
* @param contrast
* The contrast to set (set greater than 0) default is 1
*/
public void setContrast(float contrast) {
this.contrast = contrast;
updateDisplayBGC();
}
/**
* @return Returns the gamma.
*/
public float getGamma() {
return gamma;
}
/**
* Note: This affects the whole screen, not just the game window.
*
* @param gamma
* The gamma to set (default is 1)
*/
public void setGamma(float gamma) {
this.gamma = gamma;
updateDisplayBGC();
}
/**
* Sets all three in one call. <p/> Note: This affects the whole screen, not
* just the game window.
*
* @param brightness
* @param gamma
* @param contrast
*/
public void setBrightnessGammaContrast(float brightness, float gamma,
float contrast) {
this.brightness = brightness;
this.gamma = gamma;
this.contrast = contrast;
updateDisplayBGC();
}
/**
* Called when the display system is created, this function sets the default
* render states for the renderer. It should not be called directly by the
* user.
*
* @param r
* The renderer to get the default states from.
*/
public static void updateStates(Renderer r) {
for (RenderState.StateType type : RenderState.StateType.values()) {
Renderer.defaultStateList[type.ordinal()] = r.createState(type);
Renderer.defaultStateList[type.ordinal()].setEnabled(false);
}
}
/**
* Create a TextureRenderer using the underlying system.
*
* @param width
* width of texture
* @param height
* height of texture
* @param target
* @return A TextureRenderer for the display system.
*/
public abstract TextureRenderer createTextureRenderer(int width,
int height, TextureRenderer.Target target);
/**
* Translate world to screen coordinates
*
* @param worldPosition
* Vector3f representing the world position to retrieve.
* @return the screen position.
*/
public Vector3f getScreenCoordinates(Vector3f worldPosition) {
return getScreenCoordinates(worldPosition, null);
}
/**
* Translate world to screen coordinates
*
* @param worldPosition
* Vector3f representing the world position to retrieve.
* @param store
* Vector3f to store the world position in.
* @return Vector3f The store vector3f, after storing.
*/
public Vector3f getScreenCoordinates(Vector3f worldPosition, Vector3f store) {
return getRenderer().getCamera().getScreenCoordinates(worldPosition,
store);
}
/**
* Translate screen to world coordinates.
*
* @param screenPosition
* Vector2f representing the screen position with 0,0 at the
* bottom left.
* @param zPos
* The z position away from the viewing plane, between 0 and 1.
* @return A Vector3f representing the vector's world position.
*/
public Vector3f getWorldCoordinates(Vector2f screenPosition, float zPos) {
return getWorldCoordinates(screenPosition, zPos, null);
}
/**
* Translate screen to world coordinates.
*
* @param screenPosition
* Vector2f representing the screen position with 0,0 at the
* bottom left
* @param zPos
* float The z position away from the viewing plane.
* @param store
* Vector3f The vector to store the result in.
* @return Vector3f The store vector, after storing it's result.
*/
public Vector3f getWorldCoordinates(Vector2f screenPosition, float zPos,
Vector3f store) {
return getRenderer().getCamera().getWorldCoordinates(screenPosition,
zPos, store);
}
/**
* Generate a pick ray from a 2d screen point. The screen point is assumed
* to have origin at the lower left, but when using awt mouse clicks, you'll
* want to set flipVertical to true since that system has an origin at the
* upper right. The Ray will be in world coordinates and the direction will
* be normalized.
*
* @param screenPosition
* Vector2f representing the screen position with 0,0 at the
* bottom left
* @param flipVertical
* Whether or not to flip the y coordinate of the screen position
* across the middle of the screen.
* @param store
* The ray to store the result in. If null, a new Ray is created.
* @return the ray
*/
public Ray getPickRay(Vector2f screenPosition, boolean flipVertical,
Ray store) {
if (flipVertical) {
screenPosition.y = getRenderer().getHeight() - screenPosition.y;
}
if (store == null) store = new Ray();
getWorldCoordinates(screenPosition, 0,
store.origin);
getWorldCoordinates(screenPosition, 0.3f,
store.direction).subtractLocal(store.origin)
.normalizeLocal();
return store;
}
/**
* Update the display's gamma, brightness and contrast based on the set
* values.
*/
protected abstract void updateDisplayBGC();
/**
* Sets one or more icons for the DisplaySystem.
* <p>
* As a reference for usual platforms on number of icons and their sizes:
* <ul>
* <li>On Windows you should supply at least one 16x16 image and one 32x32.</li>
* <li>Linux (and similar platforms) expect one 32x32 image.</li>
* <li>Mac OS X should be supplied one 128x128 image.</li>
* </ul>
* </p>
* <p>
* Images should be in format RGBA8888. If they are not jME will try to convert them
* using ImageUtils. If that fails a <code>JmeException</code> could be thrown.
* </p>
*
* @param iconImages
* Array of Images to be used as icons.
* @author Tony Vera
* @author Tijl Houtbeckers - some changes to handling non-RGBA8888 Images.
*
*/
public abstract void setIcon(Image[] iconImages);
/**
* @return a RenderContext object representing the current OpenGL context.
*/
public abstract RenderContext<?> getCurrentContext();
public static synchronized void resetSystemProvider() {
if (system != null) {
system.disposeDisplaySystem();
system = null;
}
}
/**
* If running in windowed mode, move the window's position to the given
* display coordinates.
*
* @param locX
* @param locY
*/
public abstract void moveWindowTo(int locX, int locY);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -