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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:58:10+00:00 2026-06-15T09:58:10+00:00

I’m trying to draw a simple triangle and I’ve faced a problem combining glEnable(GL_DEPTH_TEST)

  • 0

I’m trying to draw a simple triangle and I’ve faced a problem combining glEnable(GL_DEPTH_TEST) and glOrtho. The triangle is displayed without depth test not depending on the nearVal argument but if the depth test is enabled and the nearVal is different from 0 then nothing is displayed. Here is the code.

@Override
public void init(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();

    gl.glShadeModel(GL2.GL_SMOOTH);
    gl.glEnable(GL2.GL_DEPTH_TEST);
    gl.glDepthFunc(GL2.GL_LEQUAL);
    gl.glClearColor(0, 0, 0, 1);
    gl.glClearDepth(100.0);

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

    // the nearVal = 1 and the triangle is not displayed
    // if we set the nearVal = 1 then the triangle is displayed
    gl.glOrtho(-1, 1, -1, 1, 1, 10); 
}

@Override
public void display(GLAutoDrawable drawable) {      
    GL2 gl = drawable.getGL().getGL2();

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

    gl.glBegin(GL.GL_TRIANGLES);        
    gl.glColor3f(1, 0, 0);
    gl.glVertex3f(0.0f, 0.0f, 0);       
    gl.glColor3f(0, 1, 0);
    gl.glVertex3f(1, 0.0f, 0);      
    gl.glColor3f(0, 0, 1);
    gl.glVertex3f(0f, 1f, 0);       
    gl.glEnd();

    gl.glFlush();
}
  • 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-15T09:58:10+00:00Added an answer on June 15, 2026 at 9:58 am

    Your glVertex3f calls define a triangle on the z=0 plane. If you set the nearPlane parameter of the glOrtho call to one, then your triangle will be clipped out.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am currently running into a problem where an element is coming back from
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a

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.