Artur Ryszka
Artur Ryszka

Reputation: 33

Issue with LWJGL displayMode()

I get an error with

setDisplayMode

It says that "The method Display.setDisplayMode(new DisplayMode[], String[]) in the type Display is not applicable for the arguments (Display Mode)" and it suggests to "Rename in file".

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.Display;


public class GameLoop 
{
    //Main
        public static void main(String[] argv)
        {
            GameLoop.start();
        }

        //Metodo che gestisce il loop
        public static void start() 
        {
            //Inizializzazione OpenGL
            GL11.glMatrixMode(GL11.GL_PROJECTION);
            GL11.glLoadIdentity();
            GL11.glOrtho(0, 800, 600, 0, 1, -1);
            GL11.glMatrixMode(GL11.GL_MODELVIEW);

            try 
            {
                Display.setDisplayMode(new DisplayMode(800, 600));
                Display.create();
            } catch (LWJGLException e) 
            {
                e.printStackTrace();
                System.exit(0);
            }

            while(!Display.isCloseRequested())
            {
                Entità.pulisci();
                Entità.colora();
                Entità.disegna();
                Display.update();
            }
        }

}




import org.lwjgl.opengl.GL11;

public class Entità 
{
    //Disegna un poligono
        public static void disegna()
        {
            GL11.glBegin(GL11.GL_QUADS);
            GL11.glVertex2f(100,100);
            GL11.glVertex2f(200,100);
            GL11.glVertex2f(200,200);
            GL11.glVertex2f(100,200);
            GL11.glEnd();
        }

        //Pulisce il buffer
        public static void pulisci()
        {
            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); 
        }

        //Setta il colore al poligono
        public static void colora()
        {
            GL11.glColor3f(0.5f,0.5f,1.0f);
        }

}

Upvotes: 0

Views: 994

Answers (1)

haffax
haffax

Reputation: 6008

The problem is in the line:

import org.lwjgl.util.Display;

You import the wrong Display class. Instead use:

import org.lwjgl.opengl.Display;

Upvotes: 1

Related Questions