當前位置: 首頁>>代碼示例>>Java>>正文


Java LWJGLException類代碼示例

本文整理匯總了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();
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:23,代碼來源:AppletGameContainer.java

示例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();
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:24,代碼來源:AppGameContainer.java

示例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);
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:37,代碼來源:CursorLoader.java

示例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();
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:19,代碼來源:PBufferUniqueGraphics.java

示例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();
	
}
 
開發者ID:marcioz98,項目名稱:MRCEngine,代碼行數:19,代碼來源:DisplayManager.java

示例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();
}
 
開發者ID:Vinetos,項目名稱:FreeWorld,代碼行數:20,代碼來源:FreeWorld.java

示例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();
	}
}
 
開發者ID:TheThinMatrix,項目名稱:LowPolyWater,代碼行數:20,代碼來源:Window.java

示例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);
	}
	
}
  }
 
開發者ID:imaTowan,項目名稱:Towan,代碼行數:27,代碼來源:OpenALMODPlayer.java

示例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);
}
 
開發者ID:Wurst-Imperium,項目名稱:Wurst-MC-1.12,代碼行數:50,代碼來源:FrameHook.java

示例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);
}
 
開發者ID:imaTowan,項目名稱:Towan,代碼行數:18,代碼來源:Artist.java

示例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();
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:19,代碼來源:PBufferGraphics.java

示例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;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:17,代碼來源:Config.java

示例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();
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:23,代碼來源:Minecraft.java

示例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);
}
 
開發者ID:nitrodragon,項目名稱:lwjgl_collection,代碼行數:23,代碼來源:Display2.java

示例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);
}
 
開發者ID:DevipriyaSarkar,項目名稱:Terrain,代碼行數:17,代碼來源:DisplayManager.java


注:本文中的org.lwjgl.LWJGLException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。