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 6798105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:41:24+00:00 2026-05-26T18:41:24+00:00

I am having more trouble with rendering 3d objects in java, heres my new

  • 0

I am having more trouble with rendering 3d objects in java, heres my new problem I have managed to import the needed libraries (gluPerspective, etc.) however when I run my java application in the eclipse environment, it opens a window, then the window stays black. Here is my code:

    package test;

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

    public class Obj3d {
        public static void main(String[] args) {
            Obj3d obj = new Obj3d();
            obj.start();
        }

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

            init3dGL();

            while(!Display.isCloseRequested()) {
                clear();
                renderCube();
                Display.update();
            }

            Display.destroy();
            System.exit(0);
        }

        public void init3dGL() {
            GL11.glMatrixMode(GL11.GL_PROJECTION);
            GL11.glLoadIdentity();
            GLU.gluPerspective(45, 2, -1, 100);
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glEnable(GL11.GL_DEPTH_TEST);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
            return;
        }

        public void renderCube() {
            GL11.glBegin(GL11.GL_QUADS);
                //front faces
                GL11.glNormal3d(0, 0, 1);
                GL11.glColor3d(0.0, 1.0, 1.0);
                GL11.glVertex3d(5, 5, -5);
                GL11.glVertex3d(-5, 5, -5);
                GL11.glVertex3d(-5, -5, -5);
                GL11.glVertex3d(5, -5, -5);
            GL11.glEnd();
            return;
        }

        public void clear() {
            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        }

    }

I can’t see my error in the above coding, however I am new to lwjgl 3d programming, so this may be due to my lack of experience. Please be patient, although I am a fast learner. Thanks in advance.

  • 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-05-26T18:41:25+00:00Added an answer on May 26, 2026 at 6:41 pm

    Using a negative near distance is not such a good idea, I think. Try

    GLU.gluPerpective(45, 2, 0.1, 100);
    

    And this 2 in there should actually be your window’s aspect ratio (width / height), in your case 1.333 = 800 / 600.

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

Sidebar

Related Questions

I'm relatively new to MongoDB and having trouble with a more advanced upsert. I've
I am having trouble with Html.ActionLink when I have a route that takes more
I have an issue I'm having trouble :/ err404 page's 200OK header status problem,
new to python and I'm having trouble converting a script to a more effective
I have more of a .NET background, so I've been having some trouble coming
I'm having trouble with Timeouts which do not work reliably under JRuby (Linux). More
I am fairly new to C++, having much more C experience. I am writing
I am having trouble understanding the meaning and more importantly the concept of an
I'm having trouble wrapping my head around more advanced Rails query methods. In this
I'm just starting out with NHibernate and I'm having trouble with running more complex

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.