Skip to content

kinten108101/oglsl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OGlsl

OGlsl is a set of module signatures providing overloadable functions and operators and abstract types for writing GLSL 1 in OCaml. In other words, it is a tagless-final 2 eDSL - abstract algebra of GLSL embedded in OCaml.

OGlsl isn't useful on its own. (TBA)

Installation

opam install oglsl

Usage

An introduction to OGlsl is available at the wiki. For a use case of OGlsl in one short snippet, here it is:

module SHADER
(C: Oglsl.Glsl)
(C_stdlib: Oglsl.Glsl__opengl(C).S) = struct
  open C
  open C_stdlib

  let vertex_shader =
    prog begin
    (#!) version v3_3_0 core >>=+ fun _ ->
    let+ pos = In.ref__vec3 ~layout__location:0 () in
    func0 void main @@ fun () ->
      Gl.position := Vec4.of_vec3 !pos (float 1.0)
    end
end

which can be translated to (assuming we provide an interpreter implementation)

#version 330 core
layout(location = 0) in vec3 pos;
void main() {
  gl_Position = vec4(pos, 1.0);
}

or it can be used directly (example TBA)

Let's dissect what's going on:

  • TBA
  • TBA

Acknowledgement

TBA

Footnotes

  1. https://en.wikipedia.org/wiki/OpenGL_Shading_Language

  2. https://okmij.org/ftp/tagless-final/

About

Embedding GLSL in OCaml

Resources

Stars

Watchers

Forks