Java Code Examples for org.lwjgl.opengl.Display#setInitialBackground()
The following examples show how to use
org.lwjgl.opengl.Display#setInitialBackground() .
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: Window.java From LowPolyWater with The Unlicense | 6 votes |
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 2
Source File: DisplayManager.java From OpenGL-Animation with The Unlicense | 6 votes |
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 3
Source File: ModelViewer.java From OpenRS with GNU General Public License v3.0 | 4 votes |
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(); }