Java 类org.lwjgl.input.Cursor 实例源码
项目:trashjam2017
文件:AppletGameContainer.java
/**
* {@inheritDoc}
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:trashjam2017
文件:AppGameContainer.java
/**
* @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.Image, int, int)
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),image.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:trashjam2017
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param buf The image data (stored in RGBA) to load the cursor from
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @param width The width of the image data provided
* @param height The height of the image data provided
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ByteBuffer buf,int x,int y,int width,int height) throws IOException, LWJGLException {
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = height - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(width,height, x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:trashjam2017
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param imageData The data from which the cursor can read it's contents
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ImageData imageData,int x,int y) throws IOException, LWJGLException {
ByteBuffer buf = imageData.getImageBufferData();
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = imageData.getHeight() - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(imageData.getTexWidth(), imageData.getTexHeight(), x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:Progetto-C
文件:AppletGameContainer.java
/**
* {@inheritDoc}
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:Progetto-C
文件:AppGameContainer.java
/**
* @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.Image, int, int)
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),image.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:Progetto-C
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param buf The image data (stored in RGBA) to load the cursor from
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @param width The width of the image data provided
* @param height The height of the image data provided
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ByteBuffer buf,int x,int y,int width,int height) throws IOException, LWJGLException {
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = height - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(width,height, x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:Progetto-C
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param imageData The data from which the cursor can read it's contents
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ImageData imageData,int x,int y) throws IOException, LWJGLException {
ByteBuffer buf = imageData.getImageBufferData();
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = imageData.getHeight() - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(imageData.getTexWidth(), imageData.getTexHeight(), x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:BaseClient
文件:AppletGameContainer.java
/**
* {@inheritDoc}
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:BaseClient
文件:AppGameContainer.java
/**
* @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.Image, int, int)
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),image.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:BaseClient
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param buf The image data (stored in RGBA) to load the cursor from
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @param width The width of the image data provided
* @param height The height of the image data provided
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ByteBuffer buf,int x,int y,int width,int height) throws IOException, LWJGLException {
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = height - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(width,height, x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:BaseClient
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param imageData The data from which the cursor can read it's contents
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ImageData imageData,int x,int y) throws IOException, LWJGLException {
ByteBuffer buf = imageData.getImageBufferData();
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = imageData.getHeight() - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(imageData.getTexWidth(), imageData.getTexHeight(), x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:code404
文件:AppletGameContainer.java
/**
* {@inheritDoc}
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Exception e) {
Log.error("Failed to load and apply cursor.", e);
}
}
项目:code404
文件:AppGameContainer.java
/**
* @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.Image, int, int)
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),image.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Exception e) {
Log.error("Failed to load and apply cursor.", e);
}
}
项目:code404
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param buf The image data (stored in RGBA) to load the cursor from
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @param width The width of the image data provided
* @param height The height of the image data provided
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ByteBuffer buf,int x,int y,int width,int height) throws IOException, LWJGLException {
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = height - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(width,height, x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:code404
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param imageData The data from which the cursor can read it's contents
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ImageData imageData,int x,int y) throws IOException, LWJGLException {
ByteBuffer buf = imageData.getImageBufferData();
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = imageData.getHeight() - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(imageData.getTexWidth(), imageData.getTexHeight(), x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:seventh
文件:SeventhGame.java
@Override
public void create() {
ClientMain.logSystemSpecs(console);
ClientMain.logVideoSpecs(console);
Art.load();
Sounds.init(config);
this.uiManager = new UserInterfaceManager();
seventh.client.gfx.Cursor cursor = this.uiManager.getCursor();
float sensitivity = config.getMouseSensitivity();
if(sensitivity > 0) {
cursor.setMouseSensitivity(sensitivity);
}
Gdx.input.setInputProcessor(this.inputs);
// Gdx.input.setCursorCatched(true);
initControllers();
videoReload();
this.menuScreen = new MenuScreen(this);
goToMenuScreen();
}
项目:GPVM
文件:AppletGameContainer.java
/**
* {@inheritDoc}
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:GPVM
文件:AppGameContainer.java
/**
* @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.Image, int, int)
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),image.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:GPVM
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param buf The image data (stored in RGBA) to load the cursor from
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @param width The width of the image data provided
* @param height The height of the image data provided
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ByteBuffer buf,int x,int y,int width,int height) throws IOException, LWJGLException {
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = height - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(width,height, x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:GPVM
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param imageData The data from which the cursor can read it's contents
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ImageData imageData,int x,int y) throws IOException, LWJGLException {
ByteBuffer buf = imageData.getImageBufferData();
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = imageData.getHeight() - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(imageData.getTexWidth(), imageData.getTexHeight(), x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:GPVM
文件:AppletGameContainer.java
/**
* {@inheritDoc}
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:GPVM
文件:AppGameContainer.java
/**
* @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.Image, int, int)
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),image.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:GPVM
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param buf The image data (stored in RGBA) to load the cursor from
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @param width The width of the image data provided
* @param height The height of the image data provided
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ByteBuffer buf,int x,int y,int width,int height) throws IOException, LWJGLException {
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = height - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(width,height, x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:GPVM
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param imageData The data from which the cursor can read it's contents
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ImageData imageData,int x,int y) throws IOException, LWJGLException {
ByteBuffer buf = imageData.getImageBufferData();
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = imageData.getHeight() - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(imageData.getTexWidth(), imageData.getTexHeight(), x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:SpaceStationAlpha
文件:AppletGameContainer.java
/**
* {@inheritDoc}
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:SpaceStationAlpha
文件:AppGameContainer.java
/**
* @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.Image, int, int)
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),image.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:SpaceStationAlpha
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param buf The image data (stored in RGBA) to load the cursor from
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @param width The width of the image data provided
* @param height The height of the image data provided
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ByteBuffer buf,int x,int y,int width,int height) throws IOException, LWJGLException {
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = height - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(width,height, x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:SpaceStationAlpha
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param imageData The data from which the cursor can read it's contents
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ImageData imageData,int x,int y) throws IOException, LWJGLException {
ByteBuffer buf = imageData.getImageBufferData();
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = imageData.getHeight() - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(imageData.getTexWidth(), imageData.getTexHeight(), x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:cretion
文件:AppletGameContainer.java
/**
* {@inheritDoc}
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:cretion
文件:AppGameContainer.java
/**
* @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.Image, int, int)
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),image.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:cretion
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param buf The image data (stored in RGBA) to load the cursor from
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @param width The width of the image data provided
* @param height The height of the image data provided
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ByteBuffer buf,int x,int y,int width,int height) throws IOException, LWJGLException {
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = height - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(width,height, x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:cretion
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param imageData The data from which the cursor can read it's contents
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ImageData imageData,int x,int y) throws IOException, LWJGLException {
ByteBuffer buf = imageData.getImageBufferData();
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = imageData.getHeight() - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(imageData.getTexWidth(), imageData.getTexHeight(), x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:slick2d-maven
文件:AppletGameContainer.java
/**
* {@inheritDoc}
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:slick2d-maven
文件:AppGameContainer.java
/**
* @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.Image, int, int)
*/
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
try {
Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
Graphics g = temp.getGraphics();
ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
g.drawImage(image.getFlippedCopy(false, true), 0, 0);
g.flush();
g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:slick2d-maven
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param buf The image data (stored in RGBA) to load the cursor from
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @param width The width of the image data provided
* @param height The height of the image data provided
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ByteBuffer buf,int x,int y,int width,int height) throws IOException, LWJGLException {
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = height - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(width,height, x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:slick2d-maven
文件:CursorLoader.java
/**
* Get a cursor based on a set of image data
*
* @param imageData The data from which the cursor can read it's contents
* @param x The x-coordinate of the cursor hotspot (left -> right)
* @param y The y-coordinate of the cursor hotspot (bottom -> top)
* @return The create cursor
* @throws IOException Indicates a failure to load the image
* @throws LWJGLException Indicates a failure to create the hardware cursor
*/
public Cursor getCursor(ImageData imageData,int x,int y) throws IOException, LWJGLException {
ByteBuffer buf = imageData.getImageBufferData();
for (int i=0;i<buf.limit();i+=4) {
byte red = buf.get(i);
byte green = buf.get(i+1);
byte blue = buf.get(i+2);
byte alpha = buf.get(i+3);
buf.put(i+2, red);
buf.put(i+1, green);
buf.put(i, blue);
buf.put(i+3, alpha);
}
try {
int yspot = imageData.getHeight() - y - 1;
if (yspot < 0) {
yspot = 0;
}
return new Cursor(imageData.getTexWidth(), imageData.getTexHeight(), x, yspot, 1, buf.asIntBuffer(), null);
} catch (Throwable e) {
Log.info("Chances are you cursor is too small for this platform");
throw new LWJGLException(e);
}
}
项目:trashjam2017
文件:AppletGameContainer.java
/**
* @see org.newdawn.slick.GameContainer#setMouseCursor(java.lang.String,
* int, int)
*/
public void setMouseCursor(String ref, int hotSpotX, int hotSpotY) throws SlickException {
try {
Cursor cursor = CursorLoader.get().getCursor(ref, hotSpotX, hotSpotY);
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:trashjam2017
文件:AppletGameContainer.java
/**
* @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.opengl.ImageData, int, int)
*/
public void setMouseCursor(ImageData data, int hotSpotX, int hotSpotY) throws SlickException {
try {
Cursor cursor = CursorLoader.get().getCursor(data, hotSpotX, hotSpotY);
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}
项目:trashjam2017
文件:AppletGameContainer.java
/**
* @see org.newdawn.slick.GameContainer#setMouseCursor(org.lwjgl.input.Cursor, int, int)
*/
public void setMouseCursor(Cursor cursor, int hotSpotX, int hotSpotY) throws SlickException {
try {
Mouse.setNativeCursor(cursor);
} catch (Throwable e) {
Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
}
}