{"id":17791222,"url":"https://github.com/schell/ixshader","last_synced_at":"2025-03-16T15:31:30.907Z","repository":{"id":56844732,"uuid":"106124151","full_name":"schell/ixshader","owner":"schell","description":"A shallow embedding of the OpenGL Shading Language in Haskell","archived":false,"fork":false,"pushed_at":"2018-06-18T17:58:18.000Z","size":24,"stargazers_count":15,"open_issues_count":11,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-27T11:05:29.864Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-07T19:18:17.000Z","updated_at":"2022-11-26T16:16:37.000Z","dependencies_parsed_at":"2022-09-09T04:10:42.078Z","dependency_job_id":null,"html_url":"https://github.com/schell/ixshader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schell%2Fixshader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schell%2Fixshader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schell%2Fixshader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schell%2Fixshader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schell","download_url":"https://codeload.github.com/schell/ixshader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243822312,"owners_count":20353496,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-27T10:50:18.268Z","updated_at":"2025-03-16T15:31:30.612Z","avatar_url":"https://github.com/schell.png","language":"Haskell","readme":"# ixshader\nIf you're interested in this project please see its spiritual successor\n[gristle](https://github.com/schell/gristle), which simplifies the types \ninvolved by removing indexed monads.\n\n`ixshader` is a shallow embedding of the OpenGL Shading Language in Haskell. It\naims to look as close to actual glsl shader code as possible, while providing\nbetter compile-time safety. Currently writing shader code in `ixshader`'s\n`IxShader` monad will catch variable assignment mismatches, multiplication\nmismatches and some other common errors. It also builds a description of your\nshader at the type level to use downstream during buffering and uniform updates.\nLastly, it abstracts over shader code written for opengl and webgl.\n\nSince this is a work in progress the entire language is not yet supported,\nthough you can easy use the `nxt` and `acc` functions to push your own glsl into\nthe pipeline, typechecking only what you want.\n\nThe resulting source is pretty and human readable, even debuggable without\nsourcemapping.\n\nYou should create a separate file for your shaders as `ixshader` relies on\nthe `RebindableSyntax` language extension and re-defines key functions such as\n`\u003e\u003e=`, `\u003e\u003e`, `return`, `fail`, `void`, `fromInteger` and `fromRational`.\n\n## example\n\n```haskell\n{-# LANGUAGE AllowAmbiguousTypes   #-}\n{-# LANGUAGE DataKinds             #-}\n{-# LANGUAGE FlexibleContexts      #-}\n{-# LANGUAGE FlexibleInstances     #-}\n{-# LANGUAGE GADTs                 #-}\n{-# LANGUAGE LambdaCase            #-}\n{-# LANGUAGE MultiParamTypeClasses #-}\n{-# LANGUAGE PolyKinds             #-}\n{-# LANGUAGE RankNTypes            #-}\n{-# LANGUAGE RebindableSyntax      #-}\n{-# LANGUAGE ScopedTypeVariables   #-}\n{-# LANGUAGE TypeFamilies          #-}\n{-# LANGUAGE TypeInType            #-}\n{-# LANGUAGE TypeOperators         #-}\n{-# LANGUAGE UndecidableInstances  #-}\n\nmodule MyShaders where\n\nimport Graphics.IxShader\n\nmyvertex\n  :: forall (ctx :: GLContext). HasContext ctx\n  =\u003e IxShader ctx '[] '[ In      Xvec2 \"position\"\n                       , In      Xvec4 \"color\"\n                       , Uniform Xmat4 \"projection\"\n                       , Uniform Xmat4 \"modelview\"\n                       , Out     Xvec4 \"fcolor\"\n                       , Out     Xvec4 \"gl_Position\"\n                       , Main\n                       ] ()\nmyvertex = do\n  pos    \u003c- in_\n  color  \u003c- in_\n  proj   \u003c- uniform_\n  modl   \u003c- uniform_\n  fcolor \u003c- out_\n  glPos  \u003c- gl_Position\n  main_ $ do\n    fcolor .= color\n    glPos  .= proj .* modl .* (pos .: 0.0 .: 1.0)\n\nmyfragment\n  :: forall (ctx :: GLContext). IsGLContext ctx\n  =\u003e IxShader ctx '[] '[ In  Xvec4 \"fcolor\"\n                       , Out Xvec4 (GLFragName ctx)\n                       , Main\n                       ] ()\nmyfragment = do\n  fcolor \u003c- in_\n  glFrag \u003c- gl_FragColor\n  main_ $ glFrag .= fcolor\n\n\nmain = do\n  putStrLn \"First OpenGL:\"\n  putSrcLn $ vertex @'OpenGLContext\n  putStrLn \"\\nThen WebGL:\"\n  putSrcLn $ vertex @'WebGLContext\n{-\nFirst OpenGL:\nin vec2 position;\nin vec4 color;\nuniform mat4 projection;\nuniform mat4 modelview;\nout vec4 fcolor;\nvoid main ()\n{ fcolor = color;\n  gl_Position = projection * modelview * vec4 (position.x, position.y, 0.0, 1.0);\n}\n\nThen WebGL:\nattribute vec2 position;\nattribute vec4 color;\nuniform mat4 projection;\nuniform mat4 modelview;\nvarying vec4 fcolor;\nvoid main ()\n{ fcolor = color;\n  gl_Position = projection * modelview * vec4 (position.x, position.y, 0.0, 1.0);\n}\n-}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschell%2Fixshader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschell%2Fixshader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschell%2Fixshader/lists"}