本文整理汇总了Java中org.lwjgl.LWJGLException类的典型用法代码示例。如果您正苦于以下问题:Java LWJGLException类的具体用法?Java LWJGLException怎么用?Java LWJGLException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LWJGLException类属于org.lwjgl包,在下文中一共展示了LWJGLException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.lwjgl.LWJGLException; //导入依赖的package包/类
/**
* Start the game container
*
* @throws Exception Failure to create display
*/
public void start() throws Exception {
Display.setParent(displayParent);
Display.setVSyncEnabled(true);
try {
createDisplay();
} catch (LWJGLException e) {
e.printStackTrace();
// failed to create Display, apply workaround (sleep for 1 second) and try again
Thread.sleep(1000);
createDisplay();
}
initGL();
displayParent.requestFocus();
container.runloop();
}
示例2: setFullscreen
import org.lwjgl.LWJGLException; //导入依赖的package包/类
/**
* Indicate whether we want to be in fullscreen mode. Note that the current
* display mode must be valid as a fullscreen mode for this to work
*
* @param fullscreen True if we want to be in fullscreen mode
* @throws SlickException Indicates we failed to change the display mode
*/
public void setFullscreen(boolean fullscreen) throws SlickException {
if (isFullscreen() == fullscreen) {
return;
}
if (!fullscreen) {
try {
Display.setFullscreen(fullscreen);
} catch (LWJGLException e) {
throw new SlickException("Unable to set fullscreen="+fullscreen, e);
}
} else {
setDisplayMode(width, height, fullscreen);
}
getDelta();
}
示例3: getCursor
import org.lwjgl.LWJGLException; //导入依赖的package包/类
/**
* 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);
}
}
示例4: disable
import org.lwjgl.LWJGLException; //导入依赖的package包/类
/**
* @see org.newdawn.slick.Graphics#disable()
*/
protected void disable() {
// Bind the texture after rendering.
GL11.glBindTexture(GL11.GL_TEXTURE_2D, image.getTexture().getTextureID());
GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 0, 0,
image.getTexture().getTextureWidth(),
image.getTexture().getTextureHeight(), 0);
try {
Display.makeCurrent();
} catch (LWJGLException e) {
Log.error(e);
}
SlickCallable.leaveSafeBlock();
}
示例5: createDisplay
import org.lwjgl.LWJGLException; //导入依赖的package包/类
public static void createDisplay() {
ContextAttribs attribs = new ContextAttribs(3, 2)
.withForwardCompatible(true)
.withProfileCore(true);
try {
Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
Display.create(new PixelFormat(), attribs);
Display.setTitle("MRCEngine");
} catch (LWJGLException e) {
e.printStackTrace();
}
GL11.glViewport(0, 0, WIDTH, HEIGHT);
lastFrameTime = getCurrentTime();
}
示例6: main
import org.lwjgl.LWJGLException; //导入依赖的package包/类
public static void main(String... args){
System.setProperty("org.lwjgl.librarypath", new File("native/"+(System.getProperties().getProperty("os.name").split(" ")[0]).toLowerCase()).getAbsolutePath());
FreeWorld.getFreeWorld();
try {
Display.setTitle(FreeWorld.getFreeWorld().getTitle());
Display.setDisplayMode(new DisplayMode(720, 480));
Display.setResizable(true);
Display.create();
}catch (LWJGLException e){
e.printStackTrace();
}
//TODO: Provisoire
glClearColor(0.2f, 0.7f, 0.7f, 1.0f);
FreeWorld.getFreeWorld().start();
}
示例7: Window
import org.lwjgl.LWJGLException; //导入依赖的package包/类
protected Window(Context context, WindowBuilder settings) {
this.fpsCap = settings.getFpsCap();
try {
getSuitableFullScreenModes();
DisplayMode resolution = getStartResolution(settings);
Display.setInitialBackground(1, 1, 1);
this.aspectRatio = (float) resolution.getWidth() / resolution.getHeight();
setResolution(resolution, settings.isFullScreen());
if (settings.hasIcon()) {
Display.setIcon(settings.getIcon());
}
Display.setVSyncEnabled(settings.isvSync());
Display.setTitle(settings.getTitle());
Display.create(new PixelFormat().withDepthBits(24).withSamples(4), context.getAttribs());
GL11.glViewport(0, 0, resolution.getWidth(), resolution.getHeight());
} catch (LWJGLException e) {
e.printStackTrace();
}
}
示例8: init
import org.lwjgl.LWJGLException; //导入依赖的package包/类
/**
* Initialise OpenAL LWJGL styley
*/
public void init() {
try {
AL.create();
soundWorks = true;
} catch (LWJGLException e) {
System.err.println("Failed to initialise LWJGL OpenAL");
soundWorks = false;
return;
}
if (soundWorks) {
IntBuffer sources = BufferUtils.createIntBuffer(1);
AL10.alGenSources(sources);
if (AL10.alGetError() != AL10.AL_NO_ERROR) {
System.err.println("Failed to create sources");
soundWorks = false;
} else {
source = sources.get(0);
}
}
}
示例9: createFrame
import org.lwjgl.LWJGLException; //导入依赖的package包/类
public static void createFrame(DefaultResourcePack mcDefaultResourcePack,
Logger logger) throws LWJGLException
{
// check if frame should be created
if(!isAutoMaximize() && !WurstBot.isEnabled())
return;
// create frame
frame = new JFrame("Minecraft " + WMinecraft.DISPLAY_VERSION);
// add LWJGL
Canvas canvas = new Canvas();
canvas.setBackground(new Color(16, 16, 16));
Display.setParent(canvas);
Minecraft mc = Minecraft.getMinecraft();
canvas.setSize(mc.displayWidth, mc.displayHeight);
frame.add(canvas);
// configure frame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
// add icons
InputStream icon16 = null;
InputStream icon32 = null;
try
{
icon16 = mcDefaultResourcePack.getInputStreamAssets(
new ResourceLocation("icons/icon_16x16.png"));
icon32 = mcDefaultResourcePack.getInputStreamAssets(
new ResourceLocation("icons/icon_32x32.png"));
ArrayList<BufferedImage> icons = new ArrayList<>();
icons.add(ImageIO.read(icon16));
icons.add(ImageIO.read(icon32));
frame.setIconImages(icons);
}catch(Exception e)
{
logger.error("Couldn't set icon", e);
}finally
{
IOUtils.closeQuietly(icon16);
IOUtils.closeQuietly(icon32);
}
// show frame
if(!WurstBot.isEnabled())
frame.setVisible(true);
}
示例10: BeginSession
import org.lwjgl.LWJGLException; //导入依赖的package包/类
public static void BeginSession(){
Display.setTitle(TITLE);
try {
Display.setDisplayMode(new DisplayMode(WIDTH + MENU_WIDTH, HEIGHT));
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
}
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, WIDTH + MENU_WIDTH, HEIGHT, 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
示例11: disable
import org.lwjgl.LWJGLException; //导入依赖的package包/类
/**
* @see org.newdawn.slick.Graphics#disable()
*/
protected void disable() {
GL.flush();
// Bind the texture after rendering.
GL.glBindTexture(GL11.GL_TEXTURE_2D, image.getTexture().getTextureID());
pbuffer.bindTexImage(Pbuffer.FRONT_LEFT_BUFFER);
try {
Display.makeCurrent();
} catch (LWJGLException e) {
Log.error(e);
}
SlickCallable.leaveSafeBlock();
}
示例12: getDisplayMode
import org.lwjgl.LWJGLException; //导入依赖的package包/类
public static DisplayMode getDisplayMode(Dimension p_getDisplayMode_0_) throws LWJGLException
{
DisplayMode[] adisplaymode = Display.getAvailableDisplayModes();
for (int i = 0; i < adisplaymode.length; ++i)
{
DisplayMode displaymode = adisplaymode[i];
if (displaymode.getWidth() == p_getDisplayMode_0_.width && displaymode.getHeight() == p_getDisplayMode_0_.height && (desktopDisplayMode == null || displaymode.getBitsPerPixel() == desktopDisplayMode.getBitsPerPixel() && displaymode.getFrequency() == desktopDisplayMode.getFrequency()))
{
return displaymode;
}
}
return desktopDisplayMode;
}
示例13: createDisplay
import org.lwjgl.LWJGLException; //导入依赖的package包/类
private void createDisplay() throws LWJGLException {
Display.setResizable(true);
Display.setTitle("Minecraft 1.8.8");
try {
Display.create((new PixelFormat()).withDepthBits(24));
} catch (LWJGLException lwjglexception) {
logger.error((String) "Couldn\'t set pixel format", (Throwable) lwjglexception);
try {
Thread.sleep(1000L);
} catch (InterruptedException var3) {
;
}
if (this.fullscreen) {
this.updateDisplayMode();
}
Display.create();
}
}
示例14: main
import org.lwjgl.LWJGLException; //导入依赖的package包/类
public static void main(String[] args) {
try {
Display.setDisplayMode(new DisplayMode(640, 480));
Display.setTitle("A Fresh New Display");
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
Display.destroy();
System.exit(1);
}
while (!Display.isCloseRequested()) {
// render code
// input handling code
// refresh display and poll input
Display.update();
// Maintain a 60fps frame rate
Display.sync(60);
}
Display.destroy();
System.exit(0);
}
示例15: createDisplay
import org.lwjgl.LWJGLException; //导入依赖的package包/类
public static void createDisplay() {
// OpenGL version used
ContextAttribs attribs = new ContextAttribs(3, 2)
.withForwardCompatible(true)
.withProfileCore(true);
try {
Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
Display.create(new PixelFormat(), attribs);
Display.setTitle(TITLE);
} catch (LWJGLException e) {
e.printStackTrace();
}
GL11.glViewport(0, 0, WIDTH, HEIGHT);
}