/usr/share/doc/libghc-opengl-doc/html/src/Graphics-Rendering-OpenGL-GL-Selection.html is in libghc-opengl-doc 2.8.0.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
<title>Graphics/Rendering/OpenGL/GL/Selection.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-2"></a><span class='hs-comment'>-- |</span>
<a name="line-3"></a><span class='hs-comment'>-- Module : Graphics.Rendering.OpenGL.GL.Selection</span>
<a name="line-4"></a><span class='hs-comment'>-- Copyright : (c) Sven Panne 2002-2009</span>
<a name="line-5"></a><span class='hs-comment'>-- License : BSD-style (see the file libraries/OpenGL/LICENSE)</span>
<a name="line-6"></a><span class='hs-comment'>-- </span>
<a name="line-7"></a><span class='hs-comment'>-- Maintainer : sven.panne@aedion.de</span>
<a name="line-8"></a><span class='hs-comment'>-- Stability : stable</span>
<a name="line-9"></a><span class='hs-comment'>-- Portability : portable</span>
<a name="line-10"></a><span class='hs-comment'>--</span>
<a name="line-11"></a><span class='hs-comment'>-- This module corresponds to section 5.2 (Selection) of the OpenGL 2.1 specs.</span>
<a name="line-12"></a><span class='hs-comment'>--</span>
<a name="line-13"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-14"></a>
<a name="line-15"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Graphics</span><span class='hs-varop'>.</span><span class='hs-conid'>Rendering</span><span class='hs-varop'>.</span><span class='hs-conid'>OpenGL</span><span class='hs-varop'>.</span><span class='hs-conid'>GL</span><span class='hs-varop'>.</span><span class='hs-conid'>Selection</span> <span class='hs-layout'>(</span>
<a name="line-16"></a> <span class='hs-conid'>HitRecord</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-varid'>getHitRecords</span><span class='hs-layout'>,</span>
<a name="line-17"></a> <span class='hs-conid'>Name</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-varid'>withName</span><span class='hs-layout'>,</span> <span class='hs-varid'>loadName</span><span class='hs-layout'>,</span> <span class='hs-varid'>maxNameStackDepth</span><span class='hs-layout'>,</span> <span class='hs-varid'>nameStackDepth</span><span class='hs-layout'>,</span>
<a name="line-18"></a> <span class='hs-conid'>RenderMode</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-varid'>renderMode</span>
<a name="line-19"></a><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-20"></a>
<a name="line-21"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>Marshal</span><span class='hs-varop'>.</span><span class='hs-conid'>Array</span>
<a name="line-22"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>Ptr</span>
<a name="line-23"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Graphics</span><span class='hs-varop'>.</span><span class='hs-conid'>Rendering</span><span class='hs-varop'>.</span><span class='hs-conid'>OpenGL</span><span class='hs-varop'>.</span><span class='hs-conid'>GL</span><span class='hs-varop'>.</span><span class='hs-conid'>StateVar</span>
<a name="line-24"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Graphics</span><span class='hs-varop'>.</span><span class='hs-conid'>Rendering</span><span class='hs-varop'>.</span><span class='hs-conid'>OpenGL</span><span class='hs-varop'>.</span><span class='hs-conid'>GL</span><span class='hs-varop'>.</span><span class='hs-conid'>Exception</span>
<a name="line-25"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Graphics</span><span class='hs-varop'>.</span><span class='hs-conid'>Rendering</span><span class='hs-varop'>.</span><span class='hs-conid'>OpenGL</span><span class='hs-varop'>.</span><span class='hs-conid'>GL</span><span class='hs-varop'>.</span><span class='hs-conid'>IOState</span>
<a name="line-26"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Graphics</span><span class='hs-varop'>.</span><span class='hs-conid'>Rendering</span><span class='hs-varop'>.</span><span class='hs-conid'>OpenGL</span><span class='hs-varop'>.</span><span class='hs-conid'>GL</span><span class='hs-varop'>.</span><span class='hs-conid'>QueryUtils</span>
<a name="line-27"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Graphics</span><span class='hs-varop'>.</span><span class='hs-conid'>Rendering</span><span class='hs-varop'>.</span><span class='hs-conid'>OpenGL</span><span class='hs-varop'>.</span><span class='hs-conid'>GL</span><span class='hs-varop'>.</span><span class='hs-conid'>RenderMode</span>
<a name="line-28"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Graphics</span><span class='hs-varop'>.</span><span class='hs-conid'>Rendering</span><span class='hs-varop'>.</span><span class='hs-conid'>OpenGL</span><span class='hs-varop'>.</span><span class='hs-conid'>Raw</span><span class='hs-varop'>.</span><span class='hs-conid'>ARB</span><span class='hs-varop'>.</span><span class='hs-conid'>Compatibility</span> <span class='hs-layout'>(</span>
<a name="line-29"></a> <span class='hs-varid'>glSelectBuffer</span><span class='hs-layout'>,</span> <span class='hs-varid'>glInitNames</span><span class='hs-layout'>,</span> <span class='hs-varid'>glPushName</span><span class='hs-layout'>,</span> <span class='hs-varid'>glPopName</span><span class='hs-layout'>,</span> <span class='hs-varid'>glLoadName</span> <span class='hs-layout'>)</span>
<a name="line-30"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Graphics</span><span class='hs-varop'>.</span><span class='hs-conid'>Rendering</span><span class='hs-varop'>.</span><span class='hs-conid'>OpenGL</span><span class='hs-varop'>.</span><span class='hs-conid'>Raw</span><span class='hs-varop'>.</span><span class='hs-conid'>Core31</span>
<a name="line-31"></a>
<a name="line-32"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-33"></a>
<a name="line-34"></a><a name="HitRecord"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>HitRecord</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>HitRecord</span> <span class='hs-conid'>GLfloat</span> <span class='hs-conid'>GLfloat</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>Name</span><span class='hs-keyglyph'>]</span>
<a name="line-35"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Ord</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>)</span>
<a name="line-36"></a>
<a name="line-37"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-38"></a>
<a name="line-39"></a><a name="getHitRecords"></a><span class='hs-definition'>getHitRecords</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>GLsizei</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span><span class='hs-layout'>,</span> <span class='hs-conid'>Maybe</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>HitRecord</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span>
<a name="line-40"></a><span class='hs-definition'>getHitRecords</span> <span class='hs-varid'>bufSize</span> <span class='hs-varid'>action</span> <span class='hs-keyglyph'>=</span>
<a name="line-41"></a> <span class='hs-varid'>allocaArray</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>bufSize</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>buf</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
<a name="line-42"></a> <span class='hs-varid'>glSelectBuffer</span> <span class='hs-varid'>bufSize</span> <span class='hs-varid'>buf</span>
<a name="line-43"></a> <span class='hs-layout'>(</span><span class='hs-varid'>value</span><span class='hs-layout'>,</span> <span class='hs-varid'>numHits</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>withRenderMode</span> <span class='hs-conid'>Select</span> <span class='hs-varop'>$</span> <span class='hs-keyword'>do</span>
<a name="line-44"></a> <span class='hs-varid'>glInitNames</span>
<a name="line-45"></a> <span class='hs-varid'>action</span>
<a name="line-46"></a> <span class='hs-varid'>hits</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>parseSelectionBuffer</span> <span class='hs-varid'>numHits</span> <span class='hs-varid'>buf</span>
<a name="line-47"></a> <span class='hs-varid'>return</span> <span class='hs-layout'>(</span><span class='hs-varid'>value</span><span class='hs-layout'>,</span> <span class='hs-varid'>hits</span><span class='hs-layout'>)</span>
<a name="line-48"></a>
<a name="line-49"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-50"></a>
<a name="line-51"></a><a name="parseSelectionBuffer"></a><span class='hs-definition'>parseSelectionBuffer</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>GLint</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Ptr</span> <span class='hs-conid'>GLuint</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>HitRecord</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span>
<a name="line-52"></a><span class='hs-definition'>parseSelectionBuffer</span> <span class='hs-varid'>numHits</span> <span class='hs-varid'>buf</span>
<a name="line-53"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>numHits</span> <span class='hs-varop'><</span> <span class='hs-num'>0</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>return</span> <span class='hs-conid'>Nothing</span>
<a name="line-54"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fmap</span> <span class='hs-conid'>Just</span> <span class='hs-varop'>$</span> <span class='hs-varid'>evalIOState</span> <span class='hs-layout'>(</span><span class='hs-varid'>nTimes</span> <span class='hs-varid'>numHits</span> <span class='hs-varid'>parseSelectionHit</span><span class='hs-layout'>)</span> <span class='hs-varid'>buf</span>
<a name="line-55"></a>
<a name="line-56"></a><a name="Parser"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>Parser</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>IOState</span> <span class='hs-conid'>GLuint</span> <span class='hs-varid'>a</span>
<a name="line-57"></a>
<a name="line-58"></a><a name="parseSelectionHit"></a><span class='hs-definition'>parseSelectionHit</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Parser</span> <span class='hs-conid'>HitRecord</span>
<a name="line-59"></a><span class='hs-definition'>parseSelectionHit</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
<a name="line-60"></a> <span class='hs-varid'>numNames</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>parseGLuint</span>
<a name="line-61"></a> <span class='hs-varid'>minZ</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>parseGLfloat</span>
<a name="line-62"></a> <span class='hs-varid'>maxZ</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>parseGLfloat</span>
<a name="line-63"></a> <span class='hs-varid'>nameStack</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>nTimes</span> <span class='hs-varid'>numNames</span> <span class='hs-varid'>parseName</span>
<a name="line-64"></a> <span class='hs-varid'>return</span> <span class='hs-varop'>$</span> <span class='hs-conid'>HitRecord</span> <span class='hs-varid'>minZ</span> <span class='hs-varid'>maxZ</span> <span class='hs-varid'>nameStack</span>
<a name="line-65"></a>
<a name="line-66"></a><a name="parseGLuint"></a><span class='hs-definition'>parseGLuint</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Parser</span> <span class='hs-conid'>GLuint</span>
<a name="line-67"></a><span class='hs-definition'>parseGLuint</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>peekIOState</span>
<a name="line-68"></a>
<a name="line-69"></a><a name="parseGLfloat"></a><span class='hs-definition'>parseGLfloat</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Parser</span> <span class='hs-conid'>GLfloat</span>
<a name="line-70"></a><span class='hs-definition'>parseGLfloat</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fmap</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>x</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span> <span class='hs-varop'>/</span> <span class='hs-num'>0xffffffff</span><span class='hs-layout'>)</span> <span class='hs-varid'>parseGLuint</span>
<a name="line-71"></a>
<a name="line-72"></a><a name="parseName"></a><span class='hs-definition'>parseName</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Parser</span> <span class='hs-conid'>Name</span>
<a name="line-73"></a><span class='hs-definition'>parseName</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fmap</span> <span class='hs-conid'>Name</span> <span class='hs-varid'>parseGLuint</span>
<a name="line-74"></a>
<a name="line-75"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-76"></a>
<a name="line-77"></a><a name="Name"></a><span class='hs-keyword'>newtype</span> <span class='hs-conid'>Name</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Name</span> <span class='hs-conid'>GLuint</span>
<a name="line-78"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Ord</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>)</span>
<a name="line-79"></a>
<a name="line-80"></a><a name="withName"></a><span class='hs-definition'>withName</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Name</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span>
<a name="line-81"></a><span class='hs-definition'>withName</span> <span class='hs-layout'>(</span><span class='hs-conid'>Name</span> <span class='hs-varid'>name</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>bracket_</span> <span class='hs-layout'>(</span><span class='hs-varid'>glPushName</span> <span class='hs-varid'>name</span><span class='hs-layout'>)</span> <span class='hs-varid'>glPopName</span>
<a name="line-82"></a>
<a name="line-83"></a><a name="loadName"></a><span class='hs-definition'>loadName</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Name</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-84"></a><span class='hs-definition'>loadName</span> <span class='hs-layout'>(</span><span class='hs-conid'>Name</span> <span class='hs-varid'>n</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>glLoadName</span> <span class='hs-varid'>n</span>
<a name="line-85"></a>
<a name="line-86"></a><a name="maxNameStackDepth"></a><span class='hs-definition'>maxNameStackDepth</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>GettableStateVar</span> <span class='hs-conid'>GLsizei</span>
<a name="line-87"></a><span class='hs-definition'>maxNameStackDepth</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeGettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-varid'>getSizei1</span> <span class='hs-varid'>id</span> <span class='hs-conid'>GetMaxNameStackDepth</span><span class='hs-layout'>)</span>
<a name="line-88"></a>
<a name="line-89"></a><a name="nameStackDepth"></a><span class='hs-definition'>nameStackDepth</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>GettableStateVar</span> <span class='hs-conid'>GLsizei</span>
<a name="line-90"></a><span class='hs-definition'>nameStackDepth</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeGettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-varid'>getSizei1</span> <span class='hs-varid'>id</span> <span class='hs-conid'>GetNameStackDepth</span><span class='hs-layout'>)</span>
</pre></body>
</html>
|