Difference between revisions of "OpenGL"

From HaskellWiki
Jump to navigation Jump to search
(Added section "Additional software")
(Added a link to the HOpenGL Haddock documentation; changed the FTGL link)
Line 5: Line 5:
   
 
== References ==
 
== References ==
* [http://www.haskell.org/mailman/listinfo/hopengl the hopengl mailing list]
+
* [http://www.haskell.org/mailman/listinfo/hopengl the HOpenGL mailing list]
   
 
* [http://www.haskell.org/ghc/docs/latest/html/libraries/OpenGL/Graphics-Rendering-OpenGL.html the API docs for the OpenGL binding]
 
* [http://www.haskell.org/ghc/docs/latest/html/libraries/OpenGL/Graphics-Rendering-OpenGL.html the API docs for the OpenGL binding]
Line 32: Line 32:
 
* [[OpenGLTutorial1]] and [[OpenGLTutorial2]]
 
* [[OpenGLTutorial1]] and [[OpenGLTutorial2]]
 
* [http://bluheron.europa.renci.org/docs/BeautifulCode.pdf Beautiful Code, Compelling Evidence: Functional Programming for Information Visualization and Visual Analytics] - Writing visualizations using OpenGL or Cairo (PDF)
 
* [http://bluheron.europa.renci.org/docs/BeautifulCode.pdf Beautiful Code, Compelling Evidence: Functional Programming for Information Visualization and Visual Analytics] - Writing visualizations using OpenGL or Cairo (PDF)
* http://www.cin.ufpe.br/~haskell/hopengl/ Andre Furtado's nice tutorial written in 2001 (bitrotted)
+
* [http://www.cin.ufpe.br/~haskell/hopengl/ Andre Furtado's nice tutorial] written in 2001 (bitrotted)
* http://www.haskell.org/~pairwise/HOpenGL/HOpenGL.html#texLoad Spriting with HOpenGL, David Morra
+
* [http://www.haskell.org/~pairwise/HOpenGL/HOpenGL.html#texLoad Spriting with HOpenGL], David Morra
   
 
== OpenGL Resources ==
 
== OpenGL Resources ==
Line 43: Line 43:
 
* assuming you know Haskell, any OpenGL tutorial of your choice should get you going (browsing the [http://www.opengl.org OpenGL] site is also a good idea)
 
* assuming you know Haskell, any OpenGL tutorial of your choice should get you going (browsing the [http://www.opengl.org OpenGL] site is also a good idea)
 
* use the [http://www.opengl.org/documentation/red_book/ Red Book], and its example code translations, to understand the small differences between OpenGL and HOpenGL
 
* use the [http://www.opengl.org/documentation/red_book/ Red Book], and its example code translations, to understand the small differences between OpenGL and HOpenGL
* use the [http://www.opengl.org/documentation/specs/ OpenGL and GLUT specs] to find your way around the HOpenGL Haddock documentation
+
* use the [http://www.opengl.org/documentation/specs/ OpenGL and GLUT specs] to find your way around the [http://www.haskell.org/ghc/docs/latest/html/libraries/OpenGL/Graphics-Rendering-OpenGL.html HOpenGL Haddock documentation]
 
* use the [http://www.haskell.org/mailman/listinfo/hopengl HopenGL list] for questions and success stories
 
* use the [http://www.haskell.org/mailman/listinfo/hopengl HopenGL list] for questions and success stories
   
 
== Additional software ==
 
== Additional software ==
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/FTGL FTGL]: Portable TrueType font rendering for OpenGL using the Freetype2 library
+
* [[FTGL]]: Portable TrueType font rendering for OpenGL using the Freetype2 library
 
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/GLFW GLFW]: A binding for GLFW, An OpenGL Framework
 
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/GLFW GLFW]: A binding for GLFW, An OpenGL Framework
 
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/GLUT GLUT]: A binding for the OpenGL Utility Toolkit
 
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/GLUT GLUT]: A binding for the OpenGL Utility Toolkit

Revision as of 18:18, 30 August 2008

This is a stub page for Haskell's OpenGL and GLUT bindings. It is meant as a starting point to replace the outdated and misleading documentation at the old page.

First, note that the implementation is far more up-to-date than that old page suggested (originally, it was quite useful, but the page hasn't kept up with the implementation for a long time now).

References

In particular, note that the examples/ directory in the GLUT repo contains lots of examples, including translations of the red book examples.

Both the API documentation and the examples are best studied with the original specs and the original red book examples at hand. An index of the examples from v1.1 of the red book, with screen shots, can be found here

Projects using the OpenGL bindings

  • Frag, a 3D first-person shooter game.
  • Monadius, a 2D scrolling arcade game.
  • Roguestar, a roguelike adventure game using 3D graphics.
  • Shu-thing, a 2D scroling arcade game.
  • Topkata, a jumping ball puzzle game.
  • PolyFunViz, a toolkit for scientific visualization (e.g. surfaces, flows, contours, volumes)

HOpenGL Resources

OpenGL Resources

Getting Started

  • assuming you know Haskell, any OpenGL tutorial of your choice should get you going (browsing the OpenGL site is also a good idea)
  • use the Red Book, and its example code translations, to understand the small differences between OpenGL and HOpenGL
  • use the OpenGL and GLUT specs to find your way around the HOpenGL Haddock documentation
  • use the HopenGL list for questions and success stories

Additional software

  • FTGL: Portable TrueType font rendering for OpenGL using the Freetype2 library
  • GLFW: A binding for GLFW, An OpenGL Framework
  • GLUT: A binding for the OpenGL Utility Toolkit
  • graphics-drawingcombinators: A functional interface to 2D drawing in OpenGL

Somewhat related is SDL, which is also based on OpenGL:

To add sound to OpenGL applications:

  • OpenAL: A binding to the OpenAL cross-platform 3D audio AP
  • ALUT: A binding for the OpenAL Utility Toolkit


Troubleshooting

I can't display text with renderString

It's probably because the text is displayed too big. Setting a much smaller scale factor before calling renderString should solve the problem.

scale 0.001 0.001 (0.001GLfloat)
renderString Roman "Test string"

Animations flicker

If you're not using DoubleBuffered display mode, turn that on. Also, you must set the display mode before creating the window you're going to be drawing in. To check if you've enabled double buffering use something like:

db <- get doubleBuffered

and set DoubleBuffered mode (before creating your windows!) like this:

initialDisplayMode $= [DoubleBuffered]
createWindow "My Window"
You will also need to call
swapBuffer
at the end of your draw function.