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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:13:56+00:00 2026-05-17T01:13:56+00:00

I’m new to OpenGL. I’m playing around with JOGL. I have a .obj model

  • 0

I’m new to OpenGL. I’m playing around with JOGL.

I have a .obj model that I’m drawing as polygons. It looks ok, except that most of it gets clipped. So I think that I need to increase the draw distance.

I’m not really sure how to do it. Here is my render code:

private void render(GLAutoDrawable drawable) {
        GL2 gl = drawable.getGL().getGL2();
        GLUgl2 glu = new GLUgl2();

        gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);

        gl.glMatrixMode(GL2.GL_MODELVIEW);
        gl.glLoadIdentity();

        // Position the camera
        glu.gluLookAt(cameraPos.x, cameraPos.y, cameraPos.z, cameraPos.x
                + cameraForward.x, cameraPos.y + cameraForward.y, cameraPos.z
                + cameraForward.z, cameraUp.x, cameraUp.y, cameraUp.z);

            // uncommenting out this line will make everything disappear.
        // glu.gluPerspective(2, 1, 10, 1000);

        // ****** Start of example code ******
        gl.glCallList(axes); // Show X, Y, Z axes

        gl.glCallList(secondLines);

        gl.glCallList(triangle);

        gazebo.render(gl);

                // ...

It’s possible that my problem is something else entirely. gazebo is of type ObjModel, a class that reads and represents .obj files. Here are its render and build draw list methods:

private int drawID = 0;

public ObjModel(String fn, GL2 gl) {

            // ...

    readFile(fn);

    drawID = buildDrawList(gl);
}

public void render(GL2 gl) {
    gl.glCallList(drawID);
}

private int buildDrawList(GL2 gl) {
    int result = gl.glGenLists(1);

    gl.glNewList(result, GL2.GL_COMPILE);
    gl.glPushMatrix();
    gl.glBegin(GL2.GL_POLYGON);

    for (Point3f vert : vertices) {
        gl.glVertex3f(vert.x, vert.y, vert.z);
    }

    gl.glEnd();
    gl.glPopMatrix();
    gl.glEndList();

    return result;
}

private void readFile(String filename) {
    try {
        BufferedReader input = new BufferedReader(new FileReader(fileName));
        try {
            String newLine = null;
            while ((newLine = input.readLine()) != null) {

                int indVn = newLine.indexOf("vn ");
                if (indVn != -1) {
                    readNormal(newLine);
                    continue;
                }

                int indV = newLine.indexOf("v ");
                if (indV != -1) {
                    readVertex(newLine);
                    continue;
                }

                int indF = newLine.indexOf("f ");
                if (indF != -1) {
                    readPolygon(newLine);
                    continue;
                }

                int indVt = newLine.indexOf("vt ");
                if (indVt != -1) {
                    readTexture(newLine);
                    continue;
                }
            }
        } finally {
            input.close();
        }
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

I can post screenshots if more information is needed.

Any advice? Thanks.

  • 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-17T01:13:57+00:00Added an answer on May 17, 2026 at 1:13 am

    It sounds like your model has vertices outside the clipping plane. There are a few solutions for this.

    1) scale down your model so that all vertices fit within the clip coordinates (use glScale())

    2) Use gluPerspective to set up a ‘camera’ which has a deeper clipping plane. Though you’ve tried this, I suspect your unwanted results are because you’re not modifying the projection matrix when using this call.
    Try:

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    gluPerspective( 60, 1, 0.1, 1000.0 );
    

    3) Use glFrustrum() to modify the clipping planes. This is similar to gluPerspective but provides greater flexibility at the expensive of some added complexity.

    FYI you can still use gluPerspective or glFrustrum when in modelview matrix mode, but keep in mind that the order with which you make those calls and other matrix transformation calls (eg. glScale, glTranslate, glRotate) is important.

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

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.