From 90fba69ff15784247cfa1065d101464f9a6cbb6f Mon Sep 17 00:00:00 2001 From: rkoeninger Date: Thu, 15 Sep 2016 22:26:24 -0400 Subject: [PATCH] Initial commit with some demo opengl code --- .gitignore | 1 + Famihask.cabal | 25 +++++++++++++++++++++++++ LICENSE.txt | 20 ++++++++++++++++++++ Setup.hs | 2 ++ src/Main.hs | 42 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+) create mode 100644 .gitignore create mode 100644 Famihask.cabal create mode 100644 LICENSE.txt create mode 100644 Setup.hs create mode 100644 src/Main.hs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7773828 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist/ \ No newline at end of file diff --git a/Famihask.cabal b/Famihask.cabal new file mode 100644 index 0000000..c6bbe2b --- /dev/null +++ b/Famihask.cabal @@ -0,0 +1,25 @@ +-- Initial Famihask.cabal generated by cabal init. For further +-- documentation, see http://haskell.org/cabal/users-guide/ + +name: Famihask +version: 0.1.0.0 +synopsis: NES emulator in Haskell +-- description: +homepage: http://github.com/rkoeninger/Famihask +license: MIT +license-file: LICENSE +author: rkoeninger +maintainer: rkoeninger@att.net +-- copyright: +category: Game +build-type: Simple +-- extra-source-files: +cabal-version: >=1.10 + +executable Famihask + main-is: Main.hs + -- other-modules: + -- other-extensions: + build-depends: base >=4.7 && <4.8, GLUT + hs-source-dirs: src + default-language: Haskell2010 \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..f6d435e --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,20 @@ +Copyright (c) 2016 rkoeninger + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Setup.hs b/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/src/Main.hs b/src/Main.hs new file mode 100644 index 0000000..91fb7a2 --- /dev/null +++ b/src/Main.hs @@ -0,0 +1,42 @@ +import Graphics.UI.GLUT + +myPoints :: [(GLfloat,GLfloat,GLfloat)] +myPoints = [ (sin (2*pi*k/64), cos (2*pi*k/64), 0) | k <- [1..64] ] + +main :: IO () +main = do + (_progName, _args) <- getArgsAndInitialize + _window <- createWindow "Hello World" + displayCallback $= display + mainLoop + +display :: DisplayCallback +display = do + let color3f r g b = color $ Color3 r g (b :: GLfloat) + vertex3f x y z = vertex $ Vertex3 x y (z :: GLfloat) + clear [ColorBuffer] + renderPrimitive Quads $ do + color3f 1 0 0 + vertex3f 0 0 0 + vertex3f 0 0.2 0 + vertex3f 0.2 0.2 0 + vertex3f 0.2 0 0 + + color3f 0 1 0 + vertex3f 0 0 0 + vertex3f 0 (-0.2) 0 + vertex3f 0.2 (-0.2) 0 + vertex3f 0.2 0 0 + + color3f 0 0 1 + vertex3f 0 0 0 + vertex3f 0 (-0.2) 0 + vertex3f (-0.2) (-0.2) 0 + vertex3f (-0.2) 0 0 + + color3f 1 0 1 + vertex3f 0 0 0 + vertex3f 0 0.2 0 + vertex3f (-0.2) 0.2 0 + vertex3f (-0.2) 0 0 + flush \ No newline at end of file