-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from hesiod/master
Add tessellation functionality
- Loading branch information
Showing
11 changed files
with
103 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
-- Module : Graphics.Rendering.OpenGL.GL.BeginEnd | ||
-- Copyright : (c) Sven Panne 2002-2013 | ||
-- License : BSD3 | ||
-- | ||
-- | ||
-- Maintainer : Sven Panne <[email protected]> | ||
-- Stability : stable | ||
-- Portability : portable | ||
|
@@ -15,7 +15,6 @@ | |
|
||
module Graphics.Rendering.OpenGL.GL.BeginEnd ( | ||
-- * Begin and End Objects | ||
PrimitiveMode(..), | ||
renderPrimitive, unsafeRenderPrimitive, primitiveRestart, | ||
|
||
-- * Polygon Edges | ||
|
@@ -27,6 +26,7 @@ import Graphics.Rendering.OpenGL.GL.StateVar | |
import Graphics.Rendering.OpenGL.GL.EdgeFlag | ||
import Graphics.Rendering.OpenGL.GL.Exception | ||
import Graphics.Rendering.OpenGL.GL.PrimitiveMode | ||
import Graphics.Rendering.OpenGL.GL.PrimitiveModeInternal | ||
import Graphics.Rendering.OpenGL.GL.QueryUtils | ||
import Graphics.Rendering.OpenGL.Raw | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
{-# OPTIONS_HADDOCK hide #-} | ||
-------------------------------------------------------------------------------- | ||
-- | | ||
-- Module : Graphics.Rendering.OpenGL.GL.PrimitiveMode | ||
-- Copyright : (c) Sven Panne 2002-2013 | ||
-- Copyright : (c) Sven Panne 2002-2013, Tobias Markus 2015 | ||
-- License : BSD3 | ||
-- | ||
-- | ||
-- Maintainer : Sven Panne <[email protected]> | ||
-- Stability : stable | ||
-- Portability : portable | ||
-- | ||
-- This is a purely internal module for (un-)marshaling PrimitiveMode. | ||
-- This module corresponds to section 10.1 (Primitive Types) of the OpenGL 4.4 | ||
-- specs. | ||
-- | ||
-------------------------------------------------------------------------------- | ||
|
||
module Graphics.Rendering.OpenGL.GL.PrimitiveMode ( | ||
PrimitiveMode(..), marshalPrimitiveMode, unmarshalPrimitiveMode | ||
-- * Primitive Modes | ||
PrimitiveMode(..), | ||
-- * Patches (Tessellation) | ||
patchVertices, maxPatchVertices | ||
) where | ||
|
||
import Graphics.Rendering.OpenGL.GL.StateVar | ||
import Graphics.Rendering.OpenGL.GL.QueryUtils.PName | ||
import Graphics.Rendering.OpenGL.Raw | ||
|
||
-------------------------------------------------------------------------------- | ||
|
@@ -66,31 +71,21 @@ data PrimitiveMode = | |
| Polygon | ||
-- ^ Draws a single, convex polygon. Vertices 1 through /N/ define this | ||
-- polygon. | ||
| Patches | ||
-- ^ Only used in conjunction with tessellation. The number of vertices per | ||
-- patch can be set with 'patchVertices'. | ||
deriving ( Eq, Ord, Show ) | ||
|
||
marshalPrimitiveMode :: PrimitiveMode -> GLenum | ||
marshalPrimitiveMode x = case x of | ||
Points -> gl_POINTS | ||
Lines -> gl_LINES | ||
LineLoop -> gl_LINE_LOOP | ||
LineStrip -> gl_LINE_STRIP | ||
Triangles -> gl_TRIANGLES | ||
TriangleStrip -> gl_TRIANGLE_STRIP | ||
TriangleFan -> gl_TRIANGLE_FAN | ||
Quads -> gl_QUADS | ||
QuadStrip -> gl_QUAD_STRIP | ||
Polygon -> gl_POLYGON | ||
-- | 'patchVertices' is the number of vertices per patch primitive. | ||
-- | ||
-- An 'Graphics.Rendering.OpenGL.GLU.Errors.InvalidValue' is generated if | ||
-- 'patchVertices' is set to a value less than or equal to zero or greater | ||
-- than the implementation-dependent maximum value 'maxPatchVertices'. | ||
|
||
patchVertices :: SettableStateVar GLint | ||
patchVertices = makeSettableStateVar $ glPatchParameteri gl_PATCH_VERTICES | ||
|
||
-- | Contains the maximumum number of vertices in a single patch. | ||
|
||
unmarshalPrimitiveMode :: GLenum -> PrimitiveMode | ||
unmarshalPrimitiveMode x | ||
| x == gl_POINTS = Points | ||
| x == gl_LINES = Lines | ||
| x == gl_LINE_LOOP = LineLoop | ||
| x == gl_LINE_STRIP = LineStrip | ||
| x == gl_TRIANGLES = Triangles | ||
| x == gl_TRIANGLE_STRIP = TriangleStrip | ||
| x == gl_TRIANGLE_FAN = TriangleFan | ||
| x == gl_QUADS = Quads | ||
| x == gl_QUAD_STRIP = QuadStrip | ||
| x == gl_POLYGON = Polygon | ||
| otherwise = error ("unmarshalPrimitiveMode: illegal value " ++ show x) | ||
maxPatchVertices :: GettableStateVar GLint | ||
maxPatchVertices = makeGettableStateVar $ getInteger1 id GetMaxPatchVertices |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{-# OPTIONS_HADDOCK hide #-} | ||
-------------------------------------------------------------------------------- | ||
-- | | ||
-- Module : Graphics.Rendering.OpenGL.GL.PrimitiveModeInternal | ||
-- Copyright : (c) Sven Panne 2002-2013 | ||
-- License : BSD3 | ||
-- | ||
-- Maintainer : Sven Panne <[email protected]> | ||
-- Stability : stable | ||
-- Portability : portable | ||
-- | ||
-- This is a purely internal module for (un-)marshaling PrimitiveMode. | ||
-- | ||
-------------------------------------------------------------------------------- | ||
|
||
module Graphics.Rendering.OpenGL.GL.PrimitiveModeInternal ( | ||
marshalPrimitiveMode, unmarshalPrimitiveMode | ||
) where | ||
|
||
import Graphics.Rendering.OpenGL.Raw | ||
import Graphics.Rendering.OpenGL.GL.PrimitiveMode | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
marshalPrimitiveMode :: PrimitiveMode -> GLenum | ||
marshalPrimitiveMode x = case x of | ||
Points -> gl_POINTS | ||
Lines -> gl_LINES | ||
LineLoop -> gl_LINE_LOOP | ||
LineStrip -> gl_LINE_STRIP | ||
Triangles -> gl_TRIANGLES | ||
TriangleStrip -> gl_TRIANGLE_STRIP | ||
TriangleFan -> gl_TRIANGLE_FAN | ||
Quads -> gl_QUADS | ||
QuadStrip -> gl_QUAD_STRIP | ||
Polygon -> gl_POLYGON | ||
Patches -> gl_PATCHES | ||
|
||
unmarshalPrimitiveMode :: GLenum -> PrimitiveMode | ||
unmarshalPrimitiveMode x | ||
| x == gl_POINTS = Points | ||
| x == gl_LINES = Lines | ||
| x == gl_LINE_LOOP = LineLoop | ||
| x == gl_LINE_STRIP = LineStrip | ||
| x == gl_TRIANGLES = Triangles | ||
| x == gl_TRIANGLE_STRIP = TriangleStrip | ||
| x == gl_TRIANGLE_FAN = TriangleFan | ||
| x == gl_QUADS = Quads | ||
| x == gl_QUAD_STRIP = QuadStrip | ||
| x == gl_POLYGON = Polygon | ||
| x == gl_PATCHES = Patches | ||
| otherwise = error ("unmarshalPrimitiveMode: illegal value " ++ show x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
-- Module : Graphics.Rendering.OpenGL.GLU.Tessellation | ||
-- Copyright : (c) Sven Panne 2002-2013 | ||
-- License : BSD3 | ||
-- | ||
-- | ||
-- Maintainer : Sven Panne <[email protected]> | ||
-- Stability : stable | ||
-- Portability : portable | ||
|
@@ -48,9 +48,9 @@ import Graphics.Rendering.OpenGL.GL.Tensor | |
import Graphics.Rendering.OpenGL.GL.EdgeFlag ( unmarshalEdgeFlag ) | ||
import Graphics.Rendering.OpenGL.GL.Exception ( bracket ) | ||
import Graphics.Rendering.OpenGL.GL.GLboolean ( marshalGLboolean ) | ||
import Graphics.Rendering.OpenGL.GL.PrimitiveMode ( unmarshalPrimitiveMode ) | ||
import Graphics.Rendering.OpenGL.GL.BeginEnd ( | ||
PrimitiveMode, EdgeFlag(BeginsInteriorEdge) ) | ||
import Graphics.Rendering.OpenGL.GL.PrimitiveMode ( PrimitiveMode ) | ||
import Graphics.Rendering.OpenGL.GL.PrimitiveModeInternal ( unmarshalPrimitiveMode ) | ||
import Graphics.Rendering.OpenGL.GL.BeginEnd ( EdgeFlag(BeginsInteriorEdge) ) | ||
import Graphics.Rendering.OpenGL.GL.VertexSpec | ||
import Graphics.Rendering.OpenGL.GL.QueryUtils | ||
import Graphics.Rendering.OpenGL.GLU.ErrorsInternal | ||
|