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

  • Home
  • SEARCH
  • 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 7519847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:58:11+00:00 2026-05-30T01:58:11+00:00

I’m trying to create a go board using opengl. To do this, I’m trying

  • 0

I’m trying to create a go board using opengl. To do this, I’m trying to draw a bunch of lines to create the grid. However, every tutorial site (including opengl’s) has the examples in C++ and the Haskell wiki doesn’t do a good job of explaining it. I’m new to opengl and would like a tutorial.

  • 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-30T01:58:11+00:00Added an answer on May 30, 2026 at 1:58 am

    I’ll assume that you want to use OpenGL 2.1 or earlier. For OpenGL 3.0, you need different code.

    So, in C you would write this:

    glBegin(GL_LINES);
    glVertex3f(1, 2, 3);
    glVertex3f(5, 6, 7);
    glEnd();
    

    You write the equivalent in Haskell like this:

    renderPrimitive Lines $ do
      vertex $ Vertex3 1 2 3
      vertex $ Vertex3 5 6 7
    

    With this code, since I used e.g. 1 instead of some variable, you might get errors about ambiguous types (So you should replace 1 with (1 :: GLfloat)), but if you use actual variables that already have the type GLfloat, you shouldn’t have to do this.

    Here’s a complete program that draws a white diagonal in the window:

    import Graphics.Rendering.OpenGL
    import Graphics.UI.GLUT
    
    main :: IO ()
    main = do
      -- Initialize OpenGL via GLUT
      (progname, _) <- getArgsAndInitialize
    
      -- Create the output window
      createWindow progname
    
      -- Every time the window needs to be updated, call the display function
      displayCallback $= display
    
      -- Let GLUT handle the window events, calling the displayCallback as fast as it can
      mainLoop
    
    display :: IO ()
    display = do
      -- Clear the screen with the default clear color (black)
      clear [ ColorBuffer ]
    
      -- Render a line from the bottom left to the top right
      renderPrimitive Lines $ do
        vertex $ (Vertex3 (-1) (-1)  0 :: Vertex3 GLfloat)
        vertex $ (Vertex3   1    1   0 :: Vertex3 GLfloat)
    
      -- Send all of the drawing commands to the OpenGL server
      flush
    

    The default OpenGL fixed-function projection uses (-1, -1) for the bottom left and (1, 1) for the top right of the window. You need to alter the projection matrix to get different coordinate spaces.

    For more complete examples like this, see the Haskell port of the NEHE tutorials. They use the RAW OpenGL bindings, which are more like the C bindings.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text

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.