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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:52:00+00:00 2026-06-15T06:52:00+00:00

I have this code: https://github.com/magicgoose/lwjgl-nifty-test-project When I render only GUI, it works like expected.

  • 0

I have this code: https://github.com/magicgoose/lwjgl-nifty-test-project
When I render only GUI, it works like expected. When I try to render triangle (in perspective projection) and then render GUI, everything fails, and even GUI don’t render correctly – i get only letters on black background. (it happens if I uncomment
draw_something() statement in display(...) method)

private def draw_something() {
    glTranslatef(0, 0, -20)
    glBegin(GL_TRIANGLES)
    glVertex3f(0.0f, 1.0f, 0.0f)
    glVertex3f(-1.0f, -1.0f, 0.0f)
    glVertex3f(1.0f, -1.0f, 0.0f)
    glEnd()
}

What I am doing wrong?
I tried searching for working examples with nifty-gui AND 3d graphics on background, but no luck.

Update 1

I’ve changed the code based on datenwolf’s answer, now GUI is rendered OK, but I can see white triangle only for a couple of milliseconds (maybe actually it is in a single frame?), seems like 3d setup is being “damaged”… This happens only if I render GUI, if I comment the line gui.render(false), white triangle stays on the screen.

Update 2

I added some motion to the 3d part (see updates in repository), now I can see that the triangle is barely visible (it looks like z-fighting).

  • 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-15T06:52:01+00:00Added an answer on June 15, 2026 at 6:52 am

    You must switch between orthographic and perspective projection. For this there are two functions prepared: display_ready2d (this sets up a ortho projection matrix) and display_ready3d (this sets up a perspective projection).

    Unfortunately the display_ready3d function does not reset the matrix stack before applying it’s changes. You must add a glLoadIdentity, before the call to gluPerspective. Also you should not clear the framebuffer in those functions, as you want to be able to switch between matrix setups. So change it to this:

    private def display_ready3d(fov: Float, aspect: Float) {
        glMatrixMode(GL_PROJECTION)
                glLoadIdentity();
        gluPerspective(fov, aspect, 0.01f, 100.0f)
    
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
    
        glEnable(GL_DEPTH_TEST)
    }
    

    display_ready2d right before drawing the GUI and display_ready3d before draw_something. Also you must put the clear commands there, which also need to cover the depth buffer; also the clear color should have an alpha value of 1 (except if you’ve created a transparent window).

    def display(width: Int, height: Int, AR: Float, gui: Nifty) {
                glViewport(0, 0, width, height)
                glClearDepth(1.)
                glClearColor(0., 0., 0., 1.)
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    
        display_ready3d(90, width/height)
        draw_something()
    
        display_ready2d(width, height)
        gui.render(false)
    
        glFlush()
        Display.update()
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using this code snippet: https://gist.github.com/1854699 . I have written this code Base.html: https://gist.github.com/3438843 index.html:
I use this code in my project: https://github.com/ncr/node.ws.js/blob/master/ws.js With Opera, Safari, and FF it
I have this code ( https://gist.github.com/2402116 ) : server.get('/', function(request, response) { var k
Folks, I have this code https://gist.github.com/2473387 But, how do I get the coordinates of
I am using the following API https://gist.github.com/1285901 I have this code so far but
I have this Meteor project: https://github.com/jfahrenkrug/code_buddy It's basically a tool with a big textarea
I have this code working in C#: var request = (HttpWebRequest)WebRequest.Create(https://x.com/service); request.Method = GET;
I saw this code https://gist.github.com/takuma104/ntlniph/blob/master/gtm/Foundation/GTMNSString+HTML.h but it doesn't work on ARC enabled projects or
I am modifying this code: https://github.com/jasondavies/d3-cloud <script> d3.layout.cloud().size([300, 300]) .words([ Hello, world, normally, you,
I follow this tutorial for install omniauth in devise+mongoid: https://github.com/fertapric/rails3-mongoid-devise-omniauth/wiki/OmniAuth-Installation-Tutorial I have devise 1.4.5

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.