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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:58:32+00:00 2026-06-03T14:58:32+00:00

Short Question: Given Clojure’s concurrency model, how do I ensure that all LWJGL OpenGL

  • 0

Short Question:

Given Clojure’s concurrency model, how do I ensure that all LWJGL OpenGL Update functions are called from the same thread?

Long Question

After a long and glorious battle, Using lwjgl in Leiningen/Clojure , I now have LWJGL + Leiningen + Clojure working together.

However, according to LWJGL documentation, it appears that there OpenGL client commands have thread local state — and if I call OpenGL commands from different threads, Bad Things (TM) can happen.

Thus, my question: what is the correct way, within Clojure, to set up something like Swing Threads (but I can’t use Swing Threads / have to setup my own) so that:

(1) there is a single main thread that is in charge of all OpenGL calls

(2) other threads do some type of communication with this main thread to coordinate OpenGL calls

My Background

I’m familiar with threading in C/C++. I’m familiar with Clojure’s agent/atom/ref model. However, I’m not familiar with “manual” concurrency/threading in Clojure.

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-06-03T14:58:33+00:00Added an answer on June 3, 2026 at 2:58 pm

    The usual way I would design this would be just to have a single thread responsible for all rendering. By doing this you avoid the need for other threads to “issue OpenGL calls”.

    Of course, you still need a way to get information to the rendering thread, but that can be handled with Clojure’s standard concurrency techniques. For example, if your world state is immutable you could just use an atom for state updates, and have the rendering thread just perform rendering using the latest world state stored in the atom:

      (def world-state (atom (initial-world-state)))
    
      ;; in rendering thread
      .....
      (loop []
        (render-world @world-state) ; all OpenGL calls happen in this function!!
        (other-stuff)
        (if (still-running) (recur)))
    
      ;; in other thread responsible for updating world
      (loop []
        (swap! world-state update-world-function)
        (other-stuff)
        (sleep-if-needed)
        (if (still-running) (recur)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Short question: I'm trying to make that in a given page (uses tabs) back
Short Question Is there a way to nuke the server state in OpenGL? I.e.
Short question: Is the parent of an entity group included in that entity group
Sorry if this question isn't clear. The short story is that we had someone
i want to point, that i am learning python since short time. The question
Short question since I don't know how to search for this. Can I re-update
I've got a short question that I've been wondering about for a while. There
a short question about optional regex : imagine a given page thats currently rewritten/beautified
Short question: How should product categories that appear under multiple categories be managed? Is
short question. given the following example: $arr = array(); $arr[0] = false ?: NULL;

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.