Java Code Examples for org.lwjgl.opengl.Display#setTitle()

The following examples show how to use org.lwjgl.opengl.Display#setTitle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LwJglRenderingEngine.java    From Gaalop with GNU Lesser General Public License v3.0 7 votes vote down vote up
/**
 * Starts the lwjgl engine and shows a window, where the point clouds are rendered
 */
public void startEngine() {
    int width = 800;
    int height = 600;
    
    try {
        Display.setDisplayMode(new DisplayMode(width, height));
        Display.setFullscreen(false);
        Display.setTitle("Gaalop Visualization Window");

        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(0);
    }
    
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    changeSize(width, height);
    GL11.glDisable(GL11.GL_LIGHTING);


    // init OpenGL
    GL11.glViewport(0, 0, width, height);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GLU.gluPerspective((float) 65.0, (float) width / (float) height, (float) 0.1, 100);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    
    
}
 
Example 2
Source File: GameRanking.java    From opsu with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void enter(GameContainer container, StateBasedGame game)
		throws SlickException {
	UI.enter();
	Display.setTitle(game.getTitle());
	if (!data.isGameplay()) {
		if (!MusicController.isTrackDimmed())
			MusicController.toggleTrackDimmed(0.5f);
		replayButton.setY(retryY);
		animationProgress.setTime(animationProgress.getDuration());
	} else {
		SoundController.playSound(SoundEffect.APPLAUSE);
		retryButton.resetHover();
		if (GameMod.AUTO.isActive()) {
			replayButton.setY(retryY);
			animationProgress.setTime(animationProgress.getDuration());
		} else {
			replayButton.setY(replayY);
			animationProgress.setTime(0);
		}
	}
	replayButton.resetHover();
	loadReplay();
}
 
Example 3
Source File: Window.java    From LowPolyWater with The Unlicense 6 votes vote down vote up
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();
	}
}
 
Example 4
Source File: DisplayManager.java    From OpenGL-Animation with The Unlicense 6 votes vote down vote up
public static void createDisplay() {
	try {
		Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
		ContextAttribs attribs = new ContextAttribs(3, 2).withProfileCore(true).withForwardCompatible(true);
		Display.create(new PixelFormat().withDepthBits(24).withSamples(4), attribs);
		Display.setTitle(TITLE);
		Display.setInitialBackground(1, 1, 1);
		GL11.glEnable(GL13.GL_MULTISAMPLE);
	} catch (LWJGLException e) {
		e.printStackTrace();
		System.err.println("Couldn't create display!");
		System.exit(-1);
	}
	GL11.glViewport(0, 0, WIDTH, HEIGHT);
	lastFrameTime = getCurrentTime();
}
 
Example 5
Source File: OpenGL3_TheQuadTextured.java    From ldparteditor with MIT License 6 votes vote down vote up
private void setupOpenGL() {
    // Setup an OpenGL context with API version 3.2
    try {
        PixelFormat pixelFormat = new PixelFormat();
        ContextAttribs contextAtrributes = new ContextAttribs(3, 2)
            .withForwardCompatible(true)
            .withProfileCore(true);
         
        Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
        Display.setTitle(WINDOW_TITLE);
        Display.create(pixelFormat, contextAtrributes);
         
        GL11.glViewport(0, 0, WIDTH, HEIGHT);
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(-1);
    }
     
    // Setup an XNA like background color
    GL11.glClearColor(0.4f, 0.6f, 0.9f, 0f);
     
    // Map the internal OpenGL coordinate system to the entire screen
    GL11.glViewport(0, 0, WIDTH, HEIGHT);
     
    this.exitOnGLError("setupOpenGL");
}
 
Example 6
Source File: TwlTest.java    From tablelayout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main (String[] args) throws Exception {
	System.setProperty("org.lwjgl.librarypath", new File("lib/natives").getAbsolutePath());
	Display.setTitle("TWL Examples");
	Display.setDisplayMode(new DisplayMode(800, 600));
	Display.setVSyncEnabled(true);
	Display.create();
	new TwlTest();
}
 
Example 7
Source File: Game.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Loads all required data from a beatmap.
 * @param beatmap the beatmap to load
 */
public void loadBeatmap(Beatmap beatmap) {
	this.beatmap = beatmap;
	Display.setTitle(String.format("%s - %s", game.getTitle(), beatmap.toString()));
	if (beatmap.timingPoints == null)
		BeatmapDB.load(beatmap, BeatmapDB.LOAD_ARRAY);
	BeatmapParser.parseHitObjects(beatmap);
	HitSound.setDefaultSampleSet(beatmap.sampleSet);

	Utils.gc(true);
}
 
Example 8
Source File: DisplayManager.java    From OpenGL-Tutorial-1 with The Unlicense 5 votes vote down vote up
/**
 * Creates a display window on which we can render our game. The dimensions
 * of the window are determined by setting the display mode. By using
 * "glViewport" we tell OpenGL which part of the window we want to render
 * our game onto. We indicated that we want to use the entire window.
 */
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(TITLE);
	} catch (LWJGLException e) {
		e.printStackTrace();
	}
	GL11.glViewport(0, 0, WIDTH, HEIGHT);
}
 
Example 9
Source File: DisplayContainer.java    From opsu-dance with GNU General Public License v3.0 5 votes vote down vote up
public void setup() throws Exception {
	width = height = width2 = height2 = -1;
	Display.setTitle(Constants.PROJECT_NAME);
	setupResolutionOptionlist(nativeDisplayMode.getWidth(), nativeDisplayMode.getHeight());
	updateDisplayMode(OPTION_SCREEN_RESOLUTION.getValueString());
	Display.create();
	GLHelper.setIcons(new String[] { "icon16.png", "icon32.png" });
	postInitGL();
	GLHelper.hideNativeCursor();
}
 
Example 10
Source File: Window.java    From 3DGameEngine with Apache License 2.0 5 votes vote down vote up
public static void CreateWindow(int width, int height, String title)
{
	Display.setTitle(title);
	try 
	{
		Display.setDisplayMode(new DisplayMode(width, height));
		Display.create();
		Keyboard.create();
		Mouse.create();
	} 
	catch (LWJGLException e) 
	{
		e.printStackTrace();
	}
}
 
Example 11
Source File: LwjglGraphicsModule.java    From tprogers2048game with GNU General Public License v3.0 5 votes vote down vote up
private void initOpengl() {
      try {
          /* Задаём размер будущего окна */
          Display.setDisplayMode(new DisplayMode(Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT));

          /* Задаём имя будущего окна */
          Display.setTitle(Constants.SCREEN_NAME);

          /* Создаём окно */
          Display.create();
      } catch (LWJGLException e) {
          ErrorCatcher.graphicsFailure(e);
      }

      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glOrtho(0, Constants.SCREEN_WIDTH,0, Constants.SCREEN_HEIGHT,1,-1);
      glMatrixMode(GL_MODELVIEW);

/* Для поддержки текстур */
      glEnable(GL_TEXTURE_2D);

/* Для поддержки прозрачности */
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

/* Белый фоновый цвет */
      glClearColor(1,1,1,1);
  }
 
Example 12
Source File: Game.java    From FEMultiplayer with GNU General Public License v3.0 5 votes vote down vote up
public void init(int width, int height, String name) {
	time = System.nanoTime();
	
	windowWidth = width*scaleX;
	windowHeight = height*scaleY;

	try {
		Display.setDisplayMode(new DisplayMode(windowWidth, windowHeight));
		Display.create();
		Display.setTitle(name);
		Keyboard.create();
		Keyboard.enableRepeatEvents(true);
		Mouse.create();
		glContextExists = true;
	} catch (LWJGLException e) {
		e.printStackTrace();
		System.exit(0);
	}
	
	//init OpenGL
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	glEnable(GL_ALPHA_TEST);
	glAlphaFunc(GL_GREATER, 0.01f);
	glEnable(GL_TEXTURE_2D);
	glShadeModel(GL_SMOOTH);
	glClearDepth(1.0f);
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glViewport(0, 0, windowWidth, windowHeight);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0, windowWidth/scaleX, windowHeight/scaleY, 0, 1, -1);		//It's basically a camera
	glMatrixMode(GL_MODELVIEW);
	
	keys = new ArrayList<KeyboardEvent>();
	mouseEvents = new ArrayList<MouseEvent>();
}
 
Example 13
Source File: ModelViewer.java    From OpenRS with GNU General Public License v3.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
	if (args.length < 1) {
		System.err.println("Usage: modelfile");
		System.exit(1);
	}

	ModelList list = new ModelList();
	try (Cache cache = new Cache(FileStore.open(Constants.CACHE_PATH))) {
		list.initialize(cache);
	}

	Model md = list.list(Integer.valueOf(args[0]));

	Display.setDisplayMode(new DisplayMode(800, 600));
	Display.setTitle("Model Viewer");
	Display.setInitialBackground((float) Color.gray.getRed() / 255f, (float) Color.gray.getGreen() / 255f,
			(float) Color.gray.getBlue() / 255f);
	Display.create();

	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glLoadIdentity();
	double aspect = 1;
	double near = 1; // near should be chosen as far into the scene as
						// possible
	double far = 1000;
	double fov = 1; // 1 gives you a 90� field of view. It's
					// tan(fov_angle)/2.
	GL11.glFrustum(-aspect * near * fov, aspect * near * fov, -fov, fov, near, far);

	GL11.glCullFace(GL11.GL_BACK);

	long last = 0;

	while (!Display.isCloseRequested()) {
		// Clear the screen and depth buffer
		GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

		GL11.glBegin(GL11.GL_TRIANGLES);

		for (int i = 0; i < md.faceCount; ++i) {
			int vertexA = md.triangleX[i];
			int vertexB = md.triangleY[i];
			int vertexC = md.triangleZ[i];

			int vertexAx = md.vertexX[vertexA];
			int vertexAy = md.vertexY[vertexA];
			int vertexAz = md.vertexZ[vertexA];

			int vertexBx = md.vertexX[vertexB];
			int vertexBy = md.vertexY[vertexB];
			int vertexBz = md.vertexZ[vertexB];

			int vertexCx = md.vertexX[vertexC];
			int vertexCy = md.vertexY[vertexC];
			int vertexCz = md.vertexZ[vertexC];

			short hsb = md.faceColor[i];

			int rgb = hsbToRGB(hsb);
			Color c = new Color(rgb);

			// convert to range of 0-1
			float rf = (float) c.getRed() / 255f;
			float gf = (float) c.getGreen() / 255f;
			float bf = (float) c.getBlue() / 255f;

			GL11.glColor3f(rf, gf, bf);

			GL11.glVertex3i(vertexAx, vertexAy, vertexAz - 50);
			GL11.glVertex3i(vertexBx, vertexBy, vertexBz - 50);
			GL11.glVertex3i(vertexCx, vertexCy, vertexCz - 50);
		}

		GL11.glEnd();

		Display.update();
		Display.sync(50); // fps

		long delta = System.currentTimeMillis() - last;
		last = System.currentTimeMillis();

		Camera.create();
		Camera.acceptInput(delta);

		Camera.apply();
	}

	Display.destroy();
}
 
Example 14
Source File: SlytherClient.java    From Slyther with MIT License 4 votes vote down vote up
@Override
public void run() {
    double delta = 0;
    long previousTime = System.nanoTime();
    long timer = System.currentTimeMillis();
    int ups = 0;
    double nanoUpdates = 1000000000.0 / 30.0;

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F);
    GL11.glClearDepth(1);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    setupDisplay();

    boolean doResize = false;

    while (!Display.isCloseRequested()) {
        if (Display.wasResized() && doResize) {
            setupDisplay();
        }
        doResize = true;

        long currentTime = System.nanoTime();
        double currentTickDelta = (currentTime - previousTime) / nanoUpdates;
        delta += currentTickDelta;
        frameDelta = (frameDelta + currentTickDelta) % 1.0;
        previousTime = currentTime;

        while (delta >= 1) {
            update();
            renderHandler.update();
            delta--;
            ups++;
        }

        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
        GL11.glPushMatrix();

        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

        renderHandler.render();

        fps++;

        if (System.currentTimeMillis() - timer > 1000) {
            int bytesPerSecond = 0;
            int packetsPerSecond = 0;
            if (networkManager != null) {
                bytesPerSecond = networkManager.bytesPerSecond;
                packetsPerSecond = networkManager.packetsPerSecond;
                networkManager.bytesPerSecond = 0;
                networkManager.packetsPerSecond = 0;
            }
            Display.setTitle("Slyther - FPS: " + fps + " - UPS: " + ups + " - BPS: " + bytesPerSecond + " - PPS: " + packetsPerSecond);
            fps = 0;

            timer += 1000;
            ups = 0;
        }

        GL11.glPopMatrix();
        Display.sync(60);
        Display.update();
    }
    if (networkManager != null && networkManager.isOpen()) {
        networkManager.closeConnection(ClientNetworkManager.SHUTDOWN_CODE, "");
    }
    try {
        ConfigHandler.INSTANCE.saveConfig(CONFIGURATION_FILE, configuration);
    } catch (IOException e) {
        Log.error("Failed to save config");
        Log.catching(e);
    }
    Display.destroy();
}
 
Example 15
Source File: Game.java    From FEMultiPlayer-V2 with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Inits the.
 *
 * @param width the width
 * @param height the height
 * @param name the name
 */
public void init(int width, int height, String name) {
	Game.logicalWidth = width;
	Game.logicalHeight = height;
	Game.scale = FEResources.getWindowScale();
	final int windowWidth = Math.round(logicalWidth * scale);
	final int windowHeight = Math.round(logicalHeight * scale);

	try {
		Display.setDisplayMode(new DisplayMode(windowWidth, windowHeight));
		Display.create();
		Display.setTitle(name);
		Keyboard.create();
		Keyboard.enableRepeatEvents(true);
		Mouse.create();
		glContextExists = true;
	} catch (LWJGLException e) {
		e.printStackTrace();
		System.exit(0);
	}
	
	//init OpenGL
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	glEnable(GL_ALPHA_TEST);
	glAlphaFunc(GL_GREATER, 0.01f);
	glEnable(GL_TEXTURE_2D);
	glShadeModel(GL_SMOOTH);
	glClearDepth(1.0f);
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glViewport(0, 0, windowWidth, windowHeight);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0, width, height, 0, 1, -1);		//It's basically a camera
	glMatrixMode(GL_MODELVIEW);
	
	keys = new ArrayList<KeyboardEvent>();
	mouseEvents = new ArrayList<MouseEvent>();
}
 
Example 16
Source File: Seppuku.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
/**
 * The initialization point of the client
 * this is called post launch
 */
public void init() {
    this.initLogger();
    this.eventManager = new AnnotatedEventManager();
    this.apiManager = new APIManager();
    this.configManager = new ConfigManager();
    this.ignoredManager = new IgnoredManager();
    this.friendManager = new FriendManager();
    this.rotationManager = new RotationManager();
    this.macroManager = new MacroManager();
    this.waypointManager = new WaypointManager();
    this.tickRateManager = new TickRateManager();
    this.chatManager = new ChatManager();
    this.worldManager = new WorldManager();
    this.capeManager = new CapeManager();
    this.positionManager = new PositionManager();
    this.joinLeaveManager = new JoinLeaveManager();
    this.animationManager = new AnimationManager();
    this.notificationManager = new NotificationManager();
    this.moduleManager = new ModuleManager();
    this.commandManager = new CommandManager();
    this.cameraManager = new CameraManager();
    this.hudManager = new HudManager();
    //this.seppukuMainMenu = new GuiSeppukuMainMenu();

    this.configManager.init(); // Keep last, so we load configs after everything else inits

    this.prevTitle = Display.getTitle();
    Display.setTitle("Seppuku 1.12.2");

    this.getEventManager().dispatchEvent(new EventLoad());

    // Add runtime hook to listen for shutdown to save configs
    Runtime.getRuntime().addShutdownHook(new Thread("Seppuku Shutdown Hook") {
        @Override
        public void run() {
            getConfigManager().saveAll();
        }
    });

    this.logger.info("Seppuku Loaded Successfully");
}
 
Example 17
Source File: MixinMinecraft.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@Inject(method = "createDisplay", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V", shift = At.Shift.AFTER))
private void createDisplay(CallbackInfo callbackInfo) {
    Display.setTitle(LiquidBounce.CLIENT_NAME + " b" + LiquidBounce.CLIENT_VERSION + " | " + LiquidBounce.MINECRAFT_VERSION + (LiquidBounce.IN_DEV ? " | DEVELOPMENT BUILD" : ""));
}
 
Example 18
Source File: MixinMinecraft.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@Inject(method = "createDisplay", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V", shift = At.Shift.AFTER))
private void createDisplay(CallbackInfo callbackInfo) {
    Display.setTitle(LiquidBounce.CLIENT_NAME + " b" + LiquidBounce.CLIENT_VERSION + " | " + LiquidBounce.MINECRAFT_VERSION + (LiquidBounce.IN_DEV ? " | DEVELOPMENT BUILD" : ""));
}
 
Example 19
Source File: LwjglDisplay.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setTitle(String title){
    if (created.get())
        Display.setTitle(title);
}
 
Example 20
Source File: AppGameContainer.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Set the title of the window
 * 
 * @param title The title to set on the window
 */
public void setTitle(String title) {
	Display.setTitle(title);
}