Jason McKesson avatar Jason McKesson committed a311d99

Adding images to the introduction.

Comments (0)

Files changed (6)

Documents/Basics/GenNormDeviceCoord.lua

+require "SvgWriter"
+require "vmath"
+
+local imageWidth, imageHeight = 500, 500;
+
+local yAngle = math.rad(30);
+local zAngle = math.rad(10);
+
+local ySin, yCos = math.sin(yAngle), math.cos(yAngle);
+local zSin, zCos = math.sin(zAngle), math.cos(zAngle);
+
+local yMat = vmath.mat4(
+	vmath.vec4(yCos, 0, ySin, 0),
+	vmath.vec4(0, 1, 0, 0),
+	vmath.vec4(-ySin, 0, yCos, 0),
+	vmath.vec4(0, 0, 0, 1))
+	
+local zMat = vmath.mat4(
+	vmath.vec4(1, 0, 0, 0),
+	vmath.vec4(0, zCos, -zSin, 0),
+	vmath.vec4(0, zSin, zCos, 0),
+	vmath.vec4(0, 0, 0, 1))
+	
+local fullMat = zMat * yMat
+
+local function LocalTransform(listOfPoints)
+	local ret = {};
+	for i, point in ipairs(listOfPoints) do
+		ret[#ret + 1] = fullMat:Transform(point);
+	end
+	
+	return ret;
+end
+
+--Negate the Z to get into a left-handed system.
+local viewportMatrix = vmath.mat4(
+	vmath.vec4(imageWidth / 2, 0, 0, imageWidth / 2),
+	vmath.vec4(0, imageHeight / 2, 0, imageHeight / 2),
+	vmath.vec4(0, 0, 1, 0),
+	vmath.vec4(0, 0, 0, 1))
+
+local function ViewportTransform(listOfPoints)
+	local ret = {};
+	for i, point in ipairs(listOfPoints) do
+		ret[#ret + 1] = vmath.vec2(viewportMatrix:Transform(point));
+	end
+	
+	return ret;
+end
+
+local initialBoxPoints = {
+	vmath.vec3(0.5, 0.5, 0.5),
+	vmath.vec3(-0.5, 0.5, 0.5),
+	vmath.vec3(0.5, -0.5, 0.5),
+	vmath.vec3(-0.5, -0.5, 0.5),
+	vmath.vec3(0.5, 0.5, -0.5),
+	vmath.vec3(-0.5, 0.5, -0.5),
+	vmath.vec3(0.5, -0.5, -0.5),
+	vmath.vec3(-0.5, -0.5, -0.5),
+}
+
+local initialAxisPoints =
+{
+	vmath.vec3(0.5, 0.0, 0.0),
+	vmath.vec3(1.0, 0.0, 0.0),
+	
+	vmath.vec3(-0.5, 0.0, 0.0),
+	vmath.vec3(-1.0, 0.0, 0.0),
+	
+	vmath.vec3(0.0, 0.5, 0.0),
+	vmath.vec3(0.0, 1.0, 0.0),
+
+	vmath.vec3(0.0, -0.5, 0.0),
+	vmath.vec3(0.0, -1.0, 0.0),
+
+	vmath.vec3(0.0, 0.0, 0.5),
+	vmath.vec3(0.0, 0.0, 1.5),
+
+	vmath.vec3(0.0, 0.0, -0.5),
+	vmath.vec3(0.0, 0.0, -1.5),
+}
+
+local boxPoints = ViewportTransform(LocalTransform(initialBoxPoints));
+local axisPoints = ViewportTransform(LocalTransform(initialAxisPoints));
+
+
+local boxIndexList =
+{
+	{2, 4, 8, 6},
+	{1, 2, 6, 5},
+	{1, 2, 4, 3},
+
+	{1, 3, 7, 5},
+	{3, 4, 8, 7},
+	{5, 6, 8, 7},
+}
+
+local boxList = {}
+
+for i, box in ipairs(boxIndexList) do
+	boxList[i] = {
+		boxPoints[box[1]],
+		boxPoints[box[2]],
+		boxPoints[box[3]],
+		boxPoints[box[4]]}
+end
+
+local styleLib = SvgWriter.StyleLibrary();
+
+styleLib:AddStyle(nil, "black",
+	SvgWriter.Style():stroke("black"):stroke_width("1px"));
+	
+styleLib:AddStyle(nil, "dashed",
+	SvgWriter.Style():stroke_dasharray({3, 3}));
+	
+	
+styleLib:AddStyle(nil, "fill_black",
+	SvgWriter.Style():fill("black"));
+	
+styleLib:AddStyle(nil, "fill_transluscent",
+	SvgWriter.Style():fill("blue"):fill_opacity(0.1));
+
+styleLib:AddStyle(nil, "arrowended",
+	SvgWriter.Style():marker_end(SvgWriter.uriLocalElement("arrowhead")));
+
+local arrowheadPath = SvgWriter.Path();
+arrowheadPath:M{10, 4}:L{0, 0}:L{0, 8}:Z();
+
+
+	
+local writer = SvgWriter.SvgWriter("NormDeviceCoord.svg", {imageWidth .."px", imageHeight .. "px"});
+	writer:StyleLibrary(styleLib);
+	writer:BeginDefinitions();
+		writer:BeginMarker({10, 8}, {10, 4}, "auto", nil, nil, "arrowhead");
+			writer:Path(arrowheadPath, "black");
+		writer:EndMarker();
+	writer:EndDefinitions();
+
+	--Draw the rear-most lines, with markers.
+	writer:Line(axisPoints[3], axisPoints[4], {"black", "arrowended"});
+	writer:Line(axisPoints[7], axisPoints[8], {"black", "arrowended"});
+	writer:Line(axisPoints[9], axisPoints[10], {"black", "arrowended"});
+	
+	--Draw the rear-most box sides.
+	writer:Polygon(boxList[1], {"black", "fill_transluscent"});
+	writer:Polygon(boxList[2], {"black", "fill_transluscent"});
+	writer:Polygon(boxList[3], {"black", "fill_transluscent"});
+	
+	--Draw the internal lines, no markers.
+	writer:Line(axisPoints[1], axisPoints[3], {"black", "dashed"});
+	writer:Line(axisPoints[5], axisPoints[7], {"black", "dashed"});
+	writer:Line(axisPoints[9], axisPoints[11], {"black", "dashed"});
+	
+	--Draw the front-most boxes.
+	writer:Polygon(boxList[4], {"black", "fill_transluscent"});
+	writer:Polygon(boxList[5], {"black", "fill_transluscent"});
+	writer:Polygon(boxList[6], {"black", "fill_transluscent"});
+	
+	--Draw the front-most lines, with markers.
+	writer:Line(axisPoints[1], axisPoints[2], {"black", "arrowended"});
+	writer:Line(axisPoints[5], axisPoints[6], {"black", "arrowended"});
+	writer:Line(axisPoints[11], axisPoints[12], {"black", "arrowended"});
+	
+writer:Close();
+
+
+
Add a comment to this file

Documents/Basics/LargeImage.png

Added
New image
Add a comment to this file

Documents/Basics/NormDeviceCoord.svg

Added
New image
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" height="500px" width="500px" >
+	<style type="text/css" ><![CDATA[.fill_black
+{
+	fill: black;
+}
+
+.black
+{
+	stroke-width: 1px;
+	stroke: black;
+}
+
+.fill_transluscent
+{
+	fill-opacity: 0.1;
+	fill: blue;
+}
+
+.dashed
+{
+	stroke-dasharray: 3,3;
+}
+
+.arrowended
+{
+	marker-end: url(#arrowhead);
+}]]></style>
+	<defs >
+		<marker markerWidth="10" markerHeight="8" refX="10" refY="4" markerUnits="strokeWidth" orient="auto" id="arrowhead" >
+			<path d="M 10 4 L 0 0 L 0 8 Z" class="black" />
+		</marker>
+	</defs>
+	<line x2="33.49364905389" y2="228.29397779163" y1="239.14698889582" x1="141.74682452695" class="black arrowended" />
+	<line x2="250" y2="3.798061746948" y1="126.89903087347" x1="250" class="black arrowended" />
+	<line x2="437.5" y2="193.60610005734" y1="231.20203335245" x1="312.5" class="black arrowended" />
+	<polygon points="204.24682452695,343.44999137479 204.24682452695,97.248053121736 79.246824526945,134.84398641685 79.246824526945,381.0459246699" class="black fill_transluscent" />
+	<polygon points="420.75317547305,365.15601358315 204.24682452695,343.44999137479 79.246824526945,381.0459246699 295.75317547305,402.75194687826" class="black fill_transluscent" />
+	<polygon points="420.75317547305,365.15601358315 204.24682452695,343.44999137479 204.24682452695,97.248053121736 420.75317547305,118.9540753301" class="black fill_transluscent" />
+	<line x2="141.74682452695" y2="239.14698889582" y1="260.85301110418" x1="358.25317547305" class="black dashed" />
+	<line x2="250" y2="126.89903087347" y1="373.10096912653" x1="250" class="black dashed" />
+	<line x2="187.5" y2="268.79796664755" y1="231.20203335245" x1="312.5" class="black dashed" />
+	<polygon points="420.75317547305,365.15601358315 420.75317547305,118.9540753301 295.75317547305,156.55000862521 295.75317547305,402.75194687826" class="black fill_transluscent" />
+	<polygon points="420.75317547305,118.9540753301 204.24682452695,97.248053121736 79.246824526945,134.84398641685 295.75317547305,156.55000862521" class="black fill_transluscent" />
+	<polygon points="295.75317547305,402.75194687826 79.246824526945,381.0459246699 79.246824526945,134.84398641685 295.75317547305,156.55000862521" class="black fill_transluscent" />
+	<line x2="466.50635094611" y2="271.70602220837" y1="260.85301110418" x1="358.25317547305" class="black arrowended" />
+	<line x2="250" y2="496.20193825305" y1="373.10096912653" x1="250" class="black arrowended" />
+	<line x2="62.5" y2="306.39389994266" y1="268.79796664755" x1="187.5" class="black arrowended" />
+</svg>
Add a comment to this file

Documents/Basics/SmallImage.png

Added
New image

Documents/Basics/Tutorial 00.xml

             you are reading this on an electronic display device, rather than a printout) is simply
             a two-dimensional array of pixels. If you take a screenshot of something on your screen,
             and blow it up, it will look very blocky.</para>
-        <!--TODO: Add an image of blocky pixels here.-->
+        <example>
+            <title>An Image</title>
+            <mediaobject>
+                <imageobject>
+                    <imagedata fileref="pixels.svg"/>
+                </imageobject>
+            </mediaobject>
+        </example>
         <para>Each of these blocks is a <glossterm>pixel</glossterm>. The word <quote>pixel</quote>
             is derived from the term <quote><acronym>Pic</acronym>ture
                 <acronym>El</acronym>ement</quote>. Every pixel on your screen has a particular
                 its own clip space.</para>
             <para>In clip space, the positive X direction is to the right, the positive Y direction
                 is up, and the positive Z direction is away from the viewer.</para>
-            <!--TODO: Add an image of clip space here.-->
             <para>The process of transforming vertices into clip space is quite arbitrary. OpenGL
                 provides a lot of flexibility in this step. We will cover this step in detail
                 throughout the tutorials.</para>
             </formalpara>
             <para>This process is very simple. The X, Y, and Z of each vertex's position is divided
                 by W to get normalized device coordinates. That is all.</para>
-            <para>Therefore, the space of normalized device coordinates is essentially just clip
-                space, except that the range of X, Y and Z are [-1, 1]. The directions are all the
-                same. The division by W is an important part of projecting 3D triangles onto 2D
-                images, but we will cover that in a future tutorial.</para>
+            <para>The space of normalized device coordinates is essentially just clip space, except
+                that the range of X, Y and Z are [-1, 1]. The directions are all the same. The
+                division by W is an important part of projecting 3D triangles onto 2D images, but we
+                will cover that in a future tutorial.</para>
+            <example>
+                <title>Normalized Device Coordinate Space</title>
+            </example>
+            <para>The cube indicates the boundaries of normalized device coordinate space.</para>
             <formalpara>
                 <title>Window Transformation</title>
                 <para>The next phase of rasterization is to transform the vertices of each triangle
             <para>The API, in C, is defined by a number of typedefs, #defined enumerator values, and
                 functions. The typedefs define basic GL types like <type>GLint</type>,
                     <type>GLfloat</type> and so forth.</para>
-            <para xml:id="OpenGLObjects">Complex aggregates like structs are never directly exposed in OpenGL. Any such
-                constructs are hidden behind the API. This makes it easier to expose the OpenGL API
-                to non-C languages without having a complex conversion layer.</para>
+            <para xml:id="OpenGLObjects">Complex aggregates like structs are never directly exposed
+                in OpenGL. Any such constructs are hidden behind the API. This makes it easier to
+                expose the OpenGL API to non-C languages without having a complex conversion
+                layer.</para>
             <para>In C++, if you wanted an object that contained an integer, a float, and a string,
                 you would create it and access it like this:</para>
             <programlisting>struct Object
Added
New image
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
+    version="1.1" height="308px" width="472px" >
+    <style type="text/css"><![CDATA[
+line
+{
+    stroke-width: 1px;
+    stroke: black;
+}
+]]></style>
+    <image xlink:href="smallimage.png" x="0" y="132" width="46" height="44"/>
+    <image xlink:href="largeimage.png" x="150" y="0" width="322" height="308"/>
+</svg>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.