Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8078537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:49:35+00:00 2026-06-05T15:49:35+00:00

I recevie 0 errors but I get this in the console: >Exception in thread

  • 0

I recevie 0 errors but I get this in the console:

>Exception in thread "main" java.lang.NullPointerException
  >>at org.lwjgl.opengl.GL11.glMatrixMode(GL11.java:2052)
  >>>at game.engine.GameLoop.start(GameLoop.java:22)
  >>>>at game.engine.GameLoop.main(GameLoop.java:15)  

I tried to put the actual value into “glMatrixMode()” instead of “GL11.GL_PROJECTION” but it returns same Exception.

   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);
            }

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:49:37+00:00Added an answer on June 5, 2026 at 3:49 pm

    I don’t have any experience with Java or LWJGL, but from looking at your code it seems

    Display.setDisplayMode(new DisplayMode(800, 600));
    Display.create();
    

    creates the actual display canvas (or however you may call it) which also sets up the OpenGL context. Thus calling any OpenGL function (like GL11.glMatrixMode) before those is likely to result in some error, as in your case a null pointer exception.

    So try to put those four functions after the display creation. You are making changes to the OpenGL context, thus you first need a valid context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am calling a function from the console but when it throws an exception
I'm having this annoyning problem giving this message in the console: Failed to launch
<?php require_once includes/db_data_inc.php; try { /* In this way I get a db connection
I'm trying to load latitude and longitude value using this code but I receive
I am trying to get RabbitMQ working with the Yii console in order to
How can I get this query to work where it goes through the checks
I'm making a Java console application that needs to send an HTTP request to
I am trying to remotely read a binary (REG_BINARY) registry value, but I get
I have static java methods which I add to javascript with this method: public
I've looked at several related posts but no luck with this error. I receive

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.