org.lwjgl.opengl.DisplayMode Java Examples

The following examples show how to use org.lwjgl.opengl.DisplayMode. 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: HyperiumMinecraft.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void fullScreenFix(boolean fullscreen, int displayWidth, int displayHeight) throws LWJGLException {
    if (Settings.WINDOWED_FULLSCREEN) {
        if (fullscreen) {
            System.setProperty("org.lwjgl.opengl.Window.undecorated", "true");
            Display.setDisplayMode(Display.getDesktopDisplayMode());
            Display.setLocation(0, 0);
            Display.setFullscreen(false);
        } else {
            System.setProperty("org.lwjgl.opengl.Window.undecorated", "false");
            Display.setDisplayMode(new DisplayMode(displayWidth, displayHeight));
        }
    } else {
        Display.setFullscreen(fullscreen);
        System.setProperty("org.lwjgl.opengl.Window.undecorated", "false");
    }

    Display.setResizable(false);
    Display.setResizable(true);
}
 
Example #3
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 #4
Source File: VideoHook.java    From malmo with MIT License 6 votes vote down vote up
/**
 * Resizes the window and the Minecraft rendering if necessary. Set renderWidth and renderHeight first.
 */
private void resizeIfNeeded()
{
    // resize the window if we need to
    int oldRenderWidth = Display.getWidth(); 
    int oldRenderHeight = Display.getHeight();
    if( this.renderWidth == oldRenderWidth && this.renderHeight == oldRenderHeight )
        return;
    
    try {
        int old_x = Display.getX();
        int old_y = Display.getY();
        Display.setLocation(old_x, old_y);
        Display.setDisplayMode(new DisplayMode(this.renderWidth, this.renderHeight));
        System.out.println("Resized the window");
    } catch (LWJGLException e) {
        System.out.println("Failed to resize the window!");
        e.printStackTrace();
    }
    forceResize(this.renderWidth, this.renderHeight);
}
 
Example #5
Source File: GLHelper.java    From opsu-dance with GNU General Public License v3.0 6 votes vote down vote up
/**
 * from org.newdawn.slick.AppGameContainer#setDisplayMode
 */
public static DisplayMode findFullscreenDisplayMode(int targetBPP, int targetFrequency, int width, int height) throws LWJGLException {
	DisplayMode[] modes = Display.getAvailableDisplayModes();
	DisplayMode foundMode = null;
	int freq = 0;
	int bpp = 0;

	for (DisplayMode current : modes) {
		if (current.getWidth() != width || current.getHeight() != height) {
			continue;
		}

		if (current.getBitsPerPixel() == targetBPP && current.getFrequency() == targetFrequency) {
			return current;
		}

		if (current.getFrequency() >= freq && (foundMode == null || current.getBitsPerPixel() >= bpp)) {
			foundMode = current;
			freq = foundMode.getFrequency();
			bpp = foundMode.getBitsPerPixel();
		}
	}
	return foundMode;
}
 
Example #6
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 #7
Source File: LwjglDisplay.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected DisplayMode getFullscreenDisplayMode(int width, int height, int bpp, int freq){
    try {
        DisplayMode[] modes = Display.getAvailableDisplayModes();
        for (DisplayMode mode : modes){
            if (mode.getWidth() == width
             && mode.getHeight() == height
             && (mode.getBitsPerPixel() == bpp || (bpp==24&&mode.getBitsPerPixel()==32))
             && mode.getFrequency() == freq){
                return mode;
            }
        }
    } catch (LWJGLException ex) {
        listener.handleError("Failed to acquire fullscreen display mode!", ex);
    }
    return null;
}
 
Example #8
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 #9
Source File: HyperiumMinecraft.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void displayFix(CallbackInfo ci, boolean fullscreen, int displayWidth, int displayHeight)
    throws LWJGLException {
    Display.setFullscreen(false);
    if (fullscreen) {
        if (Settings.WINDOWED_FULLSCREEN) {
            System.setProperty("org.lwjgl.opengl.Window.undecorated", "true");
        } else {
            Display.setFullscreen(true);
            DisplayMode displaymode = Display.getDisplayMode();
            parent.displayWidth = Math.max(1, displaymode.getWidth());
            parent.displayHeight = Math.max(1, displaymode.getHeight());
        }
    } else {
        if (Settings.WINDOWED_FULLSCREEN) {
            System.setProperty("org.lwjgl.opengl.Window.undecorated", "false");
        } else {
            Display.setDisplayMode(new DisplayMode(displayWidth, displayHeight));
        }
    }

    Display.setResizable(false);
    Display.setResizable(true);

    // effectively overwrites the method
    ci.cancel();
}
 
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: 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 #12
Source File: GLProgram.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Initializes a windowed application. The framerate is set to 60 and can be modified using <code>setFPS(int fps)</code>.
 * 
 * @param name The title of the window.
 * @param width The width of the window.
 * @param height The height of the window.
 * @param resizable Enables/disables the ability to resize the window.
 */
public GLProgram(String name, int width, int height, boolean resizable) {
	Display.setTitle(name);
	
	try {
		Display.setDisplayMode(new DisplayMode(width, height));
	} catch(Exception exc) {
		exc.printStackTrace();
	}
	
	Display.setResizable(resizable);
	
	fps = 60;
}
 
Example #13
Source File: Options.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/** Returns whether this resolution is possible to use in fullscreen mode. */
public boolean hasFullscreenDisplayMode() {
	try {
		for (DisplayMode mode : Display.getAvailableDisplayModes()) {
			if (width == mode.getWidth() && height == mode.getHeight())
				return true;
		}
	} catch (LWJGLException e) {
		ErrorHandler.error("Failed to get available display modes.", e, true);
	}
	return false;
}
 
Example #14
Source File: DisplayModeComparator.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final int compare(Object o1, Object o2) {
	DisplayMode d1 = (DisplayMode)o1;
	DisplayMode d2 = (DisplayMode)o2;

	/*
	 * Elias: sort after largest bpp first, then lowest freq
	 * to accomodate broken monitors lying about their
	 * capabilities
	 */
	int freq_dist1 = StrictMath.abs(d1.getFrequency() - target_mode.getFrequency());
	int freq_dist2 = StrictMath.abs(d2.getFrequency() - target_mode.getFrequency());
	int bpp_dist1 = StrictMath.abs(d1.getBitsPerPixel() - target_mode.getBitsPerPixel());
	int bpp_dist2 = StrictMath.abs(d2.getBitsPerPixel() - target_mode.getBitsPerPixel());
	if (getDistanceFromBestMode(d1) < getDistanceFromBestMode(d2))
		return -1;
	else if (getDistanceFromBestMode(d1) > getDistanceFromBestMode(d2))
		return 1;
	else if (bpp_dist1 < bpp_dist2)
		return -1;
	else if (bpp_dist1 > bpp_dist2)
		return 1;
	else if (freq_dist1 < freq_dist2)
		return -1;
	else if (freq_dist1 > freq_dist2)
		return 1;
	else
		return 0;
}
 
Example #15
Source File: TestUtils.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Initialise the GL display
 * 
 * @param width The width of the display
 * @param height The height of the display
 */
private void initGL(int width, int height) {
	try {
		Display.setDisplayMode(new DisplayMode(width,height));
		Display.create();
		Display.setVSyncEnabled(true);
	} catch (LWJGLException e) {
		e.printStackTrace();
		System.exit(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);
       
       GL11.glViewport(0,0,width,height);
	GL11.glMatrixMode(GL11.GL_MODELVIEW);

	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glLoadIdentity();
	GL11.glOrtho(0, width, height, 0, 1, -1);
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
 
Example #16
Source File: SerializableDisplayMode.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
private final static void doSetMode(SerializableDisplayMode target_mode) throws LWJGLException {
	DisplayMode[] lwjgl_modes = Display.getAvailableDisplayModes();
	for (int i = 0; i < lwjgl_modes.length; i++) {
		DisplayMode lwjgl_mode = lwjgl_modes[i];
		SerializableDisplayMode mode = new SerializableDisplayMode(lwjgl_mode);
		if (mode.equals(target_mode)) {
			nativeSetMode(lwjgl_mode);
			GL11.glViewport(0, 0, lwjgl_mode.getWidth(), lwjgl_mode.getHeight());
			return;
		}
	}
	throw new LWJGLException("Could not find mode matching: " + target_mode);
}
 
Example #17
Source File: SerializableDisplayMode.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
private final static void nativeSetMode(DisplayMode mode) throws LWJGLException {
		if (!Display.getDisplayMode().equals(mode)) {
System.out.println("setting mode = " + mode);
			Display.setDisplayMode(mode);
			Renderer.resetInput();
		}
	}
 
Example #18
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 #19
Source File: Window.java    From LowPolyWater with The Unlicense 5 votes vote down vote up
private DisplayMode getStartResolution(WindowBuilder settings) {
	if (settings.isFullScreen()) {
		DisplayMode fullScreenMode = getFullScreenDisplayMode(settings.getWidth(), settings.getHeight());
		if (fullScreenMode != null) {
			return fullScreenMode;
		}
		settings.fullScreen(false);
	}
	return new DisplayMode(settings.getWidth(), settings.getHeight());

}
 
Example #20
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 #21
Source File: Window.java    From LowPolyWater with The Unlicense 5 votes vote down vote up
public void setResolution(DisplayMode resolution, boolean fullscreen) {
	try {
		Display.setDisplayMode(resolution);
		this.resolution = resolution;
		if (fullscreen && resolution.isFullscreenCapable()) {
			Display.setFullscreen(true);
			this.fullScreen = fullscreen;
		}
	} catch (LWJGLException e) {
		e.printStackTrace();
	}
}
 
Example #22
Source File: Window.java    From LowPolyWater with The Unlicense 5 votes vote down vote up
private void getSuitableFullScreenModes() throws LWJGLException {
	DisplayMode[] resolutions = Display.getAvailableDisplayModes();
	DisplayMode desktopResolution = Display.getDesktopDisplayMode();
	for (DisplayMode resolution : resolutions) {
		if (isSuitableFullScreenResolution(resolution, desktopResolution)) {
			availableResolutions.add(resolution);
		}
	}
}
 
Example #23
Source File: Window.java    From LowPolyWater with The Unlicense 5 votes vote down vote up
private boolean isSuitableFullScreenResolution(DisplayMode resolution, DisplayMode desktopResolution) {
	if (resolution.getBitsPerPixel() == desktopResolution.getBitsPerPixel()) {
		if (resolution.getFrequency() == desktopResolution.getFrequency()) {
			float desktopAspect = (float) desktopResolution.getWidth() / desktopResolution.getHeight();
			float resAspect = (float) resolution.getWidth() / resolution.getHeight();
			float check = resAspect / desktopAspect;
			if (check > 0.95f && check < 1.05f) {
				return resolution.getHeight() > MIN_HEIGHT;
			}
		}
	}
	return false;
}
 
Example #24
Source File: Window.java    From LowPolyWater with The Unlicense 5 votes vote down vote up
private DisplayMode getFullScreenDisplayMode(int width, int height) {
	for (DisplayMode potentialMode : availableResolutions) {
		if (potentialMode.getWidth() == width && potentialMode.getHeight() == height) {
			return potentialMode;
		}
	}
	return null;
}
 
Example #25
Source File: Game.java    From FEMultiPlayer-V2 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Update window size for a new {@link FEResources#getWindowScale}
 */
public static void updateScale() {
	if (Game.scale != FEResources.getWindowScale()) {
		// This code will close the current window and open a new one,
		// even if the window's size doesn't change.
		// Hence the if; that will make the window reopen only happen when needed.
		
		Game.scale = FEResources.getWindowScale();
		final int physicalWidth = Math.round(logicalWidth * scale);
		final int physicalHeight = Math.round(logicalHeight * scale);
		
		try {
			org.lwjgl.opengl.Display.setDisplayMode(
				new org.lwjgl.opengl.DisplayMode(physicalWidth, physicalHeight)
			);
			
			org.lwjgl.opengl.GL11.glViewport(0, 0, physicalWidth, physicalHeight);
			
			org.lwjgl.opengl.GL11.glMatrixMode(org.lwjgl.opengl.GL11.GL_PROJECTION);
			org.lwjgl.opengl.GL11.glLoadIdentity();
			org.lwjgl.opengl.GL11.glOrtho(0, logicalWidth, logicalHeight, 0, 1, -1);		//It's basically a camera
			org.lwjgl.opengl.GL11.glMatrixMode(org.lwjgl.opengl.GL11.GL_MODELVIEW);
		} catch (org.lwjgl.LWJGLException e) {
			e.printStackTrace();
			// hope that live-changing the display mode isn't *that* important
		}
	}
}
 
Example #26
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 #27
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 #28
Source File: SerializableDisplayMode.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
public final static boolean isModeValid(DisplayMode mode) {
	return mode.getWidth() >= 800 && mode.getHeight() >= 600;
}
 
Example #29
Source File: DisplayModeComparator.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
private final int getDistanceFromBestMode(DisplayMode mode) {
	int dx = StrictMath.abs(target_mode.getWidth() - mode.getWidth());
	int dy = StrictMath.abs(target_mode.getHeight() - mode.getHeight());
	return dx + dy;
}
 
Example #30
Source File: SerializableDisplayMode.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
public SerializableDisplayMode(DisplayMode mode) {
	this(mode.getWidth(), mode.getHeight(), mode.getBitsPerPixel(), mode.getFrequency());
}