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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:33:54+00:00 2026-06-03T02:33:54+00:00

I know that in order to write a GTK application, I write a bunch

  • 0

I know that in order to write a GTK application, I write a bunch of code which describes what is put in the main window, then I call:

gtk_main();

Any code statements after this do not get executed.

Now let’s suppose I’d like my GTK app to display something I wrote with glut, which itself contains a bunch of statements about what graphics need to be set etc. then ends with the statement:

glutMainLoop();

Anything after this is not executed.

So my problem is that either of these two statements prevents me from calling the other.

  1. Is there a way to execute a glut main loop inside a GTK widget ?
  2. Is there a way to write a code that could somehow simultaneously call both a GTK main loop and a glut main loop (but called from the main program and rendered in a separate X window, not within a widget)? I’ve got a feeling this could be done with “threads”…
  • 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-03T02:33:56+00:00Added an answer on June 3, 2026 at 2:33 am

    You are running the main loops. gtk_main() runs until gtk_quit() is called.

    gtk_main() at GTK.org

    Runs the main loop until gtk_main_quit() is called. You can nest calls to gtk_main(). In that case gtk_main_quit() will make the innermost invocation of the main loop return.

    Also, glutMainLoop() works the same way, it processes GL events forever.

    glutMainLoop() at OpenGL.org

    glutMainLoop() enters the GLUT event processing loop. This routine should be called at most once in a GLUT program. Once called, this routine will never return. It will call as necessary any callbacks that have been registered.

    So, you you wan’t both of these things to execute at the same time (I think they might interfere with each other so you might get unexpected results) then you will need to call gtk_main_iteration() from inside glut.

    gtk_main_iteration() at GTK.org

    Runs a single iteration of the mainloop. If no events are waiting to be processed GTK+ will block until the next event is noticed. If you don’t want to block look at gtk_main_iteration_do() or check if any events are pending with gtk_events_pending() first.

    Now.. GLUT doesn’t have an equivalent to gtk_main_iteration() so you are going to need to register GLUT callbacks.

    You could register a callback with GLUT that runs gtk_main_iteration() using glutIdleFunc(void (*func)(void)) which will run a callback for every frame – glutIdleFunc()..

    Or you could give a callback to glutTimerFunc(unsigned int msecs,
    void (*func)(int value), value)
    to call and check the return value of gtk_main_iteration() every 200msec or so.

    I’d probably experiment with both, glutIdleFunc() might not always get called regularly enough for good responsiveness.

    It really is worth looking at driving GTK’s GL support though.

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

Sidebar

Related Questions

I know that if you write void function_name(int& a) , then the function will
I know that C++ doesn't specify the order in which parameters are passed to
I know that in order to programmatically add my own taxonomy to a node
I know that in order for me to force the app to be in
1) I know there are lots of web sites that describe in what order
I know that I should put all the html elements in body tag, but
I need to write some code that deals with generating and manipulating multivariable polynomials.
In an application I write that uses a large HTML table of numbers the
I know that you use @synthesize to create setter and getter methods, which makes
I know that it's a subject that can raise a lot of debate, but

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.