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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:50:43+00:00 2026-05-20T01:50:43+00:00

Is there a simple complete code example using any gui toolkit (that will work

  • 0

Is there a simple complete code example using any gui toolkit (that will work in both Linux and Windows) of opening multiple opengl windows simultaneously? And how to handle their events and such separately of course. I tried it naively and it crashes.

I received a full working source code example from someone outside of stackoverflow. I’m pasting it here for all to benefit.

module Main where

import Graphics.UI.GLUT
import System.Exit (exitWith, ExitCode(ExitSuccess))

reshape :: ReshapeCallback
reshape size = do
   viewport $= (Position 0 0, size)
   matrixMode $= Projection
   loadIdentity
   frustum (-1) 1 (-1) 1 1.5 20
   matrixMode $= Modelview 0

keyboard :: KeyboardMouseCallback
keyboard (Char '\27') Down _ _ = exitWith ExitSuccess
keyboard _            _    _ _ = return ()

renderCube :: Color3 GLfloat -> IO ()
renderCube c = do
   clear [ ColorBuffer ]

   let color3f = color :: Color3 GLfloat -> IO ()
       scalef = scale :: GLfloat -> GLfloat -> GLfloat -> IO ()

   color3f c
   loadIdentity
   lookAt (Vertex3 0 0 5) (Vertex3 0 0 0) (Vector3 0 1 0)
   scalef 1 2 1
   renderObject Wireframe (Cube 1)
   flush

displayR :: DisplayCallback
displayR = renderCube (Color3 1 0 0)

displayB :: DisplayCallback
displayB = renderCube (Color3 0 0 1)

createWindowWithDisplayFunc :: String -> Position -> DisplayCallback -> IO Window
createWindowWithDisplayFunc name pos display = do
   win <- createWindow name
   windowPosition $= pos
   clearColor $= Color4 0 0 0 0
   shadeModel $= Flat
   displayCallback $= display
   reshapeCallback $= Just reshape
   keyboardMouseCallback $= Just keyboard
   return win

main = do
   getArgsAndInitialize
   initialDisplayMode $= [ SingleBuffered, RGBMode ]
   initialWindowSize $= Size 100 100
   initialWindowPosition $= Position 100 100

   createWindowWithDisplayFunc "R" (Position 10 10) displayR
   createWindowWithDisplayFunc "B" (Position 110 10) displayB

   mainLoop
  • 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-20T01:50:43+00:00Added an answer on May 20, 2026 at 1:50 am

    GLUT, of course.

    The GLUT homepage states

    The toolkit supports:
    - Multiple windows for OpenGL rendering
    - Callback driven event processing
    - Sophisticated input devices
    - An 'idle' routine and timers
    - A simple, cascading pop-up menu facility
    - Utility routines to generate various solid and wire frame objects
    - Support for bitmap and stroke fonts
    - Miscellaneous window management functions
    

    Hence you can use GLUT for managing multiple windows (I had used once). Here is a tutorial for what you need.

    I’ve also found this article which you may look a little, since it’s Haskell specific.

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

Sidebar

Related Questions

Is there a simple way to cache MySQL queries in PHP or failing that,
Is there any simple algorithm to determine the likeliness of 2 names representing the
Is there any simple way to programatically colorize images in .NET? Basically we have
Is there any simple way to generate a default crud (given an entity) with
Update: I have provided complete code example in answer below. I have built my
Is there a simple way of getting a HTML textarea and an input type=text
Is there a simple way in .NET to quickly get the current protocol, host,
Is there a simple method of parsing XML files in C#? If so, what?
Is there a simple and lightweight program to search over a text file and
I there a simple way to append a new field to an existing open

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.