All Projects → dmjio → LearnOpenGL.hs

dmjio / LearnOpenGL.hs

Licence: BSD-3-Clause License
LearnOpenGL.com examples ported to Haskell

Programming Languages

haskell
3896 projects
GLSL
2045 projects
Nix
1067 projects
shell
77523 projects

LearnOpenGL.hs

LearnOpenGL.com chapters ported to Haskell.

Table of Contents

Demo

To see a demo of all examples run nix-build -A demo && ./result/bin/demo

Motivation

LearnOpenGL.com is touted as one of the best learning resources for OpenGL programming. This repository is a first foray into porting the learning resources of https://learnopengl.com to Haskell. The ported examples here do not focus on fancy Haskell abstractions, but attempt to emphasize the domain using the raw OpenGL C bindings (built by @ekmett). The code is intended to be simple (and sometimes ugly) to demonstrate what's necesary to effectively use C and Haskell together in OpenGL. To help contribute to this effort please see Help.

Getting Started

See Hello Window.

Hello Window

Hello Triangle

Shaders

Textures

Camera

Transformations

Lighting

Colors

Basic Lighting

Not yet implemented . Please help.

Materials

Not yet implemented . Please help.

Lighting Maps

Not yet implemented . Please help.

Light Casters

Not yet implemented . Please help.

Multiple Lights

Not yet implemented . Please help.

Model Loading

Not yet implemented. Please help.

Assimp

Not yet implemented. Please help.

Mesh

Not yet implemented. Please help.

Model

Not yet implemented. Please help.

Advanced OpenGL

Not yet implemented. Please help.

Advanced Lighting

Not yet implemented. Please help.

Physically Based Rendering

Not yet implemented. Please help.

Release

To build the current project and demo script run the following:

nix-build

Develop

Entering a nix-shell

nix-shell

Help

Adding new chapters is greatly appreciated, and will go a long way to making Haskell a first class citizen for Game development (with OpenGL).

See Contributing for more information.

Contributing

There are many more advanced chapters to cover, the GettingStarted section being an necessary prerequisite. If one is so inclined to contribute to this effort I recommend doing the following:

  • Clone this repo at https://github.com/dmjio/LearnOpenGL.hs
  • Edit Main.hs to be the implementation of a chapter that interests you (the current convention is one module per chapter -- built as an executable).
    • Note: Most chapters build off each other, so going through all examples and building the next one in order is advised.
    • Edit the shaders found in the top-level current directory of the project (or add your own as you see fit).
  • Build the project with nix-build -A app (makes linking the C libraries into your Haskell executable much simpler not so problematic).
    • For more interactive develpment you can call nix-shell and then use cabal run opengl-exp to run the project (linking shouldn't be a problem w/ nix).
    • Note: the shaders are loaded dynamically.
    • Calling nix-build -A app will only build the top level opengl-exp project.
  • When done with your implementation, copy all assets from the top-level opengl-exp (Main.hs, shaders, etc.) into its own subfolder.
    • For example, Lighting/YourChapterGoesHere/{Main.hs,vert.glsl,etc..}.
    • To see an example of script that does this for you check create.sh
  • Update the default.nix script to include your chapter in the demo executable.
  • Update the README.md with links to your chapter.

Vulkan

Many people have asked why I focussed on OpenGL instead of Vulkan. The short answer is that despite Vulkan being the future of game development, it is much more difficult (especially for beginners to GPU programming). Additionally, most Vulkan learning resources have recommended OpenGL as a good learning prerequisite. OpenGL also has a much larger body of knowledge currently, making it a good first step in the learning journey. Lastly, https://learnvulkan.com/ would be a good Haskell port to have as well, when it reaches maturity.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].